Loading core/java/android/os/Process.java +8 −0 Original line number Diff line number Diff line Loading @@ -573,6 +573,14 @@ public class Process { return UserHandle.of(UserHandle.getUserId(myUid())); } /** * Returns whether the given uid belongs to a system core component or not. * @hide */ public static boolean isCoreUid(int uid) { return UserHandle.isCore(uid); } /** * Returns whether the given uid belongs to an application. * @param uid A kernel uid. Loading core/java/android/os/UserHandle.java +22 −2 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -146,6 +153,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. Loading services/core/java/com/android/server/ForceAppStandbyTracker.java +3 −3 Original line number Diff line number Diff line Loading @@ -504,7 +504,7 @@ public class ForceAppStandbyTracker { */ void uidToForeground(int uid) { synchronized (mLock) { if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { return; } // TODO This can be optimized by calling indexOfKey and sharing the index for get and Loading @@ -522,7 +522,7 @@ public class ForceAppStandbyTracker { */ void uidToBackground(int uid, boolean remove) { synchronized (mLock) { if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { return; } // TODO This can be optimized by calling indexOfKey and sharing the index for get and Loading Loading @@ -864,7 +864,7 @@ public class ForceAppStandbyTracker { * Note clients normally shouldn't need to access it. It's only for dumpsys. */ public boolean isInForeground(int uid) { if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { return true; } synchronized (mLock) { Loading services/core/java/com/android/server/am/ActivityManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -428,7 +428,6 @@ import com.android.server.SystemServiceManager; import com.android.server.ThreadPriorityBooster; import com.android.server.Watchdog; import com.android.server.am.ActivityStack.ActivityState; import com.android.server.am.EventLogTags; import com.android.server.am.proto.ActivityManagerServiceProto; import com.android.server.am.proto.BroadcastProto; import com.android.server.am.proto.GrantUriProto; Loading Loading @@ -8849,7 +8848,7 @@ public class ActivityManagerService extends IActivityManager.Stub case AppOpsManager.MODE_ALLOWED: // If force-background-check is enabled, restrict all apps that aren't whitelisted. if (mForceBackgroundCheck && UserHandle.isApp(uid) && !UserHandle.isCore(uid) && !isOnDeviceIdleWhitelistLocked(uid)) { if (DEBUG_BACKGROUND_CHECK) { Slog.i(TAG, "Force background check: " + Loading Loading @@ -24120,7 +24119,7 @@ public class ActivityManagerService extends IActivityManager.Stub final int size = mActiveUids.size(); for (int i = 0; i < size; i++) { final int uid = mActiveUids.keyAt(i); if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { continue; } final UidRecord uidRec = mActiveUids.valueAt(i); Loading
core/java/android/os/Process.java +8 −0 Original line number Diff line number Diff line Loading @@ -573,6 +573,14 @@ public class Process { return UserHandle.of(UserHandle.getUserId(myUid())); } /** * Returns whether the given uid belongs to a system core component or not. * @hide */ public static boolean isCoreUid(int uid) { return UserHandle.isCore(uid); } /** * Returns whether the given uid belongs to an application. * @param uid A kernel uid. Loading
core/java/android/os/UserHandle.java +22 −2 Original line number Diff line number Diff line Loading @@ -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); Loading @@ -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); Loading @@ -146,6 +153,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. Loading
services/core/java/com/android/server/ForceAppStandbyTracker.java +3 −3 Original line number Diff line number Diff line Loading @@ -504,7 +504,7 @@ public class ForceAppStandbyTracker { */ void uidToForeground(int uid) { synchronized (mLock) { if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { return; } // TODO This can be optimized by calling indexOfKey and sharing the index for get and Loading @@ -522,7 +522,7 @@ public class ForceAppStandbyTracker { */ void uidToBackground(int uid, boolean remove) { synchronized (mLock) { if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { return; } // TODO This can be optimized by calling indexOfKey and sharing the index for get and Loading Loading @@ -864,7 +864,7 @@ public class ForceAppStandbyTracker { * Note clients normally shouldn't need to access it. It's only for dumpsys. */ public boolean isInForeground(int uid) { if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { return true; } synchronized (mLock) { Loading
services/core/java/com/android/server/am/ActivityManagerService.java +2 −3 Original line number Diff line number Diff line Loading @@ -428,7 +428,6 @@ import com.android.server.SystemServiceManager; import com.android.server.ThreadPriorityBooster; import com.android.server.Watchdog; import com.android.server.am.ActivityStack.ActivityState; import com.android.server.am.EventLogTags; import com.android.server.am.proto.ActivityManagerServiceProto; import com.android.server.am.proto.BroadcastProto; import com.android.server.am.proto.GrantUriProto; Loading Loading @@ -8849,7 +8848,7 @@ public class ActivityManagerService extends IActivityManager.Stub case AppOpsManager.MODE_ALLOWED: // If force-background-check is enabled, restrict all apps that aren't whitelisted. if (mForceBackgroundCheck && UserHandle.isApp(uid) && !UserHandle.isCore(uid) && !isOnDeviceIdleWhitelistLocked(uid)) { if (DEBUG_BACKGROUND_CHECK) { Slog.i(TAG, "Force background check: " + Loading Loading @@ -24120,7 +24119,7 @@ public class ActivityManagerService extends IActivityManager.Stub final int size = mActiveUids.size(); for (int i = 0; i < size; i++) { final int uid = mActiveUids.keyAt(i); if (!UserHandle.isApp(uid)) { if (UserHandle.isCore(uid)) { continue; } final UidRecord uidRec = mActiveUids.valueAt(i);