欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

添加APK白名单

程序员文章站 2022-05-18 20:25:33
...

b/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java

@@ -17793,6 +17793,17 @@ public class PackageManagerService extends IPackageManager.Stub
     String origPackage;
     String origPermission;
 }
+ //zw_add
+    private boolean isAllowInstall(String packName) {
+        boolean allowInstall = false;
+               
+         if(packName.equals("***packagename***") || packName.equals("***packagename***")){
+             return true;
+        }else{
+             return allowInstall;
+        }
+    }
+    //end

 /*
  * Install a non-existing package.
@@ -17806,6 +17817,13 @@ public class PackageManagerService extends 		IPackageManager.Stub
     String pkgName = pkg.packageName;

     if (DEBUG_INSTALL) Slog.d(TAG, "installNewPackageLI: " + pkg);
+               //zw_add
+        if(!isAllowInstall(pkgName)){
+            res.returnCode = PackageManager.INSTALL_FAILED_INVALID_APK;
+            return;
+        }
+        //end