Loading services/core/java/com/android/server/pm/UserManagerService.java +2 −18 Original line number Diff line number Diff line Loading @@ -1828,23 +1828,6 @@ public class UserManagerService extends IUserManager.Stub { return activityManagerInternal.getCurrentUserId(); } /** * Gets the current user id, or the target user id in case there is a started user switch. * * @return id of current or target foreground user, or {@link UserHandle#USER_NULL} if * {@link ActivityManagerInternal} is not available yet. */ @VisibleForTesting int getCurrentOrTargetUserId() { ActivityManagerInternal activityManagerInternal = getActivityManagerInternal(); if (activityManagerInternal == null) { Slog.w(LOG_TAG, "getCurrentOrTargetUserId() called too early, ActivityManagerInternal" + " is not set yet"); return UserHandle.USER_NULL; } return activityManagerInternal.getCurrentUser().id; } /** * Gets whether the user is the current foreground user or a started profile of that user. * Loading Loading @@ -5419,7 +5402,8 @@ public class UserManagerService extends IUserManager.Stub { final long ident = Binder.clearCallingIdentity(); try { final UserData userData; if (userId == getCurrentOrTargetUserId()) { int currentUser = getCurrentUserId(); if (currentUser == userId) { Slog.w(LOG_TAG, "Current user cannot be removed."); return false; } Loading services/tests/servicestests/src/com/android/server/pm/UserLifecycleStressTest.java +0 −15 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.content.pm.UserInfo; import android.os.RemoteException; import android.os.UserManager; import android.platform.test.annotations.Postsubmit; import android.provider.Settings; import android.util.Log; import androidx.test.InstrumentationRegistry; Loading @@ -38,7 +37,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.internal.util.FunctionalUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -64,22 +62,12 @@ public class UserLifecycleStressTest { private Context mContext; private UserManager mUserManager; private ActivityManager mActivityManager; private String mRemoveGuestOnExitOriginalValue; @Before public void setup() { mContext = InstrumentationRegistry.getInstrumentation().getContext(); mUserManager = mContext.getSystemService(UserManager.class); mActivityManager = mContext.getSystemService(ActivityManager.class); mRemoveGuestOnExitOriginalValue = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.REMOVE_GUEST_ON_EXIT); } @After public void tearDown() { Settings.Global.putString(mContext.getContentResolver(), Settings.Global.REMOVE_GUEST_ON_EXIT, mRemoveGuestOnExitOriginalValue); } /** Loading Loading @@ -117,9 +105,6 @@ public class UserLifecycleStressTest { **/ @Test public void switchToExistingGuestAndStartOverStressTest() throws Exception { Settings.Global.putString(mContext.getContentResolver(), Settings.Global.REMOVE_GUEST_ON_EXIT, "0"); if (ActivityManager.getCurrentUser() != USER_SYSTEM) { switchUser(USER_SYSTEM); } Loading Loading
services/core/java/com/android/server/pm/UserManagerService.java +2 −18 Original line number Diff line number Diff line Loading @@ -1828,23 +1828,6 @@ public class UserManagerService extends IUserManager.Stub { return activityManagerInternal.getCurrentUserId(); } /** * Gets the current user id, or the target user id in case there is a started user switch. * * @return id of current or target foreground user, or {@link UserHandle#USER_NULL} if * {@link ActivityManagerInternal} is not available yet. */ @VisibleForTesting int getCurrentOrTargetUserId() { ActivityManagerInternal activityManagerInternal = getActivityManagerInternal(); if (activityManagerInternal == null) { Slog.w(LOG_TAG, "getCurrentOrTargetUserId() called too early, ActivityManagerInternal" + " is not set yet"); return UserHandle.USER_NULL; } return activityManagerInternal.getCurrentUser().id; } /** * Gets whether the user is the current foreground user or a started profile of that user. * Loading Loading @@ -5419,7 +5402,8 @@ public class UserManagerService extends IUserManager.Stub { final long ident = Binder.clearCallingIdentity(); try { final UserData userData; if (userId == getCurrentOrTargetUserId()) { int currentUser = getCurrentUserId(); if (currentUser == userId) { Slog.w(LOG_TAG, "Current user cannot be removed."); return false; } Loading
services/tests/servicestests/src/com/android/server/pm/UserLifecycleStressTest.java +0 −15 Original line number Diff line number Diff line Loading @@ -29,7 +29,6 @@ import android.content.pm.UserInfo; import android.os.RemoteException; import android.os.UserManager; import android.platform.test.annotations.Postsubmit; import android.provider.Settings; import android.util.Log; import androidx.test.InstrumentationRegistry; Loading @@ -38,7 +37,6 @@ import androidx.test.runner.AndroidJUnit4; import com.android.internal.util.FunctionalUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; Loading @@ -64,22 +62,12 @@ public class UserLifecycleStressTest { private Context mContext; private UserManager mUserManager; private ActivityManager mActivityManager; private String mRemoveGuestOnExitOriginalValue; @Before public void setup() { mContext = InstrumentationRegistry.getInstrumentation().getContext(); mUserManager = mContext.getSystemService(UserManager.class); mActivityManager = mContext.getSystemService(ActivityManager.class); mRemoveGuestOnExitOriginalValue = Settings.Global.getString(mContext.getContentResolver(), Settings.Global.REMOVE_GUEST_ON_EXIT); } @After public void tearDown() { Settings.Global.putString(mContext.getContentResolver(), Settings.Global.REMOVE_GUEST_ON_EXIT, mRemoveGuestOnExitOriginalValue); } /** Loading Loading @@ -117,9 +105,6 @@ public class UserLifecycleStressTest { **/ @Test public void switchToExistingGuestAndStartOverStressTest() throws Exception { Settings.Global.putString(mContext.getContentResolver(), Settings.Global.REMOVE_GUEST_ON_EXIT, "0"); if (ActivityManager.getCurrentUser() != USER_SYSTEM) { switchUser(USER_SYSTEM); } Loading