getVolumeList (called from StorageHelper::getStorageVolumes) is just returning Emulated devices.
Apparently, this check is avoiding public volumes (removable devices) to be returned: #frameworks/base/core/java/android/os/storage/VolumeInfo.java
public boolean isVisibleForWrite(int userId) {
if (type == TYPE_PUBLIC && mountUserId == userId) {
return isVisible();
}
If current user id is not equal to mountUserId, the entry is ignored (method returns false)
Proposed fix for this problem is working the same way as packages/apps/Settings/src/com/android/settings/deviceinfo/StorageSettings.java (plus converting VolumeInfo List to StorageVolume array).
This way, we can return the elements we want (PUBLIC or EMULATED), not checking which is the mounting user id.
By applying the patch, the CM File Manager can see the external storage.
However, I can only navigate the directories but can't read any file.
Do you see the same issue?
Anyway, I've pushed the patch. Thanks a lot!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
[[[Picture - Tries to use gallery to show it, but returns an exception whenm trying to open]]]
01-19 21:31:59.693 1833 2056 I ActivityManager: START u0 {act=android.intent.action.VIEW dat=file:///mnt/media_rw/31A8-7276/Android/data/Screenshot_20160117-121125.png typ=image/png cmp=com.android.gallery3d/.a
pp.GalleryActivity} from uid 10024 on display 0
01-19 21:31:59.712 4301 4301 V StateManager: startState class com.android.gallery3d.app.SinglePhotoPage
01-19 21:31:59.715 4301 4316 W UriImage: fail to open: file:///mnt/media_rw/31A8-7276/Android/data/Screenshot_20160117-121125.png
01-19 21:31:59.715 4301 4316 W UriImage: java.io.FileNotFoundException: Permission denied
01-19 21:31:59.715 4301 4316 W UriImage: at android.os.Parcel.openFileDescriptor(Native Method)
01-19 21:31:59.715 4301 4316 W UriImage: at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:270)
01-19 21:31:59.715 4301 4316 W UriImage: at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:200)
01-19 21:31:59.715 4301 4316 W UriImage: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:937)
01-19 21:31:59.715 4301 4316 W UriImage: at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:795)
01-19 21:31:59.715 4301 4316 W UriImage: at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:749)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.openOrDownloadInner(UriImage.java:105)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.openFileOrDownloadTempFile(UriImage.java:80)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.prepareInputFile(UriImage.java:167)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.-wrap0(UriImage.java)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:174)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:173)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.util.ThreadPool$Worker.run(ThreadPool.java:133)
01-19 21:31:59.715 4301 4316 W UriImage: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-19 21:31:59.715 4301 4316 W UriImage: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-19 21:31:59.715 4301 4316 W UriImage: at java.lang.Thread.run(Thread.java:818)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.util.PriorityThreadFactory$1.run(PriorityThreadFactory.java:44)
It's another issue. Have to check it also
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
getVolumeList (called from StorageHelper::getStorageVolumes) is just returning Emulated devices.
Apparently, this check is avoiding public volumes (removable devices) to be returned:
#frameworks/base/core/java/android/os/storage/VolumeInfo.java
public boolean isVisibleForWrite(int userId) {
if (type == TYPE_PUBLIC && mountUserId == userId) {
return isVisible();
}
If current user id is not equal to mountUserId, the entry is ignored (method returns false)
Proposed fix for this problem is working the same way as packages/apps/Settings/src/com/android/settings/deviceinfo/StorageSettings.java (plus converting VolumeInfo List to StorageVolume array).
This way, we can return the elements we want (PUBLIC or EMULATED), not checking which is the mounting user id.
See patch attached
By applying the patch, the CM File Manager can see the external storage.
However, I can only navigate the directories but can't read any file.
Do you see the same issue?
Anyway, I've pushed the patch. Thanks a lot!
Depending on the file type, I can open it or not.
Text files are ok. For pictures, I got an "Permission Denied" exception
[[[[Text file - calls external /system/bin/cat. File is shown]]]
01-19 21:31:56.985 4073 4073 V ShellConsole: bash-fileinfo, command: /system/bin/stat, args: -t "/mnt/media_rw/31A8-7276/Android/data/New file"
01-19 21:31:56.988 4073 4104 V ShellConsole: stdin: /
01-19 21:31:56.988 4073 4104 V ShellConsole: stdin: #3041580938668576765#/0/#2176146247046869106#/
01-19 21:31:56.990 4073 4104 V ShellConsole: stdin: /
01-19 21:31:56.990 4073 4104 V ShellConsole: stdin: mnt/media_rw/31A8-7276/Android/data/New file 32 16 81f8 1023 1023 821 63 1 ? ? 1453245235 1453245223 1453245223 8192
01-19 21:31:56.993 4073 4104 V ShellConsole: stdin: /
01-19 21:31:56.993 4073 4104 V ShellConsole: stdin: #3733200745873836379#/0/#7385689162497202503#/
01-19 21:31:56.993 4073 4073 V ShellConsole: bash-fileinfo, command: /system/bin/stat, exitCode: 0
01-19 21:31:56.994 4073 4608 V ShellConsole: bash-read, command: /system/bin/cat, args: "/mnt/media_rw/31A8-7276/Android/data/New file"
01-19 21:31:57.003 4073 4104 V ShellConsole: stdin: sdfgsdfgsdfgmsdfkgjsdflkjglkdsfj
01-19 21:31:57.003 4073 4608 V ShellConsole: bash-read, command: /system/bin/cat, exitCode: 0
01-19 21:31:57.003 4073 4136 I EditorActivity: Bytes read: 32
[[[Picture - Tries to use gallery to show it, but returns an exception whenm trying to open]]]
01-19 21:31:59.693 1833 2056 I ActivityManager: START u0 {act=android.intent.action.VIEW dat=file:///mnt/media_rw/31A8-7276/Android/data/Screenshot_20160117-121125.png typ=image/png cmp=com.android.gallery3d/.a
pp.GalleryActivity} from uid 10024 on display 0
01-19 21:31:59.712 4301 4301 V StateManager: startState class com.android.gallery3d.app.SinglePhotoPage
01-19 21:31:59.715 4301 4316 W UriImage: fail to open: file:///mnt/media_rw/31A8-7276/Android/data/Screenshot_20160117-121125.png
01-19 21:31:59.715 4301 4316 W UriImage: java.io.FileNotFoundException: Permission denied
01-19 21:31:59.715 4301 4316 W UriImage: at android.os.Parcel.openFileDescriptor(Native Method)
01-19 21:31:59.715 4301 4316 W UriImage: at android.os.ParcelFileDescriptor.openInternal(ParcelFileDescriptor.java:270)
01-19 21:31:59.715 4301 4316 W UriImage: at android.os.ParcelFileDescriptor.open(ParcelFileDescriptor.java:200)
01-19 21:31:59.715 4301 4316 W UriImage: at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:937)
01-19 21:31:59.715 4301 4316 W UriImage: at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:795)
01-19 21:31:59.715 4301 4316 W UriImage: at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:749)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.openOrDownloadInner(UriImage.java:105)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.openFileOrDownloadTempFile(UriImage.java:80)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.prepareInputFile(UriImage.java:167)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage.-wrap0(UriImage.java)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:174)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.data.UriImage$RegionDecoderJob.run(UriImage.java:173)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.util.ThreadPool$Worker.run(ThreadPool.java:133)
01-19 21:31:59.715 4301 4316 W UriImage: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
01-19 21:31:59.715 4301 4316 W UriImage: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
01-19 21:31:59.715 4301 4316 W UriImage: at java.lang.Thread.run(Thread.java:818)
01-19 21:31:59.715 4301 4316 W UriImage: at com.android.gallery3d.util.PriorityThreadFactory$1.run(PriorityThreadFactory.java:44)
It's another issue. Have to check it also