赞
踩
1.系统app
系统app的权限默认开启,大家应该都知道是修改DefaultPermissionGrantPolicy.java。
frameworks/base/services/core/java/com/android/server/pm/DefaultPermissionGrantPolicy.java
在grantDefaultSystemHandlerPermissions中可以看到
- // Camera
- Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
- PackageParser.Package cameraPackage = getDefaultSystemHandlerActivityPackageLPr(
- cameraIntent, userId);
- if (cameraPackage != null
- && doesPackageSupportRuntimePermissions(cameraPackage)) {
- grantRuntimePermissionsLPw(cameraPackage, CAMERA_PERMISSIONS, userId);
- grantRuntimePermissionsLPw(cameraPackage, MICROPHONE_PERMISSIONS, userId);
- grantRuntimePermissionsLPw(cameraPackage, STORAGE_PERMISSIONS, userId);
- }
从上面这段代码就可以看到Camera中默认打开了CAMERA_PERMISSIONS, MICROPHONE_PERMISSIONS, STORAGE_PERMISSIONS这三个Dangerous Permission。
2.第三方app
手动安装的第三方app的权限默认开启是修改PackageManagerService.java。
frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java
在grantPermissionsLPw函数中添加如下代码
- //Permissions for com.xxx.xxx
- if(pkg.packageName.contains("com.xxx.xxx")) {
- final int permsSize = pkg.requestedPermissions.size();
- for (int i=0; i<permsSize; i++) {
- final String name = pkg.requestedPermissions.get(i);
- final BasePermission bp = mSettings.mPermissions.get(name);
- if(null != bp && permissionsState.grantInstallPermission(bp) != PermissionsState.PERMISSION_OPERATION_FAILURE) {
- Slog.d(TAG, "zrx--- grant permission " + name + " to package " + pkg.packageName);
- changedInstallPermission = true;
- }
- }
- }
参考:
Android6.0 动态权限(Runtime Permission)_MyeDy的博客-CSDN博客_android runtime 权限
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。