From 203e005aa3244e5dea7e9328175fe9656f5f751f Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Thu, 2 Sep 2021 20:49:12 +0800 Subject: [PATCH] Check the transient state by using public types Previously, we only checked if ITYPE_STATUS_BAR or ITYPE_NAVIGATION_BAR is showing transiently or not when deciding the control target. There could be an issue if the system doesn't have ITYPE_NAVIGATION_BAR but has ITYPE_EXTRA_NAVIGATION_BAR. When that happens, mDummyControlTarget in InsetsPolicy cannot be the navigation control target, so it cannot show the transient bar. This CL uses public types to decide the control target in transient mode. Bug: 198193735 Test: 1. Enable task bar from DeviceProfile. 2. Set smallest width to 600 dp from developer options. 3. Open an app which hides all system bars in sticky-immersive mode. 4. Swipe from top and see if task bar is visible. Change-Id: Id0a0b60831e11e32fbeac93330144535ed7cb416 --- .../java/com/android/server/wm/InsetsPolicy.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index cf783398fc8de..3d19f54ad1325 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -46,6 +46,7 @@ import android.view.InsetsState.InternalInsetsType; import android.view.InternalInsetsAnimationController; import android.view.SurfaceControl; import android.view.SyncRtSurfaceTransactionApplier; +import android.view.WindowInsets.Type; import android.view.WindowInsetsAnimation; import android.view.WindowInsetsAnimation.Bounds; import android.view.WindowInsetsAnimationControlListener; @@ -336,7 +337,7 @@ class InsetsPolicy { private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin, boolean fake) { - if (mShowingTransientTypes.indexOf(ITYPE_STATUS_BAR) != -1 && !fake) { + if (!fake && isShowingTransientTypes(Type.statusBars())) { return mDummyControlTarget; } final WindowState notificationShade = mPolicy.getNotificationShade(); @@ -386,7 +387,7 @@ class InsetsPolicy { // Force showing navigation bar while IME is visible. return null; } - if (mShowingTransientTypes.indexOf(ITYPE_NAVIGATION_BAR) != -1 && !fake) { + if (!fake && isShowingTransientTypes(Type.navigationBars())) { return mDummyControlTarget; } if (focusedWin == mPolicy.getNotificationShade()) { @@ -412,6 +413,16 @@ class InsetsPolicy { return focusedWin; } + private boolean isShowingTransientTypes(@Type.InsetsType int types) { + final IntArray showingTransientTypes = mShowingTransientTypes; + for (int i = showingTransientTypes.size() - 1; i >= 0; i--) { + if ((InsetsState.toPublicType(showingTransientTypes.get(i)) & types) != 0) { + return true; + } + } + return false; + } + /** * Determines whether the remote insets controller should take control of system bars for all * windows.