USB drives mount but they are not visible to apps
fcatrin opened this issue · 0 comments
fcatrin commented
When inserting an USB drive, it is shown in the Storage settings and it is listed in the mounted filesystems (mount and/or df commands), but it is not accessible to the apps because:
a) Non-system apps use the READ/WRITE_EXTERNAL_STORAGE permission that is not present in the system permissions (platform.xml)
b) The drive is not mounted as public in /storage because MountService doesn't flag it as Visible, only Primary Public or Adpotable drives are marked as Visible.
Take this (ugly) patch as a workaround to make USB drives always visible to apps and to include the needed permissions.
--- frameworks/base/data/etc/platform.xml.original 2017-07-03 01:04:10.236623976 -0400
+++ frameworks/base/data/etc/platform.xml 2017-07-03 01:05:29.066369954 -0400
@@ -59,6 +59,12 @@
<group gid="log" />
</permission>
+ <permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
+ <group gid="media_rw" />
+ <group gid="sdcard_r" />
+ <group gid="sdcard_rw" />
+ </permission>
+
<permission name="android.permission.WRITE_MEDIA_STORAGE" >
<group gid="media_rw" />
<group gid="sdcard_rw" />
--- ./frameworks/base/services/core/java/com/android/server/MountService.java.original 2017-07-02 02:15:51.744912102 -0400
+++ ./frameworks/base/services/core/java/com/android/server/MountService.java 2017-07-02 02:16:33.455624350 -0400
@@ -1185,7 +1185,7 @@
// Adoptable public disks are visible to apps, since they meet
// public API requirement of being in a stable location.
- if (vol.disk.isAdoptable()) {
+ if (true || vol.disk.isAdoptable()) {
vol.mountFlags |= VolumeInfo.MOUNT_FLAG_VISIBLE;
}