Loading core/java/android/os/IUserManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -87,4 +87,6 @@ interface IUserManager { in String[] disallowedPackages); boolean isUserUnlockingOrUnlocked(int userId); int getManagedProfileBadge(int userId); boolean isUserUnlocked(int userId); boolean isUserRunning(int userId); } core/java/android/os/UserManager.java +3 −5 Original line number Diff line number Diff line Loading @@ -996,10 +996,9 @@ public class UserManager { } /** {@hide} */ public boolean isUserRunning(int userId) { // TODO Switch to using UMS internal isUserRunning public boolean isUserRunning(@UserIdInt int userId) { try { return ActivityManager.getService().isUserRunning(userId, 0); return mService.isUserRunning(userId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } Loading Loading @@ -1096,8 +1095,7 @@ public class UserManager { /** {@hide} */ public boolean isUserUnlocked(@UserIdInt int userId) { try { return ActivityManager.getService().isUserRunning(userId, ActivityManager.FLAG_AND_UNLOCKED); return mService.isUserUnlocked(userId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } Loading core/java/android/os/UserManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,12 @@ public abstract class UserManagerInternal { */ public abstract boolean isUserUnlockingOrUnlocked(int userId); /** * Return whether the given user is running in an * {@code UserState.STATE_RUNNING_UNLOCKED} state. */ public abstract boolean isUserUnlocked(int userId); /** * Return whether the given user is running */ Loading services/core/java/com/android/server/pm/UserManagerService.java +33 −6 Original line number Diff line number Diff line Loading @@ -913,14 +913,33 @@ public class UserManagerService extends IUserManager.Stub { @Override public boolean isUserUnlockingOrUnlocked(int userId) { checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlockingOrUnlocked"); return mLocalService.isUserUnlockingOrUnlocked(userId); } @Override public boolean isUserUnlocked(int userId) { checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlocked"); return mLocalService.isUserUnlockingOrUnlocked(userId); } @Override public boolean isUserRunning(int userId) { checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserRunning"); return mLocalService.isUserRunning(userId); } private void checkManageOrInteractPermIfCallerInOtherProfileGroup(int userId, String name) { int callingUserId = UserHandle.getCallingUserId(); if (callingUserId != userId && !hasManageUsersPermission()) { if (!isSameProfileGroupNoChecks(callingUserId, userId)) { throw new SecurityException( "You need MANAGE_USERS permission to: check isUserUnlockingOrUnlocked"); if (callingUserId == userId || isSameProfileGroupNoChecks(callingUserId, userId) || hasManageUsersPermission()) { return; } if (ActivityManager.checkComponentPermission(Manifest.permission.INTERACT_ACROSS_USERS, Binder.getCallingUid(), -1, true) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("You need INTERACT_ACROSS_USERS or MANAGE_USERS permission " + "to: check " + name); } return mLocalService.isUserUnlockingOrUnlocked(userId); } @Override Loading Loading @@ -3641,6 +3660,14 @@ public class UserManagerService extends IUserManager.Stub { || (state == UserState.STATE_RUNNING_UNLOCKED); } } @Override public boolean isUserUnlocked(int userId) { synchronized (mUserStates) { int state = mUserStates.get(userId, -1); return state == UserState.STATE_RUNNING_UNLOCKED; } } } /* Remove all the users except of the system one. */ Loading Loading
core/java/android/os/IUserManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -87,4 +87,6 @@ interface IUserManager { in String[] disallowedPackages); boolean isUserUnlockingOrUnlocked(int userId); int getManagedProfileBadge(int userId); boolean isUserUnlocked(int userId); boolean isUserRunning(int userId); }
core/java/android/os/UserManager.java +3 −5 Original line number Diff line number Diff line Loading @@ -996,10 +996,9 @@ public class UserManager { } /** {@hide} */ public boolean isUserRunning(int userId) { // TODO Switch to using UMS internal isUserRunning public boolean isUserRunning(@UserIdInt int userId) { try { return ActivityManager.getService().isUserRunning(userId, 0); return mService.isUserRunning(userId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } Loading Loading @@ -1096,8 +1095,7 @@ public class UserManager { /** {@hide} */ public boolean isUserUnlocked(@UserIdInt int userId) { try { return ActivityManager.getService().isUserRunning(userId, ActivityManager.FLAG_AND_UNLOCKED); return mService.isUserUnlocked(userId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } Loading
core/java/android/os/UserManagerInternal.java +6 −0 Original line number Diff line number Diff line Loading @@ -141,6 +141,12 @@ public abstract class UserManagerInternal { */ public abstract boolean isUserUnlockingOrUnlocked(int userId); /** * Return whether the given user is running in an * {@code UserState.STATE_RUNNING_UNLOCKED} state. */ public abstract boolean isUserUnlocked(int userId); /** * Return whether the given user is running */ Loading
services/core/java/com/android/server/pm/UserManagerService.java +33 −6 Original line number Diff line number Diff line Loading @@ -913,14 +913,33 @@ public class UserManagerService extends IUserManager.Stub { @Override public boolean isUserUnlockingOrUnlocked(int userId) { checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlockingOrUnlocked"); return mLocalService.isUserUnlockingOrUnlocked(userId); } @Override public boolean isUserUnlocked(int userId) { checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserUnlocked"); return mLocalService.isUserUnlockingOrUnlocked(userId); } @Override public boolean isUserRunning(int userId) { checkManageOrInteractPermIfCallerInOtherProfileGroup(userId, "isUserRunning"); return mLocalService.isUserRunning(userId); } private void checkManageOrInteractPermIfCallerInOtherProfileGroup(int userId, String name) { int callingUserId = UserHandle.getCallingUserId(); if (callingUserId != userId && !hasManageUsersPermission()) { if (!isSameProfileGroupNoChecks(callingUserId, userId)) { throw new SecurityException( "You need MANAGE_USERS permission to: check isUserUnlockingOrUnlocked"); if (callingUserId == userId || isSameProfileGroupNoChecks(callingUserId, userId) || hasManageUsersPermission()) { return; } if (ActivityManager.checkComponentPermission(Manifest.permission.INTERACT_ACROSS_USERS, Binder.getCallingUid(), -1, true) != PackageManager.PERMISSION_GRANTED) { throw new SecurityException("You need INTERACT_ACROSS_USERS or MANAGE_USERS permission " + "to: check " + name); } return mLocalService.isUserUnlockingOrUnlocked(userId); } @Override Loading Loading @@ -3641,6 +3660,14 @@ public class UserManagerService extends IUserManager.Stub { || (state == UserState.STATE_RUNNING_UNLOCKED); } } @Override public boolean isUserUnlocked(int userId) { synchronized (mUserStates) { int state = mUserStates.get(userId, -1); return state == UserState.STATE_RUNNING_UNLOCKED; } } } /* Remove all the users except of the system one. */ Loading