1、通過源碼可以看到,UserHandle包含三種概念useriduidappid userid 就是有多少個實際的用戶,即手機里的主機訪客等多用戶 uid 上文講過他跟應用進程相關,除了shareduid的應用,每個用戶的每個應用的uid不一樣的 appid 跟app相關,包名相同的appid都一樣,即使是不同用戶。
2、在main方法的執(zhí)行過程中,會調(diào)用run方法,run方法中進一步調(diào)用onRun,最后在runForceStop方法中實現(xiàn)終止包名對應進程的具體邏輯值得注意的是,當未指定userId時,系統(tǒng)將默認使用UserHandleUSER_ALL,即處理所有用戶空間下的包名在力推stop命令的執(zhí)行過程中,進程控制中心ActivityManager通過A。
3、if userId == UserHandleUSER_ALL callingUid == ProcessSHELL_UID else 向AMS查詢符合條件的receiver registeredReceivers = mReceiverResolverqueryIntentintent, resolvedType, false, userId final boolean replacePending = intentgetFlags。
4、UserHandlegetUserIdBindergetCallingUid, processName,r == null ? 1 ,crashInfoexceptionClassName,crashInfoexceptionMessage,crashInfothrowFileName,crashInfothrowLineNumberaddErrorToDropBoxquotcrashquot, r, processName, null, null, null, null, null, crashInfo。
5、拿到AndroidManifestxml 中的sharedUserId, 一般情況下有“”等信息 String str = sagetNonConfigurationString , 0while type = parsernext != XmlPullParserEND_DOCUMENT type != XmlPullParserEND_TAG。
轉載請注明來自夕逆IT,本文標題:《梳理uid、userid及UserHandle概念》

還沒有評論,來說兩句吧...