美文网首页Framework
9.0 framework动态权限请求移除

9.0 framework动态权限请求移除

作者: l900 | 来源:发表于2019-07-08 10:13 被阅读0次

9.0Android 新增加了权限管理服务,对应的修改移动到permissionManagerservice.java中了

--- a/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java

+++ b/frameworks/base/services/core/java/com/android/server/pm/permission/PermissionManagerService.java

@@ -727,7 +727,7 @@ public class PermissionManagerService {

                 final String permName = pkg.requestedPermissions.get(i);

                 final BasePermission bp = mSettings.getPermissionLocked(permName);

                 final boolean appSupportsRuntimePermissions =

-                        pkg.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.M;

+                        pkg.applicationInfo.targetSdkVersion >= (Build.VERSION_CODES.P+1)  ;

                 if (DEBUG_INSTALL) {

                     Log.i(TAG, "Package " + pkg.packageName + " checking " + permName + ": " + bp);

@@ -1371,7 +1371,7 @@ public class PermissionManagerService {

                 | PackageManager.FLAG_PERMISSION_POLICY_FIXED;

         final boolean supportsRuntimePermissions = pkg.applicationInfo.targetSdkVersion

-                >= Build.VERSION_CODES.M;

+                >=(Build.VERSION_CODES.P+1)  ;

         final boolean instantApp = mPackageManagerInt.isInstantApp(pkg.packageName, userId);

@@ -1540,6 +1540,9 @@ public class PermissionManagerService {

         if (!sCtaManager.isCtaSupported()) {

             return false;

         }

+        if(pkg.packageName != null){//依照需求添加判断

+            return false;

+        }

         final boolean appSupportsRuntimePermissions = pkg.applicationInfo.targetSdkVersion

                 >= Build.VERSION_CODES.M;

         if (pkg.mSharedUserId != null) {

注意:对于apk编译的版本号比 P+1  还大的应用,仍然需要动态权限请求

(apk编译的版本号 build.gradle 中的compileSdkVersion 29) P+1 = 28  

解决方法      P+1 基础上在继续加大   

相关文章

网友评论

    本文标题:9.0 framework动态权限请求移除

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