diff options
| author | 2025-02-21 15:04:39 -0800 | |
|---|---|---|
| committer | 2025-02-21 15:04:39 -0800 | |
| commit | a8d531bdce6e2587dbb65cade4d5bfaf129ecd49 (patch) | |
| tree | a33c46da1492f83d444f974030cc287c667e799d | |
| parent | 897434309c5c0c7d9ed4de6d5a430bb7a9d78988 (diff) | |
| parent | b695dbc75f05d32dca990705c16728acbce3922f (diff) | |
Merge "Fix nav bar flickering when dialog shows" into main
| -rw-r--r-- | services/core/java/com/android/server/wm/InsetsPolicy.java | 112 |
1 files changed, 66 insertions, 46 deletions
diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index b4d55a160631..5c6695fe22c0 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -113,25 +113,33 @@ class InsetsPolicy { abortTransient(); } mFocusedWin = focusedWin; + final @InsetsType int[] requestedVisibleTypes = + {focusedWin != null ? focusedWin.getRequestedVisibleTypes() : 0}; final WindowState notificationShade = mPolicy.getNotificationShade(); final WindowState topApp = mPolicy.getTopFullscreenOpaqueWindow(); final InsetsControlTarget statusControlTarget = - getStatusControlTarget(focusedWin, false /* fake */); + getStatusControlTarget(focusedWin, false /* fake */, requestedVisibleTypes); mFakeStatusControlTarget = statusControlTarget == mTransientControlTarget - ? getStatusControlTarget(focusedWin, true /* fake */) + ? getStatusControlTarget(focusedWin, true /* fake */, requestedVisibleTypes) : statusControlTarget == notificationShade - ? getStatusControlTarget(topApp, true /* fake */) + ? getStatusControlTarget(topApp, true /* fake */, requestedVisibleTypes) : null; final InsetsControlTarget navControlTarget = - getNavControlTarget(focusedWin, false /* fake */); + getNavControlTarget(focusedWin, false /* fake */, requestedVisibleTypes); mFakeNavControlTarget = navControlTarget == mTransientControlTarget - ? getNavControlTarget(focusedWin, true /* fake */) + ? getNavControlTarget(focusedWin, true /* fake */, requestedVisibleTypes) : navControlTarget == notificationShade - ? getNavControlTarget(topApp, true /* fake */) + ? getNavControlTarget(topApp, true /* fake */, requestedVisibleTypes) : null; mStateController.onBarControlTargetChanged( statusControlTarget, mFakeStatusControlTarget, navControlTarget, mFakeNavControlTarget); + + if (statusControlTarget == mDisplayContent.mRemoteInsetsControlTarget + && navControlTarget == mDisplayContent.mRemoteInsetsControlTarget) { + notifyRemoteInsetsController(focusedWin, requestedVisibleTypes[0]); + } + mStatusBar.updateVisibility(statusControlTarget, Type.statusBars()); mNavBar.updateVisibility(navControlTarget, Type.navigationBars()); } @@ -182,12 +190,12 @@ class InsetsPolicy { @VisibleForTesting InsetsControlTarget getTransientControlTarget() { - return mTransientControlTarget; + return mTransientControlTarget; } @VisibleForTesting InsetsControlTarget getPermanentControlTarget() { - return mPermanentControlTarget; + return mPermanentControlTarget; } void hideTransient() { @@ -259,7 +267,7 @@ class InsetsPolicy { * modes. * * @param target the target on which the policy is applied - * @param state the input inset state containing all the sources + * @param state the input inset state containing all the sources * @return The state stripped of the necessary information. */ InsetsState enforceInsetsPolicyForTarget(WindowState target, InsetsState state) { @@ -461,7 +469,7 @@ class InsetsPolicy { mStateController.getFakeControllingTypes(caller); final @InsetsType int abortTypes = (fakeControllingTypes & caller.getRequestedVisibleTypes()) - | (isImeVisible ? Type.navigationBars() : 0); + | (isImeVisible ? Type.navigationBars() : 0); mShowingTransientTypes &= ~abortTypes; if (abortTypes != 0) { mDisplayContent.setLayoutNeeded(); @@ -496,6 +504,18 @@ class InsetsPolicy { } private @Nullable InsetsControlTarget getStatusControlTarget(@Nullable WindowState focusedWin, + boolean fake, @InsetsType int[] requestedVisibleTypes) { + final InsetsControlTarget target = getStatusControlTargetInner(focusedWin, fake); + if (remoteInsetsControllerControlsSystemBars(target)) { + requestedVisibleTypes[0] = (requestedVisibleTypes[0] & ~Type.statusBars()) | ( + target.getRequestedVisibleTypes() & Type.statusBars()); + return mDisplayContent.mRemoteInsetsControlTarget; + } + return target; + } + + private @Nullable InsetsControlTarget getStatusControlTargetInner( + @Nullable WindowState focusedWin, boolean fake) { if (!fake && isTransient(Type.statusBars())) { return mTransientControlTarget; @@ -521,17 +541,7 @@ class InsetsPolicy { && (notificationShade == null || !notificationShade.canReceiveKeys())) { // Non-fullscreen focused window should not break the state that the top-fullscreen-app // window hides status bar, unless the notification shade can receive keys. - if (remoteInsetsControllerControlsSystemBars( - mPolicy.getTopFullscreenOpaqueWindow())) { - notifyRemoteInsetsController(mPolicy.getTopFullscreenOpaqueWindow()); - return mDisplayContent.mRemoteInsetsControlTarget; - } else { - return mPolicy.getTopFullscreenOpaqueWindow(); - } - } - if (remoteInsetsControllerControlsSystemBars(focusedWin)) { - notifyRemoteInsetsController(focusedWin); - return mDisplayContent.mRemoteInsetsControlTarget; + return mPolicy.getTopFullscreenOpaqueWindow(); } return focusedWin; } @@ -547,6 +557,17 @@ class InsetsPolicy { } private @Nullable InsetsControlTarget getNavControlTarget(@Nullable WindowState focusedWin, + boolean fake, @InsetsType int[] requestedVisibleTypes) { + final InsetsControlTarget target = getNavControlTargetInner(focusedWin, fake); + if (remoteInsetsControllerControlsSystemBars(target)) { + requestedVisibleTypes[0] = (requestedVisibleTypes[0] & ~Type.navigationBars()) | ( + target.getRequestedVisibleTypes() & Type.navigationBars()); + return mDisplayContent.mRemoteInsetsControlTarget; + } + return target; + } + + private @Nullable InsetsControlTarget getNavControlTargetInner(@Nullable WindowState focusedWin, boolean fake) { final WindowState imeWin = mDisplayContent.mInputMethodWindow; if (imeWin != null && imeWin.isVisible() && !mHideNavBarForKeyboard) { @@ -585,29 +606,21 @@ class InsetsPolicy { && (notificationShade == null || !notificationShade.canReceiveKeys())) { // Non-fullscreen focused window should not break the state that the top-fullscreen-app // window hides navigation bar, unless the notification shade can receive keys. - if (remoteInsetsControllerControlsSystemBars( - mPolicy.getTopFullscreenOpaqueWindow())) { - notifyRemoteInsetsController(mPolicy.getTopFullscreenOpaqueWindow()); - return mDisplayContent.mRemoteInsetsControlTarget; - } else { - return mPolicy.getTopFullscreenOpaqueWindow(); - } - } - if (remoteInsetsControllerControlsSystemBars(focusedWin)) { - notifyRemoteInsetsController(focusedWin); - return mDisplayContent.mRemoteInsetsControlTarget; + return mPolicy.getTopFullscreenOpaqueWindow(); } return focusedWin; } - private void notifyRemoteInsetsController(@Nullable WindowState win) { + private void notifyRemoteInsetsController(@Nullable WindowState win, + @InsetsType int requestVisibleTypes) { if (win == null) { return; } ComponentName component = win.mActivityRecord != null ? win.mActivityRecord.mActivityComponent : null; + mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged( - component, win.getRequestedVisibleTypes()); + component, requestVisibleTypes); } boolean areTypesForciblyShowing(@InsetsType int types) { @@ -645,8 +658,8 @@ class InsetsPolicy { * Determines whether the remote insets controller should take control of system bars for all * windows. */ - boolean remoteInsetsControllerControlsSystemBars(@Nullable WindowState focusedWin) { - if (focusedWin == null) { + boolean remoteInsetsControllerControlsSystemBars(@Nullable InsetsControlTarget target) { + if (!(target instanceof WindowState win)) { return false; } @@ -660,8 +673,8 @@ class InsetsPolicy { // If necessary, auto can control application windows when // config_remoteInsetsControllerControlsSystemBars is set to true. This is useful in cases // where we want to dictate system bar inset state for applications. - return focusedWin.getAttrs().type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW - && focusedWin.getAttrs().type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; + return win.getAttrs().type >= WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW + && win.getAttrs().type <= WindowManager.LayoutParams.LAST_APPLICATION_WINDOW; } private void dispatchTransientSystemBarsVisibilityChanged( @@ -708,7 +721,7 @@ class InsetsPolicy { private class BarWindow { private final int mId; - private @StatusBarManager.WindowVisibleState int mState = + private @StatusBarManager.WindowVisibleState int mState = StatusBarManager.WINDOW_STATE_SHOWING; BarWindow(int id) { @@ -790,11 +803,13 @@ class InsetsPolicy { } @Override - public void notifyInsetsChanged() { } + public void notifyInsetsChanged() { + } @Override public void dispatchWindowInsetsAnimationPrepare( - @NonNull WindowInsetsAnimation animation) { } + @NonNull WindowInsetsAnimation animation) { + } @Override public Bounds dispatchWindowInsetsAnimationStart( @@ -812,7 +827,8 @@ class InsetsPolicy { @Override public void dispatchWindowInsetsAnimationEnd( - @NonNull WindowInsetsAnimation animation) { } + @NonNull WindowInsetsAnimation animation) { + } @Override public void applySurfaceParams(SyncRtSurfaceTransactionApplier.SurfaceParams... p) { @@ -834,7 +850,8 @@ class InsetsPolicy { } @Override - public void setSystemBarsAppearance(int appearance, int mask) { } + public void setSystemBarsAppearance(int appearance, int mask) { + } @Override public int getSystemBarsAppearance() { @@ -842,7 +859,8 @@ class InsetsPolicy { } @Override - public void setSystemBarsBehavior(int behavior) { } + public void setSystemBarsBehavior(int behavior) { + } @Override public int getSystemBarsBehavior() { @@ -855,10 +873,12 @@ class InsetsPolicy { } @Override - public void addOnPreDrawRunnable(Runnable r) { } + public void addOnPreDrawRunnable(Runnable r) { + } @Override - public void postInsetsAnimationCallback(Runnable r) { } + public void postInsetsAnimationCallback(Runnable r) { + } @Override public InputMethodManager getInputMethodManager() { |