Hello,
Thanks for the explanation!
Now I think I understand it, it seems the API is using the same magic
string, 'sdcard' for two different purposes. First it is the name of a
storageType, used in navigator.getDeviceStorage/s( storageType ). Then
it is also the storageName of the default internal storage:
const st = navigator.getDeviceStorage('sdcard'); //the storageType
const sn = st.storageName; //sn could be 'sdcard', the storageName
Unfortunate.
If the API were ever to evolve this should be resolved but until then we
will have to fix the docs to prevent confusion. Probably the storageType
should be called 'file' since it is storage for arbitrary files as
against for 'music' or 'photo' types and the storageName is 'sdcard' for
all.
Actually, would it be possible to add the 'file' storageType so we could
deprecate the 'sdcard' storageType and drop it in the future?
cheers,
~adrian
On 8/8/14 10:17 PM, Dave Hylands wrote:
There may be multiple storage areas.
You can call navigator.getDeviceStorages(type) to get back an array
of all of storage areas.
Each storage area will have a name, retrievable using .storageName
attribute.
If there is more than one storage area, then the internal one will be
named 'sdcard' and the physical storage are will be called something
else (sometimes, it's extsdcard, sometimes its sdcard1).
navigator.getDeviceStorage() returns the storage area whose .default
attribute is true. This is controlled by the user in Settings->Media
Storage->"Default media location" (way down at the bottom). If you
call addNamed and pass in a relative path, then it will be stored on
the default storage area. The onsuccess callback will get the fully
qualified name (for example /sdcard/filename) where the file was
actually stored.
The names of files on the sdcard storage area will be
/sdcard/path/filename, and the names of files on the sdcard1 storage
area will be /sdcard1/path/filename
Note that the /sdcard and /sdcard1 are storage names. Their actual
mount points on the system are determined via vold and/or
/system/etc/volume.cfg file). DeviceStorage transparently maps the
storageName into the actual mountPoint (so you don't need the mount
point if you're just accessing the files through device storage)
If you want to determine the mount point to examine the filesystem
from an adb shell, then you can determine the vold mount points by
using the command: adb shell vdc volume list (requires a root shell)
On the flame, you'll see something like: 110 0 sdcard /storage/sdcard
4 110 0 sdcard1 /storage/sdcard1 4 200 0 Volumes listed.
For volumes which aren't managed by vold (the sdcard volume on a
nexus 4/5 are examples of this), the mount point is found in
/system/etc/volume.cfg
With the engineering builds, there is a ds-test app
(gaia/dev_apps/ds-test) which I use for testing things on device
storage.
Dave Hylands
----- Original Message -----
From: "Adrian Custer" <[email protected]> To: "Moz dev-b2g list"
<[email protected]> Sent: Friday, August 8, 2014 5:06:41
PM Subject: [b2g] accessing the real SD card via DeviceStorage on
newer devices
Hey all,
is there a way to access the actual SD card on newer devices using
navigator.getDeviceStorage('....')?
While older devices had /sdcard (or really /mnt/sdcard) to access
the external SD card, the trend seems to be to have that location
reference built in ROM and have a secondary location for the SD
card. For example, the TCP tablet has:
root@android:/ # df Filesystem Size Used Free Blksize /dev 797M 32K
797M 4096 /mnt/secure 797M 0K 797M 4096 /mnt/asec 797M 0K 797M
4096 /mnt/obb 797M 0K 797M 4096 /system 1G 172M 1G 4096 /cache 1G
102M 1G 4096 /data 126M 89M 36M 4096 /mnt/sdcard 9G 84M 9G 4096
/mnt/secure/asec 9G 84M 9G 4096 /mnt/extsd 29G 4G 25G 32768
where the /mnt/sdcard is some internal block of memory and the
/mnt/extsd is the 32GB SD card in the card slot.
Gaia seems to be aware of these two spaces and may be using them
for different purposes since I have :
root@android:/ # ls /mnt/sdcard/ DCIM Documents LOST.DIR ...
root@android:/ # ls /mnt/extsd/ DCIM LOST.DIR Music Pictures ...
although maybe I added the directories by hand to the external SD
card, I don't remember. The music app can access the music files on
the card though, not sure how.
The doc page
https://developer.mozilla.org/en-US/docs/Web/API/Navigator.getDeviceStorage
does not mention anything.
thanks for any info, ~adrian
_______________________________________________ dev-b2g mailing
list [email protected]
https://lists.mozilla.org/listinfo/dev-b2g
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g