Make sure that the LockTaskUtilityActivityIfWhitelisted was started.

There is flaky in some device. After FallbackHome received the broadcast of USER_UNLOCKED, when the system was preparing to start LockTaskUtilityActivityIfWhitelisted, the case started the 'android.settings.SETTINGS', resulting in LockTaskUtilityActivityIfWhitelisted not being started.

Test: run cts -m CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedProfileOwnerTest#testLockTaskAfterReboot_tryOpeningSettings

Bug: 146006729

Change-Id: I6db66d7de561f031ccd79738224f2cd4b9a05e34
Signed-off-by: duanyangqi <duanyangqi@xiaomi.com>
(cherry picked from commit 216ed1555b5f60ad048f503f985722fbf448a7f8)
diff --git a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
index 409b076..e171988 100644
--- a/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
+++ b/hostsidetests/devicepolicy/app/DeviceAndProfileOwner/src/com/android/cts/deviceandprofileowner/LockTaskHostDrivenTest.java
@@ -86,6 +86,12 @@
         mUiDevice.pressHome();
     }
 
+    public void testLockTaskIsActive() throws Exception {
+        Log.d(TAG, "testLockTaskIsActive on host-driven test");
+        waitAndCheckLockedActivityIsResumed();
+        checkLockedActivityIsRunning();
+    }
+
     /**
      * On low-RAM devices, this test can take too long to finish, so the test runner can incorrectly
      * assume it's finished. Therefore, only use it once in a given test.
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index 517f018..1301d2a 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -1226,6 +1226,9 @@
             // Wait for the LockTask starting
             waitForBroadcastIdle();
 
+            // Make sure that the LockTaskUtilityActivityIfWhitelisted was started.
+            executeDeviceTestMethod(".LockTaskHostDrivenTest", "testLockTaskIsActive");
+
             // Try to open settings via adb
             executeShellCommand("am start -a android.settings.SETTINGS");