android

android 9.0 预装应用授权(未知来源权限)和非运行时权

2020-08-07  本文已影响0人  gale_小米

在这个目录下添加运行时权限

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();

}

}

上一篇下一篇

猜你喜欢

热点阅读