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

Commit 5dd9f71c authored by Garfield Tan's avatar Garfield Tan Committed by Android (Google) Code Review
Browse files

Merge "Fix show on lock for freeform mode properly"

parents 5377c1e0 7caf48e7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -3592,7 +3592,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    }

    /**
     * @return {@code true} if the activity windowing mode is not
     * @return {@code true} if the activity windowing mode is not in
     *         {@link android.app.WindowConfiguration#WINDOWING_MODE_PINNED} and a) activity
     *         contains windows that have {@link LayoutParams#FLAG_SHOW_WHEN_LOCKED} set or if the
     *         activity has set {@link #mShowWhenLocked}, or b) if the activity has set
@@ -7546,7 +7546,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
    /**
     * Determines whether this ActivityRecord can turn the screen on. It checks whether the flag
     * {@link ActivityRecord#getTurnScreenOnFlag} is set and checks whether the ActivityRecord
     * should be visible depending on Keyguard and window state.
     * should be visible depending on Keyguard state.
     *
     * @return true if the screen can be turned on, false otherwise.
     */
@@ -7555,7 +7555,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
            return false;
        }
        final Task stack = getRootTask();
        return stack != null && !stack.inMultiWindowMode()
        return stack != null
                && mStackSupervisor.getKeyguardController().checkKeyguardVisibility(this);
    }

+31 −15
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.wm;

import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
@@ -166,7 +167,7 @@ class KeyguardController {

        if (keyguardChanged) {
            // Irrelevant to AOD.
            dismissDockedStackIfNeeded();
            dismissMultiWindowModeForTaskIfNeeded(null /* currentTaskControllsingOcclusion */);
            setKeyguardGoingAway(false);
            if (keyguardShowing) {
                mDismissalRequested = false;
@@ -334,8 +335,12 @@ class KeyguardController {

    /**
     * Called when occluded state changed.
     *
     * @param currentTaskControllingOcclusion the task that controls the state whether keyguard
     *      should be occluded. That is the task to be shown on top of keyguard if it requests so.
     */
    private void handleOccludedChanged(int displayId) {
    private void handleOccludedChanged(
            int displayId, @Nullable Task currentTaskControllingOcclusion) {
        // TODO(b/113840485): Handle app transition for individual display, and apply occluded
        // state change to secondary displays.
        // For now, only default display fully supports occluded change. Other displays only
@@ -364,7 +369,7 @@ class KeyguardController {
                mService.continueWindowLayout();
            }
        }
        dismissDockedStackIfNeeded();
        dismissMultiWindowModeForTaskIfNeeded(currentTaskControllingOcclusion);
    }

    /**
@@ -427,19 +432,30 @@ class KeyguardController {
        }
    }

    private void dismissDockedStackIfNeeded() {
    private void dismissMultiWindowModeForTaskIfNeeded(
            @Nullable Task currentTaskControllingOcclusion) {
        // TODO(b/113840485): Handle docked stack for individual display.
        if (mKeyguardShowing && isDisplayOccluded(DEFAULT_DISPLAY)) {
        if (!mKeyguardShowing || !isDisplayOccluded(DEFAULT_DISPLAY)) {
            return;
        }

        // Dismiss split screen

        // The lock screen is currently showing, but is occluded by a window that can
        // show on top of the lock screen. In this can we want to dismiss the docked
        // stack since it will be complicated/risky to try to put the activity on top
        // of the lock screen in the right fullscreen configuration.
            final TaskDisplayArea taskDisplayArea = mRootWindowContainer
                    .getDefaultTaskDisplayArea();
            if (!taskDisplayArea.isSplitScreenModeActivated()) {
        final TaskDisplayArea taskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea();
        if (taskDisplayArea.isSplitScreenModeActivated()) {
            taskDisplayArea.onSplitScreenModeDismissed();
        }

        // Dismiss freeform windowing mode
        if (currentTaskControllingOcclusion == null) {
            return;
        }
            taskDisplayArea.onSplitScreenModeDismissed();
        if (currentTaskControllingOcclusion.inFreeformWindowingMode()) {
            currentTaskControllingOcclusion.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        }
    }

@@ -572,7 +588,7 @@ class KeyguardController {
            }

            if (lastOccluded != mOccluded) {
                controller.handleOccludedChanged(mDisplayId);
                controller.handleOccludedChanged(mDisplayId, task);
            }
        }

+3 −3
Original line number Diff line number Diff line
@@ -1673,7 +1673,7 @@ public class ActivityRecordTests extends WindowTestsBase {
    }

    @Test
    public void testCanTurnScreenOn() {
    public void testFullscreenWindowCanTurnScreenOn() {
        mStack.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
        doReturn(true).when(mActivity).getTurnScreenOnFlag();

@@ -1681,11 +1681,11 @@ public class ActivityRecordTests extends WindowTestsBase {
    }

    @Test
    public void testFreeformWindowCantTurnScreenOn() {
    public void testFreeformWindowCanTurnScreenOn() {
        mStack.setWindowingMode(WINDOWING_MODE_FREEFORM);
        doReturn(true).when(mActivity).getTurnScreenOnFlag();

        assertFalse(mActivity.canTurnScreenOn());
        assertTrue(mActivity.canTurnScreenOn());
    }

    @Test