fix removeUser failure due to slow broadcast processing

Removing the secondary user may not finish within the timeout of executeShellCommand() on low-end devices. It's because USER_STOPPING and/or ACTION_SHUTDOWN broadcasts aren't completed due to the other broadcast requests.

This CL fixes the issue by waiting for broadcast idle before removing user.

Bug:157813754
Test: run cts -m CtsMediaHostTestCases

Signed-off-by: qianyou <qianyou@xiaomi.com>
Change-Id: I4a9e1922e139771775a223052cc9e4a93ebe9212
diff --git a/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java b/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java
index e6f8c62..08461fb 100644
--- a/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java
+++ b/hostsidetests/media/src/android/media/cts/BaseMultiUserTest.java
@@ -227,6 +227,7 @@
     protected void removeUser(int userId) throws Exception  {
         if (getDevice().listUsers().contains(userId) && userId != USER_SYSTEM
                 && !mExistingUsers.contains(userId)) {
+            getDevice().executeShellCommand("am wait-for-broadcast-idle");
             // Don't log output, as tests sometimes set no debug user restriction, which
             // causes this to fail, we should still continue and remove the user.
             String stopUserCommand = "am stop-user -w -f " + userId;