Merge "Always report keyguard-going-away even if empty" into udc-dev

This commit is contained in:
Evan Rosky
2023-03-24 03:05:30 +00:00
committed by Android (Google) Code Review
4 changed files with 57 additions and 4 deletions

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_CHANGE;
import static android.view.WindowManager.TRANSIT_CLOSE; import static android.view.WindowManager.TRANSIT_CLOSE;
import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM; import static android.view.WindowManager.TRANSIT_FIRST_CUSTOM;
import static android.view.WindowManager.TRANSIT_FLAG_KEYGUARD_GOING_AWAY;
import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE;
import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_OPEN;
import static android.view.WindowManager.TRANSIT_SLEEP; import static android.view.WindowManager.TRANSIT_SLEEP;
@@ -541,9 +542,7 @@ public class Transitions implements RemoteCallable<Transitions> {
} }
} }
// Allow to notify keyguard un-occluding state to KeyguardService, which can happen while if (info.getRootCount() == 0 && !alwaysReportToKeyguard(info)) {
// screen-off, so there might no visibility change involved.
if (info.getRootCount() == 0 && info.getType() != TRANSIT_KEYGUARD_UNOCCLUDE) {
// No root-leashes implies that the transition is empty/no-op, so just do // No root-leashes implies that the transition is empty/no-op, so just do
// housekeeping and return. // housekeeping and return.
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "No transition roots (%s): %s", ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "No transition roots (%s): %s",
@@ -589,6 +588,23 @@ public class Transitions implements RemoteCallable<Transitions> {
processReadyQueue(); processReadyQueue();
} }
/**
* Some transitions we always need to report to keyguard even if they are empty.
* TODO (b/274954192): Remove this once keyguard dispatching moves to Shell.
*/
private static boolean alwaysReportToKeyguard(TransitionInfo info) {
// occlusion status of activities can change while screen is off so there will be no
// visibility change but we still need keyguardservice to be notified.
if (info.getType() == TRANSIT_KEYGUARD_UNOCCLUDE) return true;
// It's possible for some activities to stop with bad timing (esp. since we can't yet
// queue activity transitions initiated by apps) that results in an empty transition for
// keyguard going-away. In general, we should should always report Keyguard-going-away.
if ((info.getFlags() & TRANSIT_FLAG_KEYGUARD_GOING_AWAY) != 0) return true;
return false;
}
void processReadyQueue() { void processReadyQueue() {
if (mReadyTransitions.isEmpty()) { if (mReadyTransitions.isEmpty()) {
// Check if idle. // Check if idle.

View File

@@ -38,9 +38,16 @@ public class TransitionInfoBuilder {
public TransitionInfoBuilder(@WindowManager.TransitionType int type, public TransitionInfoBuilder(@WindowManager.TransitionType int type,
@WindowManager.TransitionFlags int flags) { @WindowManager.TransitionFlags int flags) {
this(type, flags, false /* asNoOp */);
}
public TransitionInfoBuilder(@WindowManager.TransitionType int type,
@WindowManager.TransitionFlags int flags, boolean asNoOp) {
mInfo = new TransitionInfo(type, flags); mInfo = new TransitionInfo(type, flags);
if (!asNoOp) {
mInfo.addRootLeash(DISPLAY_ID, createMockSurface(true /* valid */), 0, 0); mInfo.addRootLeash(DISPLAY_ID, createMockSurface(true /* valid */), 0, 0);
} }
}
public TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode, public TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode,
@TransitionInfo.ChangeFlags int flags, ActivityManager.RunningTaskInfo taskInfo) { @TransitionInfo.ChangeFlags int flags, ActivityManager.RunningTaskInfo taskInfo) {

View File

@@ -1039,6 +1039,25 @@ public class ShellTransitionTests extends ShellTestCase {
verify(observer, times(0)).onTransitionFinished(eq(transitToken3), anyBoolean()); verify(observer, times(0)).onTransitionFinished(eq(transitToken3), anyBoolean());
} }
@Test
public void testEmptyTransitionStillReportsKeyguardGoingAway() {
Transitions transitions = createTestTransitions();
transitions.replaceDefaultHandlerForTest(mDefaultHandler);
IBinder transitToken = new Binder();
transitions.requestStartTransition(transitToken,
new TransitionRequestInfo(TRANSIT_OPEN, null /* trigger */, null /* remote */));
// Make a no-op transition
TransitionInfo info = new TransitionInfoBuilder(
TRANSIT_OPEN, TRANSIT_FLAG_KEYGUARD_GOING_AWAY, true /* noOp */).build();
transitions.onTransitionReady(transitToken, info, mock(SurfaceControl.Transaction.class),
mock(SurfaceControl.Transaction.class));
// If keyguard-going-away flag set, then it shouldn't be aborted.
assertEquals(1, mDefaultHandler.activeCount());
}
class ChangeBuilder { class ChangeBuilder {
final TransitionInfo.Change mChange; final TransitionInfo.Change mChange;

View File

@@ -2690,6 +2690,17 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable,
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION); mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
return; return;
} }
if (apps == null || apps.length == 0) {
Slog.e(TAG, "Keyguard exit without a corresponding app to show.");
try {
finishedCallback.onAnimationFinished();
} catch (RemoteException e) {
Slog.e(TAG, "RemoteException");
} finally {
mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION);
}
return;
}
// TODO(bc-unlock): Sample animation, just to apply alpha animation on the app. // TODO(bc-unlock): Sample animation, just to apply alpha animation on the app.
final SyncRtSurfaceTransactionApplier applier = final SyncRtSurfaceTransactionApplier applier =