1
我正在研究與安全性有關的應用程序。即使用戶將設備重置爲出廠設置,也不能刪除應用程序。要做到這一點,設備必須紮根。然而,當我試圖獲得該位置作爲root
用戶我得到這個錯誤在Android Jellybean (4.1.1)
了當應用程序以超級用戶身份運行時,GPS不工作
uncaughtException # Exception found!!
java.lang.SecurityException: invalid UID 0
at android.os.Parcel.readException(Parcel.java:1379)
at android.location.ILocationManager$Stub$Proxy.requestLocationUpdates(ILocationManager.java:659)
at android.location.LocationManager._requestLocationUpdates(LocationManager.java:664)
at android.location.LocationManager.requestLocationUpdates(LocationManager.java:486)
當我看着Android源代碼,我看到谷歌已經在LocationManagerService.java
here
增加了額外的安全性在requestLocationUpdates
函數調用
checkPackageName(Binder.getCallingUid(), packageName);
這是checkPackageName
功能
private void checkPackageName(int uid, String packageName) {
if (packageName == null) {
throw new SecurityException("packageName cannot be null");
}
String[] packages = mPackageManager.getPackagesForUid(uid);
if (packages == null) {
throw new SecurityException("invalid UID " + uid);
}
for (String pkg : packages) {
if (packageName.equals(pkg)) return;
}
throw new SecurityException("invalid package name");
}
任何想法如何修復此問題?如果你有類似的問題如何解決這個問題,請諮詢。謝謝!