Loading services/core/java/com/android/server/am/ActivityStackSupervisor.java +7 −7 Original line number Diff line number Diff line Loading @@ -643,7 +643,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D void setWindowManager(WindowManagerService wm) { synchronized (mService) { mWindowManager = wm; mKeyguardController.setWindowManager(wm); getKeyguardController().setWindowManager(wm); mDisplayManager = (DisplayManager)mService.mContext.getSystemService(Context.DISPLAY_SERVICE); Loading Loading @@ -1312,7 +1312,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D r.setProcess(app); if (mKeyguardController.isKeyguardLocked()) { if (getKeyguardController().isKeyguardLocked()) { r.notifyUnknownVisibilityLaunched(); } Loading Loading @@ -3377,7 +3377,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } else { stack.awakeFromSleepingLocked(); if (isFocusedStack(stack) && !mKeyguardController.isKeyguardShowing(display.mDisplayId)) { && !getKeyguardController().isKeyguardShowing(display.mDisplayId)) { // If the keyguard is unlocked - resume immediately. // It is possible that the display will not be awake at the time we // process the keyguard going away, which can happen before the sleep token Loading Loading @@ -3501,7 +3501,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D void ensureActivitiesVisibleLocked(ActivityRecord starting, int configChanges, boolean preserveWindows) { mKeyguardController.beginActivityVisibilityUpdate(); getKeyguardController().beginActivityVisibilityUpdate(); try { // First the front stacks. In case any are not fullscreen and are in front of home. for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) { Loading @@ -3512,7 +3512,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } } } finally { mKeyguardController.endActivityVisibilityUpdate(); getKeyguardController().endActivityVisibilityUpdate(); } } Loading Loading @@ -3799,7 +3799,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D pw.print(prefix); pw.print("isHomeRecentsComponent="); pw.print(mRecentTasks.isRecentsComponentHomeActivity(mCurrentUser)); mKeyguardController.dump(pw, prefix); getKeyguardController().dump(pw, prefix); mService.mLockTaskController.dump(pw, prefix); } Loading @@ -3810,7 +3810,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D ActivityDisplay activityDisplay = mActivityDisplays.valueAt(displayNdx); activityDisplay.writeToProto(proto, DISPLAYS); } mKeyguardController.writeToProto(proto, KEYGUARD_CONTROLLER); getKeyguardController().writeToProto(proto, KEYGUARD_CONTROLLER); if (mFocusedStack != null) { proto.write(FOCUSED_STACK_ID, mFocusedStack.mStackId); ActivityRecord focusedActivity = getResumedActivityLocked(); Loading services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java +58 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.app.ActivityManager; import android.app.WaitResult; Loading Loading @@ -180,4 +186,56 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase { assertEquals(deliverToTopWait.who, firstActivity.realActivity); } } @Test public void testApplySleepTokensLocked() throws Exception { final ActivityDisplay display = mSupervisor.getDefaultDisplay(); final KeyguardController keyguard = mSupervisor.getKeyguardController(); final ActivityStack stack = mock(ActivityStack.class); display.addChild(stack, 0 /* position */); // Make sure we wake and resume in the case the display is turning on and the keyguard is // not showing. verifySleepTokenBehavior(display, keyguard, stack, true /*displaySleeping*/, false /* displayShouldSleep */, true /* isFocusedStack */, false /* keyguardShowing */, true /* expectWakeFromSleep */, true /* expectResumeTopActivity */); // Make sure we wake and don't resume when the display is turning on and the keyguard is // showing. verifySleepTokenBehavior(display, keyguard, stack, true /*displaySleeping*/, false /* displayShouldSleep */, true /* isFocusedStack */, true /* keyguardShowing */, true /* expectWakeFromSleep */, false /* expectResumeTopActivity */); // Make sure we wake and don't resume when the display is turning on and the keyguard is // not showing as unfocused. verifySleepTokenBehavior(display, keyguard, stack, true /*displaySleeping*/, false /* displayShouldSleep */, false /* isFocusedStack */, false /* keyguardShowing */, true /* expectWakeFromSleep */, false /* expectResumeTopActivity */); // Should not do anything if the display state hasn't changed. verifySleepTokenBehavior(display, keyguard, stack, false /*displaySleeping*/, false /* displayShouldSleep */, true /* isFocusedStack */, false /* keyguardShowing */, false /* expectWakeFromSleep */, false /* expectResumeTopActivity */); } private void verifySleepTokenBehavior(ActivityDisplay display, KeyguardController keyguard, ActivityStack stack, boolean displaySleeping, boolean displayShouldSleep, boolean isFocusedStack, boolean keyguardShowing, boolean expectWakeFromSleep, boolean expectResumeTopActivity) { reset(stack); doReturn(displayShouldSleep).when(display).shouldSleep(); doReturn(displaySleeping).when(display).isSleeping(); doReturn(keyguardShowing).when(keyguard).isKeyguardShowing(anyInt()); mSupervisor.mFocusedStack = isFocusedStack ? stack : null; mSupervisor.applySleepTokensLocked(true); verify(stack, times(expectWakeFromSleep ? 1 : 0)).awakeFromSleepingLocked(); verify(stack, times(expectResumeTopActivity ? 1 : 0)).resumeTopActivityUncheckedLocked( null /* target */, null /* targetOptions */); } } services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java +8 −1 Original line number Diff line number Diff line Loading @@ -353,21 +353,28 @@ public class ActivityTestsBase { */ protected static class TestActivityStackSupervisor extends ActivityStackSupervisor { private ActivityDisplay mDisplay; private KeyguardController mKeyguardController; public TestActivityStackSupervisor(ActivityManagerService service, Looper looper) { super(service, looper); mDisplayManager = (DisplayManager) mService.mContext.getSystemService(Context.DISPLAY_SERVICE); mWindowManager = prepareMockWindowManager(); mKeyguardController = mock(KeyguardController.class); } @Override public void initialize() { super.initialize(); mDisplay = new TestActivityDisplay(this, DEFAULT_DISPLAY); mDisplay = spy(new TestActivityDisplay(this, DEFAULT_DISPLAY)); attachDisplay(mDisplay); } @Override public KeyguardController getKeyguardController() { return mKeyguardController; } @Override ActivityDisplay getDefaultDisplay() { return mDisplay; Loading Loading
services/core/java/com/android/server/am/ActivityStackSupervisor.java +7 −7 Original line number Diff line number Diff line Loading @@ -643,7 +643,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D void setWindowManager(WindowManagerService wm) { synchronized (mService) { mWindowManager = wm; mKeyguardController.setWindowManager(wm); getKeyguardController().setWindowManager(wm); mDisplayManager = (DisplayManager)mService.mContext.getSystemService(Context.DISPLAY_SERVICE); Loading Loading @@ -1312,7 +1312,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D r.setProcess(app); if (mKeyguardController.isKeyguardLocked()) { if (getKeyguardController().isKeyguardLocked()) { r.notifyUnknownVisibilityLaunched(); } Loading Loading @@ -3377,7 +3377,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } else { stack.awakeFromSleepingLocked(); if (isFocusedStack(stack) && !mKeyguardController.isKeyguardShowing(display.mDisplayId)) { && !getKeyguardController().isKeyguardShowing(display.mDisplayId)) { // If the keyguard is unlocked - resume immediately. // It is possible that the display will not be awake at the time we // process the keyguard going away, which can happen before the sleep token Loading Loading @@ -3501,7 +3501,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D void ensureActivitiesVisibleLocked(ActivityRecord starting, int configChanges, boolean preserveWindows) { mKeyguardController.beginActivityVisibilityUpdate(); getKeyguardController().beginActivityVisibilityUpdate(); try { // First the front stacks. In case any are not fullscreen and are in front of home. for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) { Loading @@ -3512,7 +3512,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D } } } finally { mKeyguardController.endActivityVisibilityUpdate(); getKeyguardController().endActivityVisibilityUpdate(); } } Loading Loading @@ -3799,7 +3799,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D pw.print(prefix); pw.print("isHomeRecentsComponent="); pw.print(mRecentTasks.isRecentsComponentHomeActivity(mCurrentUser)); mKeyguardController.dump(pw, prefix); getKeyguardController().dump(pw, prefix); mService.mLockTaskController.dump(pw, prefix); } Loading @@ -3810,7 +3810,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D ActivityDisplay activityDisplay = mActivityDisplays.valueAt(displayNdx); activityDisplay.writeToProto(proto, DISPLAYS); } mKeyguardController.writeToProto(proto, KEYGUARD_CONTROLLER); getKeyguardController().writeToProto(proto, KEYGUARD_CONTROLLER); if (mFocusedStack != null) { proto.write(FOCUSED_STACK_ID, mFocusedStack.mStackId); ActivityRecord focusedActivity = getResumedActivityLocked(); Loading
services/tests/servicestests/src/com/android/server/am/ActivityStackSupervisorTests.java +58 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,12 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertFalse; import static org.mockito.Matchers.anyInt; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import android.app.ActivityManager; import android.app.WaitResult; Loading Loading @@ -180,4 +186,56 @@ public class ActivityStackSupervisorTests extends ActivityTestsBase { assertEquals(deliverToTopWait.who, firstActivity.realActivity); } } @Test public void testApplySleepTokensLocked() throws Exception { final ActivityDisplay display = mSupervisor.getDefaultDisplay(); final KeyguardController keyguard = mSupervisor.getKeyguardController(); final ActivityStack stack = mock(ActivityStack.class); display.addChild(stack, 0 /* position */); // Make sure we wake and resume in the case the display is turning on and the keyguard is // not showing. verifySleepTokenBehavior(display, keyguard, stack, true /*displaySleeping*/, false /* displayShouldSleep */, true /* isFocusedStack */, false /* keyguardShowing */, true /* expectWakeFromSleep */, true /* expectResumeTopActivity */); // Make sure we wake and don't resume when the display is turning on and the keyguard is // showing. verifySleepTokenBehavior(display, keyguard, stack, true /*displaySleeping*/, false /* displayShouldSleep */, true /* isFocusedStack */, true /* keyguardShowing */, true /* expectWakeFromSleep */, false /* expectResumeTopActivity */); // Make sure we wake and don't resume when the display is turning on and the keyguard is // not showing as unfocused. verifySleepTokenBehavior(display, keyguard, stack, true /*displaySleeping*/, false /* displayShouldSleep */, false /* isFocusedStack */, false /* keyguardShowing */, true /* expectWakeFromSleep */, false /* expectResumeTopActivity */); // Should not do anything if the display state hasn't changed. verifySleepTokenBehavior(display, keyguard, stack, false /*displaySleeping*/, false /* displayShouldSleep */, true /* isFocusedStack */, false /* keyguardShowing */, false /* expectWakeFromSleep */, false /* expectResumeTopActivity */); } private void verifySleepTokenBehavior(ActivityDisplay display, KeyguardController keyguard, ActivityStack stack, boolean displaySleeping, boolean displayShouldSleep, boolean isFocusedStack, boolean keyguardShowing, boolean expectWakeFromSleep, boolean expectResumeTopActivity) { reset(stack); doReturn(displayShouldSleep).when(display).shouldSleep(); doReturn(displaySleeping).when(display).isSleeping(); doReturn(keyguardShowing).when(keyguard).isKeyguardShowing(anyInt()); mSupervisor.mFocusedStack = isFocusedStack ? stack : null; mSupervisor.applySleepTokensLocked(true); verify(stack, times(expectWakeFromSleep ? 1 : 0)).awakeFromSleepingLocked(); verify(stack, times(expectResumeTopActivity ? 1 : 0)).resumeTopActivityUncheckedLocked( null /* target */, null /* targetOptions */); } }
services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java +8 −1 Original line number Diff line number Diff line Loading @@ -353,21 +353,28 @@ public class ActivityTestsBase { */ protected static class TestActivityStackSupervisor extends ActivityStackSupervisor { private ActivityDisplay mDisplay; private KeyguardController mKeyguardController; public TestActivityStackSupervisor(ActivityManagerService service, Looper looper) { super(service, looper); mDisplayManager = (DisplayManager) mService.mContext.getSystemService(Context.DISPLAY_SERVICE); mWindowManager = prepareMockWindowManager(); mKeyguardController = mock(KeyguardController.class); } @Override public void initialize() { super.initialize(); mDisplay = new TestActivityDisplay(this, DEFAULT_DISPLAY); mDisplay = spy(new TestActivityDisplay(this, DEFAULT_DISPLAY)); attachDisplay(mDisplay); } @Override public KeyguardController getKeyguardController() { return mKeyguardController; } @Override ActivityDisplay getDefaultDisplay() { return mDisplay; Loading