android 9.0 预装应用授权(未知来源权限)和非运行时权
在这个目录下添加运行时权限
android/frameworks/base/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
PackageParser.Package package = getPackage("xxxx");
if(package != null){grantRuntimePermissions(wolexuePackage, CAMERA_PERMISSIONS, userId);}
可以在FallbackHome 里面给特定应用添加非运行时权限
private String []packages={"xxxxxx"};
private void allInstall(){
AppOpsManager mAppOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
try {
PackageManager pm = getPackageManager();
for (String packageName:packages) {
@SuppressLint("WrongConstant") ApplicationInfo ai = pm.getApplicationInfo(packageName, PackageManager.GET_ACTIVITIES);
Log.d("!!","!!" + ai.uid);
mAppOpsManager.setMode(AppOpsManager.OP_REQUEST_INSTALL_PACKAGES,
ai.uid, packageName,AppOpsManager.MODE_ALLOWED);
}
}catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}