关于android8.1实现多个app升级时的注意事项

关于android8.1实现多个app升级时的注意事项

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)) {
  • 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");

  • if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID)) {
  • if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID) && (callingUid != Process.SYSTEM_UID)) {
    mAppOps.checkPackage(callingUid, callerPackageName);
    }

欢迎观看我发布的各个课程: https://edu.51cto.com/lecturer/8896847.html
或者
我的3折优惠的专题组合课程:
https://edu.51cto.com/topic/2362.html

关于android8.1实现多个app升级时的注意事项

上一篇:android设置程序开机自启动


下一篇:HTTP请求报文头属性