Merge "Invoke keyguard going away when it is collecting for wake" into sc-v2-dev

This commit is contained in:
Chris Li
2021-08-12 18:32:53 +00:00
committed by Android (Google) Code Review
11 changed files with 123 additions and 28 deletions

View File

@@ -381,8 +381,11 @@ public interface WindowManager extends ViewManager {
int TRANSIT_CHANGE = 6;
/**
* The keyguard was visible and has been dismissed.
* @deprecated use {@link #TRANSIT_TO_BACK} + {@link #TRANSIT_FLAG_KEYGUARD_GOING_AWAY} for
* keyguard going away with Shell transition.
* @hide
*/
@Deprecated
int TRANSIT_KEYGUARD_GOING_AWAY = 7;
/**
* A window is appearing above a locked keyguard.
@@ -486,6 +489,12 @@ public interface WindowManager extends ViewManager {
*/
int TRANSIT_FLAG_IS_RECENTS = 0x80;
/**
* Transition flag: Indicates that keyguard should go away with this transition.
* @hide
*/
int TRANSIT_FLAG_KEYGUARD_GOING_AWAY = 0x100;
/**
* @hide
*/
@@ -497,7 +506,8 @@ public interface WindowManager extends ViewManager {
TRANSIT_FLAG_APP_CRASHED,
TRANSIT_FLAG_OPEN_BEHIND,
TRANSIT_FLAG_KEYGUARD_LOCKED,
TRANSIT_FLAG_IS_RECENTS
TRANSIT_FLAG_IS_RECENTS,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY
})
@Retention(RetentionPolicy.SOURCE)
@interface TransitionFlags {}

View File

