Analysis of SD card mounting process in Android 2.3 (2)

Source: Internet
Author: User

In the previous blog article "Android 2.3 SD card mounting process (I)", we briefly introduced the SD card mounting process. It includes the transmission of event messages from the kernel layer to the user layer, and the introduction of vold. This article will continue to introduce the mounting of the SD card, but this article does not involve detailed analysis of the Code, because this part of the online information, I will post it at the end of the article for your reference. The main purpose of this article is to summarize the part of your own learning, and hope that you can point out what is wrong in this article.

1. SD card mounting Flowchart

The flowchart of SD card mounting is as follows:


Green arrow: indicates event transfer and SD card mounting after SD card insertion

Red Arrow: indicates the message passing process after the mounting is successful.

The yellow arrow indicates that mountservice issues the command to mount/uninstall the SD card.

You may be surprised by the sudden appearance of so many names in the figure, which can be found in the Android 2.3 source code. Next I will explain the functions of these classes one by one.


2. Main functions of each file

(1) kernel: This is the system kernel. It is not the file I want to analyze. The content in this article is not kernel-level! (Learning hard ...)


(2) netlinkmanager: netlinkmanager. cpp is located in the Android 2.3 Source Code Location/system/vold/netlinkmanager. cpp. This class receives event messages from the kernel by referencing the onevent () method in the netlinkhandler class. netlinkhandler is located in/system/vold/netlinkhandler. cpp.


(3) volumemanager: volumemanager. cpp is located in the Android 2.3 Source Code Location/system/vold/volumemanager. cpp. This class is mainly used to receive event messages processed by netlinkmanager. Because the SD card is mounted here, the messages processed by netlinkmanager are divided into five types: Block, switch, usb_composite, battery, and Power_Supply. The SD card mounting event is block.


(4) directvolume: In/system/vold/directvolume. cpp. This class is a tool class that is mainly responsible for further processing of incoming events. Block events can be divided into four types: add, removed, change, and noaction. This section introduces the Add event.


(5) volume: volume. cpp is located in/system/vold/volume. cpp, which is the main class responsible for SD card mounting. Volume. cpp is mainly responsible for checking the SD card format and mounting the SD card with compound requirements, and passing messages mounted to the Message SD card to nativedaemonconnevia socket.


(6) nativedaemonconnector: this class is located in frameworks/base/services/Java/COM. Android. Server/nativedaemonconne. Java. This class is used to receive SD card Mount messages from volume. cpp and send them up.


(7) mountservice: Located in frameworks/base/services/Java/COM. Android. Server/mountservice. java. Mountservice is a service class that provides system services for managing and querying external storage devices. When the status of an external storage device changes, the device sends a notification to the upper-layer application. This is a very important class in the Android system.


(8) storagemanaer: Located in frameworks/base/CORE/Java/andriod/OS/storage/storagemanager. java. As mentioned in the description of this class, this class is the interface of the system storage service. In system settings, there are storage related items, and setting also registers the listener for this class. Storagemanager registers its listener to mountservice. Therefore, this class is mainly used by upper-layer applications to obtain the SD card status.

Based on the previous introduction to the functions of each file and the mounting flowchart of the entire SD card, we can see how the Android system obtains the SD card mounting information from the underlying layer.

Next, we will continue to analyze the program call flowchart.


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.