Android官方资料--Configuration Examples

Configuration Examples

Below are examples of external storage configurations for various device types. Only the relevant portions of the configuration files are included.

Due to configuration changes in Android 6.0 (like the removal of thestorage_list.xml resource overlay), the configuration examples are split into two categories.

Android 5.x and earlier


Physical primary only

This is a typical configuration for a device with single external storage device which is a physical SD card, like Nexus One.

The raw physical device must first be mounted under /mnt/media_rw where only the system and FUSE daemon can access it. vold will then manage the fuse_sdcard0 service when media is inserted/removed.

fstab.hardware
[physical device node]  auto  vfat  defaults  voldmanaged=sdcard0:auto,noemulatedsd
init.hardware.rc
on init
    mkdir /mnt/media_rw/sdcard0 0700 media_rw media_rw
    mkdir /storage/sdcard0 0700 root root
    export EXTERNAL_STORAGE /storage/sdcard0
service fuse_sdcard0 /system/bin/sdcard -u 1023 -g 1023 -d /mnt/media_rw/sdcard0 /storage/sdcard0
    class late_start
    disabled
storage_list.xml
<storage
    android:mountPoint="/storage/sdcard0"
    android:storageDescription="@string/storage_sd_card"
    android:removable="true"
    android:primary="true"
    android:maxFileSize="4096" />

Emulated primary only

This is a typical configuration for a device with single external storage device which is backed by internal storage on the device, like Nexus 4.

init.hardware.rc
on init
    mkdir /mnt/shell/emulated 0700 shell shell
    mkdir /storage/emulated 0555 root root
    export EXTERNAL_STORAGE /storage/emulated/legacy
    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
    export EMULATED_STORAGE_TARGET /storage/emulated
on fs
    setprop ro.crypto.fuse_sdcard true
service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
    class late_start
storage_list.xml
<storage
    android:storageDescription="@string/storage_internal"
    android:emulated="true"
    android:mtpReserve="100" />

Emulated primary, physical secondary

This is a typical configuration for a device with multiple external storage devices, where the primary device is backed by internal storage on the device, and where the secondary device is a physical SD card, like Xoom.

The raw physical device must first be mounted under /mnt/media_rw where only the system and FUSE daemon can access it. vold will then manage the fuse_sdcard1 service when media is inserted/removed.

fstab.hardware
[physical device node]  auto  vfat  defaults  voldmanaged=sdcard1:auto
init.hardware.rc
on init
    mkdir /mnt/shell/emulated 0700 shell shell
    mkdir /storage/emulated 0555 root root
    mkdir /mnt/media_rw/sdcard1 0700 media_rw media_rw
    mkdir /storage/sdcard1 0700 root root
    export EXTERNAL_STORAGE /storage/emulated/legacy
    export EMULATED_STORAGE_SOURCE /mnt/shell/emulated
    export EMULATED_STORAGE_TARGET /storage/emulated
    export SECONDARY_STORAGE /storage/sdcard1
on fs
    setprop ro.crypto.fuse_sdcard true
service sdcard /system/bin/sdcard -u 1023 -g 1023 -l /data/media /mnt/shell/emulated
    class late_start
service fuse_sdcard1 /system/bin/sdcard -u 1023 -g 1023 -w 1023 -d /mnt/media_rw/sdcard1 /storage/sdcard1
    class late_start
    disabled
storage_list.xml
<storage
    android:storageDescription="@string/storage_internal"
    android:emulated="true"
    android:mtpReserve="100" />
<storage
    android:mountPoint="/storage/sdcard1"
    android:storageDescription="@string/storage_sd_card"
    android:removable="true"
    android:maxFileSize="4096" />

Android 6.0


Physical primary only

This is a typical configuration for a device with single external storage device which is a physical SD card, like the original Android One. There is no secondary shared storage and the device cannot support multi-user.

fstab.device
/devices/platform/mtk-msdc.1/mmc_host*         auto        auto       defaults
voldmanaged=sdcard0:auto,encryptable=userdata,noemulatedsd
init.device.rc
on init
    # By default, primary storage is physical
    setprop ro.vold.primary_physical 1
    

Emulated primary only

This is a typical configuration for a device with single external storage device which is backed by internal storage on the device, like Nexus 6.

  • Primary shared storage (/sdcard) is emulated on top of internal storage.
  • No secondary SD card storage.
  • USB OTG storage devices supported.
  • Supports multi-user.
fstab.device
/devices/*/xhci-hcd.0.auto/usb*             auto            auto    defaults
                                                    voldmanaged=usb:auto

Emulated primary, physical secondary

This is a typical configuration for a device with multiple external storage devices, where the primary device is backed by internal storage on the device, and where the secondary device is a physical SD card, like Xoom.

  • Primary shared storage (/sdcard) is emulated on top of internal storage.
  • Secondary storage is a physical SD card slot that can be adopted.
  • Supports multi-user.
fstab.device
/devices/platform/mtk-msdc.1/mmc_host*           auto      auto     defaults
voldmanaged=sdcard1:auto,encryptable=userdata
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值