@@ -59,6 +59,9 @@ public final class TransitionFilter implements Parcelable {
/** All flags must be set on a transition. */
public @WindowManager.TransitionFlags int mFlags = 0;
/** All flags must NOT be set on a transition. */
public @WindowManager.TransitionFlags int mNotFlags = 0;
/**
* A list of required changes. To pass, a transition must meet all requirements.
*/
@@ -70,6 +73,7 @@ public final class TransitionFilter implements Parcelable {
private TransitionFilter(Parcel in) {
mTypeSet = in.createIntArray();
mFlags = in.readInt();
mNotFlags = in.readInt();
mRequirements = in.createTypedArray(Requirement.CREATOR);
}
@@ -89,6 +93,9 @@ public final class TransitionFilter implements Parcelable {
if ((info.getFlags() & mFlags) != mFlags) {
return false;
}
if ((info.getFlags() & mNotFlags) != 0) {
return false;
}
// Make sure info meets all of the requirements.
if (mRequirements != null) {
for (int i = 0; i < mRequirements.length; ++i) {
@@ -106,6 +113,7 @@ public final class TransitionFilter implements Parcelable {
public void writeToParcel(@NonNull Parcel dest, int flags) {
dest.writeIntArray(mTypeSet);
dest.writeInt(mFlags);
dest.writeInt(mNotFlags);
dest.writeTypedArray(mRequirements, flags);
}
@@ -139,6 +147,7 @@ public final class TransitionFilter implements Parcelable {
}
}
sb.append("] flags=0x" + Integer.toHexString(mFlags));
sb.append("] notFlags=0x" + Integer.toHexString(mNotFlags));
sb.append(" checks=[");
if (mRequirements != null) {
for (int i = 0; i < mRequirements.length; ++i) {

View File

@@ -26,6 +26,7 @@ import static android.app.WindowConfiguration.ROTATION_UNDEFINED;
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
@@ -249,6 +250,13 @@ public final class TransitionInfo implements Parcelable {
mChanges.add(change);
}
/**
* Whether this transition includes keyguard going away.
*/
public boolean isKeyguardGoingAway() {
return (mFlags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

View File

@@ -29,7 +29,6 @@ import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLES
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_RELAUNCH;
@@ -249,10 +248,9 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
@NonNull Transitions.TransitionFinishCallback finishCallback) {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
"start default transition animation, info = %s", info);
// Fallback for screen wake. This just immediately finishes since there is no
// animation for screen-wake.
if (info.getType() == WindowManager.TRANSIT_WAKE) {
// If keyguard goes away, we should loadKeyguardExitAnimation. Otherwise this just
// immediately finishes since there is no animation for screen-wake.
if (info.getType() == WindowManager.TRANSIT_WAKE && !info.isKeyguardGoingAway()) {
startTransaction.apply();
finishCallback.onTransitionFinished(null /* wct */, null /* wctCB */);
return true;
@@ -354,7 +352,7 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
final int overrideType = options != null ? options.getType() : ANIM_NONE;
final boolean canCustomContainer = isTask ? !sDisableCustomTaskAnimationProperty : true;
if (type == TRANSIT_KEYGUARD_GOING_AWAY) {
if (info.isKeyguardGoingAway()) {
a = mTransitionAnimation.loadKeyguardExitAnimation(flags,
(changeFlags & FLAG_SHOW_WALLPAPER) != 0);
} else if (type == TRANSIT_KEYGUARD_UNOCCLUDE) {

View File

@@ -19,6 +19,7 @@ package com.android.wm.shell.transition;
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM;
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
@@ -230,7 +231,7 @@ public class Transitions implements RemoteCallable<Transitions> {
public static boolean isOpeningType(@WindowManager.TransitionType int type) {
return type == TRANSIT_OPEN
|| type == TRANSIT_TO_FRONT
|| type == WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
|| type == TRANSIT_KEYGUARD_GOING_AWAY;
}
/** @return true if the transition was triggered by closing something vs opening something */

View File

@@ -27,6 +27,7 @@ import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECI
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
@@ -89,6 +90,9 @@ import java.util.ArrayList;
/**
* Tests for the shell transitions.
*
* Build/Install/Run:
* atest WMShellUnitTests:ShellTransitionTests
*/
@SmallTest
@RunWith(AndroidJUnit4.class)
@@ -304,6 +308,54 @@ public class ShellTransitionTests {
assertFalse(filter.matches(openAndTranslucent));
}
@Test
public void testTransitionFilterChecksTypeSet() {
TransitionFilter filter = new TransitionFilter();
filter.mTypeSet = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT};
final TransitionInfo openOnly = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).build();
assertTrue(filter.matches(openOnly));
final TransitionInfo toFrontOnly = new TransitionInfoBuilder(TRANSIT_TO_FRONT)
.addChange(TRANSIT_TO_FRONT).build();
assertTrue(filter.matches(toFrontOnly));
final TransitionInfo closeOnly = new TransitionInfoBuilder(TRANSIT_CLOSE)
.addChange(TRANSIT_CLOSE).build();
assertFalse(filter.matches(closeOnly));
}
@Test
public void testTransitionFilterChecksFlags() {
TransitionFilter filter = new TransitionFilter();
filter.mFlags = TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
final TransitionInfo withFlag = new TransitionInfoBuilder(TRANSIT_TO_BACK,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY)
.addChange(TRANSIT_TO_BACK).build();
assertTrue(filter.matches(withFlag));
final TransitionInfo withoutFlag = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).build();
assertFalse(filter.matches(withoutFlag));
}
@Test
public void testTransitionFilterChecksNotFlags() {
TransitionFilter filter = new TransitionFilter();
filter.mNotFlags = TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
final TransitionInfo withFlag = new TransitionInfoBuilder(TRANSIT_TO_BACK,
TRANSIT_FLAG_KEYGUARD_GOING_AWAY)
.addChange(TRANSIT_TO_BACK).build();
assertFalse(filter.matches(withFlag));
final TransitionInfo withoutFlag = new TransitionInfoBuilder(TRANSIT_OPEN)
.addChange(TRANSIT_OPEN).build();
assertTrue(filter.matches(withoutFlag));
}
@Test
public void testRegisteredRemoteTransition() {
Transitions transitions = createTestTransitions();
@@ -534,7 +586,12 @@ public class ShellTransitionTests {
final TransitionInfo mInfo;
TransitionInfoBuilder(@WindowManager.TransitionType int type) {
mInfo = new TransitionInfo(type, 0 /* flags */);
this(type, 0 /* flags */);
}
TransitionInfoBuilder(@WindowManager.TransitionType int type,
@WindowManager.TransitionFlags int flags) {
mInfo = new TransitionInfo(type, flags);
mInfo.setRootLeash(createMockSurface(true /* valid */), 0, 0);
}

View File

@@ -19,6 +19,7 @@ package com.android.systemui.shared.system;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
@@ -172,6 +173,8 @@ public class RemoteTransitionCompat implements Parcelable {
if (mFilter == null) {
mFilter = new TransitionFilter();
}
// No need to handle the transition that also dismisses keyguard.
mFilter.mNotFlags = TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
mFilter.mRequirements =
new TransitionFilter.Requirement[]{new TransitionFilter.Requirement(),
new TransitionFilter.Requirement()};

View File

@@ -21,6 +21,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.RemoteAnimationTarget.MODE_CLOSING;
import static android.view.RemoteAnimationTarget.MODE_OPENING;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_LOCKED;
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE;
@@ -33,6 +34,7 @@ import static android.view.WindowManager.TRANSIT_OLD_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.view.WindowManager.TransitionFlags;
import static android.view.WindowManager.TransitionOldType;
import static android.view.WindowManager.TransitionType;
import static android.window.TransitionInfo.FLAG_OCCLUDES_KEYGUARD;
@@ -170,8 +172,9 @@ public class KeyguardService extends Service {
}
private static @TransitionOldType int getTransitionOldType(@TransitionType int type,
RemoteAnimationTarget[] apps) {
if (type == TRANSIT_KEYGUARD_GOING_AWAY) {
@TransitionFlags int flags, RemoteAnimationTarget[] apps) {
if (type == TRANSIT_KEYGUARD_GOING_AWAY
|| (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0) {
return apps.length == 0 ? TRANSIT_OLD_KEYGUARD_GOING_AWAY_ON_WALLPAPER
: TRANSIT_OLD_KEYGUARD_GOING_AWAY;
} else if (type == TRANSIT_KEYGUARD_OCCLUDE) {
@@ -200,7 +203,7 @@ public class KeyguardService extends Service {
t.setAlpha(change.getLeash(), 1.0f);
}
t.apply();
runner.onAnimationStart(getTransitionOldType(info.getType(), apps),
runner.onAnimationStart(getTransitionOldType(info.getType(), info.getFlags(), apps),
apps, wallpapers, nonApps,
new IRemoteAnimationFinishedCallback.Stub() {
@Override
@@ -232,7 +235,7 @@ public class KeyguardService extends Service {
if (sEnableRemoteKeyguardGoingAwayAnimation) {
Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_GOING_AWAY");
TransitionFilter f = new TransitionFilter();
f.mTypeSet = new int[]{TRANSIT_KEYGUARD_GOING_AWAY};
f.mFlags = TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
shellTransitions.registerRemote(f, wrap(mExitAnimationRunner));
}
if (sEnableRemoteKeyguardOccludeAnimation) {

View File

@@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE;
@@ -27,6 +28,7 @@ import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_W
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_KEYGUARD_OCCLUDE;
import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE;
import static android.view.WindowManager.TRANSIT_TO_BACK;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_NO_WINDOW_ANIMATIONS;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_SUBTLE_WINDOW_ANIMATIONS;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_SHADE;
@@ -235,8 +237,14 @@ class KeyguardController {
mAodShowing ? 1 : 0,
1 /* keyguardGoingAway */,
"keyguardGoingAway");
mRootWindowContainer.getDefaultDisplay().requestTransitionAndLegacyPrepare(
TRANSIT_KEYGUARD_GOING_AWAY, convertTransitFlags(flags));
final int transitFlags = convertTransitFlags(flags);
final DisplayContent dc = mRootWindowContainer.getDefaultDisplay();
dc.prepareAppTransition(TRANSIT_KEYGUARD_GOING_AWAY, transitFlags);
// We are deprecating TRANSIT_KEYGUARD_GOING_AWAY for Shell transition and use
// TRANSIT_FLAG_KEYGUARD_GOING_AWAY to indicate that it should animate keyguard going
// away.
dc.mAtmService.getTransitionController().requestTransitionIfNeeded(
TRANSIT_TO_BACK, transitFlags, null /* trigger */, dc);
updateKeyguardSleepToken();
// Some stack visibility might change (e.g. docked stack)
@@ -276,7 +284,7 @@ class KeyguardController {
}
private int convertTransitFlags(int keyguardGoingAwayFlags) {
int result = 0;
int result = TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
if ((keyguardGoingAwayFlags & KEYGUARD_GOING_AWAY_FLAG_TO_SHADE) != 0) {
result |= TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE;
}

View File

@@ -25,6 +25,7 @@ import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECI
import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE;
@@ -622,13 +623,14 @@ class Transition extends Binder implements BLASTSyncEngine.TransactionReadyListe
}
private void handleNonAppWindowsInTransition(int displayId,
@TransitionType int transit, int flags) {
@TransitionType int transit, @TransitionFlags int flags) {
final DisplayContent dc =
mController.mAtm.mRootWindowContainer.getDisplayContent(displayId);
if (dc == null) {
return;
}
if (transit == TRANSIT_KEYGUARD_GOING_AWAY
if ((transit == TRANSIT_KEYGUARD_GOING_AWAY
|| (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0)
&& !WindowManagerService.sEnableRemoteKeyguardGoingAwayAnimation) {
if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER) != 0
&& (flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION) == 0

View File

@@ -18,11 +18,7 @@ package com.android.server.wm;
import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FLAG_IS_RECENTS;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER;
import static android.view.WindowManager.TRANSIT_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
@@ -230,6 +226,10 @@ class TransitionController {
if (isCollecting()) {
// Make the collecting transition wait until this request is ready.
mCollectingTransition.setReady(readyGroupRef, false);
if ((flags & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0) {
// Add keyguard flag to dismiss keyguard
mCollectingTransition.addFlag(flags);
}
} else {
newTransition = requestStartTransition(createTransition(type, flags),
trigger != null ? trigger.asTask() : null, remoteTransition);
@@ -354,11 +354,7 @@ class TransitionController {
}
void dispatchLegacyAppTransitionStarting(TransitionInfo info) {
final boolean keyguardGoingAway = info.getType() == TRANSIT_KEYGUARD_GOING_AWAY
|| (info.getFlags() & (TRANSIT_FLAG_KEYGUARD_GOING_AWAY_TO_SHADE
| TRANSIT_FLAG_KEYGUARD_GOING_AWAY_NO_ANIMATION
| TRANSIT_FLAG_KEYGUARD_GOING_AWAY_WITH_WALLPAPER
| TRANSIT_FLAG_KEYGUARD_GOING_AWAY_SUBTLE_ANIMATION)) != 0;
final boolean keyguardGoingAway = info.isKeyguardGoingAway();
for (int i = 0; i < mLegacyListeners.size(); ++i) {
mLegacyListeners.get(i).onAppTransitionStartingLocked(keyguardGoingAway,
0 /* durationHint */, SystemClock.uptimeMillis(),