summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java11
-rw-r--r--services/core/java/com/android/server/wm/RootWindowContainer.java80
2 files changed, 53 insertions, 38 deletions
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 baa9acaafa4b..1fc2fb876432 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
@@ -204,12 +204,6 @@ public class Transitions implements RemoteCallable<Transitions>,
*/
private static final int SYNC_ALLOWANCE_MS = 120;
- /**
- * Keyguard gets a more generous timeout to finish its animations, because we are always holding
- * a sleep token during occlude/unocclude transitions and we want them to finish playing cleanly
- */
- private static final int SYNC_ALLOWANCE_KEYGUARD_MS = 2000;
-
/** For testing only. Disables the force-finish timeout on sync. */
private boolean mDisableForceSync = false;
@@ -1203,11 +1197,8 @@ public class Transitions implements RemoteCallable<Transitions>,
if (track.mActiveTransition == playing) {
if (!mDisableForceSync) {
// Give it a short amount of time to process it before forcing.
- final int tolerance = KeyguardTransitionHandler.handles(playing.mInfo)
- ? SYNC_ALLOWANCE_KEYGUARD_MS
- : SYNC_ALLOWANCE_MS;
mMainExecutor.executeDelayed(
- () -> finishForSync(reason, trackIdx, playing), tolerance);
+ () -> finishForSync(reason, trackIdx, playing), SYNC_ALLOWANCE_MS);
}
break;
}
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 4a467dfbcd14..f64417d840bf 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -174,10 +174,14 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
private static final int SET_SCREEN_BRIGHTNESS_OVERRIDE = 1;
private static final int SET_USER_ACTIVITY_TIMEOUT = 2;
+ private static final int MSG_SEND_SLEEP_TRANSITION = 3;
+
static final String TAG_TASKS = TAG + POSTFIX_TASKS;
static final String TAG_STATES = TAG + POSTFIX_STATES;
private static final String TAG_RECENTS = TAG + POSTFIX_RECENTS;
+ private static final long SLEEP_TRANSITION_WAIT_MILLIS = 1000L;
+
private Object mLastWindowFreezeSource = null;
private float mScreenBrightnessOverride = PowerManager.BRIGHTNESS_INVALID_FLOAT;
private long mUserActivityTimeout = -1;
@@ -1132,6 +1136,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
mWmService.mPowerManagerInternal.
setUserActivityTimeoutOverrideFromWindowManager((Long) msg.obj);
break;
+ case MSG_SEND_SLEEP_TRANSITION:
+ synchronized (mService.mGlobalLock) {
+ sendSleepTransition((DisplayContent) msg.obj);
+ }
+ break;
default:
break;
}
@@ -2442,8 +2451,38 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
return result;
}
+ void sendSleepTransition(final DisplayContent display) {
+ // We don't actually care about collecting anything here. We really just want
+ // this as a signal to the transition-player.
+ final Transition transition = new Transition(TRANSIT_SLEEP, 0 /* flags */,
+ display.mTransitionController, mWmService.mSyncEngine);
+ final TransitionController.OnStartCollect sendSleepTransition = (deferred) -> {
+ if (deferred && !display.shouldSleep()) {
+ transition.abort();
+ } else {
+ display.mTransitionController.requestStartTransition(transition,
+ null /* trigger */, null /* remote */, null /* display */);
+ // Force playing immediately so that unrelated ops can't be collected.
+ transition.playNow();
+ }
+ };
+ if (!display.mTransitionController.isCollecting()) {
+ // Since this bypasses sync, submit directly ignoring whether sync-engine
+ // is active.
+ if (mWindowManager.mSyncEngine.hasActiveSync()) {
+ Slog.w(TAG, "Ongoing sync outside of a transition.");
+ }
+ display.mTransitionController.moveToCollecting(transition);
+ sendSleepTransition.onCollectStarted(false /* deferred */);
+ } else {
+ display.mTransitionController.startCollectOrQueue(transition,
+ sendSleepTransition);
+ }
+ }
+
void applySleepTokens(boolean applyToRootTasks) {
- boolean builtSleepTransition = false;
+ boolean scheduledSleepTransition = false;
+
for (int displayNdx = getChildCount() - 1; displayNdx >= 0; --displayNdx) {
// Set the sleeping state of the display.
final DisplayContent display = getChildAt(displayNdx);
@@ -2453,35 +2492,16 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
}
display.setIsSleeping(displayShouldSleep);
- if (display.mTransitionController.isShellTransitionsEnabled() && !builtSleepTransition
+ if (display.mTransitionController.isShellTransitionsEnabled()
+ && !scheduledSleepTransition
// Only care if there are actual sleep tokens.
&& displayShouldSleep && !display.mAllSleepTokens.isEmpty()) {
- builtSleepTransition = true;
- // We don't actually care about collecting anything here. We really just want
- // this as a signal to the transition-player.
- final Transition transition = new Transition(TRANSIT_SLEEP, 0 /* flags */,
- display.mTransitionController, mWmService.mSyncEngine);
- final TransitionController.OnStartCollect sendSleepTransition = (deferred) -> {
- if (deferred && !display.shouldSleep()) {
- transition.abort();
- } else {
- display.mTransitionController.requestStartTransition(transition,
- null /* trigger */, null /* remote */, null /* display */);
- // Force playing immediately so that unrelated ops can't be collected.
- transition.playNow();
- }
- };
- if (!display.mTransitionController.isCollecting()) {
- // Since this bypasses sync, submit directly ignoring whether sync-engine
- // is active.
- if (mWindowManager.mSyncEngine.hasActiveSync()) {
- Slog.w(TAG, "Ongoing sync outside of a transition.");
- }
- display.mTransitionController.moveToCollecting(transition);
- sendSleepTransition.onCollectStarted(false /* deferred */);
- } else {
- display.mTransitionController.startCollectOrQueue(transition,
- sendSleepTransition);
+ scheduledSleepTransition = true;
+
+ if (!mHandler.hasMessages(MSG_SEND_SLEEP_TRANSITION)) {
+ mHandler.sendMessageDelayed(
+ mHandler.obtainMessage(MSG_SEND_SLEEP_TRANSITION, display),
+ SLEEP_TRANSITION_WAIT_MILLIS);
}
}
@@ -2535,6 +2555,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
}
});
}
+
+ if (!scheduledSleepTransition) {
+ mHandler.removeMessages(MSG_SEND_SLEEP_TRANSITION);
+ }
}
protected Task getRootTask(int rooTaskId) {