本文共 1647 字,大约阅读时间需要 5 分钟。
android新的版本,packagemanager对app安装有一定的限制,就是除了shell和root用户外,其他用户的进程不允许安装除了系统用户(system ui)以外的app。也就是例如system用户不允许安装uid为7000的app。
所以,如果你想通过一个appupgrade(一个system用户的进程)专门去进行多个不用用户的应用进行差分升级,那么需要去掉此限制。
修改如下:diff --git a/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java b/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java
index 94f7577..53eea02 100644--- a/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java+++ b/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java@@ -438,7 +438,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub { throw new SecurityException("User restriction prevents installing");}if ((callingUid == Process.SHELL_UID) || (callingUid == Process.ROOT_UID) || (callingUid == Process.SYSTEM_UID)) {
params.installFlags |= PackageManager.INSTALL_FROM_ADB;} else {
@@ -737,7 +737,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {
IntentSender statusReceiver, int userId) throws RemoteException { final int callingUid = Binder.getCallingUid();mPm.enforceCrossUserPermission(callingUid, userId, true, true, "uninstall");欢迎观看我发布的各个课程:
或者我的3折优惠的专题组合课程:转载于:https://blog.51cto.com/8906847/2397612