Android 的Process类包含以下定义(除其他外):
/**
* Defines the root UID.
*/
public static final int ROOT_UID = 0;
/**
* Defines the UID/GID under which system code runs.
*/
public static final int SYSTEM_UID = 1000;
/**
* Defines the UID/GID under which the telephony code runs.
*/
public static final int PHONE_UID = 1001;
这些框架值对应于uid、root和system用户radio的内核。在 Android 中,许多系统进程作为这三个uids 之一运行。
NotificationManagerService 用于isUidSystem()检查调用进程是否由这些用户之一拥有,如果是,则设置布尔值isSystemNotification(如果包名称以 开头,它也最终为真android.*)。
请注意,isSystemUid它不会直接将调用uid与上述值进行比较,而是首先通过 运行它UserHandle.getAppId(),它获取内核值并将其修改为UserHandle.PER_USER_RANGE,通常定义为 100000(即uid % PER_USER_RANGE)。这最终是 kernel 的最后五位数字uid,其中前两位对应userId于多用户设备。
因此,对于以 root 用户身份运行的进程和应用程序,uidand将为 0,并在这种情况下返回。只要 uid 来自作为or用户运行的调用者,它也会返回 true 。appIdisSystemUid()truesystemradio