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

This commit is contained in:
Jorge Gil
2023-05-25 20:21:34 +00:00
committed by Android (Google) Code Review
4 changed files with 48 additions and 26 deletions

View File

@@ -16,9 +16,12 @@
package com.android.wm.shell.transition; 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_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM; 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_OPEN;
import static android.view.WindowManager.TRANSIT_SLEEP; import static android.view.WindowManager.TRANSIT_SLEEP;
import static android.view.WindowManager.TRANSIT_TO_BACK; 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); mOrganizer.startTransition(transitionToken, wct != null && wct.isEmpty() ? null : wct);
active.mToken = transitionToken; active.mToken = transitionToken;
// Currently, WMCore only does one transition at a time. If it makes a requestStart, it // Currently, WMCore only does one transition at a time. If it makes a requestStart, it

View File

@@ -6511,6 +6511,22 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
.getKeyguardController().isDisplayOccluded(mDisplayId); .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 @VisibleForTesting
void removeAllTasks() { void removeAllTasks() {
forAllTasks((t) -> { t.getRootTask().removeChild(t, "removeAllTasks"); }); forAllTasks((t) -> { t.getRootTask().removeChild(t, "removeAllTasks"); });

View File

@@ -17,7 +17,6 @@
package com.android.server.wm; package com.android.server.wm;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM; 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.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY; import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
@@ -411,19 +410,20 @@ class KeyguardController {
if (waitAppTransition) { if (waitAppTransition) {
mService.deferWindowLayout(); mService.deferWindowLayout();
try { try {
mRootWindowContainer.getDefaultDisplay() if (isDisplayOccluded(DEFAULT_DISPLAY)) {
.requestTransitionAndLegacyPrepare( mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare(
isDisplayOccluded(DEFAULT_DISPLAY) TRANSIT_KEYGUARD_OCCLUDE,
? TRANSIT_KEYGUARD_OCCLUDE topActivity != null ? topActivity.getRootTask() : null);
: TRANSIT_KEYGUARD_UNOCCLUDE, 0 /* flags */); } else {
mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare(
TRANSIT_KEYGUARD_UNOCCLUDE, 0 /* flags */);
}
updateKeyguardSleepToken(DEFAULT_DISPLAY); updateKeyguardSleepToken(DEFAULT_DISPLAY);
mWindowManager.executeAppTransition(); mWindowManager.executeAppTransition();
} finally { } finally {
mService.continueWindowLayout(); mService.continueWindowLayout();
} }
} }
dismissMultiWindowModeForTaskIfNeeded(displayId, topActivity != null
? topActivity.getRootTask() : null);
} }
/** /**
@@ -473,6 +473,14 @@ class KeyguardController {
return getDisplayState(displayId).mOccluded; 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. * @return true if Keyguard can be currently dismissed without entering credentials.
*/ */
@@ -488,22 +496,6 @@ class KeyguardController {
return getDisplayState(DEFAULT_DISPLAY).mShowingDream; 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() { private void updateKeyguardSleepToken() {
for (int displayNdx = mRootWindowContainer.getChildCount() - 1; for (int displayNdx = mRootWindowContainer.getChildCount() - 1;
displayNdx >= 0; displayNdx--) { displayNdx >= 0; displayNdx--) {

View File

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