Merge "New @SystemApi: UserManager.getVisibleUsers()"

This commit is contained in:
Felipe Leme
2022-08-24 20:06:21 +00:00
committed by Android (Google) Code Review
4 changed files with 44 additions and 1 deletions

View File

@@ -129,6 +129,7 @@ interface IUserManager {
boolean isUserRunning(int userId);
boolean isUserForeground(int userId);
boolean isUserVisible(int userId);
List<UserHandle> getVisibleUsers();
boolean isUserNameSet(int userId);
boolean hasRestrictedProfiles(int userId);
boolean requestQuietModeEnabled(String callingPackage, boolean enableQuietMode, int userId, in IntentSender target, int flags);

View File

@@ -2885,6 +2885,21 @@ public class UserManager {
}
}
/**
* Gets the visible users (as defined by {@link #isUserVisible()}.
*
* @return visible users at the moment.
*/
@RequiresPermission(anyOf = {Manifest.permission.MANAGE_USERS,
Manifest.permission.INTERACT_ACROSS_USERS})
public @NonNull List<UserHandle> getVisibleUsers() {
try {
return mService.getVisibleUsers();
} catch (RemoteException re) {
throw re.rethrowFromSystemServer();
}
}
/**
* Return whether the context user is running in an "unlocked" state.
* <p>