Loading core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -31638,6 +31638,7 @@ package android.os { method public boolean isQuietModeEnabled(android.os.UserHandle); method public boolean isSystemUser(); method public boolean isUserAGoat(); method public boolean isUserForeground(); method @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.INTERACT_ACROSS_USERS"}, conditional=true) public boolean isUserRunning(android.os.UserHandle); method @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.INTERACT_ACROSS_USERS"}, conditional=true) public boolean isUserRunningOrStopping(android.os.UserHandle); method public boolean isUserUnlocked(); core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ interface IUserManager { boolean hasBadge(int userId); boolean isUserUnlocked(int userId); boolean isUserRunning(int userId); boolean isUserForeground(); boolean isUserNameSet(int userId); boolean hasRestrictedProfiles(); boolean requestQuietModeEnabled(String callingPackage, boolean enableQuietMode, int userId, in IntentSender target, int flags); Loading core/java/android/os/UserManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -2299,6 +2299,19 @@ public class UserManager { } } /** * Checks if the calling user is running on foreground. * * @return whether the calling user is running on foreground. */ public boolean isUserForeground() { try { return mService.isUserForeground(); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Return whether the calling user is running in an "unlocked" state. * <p> Loading services/core/java/com/android/server/pm/UserManagerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -1521,6 +1521,14 @@ public class UserManagerService extends IUserManager.Stub { return mLocalService.isUserRunning(userId); } @Override public boolean isUserForeground() { int callingUserId = Binder.getCallingUserHandle().getIdentifier(); int currentUser = Binder.withCleanCallingIdentity(() -> ActivityManager.getCurrentUser()); // TODO(b/179163496): should return true for profile users of the current user as well return currentUser == callingUserId; } @Override public String getUserName() { if (!hasManageUsersOrPermission(android.Manifest.permission.GET_ACCOUNTS_PRIVILEGED)) { Loading Loading
core/api/current.txt +1 −0 Original line number Diff line number Diff line Loading @@ -31638,6 +31638,7 @@ package android.os { method public boolean isQuietModeEnabled(android.os.UserHandle); method public boolean isSystemUser(); method public boolean isUserAGoat(); method public boolean isUserForeground(); method @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.INTERACT_ACROSS_USERS"}, conditional=true) public boolean isUserRunning(android.os.UserHandle); method @RequiresPermission(anyOf={"android.permission.MANAGE_USERS", "android.permission.INTERACT_ACROSS_USERS"}, conditional=true) public boolean isUserRunningOrStopping(android.os.UserHandle); method public boolean isUserUnlocked();
core/java/android/os/IUserManager.aidl +1 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,7 @@ interface IUserManager { boolean hasBadge(int userId); boolean isUserUnlocked(int userId); boolean isUserRunning(int userId); boolean isUserForeground(); boolean isUserNameSet(int userId); boolean hasRestrictedProfiles(); boolean requestQuietModeEnabled(String callingPackage, boolean enableQuietMode, int userId, in IntentSender target, int flags); Loading
core/java/android/os/UserManager.java +13 −0 Original line number Diff line number Diff line Loading @@ -2299,6 +2299,19 @@ public class UserManager { } } /** * Checks if the calling user is running on foreground. * * @return whether the calling user is running on foreground. */ public boolean isUserForeground() { try { return mService.isUserForeground(); } catch (RemoteException re) { throw re.rethrowFromSystemServer(); } } /** * Return whether the calling user is running in an "unlocked" state. * <p> Loading
services/core/java/com/android/server/pm/UserManagerService.java +8 −0 Original line number Diff line number Diff line Loading @@ -1521,6 +1521,14 @@ public class UserManagerService extends IUserManager.Stub { return mLocalService.isUserRunning(userId); } @Override public boolean isUserForeground() { int callingUserId = Binder.getCallingUserHandle().getIdentifier(); int currentUser = Binder.withCleanCallingIdentity(() -> ActivityManager.getCurrentUser()); // TODO(b/179163496): should return true for profile users of the current user as well return currentUser == callingUserId; } @Override public String getUserName() { if (!hasManageUsersOrPermission(android.Manifest.permission.GET_ACCOUNTS_PRIVILEGED)) { Loading