summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yasin Kilicdere <tyk@google.com> 2023-01-04 21:11:46 +0000
committer Android (Google) Code Review <android-gerrit@google.com> 2023-01-04 21:11:46 +0000
commit719d7559001aa6ece0d6e9fa59eed9d4550314d9 (patch)
tree45d14045de5c886011d1fc389bdcf10bb60c84b4
parent71a1e9bf25be3f6183e45bb40b4eada148241454 (diff)
parent75266fb9d258bd859fb8f9fee89648284dc1bf9a (diff)
Merge "Force stop a user before removing it in perf tests."
-rw-r--r--apct-tests/perftests/multiuser/src/android/multiuser/BroadcastWaiter.java12
-rw-r--r--apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java18
2 files changed, 8 insertions, 22 deletions
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/BroadcastWaiter.java b/apct-tests/perftests/multiuser/src/android/multiuser/BroadcastWaiter.java
index dcabca476925..727c682b5202 100644
--- a/apct-tests/perftests/multiuser/src/android/multiuser/BroadcastWaiter.java
+++ b/apct-tests/perftests/multiuser/src/android/multiuser/BroadcastWaiter.java
@@ -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<>();
@@ -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();
}
}
@@ -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 + ")");
@@ -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();
@@ -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);
- }
}
diff --git a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
index b2bd8d7f5d5d..3f9b54cb8578 100644
--- a/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
+++ b/apct-tests/perftests/multiuser/src/android/multiuser/UserLifecycleTests.java
@@ -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();
@@ -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();
@@ -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()) {
@@ -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()) {
@@ -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
@@ -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);
@@ -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();