diff options
| author | 2015-04-17 18:42:41 -0700 | |
|---|---|---|
| committer | 2015-04-17 18:52:26 -0700 | |
| commit | 5760e1786bcc2feac9d1c2c784520aa4d6cf8cb8 (patch) | |
| tree | 1507d077b90366e471dbc21c5e82ca3cd8d39137 | |
| parent | fedd63165d0cd852c129c3fa18a0849f5de9dfb1 (diff) | |
Add isSystemUser API
Bug: 20348316
Bug: 19945747
Change-Id: Ibb81f0b2fccec621e26e4543bf9f26ffddfafb15
| -rw-r--r-- | api/current.txt | 1 | ||||
| -rw-r--r-- | api/system-current.txt | 1 | ||||
| -rw-r--r-- | core/java/android/os/UserManager.java | 15 |
3 files changed, 15 insertions, 2 deletions
diff --git a/api/current.txt b/api/current.txt index 4375e6f4ff0e..d7359f8519aa 100644 --- a/api/current.txt +++ b/api/current.txt @@ -23650,6 +23650,7 @@ package android.os { method public android.os.Bundle getUserRestrictions(); method public android.os.Bundle getUserRestrictions(android.os.UserHandle); method public boolean hasUserRestriction(java.lang.String); + method public boolean isSystemUser(); method public boolean isUserAGoat(); method public boolean isUserRunning(android.os.UserHandle); method public boolean isUserRunningOrStopping(android.os.UserHandle); diff --git a/api/system-current.txt b/api/system-current.txt index 363967373791..02842a5f2094 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -25550,6 +25550,7 @@ package android.os { method public android.os.Bundle getUserRestrictions(android.os.UserHandle); method public boolean hasUserRestriction(java.lang.String); method public boolean isManagedProfile(); + method public boolean isSystemUser(); method public boolean isUserAGoat(); method public boolean isUserRunning(android.os.UserHandle); method public boolean isUserRunningOrStopping(android.os.UserHandle); diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java index b9e307fa24f9..44eb1edc47ea 100644 --- a/core/java/android/os/UserManager.java +++ b/core/java/android/os/UserManager.java @@ -466,9 +466,9 @@ public class UserManager { } /** - * Returns the user handle for the user that the calling process is running on. + * Returns the user handle for the user that this process is running under. * - * @return the user handle of the user making this call. + * @return the user handle of this process. * @hide */ public int getUserHandle() { @@ -505,6 +505,17 @@ public class UserManager { } /** + * Used to check if this process is running under the system user. The system user + * is the initial user that is implicitly created on first boot and hosts most of the + * system services. + * + * @return whether this process is running under the system user. + */ + public boolean isSystemUser() { + return UserHandle.myUserId() == UserHandle.USER_OWNER; + } + + /** * Used to check if the user making this call is linked to another user. Linked users may have * a reduced number of available apps, app restrictions and account restrictions. * @return whether the user making this call is a linked user |