diff options
| author | 2025-01-16 12:27:43 -0800 | |
|---|---|---|
| committer | 2025-01-16 14:49:00 -0800 | |
| commit | 46dbc811de270741e8fc328ccee43d7777e291f4 (patch) | |
| tree | 243a753f46d497e1cadacf01ea70150548ace275 | |
| parent | 441143d1aa13f54144f12fa9d42801179eeee8e3 (diff) | |
getUserSwitchability correct permission
The documentation didn't match the permission requirement.
Bug: 390458180
Flag: android.multiuser.get_user_switchability_permission
Test: com.android.server.pm.UserManagerTest
Change-Id: I0a7a68d154e5dfdfeb5d2bddea07fb3b389a69d4
| -rw-r--r-- | core/java/android/content/pm/multiuser.aconfig | 10 | ||||
| -rw-r--r-- | services/core/java/com/android/server/pm/UserManagerService.java | 11 |
2 files changed, 20 insertions, 1 deletions
diff --git a/core/java/android/content/pm/multiuser.aconfig b/core/java/android/content/pm/multiuser.aconfig index 813208d7ff38..c9efdf173702 100644 --- a/core/java/android/content/pm/multiuser.aconfig +++ b/core/java/android/content/pm/multiuser.aconfig @@ -457,6 +457,16 @@ flag { } flag { + name: "get_user_switchability_permission" + namespace: "multiuser" + description: "Update permissions for getUserSwitchability" + bug: "390458180" + metadata { + purpose: PURPOSE_BUGFIX + } +} + +flag { name: "restrict_quiet_mode_credential_bug_fix_to_managed_profiles" namespace: "profile_experiences" description: "Use user states to check the state of quiet mode for managed profiles only" diff --git a/services/core/java/com/android/server/pm/UserManagerService.java b/services/core/java/com/android/server/pm/UserManagerService.java index b2b8aaf7dd2a..e7a5c1a58a00 100644 --- a/services/core/java/com/android/server/pm/UserManagerService.java +++ b/services/core/java/com/android/server/pm/UserManagerService.java @@ -2916,7 +2916,16 @@ public class UserManagerService extends IUserManager.Stub { * switchable. */ public @UserManager.UserSwitchabilityResult int getUserSwitchability(int userId) { - checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, "getUserSwitchability"); + if (Flags.getUserSwitchabilityPermission()) { + if (!hasManageUsersOrPermission(android.Manifest.permission.INTERACT_ACROSS_USERS)) { + throw new SecurityException( + "You need MANAGE_USERS or INTERACT_ACROSS_USERS permission to " + + "getUserSwitchability"); + } + } else { + checkManageOrInteractPermissionIfCallerInOtherProfileGroup(userId, + "getUserSwitchability"); + } final TimingsTraceAndSlog t = new TimingsTraceAndSlog(); t.traceBegin("getUserSwitchability-" + userId); |