一、首先需要app的AndroidManifest.xml中添加如下请求读取和写入外部存储的权限: <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 二、修改源码使WRITE_EXTERNAL_STORAGE和READ_EXTERNAL_STORAGE映射到 media_rw 用户组: diff --git a/frameworks/base/data/etc/platform.xml b/frameworks/base/data/etc/platform.xml index 76247c2d7a..2246d70a13 100644 --- a/frameworks/base/data/etc/platform.xml +++ b/frameworks/base/data/etc/platform.xml @@ -131,8 +131,12 @@ is negligible (one tag with the permission) compared to the fragility as one can remove a built-in permission which no longer needs to be mapped to gids and break grant propagation. --> - <permission name="android.permission.READ_EXTERNAL_STORAGE" /> - <permission name="android.permission.WRITE_EXTERNAL_STORAGE" /> + <permission name="android.permission.READ_EXTERNAL_STORAGE" > + <group gid="media_rw" /> + </permission> + <permission name="android.permission.WRITE_EXTERNAL_STORAGE" > + <group gid="media_rw" /> + </permission> <!-- ================================================================== --> <!-- ================================================================== --> 三、全编译烧写测试验证即可。 |
|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )
GMT+8, 2024-11-22 09:33
Powered by Discuz! X3.4
© 2001-2013 Comsenz Inc.