Merge "Refactor lambda to use listener instead" into ub-launcher3-qt-dev
diff --git a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
index a53a06e..771c7d7 100644
--- a/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
+++ b/go/quickstep/src/com/android/quickstep/views/IconRecentsView.java
@@ -154,6 +154,7 @@
     private boolean mTransitionedFromApp;
     private boolean mUsingRemoteAnimation;
     private boolean mStartedEnterAnimation;
+    private boolean mShowStatusBarForegroundScrim;
     private AnimatorSet mLayoutAnimation;
     private final ArraySet<View> mLayingOutViews = new ArraySet<>();
     private Rect mInsets;
@@ -409,7 +410,14 @@
      * @param showStatusBarForegroundScrim true to show the scrim, false to hide
      */
     public void setShowStatusBarForegroundScrim(boolean showStatusBarForegroundScrim) {
-        boolean shouldShow = mInsets.top != 0 && showStatusBarForegroundScrim;
+        mShowStatusBarForegroundScrim = showStatusBarForegroundScrim;
+        if (mShowStatusBarForegroundScrim != showStatusBarForegroundScrim) {
+            updateStatusBarScrim();
+        }
+    }
+
+    private void updateStatusBarScrim() {
+        boolean shouldShow = mInsets.top != 0 && mShowStatusBarForegroundScrim;
         mActivity.getDragLayer().setForeground(shouldShow ? mStatusBarForegroundScrim : null);
     }
 
@@ -838,6 +846,9 @@
         mInsets = insets;
         mTaskRecyclerView.setPadding(insets.left, insets.top, insets.right, insets.bottom);
         mTaskRecyclerView.invalidateItemDecorations();
+        if (mInsets.top != 0) {
+            updateStatusBarScrim();
+        }
     }
 
     /**
diff --git a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
index 4d8ff1b..0d8d92c 100644
--- a/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
+++ b/tests/tapl/com/android/launcher3/tapl/LauncherInstrumentation.java
@@ -176,17 +176,19 @@
             // Workaround, use constructed context because both the instrumentation context and the
             // app context are not constructed with resources that take overlays into account
             final Context ctx = baseContext.createPackageContext("android", 0);
-            log("Interaction mode = " + getCurrentInteractionMode(ctx));
-            if (isGesturalMode(ctx)) {
-                return NavigationModel.ZERO_BUTTON;
-            } else if (isSwipeUpMode(ctx)) {
-                return NavigationModel.TWO_BUTTON;
-            } else if (isLegacyMode(ctx)) {
-                return NavigationModel.THREE_BUTTON;
-            } else {
-                fail("Can't detect navigation mode");
+            for (int i = 0; i < 100; ++i) {
+                log("Interaction mode = " + getCurrentInteractionMode(ctx));
+                if (isGesturalMode(ctx)) {
+                    return NavigationModel.ZERO_BUTTON;
+                } else if (isSwipeUpMode(ctx)) {
+                    return NavigationModel.TWO_BUTTON;
+                } else if (isLegacyMode(ctx)) {
+                    return NavigationModel.THREE_BUTTON;
+                }
+                Thread.sleep(100);
             }
-        } catch (PackageManager.NameNotFoundException e) {
+            fail("Can't detect navigation mode");
+        } catch (Exception e) {
             fail(e.toString());
         }
         return NavigationModel.THREE_BUTTON;