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

Commit e2b9205b authored by Kazuki Takise's avatar Kazuki Takise
Browse files

Don't show immersive confirmation for presentation

ag/31583844 made presentation windows immersive but as a side
effect, immersive confirmation started to show up.

This is undesirable for presentation windows because they are
designed so the user doesn't have to directly interract with the
window and focus should stay with their host activity.

This change adds window type argument to onImmersiveModeChanged()
so we can skip showing the dialog for presentations.

Flag: com.android.window.flags.enable_presentation_for_connected_displays
Bug: 397597400
Test: atest PresentationTest
Change-Id: I8e43711222584c2ec7efc31160d62ba03b936605
parent a54f82cd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ oneway interface IStatusBar
     * Notify system UI the immersive mode changed. This shall be removed when client immersive is
     * enabled.
     */
    void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode);
    void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode, int windowType);

    void dismissKeyboardShortcutsMenu();
    void toggleKeyboardShortcutsMenu(int deviceId);
+3 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import static android.service.quickaccesswallet.Flags.FLAG_LAUNCH_WALLET_OPTION_
import static android.service.quickaccesswallet.Flags.FLAG_LAUNCH_WALLET_VIA_SYSUI_CALLBACKS;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowInsetsController.BEHAVIOR_DEFAULT;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;

import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
@@ -556,9 +557,9 @@ public class CommandQueueTest extends SysuiTestCase {
    @Test
    public void testImmersiveModeChanged() {
        final int displayAreaId = 10;
        mCommandQueue.immersiveModeChanged(displayAreaId, true);
        mCommandQueue.immersiveModeChanged(displayAreaId, true, TYPE_APPLICATION);
        waitForIdleSync();
        verify(mCallbacks).immersiveModeChanged(displayAreaId, true);
        verify(mCallbacks).immersiveModeChanged(displayAreaId, true, TYPE_APPLICATION);
    }

    @Test
+8 −3
Original line number Diff line number Diff line
@@ -580,7 +580,8 @@ public class CommandQueue extends IStatusBar.Stub implements
        /**
         * @see IStatusBar#immersiveModeChanged
         */
        default void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode) {}
        default void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode,
                int windowType) {}

        /**
         * @see IStatusBar#moveFocusedTaskToDesktop(int)
@@ -876,11 +877,13 @@ public class CommandQueue extends IStatusBar.Stub implements
    }

    @Override
    public void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode) {
    public void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode,
            int windowType) {
        synchronized (mLock) {
            final SomeArgs args = SomeArgs.obtain();
            args.argi1 = rootDisplayAreaId;
            args.argi2 = isImmersiveMode ? 1 : 0;
            args.argi3 = windowType;
            mHandler.obtainMessage(MSG_IMMERSIVE_CHANGED, args).sendToTarget();
        }
    }
@@ -2030,8 +2033,10 @@ public class CommandQueue extends IStatusBar.Stub implements
                    args = (SomeArgs) msg.obj;
                    int rootDisplayAreaId = args.argi1;
                    boolean isImmersiveMode = args.argi2 != 0;
                    int windowType = args.argi3;
                    for (int i = 0; i < mCallbacks.size(); i++) {
                        mCallbacks.get(i).immersiveModeChanged(rootDisplayAreaId, isImmersiveMode);
                        mCallbacks.get(i).immersiveModeChanged(rootDisplayAreaId, isImmersiveMode,
                                windowType);
                    }
                    break;
                case MSG_ENTER_DESKTOP: {
+7 −2
Original line number Diff line number Diff line
@@ -23,6 +23,8 @@ import static android.app.StatusBarManager.DISABLE_HOME;
import static android.app.StatusBarManager.DISABLE_RECENT;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
import static android.view.WindowManager.LayoutParams.TYPE_PRIVATE_PRESENTATION;
import static android.window.DisplayAreaOrganizer.FEATURE_UNDEFINED;
import static android.window.DisplayAreaOrganizer.KEY_ROOT_DISPLAY_AREA_ID;

@@ -208,7 +210,8 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
    }

    @Override
    public void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode) {
    public void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode,
            int windowType) {
        mHandler.removeMessages(H.SHOW);
        if (isImmersiveMode) {
            if (DEBUG) Log.d(TAG, "immersiveModeChanged() sConfirmed=" + sConfirmed);
@@ -221,7 +224,9 @@ public class ImmersiveModeConfirmation implements CoreStartable, CommandQueue.Ca
                    && mCanSystemBarsBeShownByUser
                    && !mNavBarEmpty
                    && !UserManager.isDeviceInDemoMode(mDisplayContext)
                    && (mLockTaskState != LOCK_TASK_MODE_LOCKED)) {
                    && (mLockTaskState != LOCK_TASK_MODE_LOCKED)
                    && windowType != TYPE_PRESENTATION
                    && windowType != TYPE_PRIVATE_PRESENTATION) {
                final Message msg = mHandler.obtainMessage(
                        H.SHOW);
                msg.arg1 = rootDisplayAreaId;
+3 −1
Original line number Diff line number Diff line
@@ -160,8 +160,10 @@ public interface StatusBarManagerInternal {
     * @param displayId The changed display Id.
     * @param rootDisplayAreaId The changed display area Id.
     * @param isImmersiveMode {@code true} if the display area get into immersive mode.
     * @param windowType The window type of the controlling window.
     */
    void immersiveModeChanged(int displayId, int rootDisplayAreaId, boolean isImmersiveMode);
    void immersiveModeChanged(int displayId, int rootDisplayAreaId, boolean isImmersiveMode,
            int windowType);

    /**
     * Show a rotation suggestion that a user may approve to rotate the screen.
Loading