/** * Generate a text representation of the uid, breaking out its individual * components -- user, app, isolated, etc. * @hide */publicstaticvoidformatUid(StringBuildersb,intuid){if(uid<Process.FIRST_APPLICATION_UID){sb.append(uid);}else{sb.append('u');sb.append(getUserId(uid));finalintappId=getAppId(uid);if(isIsolated(appId)){if(appId>Process.FIRST_ISOLATED_UID){sb.append('i');sb.append(appId-Process.FIRST_ISOLATED_UID);}else{sb.append("ai");sb.append(appId-Process.FIRST_APP_ZYGOTE_ISOLATED_UID);}}elseif(appId>=Process.FIRST_APPLICATION_UID){sb.append('a');sb.append(appId-Process.FIRST_APPLICATION_UID);}else{sb.append('s');sb.append(appId);}}}
部分常量
123456789101112131415161718192021222324
/** * Defines the start of a range of UIDs (and GIDs), going from this * number to {@link #LAST_APPLICATION_UID} that are reserved for assigning * to applications. */publicstaticfinalintFIRST_APPLICATION_UID=10000;/** * Last of application-specific UIDs starting at * {@link #FIRST_APPLICATION_UID}. */publicstaticfinalintLAST_APPLICATION_UID=19999;/** * First uid used for fully isolated sandboxed processes (with no permissions of their own) * @hide */@UnsupportedAppUsage@TestApipublicstaticfinalintFIRST_ISOLATED_UID=99000;/** * First uid used for fully isolated sandboxed processes spawned from an app zygote * @hide */@TestApipublicstaticfinalintFIRST_APP_ZYGOTE_ISOLATED_UID=90000;