Android实现OTG功能
2015-11-29 20:26
531 查看
一般来说,接上U盘后,Linux内核是可以识别到U盘的,但Android层需要进行挂载该U盘,才能被读取到。在init.rc中看到一个网址,于是便打开来查看,原来Android有相应的方法来挂载U盘的。摘录如下。
本文摘自https://source.android.com/devices/storage/config-example.html
The raw physical device must first be mounted under
The raw physical device must first be mounted under
Primary shared storage (
No secondary SD card storage.
USB OTG storage devices supported.
Supports multi-user.
Primary shared storage (
Secondary storage is a physical SD card slot that can be adopted.
Supports multi-user.
本文摘自https://source.android.com/devices/storage/config-example.html
Android 5.x and earlier
Physical primary only
This is a typical configuration for a device with single external storagedevice which is a physical SD card, like Nexus One.The raw physical device must first be mounted under
/mnt/media_rwwhere only the system and FUSE daemon can accessit.
voldwill then manage the
fuse_sdcard0servicewhen 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 storagedevice 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 externalstorage devices, where the primary device is backed by internal storageon 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_rwwhere only the system and FUSE daemon canaccess it.
voldwill then manage the
fuse_sdcard1service 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 storagedevice which is a physical SD card, like the original Android One. There is nosecondary shared storage and the device cannot support multi-user.init.device.rc
on init # By default, primary storage is physical setprop ro.vold.primary_physical 1
fstab.device
/devices/platform/mtk-msdc.1/mmc_host* auto auto defaults voldmanaged=sdcard0:auto,encryptable=userdata,noemulatedsd
Emulated primary only
This is a typical configuration for a device with single external storagedevice 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 storagedevices, 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.
/devices/platform/mtk-msdc.1/mmc_host* auto auto defaults voldmanaged=sdcard1:auto,encryptable=userdata
相关文章推荐
- Android Glide源码解析
- Android进程与线程基本知识
- Android学习笔记之Drawable 文件夹
- mac系统配置android adb环境
- android.mk文件内容
- Android-Android6.0新特性-略讲1
- AndroidStudio怎么将开源项目发布到jcenter
- Android软键盘的隐藏显示研究
- android开发设计模式の单例模式
- Android 简单的Logger 日志系统实现
- Android中的转屏流程
- (转载一些资料) Android打开各种类型的文件方法总结..........
- android git和repo的使用,获取android代码
- Android 禁止屏幕休眠和锁屏的方法
- Android系统服务-简介
- Android系统服务-WindowManager
- 王学岗补间动画(二)————————动画集合的应用
- Android Camera CameraHal.cpp 初始化分析
- Android之screenOrientation属性
- Android Camera数据流分析全程记录(overlay方式二)