Wednesday, May 22, 2013

SDCard automount in Android



Curious to know how auto mounting the devices in Android system works?? here some know how shared. Manually mounting the device worked with mount command but still android applications are not aware of the device being mounted!!!. After googling found that devices mounted status has to be broad casted. what about the hotplug/unplanned removal of device?

Inside android eclair source forest you will see volume daemon service (system/core/vold). vold takes care of mounting/unmounting and informing mountlistner and mediascanner services.


vol daemon keeps reading a socket for uevent and when there is event from kernel appears then takes necessary action to handle
1. device type,
2. partitions, major/minor number
3. file system type and checking,
4. mounting and informing upper servce layers (mount listner, media scanner) to update mount status and sqlite database.

If automount is not working on your platform then first enable the DEBUG messages in vold. Search for DEBUG in system/core/vold and define those and capture those plenty of logs. Make a note: vold keeps running in the background so system does not allow to overwrite the vold binary. If vold is killed then init will spawn another. One way it is good to make vold to read /etc/vold.conf if you have changed.

From the log it should be clearly visible what uevent parameters system is getting from the kernel and against which vold is trying to match.

DISCLAIMER:There are many mailing discussions and solutions, but I am just consolidating here and putting few of the hacks. These may vary from platform to platform and my assumption may prove wrong for you. do not blame me...........