diff options
| author | Makoto Onuki <omakoto@google.com> | 2018-01-23 12:33:56 -0800 |
|---|---|---|
| committer | Makoto Onuki <omakoto@google.com> | 2018-01-23 15:47:29 -0800 |
| commit | 9cc471ce76539ea24dc258d08778fa88e3eeaaae (patch) | |
| tree | 7c809541b681ad8f7b3f5b8b734a595dcc596623 /core/java/android/os/UserHandle.java | |
| parent | bab202f7cf96387f973cc9b040db29f061b0e07e (diff) | |
Fix wrong use if "!UserHandle.isApp()"
Turned out !UserHandle.isApp() doesn't mean "is system" because of isolated UIDs.
Bug: 72174012
Test: atest $ANDROID_BUILD_TOP/frameworks/base/services/tests/servicestests/src/com/android/server/ForceAppStandbyTrackerTest.java
Change-Id: Ibf6175d550ecc74677877c74db2473bf3f30132d
Diffstat (limited to 'core/java/android/os/UserHandle.java')
| -rw-r--r-- | core/java/android/os/UserHandle.java | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/core/java/android/os/UserHandle.java b/core/java/android/os/UserHandle.java index 6381b56a6503..5be72bc5c54b 100644 --- a/core/java/android/os/UserHandle.java +++ b/core/java/android/os/UserHandle.java @@ -126,7 +126,10 @@ public final class UserHandle implements Parcelable { return getAppId(uid1) == getAppId(uid2); } - /** @hide */ + /** + * Whether a UID is an "isolated" UID. + * @hide + */ public static boolean isIsolated(int uid) { if (uid > 0) { final int appId = getAppId(uid); @@ -136,7 +139,11 @@ public final class UserHandle implements Parcelable { } } - /** @hide */ + /** + * Whether a UID belongs to a regular app. *Note* "Not a regular app" does not mean + * "it's system", because of isolated UIDs. Use {@link #isCore} for that. + * @hide + */ public static boolean isApp(int uid) { if (uid > 0) { final int appId = getAppId(uid); @@ -147,6 +154,19 @@ public final class UserHandle implements Parcelable { } /** + * Whether a UID belongs to a system core component or not. + * @hide + */ + public static boolean isCore(int uid) { + if (uid > 0) { + final int appId = getAppId(uid); + return appId < Process.FIRST_APPLICATION_UID; + } else { + return false; + } + } + + /** * Returns the user for a given uid. * @param uid A uid for an application running in a particular user. * @return A {@link UserHandle} for that user. |
