android7.1 外置SD卡三方应用没有读写权限

车机上面会挂载SD卡和U盘,三方应用想要在外置存储中读写文件操作需要添加权限,系统修改如下:

/frameworks/base/services/core/java/com/android/server/pm/PackageManagerService.java

commit a25497c19f5eef9d0d113710492f7d66dbbb9702
Author: zhoujinyan [email protected]
Date: Mon May 18 14:52:25 2020 +0800

[frameworks]解决三方应用没有权限读写sd问题

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 66615a0…3f1f844 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
@@ -10177,7 +10177,8 @@ public class PackageManagerService extends IPackageManager.Stub {
case PermissionInfo.PROTECTION_SIGNATURE: {
// For all apps signature permissions are install time ones.
allowedSig = grantSignaturePermission(perm, pkg, bp, origPermissions);

  •                if (allowedSig) {
    
  •               //对所有应用放开android.permission.WRITE_MEDIA_STORAGE权限.add by zhoujinyan 20200518
    
  •                if (allowedSig || perm.equals("android.permission.WRITE_MEDIA_STORAGE")) {
                       grant = GRANT_INSTALL;
                   }
               } break;
    

你可能感兴趣的:(sd,android,java,开发语言)