summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author wilsonshih <wilsonshih@google.com> 2022-08-17 16:49:39 +0800
committer wilsonshih <wilsonshih@google.com> 2022-08-17 16:49:39 +0800
commit6e497e2564125f9dc14cc9d212a2f892bb7ebf4d (patch)
tree201cf79f27c64a4a50fbfcb4477a34d3bf1aaffc
parentf568c59b8825af5464e122bfc252a81b19a003a6 (diff)
[Shell Transition]Fix occluded activity could show behind keyguard.
Register for specific un/occluded transition filter type in keyguard service. The current condition cannot fulfill every situation. E.g. when close top activity while screen off but next activity is occluded, this should an occluded transition, but since the activity is invisible, the condition would match unoccluded transition. The unoccluded status could accidentally trigger keyguardGoingAway and ask core to resume top activity. But on the contrary, if we add above condition in occluded transition, then when user trying to dismiss occluded activity when unlock keyguard, the condition would match occluded transition. To simplify the filter conditions, additional register the filter for those transition type. Also fix DisplayPolicy#mAwake wasn't synchronized by wm lock. Bug: 241745428 Test: Enable shell transition. 1. Start Activity A with showWhenLocked + turnScreenOn while keyguard locked and screen off. 2. Start Activity B in the same task without showWhenLocked. 3. Turn screen off, activity B finish itself. Monitor the occluded status in SystemUI should be true. No keyguard going away triggerred. 4. Turn screen on. Monitor Activity A resumed and occluded keyguard. 5. Swipe up/press back to dismiss Activity A. Verify device can show keyguard. Test: run atest ActivityVisibilityTests#testTurnScreenOnActivity, monitor test activity won't remain behind keyguard while test finish. Change-Id: Ide14913f2b2d25af2c518866b4df8d1a3ff4b18d
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java26
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java10
2 files changed, 27 insertions, 9 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
index 3eb3c80f4081..6dfbd426ef30 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardService.java
@@ -323,6 +323,8 @@ public class KeyguardService extends Service {
if (sEnableRemoteKeyguardOccludeAnimation) {
Slog.d(TAG, "KeyguardService registerRemote: TRANSIT_KEYGUARD_(UN)OCCLUDE");
// Register for occluding
+ final RemoteTransition occludeTransition = new RemoteTransition(
+ mOccludeAnimation, getIApplicationThread());
TransitionFilter f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED;
f.mRequirements = new TransitionFilter.Requirement[]{
@@ -337,10 +339,11 @@ public class KeyguardService extends Service {
f.mRequirements[1].mMustBeIndependent = false;
f.mRequirements[1].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[1].mModes = new int[]{TRANSIT_CLOSE, TRANSIT_TO_BACK};
- mShellTransitions.registerRemote(f,
- new RemoteTransition(mOccludeAnimation, getIApplicationThread()));
+ mShellTransitions.registerRemote(f, occludeTransition);
// Now register for un-occlude.
+ final RemoteTransition unoccludeTransition = new RemoteTransition(
+ mUnoccludeAnimation, getIApplicationThread());
f = new TransitionFilter();
f.mFlags = TRANSIT_FLAG_KEYGUARD_LOCKED;
f.mRequirements = new TransitionFilter.Requirement[]{
@@ -358,8 +361,23 @@ public class KeyguardService extends Service {
f.mRequirements[0].mMustBeIndependent = false;
f.mRequirements[0].mFlags = FLAG_OCCLUDES_KEYGUARD;
f.mRequirements[0].mModes = new int[]{TRANSIT_OPEN, TRANSIT_TO_FRONT};
- mShellTransitions.registerRemote(f,
- new RemoteTransition(mUnoccludeAnimation, getIApplicationThread()));
+ mShellTransitions.registerRemote(f, unoccludeTransition);
+
+ // Register for specific transition type.
+ // Above filter cannot fulfill all conditions.
+ // E.g. close top activity while screen off but next activity is occluded, this should
+ // an occluded transition, but since the activity is invisible, the condition would
+ // match unoccluded transition.
+ // But on the contrary, if we add above condition in occluded transition, then when user
+ // trying to dismiss occluded activity when unlock keyguard, the condition would match
+ // occluded transition.
+ f = new TransitionFilter();
+ f.mTypeSet = new int[]{TRANSIT_KEYGUARD_OCCLUDE};
+ mShellTransitions.registerRemote(f, occludeTransition);
+
+ f = new TransitionFilter();
+ f.mTypeSet = new int[]{TRANSIT_KEYGUARD_UNOCCLUDE};
+ mShellTransitions.registerRemote(f, unoccludeTransition);
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 5221072f696d..7f79dff2f837 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -794,11 +794,11 @@ public class DisplayPolicy {
}
public void setAwake(boolean awake) {
- if (awake == mAwake) {
- return;
- }
- mAwake = awake;
- synchronized (mService.mGlobalLock) {
+ synchronized (mLock) {
+ if (awake == mAwake) {
+ return;
+ }
+ mAwake = awake;
if (!mDisplayContent.isDefaultDisplay) {
return;
}