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

Commit 1646b31c authored by Louis Chang's avatar Louis Chang
Browse files

Fix activities are not removed while removing the Display

Activities are re-parented to default display when the display
is removed, even when the remove-content-mode is set to
REMOVE_MODE_DESTROY_CONTENT.

Checking the remove content mode settings in the DisplayWindowSettings
vs. the settings in the DisplayInfo.

Bug: 356220670
Test: atest DisplayWindowSettingsTests
Flag: EXEMPT bugfix
Change-Id: I7754d242cdaa6f0ccf50db0de664ab183a76cbce
parent cca31ca5
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -45,7 +45,6 @@ import static android.view.Display.FLAG_CAN_SHOW_WITH_INSECURE_KEYGUARD;
import static android.view.Display.FLAG_PRIVATE;
import static android.view.Display.FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS;
import static android.view.Display.INVALID_DISPLAY;
import static android.view.Display.REMOVE_MODE_DESTROY_CONTENT;
import static android.view.Display.STATE_UNKNOWN;
import static android.view.Display.isSuspendedState;
import static android.view.InsetsSource.ID_IME;
@@ -80,6 +79,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_DIALOG;
import static android.view.WindowManager.LayoutParams.TYPE_SYSTEM_ERROR;
import static android.view.WindowManager.LayoutParams.TYPE_TOAST;
import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.REMOVE_CONTENT_MODE_DESTROY;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
@@ -6556,7 +6556,12 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    @VisibleForTesting
    boolean shouldDestroyContentOnRemove() {
        return mDisplay.getRemoveMode() == REMOVE_MODE_DESTROY_CONTENT;
        return getRemoveContentMode() == REMOVE_CONTENT_MODE_DESTROY;
    }

    @WindowManager.RemoveContentMode
    int getRemoveContentMode() {
        return mWmService.mDisplayWindowSettings.getRemoveContentModeLocked(this);
    }

    boolean shouldSleep() {
+1 −1
Original line number Diff line number Diff line
@@ -7656,7 +7656,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        displayId);
                return REMOVE_CONTENT_MODE_UNDEFINED;
            }
            return mDisplayWindowSettings.getRemoveContentModeLocked(displayContent);
            return displayContent.getRemoveContentMode();
        }
    }

+10 −0
Original line number Diff line number Diff line
@@ -309,6 +309,16 @@ public class DisplayWindowSettingsTests extends WindowTestsBase {
    public void testPublicDisplayDefaultToMoveToPrimary() {
        assertEquals(REMOVE_CONTENT_MODE_MOVE_TO_PRIMARY,
                mDisplayWindowSettings.getRemoveContentModeLocked(mSecondaryDisplay));

        // Sets the remove-content-mode and make sure the mode is updated.
        mDisplayWindowSettings.setRemoveContentModeLocked(mSecondaryDisplay,
                REMOVE_CONTENT_MODE_DESTROY);
        final int removeContentMode = mDisplayWindowSettings.getRemoveContentModeLocked(
                mSecondaryDisplay);
        assertEquals(REMOVE_CONTENT_MODE_DESTROY, removeContentMode);

        doReturn(removeContentMode).when(mSecondaryDisplay).getRemoveContentMode();
        assertTrue(mSecondaryDisplay.shouldDestroyContentOnRemove());
    }

    @Test