These days the test found a very strange problem if the TF card inserted into the card and then inserted into the board after hot plug can be mounted on but the use of a USB stick only when the first plug-in can be mounted on the pull down after the plug in the drive can be recognized that the USB stick has been inserted studied the Mountservice and Vold finally by looking at the/proc/mounts file to find the USB stick after the first plug is normal mount but after unplugging how tangled events mainly involved in the file system/vold/directvolume.cpp
Analysis log found when unplugging a card reader with a TF card The state is like this
4 (mounted)-5 (unmounting)
5 (unmounting)-1 (idle-unmounted)
1 (idle-unmounted) -0 (No-media)
and the U disk unplugged state is like this
4 (mounted)-0 (No-media)
When you unplug a card reader with a TF card, the last two functions are executed
Executed first.
Handlepartitionremoved
And then executed the
Handlediskremoved
When you unplug the USB stick, the last function executes only
Handlediskremoved
And the unloaded function is executed in handlepartitionremoved , so modify the handlediskremoved function.
Modified as follows
void directvolume::handlediskremoved (const char *devpath, netlinkevent *evt) {int major = Atoi (Evt->findparam ("Majo R ")); int minor = Atoi (Evt->findparam ("minor")); Char msg[255]; SLOGD ("Volume%s%s disk%d:%d removed\n", Getlabel (), Getmountpoint (), Major, minor); snprintf (msg, sizeof (msg), "Volume%s%s disk removed (%d:%d)", Getlabel (), Getmountpoint (), Major, minor); Mvm->getbroadcaster ()->sendbroadcast (responsecode::volumediskremoved, MSG, FALSE); if (getState () = = volume::state_mounted) {//add by Hclydao for Udisk if (Volume::unmountvol (true, False) {Sloge ("Failed to unmount volume in Bad removal (%s)", Strerror (errno)); Xxx:at this point we ' re screwed for now} else {slogd ("Crisis averted"); }} setState (Volume::state_nomedia);}
Added the middle of this judgment
if (getState () = = volume::state_mounted) {//add by Hclydao for Udisk if (Volume::unmountvol (True, False)) { Sloge ("Failed to unmount volume in Bad removal (%s)", strerror (errno)); Xxx:at this point we ' re screwed for now } else { slogd ("Crisis averted");} }
Recompile the vold and push it to the board to reboot.
The initial test is no problem.
android4.0 u disk hot Plug and mount not on the bug fix