Snap for 7961266 from 7a4cb58a136e41e53e8ad4b6c413932c79559c94 to sc-platform-release

Change-Id: I6dd2e44668e312b0d4398103aca5bbd4973fdbc1
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java b/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java
index ec4903b..aaeedc2 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/ActivityVisibilityTests.java
@@ -205,18 +205,14 @@
         }
         final ActivitySessionClient activityClient = createManagedActivityClientSession();
         testTurnScreenOnActivity(lockScreenSession, activityClient,
-                true /* useWindowFlags */, true /* showWhenLocked */);
+                true /* useWindowFlags */);
         testTurnScreenOnActivity(lockScreenSession, activityClient,
-                false /* useWindowFlags */, true /* showWhenLocked */);
+                false /* useWindowFlags */);
         if (notSupportsInsecureLock) {
             // In the platform without InsecureLock, we just test if the display is on with
             // TurnScreenOnActivity.
             mObjectTracker.close(lockScreenSession);
         }
-        testTurnScreenOnActivity(lockScreenSession, activityClient,
-                true /* useWindowFlags */, false /* showWhenLocked */);
-        testTurnScreenOnActivity(lockScreenSession, activityClient,
-                false /* useWindowFlags */, false /* showWhenLocked */);
     }
 
     @Test
@@ -230,21 +226,20 @@
         // timeout should still notify the client activity to be visible. Then the relayout can
         // send the visible request to apply the flags and turn on screen.
         testTurnScreenOnActivity(lockScreenSession, activityClient, true /* useWindowFlags */,
-                true /* showWhenLocked */, 1000 /* sleepMsInOnCreate */);
+                1000 /* sleepMsInOnCreate */);
     }
 
     private void testTurnScreenOnActivity(LockScreenSession lockScreenSession,
-            ActivitySessionClient activitySessionClient, boolean useWindowFlags,
-            boolean showWhenLocked) {
+            ActivitySessionClient activitySessionClient, boolean useWindowFlags) {
         testTurnScreenOnActivity(lockScreenSession, activitySessionClient, useWindowFlags,
-                showWhenLocked, 0 /* sleepMsInOnCreate */);
+                0 /* sleepMsInOnCreate */);
     }
 
     private void testTurnScreenOnActivity(LockScreenSession lockScreenSession,
             ActivitySessionClient activitySessionClient, boolean useWindowFlags,
-            boolean showWhenLocked, int sleepMsInOnCreate) {
+            int sleepMsInOnCreate) {
         ActivitySession activity = sleepDeviceAndLaunchTurnScreenOnActivity(lockScreenSession,
-                activitySessionClient, useWindowFlags, showWhenLocked, sleepMsInOnCreate,
+                activitySessionClient, useWindowFlags, sleepMsInOnCreate,
                 WINDOWING_MODE_FULLSCREEN);
 
         mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, true);
@@ -263,21 +258,16 @@
         final ActivitySessionClient activityClient = createManagedActivityClientSession();
 
         testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient,
-                true/* useWindowFlags */, true/* showWhenLocked */);
+                true/* useWindowFlags */);
         testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient,
