17th of the android technology series-Volume Service

Source: Internet
Author: User

The volume service of Android is mainly used to manage external storage devices such as USB/SD card. The platform can perform operations and polling on external storage devices. When the status of the external storage device changes, the volume service will immediately report to the platform.

The relevant code is mainly located:
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

Describes the relationships between these components. But I have not figured out what imountservice. h/CPP is.

It is worth noting that mountservice is registered by an android internal class servicemanager (systemserver. Java ):
Servicemanager. addservice ("Mount", new mountservice (context ))
In this way, register the famous service (named Service). The registered service is a derived class that implements the stub class generated by aidl, and does not need to implement a service derived class. Servicemanager is only used within the Android platform.

 

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.
But I meet into troubles and finally find that the real problem is in the Linux kernel.
Thanks to the android mail list.

Part I (kernel)

(1) make sure thus Kernel configuration in MMC driver

Config_mmc = y
# Config_mmc_debug is not set
Config_mmc_unsafe_resume = y
# Config_mmc_embedded_sdio is not set
Config_mmc_paranoid_sd_init = y

#
# MMC/SD Card Drivers
#
Config_mmc_block = y
Config_mmc_block_bounce = y
# Config_mmc_block_paranoid_resume is not set
# Config_sdio_uart is not set
# Config_mmc_test is not set

#
# MMC/SD host controller drivers
#
Config_mmc_sdhci = y

(2) disable this option
General setup-> Create deprecated sysfs layout for older userspace tools

Before I did this, vold showed a lot of trouble.
And, my media_path is not right
Media_path/devices/platform/s3c-sdhci.0/mmc_host: mmc0 <-- my path before turn off that option

Media_path/devices/platforms/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
D/vold (42): dispatch_cmd (send_ums_status ):
D/vold (42): dispatch_cmd (mount_volume:/sdcard ):
E/vold (42): cannot start volume '/sdcard' (volume is not bound)
D/mountlistener (59): handleevent volume_nomedia:/sdcard
D/mountlistener (59): handleevent ums_disabled
D/mountlistener (59): handleevent ums_disconnected

(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 {
# This is the direct uevent device path to the SD slot on the device
Media_path/devices/platform/s3c-sdhci.0/mmc_host/mmc0

Media_type MMC
Mount_point/sdcard
Ums_path/devices/platform/usb_mass_storage/lun0
}

(2) Add those below to androidboard. mk

Include $ (clear_vars)
Local_module_class: = etc
Local_module: = vold. conf
Local_src_files: = $ (local_module)
Include $ (build_prebuilt)

(3) rebuild the system and check init. RC

Service vold/system/bin/vold
Socket vold stream 0660 root Mount

(4) enjoy

D/vold (42): accepted connection from framework
D/vold (42): dispatch_cmd (send_ums_status ):
D/vold (42): dispatch_cmd (mount_volume:/sdcard ):
I/vold (42): Evaluating Dev '/devices/platform/s3c-sdhci.0/mmc_host/mmc0/mmc0: e624/block/mmcblk0' for mountable filesystems for'/sdcard'
D/mountlistener (61): handleevent volume_unmounted:/sdcard
D/mountlistener (61): handleevent ums_disabled
D/mountlistener (61): handleevent ums_disconnected
D/mountlistener (61): handleevent volume_checking:/sdcard

 

Rockie Cheng

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.