From 196054ac4c1d16970d35470fca15f2ba2f67f060 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Mon, 24 Apr 2023 17:07:48 +0200 Subject: [PATCH] Report keyguard changes even with display changes Display changes shouldn't be played by remote animations unless shell is allowed to play rotation animations. Keyguard updates must make it to the keyguard handler so that keyguard gets the right information about lock/unlock state. If these rules conflict, the second one wins because the consequences are worse. Fix: 278069129 Test: atest WMShellUnitTests Change-Id: Iaf8468168e1bc8db423f3d6910ef46c0531d4aab --- .../transition/RemoteTransitionHandler.java | 4 +++- .../wm/shell/transition/Transitions.java | 19 +------------------ .../android/wm/shell/util/TransitionUtil.java | 19 +++++++++++++++++++ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java index 5b7231c5a5fb5..ef2a511177b24 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/RemoteTransitionHandler.java @@ -94,9 +94,11 @@ public class RemoteTransitionHandler implements Transitions.TransitionHandler { @NonNull SurfaceControl.Transaction startTransaction, @NonNull SurfaceControl.Transaction finishTransaction, @NonNull Transitions.TransitionFinishCallback finishCallback) { - if (!Transitions.SHELL_TRANSITIONS_ROTATION && TransitionUtil.hasDisplayChange(info)) { + if (!Transitions.SHELL_TRANSITIONS_ROTATION && TransitionUtil.hasDisplayChange(info) + && !TransitionUtil.alwaysReportToKeyguard(info)) { // Note that if the remote doesn't have permission ACCESS_SURFACE_FLINGER, some // operations of the start transaction may be ignored. + mRequestedRemotes.remove(transition); return false; } RemoteTransition pendingRemote = mRequestedRemotes.get(transition); 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 5c8791effe18e..a4057b1328f41 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 @@ -650,7 +650,7 @@ public class Transitions implements RemoteCallable { active.mToken, info, active.mStartT, active.mFinishT); } - if (info.getRootCount() == 0 && !alwaysReportToKeyguard(info)) { + if (info.getRootCount() == 0 && !TransitionUtil.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 in %s so" @@ -699,23 +699,6 @@ public class Transitions implements RemoteCallable { return true; } - /** - * 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; - } - private boolean areTracksIdle() { for (int i = 0; i < mTracks.size(); ++i) { if (!mTracks.get(i).isIdle()) return false; diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java b/libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java index ce102917352d9..c5cd2d91eb390 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/util/TransitionUtil.java @@ -24,7 +24,9 @@ import static android.view.WindowManager.LayoutParams.INVALID_WINDOW_TYPE; import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; 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_KEYGUARD_GOING_AWAY; +import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE; import static android.view.WindowManager.TRANSIT_OPEN; import static android.view.WindowManager.TRANSIT_TO_BACK; import static android.view.WindowManager.TRANSIT_TO_FRONT; @@ -77,6 +79,23 @@ public class TransitionUtil { return false; } + /** + * 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. + */ + public 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; + } + /** Returns `true` if `change` is a wallpaper. */ public static boolean isWallpaper(TransitionInfo.Change change) { return (change.getTaskInfo() == null)