Android 的volume服务主要是用来管理usb/sd卡 等外部存储设备。平台可以对外部存储设备进行操作和轮询状态,当外部存储设备状态发生变化时,volume 服务也会即时报告平台。
相关代码主要位于:
system/core/vold
frameworks/base/services/java/com/android/server/MountListener.java
frameworks/base/services/java/com/android/server/MountService.java
frameworks/base/core/java/android/os/IMountService.aidl
hardware/libhardware_legacy/mount/IMountService.cpp
hardware/libhardware_legacy/include/hardware_legacy/IMountService.h
下图概述了这些组件之间的关系。但是没有搞清楚IMountService.h/cpp是干什么用的。
还有一点值得注意,MountService被一个Android内部类ServiceManager注册(SystemServer.java):
ServiceManager.addService("mount", new MountService(context))
以这种方式注册有名服务(named service),所注册的服务是一个实现了aidl产生的stub类的派生类,并不需要实现一个Service的派生类。ServiceManager仅供Android平台内部使用。
Rockie's Android Porting Guide(4)——Add SD card to your system Rockie Cheng Andorid use vold to manage SD card and it is easy to use. Part I (kernel) (1)make sure thus kernel configuration in MMC driver CONFIG_MMC=y # # Before I did this,vold showed a lot of trouble. media_path /devices/platform/s3c-sdhci.0/mmc_host/mmc0 <--this is the right one Vold may be unhappy to accept my old path,and it didn't work. D/vold ( 42): Accepted connection from framework (3) rebuild your linux kernel PART II(android system) (1) creat a vold.conf in build/target/board/idea6410 ## vold configuration file for idea6410 volume_sdcard { media_type mmc (2)add those below to AndroidBoard.mk include $(CLEAR_VARS) (3)rebuild the system and check init.rc service vold /system/bin/vold (4)enjoy D/vold ( 42): Accepted connection from framework
Rockie Cheng |