diff options
| author | 2020-07-17 16:28:33 +0800 | |
|---|---|---|
| committer | 2020-07-20 09:25:17 +0000 | |
| commit | 2d9334940f01aaf32bb5661bb49e5b5d7b96e712 (patch) | |
| tree | 4375ba919c24ab4d32bc0a2c1fb238a281db8868 | |
| parent | 82658d6c48859d30f57d913d5a906b5cc755e416 (diff) | |
Fix panic gesture for hidden navigation bar
And make sure we don't show transient bar while notification shade is
controlling system UI.
Fix: 161514002
Test: 1. Open an immersive app (which hides navigation bar).
2. Press power key twice within 5 seconds.
3. Return to the app (unlock lockscreen if there is any).
Change-Id: I61ada33306f767acdd194de76ce6d15b4e61387f
| -rw-r--r-- | services/core/java/com/android/server/wm/DisplayPolicy.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 53f16a7241fc..832205175097 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -356,6 +356,8 @@ public class DisplayPolicy { private WindowState mFocusedWindow; private WindowState mLastFocusedWindow; + private WindowState mSystemUiControllingWindow; + // The states of decor windows from the last layout. These are used to generate another display // layout in different bounds but with the same states. private boolean mLastNavVisible; @@ -3436,6 +3438,7 @@ public class DisplayPolicy { } } final WindowState win = winCandidate; + mSystemUiControllingWindow = win; mDisplayContent.getInsetsPolicy().updateBarControlTarget(win); @@ -3740,8 +3743,12 @@ public class DisplayPolicy { & WindowManager.LayoutParams.FLAG_FULLSCREEN) != 0; final boolean hideStatusBarSysui = (vis & View.SYSTEM_UI_FLAG_FULLSCREEN) != 0; - final boolean hideNavBarSysui = - (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0; + final boolean hideNavBarSysui = (vis & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) != 0 + // We shouldn't rely on the system UI visibilities anymore because the window can + // use the new API (e.g., WindowInsetsController.hide) to hide navigation bar. + // TODO(b/149813814): clean up the system UI flag usages in this function. + || !win.getRequestedInsetsState().getSourceOrDefaultVisibility( + ITYPE_NAVIGATION_BAR); final boolean transientStatusBarAllowed = getStatusBar() != null && (notificationShadeHasFocus || (!mForceShowSystemBars @@ -3755,15 +3762,16 @@ public class DisplayPolicy { && now - mPendingPanicGestureUptime <= PANIC_GESTURE_EXPIRATION; final DisplayPolicy defaultDisplayPolicy = mService.getDefaultDisplayContentLocked().getDisplayPolicy(); - if (pendingPanic && hideNavBarSysui && !isKeyguardShowing() + if (pendingPanic && hideNavBarSysui && win != mNotificationShade + && getInsetsPolicy().isHidden(ITYPE_NAVIGATION_BAR) // TODO (b/111955725): Show keyguard presentation on all external displays && defaultDisplayPolicy.isKeyguardDrawComplete()) { // The user performed the panic gesture recently, we're about to hide the bars, // we're no longer on the Keyguard and the screen is ready. We can now request the bars. mPendingPanicGestureUptime = 0; - mStatusBarController.showTransient(); if (!isNavBarEmpty(vis)) { - mNavigationBarController.showTransient(); + mDisplayContent.getInsetsPolicy().showTransient(IntArray.wrap( + new int[] {ITYPE_NAVIGATION_BAR})); } } @@ -3908,6 +3916,9 @@ public class DisplayPolicy { } private boolean isImmersiveMode(WindowState win) { + if (win == null) { + return false; + } final int behavior = win.mAttrs.insetsFlags.behavior; return getNavigationBar() != null && canHideNavigationBar() @@ -3942,11 +3953,7 @@ public class DisplayPolicy { return; } mPendingPanicGestureUptime = SystemClock.uptimeMillis(); - if (!isNavBarEmpty(mLastSystemUiFlags)) { - mNavigationBarController.showTransient(); - mDisplayContent.getInsetsPolicy().showTransient(IntArray.wrap( - new int[] {ITYPE_NAVIGATION_BAR})); - } + updateSystemUiVisibilityLw(); } } }; @@ -3955,7 +3962,7 @@ public class DisplayPolicy { // Detect user pressing the power button in panic when an application has // taken over the whole screen. boolean panic = mImmersiveModeConfirmation.onPowerKeyDown(isScreenOn, - SystemClock.elapsedRealtime(), isImmersiveMode(mLastSystemUiFlags), + SystemClock.elapsedRealtime(), isImmersiveMode(mSystemUiControllingWindow), isNavBarEmpty(mLastSystemUiFlags)); if (panic) { mHandler.post(mHiddenNavPanic); |