From 232e11a05734c2b86e39b6ee959efd28e93b03fb Mon Sep 17 00:00:00 2001 From: Jorge Gil Date: Mon, 3 Apr 2023 19:11:31 +0000 Subject: Change freeform activity occluding keyguard to fullscreen Lets WM Shell change the windowing mode of a freeform task that is occluding the keyguard to fullscreen. There's two scenarios/code paths that this CL changes: 1) Unsecure keyguard: when a freeform task is on top and has the FLAG_DISMISS_KEYGUARD flag set, RootWindowContainer#applySleepTokens starts a transition of type TRANSIT_KEYGUARD_OCCLUDE. By setting the occluding activity as the triggerTask, WM Shell is able to intercept the request and change the windowing mode to fullscreen before the transition runs/animates. 2) Secure keyguard: when a freeform task is on top and after off/on, A) Unlocking the keyguard starts the activity. If it sets setShowWhenLocked==true, it used to change the windowing mode to fullscreen, which was unwanted behavior since the app will not be shown on top of the keyguard since it was unlocked and going away. B) If the activity starts without unlocking the keyguard (e.g. from quick settings), and setShowWhenLocked is set to true, then the windowing mode should change to fullscreen as it will be shown over the keyguard. To handle both A) and B), instead of always dismissing the freeform mode in #handleOccludedChange, add the occluding task as the trigger task of the TRANSIT_KEYGUARD_OCCLUDE transition that is also started in #handleOcclusionChange, so that WM Shell can intercept it and change the windowing mode. Bug: 261765739 Test: (1) with unsecure keyguard, open calculator, enter freeform, turn screen off/on, verify calculator is in fullscreen on top of keyguard; (2A) with secure keyguard, enter freeform, off/on, unlock, verify calculator is still in freeform mode; (2B) with secure keyguard, enter freeform, off/on, open calculator from quick settings, verify calculator is shown on top of the keyguard in fullscreen. Change-Id: Idac9e012d25c50b73eba8afe9088d77043c68a85 --- .../src/com/android/wm/shell/transition/Transitions.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libs') diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java index 3b306e793640..e6d4603db10d 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java @@ -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, } } } + 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 -- cgit v1.2.3-59-g8ed1b