summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jeff Chang <chengjeff@google.com> 2020-08-07 16:08:15 +0800
committer android-build-team Robot <android-build-team-robot@google.com> 2020-09-19 10:11:00 +0000
commitd3021c68cbbef89dfb18b1a6fa4b816a2b2ec3ee (patch)
tree6df85750e84fbd8d9e8d720b4e8ea3432fb6337e
parent9819f57770fe85daa5715f240c52806563f7267f (diff)
[RESTRICT AUTOMERGE] Update the visibility of activities on sleeping display
Activity with showWhenLocked flag is visible when screen is off and leads to activity restart called. This CL update the visibility condition for showWhenLocked and dismisskeyguard activities and refer the keyguard visibility to ensure the function works as expected. Bug: 161036653 Test: atest ActivityRecordTests atest CtsWindowManagerDeviceTestCases:KeyguardTests atest CtsWindowManagerDeviceTestCases:KeyguardLockedTests Change-Id: I9d56e40de964e9d11193fec7008f8d880028ac50 (cherry picked from commit 73d6c7926d2cdc39de617f7213fc85f303501f37) (cherry picked from commit 31fc73a70719ed9a07a9a865c71b602e2fd0c53e) (cherry picked from commit 1e8e7a94872de70aa6e661fe960854e01447b1c0)
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java15
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java28
2 files changed, 34 insertions, 9 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 3e9377ed0664..41e48b8ec9db 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -4578,15 +4578,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return false;
}
- // Check if the activity is on a sleeping display, and if it can turn it ON.
- if (getDisplay().isSleeping()) {
- final boolean canTurnScreenOn = !mSetToSleep || canTurnScreenOn()
- || canShowWhenLocked() || containsDismissKeyguardWindow();
- if (!canTurnScreenOn) {
- return false;
- }
- }
-
// Now check whether it's really visible depending on Keyguard state, and update
// {@link ActivityStack} internal states.
// Inform the method if this activity is the top activity of this stack, but exclude the
@@ -4597,6 +4588,12 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
final boolean visibleIgnoringDisplayStatus = stack.checkKeyguardVisibility(this,
visibleIgnoringKeyguard, isTop && isTopNotPinnedStack);
+ // Check if the activity is on a sleeping display, and if it can turn it ON.
+ // TODO(b/163993448): Do not make activity visible before display awake.
+ if (visibleIgnoringDisplayStatus && getDisplay().isSleeping()) {
+ return !mSetToSleep || canTurnScreenOn();
+ }
+
return visibleIgnoringDisplayStatus;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index c7b45efb2de1..6ab0697206e3 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -1100,6 +1100,34 @@ public class ActivityRecordTests extends ActivityTestsBase {
}
/**
+ * Verify the visibility of a show-when-locked and dismiss keyguard activity on sleeping
+ * display.
+ */
+ @Test
+ public void testDisplaySleeping_activityInvisible() {
+ final KeyguardController keyguardController =
+ mActivity.mStackSupervisor.getKeyguardController();
+ doReturn(true).when(keyguardController).isKeyguardLocked();
+ final ActivityRecord topActivity = new ActivityBuilder(mService).setTask(mTask).build();
+ topActivity.mVisibleRequested = true;
+ topActivity.nowVisible = true;
+ topActivity.setState(RESUMED, "test" /*reason*/);
+ doReturn(true).when(topActivity).containsDismissKeyguardWindow();
+ doCallRealMethod().when(mRootWindowContainer).ensureActivitiesVisible(
+ any() /* starting */, anyInt() /* configChanges */,
+ anyBoolean() /* preserveWindows */, anyBoolean() /* notifyClients */);
+ topActivity.setShowWhenLocked(true);
+
+ // Verify the top activity is occluded keyguard.
+ assertEquals(topActivity, mStack.topRunningActivity());
+ assertTrue(mStack.topActivityOccludesKeyguard());
+
+ final DisplayContent display = mActivity.mDisplayContent;
+ doReturn(true).when(display).isSleeping();
+ assertFalse(topActivity.shouldBeVisible());
+ }
+
+ /**
* Verify that complete finish request for a show-when-locked activity must ensure the
* keyguard occluded state being updated.
*/