[高通SDM450][Android9.0]CTA认证--Android6.0以下应用默认不授权

news/2024/11/16 4:26:50/

文章目录

    • 开发平台基本信息
    • 问题描述
    • 解决方法

开发平台基本信息

芯片: SDM450
版本: Android 9.0
kernel: msm-4.9

问题描述

设备在进行入网认证的时候,实验室要求应用在使用特殊权限的时候,需要告知用户,要用户授权才能使用相应的权限;而Android的动态申请权限是6.0才有的,也就是说,如果应用把sdk版本设置为6.0以下,那么应用则不需要动态申请权限就能默认获得AndroidManifest.xml里面配置的权限;这在入网实验室的不允许的,虽然低版本的应用不会申请授权,但是实验室要求默认不给低版本的应用授权,让用户在设置的应用中手动授权即可。所以,要解决这个问题,就是去掉限制Android6.0的这个条件,让所有版本的应用都需要动态申请权限。

解决方法

diff --git a/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java b/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java
index 95b1a3a8a6..a0712e25c9 100644
--- a/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java
+++ b/frameworks/base/services/core/java/com/android/server/pm/PackageInstallerService.java
@@ -426,6 +426,7 @@ public class PackageInstallerService extends IPackageInstaller.Stub {// caller.if (mContext.checkCallingOrSelfPermission(Manifest.permission.INSTALL_PACKAGES) !=PackageManager.PERMISSION_GRANTED) {
+                mAppOps = mContext.getSystemService(AppOpsManager.class);mAppOps.checkPackage(callingUid, installerPackageName);}diff --git a/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java b/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
index 3de4fc27b3..36b4f52fb9 100755
--- a/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -19548,8 +19548,7 @@ public class PackageManagerService extends IPackageManager.Stub// If permission review is enabled and this is a legacy app, mark the// permission as requiring a review as this is the initial state.int flags = 0;
-            if (mSettings.mPermissions.mPermissionReviewRequired
-                    && ps.pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
+            if (mSettings.mPermissions.mPermissionReviewRequired) {flags |= FLAG_PERMISSION_REVIEW_REQUIRED;}if (permissionsState.updatePermissionFlags(bp, userId, userSettableMask, flags)) {
diff --git 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
index c51a72406b..b203e3805a 100644
--- 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
@@ -716,8 +716,7 @@ public class PermissionManagerService {for (int i = 0; i < N; i++) {final String permName = pkg.requestedPermissions.get(i);final BasePermission bp = mSettings.getPermissionLocked(permName);
-                final boolean appSupportsRuntimePermissions =
-                        pkg.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.M;
+                final boolean appSupportsRuntimePermissions =false;if (DEBUG_INSTALL) {Log.i(TAG, "Package " + pkg.packageName + " checking " + permName + ": " + bp);
@@ -767,10 +766,7 @@ public class PermissionManagerService {// their permissions as always granted runtime ones since we need// to keep the review required permission flag per user while an// install permission's state is shared across all users.
-                    if (!appSupportsRuntimePermissions && !mSettings.mPermissionReviewRequired) {
-                        // For legacy apps dangerous permissions are install time ones.
-                        grant = GRANT_INSTALL;
-                    } else if (origPermissions.hasInstallPermission(bp.getName())) {
+                    if (origPermissions.hasInstallPermission(bp.getName())) {// For legacy apps that became modern, install becomes runtime.grant = GRANT_UPGRADE;} else if (isLegacySystemApp) {
@@ -1186,14 +1182,6 @@ public class PermissionManagerService {}}if (!allowed) {
-            if (!allowed
-                    && bp.isPre23()
-                    && pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
-                // If this was a previously normal/dangerous permission that got moved
-                // to a system permission as part of the runtime permission redesign, then
-                // we still want to blindly grant it to old apps.
-                allowed = true;
-            }if (!allowed && bp.isInstaller()&& pkg.packageName.equals(mPackageManagerInt.getKnownPackageName(PackageManagerInternal.PACKAGE_INSTALLER, UserHandle.USER_SYSTEM))) {
@@ -1256,9 +1244,9 @@ public class PermissionManagerService {}// Permission review applies only to apps not supporting the new permission model.
-        if (pkg.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.M) {
-            return false;
-        }
+        //if (pkg.applicationInfo.targetSdkVersion >= Build.VERSION_CODES.M) {
+        //    return false;
+        //}// Legacy apps have the permission and get user consent on launch.if (pkg == null || pkg.mExtras == null) {
@@ -1408,7 +1396,7 @@ public class PermissionManagerService {// to keep the review required permission flag per user while an// install permission's state is shared across all users.if (mSettings.mPermissionReviewRequired
-                && pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M
+                //&& pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M&& bp.isRuntime()) {return;}
@@ -1445,10 +1433,10 @@ public class PermissionManagerService {+ permName + " for package " + packageName);}-        if (pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
-            Slog.w(TAG, "Cannot grant runtime permission to a legacy app");
-            return;
-        }
+        //if (pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M) {
+        //    Slog.w(TAG, "Cannot grant runtime permission to a legacy app");
+        //    return;
+        //}final int result = permissionsState.grantRuntimePermission(bp, userId);switch (result) {
@@ -1529,7 +1517,7 @@ public class PermissionManagerService {// to keep the review required permission flag per user while an// install permission's state is shared across all users.if (mSettings.mPermissionReviewRequired
-                && pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M
+                //&& pkg.applicationInfo.targetSdkVersion < Build.VERSION_CODES.M&& bp.isRuntime()) {return;}
diff --git a/packages/apps/PackageInstaller/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java b/packages/apps/PackageInstaller/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
index aafce8df54..620a57a29b 100644
--- a/packages/apps/PackageInstaller/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
+++ b/packages/apps/PackageInstaller/src/com/android/packageinstaller/permission/model/AppPermissionGroup.java
@@ -209,8 +209,7 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>mUserHandle = userHandle;mPackageManager = mContext.getPackageManager();mPackageInfo = packageInfo;
-        mAppSupportsRuntimePermissions = packageInfo.applicationInfo
-                .targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1;
+        mAppSupportsRuntimePermissions = true;mIsEphemeralApp = packageInfo.applicationInfo.isInstantApp();mAppOps = context.getSystemService(AppOpsManager.class);mActivityManager = context.getSystemService(ActivityManager.class);
@@ -407,6 +406,8 @@ public final class AppPermissionGroup implements Comparable<AppPermissionGroup>} else {// Legacy apps cannot have a not granted permission but just in case.if (!permission.isGranted()) {
+                    mPackageManager.grantRuntimePermission(mPackageInfo.packageName,
+                         permission.getName(), mUserHandle);continue;}

http://www.ppmy.cn/news/724920.html

相关文章

高通SDM450 主屏mipi转EDP

主屏通过lt8911exb 将mipi信号转换成EDP信号输出&#xff0c;调试从大的方向上看&#xff0c;主要是两方面&#xff0c;一个是bootloader阶段的lt8911exb初始化&#xff0c;为了让现实过程更完整&#xff0c;需要在lk的display init之前就要将lt8911exb准备好.当lt8911exb准备好…

[高通SDM450][Android9.0]debug串口转通用串口

文章目录 开发平台基本信息问题描述解决方法debug口转普通串口补丁 开发平台基本信息 芯片: SDM450 版本: Android 9.0 kernel: msm-4.9 问题描述 由于硬件起初设计的时候&#xff0c;没有预留通用串口&#xff0c;而usb转串口又不是特别稳定&#xff0c;经常会挂死&#xf…

[高通SDM450][Android9.0]同一套代码兼容不同的emmc

文章目录 开发平台基本信息问题描述解决方法1. 如何计算userdata分区大小2. 兼容不同规格的emmc3.MTP模式显示异常 开发平台基本信息 芯片: SDM450 版本: Android 9.0 kernel: msm-4.9 问题描述 一款设备&#xff0c;经常会出现搭配不同内存的情况&#xff0c;比如216跟464&…

高通SDM450平台配置SPI0接口

一、查看原理图&#xff0c;需要将GPIO_0、GPIO_1、GPIO_2、GPIO_3配置成SPI接口 二、查看安SDM450平台的数据手册&#xff0c;文档号&#xff1a;80-PC173-1,查看相关的手册可知&#xff0c;GPIO_0、GPIO_1、GPIO_2、GPIO_3可以复用成SPI1&#xff0c; 三、查看高通的文档号&a…

高通SDM450平台的LDO 输出与电压调节

开始之前,首先我们要知道什么是LDO?有什么作用?LDO调试需要调哪些? 什么是LDO,有什么作用? LDO为 低压线性稳压器,高通平台有多路LDO电压输出,以SDM450 为例 共有 LDO1~LDO23 23路。用于给外设提供电源。 LDO需要调什么? LDO的调试主要 有 打开和关闭 LDO电压 和 …

GO中file文件操作

一、File文件操作 首先&#xff0c;file类是在os包中的&#xff0c;封装了底层的文件描述符和相关信息&#xff0c;同时封装了Read和Write的实现。 1、FileInfo接口 FileInfo接口中定义了File信息相关的方法。 type FileInfo interface {Name() string // base name …

C#(四十六)之基于流的文件操作(FileStream)

FileStream类属性和方法 属性 CanRead 指示当前文件流是否支持读取 CanWrite 指示当前文件流是否支持写入 CanSeek 指示当前文件流是否支持查找 IsAsync FileStream是同步打开还是异步打开 Length 流的长度&#xff08;字节数&#xff09; CanTimeOut 当前文件流是否可以…

【github】Github内置Visual Studio Code

打开内置VScode 1s.dev https://github1s.dev 对比 原始 https://github.com/vuejs/vue 内置Vscode https://github1s.dev/vuejs/vue