-                true/* useWindowFlags */, false/* showWhenLocked */);
-        testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient,
-                false/* useWindowFlags */, true/* showWhenLocked */);
-        testFreeformWindowTurnScreenOnActivity(lockScreenSession, activityClient,
-                false/* useWindowFlags */, false/* showWhenLocked */);
+                false/* useWindowFlags */);
     }
 
     private void testFreeformWindowTurnScreenOnActivity(LockScreenSession lockScreenSession,
-            ActivitySessionClient activityClient, boolean useWindowFlags,
-            boolean showWhenLocked) {
+            ActivitySessionClient activityClient, boolean useWindowFlags) {
         ActivitySession activity = sleepDeviceAndLaunchTurnScreenOnActivity(lockScreenSession,
-                activityClient, useWindowFlags, showWhenLocked,
-                0 /* sleepMsInOnCreate */, WINDOWING_MODE_FREEFORM);
+                activityClient, useWindowFlags, 0 /* sleepMsInOnCreate */,
+                WINDOWING_MODE_FREEFORM);
         mWmState.waitForValidState(
                 new WaitForValidActivityState.Builder(TURN_SCREEN_ON_ACTIVITY)
                         .setWindowingMode(WINDOWING_MODE_FULLSCREEN)
@@ -291,16 +281,13 @@
 
     private ActivitySession sleepDeviceAndLaunchTurnScreenOnActivity(
             LockScreenSession lockScreenSession, ActivitySessionClient activitySessionClient,
-            boolean useWindowFlags, boolean showWhenLocked, int sleepMsInOnCreate,
-            int windowingMode) {
+            boolean useWindowFlags, int sleepMsInOnCreate, int windowingMode) {
         lockScreenSession.sleepDevice();
 
         return activitySessionClient.startActivity(
                 getLaunchActivityBuilder().setUseInstrumentation().setIntentExtra(extra -> {
                     extra.putBoolean(Components.TurnScreenOnActivity.EXTRA_USE_WINDOW_FLAGS,
                             useWindowFlags);
-                    extra.putBoolean(Components.TurnScreenOnActivity.EXTRA_SHOW_WHEN_LOCKED,
-                            showWhenLocked);
                     extra.putLong(Components.TurnScreenOnActivity.EXTRA_SLEEP_MS_IN_ON_CREATE,
                             sleepMsInOnCreate);
                 }).setTargetActivity(TURN_SCREEN_ON_ACTIVITY).setWindowingMode(windowingMode));
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java
index 92368fb..62a5ac7 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardLockedTests.java
@@ -216,40 +216,6 @@
     }
 
     @Test
-    public void testTurnScreenOnActivity_withSecureKeyguardAndAod() {
-        final AodSession aodSession = createManagedAodSession();
-        final LockScreenSession lockScreenSession = createManagedLockScreenSession();
-        lockScreenSession.setLockCredential();
-        testTurnScreenOnActivity_withSecureKeyguard(aodSession, lockScreenSession,
-                false /* enableAod */);
-        testTurnScreenOnActivity_withSecureKeyguard(aodSession, lockScreenSession,
-                true /* enableAod */);
-    }
-
-    private void testTurnScreenOnActivity_withSecureKeyguard(AodSession aodSession,
-            LockScreenSession lockScreenSession, boolean enableAod) {
-        if (enableAod) {
-            assumeTrue(aodSession.isAodAvailable());
-        }
-        aodSession.setAodEnabled(enableAod);
-        lockScreenSession.sleepDevice();
-        mWmState.computeState();
-        assertTrue(mWmState.getKeyguardControllerState().keyguardShowing);
-
-        final CommandSession.ActivitySessionClient activityClient =
-                createManagedActivityClientSession();
-        final CommandSession.ActivitySession activity = activityClient.startActivity(
-                getLaunchActivityBuilder().setUseInstrumentation().setIntentExtra(extra -> {
-                    extra.putBoolean(Components.TurnScreenOnActivity.EXTRA_SHOW_WHEN_LOCKED, false);
-                }).setTargetActivity(TURN_SCREEN_ON_ACTIVITY));
-        mWmState.waitForKeyguardShowingAndNotOccluded();
-        mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, false);
-        assertTrue(mWmState.getKeyguardControllerState().keyguardShowing);
-        assertFalse(isDisplayOn(DEFAULT_DISPLAY));
-        activity.finish();
-    }
-
-    @Test
     public void testDismissKeyguardAttrActivity_method_turnScreenOn_withSecureKeyguard() {
         final LockScreenSession lockScreenSession = createManagedLockScreenSession();
         lockScreenSession.setLockCredential().sleepDevice();
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java
index 4213984..dc7c308 100755
--- a/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/KeyguardTests.java
@@ -443,7 +443,7 @@
     }
 
     @Test
-    public void testTurnScreenOnOnActivityOnAod() {
+    public void testTurnScreenOnActivityOnAod() {
         final AodSession aodSession = createManagedAodSession();
         assumeTrue(aodSession.isAodAvailable());
         aodSession.setAodEnabled(true);
@@ -460,10 +460,13 @@
                             false);
                 }).setTargetActivity(TURN_SCREEN_ON_ACTIVITY));
 
-        mWmState.computeState(TURN_SCREEN_ON_ACTIVITY);
-        mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, true);
-        assertFalse(mWmState.getKeyguardControllerState().keyguardShowing);
-        assertTrue(isDisplayOn(DEFAULT_DISPLAY));
+        mWmState.waitForAllStoppedActivities();
+        // An activity without set showWhenLocked or dismissKeyguard cannot wakeup device and/or
+        // unlock insecure keyguard even if it has setTurnScreenOn, so the device should stay
+        // invisible and the display stay in dozing.
+        mWmState.assertVisibility(TURN_SCREEN_ON_ACTIVITY, false);
+        assertTrue(mWmState.getKeyguardControllerState().keyguardShowing);
+        assertFalse(isDisplayOn(DEFAULT_DISPLAY));
     }
     /**
      * Tests whether a FLAG_DISMISS_KEYGUARD activity occludes Keyguard.