Snap for 7618979 from 55861dc50bd6a32311ca1a4669688d5b07390d9e to sc-v2-release

Change-Id: I6f10c5ad33779fa9ad3e26e3bcda06c957cea926
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java
index dd7c403..6fbef9b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarNavButtonController.java
@@ -18,7 +18,6 @@
 
 import static android.view.Display.DEFAULT_DISPLAY;
 
-import android.content.Intent;
 import android.view.inputmethod.InputMethodManager;
 
 import androidx.annotation.IntDef;
@@ -90,9 +89,7 @@
     }
 
     private void navigateHome() {
-        mService.startActivity(new Intent(Intent.ACTION_MAIN)
-                .addCategory(Intent.CATEGORY_HOME)
-                .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
+        mService.getOverviewCommandHelper().addCommand(OverviewCommandHelper.TYPE_HOME);
     }
 
     private void navigateToOverview() {
diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
index 6249e6a..42c89fd 100644
--- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
+++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java
@@ -1534,7 +1534,9 @@
         boolean wasVisible = mWasLauncherAlreadyVisible || mGestureStarted;
         mActivityInterface.onTransitionCancelled(wasVisible, mGestureState.getEndTarget());
 
-        TaskViewUtils.setDividerBarShown(mRecentsAnimationTargets.nonApps, true);
+        if (mRecentsAnimationTargets != null) {
+            TaskViewUtils.setDividerBarShown(mRecentsAnimationTargets.nonApps, true);
+        }
 
         // Leave the pending invisible flag, as it may be used by wallpaper open animation.
         if (mActivity != null) {
diff --git a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
index 5d1f908..8fb851c 100644
--- a/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
+++ b/quickstep/src/com/android/quickstep/OverviewCommandHelper.java
@@ -49,6 +49,7 @@
     public static final int TYPE_SHOW_NEXT_FOCUS = 2;
     public static final int TYPE_HIDE = 3;
     public static final int TYPE_TOGGLE = 4;
+    public static final int TYPE_HOME = 5;
 
     private static final String TRANSITION_NAME = "Transition:toOverview";
 
@@ -154,6 +155,10 @@
                 // already hidden
                 return true;
             }
+            if (cmd.type == TYPE_HOME) {
+                mService.startActivity(mOverviewComponentObserver.getHomeIntent());
+                return true;
+            }
         } else {
             switch (cmd.type) {
                 case TYPE_SHOW:
@@ -168,6 +173,9 @@
                 }
                 case TYPE_TOGGLE:
                     return launchTask(recents, getNextTask(recents), cmd);
+                case TYPE_HOME:
+                    recents.startHome();
+                    return true;
             }
         }
 
diff --git a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
index 080533b..f49c9b0 100644
--- a/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskOverlayFactory.java
@@ -183,6 +183,13 @@
         }
 
         /**
+         * Called when the current task's thumbnail has changed.
+         */
+        public void refreshActionVisibility(ThumbnailData thumbnail) {
+            getActionsView().updateDisabledFlags(DISABLED_NO_THUMBNAIL, thumbnail == null);
+        }
+
+        /**
          * End rendering live tile in Overview.
          *
          * @param callback callback to run, after switching to screenshot
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
index 320ea09..35e21ad 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailView.java
@@ -162,7 +162,9 @@
             mBitmapShader = new BitmapShader(bm, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
             mPaint.setShader(mBitmapShader);
             updateThumbnailMatrix();
-            refreshOverlay();
+            if (mOverlayEnabled) {
+                getTaskOverlay().refreshActionVisibility(mThumbnailData);
+            }
         } else {
             mBitmapShader = null;
             mThumbnailData = null;
diff --git a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
index dcb6dc1..0d5b9ad 100644
--- a/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
+++ b/tests/src/com/android/launcher3/ui/AbstractLauncherUiTest.java
@@ -254,26 +254,12 @@
         return mDevice;
     }
 
-    private boolean hasSystemUiObject(String resId) {
-        return mDevice.hasObject(By.res(SYSTEMUI_PACKAGE, resId));
-    }
-
     @Before
     public void setUp() throws Exception {
         mLauncher.onTestStart();
-        Log.d(TAG, "Before disabling battery defender");
-        mDevice.executeShellCommand("setprop vendor.battery.defender.disable 1");
-        Log.d(TAG, "Before enabling stay awake");
-        mDevice.executeShellCommand("settings put global stay_on_while_plugged_in 3");
-        for (int i = 0; i < 10 && hasSystemUiObject("keyguard_status_view"); ++i) {
-            Log.d(TAG, "Before unlocking the phone");
-            mDevice.executeShellCommand("input keyevent 82");
-            mDevice.waitForIdle();
-        }
-        Assert.assertTrue("Keyguard still visible",
+        Assert.assertTrue("Keyguard is visible, which is likely caused by a crash in SysUI",
                 TestHelpers.wait(
                         Until.gone(By.res(SYSTEMUI_PACKAGE, "keyguard_status_view")), 60000));
-        Log.d(TAG, "Keyguard is not visible");
 
         final String launcherPackageName = mDevice.getLauncherPackageName();
         try {