Loading apct-tests/perftests/multiuser/src/android/multiuser/BroadcastWaiter.java +0 −12 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ public class BroadcastWaiter implements Closeable { private final int mTimeoutInSecond; private final Set<String> mActions; private final Set<String> mActionReceivedForUser = new HashSet<>(); private final List<BroadcastReceiver> mBroadcastReceivers = new ArrayList<>(); private final Map<String, Semaphore> mSemaphoresMap = new ConcurrentHashMap<>(); Loading Loading @@ -80,7 +79,6 @@ public class BroadcastWaiter implements Closeable { final String data = intent.getDataString(); Log.d(mTag, "Received " + action + " for user " + userId + (!TextUtils.isEmpty(data) ? " with " + data : "")); mActionReceivedForUser.add(action + userId); getSemaphore(action, userId).release(); } } Loading @@ -95,10 +93,6 @@ public class BroadcastWaiter implements Closeable { mBroadcastReceivers.forEach(mContext::unregisterReceiver); } public boolean hasActionBeenReceivedForUser(String action, int userId) { return mActionReceivedForUser.contains(action + userId); } private boolean waitActionForUser(String action, int userId) { Log.d(mTag, "#waitActionForUser(action: " + action + ", userId: " + userId + ")"); Loading Loading @@ -129,7 +123,6 @@ public class BroadcastWaiter implements Closeable { public String runThenWaitForBroadcasts(int userId, FunctionalUtils.ThrowingRunnable runnable, String... actions) { for (String action : actions) { mActionReceivedForUser.remove(action + userId); getSemaphore(action, userId).drainPermits(); } runnable.run(); Loading @@ -140,9 +133,4 @@ public class BroadcastWaiter implements Closeable { } return null; } public boolean waitActionForUserIfNotReceivedYet(String action, int userId) { return hasActionBeenReceivedForUser(action, userId) || waitActionForUser(action, userId); } } apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java +8 −10 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ public class UserLifecycleTests { /** Tests creating a new user. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void createUser() { public void createUser() throws RemoteException { while (mRunner.keepRunning()) { Log.i(TAG, "Starting timer"); final int userId = createUserNoFlags(); Loading Loading @@ -229,7 +229,7 @@ public class UserLifecycleTests { * Measures the time until unlock listener is triggered and user is unlocked. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void startAndUnlockUser() { public void startAndUnlockUser() throws RemoteException { while (mRunner.keepRunning()) { mRunner.pauseTiming(); final int userId = createUserNoFlags(); Loading Loading @@ -451,7 +451,7 @@ public class UserLifecycleTests { /** Tests creating a new profile. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileCreate() { public void managedProfileCreate() throws RemoteException { assumeTrue(mHasManagedUserFeature); while (mRunner.keepRunning()) { Loading @@ -468,7 +468,7 @@ public class UserLifecycleTests { /** Tests starting (unlocking) an uninitialized profile. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileUnlock() { public void managedProfileUnlock() throws RemoteException { assumeTrue(mHasManagedUserFeature); while (mRunner.keepRunning()) { Loading Loading @@ -639,7 +639,7 @@ public class UserLifecycleTests { // TODO: This is just a POC. Do this properly and add more. /** Tests starting (unlocking) a newly-created profile using the user-type-pkg-whitelist. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileUnlock_usingWhitelist() { public void managedProfileUnlock_usingWhitelist() throws RemoteException { assumeTrue(mHasManagedUserFeature); final int origMode = getUserTypePackageWhitelistMode(); setUserTypePackageWhitelistMode(USER_TYPE_PACKAGE_WHITELIST_MODE_ENFORCE Loading @@ -665,7 +665,7 @@ public class UserLifecycleTests { } /** Tests starting (unlocking) a newly-created profile NOT using the user-type-pkg-whitelist. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileUnlock_notUsingWhitelist() { public void managedProfileUnlock_notUsingWhitelist() throws RemoteException { assumeTrue(mHasManagedUserFeature); final int origMode = getUserTypePackageWhitelistMode(); setUserTypePackageWhitelistMode(USER_TYPE_PACKAGE_WHITELIST_MODE_DISABLE); Loading Loading @@ -908,10 +908,8 @@ public class UserLifecycleTests { result != null && result.contains("Failed")); } private void removeUser(int userId) { if (mBroadcastWaiter.hasActionBeenReceivedForUser(Intent.ACTION_USER_STARTED, userId)) { mBroadcastWaiter.waitActionForUserIfNotReceivedYet(Intent.ACTION_MEDIA_MOUNTED, userId); } private void removeUser(int userId) throws RemoteException { stopUserAfterWaitingForBroadcastIdle(userId, true); try { mUm.removeUser(userId); final long startTime = System.currentTimeMillis(); Loading Loading
apct-tests/perftests/multiuser/src/android/multiuser/BroadcastWaiter.java +0 −12 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ public class BroadcastWaiter implements Closeable { private final int mTimeoutInSecond; private final Set<String> mActions; private final Set<String> mActionReceivedForUser = new HashSet<>(); private final List<BroadcastReceiver> mBroadcastReceivers = new ArrayList<>(); private final Map<String, Semaphore> mSemaphoresMap = new ConcurrentHashMap<>(); Loading Loading @@ -80,7 +79,6 @@ public class BroadcastWaiter implements Closeable { final String data = intent.getDataString(); Log.d(mTag, "Received " + action + " for user " + userId + (!TextUtils.isEmpty(data) ? " with " + data : "")); mActionReceivedForUser.add(action + userId); getSemaphore(action, userId).release(); } } Loading @@ -95,10 +93,6 @@ public class BroadcastWaiter implements Closeable { mBroadcastReceivers.forEach(mContext::unregisterReceiver); } public boolean hasActionBeenReceivedForUser(String action, int userId) { return mActionReceivedForUser.contains(action + userId); } private boolean waitActionForUser(String action, int userId) { Log.d(mTag, "#waitActionForUser(action: " + action + ", userId: " + userId + ")"); Loading Loading @@ -129,7 +123,6 @@ public class BroadcastWaiter implements Closeable { public String runThenWaitForBroadcasts(int userId, FunctionalUtils.ThrowingRunnable runnable, String... actions) { for (String action : actions) { mActionReceivedForUser.remove(action + userId); getSemaphore(action, userId).drainPermits(); } runnable.run(); Loading @@ -140,9 +133,4 @@ public class BroadcastWaiter implements Closeable { } return null; } public boolean waitActionForUserIfNotReceivedYet(String action, int userId) { return hasActionBeenReceivedForUser(action, userId) || waitActionForUser(action, userId); } }
apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java +8 −10 Original line number Diff line number Diff line Loading @@ -167,7 +167,7 @@ public class UserLifecycleTests { /** Tests creating a new user. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void createUser() { public void createUser() throws RemoteException { while (mRunner.keepRunning()) { Log.i(TAG, "Starting timer"); final int userId = createUserNoFlags(); Loading Loading @@ -229,7 +229,7 @@ public class UserLifecycleTests { * Measures the time until unlock listener is triggered and user is unlocked. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void startAndUnlockUser() { public void startAndUnlockUser() throws RemoteException { while (mRunner.keepRunning()) { mRunner.pauseTiming(); final int userId = createUserNoFlags(); Loading Loading @@ -451,7 +451,7 @@ public class UserLifecycleTests { /** Tests creating a new profile. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileCreate() { public void managedProfileCreate() throws RemoteException { assumeTrue(mHasManagedUserFeature); while (mRunner.keepRunning()) { Loading @@ -468,7 +468,7 @@ public class UserLifecycleTests { /** Tests starting (unlocking) an uninitialized profile. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileUnlock() { public void managedProfileUnlock() throws RemoteException { assumeTrue(mHasManagedUserFeature); while (mRunner.keepRunning()) { Loading Loading @@ -639,7 +639,7 @@ public class UserLifecycleTests { // TODO: This is just a POC. Do this properly and add more. /** Tests starting (unlocking) a newly-created profile using the user-type-pkg-whitelist. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileUnlock_usingWhitelist() { public void managedProfileUnlock_usingWhitelist() throws RemoteException { assumeTrue(mHasManagedUserFeature); final int origMode = getUserTypePackageWhitelistMode(); setUserTypePackageWhitelistMode(USER_TYPE_PACKAGE_WHITELIST_MODE_ENFORCE Loading @@ -665,7 +665,7 @@ public class UserLifecycleTests { } /** Tests starting (unlocking) a newly-created profile NOT using the user-type-pkg-whitelist. */ @Test(timeout = TIMEOUT_MAX_TEST_TIME_MS) public void managedProfileUnlock_notUsingWhitelist() { public void managedProfileUnlock_notUsingWhitelist() throws RemoteException { assumeTrue(mHasManagedUserFeature); final int origMode = getUserTypePackageWhitelistMode(); setUserTypePackageWhitelistMode(USER_TYPE_PACKAGE_WHITELIST_MODE_DISABLE); Loading Loading @@ -908,10 +908,8 @@ public class UserLifecycleTests { result != null && result.contains("Failed")); } private void removeUser(int userId) { if (mBroadcastWaiter.hasActionBeenReceivedForUser(Intent.ACTION_USER_STARTED, userId)) { mBroadcastWaiter.waitActionForUserIfNotReceivedYet(Intent.ACTION_MEDIA_MOUNTED, userId); } private void removeUser(int userId) throws RemoteException { stopUserAfterWaitingForBroadcastIdle(userId, true); try { mUm.removeUser(userId); final long startTime = System.currentTimeMillis(); Loading