内置与外置卡路径实际是存在系统文件"system/etc/vold.fstab"中,可以用一下语句获得路径。
Environment.getRootDirectory().getAbsoluteFile() + File.separator + "etc" + File.separator + "vold.fstab";
联想K860i的system/etc/vold.fstab文件内容如下:
## Vold 2.0 Generic fstab
## - San Mehat ([email protected])
##
#######################
## Regular device mount
##
## Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>
## label - Label for the volume
## mount_point - Where the volume will be mounted
## part - Partition # (1 based), or 'auto' for first usable partition.
## <sysfs_path> - List of sysfs paths to source devices
######################
dev_mount sdcard /mnt/sdcard 1 /devices/platform/dw_mmc/mmc_host/mmc0
dev_mount extra_sd /mnt/sdcard/extra_sd auto /devices/platform/s3c-sdhci.2/mmc_host/mmc1
联想K860i的sd卡路径是:
mnt/sdcard 内置卡,mnt/sdcard/extra_sd外置卡,与结果相符。
目前只在联想K860i和公司的样机G2,G10,G6+,D6上测试OK。
G2,/storage/sdcard0内置卡,/storage/sdcard1外置卡
dev_mount sdcard /storage/sdcard0 emmc@fat /devices/platform/goldfish_mmc.0 /devices/platform/mtk-sd.0/mmc_host
dev_mount sdcard2 /storage/sdcard1 auto /devices/platform/goldfish_mmc.1 /devices/platform/mtk-sd.1/mmc_host
G10&G10+,/mnt/sdcard外置卡,/mnt/external_sd外置卡,/mnt/usb_storageU盘
dev_mount flash /mnt/sdcard auto /dev/block/mtd/by-name/user
dev_mount sdcard /mnt/external_sd auto /devices/platform/rk29_sdmmc.0/mmc_host/mmc0
dev_mount udisk /mnt/usb_storage auto /devices/platform/usb20_host/usb /devices/platform/usb20_otg/usb
G6+,/mnt/sdcard内置卡,/mnt/external_sd外置卡
dev_mount flash /mnt/sdcard auto /devices/virtual/mtd/mtd9/mtdblock9
dev_mount sdcard /mnt/external_sd auto /devices/platform/rk29_sdmmc.0/mmc_host/mmc0
D6,/mnt/sdcard内置卡,/mnt/extsd外置卡,/mnt/usbhost1U盘
dev_mount sdcard/mnt/sdcard auto/devices/virtual/block/nandj
dev_mount extsd/mnt/extsd auto/devices/platform/sunxi-mmc.1/mmc_host /devices/platform/sunxi-mmc.0/mmc_host
dev_mount usbhost1/mnt/usbhost1 auto/devices/platform/sw-ehci.1 /devices/platform/sw_hcd_host0/devices/platform/sw-ohci.1
G6,,/mnt/sdcard内置卡,/mnt/extsd外置卡,/mnt/usbhost1U盘
dev_mount sdcard/mnt/sdcard auto/devices/virtual/block/nandj
dev_mount extsd/mnt/extsd auto/devices/platform/sunxi-mmc.1/mmc_host /devices/platform/sunxi-mmc.0/mmc_host
dev_mount usbhost1/mnt/usbhost1 auto/devices/platform/sw-ehci.1 /devices/platform/sw_hcd_host0/devices/platform/sw-ehci.2a
D6和G6有所不同,不是用空格隔开,而是用TAB隔开。
获取盘符类:
public class Dev_MountInfo implements IDev {调用代码:
//获得各盘符路径
Dev_MountInfo dev = Dev_MountInfo.getInstance();
DevInfo info = dev.getInternalInfo();
this.diskInternal = info.getMount_point();
//Environment.getExternalStorageDirectory() 这两个要是不一样咋办
info = dev.getExternalInfo();
this.diskExternal = info.getMount_point();
info = dev.getUSBInfo();
this.diskUSB = info.getMount_point();
该方法基于以下几点猜测:
1.挂载盘符的文件一定是 system/etc/vold.fstab
2.挂载盘符顺序一定是 内置卡 外置卡 U盘,而且前面必须有
3.每个盘符挂载信息都是如下排序 Format: dev_mount <label> <mount_point> <part> <sysfs_path1...>
4.