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

Commit c1e825ac authored by Jorge Gil's avatar Jorge Gil Committed by Automerger Merge Worker
Browse files

Merge "Change freeform activity occluding keyguard to fullscreen" into udc-dev am: d48052dd

parents 18aaacce d48052dd
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -16,9 +16,12 @@

package com.android.wm.shell.transition;

import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM;
import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_SLEEP;
import static android.view.WindowManager.TRANSIT_TO_BACK;
@@ -1081,6 +1084,16 @@ public class Transitions implements RemoteCallable<Transitions>,
                }
            }
        }
        if (request.getType() == TRANSIT_KEYGUARD_OCCLUDE && request.getTriggerTask() != null
                && request.getTriggerTask().getWindowingMode() == WINDOWING_MODE_FREEFORM) {
            // This freeform task is on top of keyguard, so its windowing mode should be changed to
            // fullscreen.
            if (wct == null) {
                wct = new WindowContainerTransaction();
            }
            wct.setWindowingMode(request.getTriggerTask().token, WINDOWING_MODE_FULLSCREEN);
            wct.setBounds(request.getTriggerTask().token, null);
        }
        mOrganizer.startTransition(transitionToken, wct != null && wct.isEmpty() ? null : wct);
        active.mToken = transitionToken;
        // Currently, WMCore only does one transition at a time. If it makes a requestStart, it
+16 −0
Original line number Diff line number Diff line
@@ -6511,6 +6511,22 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
                .getKeyguardController().isDisplayOccluded(mDisplayId);
    }

    /**
     * @return the task that is occluding the keyguard
     */
    @Nullable
    Task getTaskOccludingKeyguard() {
        final KeyguardController keyguardController = mRootWindowContainer.mTaskSupervisor
                .getKeyguardController();
        if (keyguardController.getTopOccludingActivity(mDisplayId) != null) {
            return keyguardController.getTopOccludingActivity(mDisplayId).getRootTask();
        }
        if (keyguardController.getDismissKeyguardActivity(mDisplayId) != null) {
            return keyguardController.getDismissKeyguardActivity(mDisplayId).getRootTask();
        }
        return null;
    }

    @VisibleForTesting
    void removeAllTasks() {
        forAllTasks((t) -> { t.getRootTask().removeChild(t, "removeAllTasks"); });
+16 −24
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package com.android.server.wm;

import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
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;
@@ -411,19 +410,20 @@ class KeyguardController {
        if (waitAppTransition) {
            mService.deferWindowLayout();
            try {
                mRootWindowContainer.getDefaultDisplay()
                        .requestTransitionAndLegacyPrepare(
                                isDisplayOccluded(DEFAULT_DISPLAY)
                                        ? TRANSIT_KEYGUARD_OCCLUDE
                                        : TRANSIT_KEYGUARD_UNOCCLUDE, 0 /* flags */);
                if (isDisplayOccluded(DEFAULT_DISPLAY)) {
                    mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare(
                            TRANSIT_KEYGUARD_OCCLUDE,
                            topActivity != null ? topActivity.getRootTask() : null);
                } else {
                    mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare(
                            TRANSIT_KEYGUARD_UNOCCLUDE, 0 /* flags */);
                }
                updateKeyguardSleepToken(DEFAULT_DISPLAY);
                mWindowManager.executeAppTransition();
            } finally {
                mService.continueWindowLayout();
            }
        }
        dismissMultiWindowModeForTaskIfNeeded(displayId, topActivity != null
                ? topActivity.getRootTask() : null);
    }

    /**
@@ -473,6 +473,14 @@ class KeyguardController {
        return getDisplayState(displayId).mOccluded;
    }

    ActivityRecord getTopOccludingActivity(int displayId) {
        return getDisplayState(displayId).mTopOccludesActivity;
    }

    ActivityRecord getDismissKeyguardActivity(int displayId) {
        return getDisplayState(displayId).mDismissingKeyguardActivity;
    }

    /**
     * @return true if Keyguard can be currently dismissed without entering credentials.
     */
@@ -488,22 +496,6 @@ class KeyguardController {
        return getDisplayState(DEFAULT_DISPLAY).mShowingDream;
    }

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

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

    private void updateKeyguardSleepToken() {
        for (int displayNdx = mRootWindowContainer.getChildCount() - 1;
             displayNdx >= 0; displayNdx--) {
+3 −2
Original line number Diff line number Diff line
@@ -2376,6 +2376,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
            if (!displayShouldSleep && display.mTransitionController.isShellTransitionsEnabled()
                    && !display.mTransitionController.isCollecting()) {
                int transit = TRANSIT_NONE;
                Task startTask = null;
                if (!display.getDisplayPolicy().isAwake()) {
                    // Note that currently this only happens on default display because non-default
                    // display is always awake.
@@ -2383,12 +2384,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
                } else if (display.isKeyguardOccluded()) {
                    // The display was awake so this is resuming activity for occluding keyguard.
                    transit = WindowManager.TRANSIT_KEYGUARD_OCCLUDE;
                    startTask = display.getTaskOccludingKeyguard();
                }
                if (transit != TRANSIT_NONE) {
                    display.mTransitionController.requestStartTransition(
                            display.mTransitionController.createTransition(transit),
                            null /* startTask */, null /* remoteTransition */,
                            null /* displayChange */);
                            startTask, null /* remoteTransition */, null /* displayChange */);
                }
            }
            // Set the sleeping state of the root tasks on the display.