谷歌4.4新增对外置sd读写权限的说明

因为谷歌考虑安全问题所以对于SD卡的权限作了限制.
根据该版本的API改进,应用程序将不能再往SD卡中写入文件。在Android开发者网站的 “外部存储技术信息”文档中描述道: 

WRITE_EXTERNAL_STORAGE只为设备上的主要外部存储授予写权限,应用程序无法将数据写入二级外部存储设备 
,除非综合权限指定了应用程序的包目录

怎么解决呢?

第一是:

修改源码system/vold/Volume.cpp 

if (primaryStorage) {
            // Special case the primary SD card.
            // For this we grant write access to the SDCARD_RW group.
            gid = AID_SDCARD_RW;
        } else {
            // For secondary external storage we keep things locked up.
            gid = AID_MEDIA_RW;
        }
改为

if (1) {
            // Special case the primary SD card.
            // For this we grant write access to the SDCARD_RW group.
            gid = AID_SDCARD_RW;
        } else {
            // For secondary external storage we keep things locked up.
            gid = AID_MEDIA_RW;
        }

方法二:

在android/out/target/product/wing-k70/system/etc/permissions目录下的platform.xml

如果没有源码的话,就下个ES,修改同样是修改system/etc/permissions目录下的platform.xml


<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
      <group gid="sdcard_rw" />
    </permission>
改为
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
      <group gid="sdcard_rw" />
      <group gid="media_rw" />
    </permission>

保存,重启。所有的应用都能够打开extsd卡上文件并修改保存,pptv也能把下载地址设置为extsd。另外360手机助手也能直接操作extsd卡上的内容进行删除。

在到/mnt下ll,如图:

extsd的权限已改为777;

猜你喜欢

转载自blog.csdn.net/lzpdz/article/details/54630054