diff options
4 files changed, 20 insertions, 22 deletions
diff --git a/core/java/android/os/IUserManager.aidl b/core/java/android/os/IUserManager.aidl index 427add19f14f..65c609308b63 100644 --- a/core/java/android/os/IUserManager.aidl +++ b/core/java/android/os/IUserManager.aidl @@ -85,4 +85,5 @@ interface IUserManager { boolean isDemoUser(int userId); UserInfo createProfileForUserEvenWhenDisallowed(in String name, int flags, int userHandle, in String[] disallowedPackages); + boolean isUserUnlockingOrUnlocked(int userId); } diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index c656b066a51d..bc5af81531d2 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -1094,10 +1094,8 @@ public class UserManager { /** {@hide} */ public boolean isUserUnlockingOrUnlocked(@UserIdInt int userId) { - // TODO Switch to using UMS internal isUserUnlockingOrUnlocked try { - return ActivityManagerNative.getDefault().isUserRunning(userId, - ActivityManager.FLAG_AND_UNLOCKING_OR_UNLOCKED); + return mService.isUserUnlockingOrUnlocked(userId); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java index 54c9afea5766..4819c0a23177 100644 --- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -64,6 +64,7 @@ import android.os.RemoteException; import android.os.SystemClock; import android.os.UserHandle; import android.os.UserManager; +import android.os.UserManagerInternal; import android.provider.Settings; import android.text.TextUtils; import android.text.TextUtils.SimpleStringSplitter; @@ -1301,14 +1302,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { private void updateServicesLocked(UserState userState) { Map<ComponentName, Service> componentNameToServiceMap = userState.mComponentNameToServiceMap; - boolean isUnlockingOrUnlocked; - final long identity = Binder.clearCallingIdentity(); - try { - isUnlockingOrUnlocked = mContext.getSystemService(UserManager.class) + boolean isUnlockingOrUnlocked = LocalServices.getService(UserManagerInternal.class) .isUserUnlockingOrUnlocked(userState.mUserId); - } finally { - Binder.restoreCallingIdentity(identity); - } for (int i = 0, count = userState.mInstalledServices.size(); i < count; i++) { AccessibilityServiceInfo installedService = userState.mInstalledServices.get(i); diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index c0de214c5833..6498b0ec0f76 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -673,12 +673,6 @@ public class UserManagerService extends IUserManager.Stub { public boolean isSameProfileGroup(int userId, int otherUserId) { if (userId == otherUserId) return true; checkManageUsersPermission("check if in the same profile group"); - synchronized (mPackagesLock) { - return isSameProfileGroupLP(userId, otherUserId); - } - } - - private boolean isSameProfileGroupLP(int userId, int otherUserId) { synchronized (mUsersLock) { UserInfo userInfo = getUserInfoLU(userId); if (userInfo == null || userInfo.profileGroupId == UserInfo.NO_PROFILE_GROUP_ID) { @@ -880,12 +874,10 @@ public class UserManagerService extends IUserManager.Stub { public boolean isManagedProfile(int userId) { int callingUserId = UserHandle.getCallingUserId(); if (callingUserId != userId && !hasManageUsersPermission()) { - synchronized (mPackagesLock) { - if (!isSameProfileGroupLP(callingUserId, userId)) { - throw new SecurityException( - "You need MANAGE_USERS permission to: check if specified user a " + - "managed profile outside your profile group"); - } + if (!isSameProfileGroup(callingUserId, userId)) { + throw new SecurityException( + "You need MANAGE_USERS permission to: check if specified user a " + + "managed profile outside your profile group"); } } synchronized (mUsersLock) { @@ -895,6 +887,18 @@ public class UserManagerService extends IUserManager.Stub { } @Override + public boolean isUserUnlockingOrUnlocked(int userId) { + int callingUserId = UserHandle.getCallingUserId(); + if (callingUserId != userId && !hasManageUsersPermission()) { + if (!isSameProfileGroup(callingUserId, userId)) { + throw new SecurityException( + "You need MANAGE_USERS permission to: check isUserUnlockingOrUnlocked"); + } + } + return mLocalService.isUserUnlockingOrUnlocked(userId); + } + + @Override public boolean isDemoUser(int userId) { int callingUserId = UserHandle.getCallingUserId(); if (callingUserId != userId && !hasManageUsersPermission()) { |