Loading services/core/java/com/android/server/wm/ActivityRecord.java +6 −9 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; } Loading services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +28 −0 Original line number Diff line number Diff line Loading @@ -1099,6 +1099,34 @@ public class ActivityRecordTests extends ActivityTestsBase { verify(topActivity).destroyIfPossible(anyString()); } /** * 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. Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +6 −9 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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; } Loading
services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +28 −0 Original line number Diff line number Diff line Loading @@ -1099,6 +1099,34 @@ public class ActivityRecordTests extends ActivityTestsBase { verify(topActivity).destroyIfPossible(anyString()); } /** * 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. Loading