Merge "Wait OCCLUDE transition until screen turning on activity becomes ready." into sc-dev

This commit is contained in:
Issei Suzuki
2021-04-14 10:00:02 +00:00
committed by Android (Google) Code Review
8 changed files with 37 additions and 14 deletions

View File

@@ -4492,8 +4492,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
@Override
public boolean okToAnimate() {
return mDefaultDisplayPolicy.isAwake() && !mDeviceGoingToSleep;
public boolean okToAnimate(boolean ignoreScreenOn) {
return (ignoreScreenOn || mDefaultDisplayPolicy.isAwake()) && !mDeviceGoingToSleep;
}
/** {@inheritDoc} */

View File

@@ -897,12 +897,13 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
public boolean isScreenOn();
/**
* @param ignoreScreenOn {@code true} if screen state should be ignored.
* @return whether the device is currently allowed to animate.
*
* Note: this can be true even if it is not appropriate to animate for reasons that are outside
* of the policy's authority.
*/
boolean okToAnimate();
boolean okToAnimate(boolean ignoreScreenOn);
/**
* Tell the policy that the lid switch has changed state.

View File

@@ -4655,7 +4655,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
// still check DC#okToAnimate again if the transition animation is fine to apply.
// TODO(new-app-transition): Rewrite this logic using WM Shell.
final boolean recentsAnimating = isAnimating(PARENTS, ANIMATION_TYPE_RECENTS);
if (okToAnimate(true /* ignoreFrozen */) && (appTransition.isTransitionSet()
if (okToAnimate(true /* ignoreFrozen */, canTurnScreenOn())
&& (appTransition.isTransitionSet()
|| (recentsAnimating && !isActivityTypeHome()))) {
if (visible) {
displayContent.mOpeningApps.add(this);

View File

@@ -4436,9 +4436,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
}
boolean okToDisplay(boolean ignoreFrozen) {
return okToDisplay(ignoreFrozen, false /* ignoreScreenOn */);
}
boolean okToDisplay(boolean ignoreFrozen, boolean ignoreScreenOn) {
if (mDisplayId == DEFAULT_DISPLAY) {
return (!mWmService.mDisplayFrozen || ignoreFrozen)
&& mWmService.mDisplayEnabled && mWmService.mPolicy.isScreenOn();
&& mWmService.mDisplayEnabled
&& (ignoreScreenOn || mWmService.mPolicy.isScreenOn());
}
return mDisplayInfo.state == Display.STATE_ON;
}
@@ -4448,8 +4453,13 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
}
boolean okToAnimate(boolean ignoreFrozen) {
return okToDisplay(ignoreFrozen) &&
(mDisplayId != DEFAULT_DISPLAY || mWmService.mPolicy.okToAnimate());
return okToAnimate(ignoreFrozen, false /* ignoreScreenOn */);
}
boolean okToAnimate(boolean ignoreFrozen, boolean ignoreScreenOn) {
return okToDisplay(ignoreFrozen, ignoreScreenOn)
&& (mDisplayId != DEFAULT_DISPLAY
|| mWmService.mPolicy.okToAnimate(ignoreScreenOn));
}
static final class TaskForResizePointSearchResult {

View File

@@ -731,7 +731,7 @@ public class DisplayRotation {
private RotationAnimationPair selectRotationAnimation() {
// If the screen is off or non-interactive, force a jumpcut.
final boolean forceJumpcut = !mDisplayPolicy.isScreenOnFully()
|| !mService.mPolicy.okToAnimate();
|| !mService.mPolicy.okToAnimate(false /* ignoreScreenOn */);
final WindowState topFullscreen = mDisplayPolicy.getTopFullscreenOpaqueWindow();
if (DEBUG_ANIM) Slog.i(TAG, "selectRotationAnimation topFullscreen="
+ topFullscreen + " rotationAnimation="

View File

@@ -341,11 +341,10 @@ class KeyguardController {
/**
* Called when occluded state changed.
*
* @param currentTaskControllingOcclusion the task that controls the state whether keyguard
* should be occluded. That is the task to be shown on top of keyguard if it requests so.
* @param topActivity the activity that controls the state whether keyguard should
* be occluded. That is the activity to be shown on top of keyguard if it requests so.
*/
private void handleOccludedChanged(
int displayId, @Nullable Task currentTaskControllingOcclusion) {
private void handleOccludedChanged(int displayId, @Nullable ActivityRecord topActivity) {
// TODO(b/113840485): Handle app transition for individual display, and apply occluded
// state change to secondary displays.
// For now, only default display fully supports occluded change. Other displays only
@@ -364,6 +363,13 @@ class KeyguardController {
isDisplayOccluded(DEFAULT_DISPLAY)
? TRANSIT_KEYGUARD_OCCLUDE
: TRANSIT_KEYGUARD_UNOCCLUDE);
// When the occluding activity also turns on the display, visibility of the activity
// can be committed before KEYGUARD_OCCLUDE transition is handled.
// Set mRequestForceTransition flag to make sure that the app transition animation
// is applied for such case.
if (topActivity != null) {
topActivity.mRequestForceTransition = true;
}
updateKeyguardSleepToken(DEFAULT_DISPLAY);
mWindowManager.executeAppTransition();
} finally {
@@ -580,7 +586,7 @@ class KeyguardController {
if (lastOccluded != mOccluded) {
occludingChange = true;
controller.handleOccludedChanged(mDisplayId, task);
controller.handleOccludedChanged(mDisplayId, mTopOccludesActivity);
}
if (occludingChange || turningScreenOn) {

View File

@@ -2796,6 +2796,11 @@ class WindowContainer<E extends WindowContainer> extends ConfigurationContainer<
return dc != null && dc.okToAnimate(ignoreFrozen);
}
boolean okToAnimate(boolean ignoreFrozen, boolean ignoreScreenOn) {
final DisplayContent dc = getDisplayContent();
return dc != null && dc.okToAnimate(ignoreFrozen, ignoreScreenOn);
}
@Override
public void commitPendingTransaction() {
scheduleAnimation();

View File

@@ -210,7 +210,7 @@ class TestWindowManagerPolicy implements WindowManagerPolicy {
}
@Override
public boolean okToAnimate() {
public boolean okToAnimate(boolean ignoreScreenOn) {
return mOkToAnimate;
}