testAlwaysOnVpnUnsupportedPackageReplaced failed during cts test


Original change: https://android-review.googlesource.com/c/platform/cts/+/1366979

Test: run cts -m  CtsDevicePolicyManagerTestCases -t com.android.cts.devicepolicy.MixedManagedProfileOwnerTest#testAlwaysOnVpnUnsupportedPackageReplaced

Bug: 161731350
Bug: 163410385
Change-Id: Ic1518689c4b92abcb9b26cd89c9e2b398b1f6e58
Merged-In: Ic1518689c4b92abcb9b26cd89c9e2b398b1f6e58
(cherry picked from commit 2d8433c6c812beb6e3132b12db1f53eaa6bb626d)
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
index bf466cf..d16f982 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/DeviceAndProfileOwnerTest.java
@@ -564,6 +564,8 @@
             executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testSetSupportedVpnAlwaysOn");
             // Update the app to target higher API level, but with manifest opt-out
             installAppAsUser(VPN_APP_NOT_ALWAYS_ON_APK, mUserId);
+            // wait for the app update install completed, ready to be tested
+            waitForBroadcastIdle();
             executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testAssertNoAlwaysOnVpn");
         } finally {
             executeDeviceTestMethod(".AlwaysOnVpnUnsupportedTest", "testClearAlwaysOnVpn");