Recently, we have been studying system transplantation. The USB debugging connect (USB debugging) is correctly displayed, but the USB connection icon is not displayed in the notification bar, the statusbar does not display a USB connection prompt, so this situation is analyzed to find out the cause. The next step is to record the entire process of finding and solving the problem.
This is shown in the log print information.
Ums connection failed
Start with the USB connection mode. There are two modes for USB connection: AC mode (charging) and USB mode (usb_storage connect and USB debugging Connect ), the specific judgment is described in the previous log, which is not mentioned here, because in the SYS file system, I found my corresponding two files
/Sys/class/Power_Supply/AC/online: The displayed value is 0;
/Sys/class/Power_Supply/USB/online: The displayed value is 1;
From this, we can determine that the kernel is correct. This error is not in the kernel. The problem should be caused by a parameter error at the frame framework layer.
Next we will focus on the problem finding at the frame layer.
Recorded on February 16
Certificate ----------------------------------------------------------------------------------------------------------------------------------------
Check the relevant information, and the source code to find the related category of USB connection:
Find the following categories in the USB folder under SYSTEM level apk-systemui.apk:
Storagenotification. Java
Usbstorageactivity. Java
This is another normal log information: The ellipsis is other log information,
--------- Beginning of/dev/log/System
I/vold (1245): vold 2.1 (the revenge) Firing up
D/vold (1245): volume sdcard state changing-1 (initializing)-> 0 (no-Media)
D/vold (1245): volume sdcard state changing 0 (no-media)-> 2 (pending)
D/vold (1245): volume sdcard state changing 2 (pending)-> 1 (idle-unmounted)
W/vold (1245): Ignoring unknown switch 'msm _ hsusb_peripheral'
W/vold (1245): Ignoring unknown switch 'msm _ hsusb_peripheral'
.............
I/systemserver (1327): USB Service
I/USB Service (1327): This kernel does not have USB configuration switch support
I/USB Service (1327): Trying legacy USB configuration switch support
W/USB Service (1327): This kernel does not have USB composite class support
D/usbservice (1327): diag contains non-numeric data
............
D/vold1_listener (1245): Share status UMS
D/storagenotification (1453): startup with ums connection false (media state unmounted)
I/storagenotification (1453): ums connection changed to true (media state unmounted)
The problem is the last one. The error log is ums connection changed to false (media state unmounted)
The log information of this sentence is from the onusbmassstorageconnectionchangedasync method in storagenotification. java.
Private void onusbmassstorageconnectionchangedasync (Boolean connected ){
Mumsavailable = connected;
String ST = environment. getexternalstoragestate ();
Slog. I (TAG, String. Format ("ums connection changed to % s (media state % s)", connected, St ));
Slog. V (TAG, String. Format ("ums connection changed to % s (media state % s)", connected, St ));
Source code
Updateusbmassstoragenotification (connected );
}
Finally, an updateusbmassstoragenotification () method is called to pass the connected (available or unavailable) parameter)
Void updateusbmassstoragenotification (Boolean available ){
If (available ){
Intent intent = new intent ();
Intent. setclass (mcontext, Com. Android. systemui. USB. usbstorageactivity. Class );
Intent. setflags (intent. flag_activity_new_task );
Pendingintent Pi = pendingintent. getactivity (mcontext, 0, intent, 0 );
Setusbstoragenotification (
Com. Android. Internal. R. String. usb_storage_icationication_title,
Com. Android. Internal. R. String. usb_storage_icationication_message,
Com. Android. Internal. R. drawable. stat_sys_data_usb,
False, true, Pi );
} Else {
Setusbstoragenotification (0, 0, 0, false, false, null );
}
}
From the above update method, we can see that as long as the passed connected parameter is available, the status bar information will be updated and the title of the USB connection will appear,
Where does the connected parameter come from? Next, let's look at a piece of log information:
USB not connected
10-1116:5:19. 714: Debug/vold (70 ):
USB disconnected
10-1116:5:19. 714: Debug/vold (70 ):
Share Method ums now unavailable
10-1116:5:19. 734: INFO/storagenotification (177): ums connection changed to false (media state removed)
10-1116:5. 734: verbose/storagenotification (177): ums connection changed to false (media state removed)
10-1116:5:19. 734: verbose/storagenotification (177): --------- beginning of/dev/log/main
10-1116:5:20. 820: Debug/tethering (112): initialstate. processmessage what = 4
10-1116:5:20. 820: Debug/tethering (112): sendtetherstatechangedbroadcast 0, 0, 0
USB connected
10-1116:5:30. 101: Debug/vold (70 ):
USB connected
10-1116:5:30. 101: Debug/vold (70 ):
Share Method ums now available
10-1116:5. 132: verbose/environment (177): getexternalstoragestate ()
10-1116:5. 140: INFO/storagenotification (177): ums connection changed to true (media state removed)
10-1116:5. 140: verbose/storagenotification (177): ums connection changed to true (media state removed)
10-1116:5. 156: Debug/tethering (112): sendtetherstatechangedbroadcast 1, 0, 0
10-1116:5:30. 156: Debug/tethering (112): interfaceadded: usb0
From this log, we can see that the available parameter is passed from the vold underlying layer.
Not complete...
Recorded on February 19
Certificate ----------------------------------------------------------------------------------------------------------------------------------