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());
                    ...
        }    
相关推荐
HerayChen15 分钟前
HbuildderX运行到手机或模拟器的Android App基座识别不到设备 mac
android·macos·智能手机
顾北川_野16 分钟前
Android 手机设备的OEM-unlock解锁 和 adb push文件
android·java
hairenjing112318 分钟前
在 Android 手机上从SD 卡恢复数据的 6 个有效应用程序
android·人工智能·windows·macos·智能手机
小黄人软件43 分钟前
android浏览器源码 可输入地址或关键词搜索 android studio 2024 可开发可改地址
android·ide·android studio
dj15402252031 小时前
group_concat配置影响程序出bug
android·bug
周全全1 小时前
MySQL报错解决:The user specified as a definer (‘root‘@‘%‘) does not exist
android·数据库·mysql
- 羊羊不超越 -2 小时前
App渠道来源追踪方案全面分析(iOS/Android/鸿蒙)
android·ios·harmonyos
wk灬丨3 小时前
Android Kotlin Flow 冷流 热流
android·kotlin·flow
千雅爸爸3 小时前
Android MVVM demo(使用DataBinding,LiveData,Fresco,RecyclerView,Room,ViewModel 完成)
android