Merge "Only register RecentTasksChangedListener if flag is enabled" into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 800c594..18becbb 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -814,11 +814,6 @@
      */
     public void setUIController(@NonNull TaskbarUIController uiController) {
         mControllers.setUiController(uiController);
-        if (mControllers.bubbleControllers.isEmpty()) {
-            // if the bubble bar was visible in a previous configuration of taskbar and is being
-            // recreated now without bubbles, clean up any bubble bar adjustments from hotseat
-            bubbleBarVisibilityChanged(/* isVisible= */ false);
-        }
     }
 
     /**
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
index 186c453..f4d3695 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumer.java
@@ -27,6 +27,8 @@
 import android.view.MotionEvent;
 import android.view.ViewConfiguration;
 
+import androidx.annotation.VisibleForTesting;
+
 import com.android.launcher3.Utilities;
 import com.android.launcher3.logging.StatsLogManager;
 import com.android.launcher3.util.DisplayController;
@@ -48,7 +50,7 @@
     private static final boolean DEBUG_NAV_HANDLE = Utilities.isPropertyEnabled(
             NAV_HANDLE_LONG_PRESS);
 
-    private final NavHandleLongPressHandler mNavHandleLongPressHandler;
+    private NavHandleLongPressHandler mNavHandleLongPressHandler;
     private final float mNavHandleWidth;
     private final float mScreenWidth;
 
@@ -265,4 +267,9 @@
     protected String getDelegatorName() {
         return "NavHandleLongPressInputConsumer";
     }
+
+    @VisibleForTesting
+    void setNavHandleLongPressHandler(NavHandleLongPressHandler navHandleLongPressHandler) {
+        mNavHandleLongPressHandler = navHandleLongPressHandler;
+    }
 }
diff --git a/quickstep/src/com/android/quickstep/util/DeviceConfigHelper.kt b/quickstep/src/com/android/quickstep/util/DeviceConfigHelper.kt
index d36dc7e..2dd727e 100644
--- a/quickstep/src/com/android/quickstep/util/DeviceConfigHelper.kt
+++ b/quickstep/src/com/android/quickstep/util/DeviceConfigHelper.kt
@@ -26,19 +26,21 @@
 import androidx.annotation.WorkerThread
 import com.android.launcher3.BuildConfig
 import com.android.launcher3.util.Executors
+import java.util.concurrent.CopyOnWriteArrayList
 
 /** Utility class to manage a set of device configurations */
 class DeviceConfigHelper<ConfigType>(private val factory: (PropReader) -> ConfigType) {
 
     var config: ConfigType
         private set
+
     private val allKeys: Set<String>
     private val propertiesListener = OnPropertiesChangedListener { onDevicePropsChanges(it) }
     private val sharedPrefChangeListener = OnSharedPreferenceChangeListener { _, _ ->
         recreateConfig()
     }
 
-    private val changeListeners = mutableListOf<Runnable>()
+    private val changeListeners = CopyOnWriteArrayList<Runnable>()
 
     init {
         // Initialize the default config once.
diff --git a/quickstep/tests/src/com/android/launcher3/model/QuickstepModelDelegateTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/model/QuickstepModelDelegateTest.kt
similarity index 79%
rename from quickstep/tests/src/com/android/launcher3/model/QuickstepModelDelegateTest.kt
rename to quickstep/tests/multivalentTests/src/com/android/launcher3/model/QuickstepModelDelegateTest.kt
index a532762..0005df6 100644
--- a/quickstep/tests/src/com/android/launcher3/model/QuickstepModelDelegateTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/model/QuickstepModelDelegateTest.kt
@@ -1,3 +1,18 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.android.launcher3.model
 
 import android.app.prediction.AppPredictor
@@ -19,7 +34,7 @@
 import org.mockito.Mock
 import org.mockito.Mockito.never
 import org.mockito.Mockito.verify
-import org.mockito.Mockito.verifyZeroInteractions
+import org.mockito.Mockito.verifyNoMoreInteractions
 import org.mockito.MockitoAnnotations
 
 /** Unit tests for [QuickstepModelDelegate]. */
@@ -57,25 +72,25 @@
         underTest.onAppTargetEvent(mockedAppTargetEvent, CONTAINER_PREDICTION)
 
         verify(allAppsPredictor).notifyAppTargetEvent(mockedAppTargetEvent)
-        verifyZeroInteractions(hotseatPredictor)
-        verifyZeroInteractions(widgetRecommendationPredictor)
+        verifyNoMoreInteractions(hotseatPredictor)
+        verifyNoMoreInteractions(widgetRecommendationPredictor)
     }
 
     @Test
     fun onWidgetPrediction_notifyWidgetRecommendationPredictor() {
         underTest.onAppTargetEvent(mockedAppTargetEvent, CONTAINER_WIDGETS_PREDICTION)
 
-        verifyZeroInteractions(allAppsPredictor)
+        verifyNoMoreInteractions(allAppsPredictor)
         verify(widgetRecommendationPredictor).notifyAppTargetEvent(mockedAppTargetEvent)
-        verifyZeroInteractions(hotseatPredictor)
+        verifyNoMoreInteractions(hotseatPredictor)
     }
 
     @Test
     fun onHotseatPrediction_notifyHotseatPredictor() {
         underTest.onAppTargetEvent(mockedAppTargetEvent, CONTAINER_HOTSEAT_PREDICTION)
 
-        verifyZeroInteractions(allAppsPredictor)
-        verifyZeroInteractions(widgetRecommendationPredictor)
+        verifyNoMoreInteractions(allAppsPredictor)
+        verifyNoMoreInteractions(widgetRecommendationPredictor)
         verify(hotseatPredictor).notifyAppTargetEvent(mockedAppTargetEvent)
     }
 
@@ -83,8 +98,8 @@
     fun onOtherClient_notifyHotseatPredictor() {
         underTest.onAppTargetEvent(mockedAppTargetEvent, CONTAINER_WALLPAPERS)
 
-        verifyZeroInteractions(allAppsPredictor)
-        verifyZeroInteractions(widgetRecommendationPredictor)
+        verifyNoMoreInteractions(allAppsPredictor)
+        verifyNoMoreInteractions(widgetRecommendationPredictor)
         verify(hotseatPredictor).notifyAppTargetEvent(mockedAppTargetEvent)
     }
 
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
new file mode 100644
index 0000000..679a208
--- /dev/null
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
@@ -0,0 +1,298 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.quickstep.inputconsumers;
+
+import static android.view.MotionEvent.ACTION_CANCEL;
+import static android.view.MotionEvent.ACTION_DOWN;
+import static android.view.MotionEvent.ACTION_HOVER_ENTER;
+import static android.view.MotionEvent.ACTION_MOVE;
+import static android.view.MotionEvent.ACTION_UP;
+
+import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.os.SystemClock;
+import android.view.MotionEvent;
+import android.view.ViewConfiguration;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.filters.SmallTest;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.MainThreadInitializedObject.SandboxContext;
+import com.android.quickstep.GestureState;
+import com.android.quickstep.InputConsumer;
+import com.android.quickstep.NavHandle;
+import com.android.quickstep.RecentsAnimationDeviceState;
+import com.android.quickstep.TopTaskTracker;
+import com.android.systemui.shared.system.InputMonitorCompat;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class NavHandleLongPressInputConsumerTest {
+
+    private static final float TOUCH_SLOP = 10;
+    private static final float SQUARED_TOUCH_SLOP = 100;
+
+    private final AtomicBoolean mLongPressTriggered = new AtomicBoolean();
+    private NavHandleLongPressInputConsumer mUnderTest;
+    private float mScreenWidth;
+    @Mock InputConsumer mDelegate;
+    @Mock InputMonitorCompat mInputMonitor;
+    @Mock RecentsAnimationDeviceState mDeviceState;
+    @Mock NavHandle mNavHandle;
+    @Mock GestureState mGestureState;
+    @Mock NavHandleLongPressHandler mNavHandleLongPressHandler;
+    @Mock TopTaskTracker mTopTaskTracker;
+    @Mock TopTaskTracker.CachedTaskInfo mTaskInfo;
+
+    @Before
+    public void setup() {
+        MockitoAnnotations.initMocks(this);
+        when(mTopTaskTracker.getCachedTopTask(anyBoolean())).thenReturn(mTaskInfo);
+        when(mDeviceState.getSquaredTouchSlop()).thenReturn(SQUARED_TOUCH_SLOP);
+        when(mDelegate.allowInterceptByParent()).thenReturn(true);
+        mLongPressTriggered.set(false);
+        when(mNavHandleLongPressHandler.getLongPressRunnable(any())).thenReturn(
+                () -> mLongPressTriggered.set(true));
+        SandboxContext context = new SandboxContext(getApplicationContext());
+        context.putObject(TopTaskTracker.INSTANCE, mTopTaskTracker);
+        mScreenWidth = DisplayController.INSTANCE.get(context).getInfo().currentSize.x;
+        mUnderTest = new NavHandleLongPressInputConsumer(context, mDelegate, mInputMonitor,
+                mDeviceState, mNavHandle, mGestureState);
+        mUnderTest.setNavHandleLongPressHandler(mNavHandleLongPressHandler);
+    }
+
+    @Test
+    public void testGetType() {
+        assertThat(mUnderTest.getType() & InputConsumer.TYPE_NAV_HANDLE_LONG_PRESS).isNotEqualTo(0);
+    }
+
+    @Test
+    public void testDelegateDisallowsTouchIntercept() {
+        when(mDelegate.allowInterceptByParent()).thenReturn(false);
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+
+        verify(mDelegate).onMotionEvent(any());
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        verify(mNavHandleLongPressHandler, never()).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, never()).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testDelegateDisallowsTouchInterceptAfterTouchDown() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+
+        // Delegate should still get touches unless long press is triggered.
+        verify(mDelegate).onMotionEvent(any());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, never()).onTouchFinished(any(), any());
+
+        when(mDelegate.allowInterceptByParent()).thenReturn(false);
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_MOVE));
+
+        // Delegate should still get motion events unless long press is triggered.
+        verify(mDelegate, times(2)).onMotionEvent(any());
+        // But our handler should be cancelled.
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testLongPressTriggered() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
+        assertTrue(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, never()).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testLongPressTriggeredWithSlightVerticalMovement() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+        mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE,
+                -(TOUCH_SLOP - 1)));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
+        assertTrue(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, never()).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testLongPressTriggeredWithSlightHorizontalMovement() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+        mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
+                mScreenWidth / 2f - (TOUCH_SLOP - 1), 0));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
+        assertTrue(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, never()).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testLongPressAbortedByTouchUp() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_UP));
+        // Wait past the long press timeout, to be extra sure it wouldn't have triggered.
+        SystemClock.sleep(20);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testLongPressAbortedByTouchCancel() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_CANCEL));
+        // Wait past the long press timeout, to be extra sure it wouldn't have triggered.
+        SystemClock.sleep(20);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testLongPressAbortedByTouchSlopPassedVertically() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+
+        mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE,
+                -(TOUCH_SLOP + 1)));
+        // Wait past the long press timeout, to be extra sure it wouldn't have triggered.
+        SystemClock.sleep(20);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testLongPressAbortedByTouchSlopPassedHorizontally() {
+        mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout() - 10);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+
+        mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
+                mScreenWidth / 2f - (TOUCH_SLOP + 1), 0));
+        // Wait past the long press timeout, to be extra sure it wouldn't have triggered.
+        SystemClock.sleep(20);
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, times(1)).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testTouchOutsideNavHandleIgnored() {
+        // Touch the far left side of the screen. (y=0 is top of navbar region, picked arbitrarily)
+        mUnderTest.onMotionEvent(generateMotionEvent(ACTION_DOWN, 0, 0));
+        SystemClock.sleep(ViewConfiguration.getLongPressTimeout());
+        InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+
+        // Should be ignored because the x position was not centered in the navbar region.
+        assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
+        assertFalse(mLongPressTriggered.get());
+        verify(mNavHandleLongPressHandler, never()).onTouchStarted(any());
+        verify(mNavHandleLongPressHandler, never()).onTouchFinished(any(), any());
+    }
+
+    @Test
+    public void testHoverPassedToDelegate() {
+        // Regardless of whether the delegate wants us to intercept, we tell it about hover events.
+        when(mDelegate.allowInterceptByParent()).thenReturn(false);
+        mUnderTest.onHoverEvent(generateCenteredMotionEvent(ACTION_HOVER_ENTER));
+
+        verify(mDelegate).onHoverEvent(any());
+
+        when(mDelegate.allowInterceptByParent()).thenReturn(true);
+        mUnderTest.onHoverEvent(generateCenteredMotionEvent(ACTION_HOVER_ENTER));
+
+        verify(mDelegate, times(2)).onHoverEvent(any());
+    }
+
+    /** Generate a motion event centered horizontally in the screen. */
+    private MotionEvent generateCenteredMotionEvent(int motionAction) {
+        return generateCenteredMotionEventWithYOffset(motionAction, 0);
+    }
+
+    /** Generate a motion event centered horizontally in the screen, with y offset. */
+    private MotionEvent generateCenteredMotionEventWithYOffset(int motionAction, float y) {
+        return generateMotionEvent(motionAction, mScreenWidth / 2f, y);
+    }
+
+    private static MotionEvent generateMotionEvent(int motionAction, float x, float y) {
+        return MotionEvent.obtain(0, 0, motionAction, x, y, 0);
+    }
+}
diff --git a/tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java b/tests/multivalentTests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java
similarity index 95%
rename from tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java
rename to tests/multivalentTests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java
index 260f556..6cfa6ee 100644
--- a/tests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java
+++ b/tests/multivalentTests/src/com/android/launcher3/touch/SingleAxisSwipeDetectorTest.java
@@ -22,9 +22,9 @@
 import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;
 
 import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyBoolean;
-import static org.mockito.Matchers.anyFloat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
+import static org.mockito.ArgumentMatchers.anyFloat;
 import static org.mockito.Mockito.doAnswer;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.never;
@@ -41,6 +41,8 @@
 
 import com.android.launcher3.testcomponent.TouchEventGenerator;
 
+import com.google.errorprone.annotations.FormatMethod;
+
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -52,7 +54,8 @@
 public class SingleAxisSwipeDetectorTest {
 
     private static final String TAG = SingleAxisSwipeDetectorTest.class.getSimpleName();
-    public static void L(String s, Object... parts) {
+    @FormatMethod
+    public static void logD(String s, Object... parts) {
         Log.d(TAG, (parts.length == 0) ? s : String.format(s, parts));
     }
 
@@ -82,7 +85,7 @@
         mTouchSlop = orgConfig.getScaledTouchSlop();
         doReturn(mTouchSlop).when(mMockConfig).getScaledTouchSlop();
 
-        L("mTouchSlop=", mTouchSlop);
+        logD("mTouchSlop= %s", mTouchSlop);
     }
 
     @Test