android 自动挂载sd卡,如何让 Android 自动挂载 SD 卡
1. History about mountd and vold.a. in older version, Android use mountd daemon to manage SD card.b. from cupcake version, vold is used.from the cupcake source code, there is mountd folder in /system/
1. History about mountd and vold.
a. in older version, Android use mountd daemon to manage SD card.
b. from cupcake version, vold is used.
from the cupcake source code, there is mountd folder in /system/core source code.
but from the Android.mk, we can see mountd is not built by default,
and from the comment, we can see vold replaces mountd.
# disabled - we are using vold now instead# include $(BUILD_EXECUTABLE)
c.in eclair version, there is no mountd source code in /system/core.
2. Pre-condition.
we need make sure SD card can be mounted manually.
a.firstly, make sure the feature is supported in kernel layer.
b. we can use mount command to mount or umount the SD card.
the below is a example.
mount -t vfat /dev/block/mmcblk0p1 /sdcard
3. uevent format.
for vold daemon, it receives uevent from kernel space. and the below function processes block device related event.
/system/core/vold/uevent.c: handle_block_event().
it requests specific event format, and it is not compatible with the old userspace tools.
so we need disable the below option in kernel configuration.
General Setup -> Create deprecated sysfs layout for older userspace tools
it is very important, if the above option is enable, v->dev will be none, and the log shows "Cannot start volume /sdard (volume is not bound)"
} else if (v->media_type == media_mmc) {if (!v->dev) {LOGE("Cannot start volume '%s' (volume is not bound)", mount_point);pthread_mutex_unlock(&v->lock);return -ENOENT;}if (_volmgr_consider_disk_and_vol(v, v->dev->disk) < 0) {LOGE("volmgr failed to start volume '%s'", v->mount_point);}}
the below is my log for this issue:
/ARMAssembler( 823): generated scanline__00000077:03515105_00000A01_00000000 [ 42 ipp] (63 ins) at [0x342098:0x342194] in 213623 nsD/vold ( 803): [UEVENT] Sq: 770 S: uids A: 0 P: /kernel/uids/10016D/vold ( 803): DEVPATH=/kernel/uids/10016D/vold ( 803): No uevent handlers registered for 'uids' subsystemI/ActivityManager( 823): Start proc com.android.bluetooth for broadcast com.android.bluetooth/.opp.BluetoothOppReceiver: pid=917 uid=10016}D/vold ( 803): Accepted connection from frameworkD/vold ( 803): dispatch_cmd(send_ums_status):D/vold ( 803): dispatch_cmd(mount_volume:/sdcard):E/vold ( 803): Cannot start volume '/sdcard' (volume is not bound)D/MountListener( 823): handleEvent volume_nomedia:/sdcardD/MountListener( 823): handleEvent ums_disabledD/MountListener( 823): handleEvent ums_disconnected
4. prepare vold configuration.
vold.conf is in /development/data/etc of Eclair's build environment.
and in phone, the file is in /system/etc/.
I add the below items for my phone.
volume_sdcard {media_path /devices/platform/pxa2xx-mci.0/mmc_host/mmc0media_type mmcmount_point /sdcardums_path devices/platform/usb_mass_storage/lun0}
5. reboot the phone, and enjor it.
----
Appendx:
i. one exception.
I have enabled some debug switches to debug, there is one place which has issue.
/system/core/vold/volmgr_vfat.c: vfat_mount()
the original source code is:
LOG_VOL("vfat_mount(%s, %d:%d): mount rc = %d", dev->major,k dev->minor,vol->mount_point, rc);
it can not be built, I found there is a more 'k' character.
if we delete this 'k', build is ok, but in fact, the sequence of four varibles are wrong, and exception will happen.
we need adjust the sequence of the third varible to the first place.
the belos is my log for this issue:
D/vold ( 824): Filesystem check completed OKI/vold ( 824): vfat filesystem check of 179:1 OKD/vold ( 824): vfat_mount(179:1, /sdcard, 1):I/DEBUG ( 798): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***I/DEBUG ( 798): Build fingerprint: 'generic/generic/generic/:2.1-update1/ERE27/eng.amuhong.20100504.104022:eng/test-keys'I/DEBUG ( 798): pid: 824, tid: 1042 >>> /system/bin/vold <<
ii. SD related source code.
a. SD card settings source code:
packages/apps/Settings/src/com/android/settings/SdCardSettings.java
b. MountService source code:
frameworks/base/services/java/com/android/server/MountService.javaframeworks/base/services/java/com/android/server/MountListener.java
frameworks/base/core/java/android/os/IMountService.aidl
c. Native layer:
system/core/voldhardware/libhardware_legacy/mount/IMountService.cpphardware/libhardware_legacy/include/hardware_legacy/IMountService.h
更多推荐
所有评论(0)