Loading core/java/android/os/UserManager.java +26 −6 Original line number Original line Diff line number Diff line Loading @@ -1848,7 +1848,7 @@ public class UserManager { Manifest.permission.MANAGE_USERS}, // Can be INTERACT_ACROSS_USERS instead. Manifest.permission.MANAGE_USERS}, // Can be INTERACT_ACROSS_USERS instead. conditional = true) conditional = true) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UserHandleAware() @UserHandleAware public boolean canSwitchUsers() { public boolean canSwitchUsers() { boolean allowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt( boolean allowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt( mContext.getContentResolver(), mContext.getContentResolver(), Loading Loading @@ -1929,8 +1929,13 @@ public class UserManager { * Returns the userId for the context user. * Returns the userId for the context user. * * * @return the userId of the context user. * @return the userId of the context user. * * @deprecated To get the <em>calling</em> user, use {@link UserHandle#myUserId()}. * To get the <em>context</em> user, get it directly from the context. * * @hide * @hide */ */ @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.TIRAMISU) @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.TIRAMISU) // *** Do NOT use this in UserManager. Instead always use mUserId. *** // *** Do NOT use this in UserManager. Instead always use mUserId. *** Loading @@ -1938,6 +1943,21 @@ public class UserManager { return getContextUserIfAppropriate(); return getContextUserIfAppropriate(); } } /** * Returns the userId for the user that this process is running under * (<em>not</em> the context user). * * @return the userId of <em>this process</em>. * * @deprecated Use {@link UserHandle#myUserId()} * @hide */ @Deprecated // NOT @UserHandleAware public @UserIdInt int getProcessUserId() { return UserHandle.myUserId(); } /** /** * @return the user type of the context user. * @return the user type of the context user. * @hide * @hide Loading Loading @@ -2012,7 +2032,7 @@ public class UserManager { return false; return false; } } // Caution: This is NOT @UserHandleAware (because mContext is getApplicationContext and // Caution: This is NOT @UserHandleAware (because mContext is getApplicationContext and // holds a different userId), but for R+ it returns false, so it doesn't matter anyway. // can hold a different userId), but for R+ it returns false, so it doesn't matter anyway. return mContext.getPackageManager() return mContext.getPackageManager() .isPackageAvailable("com.coffeestainstudios.goatsimulator"); .isPackageAvailable("com.coffeestainstudios.goatsimulator"); } } Loading Loading @@ -2447,7 +2467,7 @@ public class UserManager { */ */ @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, Manifest.permission.CREATE_USERS}) Manifest.permission.CREATE_USERS}) @UserHandleAware() @UserHandleAware public boolean isEphemeralUser() { public boolean isEphemeralUser() { return isUserEphemeral(mUserId); return isUserEphemeral(mUserId); } } Loading Loading @@ -3315,7 +3335,7 @@ public class UserManager { @TestApi @TestApi @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, Manifest.permission.CREATE_USERS}) Manifest.permission.CREATE_USERS}) @UserHandleAware() @UserHandleAware public @Nullable UserInfo createRestrictedProfile(@Nullable String name) { public @Nullable UserInfo createRestrictedProfile(@Nullable String name) { try { try { final int parentUserId = mUserId; final int parentUserId = mUserId; Loading Loading @@ -4605,7 +4625,7 @@ public class UserManager { android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group }) }) @UserHandleAware() @UserHandleAware public boolean isUserSwitcherEnabled() { public boolean isUserSwitcherEnabled() { return isUserSwitcherEnabled(true); return isUserSwitcherEnabled(true); } } Loading @@ -4622,7 +4642,7 @@ public class UserManager { android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group }) }) @UserHandleAware() @UserHandleAware public boolean isUserSwitcherEnabled(boolean showEvenIfNotActionable) { public boolean isUserSwitcherEnabled(boolean showEvenIfNotActionable) { if (!supportsMultipleUsers()) { if (!supportsMultipleUsers()) { return false; return false; Loading Loading
core/java/android/os/UserManager.java +26 −6 Original line number Original line Diff line number Diff line Loading @@ -1848,7 +1848,7 @@ public class UserManager { Manifest.permission.MANAGE_USERS}, // Can be INTERACT_ACROSS_USERS instead. Manifest.permission.MANAGE_USERS}, // Can be INTERACT_ACROSS_USERS instead. conditional = true) conditional = true) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) @UserHandleAware() @UserHandleAware public boolean canSwitchUsers() { public boolean canSwitchUsers() { boolean allowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt( boolean allowUserSwitchingWhenSystemUserLocked = Settings.Global.getInt( mContext.getContentResolver(), mContext.getContentResolver(), Loading Loading @@ -1929,8 +1929,13 @@ public class UserManager { * Returns the userId for the context user. * Returns the userId for the context user. * * * @return the userId of the context user. * @return the userId of the context user. * * @deprecated To get the <em>calling</em> user, use {@link UserHandle#myUserId()}. * To get the <em>context</em> user, get it directly from the context. * * @hide * @hide */ */ @Deprecated @UnsupportedAppUsage @UnsupportedAppUsage @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.TIRAMISU) @UserHandleAware(enabledSinceTargetSdkVersion = Build.VERSION_CODES.TIRAMISU) // *** Do NOT use this in UserManager. Instead always use mUserId. *** // *** Do NOT use this in UserManager. Instead always use mUserId. *** Loading @@ -1938,6 +1943,21 @@ public class UserManager { return getContextUserIfAppropriate(); return getContextUserIfAppropriate(); } } /** * Returns the userId for the user that this process is running under * (<em>not</em> the context user). * * @return the userId of <em>this process</em>. * * @deprecated Use {@link UserHandle#myUserId()} * @hide */ @Deprecated // NOT @UserHandleAware public @UserIdInt int getProcessUserId() { return UserHandle.myUserId(); } /** /** * @return the user type of the context user. * @return the user type of the context user. * @hide * @hide Loading Loading @@ -2012,7 +2032,7 @@ public class UserManager { return false; return false; } } // Caution: This is NOT @UserHandleAware (because mContext is getApplicationContext and // Caution: This is NOT @UserHandleAware (because mContext is getApplicationContext and // holds a different userId), but for R+ it returns false, so it doesn't matter anyway. // can hold a different userId), but for R+ it returns false, so it doesn't matter anyway. return mContext.getPackageManager() return mContext.getPackageManager() .isPackageAvailable("com.coffeestainstudios.goatsimulator"); .isPackageAvailable("com.coffeestainstudios.goatsimulator"); } } Loading Loading @@ -2447,7 +2467,7 @@ public class UserManager { */ */ @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, Manifest.permission.CREATE_USERS}) Manifest.permission.CREATE_USERS}) @UserHandleAware() @UserHandleAware public boolean isEphemeralUser() { public boolean isEphemeralUser() { return isUserEphemeral(mUserId); return isUserEphemeral(mUserId); } } Loading Loading @@ -3315,7 +3335,7 @@ public class UserManager { @TestApi @TestApi @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, @RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS, Manifest.permission.CREATE_USERS}) Manifest.permission.CREATE_USERS}) @UserHandleAware() @UserHandleAware public @Nullable UserInfo createRestrictedProfile(@Nullable String name) { public @Nullable UserInfo createRestrictedProfile(@Nullable String name) { try { try { final int parentUserId = mUserId; final int parentUserId = mUserId; Loading Loading @@ -4605,7 +4625,7 @@ public class UserManager { android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group }) }) @UserHandleAware() @UserHandleAware public boolean isUserSwitcherEnabled() { public boolean isUserSwitcherEnabled() { return isUserSwitcherEnabled(true); return isUserSwitcherEnabled(true); } } Loading @@ -4622,7 +4642,7 @@ public class UserManager { android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.MANAGE_USERS, android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group android.Manifest.permission.CREATE_USERS // And INTERACT_ if diff profile group }) }) @UserHandleAware() @UserHandleAware public boolean isUserSwitcherEnabled(boolean showEvenIfNotActionable) { public boolean isUserSwitcherEnabled(boolean showEvenIfNotActionable) { if (!supportsMultipleUsers()) { if (!supportsMultipleUsers()) { return false; return false; Loading