您的位置:首页 > 教育 > 培训 > 访问网页的方法_网站建设电话销售_seo交流_个人网站免费制作平台

访问网页的方法_网站建设电话销售_seo交流_个人网站免费制作平台

2025/2/23 13:01:55 来源:https://blog.csdn.net/qq_46687516/article/details/143774616  浏览:    关键词:访问网页的方法_网站建设电话销售_seo交流_个人网站免费制作平台
访问网页的方法_网站建设电话销售_seo交流_个人网站免费制作平台

 GRANT_INSTALL就是在安装apk时已经给予了所有申请权限,所以运行时给与权限改为安装时给予权限就可以了。
解决方案如下:
PermissionManagerService.java文件中restorePermissionState方法中将应用权限设置为安装权限

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

final String perm = bp.getName();
                boolean allowedSig = false;
                int grant = GRANT_DENIED;

                // Keep track of app op permissions.
                if (bp.isAppOp()) {
                    mSettings.addAppOpPackage(perm, pkg.packageName);
                }

public class PermissionManagerService {
 if (bp.isNormal()) {
                    // For all apps normal permissions are install time ones.
                    grant = GRANT_INSTALL;
                } else if (bp.isRuntime()) {
                    if (origPermissions.hasInstallPermission(bp.getName())
                            || upgradedActivityRecognitionPermission != null) {
                        // Before Q we represented some runtime permissions as install permissions,
                        // in Q we cannot do this anymore. Hence upgrade them all.
                        grant = GRANT_UPGRADE;
                    } else {
                        // For modern apps keep runtime permissions unchanged.
+                        //grant = GRANT_RUNTIME;
+                         grant = GRANT_INSTALL;
                    }
                } else if (bp.isSignature()) {
                    // For all apps signature permissions are install time ones.
                         // Before Q we represented some runtime permissions as install permissions,
                         // in Q we cannot do this anymore. Hence upgrade them all.
-                        grant = GRANT_UPGRADE;
+                        grant = GRANT_INSTALL;
                     } else {
                         // For modern apps keep runtime permissions unchanged.
                         //grant = GRANT_RUNTIME;
@@ -1179,7 +1179,7 @@ public class PermissionManagerService {
                             // to the platform (note: need to only do this when
                             // updating the platform).
                             if (!isNewPlatformPermissionForPackage(perm, pkg)) {
-                                grant = GRANT_DENIED;
+                                grant = GRANT_INSTALL;
                             }
                         }
                     }

另外,此修改方法只适用于安卓10,或者安卓11 R版本修改,也是行的通的。

请查阅下面的参考修改: 

Android R版本默认允许运行时安装权限-CSDN博客

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com