Theo
Theo

Reputation: 2042

External SDcards with Android API 26

Evironment:

Android Studio 3.0.1. All latest patches applied. AVD Nexus 6, Sd card external.

Issue: Having launched the AVD, the external sdcard does not show in ESExplorer, nor in my app New Playlist Manager when browsing local folders.

Using

adb shell
su
cd /storage
ls -al

shows

emulated
self

so no external sdcard.

However, using the new Files app, the external sdcard DOES show. Also, running the Picker when requesting access to the sdcard (with the Storage Access Framework)

            Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
            startActivityForResult(intent, OPEN_DIRECTORY_REQUEST_CODE);

again the External Sdcard shows

I have explored several selinux level options using a class called MemoryStorage (posted on this forum)

/proc/mounts does not return the external sdcard

/system/etc/vold.fstab does not exist

Have Google yet again changed access to the external sdcard?

How can I get the physical external sdcard.?

Additional: The sdcard is part of the filesystem as proven below where LOST.DIR is located on the external sdcard

generic_x86:/ # ls -alR |grep LOST.DIR
drwxrwx--- 2 media_rw media_rw 2048 2017-12-04 15:06 LOST.DIR
./mnt/media_rw/14FA-3B13/LOST.DIR:

Upvotes: 0

Views: 1780

Answers (1)

Theo
Theo

Reputation: 2042

I found this: The new "SDCardFS" file system wrapper

Google hasn't officially said a word about this, but apparently Android 8.0 comes with support for a new file system wrapper called "SDCardFS." Maybe that statement is too presumptuous—with the 8.0 upgrade, the Google Pixel and a few Nexus devices magically start using SDCardFS, so presumably that means the new file storage scheme is available for anyone in AOSP. The intrepid hardware hackers over at XDA have been tracking the implementation progress, and apparently SDCardFS should significantly reduce the I/O overhead involved in accessing Android's shared data storage.

Reference:

arstechnica.com

https://arstechnica.com/gadgets/2017/09/android-8-0-oreo-thoroughly-reviewed/8/

another interesting article:

xda developers

https://www.xda-developers.com/diving-into-sdcardfs-how-googles-fuse-replacement-will-reduce-io-overhead/

and

http://pocketnow.com/2015/12/18/adoptable-storage

Update: further investigations show that the external sdcard does exist but the permissions xrw are only set for User (owner) and Group access. The Other Access has no permissions.

Using chmod o+r has no effect

generic_x86:/mnt # ls -al
total 0
drwxr-xr-x 10 root   system   220 2017-12-07 11:29 .
drwxrwxrwt 16 root   root     660 2017-12-07 11:29 ..
drwx--x--x  2 root   root      40 2017-12-07 11:29 appfuse
drwxr-xr-x  2 root   system    40 2017-12-07 11:29 asec
drwxrwx--x  2 system system    40 2017-12-07 11:29 expand
drwxr-x---  3 root   media_rw  60 2017-12-07 11:29 media_rw
drwxr-xr-x  2 root   system    40 2017-12-07 11:29 obb
drwx------  5 root   root     100 2017-12-07 11:29 runtime
lrwxrwxrwx  1 root   root      21 2017-12-07 11:29 sdcard -> /storage/self/primary
drwx------  3 root   root      60 2017-12-07 11:29 secure
drwxr-xr-x  3 root   root      60 2017-12-07 11:29 user
generic_x86:/mnt # cd media_rw
generic_x86:/mnt/media_rw # ls -al
total 0
drwxr-x---  3 root     media_rw  60 2017-12-07 11:29 .
drwxr-xr-x 10 root     system   220 2017-12-07 11:29 ..
drwxrwx---  3 media_rw media_rw 512 2017-12-07 11:29 12FE-0C07

Further update:

Guess what

adb shell sm set-force-adoptable true

makes the sdcard appear as /storage/xxxx-xxxx.

switches for the selinux sm command:

   generic_x86:/ # sm /?
    usage: sm list-disks [adoptable]
           sm list-volumes [public|private|emulated|all]
           sm has-adoptable
           sm get-primary-storage-uuid
           sm set-force-adoptable [true|false]
           sm set-virtual-disk [true|false]
           sm partition DISK [public|private|mixed] [ratio]
           sm mount VOLUME
           sm unmount VOLUME
           sm format VOLUME
           sm benchmark VOLUME
           sm fstrim
           sm forget [UUID|all]
           sm set-emulate-fbe [true|false]

Upvotes: 2

Related Questions