Simplify/correct Taskbar insetsRoundedCornerFrame calculation

Now we base it on the current tappableElement insets, which will only be
> 0 for the unstashed, persistent taskbar which draws rounded corners.
This inset also stays stable during temporary stash transitions such as
when the IME is showing.

Flag: ENABLE_TRANSIENT_TASKBAR=true, ENABLE_TASKBAR_PINNING=true
Test: in split screen for both transient and pinned (persistent)
taskbar, ensure split screen divider bottom is drawn appropriately
Fixes: 278028503

Change-Id: Iab56c5dc8f9fc81c34aa01f41b5212dd5c6fd7f0
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 9db03f5..7e0530b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -674,18 +674,6 @@
     }
 
     /**
-     * Notify system to inset the rounded corner frame based on the task bar insets.
-     */
-    public void updateInsetRoundedCornerFrame(boolean shouldInsetsRoundedCorner) {
-        if (!mDragLayer.isAttachedToWindow()
-                || mWindowLayoutParams.insetsRoundedCornerFrame == shouldInsetsRoundedCorner) {
-            return;
-        }
-        mWindowLayoutParams.insetsRoundedCornerFrame = shouldInsetsRoundedCorner;
-        mWindowManager.updateViewLayout(mDragLayer, mWindowLayoutParams);
-    }
-
-    /**
      * Updates the TaskbarContainer height (pass {@link #getDefaultTaskbarWindowHeight()} to reset).
      */
     public void setTaskbarWindowHeight(int height) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
index c029097..19b9a18 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarInsetsController.kt
@@ -71,7 +71,6 @@
     fun init(controllers: TaskbarControllers) {
         this.controllers = controllers
         windowLayoutParams = context.windowLayoutParams
-        windowLayoutParams.insetsRoundedCornerFrame = true
         onTaskbarWindowHeightOrInsetsChanged()
 
         context.addOnDeviceProfileChangeListener(deviceProfileChangeListener)
@@ -86,23 +85,23 @@
     fun onTaskbarWindowHeightOrInsetsChanged() {
         if (context.isGestureNav) {
             windowLayoutParams.providedInsets =
-                    arrayOf(
-                            InsetsFrameProvider(insetsOwner, 0, navigationBars())
-                                    .setFlags(FLAG_SUPPRESS_SCRIM, FLAG_SUPPRESS_SCRIM),
-                            InsetsFrameProvider(insetsOwner, 0, tappableElement()),
-                            InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures()),
-                            InsetsFrameProvider(insetsOwner, INDEX_LEFT, systemGestures())
-                                    .setSource(SOURCE_DISPLAY),
-                            InsetsFrameProvider(insetsOwner, INDEX_RIGHT, systemGestures())
-                                    .setSource(SOURCE_DISPLAY)
-                    )
+                arrayOf(
+                    InsetsFrameProvider(insetsOwner, 0, navigationBars())
+                        .setFlags(FLAG_SUPPRESS_SCRIM, FLAG_SUPPRESS_SCRIM),
+                    InsetsFrameProvider(insetsOwner, 0, tappableElement()),
+                    InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures()),
+                    InsetsFrameProvider(insetsOwner, INDEX_LEFT, systemGestures())
+                        .setSource(SOURCE_DISPLAY),
+                    InsetsFrameProvider(insetsOwner, INDEX_RIGHT, systemGestures())
+                        .setSource(SOURCE_DISPLAY)
+                )
         } else {
             windowLayoutParams.providedInsets =
-                    arrayOf(
-                            InsetsFrameProvider(insetsOwner, 0, navigationBars()),
-                            InsetsFrameProvider(insetsOwner, 0, tappableElement()),
-                            InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures())
-                    )
+                arrayOf(
+                    InsetsFrameProvider(insetsOwner, 0, navigationBars()),
+                    InsetsFrameProvider(insetsOwner, 0, tappableElement()),
+                    InsetsFrameProvider(insetsOwner, 0, mandatorySystemGestures())
+                )
         }
 
         val touchableHeight = controllers.taskbarStashController.touchableHeight
@@ -162,6 +161,11 @@
                 provider.insetsSizeOverrides = insetsSizeOverride
             }
         }
+
+        // We only report tappableElement height for unstashed, persistent taskbar,
+        // which is also when we draw the rounded corners above taskbar.
+        windowLayoutParams.insetsRoundedCornerFrame = tappableHeight > 0
+
         context.notifyUpdateLayoutParams()
     }
 
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index 1d90a43..2d6d670 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -107,9 +107,6 @@
             | FLAG_STASHED_IN_APP_IME | FLAG_STASHED_IN_TASKBAR_ALL_APPS
             | FLAG_STASHED_SMALL_SCREEN | FLAG_STASHED_IN_APP_AUTO;
 
-    private static final int FLAGS_STASHED_IN_APP_IGNORING_IME =
-            FLAGS_STASHED_IN_APP & ~FLAG_STASHED_IN_APP_IME;
-
     // If any of these flags are enabled, inset apps by our stashed height instead of our unstashed
     // height. This way the reported insets are consistent even during transitions out of the app.
     // Currently any flag that causes us to stash in an app is included, except for IME or All Apps
@@ -415,13 +412,6 @@
     }
 
     /**
-     * Returns whether the taskbar should be stashed in apps regardless of the IME visibility.
-     */
-    public boolean isStashedInAppIgnoringIme() {
-        return hasAnyFlag(FLAGS_STASHED_IN_APP_IGNORING_IME);
-    }
-
-    /**
      * Returns whether the taskbar should be stashed in the current LauncherState.
      */
     public boolean isInStashedLauncherState() {
@@ -1064,11 +1054,6 @@
     private void notifyStashChange(boolean visible, boolean stashed) {
         mSystemUiProxy.notifyTaskbarStatus(visible, stashed);
         setUpTaskbarSystemAction(visible);
-        // If stashing taskbar is caused by IME visibility, we could just skip updating rounded
-        // corner insets since the rounded corners will be covered by IME during IME is showing and
-        // taskbar will be restored back to unstashed when IME is hidden.
-        mControllers.taskbarActivityContext.updateInsetRoundedCornerFrame(
-                    visible && !isStashedInAppIgnoringIme());
         mControllers.rotationButtonController.onTaskbarStateChange(visible, stashed);
     }