Commit 31b1b13c authored by Dan Harrington's avatar Dan Harrington Committed by Commit Bot

More small fixes before moving the feed code

This fixes various problems we'll have moving
the feed code into chromium. Most are lint/warning
fixes.

Bug: 1024945
Change-Id: Ib3e8a0085faf7c465ceb6525d9825d217c1ce496
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931436
Commit-Queue: Dan H <harringtond@chromium.org>
Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718855}
parent d6f63893
...@@ -50,7 +50,7 @@ class ConsumerSyncWrapper<T> implements Consumer<T> { ...@@ -50,7 +50,7 @@ class ConsumerSyncWrapper<T> implements Consumer<T> {
* @param operation The operation that should feed its result to the consumer. * @param operation The operation that should feed its result to the consumer.
* @param timeoutMs The timeout in milliseconds to wait for operation to execute * @param timeoutMs The timeout in milliseconds to wait for operation to execute
*/ */
static public <T> void waitForConsumer( public static <T> void waitForConsumer(
Consumer<T> consumer, Consumer<Consumer<T>> operation, long timeoutMs) { Consumer<T> consumer, Consumer<Consumer<T>> operation, long timeoutMs) {
ConsumerSyncWrapper<T> wrapper = new ConsumerSyncWrapper<>(consumer); ConsumerSyncWrapper<T> wrapper = new ConsumerSyncWrapper<>(consumer);
PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> operation.accept(wrapper)); PostTask.postTask(UiThreadTaskTraits.DEFAULT, () -> operation.accept(wrapper));
......
...@@ -11,8 +11,8 @@ import com.google.android.libraries.feed.sharedstream.publicapi.scroll.ScrollObs ...@@ -11,8 +11,8 @@ import com.google.android.libraries.feed.sharedstream.publicapi.scroll.ScrollObs
import com.google.android.libraries.feed.sharedstream.publicapi.scroll.ScrollObserver; import com.google.android.libraries.feed.sharedstream.publicapi.scroll.ScrollObserver;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* Monitors and dispatches scroll events to the registered listeners. * Monitors and dispatches scroll events to the registered listeners.
...@@ -29,7 +29,7 @@ public class BasicStreamScrollMonitor ...@@ -29,7 +29,7 @@ public class BasicStreamScrollMonitor
public BasicStreamScrollMonitor(Clock clock) { public BasicStreamScrollMonitor(Clock clock) {
this.mClock = clock; this.mClock = clock;
mScrollObservers = Collections.newSetFromMap(new ConcurrentHashMap<>()); mScrollObservers = Collections.newSetFromMap(Collections.synchronizedMap(new HashMap<>()));
} }
@Override @Override
......
...@@ -12,7 +12,6 @@ import com.google.android.libraries.feed.common.concurrent.MainThreadRunner; ...@@ -12,7 +12,6 @@ import com.google.android.libraries.feed.common.concurrent.MainThreadRunner;
import com.google.android.libraries.feed.common.time.testing.FakeClock; import com.google.android.libraries.feed.common.time.testing.FakeClock;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.PriorityQueue; import java.util.PriorityQueue;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
...@@ -28,10 +27,8 @@ public final class FakeMainThreadRunner extends MainThreadRunner { ...@@ -28,10 +27,8 @@ public final class FakeMainThreadRunner extends MainThreadRunner {
private final List<Runnable> mTasksToRun = new ArrayList<>(); private final List<Runnable> mTasksToRun = new ArrayList<>();
private final boolean mShouldQueueTasks; private final boolean mShouldQueueTasks;
// Suppressing use of Comparator, which is fine because this is only used in tests. private final PriorityQueue<TimedRunnable> mDelayedTasks = new PriorityQueue<>(
@SuppressWarnings("AndroidJdkLibsChecker") 1, (a, b) -> Long.compare(a.getExecutionTime(), b.getExecutionTime()));
private final PriorityQueue<TimedRunnable> mDelayedTasks =
new PriorityQueue<>(Comparator.comparingLong(TimedRunnable::getExecutionTime));
private int mCompletedTaskCount; private int mCompletedTaskCount;
......
...@@ -1071,7 +1071,7 @@ public final class FeedModelProvider ...@@ -1071,7 +1071,7 @@ public final class FeedModelProvider
@VisibleForTesting @VisibleForTesting
final class TokenMutation extends MutationHandler { final class TokenMutation extends MutationHandler {
private final StreamToken mMutationSourceToken; private final StreamToken mMutationSourceToken;
/*@Nullable*/ TokenTracking mToken = null; /*@Nullable*/ TokenTracking mToken;
int mNewCursorStart = -1; int mNewCursorStart = -1;
TokenMutation(StreamToken mutationSourceToken) { TokenMutation(StreamToken mutationSourceToken) {
......
...@@ -45,16 +45,19 @@ public final class FeatureChangeImpl implements FeatureChange { ...@@ -45,16 +45,19 @@ public final class FeatureChangeImpl implements FeatureChange {
} }
/** Returns {@code true} if the ModelFeature changed. */ /** Returns {@code true} if the ModelFeature changed. */
@Override
public boolean isFeatureChanged() { public boolean isFeatureChanged() {
return mFeatureChanged; return mFeatureChanged;
} }
/** Returns the ModelFeature that was changed. */ /** Returns the ModelFeature that was changed. */
@Override
public ModelFeature getModelFeature() { public ModelFeature getModelFeature() {
return mModelFeature; return mModelFeature;
} }
/** Returns the structural changes to the ModelFeature. */ /** Returns the structural changes to the ModelFeature. */
@Override
public ChildChanges getChildChanges() { public ChildChanges getChildChanges() {
return mChildChanges; return mChildChanges;
} }
......
...@@ -428,7 +428,7 @@ public final class FeedRequestManagerImpl implements FeedRequestManager { ...@@ -428,7 +428,7 @@ public final class FeedRequestManagerImpl implements FeedRequestManager {
private ClientInfo buildClientInfo() { private ClientInfo buildClientInfo() {
ClientInfo.Builder clientInfoBuilder = ClientInfo.newBuilder(); ClientInfo.Builder clientInfoBuilder = ClientInfo.newBuilder();
clientInfoBuilder.setPlatformType(PlatformType.ANDROID); clientInfoBuilder.setPlatformType(PlatformType.ANDROID_ID);
clientInfoBuilder.setPlatformVersion(getPlatformVersion()); clientInfoBuilder.setPlatformVersion(getPlatformVersion());
clientInfoBuilder.setLocale(LocaleUtils.getLanguageTag(mContext)); clientInfoBuilder.setLocale(LocaleUtils.getLanguageTag(mContext));
clientInfoBuilder.setAppType(Utils.convertAppType(mApplicationInfo.getAppType())); clientInfoBuilder.setAppType(Utils.convertAppType(mApplicationInfo.getAppType()));
......
...@@ -9,8 +9,9 @@ import com.google.android.libraries.feed.common.logging.Dumper; ...@@ -9,8 +9,9 @@ import com.google.android.libraries.feed.common.logging.Dumper;
import com.google.android.libraries.feed.common.logging.Logger; import com.google.android.libraries.feed.common.logging.Logger;
import com.google.search.now.feed.client.StreamDataProto.StreamPayload; import com.google.search.now.feed.client.StreamDataProto.StreamPayload;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* In order to support optimistic writes, the cache must store the payloads for the full duration of * In order to support optimistic writes, the cache must store the payloads for the full duration of
...@@ -32,7 +33,7 @@ public final class ContentCache implements Dumpable { ...@@ -32,7 +33,7 @@ public final class ContentCache implements Dumpable {
private int mMutationsCount; private int mMutationsCount;
public ContentCache() { public ContentCache() {
mMutationCache = new ConcurrentHashMap<>(); mMutationCache = Collections.synchronizedMap(new HashMap<>());
} }
/** /**
......
...@@ -213,7 +213,7 @@ public final class SessionManagerMutation implements Dumpable { ...@@ -213,7 +213,7 @@ public final class SessionManagerMutation implements Dumpable {
private final BasicLoggingApi mBasicLoggingApi; private final BasicLoggingApi mBasicLoggingApi;
@VisibleForTesting @VisibleForTesting
boolean mClearedHead = false; boolean mClearedHead;
private Model mModel; private Model mModel;
private MutationCommitter(String task, MutationContext mutationContext, private MutationCommitter(String task, MutationContext mutationContext,
......
...@@ -66,11 +66,10 @@ public class MediaQueryHelper { ...@@ -66,11 +66,10 @@ public class MediaQueryHelper {
return mFrameWidthPx < targetWidth; return mFrameWidthPx < targetWidth;
case NOT_EQUALS: case NOT_EQUALS:
return mFrameWidthPx != targetWidth; return mFrameWidthPx != targetWidth;
default:
throw new PietFatalException(ErrorCode.ERR_INVALID_MEDIA_QUERY_CONDITION,
String.format("Unhandled ComparisonCondition: %s",
condition.getFrameWidth().getCondition().name()));
} }
throw new PietFatalException(ErrorCode.ERR_INVALID_MEDIA_QUERY_CONDITION,
String.format("Unhandled ComparisonCondition: %s",
condition.getFrameWidth().getCondition().name()));
case ORIENTATION: case ORIENTATION:
switch (condition.getOrientation().getOrientation()) { switch (condition.getOrientation().getOrientation()) {
case LANDSCAPE: case LANDSCAPE:
......
...@@ -26,7 +26,7 @@ public class GridRowView extends LinearLayout { ...@@ -26,7 +26,7 @@ public class GridRowView extends LinearLayout {
// parent is wider than the space required by the GridRowView. // parent is wider than the space required by the GridRowView.
// This is the analogue of LinearLayout.mTotalLength // This is the analogue of LinearLayout.mTotalLength
@VisibleForTesting @VisibleForTesting
int mTotalContentWidth = 0; int mTotalContentWidth;
// Copied from LinearLayout. // Copied from LinearLayout.
private int mViewGravity = Gravity.START | Gravity.TOP; private int mViewGravity = Gravity.START | Gravity.TOP;
......
...@@ -6,6 +6,7 @@ package com.google.android.libraries.feed.piet.ui; ...@@ -6,6 +6,7 @@ package com.google.android.libraries.feed.piet.ui;
import static com.google.android.libraries.feed.common.Validators.checkState; import static com.google.android.libraries.feed.common.Validators.checkState;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Outline; import android.graphics.Outline;
...@@ -138,6 +139,7 @@ public class RoundedCornerWrapperView extends FrameLayout { ...@@ -138,6 +139,7 @@ public class RoundedCornerWrapperView extends FrameLayout {
mRoundingDelegate.initializeForView(this); mRoundingDelegate.initializeForView(this);
} }
@TargetApi(VERSION_CODES.LOLLIPOP)
private void setupOutlineProvider() { private void setupOutlineProvider() {
if (mHasRoundedCorners) { if (mHasRoundedCorners) {
super.setOutlineProvider(new ViewOutlineProvider() { super.setOutlineProvider(new ViewOutlineProvider() {
...@@ -203,6 +205,7 @@ public class RoundedCornerWrapperView extends FrameLayout { ...@@ -203,6 +205,7 @@ public class RoundedCornerWrapperView extends FrameLayout {
* strategy requires manipulating the {@link Canvas}, which the delegate handles. * strategy requires manipulating the {@link Canvas}, which the delegate handles.
*/ */
@Override @Override
@SuppressWarnings("MissingSuperCall")
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
mDrawSuperCalled = false; mDrawSuperCalled = false;
mRoundingDelegate.draw(this, canvas); mRoundingDelegate.draw(this, canvas);
......
...@@ -8,7 +8,7 @@ import com.google.android.libraries.feed.api.internal.modelprovider.ModelProvide ...@@ -8,7 +8,7 @@ import com.google.android.libraries.feed.api.internal.modelprovider.ModelProvide
/** Fake implementation of {@link ViewDepthProvider}. */ /** Fake implementation of {@link ViewDepthProvider}. */
public final class FakeViewDepthProvider implements ViewDepthProvider { public final class FakeViewDepthProvider implements ViewDepthProvider {
/*@Nullable*/ private String mChildViewDepth = null; /*@Nullable*/ private String mChildViewDepth;
public FakeViewDepthProvider() {} public FakeViewDepthProvider() {}
......
...@@ -20,7 +20,7 @@ option java_outer_classname = "ClientInfoProto"; ...@@ -20,7 +20,7 @@ option java_outer_classname = "ClientInfoProto";
message ClientInfo { message ClientInfo {
enum PlatformType { enum PlatformType {
UNKNOWN_PLATFORM = 0; UNKNOWN_PLATFORM = 0;
ANDROID = 1; ANDROID_ID = 1;
IOS = 2; IOS = 2;
} }
......
...@@ -732,7 +732,7 @@ public class FeedRequestManagerImplTest { ...@@ -732,7 +732,7 @@ public class FeedRequestManagerImplTest {
FeedQuery.RequestReason.SCHEDULED_REFRESH)) FeedQuery.RequestReason.SCHEDULED_REFRESH))
.setClientInfo( .setClientInfo(
ClientInfo.newBuilder() ClientInfo.newBuilder()
.setPlatformType(PlatformType.ANDROID) .setPlatformType(PlatformType.ANDROID_ID)
.setPlatformVersion( .setPlatformVersion(
Version.newBuilder() Version.newBuilder()
.setMajor(7) .setMajor(7)
...@@ -830,7 +830,7 @@ public class FeedRequestManagerImplTest { ...@@ -830,7 +830,7 @@ public class FeedRequestManagerImplTest {
.setConsistencyToken(ConsistencyToken.getDefaultInstance()) .setConsistencyToken(ConsistencyToken.getDefaultInstance())
.setClientInfo( .setClientInfo(
ClientInfo.newBuilder() ClientInfo.newBuilder()
.setPlatformType(PlatformType.ANDROID) .setPlatformType(PlatformType.ANDROID_ID)
.setPlatformVersion(Version.newBuilder() .setPlatformVersion(Version.newBuilder()
.setMajor(4) .setMajor(4)
.setMinor(4) .setMinor(4)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment