Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66f73a87 authored by Sudheer Shanka's avatar Sudheer Shanka
Browse files

Fix UserManagerTest#testSwitchUser.

ActivityManager.getCurrentUser() will return the targetUserId right
after ActivityManager.switchUser() is called. So, it is not a good
signal for the test to figure out if user switching is completed or
not. Instead just rely on the USER_SWITCHED broadcast.

Bug: 31045777
Change-Id: I58bff8a42ef4fa15c8667708f5956865b6417934
parent e637f315
Loading
Loading
Loading
Loading
+8 −11
Original line number Diff line number Diff line
@@ -41,7 +41,6 @@ import java.util.List;
public class UserManagerTest extends AndroidTestCase {
    private static final int REMOVE_CHECK_INTERVAL_MILLIS = 500; // 0.5 seconds
    private static final int REMOVE_TIMEOUT_MILLIS = 60 * 1000; // 60 seconds
    private static final int SWITCH_CHECK_INTERVAL_MILLIS = 2 * 1000; // 2 seconds
    private static final int SWITCH_USER_TIMEOUT_MILLIS = 40 * 1000; // 40 seconds

    private final Object mUserRemoveLock = new Object();
@@ -347,9 +346,8 @@ public class UserManagerTest extends AndroidTestCase {
            ActivityManager am = getContext().getSystemService(ActivityManager.class);
            am.switchUser(userId);
            long time = System.currentTimeMillis();
            while (am.getCurrentUser() != userId) {
            try {
                    mUserSwitchLock.wait(SWITCH_CHECK_INTERVAL_MILLIS);
                mUserSwitchLock.wait(SWITCH_USER_TIMEOUT_MILLIS);
            } catch (InterruptedException ie) {
                Thread.currentThread().interrupt();
                return;
@@ -359,7 +357,6 @@ public class UserManagerTest extends AndroidTestCase {
            }
        }
    }
    }

    private void removeUser(int userId) {
        synchronized (mUserRemoveLock) {