android4.0 u disk hot Plug and mount not on the bug fix

Source: Internet
Author: User

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

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.