summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorDianne Hackborn <hackbod@google.com>2012-10-24 15:22:21 -0700
committerDianne Hackborn <hackbod@google.com>2012-10-24 15:28:03 -0700
commitb26306ad5277097b3abb345112b24d9a142fb299 (patch)
treeaf68026638741f94744c10a7f04889ff4a167304 /core/java
parentcd668554417f089aa0ae013a29ab81864b4b4685 (diff)
downloadframeworks_base-b26306ad5277097b3abb345112b24d9a142fb299.zip
frameworks_base-b26306ad5277097b3abb345112b24d9a142fb299.tar.gz
frameworks_base-b26306ad5277097b3abb345112b24d9a142fb299.tar.bz2
Fix issue #7408647: Add getUserCount() API
Change-Id: Ib4e8e2300757e0941fae8fbc46c4323f5e2d7d6b
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/os/UserManager.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 898c766..d73f99a 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -122,7 +122,7 @@ public class UserManager {
* @param userHandle the user handle of the user whose information is being requested.
* @return the UserInfo object for a specific user.
* @hide
- * */
+ */
public UserInfo getUserInfo(int userHandle) {
try {
return mService.getUserInfo(userHandle);
@@ -134,10 +134,11 @@ public class UserManager {
/**
* Return the serial number for a user. This is a device-unique
- * number assigned to that user; if the user is deleted and new users
- * created, the new users will not be given the same serial number.
+ * number assigned to that user; if the user is deleted and then a new
+ * user created, the new users will not be given the same serial number.
* @param user The user whose serial number is to be retrieved.
- * @return The serial number of the given user.
+ * @return The serial number of the given user; returns -1 if the
+ * given UserHandle does not exist.
* @see #getUserForSerialNumber(long)
*/
public long getSerialNumberForUser(UserHandle user) {
@@ -179,6 +180,14 @@ public class UserManager {
}
/**
+ * Return the number of users currently created on the device.
+ */
+ public int getUserCount() {
+ List<UserInfo> users = getUsers();
+ return users != null ? users.size() : 1;
+ }
+
+ /**
* Returns information for all users on this device.
* Requires {@link android.Manifest.permission#MANAGE_USERS} permission.
* @return the list of users that were created.