Merge "Fix testDisableRotationCheck"
diff --git a/quickstep/src/com/android/launcher3/appprediction/InstantAppItemInfo.java b/quickstep/src/com/android/launcher3/appprediction/InstantAppItemInfo.java
index 9c3b881..8baee00 100644
--- a/quickstep/src/com/android/launcher3/appprediction/InstantAppItemInfo.java
+++ b/quickstep/src/com/android/launcher3/appprediction/InstantAppItemInfo.java
@@ -22,6 +22,8 @@
 import android.content.Context;
 import android.content.Intent;
 
+import androidx.annotation.NonNull;
+
 import com.android.launcher3.LauncherSettings;
 import com.android.launcher3.model.data.AppInfo;
 import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -33,11 +35,13 @@
         this.componentName = new ComponentName(packageName, COMPONENT_CLASS_MARKER);
     }
 
+    @NonNull
     @Override
     public ComponentName getTargetComponent() {
         return componentName;
     }
 
+    @NonNull
     @Override
     public WorkspaceItemInfo makeWorkspaceItem(Context context) {
         WorkspaceItemInfo workspaceItemInfo = super.makeWorkspaceItem(context);
diff --git a/quickstep/src/com/android/quickstep/ViewUtils.java b/quickstep/src/com/android/quickstep/ViewUtils.java
index 1bb95b9..b132067 100644
--- a/quickstep/src/com/android/quickstep/ViewUtils.java
+++ b/quickstep/src/com/android/quickstep/ViewUtils.java
@@ -53,13 +53,13 @@
         final Runnable mFinishCallback;
         final BooleanSupplier mCancelled;
         final Handler mHandler;
+        boolean mSurfaceCallbackRegistered = false;
         boolean mFinished;
 
         int mDeferFrameCount = 1;
 
         FrameHandler(View view, Runnable finishCallback, BooleanSupplier cancelled) {
             mViewRoot = view.getViewRootImpl();
-            mViewRoot.addSurfaceChangedCallback(this);
             mFinishCallback = finishCallback;
             mCancelled = cancelled;
             mHandler = new Handler();
@@ -103,6 +103,10 @@
 
         private boolean schedule() {
             if (mViewRoot != null && mViewRoot.getView() != null) {
+                if (!mSurfaceCallbackRegistered) {
+                    mSurfaceCallbackRegistered = true;
+                    mViewRoot.addSurfaceChangedCallback(this);
+                }
                 mViewRoot.registerRtFrameCallback(this);
                 mViewRoot.getView().invalidate();
                 return true;
@@ -119,7 +123,10 @@
             if (mFinishCallback != null) {
                 mFinishCallback.run();
             }
-            mViewRoot.removeSurfaceChangedCallback(this);
+            if (mViewRoot != null) {
+                mViewRoot.removeSurfaceChangedCallback(this);
+                mSurfaceCallbackRegistered = false;
+            }
         }
     }
 }
diff --git a/res/layout/search_container_all_apps.xml b/res/layout/search_container_all_apps.xml
index e1646ba..b46298c 100644
--- a/res/layout/search_container_all_apps.xml
+++ b/res/layout/search_container_all_apps.xml
@@ -26,6 +26,7 @@
     android:gravity="center"
     android:hint="@string/all_apps_search_bar_hint"
     android:imeOptions="actionSearch|flagNoExtractUi"
+    android:importantForAutofill="no"
     android:inputType="text|textNoSuggestions|textCapWords"
     android:maxLines="1"
     android:padding="8dp"
diff --git a/res/layout/secondary_launcher.xml b/res/layout/secondary_launcher.xml
index bdc51be..4be2e45 100644
--- a/res/layout/secondary_launcher.xml
+++ b/res/layout/secondary_launcher.xml
@@ -93,6 +93,7 @@
             android:gravity="center"
             android:hint="@string/all_apps_search_bar_hint"
             android:imeOptions="actionSearch|flagNoExtractUi"
+            android:importantForAutofill="no"
             android:inputType="text|textNoSuggestions|textCapWords"
             android:maxLines="1"
             android:padding="8dp"
diff --git a/res/layout/user_folder_icon_normalized.xml b/res/layout/user_folder_icon_normalized.xml
index 337014a..87bf33d 100644
--- a/res/layout/user_folder_icon_normalized.xml
+++ b/res/layout/user_folder_icon_normalized.xml
@@ -47,6 +47,7 @@
             android:gravity="center_horizontal"
             android:hint="@string/folder_hint_text"
             android:imeOptions="flagNoExtractUi"
+            android:importantForAutofill="no"
             android:singleLine="true"
             android:textColor="?attr/folderTextColor"
             android:textColorHighlight="?android:attr/colorControlHighlight"
diff --git a/res/layout/widgets_search_bar.xml b/res/layout/widgets_search_bar.xml
index 9178a75..6d44865 100644
--- a/res/layout/widgets_search_bar.xml
+++ b/res/layout/widgets_search_bar.xml
@@ -23,6 +23,7 @@
         android:layout_weight="1"
         android:inputType="text"
         android:imeOptions="actionSearch"
+        android:importantForAutofill="no"
         android:textColor="?android:attr/textColorPrimary"
         android:textColorHint="?android:attr/textColorSecondary"/>
 
diff --git a/src/com/android/launcher3/icons/ComponentWithLabel.java b/src/com/android/launcher3/icons/ComponentWithLabel.java
index 372c591..30575fc 100644
--- a/src/com/android/launcher3/icons/ComponentWithLabel.java
+++ b/src/com/android/launcher3/icons/ComponentWithLabel.java
@@ -20,6 +20,8 @@
 import android.content.pm.PackageManager;
 import android.os.UserHandle;
 
+import androidx.annotation.NonNull;
+
 import com.android.launcher3.icons.cache.CachingLogic;
 
 public interface ComponentWithLabel {
@@ -42,22 +44,26 @@
         }
 
         @Override
-        public ComponentName getComponent(T object) {
+        @NonNull
+        public ComponentName getComponent(@NonNull T object) {
             return object.getComponent();
         }
 
+        @NonNull
         @Override
-        public UserHandle getUser(T object) {
+        public UserHandle getUser(@NonNull T object) {
             return object.getUser();
         }
 
+        @NonNull
         @Override
-        public CharSequence getLabel(T object) {
+        public CharSequence getLabel(@NonNull T object) {
             return object.getLabel(mPackageManager);
         }
 
+        @NonNull
         @Override
-        public BitmapInfo loadIcon(Context context, T object) {
+        public BitmapInfo loadIcon(@NonNull Context context, @NonNull T object) {
             return BitmapInfo.LOW_RES_INFO;
         }
 
diff --git a/src/com/android/launcher3/icons/ComponentWithLabelAndIcon.java b/src/com/android/launcher3/icons/ComponentWithLabelAndIcon.java
index c8606b1..0a52dd7 100644
--- a/src/com/android/launcher3/icons/ComponentWithLabelAndIcon.java
+++ b/src/com/android/launcher3/icons/ComponentWithLabelAndIcon.java
@@ -41,7 +41,8 @@
 
         @NonNull
         @Override
-        public BitmapInfo loadIcon(Context context, ComponentWithLabelAndIcon object) {
+        public BitmapInfo loadIcon(@NonNull Context context,
+                @NonNull ComponentWithLabelAndIcon object) {
             Drawable d = object.getFullResIcon(LauncherAppState.getInstance(context)
                     .getIconCache());
             if (d == null) {
diff --git a/src/com/android/launcher3/icons/IconCache.java b/src/com/android/launcher3/icons/IconCache.java
index 7621dc2..0b4a4a5 100644
--- a/src/com/android/launcher3/icons/IconCache.java
+++ b/src/com/android/launcher3/icons/IconCache.java
@@ -118,15 +118,16 @@
     }
 
     @Override
-    protected long getSerialNumberForUser(UserHandle user) {
+    protected long getSerialNumberForUser(@NonNull UserHandle user) {
         return mUserManager.getSerialNumberForUser(user);
     }
 
     @Override
-    protected boolean isInstantApp(ApplicationInfo info) {
+    protected boolean isInstantApp(@NonNull ApplicationInfo info) {
         return mInstantAppResolver.isInstantApp(info);
     }
 
+    @NonNull
     @Override
     public BaseIconFactory getIconFactory() {
         return LauncherIcons.obtain(mContext);
@@ -135,7 +136,8 @@
     /**
      * Updates the entries related to the given package in memory and persistent DB.
      */
-    public synchronized void updateIconsForPkg(String packageName, UserHandle user) {
+    public synchronized void updateIconsForPkg(@NonNull final String packageName,
+            @NonNull final UserHandle user) {
         removeIconsForPkg(packageName, user);
         try {
             PackageInfo info = mPackageManager.getPackageInfo(packageName,
@@ -471,7 +473,7 @@
      * Fill in {@param infoInOut} with the corresponding icon and label.
      */
     public synchronized void getTitleAndIconForApp(
-            PackageItemInfo infoInOut, boolean useLowResIcon) {
+            @NonNull final PackageItemInfo infoInOut, final boolean useLowResIcon) {
         CacheEntry entry = getEntryForPackageLocked(
                 infoInOut.packageName, infoInOut.user, useLowResIcon);
         applyCacheEntry(entry, infoInOut);
@@ -510,10 +512,16 @@
         return bitmap.withFlags(getUserFlagOpLocked(user));
     }
 
-    protected void applyCacheEntry(CacheEntry entry, ItemInfoWithIcon info) {
+    protected void applyCacheEntry(@NonNull final CacheEntry entry,
+            @NonNull final ItemInfoWithIcon info) {
         info.title = Utilities.trim(entry.title);
         info.contentDescription = entry.contentDescription;
-        info.bitmap = (entry.bitmap == null) ? getDefaultIcon(info.user) : entry.bitmap;
+        info.bitmap = entry.bitmap;
+        if (entry.bitmap == null) {
+            // TODO: entry.bitmap can never be null, so this should not happen at all.
+            Log.wtf(TAG, "Cannot find bitmap from the cache, default icon was loaded.");
+            info.bitmap = getDefaultIcon(info.user);
+        }
     }
 
     public Drawable getFullResIcon(LauncherActivityInfo info) {
@@ -526,6 +534,7 @@
     }
 
     @Override
+    @NonNull
     protected String getIconSystemState(String packageName) {
         return mIconProvider.getSystemStateForPackage(mSystemState, packageName);
     }
diff --git a/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java b/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java
index 4b8c1ad..406f697 100644
--- a/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java
+++ b/src/com/android/launcher3/icons/LauncherActivityCachingLogic.java
@@ -20,6 +20,8 @@
 import android.content.pm.LauncherActivityInfo;
 import android.os.UserHandle;
 
+import androidx.annotation.NonNull;
+
 import com.android.launcher3.LauncherAppState;
 import com.android.launcher3.R;
 import com.android.launcher3.icons.BaseIconFactory.IconOptions;
@@ -40,23 +42,27 @@
                 R.string.launcher_activity_logic_class);
     }
 
+    @NonNull
     @Override
-    public ComponentName getComponent(LauncherActivityInfo object) {
+    public ComponentName getComponent(@NonNull LauncherActivityInfo object) {
         return object.getComponentName();
     }
 
+    @NonNull
     @Override
-    public UserHandle getUser(LauncherActivityInfo object) {
+    public UserHandle getUser(@NonNull LauncherActivityInfo object) {
         return object.getUser();
     }
 
+    @NonNull
     @Override
-    public CharSequence getLabel(LauncherActivityInfo object) {
+    public CharSequence getLabel(@NonNull LauncherActivityInfo object) {
         return object.getLabel();
     }
 
+    @NonNull
     @Override
-    public BitmapInfo loadIcon(Context context, LauncherActivityInfo object) {
+    public BitmapInfo loadIcon(@NonNull Context context, @NonNull LauncherActivityInfo object) {
         try (LauncherIcons li = LauncherIcons.obtain(context)) {
             return li.createBadgedIconBitmap(LauncherAppState.getInstance(context)
                             .getIconProvider().getIcon(object, li.mFillResIconDpi),
diff --git a/src/com/android/launcher3/icons/ShortcutCachingLogic.java b/src/com/android/launcher3/icons/ShortcutCachingLogic.java
index 1e46344..4890ba6 100644
--- a/src/com/android/launcher3/icons/ShortcutCachingLogic.java
+++ b/src/com/android/launcher3/icons/ShortcutCachingLogic.java
@@ -29,6 +29,7 @@
 import android.util.Log;
 
 import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
 
 import com.android.launcher3.LauncherAppState;
 import com.android.launcher3.icons.cache.CachingLogic;
@@ -43,29 +44,34 @@
     private static final String TAG = "ShortcutCachingLogic";
 
     @Override
-    public ComponentName getComponent(ShortcutInfo info) {
+    @NonNull
+    public ComponentName getComponent(@NonNull ShortcutInfo info) {
         return ShortcutKey.fromInfo(info).componentName;
     }
 
+    @NonNull
     @Override
-    public UserHandle getUser(ShortcutInfo info) {
+    public UserHandle getUser(@NonNull ShortcutInfo info) {
         return info.getUserHandle();
     }
 
+    @NonNull
     @Override
-    public CharSequence getLabel(ShortcutInfo info) {
+    public CharSequence getLabel(@NonNull ShortcutInfo info) {
         return info.getShortLabel();
     }
 
     @Override
-    public CharSequence getDescription(ShortcutInfo object, CharSequence fallback) {
+    @NonNull
+    public CharSequence getDescription(@NonNull ShortcutInfo object,
+            @NonNull CharSequence fallback) {
         CharSequence label = object.getLongLabel();
         return TextUtils.isEmpty(label) ? fallback : label;
     }
 
     @NonNull
     @Override
-    public BitmapInfo loadIcon(Context context, ShortcutInfo info) {
+    public BitmapInfo loadIcon(@NonNull Context context, @NonNull ShortcutInfo info) {
         try (LauncherIcons li = LauncherIcons.obtain(context)) {
             Drawable unbadgedDrawable = ShortcutCachingLogic.getIcon(
                     context, info, LauncherAppState.getIDP(context).fillResIconDpi);
@@ -76,7 +82,8 @@
     }
 
     @Override
-    public long getLastUpdatedTime(ShortcutInfo shortcutInfo, PackageInfo info) {
+    public long getLastUpdatedTime(@Nullable ShortcutInfo shortcutInfo,
+            @NonNull PackageInfo info) {
         if (shortcutInfo == null) {
             return info.lastUpdateTime;
         }
diff --git a/src/com/android/launcher3/model/data/AppInfo.java b/src/com/android/launcher3/model/data/AppInfo.java
index 5b2bcf5..24e7dd3 100644
--- a/src/com/android/launcher3/model/data/AppInfo.java
+++ b/src/com/android/launcher3/model/data/AppInfo.java
@@ -29,7 +29,6 @@
 import android.os.UserManager;
 
 import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
 import androidx.annotation.VisibleForTesting;
 
 import com.android.launcher3.LauncherSettings;
@@ -55,6 +54,7 @@
      */
     public Intent intent;
 
+    @NonNull
     public ComponentName componentName;
 
     // Section name used for indexing.
@@ -151,7 +151,7 @@
                         | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
     }
 
-    @Nullable
+    @NonNull
     @Override
     public ComponentName getTargetComponent() {
         return componentName;
diff --git a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
index 09b8228..8f7a4ec 100644
--- a/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
+++ b/src/com/android/launcher3/touch/AbstractStateChangeTouchController.java
@@ -32,6 +32,7 @@
 
 import android.animation.Animator.AnimatorListener;
 import android.animation.ValueAnimator;
+import android.util.Log;
 import android.view.MotionEvent;
 
 import com.android.launcher3.Launcher;
@@ -211,6 +212,10 @@
                     mFlingBlockCheck.blockFling();
                 }
             }
+            if (mFromState == LauncherState.ALL_APPS) {
+                mAllAppsOvershootStarted = true;
+                mLauncher.getAppsView().onPull(-progress , -progress);
+            }
         } else if (progress >= 1) {
             if (reinitCurrentAnimation(true, isDragTowardPositive)) {
                 mDisplacementShift = displacement;
diff --git a/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java b/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
index 960d27d..7d36740 100644
--- a/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
+++ b/tests/src/com/android/launcher3/model/CacheDataUpdatedTaskTest.java
@@ -64,23 +64,26 @@
         IconCache iconCache = LauncherAppState.getInstance(context).getIconCache();
         CachingLogic<ItemInfo> placeholderLogic = new CachingLogic<ItemInfo>() {
             @Override
-            public ComponentName getComponent(ItemInfo info) {
+            @NonNull
+            public ComponentName getComponent(@NonNull ItemInfo info) {
                 return info.getTargetComponent();
             }
 
+            @NonNull
             @Override
-            public UserHandle getUser(ItemInfo info) {
+            public UserHandle getUser(@NonNull ItemInfo info) {
                 return info.user;
             }
 
+            @NonNull
             @Override
-            public CharSequence getLabel(ItemInfo info) {
+            public CharSequence getLabel(@NonNull ItemInfo info) {
                 return NEW_LABEL_PREFIX + info.id;
             }
 
             @NonNull
             @Override
-            public BitmapInfo loadIcon(Context context, ItemInfo info) {
+            public BitmapInfo loadIcon(@NonNull Context context, @NonNull ItemInfo info) {
                 return BitmapInfo.of(Bitmap.createBitmap(1, 1, Config.ARGB_8888), Color.RED);
             }
         };
diff --git a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
index 14e16ab..c812a0f 100644
--- a/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
+++ b/tests/src/com/android/launcher3/ui/TaplTestsLauncher3.java
@@ -18,6 +18,8 @@
 
 import static androidx.test.InstrumentationRegistry.getInstrumentation;
 
+import android.platform.test.annotations.IwTest;
+
 import static com.google.common.truth.Truth.assertThat;
 
 import static org.junit.Assert.assertEquals;
@@ -203,6 +205,7 @@
                 false /* tapRight */);
     }
 
+    @IwTest(focusArea="launcher")
     @Test
     @ScreenRecord // b/202433017
     public void testWorkspace() throws Exception {
@@ -330,6 +333,7 @@
         }
     }
 
+    @IwTest(focusArea="launcher")
     @Test
     @PortraitLandscape
     public void testDragAppIcon() throws Throwable {
diff --git a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
index 194ee4f..561f3cc 100644
--- a/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
+++ b/tests/src/com/android/launcher3/ui/widget/AddWidgetTest.java
@@ -20,6 +20,8 @@
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
+import android.platform.test.annotations.IwTest;
+
 import androidx.test.filters.LargeTest;
 import androidx.test.runner.AndroidJUnit4;
 
@@ -45,6 +47,7 @@
     @Rule
     public ShellCommandRule mGrantWidgetRule = ShellCommandRule.grantWidgetBind();
 
+    @IwTest(focusArea="launcher")
     @Test
     @PortraitLandscape
     public void testDragIcon() throws Throwable {