Merge "Include the wallpaper visibility change in the existing keyguard unlocking transition" into udc-dev

This commit is contained in:
Marzia Favaro
2023-05-02 14:48:11 +00:00
committed by Android (Google) Code Review
5 changed files with 76 additions and 6 deletions

View File

@@ -533,8 +533,12 @@ public class Transitions implements RemoteCallable<Transitions>,
final int layer;
// Put all the OPEN/SHOW on top
if ((change.getFlags() & FLAG_IS_WALLPAPER) != 0) {
// Wallpaper is always at the bottom.
layer = -zSplitLine;
// Wallpaper is always at the bottom, opening wallpaper on top of closing one.
if (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT) {
layer = -zSplitLine + numChanges - i;
} else {
layer = -zSplitLine - i;
}
} else if (mode == TRANSIT_OPEN || mode == TRANSIT_TO_FRONT) {
if (isOpening) {
// put on top

View File

@@ -269,6 +269,8 @@ class KeyguardController {
TRANSIT_TO_BACK, transitFlags, null /* trigger */, dc);
updateKeyguardSleepToken();
// Make the home wallpaper visible
dc.mWallpaperController.showHomeWallpaperInTransition();
// Some stack visibility might change (e.g. docked stack)
mRootWindowContainer.resumeFocusedTasksTopActivities();
mRootWindowContainer.ensureActivitiesVisible(null, 0, !PRESERVE_WINDOWS);

View File

@@ -1325,6 +1325,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
// ActivityRecord#canShowWindows() may reject to show its window. The visibility also
// needs to be updated for STATE_ABORT.
commitVisibleActivities(transaction);
commitVisibleWallpapers();
// Fall-back to the default display if there isn't one participating.
final DisplayContent primaryDisplay = !mTargetDisplays.isEmpty() ? mTargetDisplays.get(0)
@@ -1357,6 +1358,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
}
// Resolve the animating targets from the participants.
mTargets = calculateTargets(mParticipants, mChanges);
// Check whether the participants were animated from back navigation.
mController.mAtm.mBackNavigationController.onTransactionReady(this, mTargets);
final TransitionInfo info = calculateTransitionInfo(mType, mFlags, mTargets, transaction);
@@ -1633,6 +1635,30 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
}
}
/**
* Reset waitingToshow for all wallpapers, and commit the visibility of the visible ones
*/
private void commitVisibleWallpapers() {
boolean showWallpaper = shouldWallpaperBeVisible();
for (int i = mParticipants.size() - 1; i >= 0; --i) {
final WallpaperWindowToken wallpaper = mParticipants.valueAt(i).asWallpaperToken();
if (wallpaper != null) {
wallpaper.waitingToShow = false;
if (!wallpaper.isVisible() && wallpaper.isVisibleRequested()) {
wallpaper.commitVisibility(showWallpaper);
}
}
}
}
private boolean shouldWallpaperBeVisible() {
for (int i = mParticipants.size() - 1; i >= 0; --i) {
WindowContainer participant = mParticipants.valueAt(i);
if (participant.showWallpaper()) return true;
}
return false;
}
// TODO(b/188595497): Remove after migrating to shell.
/** @see RecentsAnimationController#attachNavigationBarToApp */
private void handleLegacyRecentsStartBehavior(DisplayContent dc, TransitionInfo info) {

View File

@@ -339,6 +339,31 @@ class WallpaperController {
}
}
/**
* Change the visibility if wallpaper is home screen only.
* This is called during the keyguard unlocking transition
* (see {@link KeyguardController#keyguardGoingAway(int, int)}) and thus assumes that if the
* system wallpaper is shared with lock, then it needs no animation.
*/
public void showHomeWallpaperInTransition() {
updateWallpaperWindowsTarget(mFindResults);
if (!mFindResults.hasTopShowWhenLockedWallpaper()) {
Slog.w(TAG, "There is no wallpaper for the lock screen");
return;
}
WindowState hideWhenLocked = mFindResults.mTopWallpaper.mTopHideWhenLockedWallpaper;
WindowState showWhenLocked = mFindResults.mTopWallpaper.mTopShowWhenLockedWallpaper;
if (!mFindResults.hasTopHideWhenLockedWallpaper()) {
// Shared wallpaper, ensure its visibility
showWhenLocked.mToken.asWallpaperToken().updateWallpaperWindows(true);
} else {
// Separate lock and home wallpapers: show home wallpaper and hide lock
hideWhenLocked.mToken.asWallpaperToken().updateWallpaperWindowsInTransition(true);
showWhenLocked.mToken.asWallpaperToken().updateWallpaperWindowsInTransition(false);
}
}
void hideDeferredWallpapersIfNeededLegacy() {
for (int i = mWallpaperTokens.size() - 1; i >= 0; i--) {
final WallpaperWindowToken token = mWallpaperTokens.get(i);
@@ -815,7 +840,6 @@ class WallpaperController {
}
}
// Keep both wallpapers visible unless the keyguard is locked (then hide private wp)
if (!mDisplayContent.isKeyguardGoingAway() || !mIsLockscreenLiveWallpaperEnabled) {
// When keyguard goes away, KeyguardController handles the visibility
updateWallpaperTokens(visible, mDisplayContent.isKeyguardLocked());

View File

@@ -128,6 +128,20 @@ class WallpaperWindowToken extends WindowToken {
}
}
/**
* Update the visibility of the token to {@param visible}. If a transition will collect the
* wallpaper, then the visibility will be committed during the execution of the transition.
*
* waitingToShow is reset at the beginning of the transition:
* {@link Transition#onTransactionReady(int, SurfaceControl.Transaction)}
*/
void updateWallpaperWindowsInTransition(boolean visible) {
if (mTransitionController.isCollecting() && mVisibleRequested != visible) {
waitingToShow = true;
}
updateWallpaperWindows(visible);
}
void updateWallpaperWindows(boolean visible) {
if (mVisibleRequested != visible) {
ProtoLog.d(WM_DEBUG_WALLPAPER, "Wallpaper token %s visible=%b",
@@ -199,11 +213,11 @@ class WallpaperWindowToken extends WindowToken {
}
/**
* Commits the visibility of this token. This will directly update the visibility without
* regard for other state (like being in a transition).
* Commits the visibility of this token. This will directly update the visibility unless the
* wallpaper is in a transition.
*/
void commitVisibility(boolean visible) {
if (visible == isVisible()) return;
if (visible == isVisible() || waitingToShow) return;
ProtoLog.v(WM_DEBUG_APP_TRANSITIONS,
"commitVisibility: %s: visible=%b mVisibleRequested=%b", this,