diff options
| author | 2023-03-24 03:05:30 +0000 | |
|---|---|---|
| committer | 2023-03-24 03:05:30 +0000 | |
| commit | 26994f4d2e7332fa49c3aa6b7e72bcaa582e56e4 (patch) | |
| tree | 0f940fbc1de63fb7771cb6482043fe193a5e3175 | |
| parent | f5a5d2486fa9dd707364c393e2a1cb5821a392de (diff) | |
| parent | e6b3aa3dbf1027e8e8c821b9caa5a21004924977 (diff) | |
Merge "Always report keyguard-going-away even if empty" into udc-dev
4 files changed, 57 insertions, 4 deletions
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java index b8b6d5b96a93..b15802a0f5d4 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java @@ -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_FLAG_KEYGUARD_GOING_AWAY; import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; import static android.view.WindowManager.TRANSIT_OPEN; 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 - // screen-off, so there might no visibility change involved. - if (info.getRootCount() == 0 && info.getType() != TRANSIT_KEYGUARD_UNOCCLUDE) { + if (info.getRootCount() == 0 && !alwaysReportToKeyguard(info)) { // No root-leashes implies that the transition is empty/no-op, so just do // housekeeping and return. ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS, "No transition roots (%s): %s", @@ -589,6 +588,23 @@ public class Transitions implements RemoteCallable<Transitions> { 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() { if (mReadyTransitions.isEmpty()) { // Check if idle. diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/TransitionInfoBuilder.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/TransitionInfoBuilder.java index 26b787fa836c..a658375ca38a 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/TransitionInfoBuilder.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/TransitionInfoBuilder.java @@ -38,8 +38,15 @@ public class TransitionInfoBuilder { public TransitionInfoBuilder(@WindowManager.TransitionType int type, @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.addRootLeash(DISPLAY_ID, createMockSurface(true /* valid */), 0, 0); + if (!asNoOp) { + mInfo.addRootLeash(DISPLAY_ID, createMockSurface(true /* valid */), 0, 0); + } } public TransitionInfoBuilder addChange(@WindowManager.TransitionType int mode, diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java index 44f1f0147b52..60d697823f64 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java @@ -1039,6 +1039,25 @@ public class ShellTransitionTests extends ShellTestCase { 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 { final TransitionInfo.Change mChange; diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java index 5ecc00fb66b5..0825435e9ae5 100644 --- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java +++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java @@ -2690,6 +2690,17 @@ public class KeyguardViewMediator implements CoreStartable, Dumpable, mInteractionJankMonitor.end(CUJ_LOCKSCREEN_UNLOCK_ANIMATION); 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. final SyncRtSurfaceTransactionApplier applier = |