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

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

作者: gale_小米 | 来源:发表于2020-08-07 17:13 被阅读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();

    }

    }

    相关文章

      网友评论

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

        本文链接:https://www.haomeiwen.com/subject/wyxqdktx.html