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
This commit is contained in:
Robin Lee
2023-04-24 17:07:48 +02:00
parent 66a64d2303
commit 196054ac4c
3 changed files with 23 additions and 19 deletions

View File

@@ -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);

View File

@@ -650,7 +650,7 @@ public class Transitions implements RemoteCallable<Transitions> {
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<Transitions> {
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;

View File

@@ -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)