Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c87d9cb authored by Calvin Huang's avatar Calvin Huang
Browse files

Handle dialogs for remote insets controller

Dialog from app or system should not change the system bar visibilty
set by the top fullscreen opaque window.

Notifiy the remote insets controller with the top full screen
opaque window if finding the focused window is a dialog.

Dialog from app share the same package name as it's owner, so checking
if the window is dialog first.

Flag: EXEMPT bugfix
Bug: 357705344
Test: manual
Change-Id: I668273e9c7ae81db2d2a52546bf88d0fbb148149
parent f23c500e
Loading
Loading
Loading
Loading
+32 −16
Original line number Diff line number Diff line
@@ -502,13 +502,6 @@ class InsetsPolicy {
            // Notification shade has control anyways, no reason to force anything.
            return focusedWin;
        }
        if (remoteInsetsControllerControlsSystemBars(focusedWin)) {
            ComponentName component = focusedWin.mActivityRecord != null
                    ? focusedWin.mActivityRecord.mActivityComponent : null;
            mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged(
                    component, focusedWin.getRequestedVisibleTypes());
            return mDisplayContent.mRemoteInsetsControlTarget;
        }
        if (areTypesForciblyShowing(Type.statusBars())) {
            // Status bar is forcibly shown. We don't want the client to control the status bar, and
            // we will dispatch the real visibility of status bar to the client.
@@ -525,8 +518,18 @@ 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 focusedWin;
    }

@@ -562,13 +565,6 @@ class InsetsPolicy {
                return focusedWin;
            }
        }
        if (remoteInsetsControllerControlsSystemBars(focusedWin)) {
            ComponentName component = focusedWin.mActivityRecord != null
                    ? focusedWin.mActivityRecord.mActivityComponent : null;
            mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged(
                    component, focusedWin.getRequestedVisibleTypes());
            return mDisplayContent.mRemoteInsetsControlTarget;
        }
        if (areTypesForciblyShowing(Type.navigationBars())) {
            // Navigation bar is forcibly shown. We don't want the client to control the navigation
            // bar, and we will dispatch the real visibility of navigation bar to the client.
@@ -586,11 +582,31 @@ 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 focusedWin;
    }

    private void notifyRemoteInsetsController(@Nullable WindowState win) {
        if (win == null) {
            return;
        }
        ComponentName component = win.mActivityRecord != null
                ? win.mActivityRecord.mActivityComponent : null;
        mDisplayContent.mRemoteInsetsControlTarget.topFocusedWindowChanged(
                component, win.getRequestedVisibleTypes());
    }

    boolean areTypesForciblyShowing(@InsetsType int types) {
        return (mForcedShowingTypes & types) == types;
    }