1. Overall Architecture
2. Process Overview
2.1 enable vold
2.2 boot uevent
2.3 handle events
As a local service of Android, the vold-volume daemon is responsible for processing events such as storage devices such as SD and USB.
1. Overall Architecture
The vold service is centrally controlled by volumemanager. It distributes specific tasks to netlinkmanager, commandlistener, directvolume, and volume.
The vold service interacts with the underlying driver through the socket mechanism downward, and interacts with the Java framework through mechanisms such as JNI, intent, socket, and docommand.
2 Process Overview
2.1 enable the Service
Enable the vold local service when initializing the Android system,
Create a vold folder under/dev/block and enable volumemanager, netlinkmanager, and commandlistener.
2.2 boot uevent
Netlinkmanager monitors uevent events reported by underlying Linux.
The system's socketlistner manages all socket events in a unified manner.
Netlinklistner is responsible for parsing socket events.
Finally, onevent () returns the vold event to netlinkmanager for processing.
2.3 process block and switch events
Netlinkmanager calls the class that handles vold events in volumemanager.
Handleblockevent () is used to mount and detach the SD file, which is handed over to directvolume.
Handleswitchevent () connects USB flash drives.
The two finally use setbroadcast () to pass the responsiblecode through the socket listening mechanism of nativedaemonconnector, and finally upload it to mountservice for unified planning.
The onevent () in mountservice obtains the parsed event and completes the two tasks,
-> Send command docommand () to volumemanager through commandlistener
-> Broadcast event information to related services for upper-layer applications.