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

Commit cb539a54 authored by Lingyu Feng's avatar Lingyu Feng
Browse files

Notify StatusBar and NavBar via onDisplayRemoveSystemDecorations when starting mirroring

In this CL, when the connected display is switched from extended mode to
mirroring mode:
(1) WM sends onDisplayRemoveSystemDecorations() to status bar and nav bar.
(2) Status bar and nav bar then perform similar actions to those
triggered by onDisplayRemoved().

Bug: 352461502
Bug: 374240163
Flag: com.android.server.display.feature.flags.enable_display_content_mode_management
Test: manually (adb shell settings put secure mirror_built_in_display {1|0})
Change-Id: If5ebf4dbf62c37eaa5e9efdf8d7fa35babf6a36b
parent 75989f24
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -213,6 +213,11 @@ oneway interface IStatusBar
     */
    void onDisplayReady(int displayId);

    /**
     * Notifies System UI that the system decorations should be removed from the display.
     */
    void onDisplayRemoveSystemDecorations(int displayId);

    /**
     * Notifies System UI side of system bar attribute change on the specified display.
     *
+5 −0
Original line number Diff line number Diff line
@@ -274,6 +274,11 @@ public class NavigationBarControllerImpl implements
    private final CommandQueue.Callbacks mCommandQueueCallbacks = new CommandQueue.Callbacks() {
        @Override
        public void onDisplayRemoved(int displayId) {
            onDisplayRemoveSystemDecorations(displayId);
        }

        @Override
        public void onDisplayRemoveSystemDecorations(int displayId) {
            removeNavigationBar(displayId);
            mHasNavBar.delete(displayId);
        }
+20 −0
Original line number Diff line number Diff line
@@ -185,6 +185,7 @@ public class CommandQueue extends IStatusBar.Stub implements
    private static final int MSG_TOGGLE_QUICK_SETTINGS_PANEL = 82 << MSG_SHIFT;
    private static final int MSG_WALLET_ACTION_LAUNCH_GESTURE = 83 << MSG_SHIFT;
    private static final int MSG_SET_HAS_NAVIGATION_BAR = 84 << MSG_SHIFT;
    private static final int MSG_DISPLAY_REMOVE_SYSTEM_DECORATIONS = 85 << MSG_SHIFT;
    public static final int FLAG_EXCLUDE_NONE = 0;
    public static final int FLAG_EXCLUDE_SEARCH_PANEL = 1 << 0;
    public static final int FLAG_EXCLUDE_RECENTS_PANEL = 1 << 1;
@@ -419,6 +420,12 @@ public class CommandQueue extends IStatusBar.Stub implements
        default void onDisplayReady(int displayId) {
        }

        /**
         * @see IStatusBar#onDisplayRemoveSystemDecorations(int)
         */
        default void onDisplayRemoveSystemDecorations(int displayId) {
        }

        /**
         * @see DisplayTracker.Callback#onDisplayRemoved(int)
         */
@@ -1204,6 +1211,14 @@ public class CommandQueue extends IStatusBar.Stub implements
        }
    }

    @Override
    public void onDisplayRemoveSystemDecorations(int displayId) {
        synchronized (mLock) {
            mHandler.obtainMessage(MSG_DISPLAY_REMOVE_SYSTEM_DECORATIONS, displayId, 0)
                    .sendToTarget();
        }
    }

    // This was previously called from WM, but is now called from WMShell
    public void onRecentsAnimationStateChanged(boolean running) {
        synchronized (mLock) {
@@ -1841,6 +1856,11 @@ public class CommandQueue extends IStatusBar.Stub implements
                        mCallbacks.get(i).onDisplayReady(msg.arg1);
                    }
                    break;
                case MSG_DISPLAY_REMOVE_SYSTEM_DECORATIONS:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).onDisplayRemoveSystemDecorations(msg.arg1);
                    }
                    break;
                case MSG_RECENTS_ANIMATION_STATE_CHANGED:
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).onRecentsAnimationStateChanged(msg.arg1 > 0);
+7 −0
Original line number Diff line number Diff line
@@ -177,6 +177,13 @@ public interface StatusBarManagerInternal {
     */
    void onDisplayReady(int displayId);

    /**
     * Notifies System UI that the system decorations should be removed from the display.
     *
     * @param displayId display ID
     */
    void onDisplayRemoveSystemDecorations(int displayId);

    /** @see com.android.internal.statusbar.IStatusBar#onSystemBarAttributesChanged */
    void onSystemBarAttributesChanged(int displayId, @Appearance int appearance,
            AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme,
+20 −0
Original line number Diff line number Diff line
@@ -792,6 +792,26 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
            }
        }

        @Override
        public void onDisplayRemoveSystemDecorations(int displayId) {
            if (isVisibleBackgroundUserOnDisplay(displayId)) {
                if (SPEW) {
                    Slog.d(TAG,
                            "Skipping onDisplayRemoveSystemDecorations for visible background "
                                    + "user "
                                    + mUserManagerInternal.getUserAssignedToDisplay(displayId));
                }
                return;
            }

            IStatusBar bar = mBar;
            if (bar != null) {
                try {
                    bar.onDisplayRemoveSystemDecorations(displayId);
                } catch (RemoteException ex) {}
            }
        }

        @Override
        public void onSystemBarAttributesChanged(int displayId, @Appearance int appearance,
                AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme,
Loading