Stop animation when screen times out and the user turns on the phone.

When screen turns on, display off sleep token and keyguard sleep token
are both removed. However it's not deterministic which one is removed
first, so we have to take care both cases.

Test: atest KeyguardTransitionTests and manual.
  1. set lock mode to none (keep showing Settings activity)
  2. wait until the screen times out
  3. tap screen to turn on the screen
  4. verity no animation is applied on the Settings activity
Bug: 189438446
Change-Id: I2f4dd4f62b5c52f50e92bd405bea9a23e07217b8
This commit is contained in:
Issei Suzuki
2021-07-16 13:47:29 +02:00
parent 38f16f29d8
commit 53f6b7939b
2 changed files with 31 additions and 13 deletions

View File

@@ -66,6 +66,8 @@ class KeyguardController {
private static final String TAG = TAG_WITH_CLASS_NAME ? "KeyguardController" : TAG_ATM;
static final String KEYGUARD_SLEEP_TOKEN_TAG = "keyguard";
private final ActivityTaskSupervisor mTaskSupervisor;
private WindowManagerService mWindowManager;
private boolean mKeyguardShowing;
@@ -82,7 +84,7 @@ class KeyguardController {
ActivityTaskSupervisor taskSupervisor) {
mService = service;
mTaskSupervisor = taskSupervisor;
mSleepTokenAcquirer = mService.new SleepTokenAcquirerImpl("keyguard");
mSleepTokenAcquirer = mService.new SleepTokenAcquirerImpl(KEYGUARD_SLEEP_TOKEN_TAG);
}
void setWindowManager(WindowManagerService windowManager) {

View File

@@ -66,6 +66,7 @@ import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP;
import static com.android.server.wm.ActivityTaskSupervisor.PRESERVE_WINDOWS;
import static com.android.server.wm.ActivityTaskSupervisor.dumpHistoryList;
import static com.android.server.wm.ActivityTaskSupervisor.printThisActivity;
import static com.android.server.wm.KeyguardController.KEYGUARD_SLEEP_TOKEN_TAG;
import static com.android.server.wm.RootWindowContainerProto.IS_HOME_RECENTS_COMPONENT;
import static com.android.server.wm.RootWindowContainerProto.KEYGUARD_CONTROLLER;
import static com.android.server.wm.RootWindowContainerProto.WINDOW_CONTAINER;
@@ -2048,7 +2049,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
/**
* Move root task with all its existing content to specified task display area.
*
* @param rootTaskId Id of root task to move.
* @param rootTaskId Id of root task to move.
* @param taskDisplayArea The task display area to move root task to.
* @param onTop Indicates whether container should be place on top or on bottom.
*/
@@ -2086,9 +2087,9 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
/**
* Move root task with all its existing content to specified display.
*
* @param rootTaskId Id of root task to move.
* @param displayId Id of display to move root task to.
* @param onTop Indicates whether container should be place on top or on bottom.
* @param rootTaskId Id of root task to move.
* @param displayId Id of display to move root task to.
* @param onTop Indicates whether container should be place on top or on bottom.
*/
void moveRootTaskToDisplay(int rootTaskId, int displayId, boolean onTop) {
final DisplayContent displayContent = getDisplayContentOrCreate(displayId);
@@ -2171,7 +2172,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
final ActivityRecord oldTopActivity = task.getTopMostActivity();
if (oldTopActivity != null && oldTopActivity.isState(STOPPED)
&& task.getDisplayContent().mAppTransition.containsTransitRequest(
TRANSIT_TO_BACK)) {
TRANSIT_TO_BACK)) {
task.getDisplayContent().mClosingApps.add(oldTopActivity);
oldTopActivity.mRequestForceTransition = true;
}
@@ -2663,13 +2664,28 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
}
mSleepTokens.remove(token.mHashKey);
final DisplayContent display = getDisplayContent(token.mDisplayId);
if (display != null) {
display.mAllSleepTokens.remove(token);
if (display.mAllSleepTokens.isEmpty()) {
mService.updateSleepIfNeededLocked();
if (token.mTag.equals(DISPLAY_OFF_SLEEP_TOKEN_TAG)) {
display.mSkipAppTransitionAnimation = true;
}
if (display == null) {
Slog.d(TAG, "Remove sleep token for non-existing display: " + token + " from "
+ Debug.getCallers(6));
return;
}
display.mAllSleepTokens.remove(token);
if (display.mAllSleepTokens.isEmpty()) {
mService.updateSleepIfNeededLocked();
// Assuming no lock screen is set and a user launches an activity, turns off the screen
// and turn on the screen again, then the launched activity should be displayed on the
// screen without app transition animation. When the screen turns on, both keyguard
// sleep token and display off sleep token are removed, but the order is
// non-deterministic.
// Note: Display#mSkipAppTransitionAnimation will be ignored when keyguard related
// transition exists, so this affects only when no lock screen is set. Otherwise
// keyguard going away animation will be played.
// See also AppTransitionController#getTransitCompatType for more details.
if ((!mTaskSupervisor.getKeyguardController().isDisplayOccluded(display.mDisplayId)
&& token.mTag.equals(KEYGUARD_SLEEP_TOKEN_TAG))
|| token.mTag.equals(DISPLAY_OFF_SLEEP_TOKEN_TAG)) {
display.mSkipAppTransitionAnimation = true;
}
}
}