Skip screen animation if it is off

This is similar to legacy WindowManagerService#startFreezingDisplay
that only runs animation when screen is on.

So if display is resized or rotated when screen off, it can go the
end state directly, which is more efficiency and also avoid seeing
partial animation when turning screen on.

This may slightly reduce some latency of display switch.

Bug: 282110960
Bug: 281067141
Test: On a device which support display switch.
      Launch an activity that keeps screen on.
      Turn on auto rotation for inner display, off for outer.
      Rotate inner display to 90 degree.
      Switch to outer display with a nosensor activity.
      The outer display should show in rotation 0 directly
      instead of additional rotation animation.
Change-Id: I5cff845810ef6da69adb88be2a24858388be2acf
This commit is contained in:
Riddle Hsu
2023-05-22 23:37:26 +08:00
parent d62eae979e
commit bf312b0ee0
4 changed files with 17 additions and 3 deletions

View File

@@ -554,6 +554,13 @@ public interface WindowManager extends ViewManager {
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT = (1 << 9); // 0x200
/**
* Transition flag: The transition is prepared when nothing is visible on screen, e.g. screen
* is off. The animation handlers can decide whether to skip animations.
* @hide
*/
int TRANSIT_FLAG_INVISIBLE = (1 << 10); // 0x400
/**
* @hide
*/
@@ -567,7 +574,8 @@ public interface WindowManager extends ViewManager {
TRANSIT_FLAG_KEYGUARD_LOCKED,
TRANSIT_FLAG_IS_RECENTS,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT
TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_LAUNCHER_CLEAR_SNAPSHOT,
TRANSIT_FLAG_INVISIBLE,
})
@Retention(RetentionPolicy.SOURCE)
@interface TransitionFlags {}

View File

@@ -299,7 +299,8 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
}
// Early check if the transition doesn't warrant an animation.
if (Transitions.isAllNoAnimation(info) || Transitions.isAllOrderOnly(info)) {
if (Transitions.isAllNoAnimation(info) || Transitions.isAllOrderOnly(info)
|| (info.getFlags() & WindowManager.TRANSIT_FLAG_INVISIBLE) != 0) {
startTransaction.apply();
finishTransaction.apply();
finishCallback.onTransitionFinished(null /* wct */, null /* wctCB */);

View File

@@ -513,6 +513,7 @@ public class DisplayRotation {
}
if (mDisplayContent.inTransition()
&& mDisplayContent.getDisplayPolicy().isScreenOnFully()
&& !mDisplayContent.mTransitionController.useShellTransitionsRotation()) {
// Rotation updates cannot be performed while the previous rotation change animation
// is still in progress. Skip this update. We will try updating again after the

View File

@@ -680,7 +680,11 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
// All windows are synced already.
return;
}
if (!isInTransition(wc)) return;
if (wc.mDisplayContent == null || !isInTransition(wc)) return;
if (!wc.mDisplayContent.getDisplayPolicy().isScreenOnFully()
|| wc.mDisplayContent.getDisplayInfo().state == Display.STATE_OFF) {
mFlags |= WindowManager.TRANSIT_FLAG_INVISIBLE;
}
if (mContainerFreezer == null) {
mContainerFreezer = new ScreenshotFreezer();