Android T(13) The app is granted permissions by default

我的博客

对比Android11,frameworks\base\services\core\java\com\android\server\pm\permission文件夹下,多了个PermissionManagerServiceImpl.java.

有一部分关于权限的处理,移到了这个文件中.比如:restorePermissionState(...)

all app granted permissions by default
+++ b/frameworks/base/services/core/java/com/android/server/pm/permission/Permission.java
@@ -206,12 +206,18 @@ public final class Permission {
     }

     public boolean isNormal() {
-        return (mPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
-                == PermissionInfo.PROTECTION_NORMAL;
+        //add text
+        /*return (mPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
+                == PermissionInfo.PROTECTION_NORMAL;*/
+        return true;
+        //add text
     }
     public boolean isRuntime() {
-        return (mPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
-                == PermissionInfo.PROTECTION_DANGEROUS;
+        //add text
+        /*return (mPermissionInfo.protectionLevel & PermissionInfo.PROTECTION_MASK_BASE)
+                == PermissionInfo.PROTECTION_DANGEROUS;*/
+        return false;
+        //add text
     }
customer's app granted permissions by default
 /**
     * Restore the permission state for a package.
     *
     * <ul>
     *     <li>During boot the state gets restored from the disk</li>
     *     <li>During app update the state gets restored from the last version of the app</li>
     * </ul>
     *
     * @param pkg the package the permissions belong to
     * @param replace if the package is getting replaced (this might change the requested
     *                permissions of this package)
     * @param packageOfInterest If this is the name of {@code pkg} add extra logging
     * @param callback Result call back
     * @param filterUserId If not {@link UserHandle.USER_ALL}, only restore the permission state for
     *                     this particular user
     */
    private void restorePermissionState(@NonNull AndroidPackage pkg, boolean replace,
            @Nullable String packageOfInterest, @Nullable PermissionCallback callback,
            @UserIdInt int filterUserId) {
        
            ...
            else if (bp.isRuntime()) {
                    boolean hardRestricted = bp.isHardRestricted();
                    boolean softRestricted = bp.isSoftRestricted();
                ...
                if (wasChanged) {
                        updatedUserIds = ArrayUtils.appendInt(updatedUserIds, userId);
                    }
                    uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL, flags);
+                        //add text
+                        String packageName_t = pkg.getPackageName();
+                        if(packageName_t.equals("android.xx.xxxxx")){
+                            uidState.revokePermission(bp);//先撤销
+                            uidState.updatePermissionFlags(bp, MASK_PERMISSION_FLAGS_ALL, 0);//在更新
+                            updatedUserIds = ArrayUtils.appendInt(updatedUserIds, userId);
+                            if(uidState.grantPermission(bp)){
+                                changedInstallPermission = true;//让RunTime Permission 走 Install Permission 的路
+                            }
+                        }
+                        //add text
                     } else {
                         Slog.wtf(LOG_TAG, "Unknown permission protection " + bp.getProtection()
                                 + " for permission " + bp.getName());
                    ...
        }    
相关推荐
拭心4 小时前
Google 提供的 Android 端上大模型组件:MediaPipe LLM 介绍
android
带电的小王7 小时前
WhisperKit: Android 端测试 Whisper -- Android手机(Qualcomm GPU)部署音频大模型
android·智能手机·whisper·qualcomm
梦想平凡7 小时前
PHP 微信棋牌开发全解析:高级教程
android·数据库·oracle
元争栈道7 小时前
webview和H5来实现的android短视频(短剧)音视频播放依赖控件
android·音视频
阿甘知识库8 小时前
宝塔面板跨服务器数据同步教程:双机备份零停机
android·运维·服务器·备份·同步·宝塔面板·建站
元争栈道9 小时前
webview+H5来实现的android短视频(短剧)音视频播放依赖控件资源
android·音视频
MuYe9 小时前
Android Hook - 动态加载so库
android
居居飒10 小时前
Android学习(四)-Kotlin编程语言-for循环
android·学习·kotlin
Henry_He13 小时前
桌面列表小部件不能点击的问题分析
android
工程师老罗13 小时前
Android笔试面试题AI答之Android基础(1)
android