Problem Description: In the reverse of an app, the research environment is a red rice 2, need to use the JDWP interface, that is, DDMS below this interface:
But the magic is, on the same host, the emulator process can be displayed on the Ddms interface, Red Meter 2 does not show a process. CMD uses the adb jdwp command, nor does it show any interfaces.
Through a simple search found that an app process to be able to be JDWP client debugging, or compile when the main configuration file needs to turn on android:debuggable= "true", or a file in the system boot.img Default.pro The ro.debuggable requires a value of 1, which allows all app processes to debug, decompile the target app with the Apktool tool based on the online approach, add its master profile to android:debuggable= "true" and repackage it, then install to red Rice 2 , however the ADB jdwp still shows no interface.
In this case, we need to study the principles of the ADB and jdwp, according to the Android source code system/core/adb/jdwp_service.c notes, the basic understanding of ADB and jdwp what is going on, presumably, The ADB has 3 roles (the code is a set, the compilation options and the Run options differ): ADBD,ADB client, adb server, ADB client The simplest is the ADB command that is typed in cmd when debugging, this time running is the ADB client code, another , the debug interface in Ddms or Eclipse or Android studio is, in fact, an ADB client that accepts commands from users and sends them to ADB server. ADB server is a service process on the debug side (such as the PC side) that accepts commands from the ADB client and then sends it to the ADBD process in the device or emulator. In addition, the device may start a ADBD daemon process according to the configuration, this process is responsible for responding to the commands of ADB server, to the Android system after requesting various data back to ADB server,adbd and ADB Server interactions can be in TCP or USB mode. JDWP is a Java debugging protocol, in the Android implementation, if debugging is turned on (at least one of the two previously mentioned cases), then the process internal virtual opportunity to start a jdwp thread, and then this thread will have a UNIX socket with the ADBD process interaction, The result of the interaction is that ADBD internally maintains a list of target app processes that can be debugged, so that when ADB client jdwp into ADB, the ADB server passes the command to ADBD, and ADBD can return a list of processes to the ADB client.
The ADB client (debugger), ADB server, ADBD, JDWP 4 relationships are as follows:
The JDWP thread and the ADBD UNIX socket connection can be viewed by command:
After understanding the above principles, you can first determine whether the JDWP debug path inside the device is normal, by first installing the native app (without debugging), and then BusyBox Netstat-xa | grep jdwp View, found that there is no connection, and then, with Apktool decompile, modify and then package the installation, and then use the same command to view, found a few connections, this time can be basic judgment, the app's modification is valid, and the internal launch of the JDWP thread and has registered to the ADBD In-process.
The next question is why the PC-side ADB client is not able to return a list when asked by the ADBD, and if the request is a simulator, it is normal.
Red Rice 2 Real machine and the difference between the simulator, mainly is the ADB server and ADBD connection method is not the same, the former is the way of USB, the latter is the way of TCP, and there is a phenomenon is, connect red Rice 2, the Adb devices will be prompted to appear two devices, obviously only one device! Since there are two devices, just look at the Device Manager what is the case, sure enough to find:
Android phone device has two drivers, search the Xiaomi MDB, sure enough, there are cases:
Analysis of Xiaomi MDB scheme
How Android kills Daemons-kill Xiaomi Phone helper
Xiaomi Assistant does not have to open USB debugging can be connected to the phone small research
Originally millet/Red rice has a set of MDB scheme, can realize the Xiaomi assistant in the case of the phone does not open USB debugging can still connect the phone (previously installed Xiaomi Assistant, not sure if the MDB driver is installed at that time), regardless of 3,721, found in the device mdbd process, kill it, found to automatically restart, Back to the PC, the MDB driver uninstall, restart the system, once again ADB devices found only one device, then ADB jdwp, found incredibly able to display the list:
Open DDMS can also connect normally, it seems to be the result of the Xiaomi MDB Drive.
Solve the problem of jdwp Debugging for MI/red rice phone