Android 预置APK的权限授予

Android 预置APK的权限授予

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

在private void grantPermissionsLPw(PackageParser.Package pkg, boolean replace, String packageOfInterest) {

函数中添加需要豁免的运行时权限

if(pkg.packageName.equals("com.android.apitest")) {
    final int permsSize = pkg.requestedPermissions.size();
    for (int i=0; i>>>>>>>>>>perm&package grant permission " + name + " to package " + pkg.packageName);
            changedInstallPermission = true;
        }
    }
}

为需要过滤的列表,添加白名单

public static String[] preApp = {
        "com.android.captiveportallogin",
        "com.android.certinstaller",
        "com.android.deskclock",
        "com.android.development",
        "com.android.documentsui",
        "com.android.providers.downloads.ui",
    };

if(Arrays.asList(PreInstalledApp.preApp).contains(pkg.packageName)) {
    final int permsSize = pkg.requestedPermissions.size();
    for (int i=0; i>>>>>>>>>>perm&package grant permission " + name + " to package " + pkg.packageName);
            changedInstallPermission = true;
        }
    }
}

相关链接
http://blog.csdn.net/q1183345443/article/details/53005114
http://blog.csdn.net/blank557/article/details/51734541
http://blog.csdn.net/zy00000000001/article/details/51956883

你可能感兴趣的:(Android权限)