天天看點

Android sharedUserId

android:sharedUserId
           
The name of a Linux user ID that will be shared with other applications. 
           
By default, Android assigns each application its own unique user ID.
           
However, if this attribute is set to the same value for two or more 
           
applications,they will all share the same ID — provided that they are 
           
also signed by the same certificate. Application with the same user ID 
           
can access each other's data and, if desired, run in the same process.
           

android:sharedUserId = "android.uid.system"首先加入android:sharedUserId="android.uid.system"這個屬性。通過Shared User id,擁有同一個User id的多個APK可以配置成運作在同一個程序中。那麼把程式的UID配成android.uid.system,也就是要讓程式運作在系統程序中,這樣就有權限來修改系統xx了。 隻是加入UID還不夠,如果這時候安裝APK的話發現無法安裝,提示簽名不符,原因是程式想要運作在系統程序中還要有目标系統的platform key,就是上面第二個方法提到的platform.pk8和platform.x509.pem兩個檔案。用這兩個key簽名後apk才真正可以放入系統程序中。第一個方法中加入LOCAL_CERTIFICATE := platform其實就是用這兩個key來簽名。

繼續閱讀