1、通過源碼可以看到,UserHandle包含三種概念useriduidappid userid 就是有多少個實(shí)際的用戶,即手機(jī)里的主機(jī)訪客等多用戶 uid 上文講過他跟應(yīng)用進(jìn)程相關(guān),除了shareduid的應(yīng)用,每個用戶的每個應(yīng)用的uid不一樣的 appid 跟app相關(guān),包名相同的appid都一樣,即使是不同用戶。
2、在main方法的執(zhí)行過程中,會調(diào)用run方法,run方法中進(jìn)一步調(diào)用onRun,最后在runForceStop方法中實(shí)現(xiàn)終止包名對應(yīng)進(jìn)程的具體邏輯值得注意的是,當(dāng)未指定userId時,系統(tǒng)將默認(rèn)使用UserHandleUSER_ALL,即處理所有用戶空間下的包名在力推stop命令的執(zhí)行過程中,進(jìn)程控制中心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。
轉(zhuǎn)載請注明來自夕逆IT,本文標(biāo)題:《梳理uid、userid及UserHandle概念》

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