How does Android Enable Automatic Installation of a usb driver?

Source: Internet
Author: User

 

 

How does one Enable Automatic Installation of a usb driver? The specific requirement may be: after connecting to the usb, the default option is the built-in cd rom mode, automatically run the driver embedded in the CD. After the installation is complete, switch back to usb mass stoage (ums) mode [KEYWORD] usb default connection, Built-in cd-rom, BICR, CD-ROM, cdrom, built-in disc, auto install driver, auto run, the built-in driver [SOLUTION] provides the following implementation ideas: 1. Make your driver into an iso file. You can find the production tool online. 2. Modify the default function of USB connection to bicr. For more information about How to set the default usb connection mode to bicr, see FAQ04464 3. add the iso file to BICR. For more information, see FAQ05690 How to add ISO files into BICR 4, you need to modify your driver. Send the corresponding cmd REZERO_UNIT, depending on the cmnd [1] parameter, to decide whether to switch to UMS or BICR.
1) In our code, the default cmnd [1] parameters are 0xD and 0xB. You can customize your own cmd. 2). The implementation in our code is to switch to UMS, you can customize to switch to another usb mode, such as MTP. Public void updateState (String state ){
...} Else if (REZEROCMD. equals (state )){
/* When recieve REZEROCMD, it means that PC has installed a proper driver, so can switch to other USB function (UMS )*/
Slog. w (TAG, PC knows me );
MIsPcKnowMe = true;
SetCurrentFunctions (UsbManager. USB_FUNCTION_MASS_STORAGE, false); // modify USB_FUNCTION_MASS_STORAGE to USB_FUNCTION_MTP.
Return ;......
The code related to the mobile phone side is attached: The code related to this function is in the following file, you can refer to learn about the specific implementation of the mobile phone side:
1. f_mass_storage.c
Static int do_scsi_command (struct fsg_common * common)
{
Case REZERO_UNIT:
Printk (Get REZERO_UNIT command = % x, common-> cmnd [1]);
If (common-> cmnd [1] = 0xB)
Common-> android_callback (1 );
Else if (common-> cmnd [1] = 0xD)
Common-> android_callback (2 );......
}
2. android. c
Static void android_work (struct work_struct * data)
{
... Char * rezero_event [2] = {USB_STATE = REZEROCMD, NULL };
Char * showcdrom_event [2] = {USB_STATE = SHOWCDROMCMD, NULL };
...... If (dev-> rezero_cmd = 1 ){
Uevent_envp_cdrom = rezero_event;
Dev-> rezero_cmd = 0;
} Else if (dev-> rezero_cmd = 2 ){
Uevent_envp_cdrom = showcdrom_event;
Dev-> rezero_cmd = 0;
}
... If (uevent_envp_cdrom ){
Kobject_uevent_env (& dev-> kobj, KOBJ_CHANGE, uevent_envp_cdrom );
Xlog_printk (ANDROID_LOG_INFO, USB_LOG, % s: sent uevent % s, _ func __, uevent_envp_cdrom [0]);
} Else {
Xlog_printk (ANDROID_LOG_INFO, USB_LOG, % s: did not send zero uevent, _ func __);
}

}
Void mass_storage_callback (unsigned char 1__type)
{
Struct android_dev * dev = _ android_dev;
If (cmd_type! = 0)
Dev-> rezero_cmd = resource_type;
Schedule_work (& dev-> work );
}
3. USB devicemanager. java
Public void updateState (String state ){
... Int connected, configured; if (DEBUG) SXlog. d (TAG, updateState-+ state );
Message msg;...} else if (REZEROCMD. equals (state )){
/* When recieve REZEROCMD, it means that PC has installed a proper driver, so can switch to other USB function (UMS )*/
Slog. w (TAG, PC knows me );
MIsPcKnowMe = true;
SetCurrentFunctions (UsbManager. USB_FUNCTION_MASS_STORAGE, false );
Return;
} Else if (SHOWCDROMCMD. equals (state )){
/* When recieve REZEROCMD, it means that PC has installed a proper driver, so can switch to other USB function (UMS )*/
Slog. w (TAG, SHOW CD-ROM CMD );
SetCurrentFunctions (UsbManager. USB_FUNCTION_BICR, false );
Return ;......}

 

Related Article

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.