RK3288 Android 10 系统开发[4] - 提供 app 默认权限
禁用旧版本SDK弹框
如果在Android10系统上安装旧版本的app,会提示以下信息。
此应用专为旧版 Android 打造,因此可能无法正常运行。请尝试检查更新或与开发者联系。
为了去掉这个弹框提示,需要添加以下修改, 将 onStartActivity
函数中的 showDeprecatedTargetDialogIfNeeded
禁用。
--- a/services/core/java/com/android/server/wm/AppWarnings.java
+++ b/services/core/java/com/android/server/wm/AppWarnings.java
@@ -166,7 +166,8 @@ class AppWarnings {
public void onStartActivity(ActivityRecord r) {
showUnsupportedCompileSdkDialogIfNeeded(r);
showUnsupportedDisplaySizeDialogIfNeeded(r);
- showDeprecatedTargetDialogIfNeeded(r);
+ //showDeprecatedTargetDialogIfNeeded(r);
}
/**
安装app默认提供权限
对于安装app是自动提供的权限,可以添加以下修改。 在 PackageManagerService.java
文件中添加白名单.
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -1872,7 +1872,8 @@ public class PackageManagerService extends IPackageManager.Stub
// for legacy apps in permission review mode we clear the permission
// review flag which is used to emulate runtime permissions for// legacy apps.
- if (grantPermissions) {
+ if (grantPermissions || res.name.contains("com.customPackage") || res.name.contains("com.baidu.input")) {
final int callingUid = Binder.getCallingUid();
mPermissionManager.grantRequestedRuntimePermissions(
res.pkg, res.newUsers, grantedPermissions, callingUid,
运行时权限
对于运行时的权限,在Android10里目前只找到对指定app进行权限配置的方法。以百度输入法为例,添加权限如下。
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -744,6 +744,16 @@ public final class DefaultPermissionGrantPolicy {
grantPermissionsToSystemPackage(systemCaptionsServicePackageName, userId,
MICROPHONE_PERMISSIONS);
}
+
+ PackageInfo mBaiduPackageInfo = getPackageInfo("com.baidu.input");
+ if (mBaiduPackageInfo != null && doesPackageSupportRuntimePermissions(mBaiduPackageInfo)) {
+ grantPermissionsToPackage(mBaiduPackageInfo, userId, false, true, true, STORAGE_PERMISSIONS);
+ grantPermissionsToPackage(mBaiduPackageInfo, userId, false, true, true, ALWAYS_LOCATION_PERMISSIONS);
+ grantPermissionsToPackage(mBaiduPackageInfo, userId, false, true, true, PHONE_PERMISSIONS);
+ grantPermissionsToPackage(mBaiduPackageInfo, userId, false, true, true, CONTACTS_PERMISSIONS);
+ }
}
private String getDefaultSystemHandlerActivityPackageForCategory(String category, int userId) {
参考
版权声明:本博客所有文章除特殊声明外,均采用 CC BY-NC 4.0 许可协议。转载请注明出处 litreily的博客!