Loading services/core/java/com/android/server/wm/AppWindowToken.java +18 −0 Original line number Original line Diff line number Diff line Loading @@ -915,7 +915,11 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } } if (mPendingRelaunchCount > 0) { if (mPendingRelaunchCount > 0) { mPendingRelaunchCount--; mPendingRelaunchCount--; } else { // Update keyguard flags upon finishing relaunch. checkKeyguardFlagsChanged(); } } updateAllDrawn(); updateAllDrawn(); } } Loading Loading @@ -1505,6 +1509,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } } boolean containsDismissKeyguardWindow() { boolean containsDismissKeyguardWindow() { // Window state is transient during relaunch. We are not guaranteed to be frozen during the // entirety of the relaunch. if (isRelaunching()) { return mLastContainsDismissKeyguardWindow; } for (int i = mChildren.size() - 1; i >= 0; i--) { for (int i = mChildren.size() - 1; i >= 0; i--) { if ((mChildren.get(i).mAttrs.flags & FLAG_DISMISS_KEYGUARD) != 0) { if ((mChildren.get(i).mAttrs.flags & FLAG_DISMISS_KEYGUARD) != 0) { return true; return true; Loading @@ -1514,11 +1524,19 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } } boolean containsShowWhenLockedWindow() { boolean containsShowWhenLockedWindow() { // When we are relaunching, it is possible for us to be unfrozen before our previous // windows have been added back. Using the cached value ensures that our previous // showWhenLocked preference is honored until relaunching is complete. if (isRelaunching()) { return mLastContainsShowWhenLockedWindow; } for (int i = mChildren.size() - 1; i >= 0; i--) { for (int i = mChildren.size() - 1; i >= 0; i--) { if ((mChildren.get(i).mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) { if ((mChildren.get(i).mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) { return true; return true; } } } } return false; return false; } } Loading services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java +30 −1 Original line number Original line Diff line number Diff line Loading @@ -30,13 +30,15 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; /** /** * Tests for the {@link AppWindowToken} class. * Tests for the {@link AppWindowToken} class. * * Loading Loading @@ -184,4 +186,31 @@ public class AppWindowTokenTests extends WindowTestsBase { // Can specify orientation if the current orientation candidate is orientation behind. // Can specify orientation if the current orientation candidate is orientation behind. assertEquals(SCREEN_ORIENTATION_LANDSCAPE, token.getOrientation(SCREEN_ORIENTATION_BEHIND)); assertEquals(SCREEN_ORIENTATION_LANDSCAPE, token.getOrientation(SCREEN_ORIENTATION_BEHIND)); } } @Test public void testKeyguardFlagsDuringRelaunch() throws Exception { final WindowTestUtils.TestAppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent); final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams( TYPE_BASE_APPLICATION); attrs.flags |= FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD; attrs.setTitle("AppWindow"); final WindowTestUtils.TestWindowState appWindow = createWindowState(attrs, token); // Add window with show when locked flag token.addWindow(appWindow); assertTrue(token.containsShowWhenLockedWindow() && token.containsDismissKeyguardWindow()); // Start relaunching token.startRelaunching(); assertTrue(token.containsShowWhenLockedWindow() && token.containsDismissKeyguardWindow()); // Remove window and make sure that we still report back flag token.removeChild(appWindow); assertTrue(token.containsShowWhenLockedWindow() && token.containsDismissKeyguardWindow()); // Finish relaunching and ensure flag is now not reported token.finishRelaunching(); assertFalse(token.containsShowWhenLockedWindow() || token.containsDismissKeyguardWindow()); } } } Loading
services/core/java/com/android/server/wm/AppWindowToken.java +18 −0 Original line number Original line Diff line number Diff line Loading @@ -915,7 +915,11 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } } if (mPendingRelaunchCount > 0) { if (mPendingRelaunchCount > 0) { mPendingRelaunchCount--; mPendingRelaunchCount--; } else { // Update keyguard flags upon finishing relaunch. checkKeyguardFlagsChanged(); } } updateAllDrawn(); updateAllDrawn(); } } Loading Loading @@ -1505,6 +1509,12 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } } boolean containsDismissKeyguardWindow() { boolean containsDismissKeyguardWindow() { // Window state is transient during relaunch. We are not guaranteed to be frozen during the // entirety of the relaunch. if (isRelaunching()) { return mLastContainsDismissKeyguardWindow; } for (int i = mChildren.size() - 1; i >= 0; i--) { for (int i = mChildren.size() - 1; i >= 0; i--) { if ((mChildren.get(i).mAttrs.flags & FLAG_DISMISS_KEYGUARD) != 0) { if ((mChildren.get(i).mAttrs.flags & FLAG_DISMISS_KEYGUARD) != 0) { return true; return true; Loading @@ -1514,11 +1524,19 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree } } boolean containsShowWhenLockedWindow() { boolean containsShowWhenLockedWindow() { // When we are relaunching, it is possible for us to be unfrozen before our previous // windows have been added back. Using the cached value ensures that our previous // showWhenLocked preference is honored until relaunching is complete. if (isRelaunching()) { return mLastContainsShowWhenLockedWindow; } for (int i = mChildren.size() - 1; i >= 0; i--) { for (int i = mChildren.size() - 1; i >= 0; i--) { if ((mChildren.get(i).mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) { if ((mChildren.get(i).mAttrs.flags & FLAG_SHOW_WHEN_LOCKED) != 0) { return true; return true; } } } } return false; return false; } } Loading
services/tests/servicestests/src/com/android/server/wm/AppWindowTokenTests.java +30 −1 Original line number Original line Diff line number Diff line Loading @@ -30,13 +30,15 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FIRST_SUB_WINDOW; import static android.view.WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue; /** /** * Tests for the {@link AppWindowToken} class. * Tests for the {@link AppWindowToken} class. * * Loading Loading @@ -184,4 +186,31 @@ public class AppWindowTokenTests extends WindowTestsBase { // Can specify orientation if the current orientation candidate is orientation behind. // Can specify orientation if the current orientation candidate is orientation behind. assertEquals(SCREEN_ORIENTATION_LANDSCAPE, token.getOrientation(SCREEN_ORIENTATION_BEHIND)); assertEquals(SCREEN_ORIENTATION_LANDSCAPE, token.getOrientation(SCREEN_ORIENTATION_BEHIND)); } } @Test public void testKeyguardFlagsDuringRelaunch() throws Exception { final WindowTestUtils.TestAppWindowToken token = new WindowTestUtils.TestAppWindowToken(mDisplayContent); final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams( TYPE_BASE_APPLICATION); attrs.flags |= FLAG_SHOW_WHEN_LOCKED | FLAG_DISMISS_KEYGUARD; attrs.setTitle("AppWindow"); final WindowTestUtils.TestWindowState appWindow = createWindowState(attrs, token); // Add window with show when locked flag token.addWindow(appWindow); assertTrue(token.containsShowWhenLockedWindow() && token.containsDismissKeyguardWindow()); // Start relaunching token.startRelaunching(); assertTrue(token.containsShowWhenLockedWindow() && token.containsDismissKeyguardWindow()); // Remove window and make sure that we still report back flag token.removeChild(appWindow); assertTrue(token.containsShowWhenLockedWindow() && token.containsDismissKeyguardWindow()); // Finish relaunching and ensure flag is now not reported token.finishRelaunching(); assertFalse(token.containsShowWhenLockedWindow() || token.containsDismissKeyguardWindow()); } } }