An Android device remote connection debugging method, device and medium
By encapsulating and parsing ADB data in a relay server, efficient remote debugging of Android devices is achieved, solving the problems of low efficiency and high cost in existing technologies and improving the efficiency of collecting customer environment information.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- INSPUR ZHUOSHU BIG DATA IND DEV CO LTD
- Filing Date
- 2023-01-04
- Publication Date
- 2026-04-28
AI Technical Summary
Existing Android system debugging methods are inefficient, difficult to collect customer environment information in real time, and costly.
ADB data is encapsulated using the WebSocket protocol and converted into HTTP proxy protocol data in a relay server. The data encapsulation and parsing are completed through a browser application, establishing a remote debugging link and removing the installation requirements for ADB Server and ADBClient.
It improves the efficiency of collecting customer environmental information, reduces debugging costs, and eliminates the need for on-site debugging.
Smart Images

Figure CN116319723B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method, device and medium for remote connection and debugging of Android devices. Background Technology
[0002] After Android-based devices are deployed and launched, if problems arise, the existing debugging methods usually involve logging and uploading logs to discover and resolve the issues.
[0003] If the pre-set log points do not contain the necessary information, it is difficult to discover and resolve the issue. Furthermore, due to the lack of interactivity in log-based systems, even if a problem is discovered, it is impossible to collect the necessary customer environment information in real time. On the other hand, debugging at the customer's site is not only inefficient but also costly. Summary of the Invention
[0004] This application provides a method, device, and medium for remote connection and debugging of Android devices, which addresses the following technical problem: existing methods for debugging Android systems are inefficient.
[0005] The embodiments of this application adopt the following technical solutions:
[0006] This application provides a method for remote connection debugging of an Android device. The method includes: establishing a first connection between the debugging device and a relay server; establishing a second connection between the Android device to be debugged and the relay server; converting the first connection via the relay server and connecting the converted first connection to the second connection to establish a command sending link; issuing a debugging command via the debugging device and sending the debugging command to the Android device to be debugged via the command sending link, thereby performing remote debugging of the device to be debugged.
[0007] This application embodiment encapsulates ADB data using the WebSocket protocol, and then extracts the WebSocket-wrapped ADB data in the relay server and further encapsulates it into HTTP proxy protocol data, which is then connected to the intranet penetration relay proxy service. This application embodiment removes the ADB Server and ADBClient that need to be installed on the debugging machine in the prior art; all encapsulation and parsing of ADB data are completed in the browser application. This not only eliminates the need to prepare ADB tools, but also improves the efficiency of collecting customer environment information and eliminates the need for on-site debugging, thus reducing debugging costs.
[0008] In one implementation of this application, establishing a first connection between the debugging device and the relay server specifically includes: establishing a WebSocket connection between the debugging machine and the relay server based on the WebSocket protocol, thereby realizing the connection between the debugging machine and the relay server; wherein, the WebSocket protocol is related to the web application of the browser.
[0009] In one implementation of this application, a second connection is established between the Android device to be debugged and the relay server. Specifically, this includes establishing an intranet penetration TCP connection between the relay server and the Android device to be debugged to achieve the connection between the relay server and the Android device to be debugged.
[0010] In one implementation of this application, a relay server is used to convert the first connection and connect the converted first connection to the second connection to establish a command sending link. Specifically, this includes: converting the WebSocket connection to an HTTP proxy connection through the relay server and connecting the HTTP proxy connection to an intranet-penetrating TCP connection.
[0011] In one implementation of this application, issuing debugging commands through a debugging device specifically includes: encapsulating the debugging commands within the browser web application of the debugging device; and issuing the encapsulated debugging commands through the debugging device.
[0012] In one implementation of this application, a debugging command is sent to the Android device to be debugged based on a command sending link for remote debugging of the device. Specifically, this includes: sending the debugging command to a relay server through a first connection; and sending the debugging command to the Android device to be debugged through a second connection between the relay server and the Android device to be debugged for remote debugging of the device.
[0013] In one implementation of this application, debugging commands are sent to the Android device to be debugged via a relay server and a second connection. Specifically, this includes: extracting ADB data wrapped in WebSocket via the relay server; re-encapsulating the extracted ADB data wrapped in WebSocket into HTTP proxy protocol data via a pre-installed WEB service program in the relay server; and connecting the HTTP proxy data to an intranet-penetrating TCP connection to send it to the Android device to be debugged.
[0014] In one implementation of this application, after remotely debugging the device to be debugged, the method further includes: upon receiving a remote debugging shutdown command, closing the first connection and the second connection, and closing the corresponding debugging-related service processes.
[0015] This application provides a method for remotely connecting an Android device to a debugging device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: establish a first connection between the debugging device and a relay server; establish a second connection between the Android device to be debugged and the relay server; convert the first connection through the relay server and connect the converted first connection to the second connection to establish a command sending link; and issue debugging commands through the debugging device and send the debugging commands to the Android device to be debugged based on the command sending link to remotely debug the device to be debugged.
[0016] This application provides a non-volatile computer storage medium storing computer-executable instructions. The computer-executable instructions are configured to: establish a first connection between a debugging device and a relay server; establish a second connection between an Android device to be debugged and the relay server; convert the first connection through the relay server and connect the converted first connection to the second connection to establish a command sending link; issue a debugging command through the debugging device and send the debugging command to the Android device to be debugged based on the command sending link to remotely debug the device to be debugged.
[0017] The above-mentioned technical solutions adopted in this application embodiment can achieve the following beneficial effects: This application embodiment uses the WebSocket protocol to encapsulate ADB data, and extracts the WebSocket-wrapped ADB data in the relay server and then encapsulates it into HTTP proxy protocol data, which is then connected to the intranet penetration relay proxy service. This application embodiment removes the ADB Server and ADBClient that need to be installed on the debugging machine in the prior art. All encapsulation and parsing of ADB data are completed in the browser application. Not only is it unnecessary to prepare ADB tools, but it also improves the efficiency of collecting customer environment information, eliminates the need for on-site debugging without customers, and reduces debugging costs. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. In the drawings:
[0019] Figure 1 A flowchart illustrating a remote connection and debugging method for an Android device provided in this application embodiment;
[0020] Figure 2 This is a schematic diagram of a remote connection and debugging method for an Android device provided in an embodiment of this application;
[0021] Figure 3 This is a schematic diagram of the structure of an Android device remotely connecting to a debugging device, provided in an embodiment of this application. Detailed Implementation
[0022] This application provides a method, device, and medium for remote connection and debugging of Android devices.
[0023] To enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this application.
[0024] After Android-based devices are deployed and launched, if problems arise, the existing debugging methods usually involve logging and uploading logs to discover and resolve the issues.
[0025] If the pre-set log points do not contain the necessary information, it is difficult to discover and resolve the issue. Furthermore, due to the lack of interactivity in log-based systems, even if a problem is discovered, it is impossible to collect the necessary customer environment information in real time. Debugging at the customer's site is not only inefficient but also costly.
[0026] This application embodiment encapsulates ADB data using the WebSocket protocol, and then extracts the WebSocket-wrapped ADB data in the relay server and further encapsulates it into HTTP proxy protocol data, which is then connected to the intranet penetration relay proxy service. This application embodiment removes the ADB Server and ADBClient that need to be installed on the debugging machine in the prior art; all encapsulation and parsing of ADB data are completed in the browser application. This not only eliminates the need to prepare ADB tools, but also improves the efficiency of collecting customer environment information and eliminates the need for on-site debugging, thus reducing debugging costs.
[0027] The technical solutions proposed in the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0028] Figure 1 This is a flowchart illustrating a remote connection and debugging method for an Android device, as provided in an embodiment of this application. Figure 1 As shown, the method for remote connection and debugging on an Android device includes the following steps:
[0029] S101. Establish the first connection based on the debugging equipment and the relay server.
[0030] In one embodiment of this application, the prior art employs intranet penetration technology, which uses a data relay server to forward data, thereby enabling communication between the ADB Server and ADB Daemon through a virtual network link to achieve remote control. However, this solution is relatively cumbersome, requiring ADB tools, port forwarding software, complex configuration, and a series of application tools such as command line, file management, and screen control.
[0031] It should be noted that ADB (Android Debug Bridge) is a general-purpose command-line tool that allows communication with emulator instances or connected Android devices.
[0032] ADB is mainly divided into three parts:
[0033] (1) ADB daemon: A background program that runs on Android devices. When the developer mode of an Android device is turned on and USB debugging is enabled, an ADB dadmon process will run on the Android device or emulator.
[0034] (2) ADB server: This component manages the communication between the client and the background program. The server runs as a background process on the development computer.
[0035] (3) ADB client: This component sends commands. The client runs on the development computer and can be invoked from the command-line terminal using the adb command. By default, the adb client communicates with the local adb server, but it can also communicate with the adb server on a remote machine by specifying parameters.
[0036] The WebSocket protocol is an application layer protocol based on TCP, used to implement bidirectional communication in client / server architecture applications.
[0037] In one embodiment of this application, a WebSocket connection is established between the debugging device and the relay server based on the WebSocket protocol to achieve the connection between the debugging device and the relay server. The WebSocket protocol is related to web applications in browsers.
[0038] Specifically, this embodiment removes the ADB Server and ADBClient that need to be installed on the debugging device. All encapsulation and parsing of ADB data are completed in the browser application. Since the browser cannot directly send ADB data using the ordinary TCP protocol, this embodiment uses the WebSocket protocol to encapsulate the ADB data and uses the WebSocket protocol to establish the connection between the debugging device and the relay server.
[0039] S102. Establish a second connection between the Android device to be debugged and the relay server.
[0040] In one embodiment of this application, an intranet-penetrating TCP connection is established between the relay server and the Android device to be debugged, so as to realize the connection between the relay server and the Android device to be debugged.
[0041] Specifically, the relay server extracts the ADB data wrapped in WebSocket and then repackages it into HTTP proxy protocol data. This is achieved by adding a web service program to the relay server to perform data repackaging from WebSocket to HTTP proxy, thus connecting it to the intranet penetration relay proxy service.
[0042] S103. The first connection is converted through a relay server, and the converted first connection is connected to the second connection to establish a command sending link.
[0043] In one embodiment of this application, a relay server is used to convert the WebSocket connection into an HTTP proxy connection, and the HTTP proxy connection is then connected to an intranet-penetrating TCP connection.
[0044] Specifically, in order to send debugging commands from the debugging device to the Android device to be debugged, after establishing a WebSocket connection between the relay server and the debugging device, it is also necessary to establish a connection between the relay server and the Android device to be debugged, thereby establishing a command transmission link. The debugging commands sent by the debugging device are then sent to the Android device to be debugged through this command transmission link to achieve debugging of the Android device to be debugged.
[0045] Furthermore, in this embodiment, the received first connection, i.e., the WebSocket connection, is converted into an HTTP proxy connection via a relay server. The converted HTTP proxy connection is then connected to an intranet-penetrating TCP connection to establish a transmission link between the debugging device and the Android device to be debugged.
[0046] S104. Debug commands are issued through the debugging device and sent to the Android device to be debugged based on the command sending link, so as to perform remote debugging on the device to be debugged.
[0047] In one embodiment of this application, debugging commands are encapsulated within the browser web application of the debugging device. The debugging device then distributes the encapsulated debugging commands.
[0048] Specifically, this embodiment of the application does not require the installation of separate ADB Server and ADBClient. All encapsulation and parsing of ADB data are completed within the browser application. Since the browser cannot directly send ADB data using the ordinary TCP protocol, the WebSocket protocol is used to encapsulate the ADB data. After encapsulation, the encapsulated debugging commands are sent to the relay server through the first connection established by the WebSocket protocol.
[0049] In one embodiment of this application, a debugging command is sent to a relay server via a first connection. The relay server, in turn, connects to a second connection to send the debugging command to the Android device to be debugged, enabling remote debugging of the device.
[0050] Specifically, after the encapsulated debugging command is sent to the relay server, the relay server connects it to the second connection, that is, to the intranet penetration TCP connection, so that the encapsulated debugging command can be sent to the Android device to be debugged through the intranet penetration TCP connection.
[0051] In one embodiment of this application, ADB data wrapped in WebSocket is extracted via a relay server. A pre-installed web service program on the relay server then re-encapsulates the extracted WebSocket-wrapped ADB data into HTTP proxy protocol data. This HTTP proxy data is then connected to an intranet-penetrating TCP connection for transmission to the Android device to be debugged.
[0052] Specifically, the relay server in this embodiment has a pre-installed web service program. This web service program is used to re-encapsulate the extracted ADB data wrapped in WebSocket into HTTP proxy protocol data. Debugging commands sent by the debugging device are encapsulated and sent to the relay server via a WebSocket connection. The relay server then re-encapsulates the debugging commands into HTTP proxy protocol data and connects them to an intranet-penetrating TCP connection to send them to the Android device to be debugged.
[0053] In one embodiment of this application, after receiving a remote debugging shutdown command, the first connection and the second connection are closed, and the corresponding debugging-related service processes are shut down.
[0054] Furthermore, upon receiving the remote debugging shutdown command, the websocket connection and the intranet-penetrating TCP connection are closed, as well as other debugging-related processes are shut down.
[0055] This application embodiment encapsulates ADB data using the WebSocket protocol, and then extracts the WebSocket-wrapped ADB data in the relay server and further encapsulates it into HTTP proxy protocol data, which is then connected to the intranet penetration relay proxy service. This application embodiment removes the ADB Server and ADBClient that need to be installed on the debugging machine in existing technologies; all encapsulation and parsing of ADB data is completed within the browser application. This not only eliminates the need for ADB tools but also improves the efficiency of collecting customer environment information and eliminates the need for on-site debugging, reducing debugging costs.
[0056] Figure 2 This is a schematic diagram illustrating a remote connection and debugging method for an Android device provided in an embodiment of this application. Figure 2 As shown, in this embodiment of the application, the encapsulation and parsing of ADB data are completed in the browser application. Since the browser cannot directly send ADB data using the ordinary TCP protocol, the WebSocket protocol is used to encapsulate the ADB data. The WebSocket-encapsulated ADB data is extracted in the relay server and then encapsulated into HTTP proxy protocol data (specifically, this is achieved by adding a WebSocket to HTTP proxy data encapsulation WEB service program in the relay server) and connected to the intranet penetration relay proxy service.
[0057] Figure 3 This is a schematic diagram illustrating the structure of an Android device remotely connecting to a debugging device, as provided in an embodiment of this application. Figure 3 As shown, the Android device remotely connects to the debugging device, including:
[0058] At least one processor; and,
[0059] A memory communicatively connected to the at least one processor; wherein,
[0060] The memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to:
[0061] Establish the first connection based on the debugging equipment and the relay server;
[0062] A second connection is established between the Android device to be debugged and the relay server;
[0063] The relay server converts the first connection and connects the converted first connection to the second connection to establish a command sending link;
[0064] The debugging device issues a debugging command, which is then sent to the Android device to be debugged via the command sending link, so as to perform remote debugging on the device to be debugged.
[0065] This application embodiment also provides a non-volatile computer storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured as follows:
[0066] Establish the first connection based on the debugging equipment and the relay server;
[0067] A second connection is established between the Android device to be debugged and the relay server;
[0068] The relay server converts the first connection and connects the converted first connection to the second connection to establish a command sending link;
[0069] The debugging device issues a debugging command, which is then sent to the Android device to be debugged via the command sending link, so as to perform remote debugging on the device to be debugged.
[0070] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, devices, and non-volatile computer storage media are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0071] The foregoing has described specific embodiments of this application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0072] The above description is merely an embodiment of this application and is not intended to limit this application. For those skilled in the art, various modifications and variations can be made to the embodiments of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the embodiments of this application should be included within the scope of the claims of this application.
Claims
1. A method for remote connection and debugging of an Android device, characterized in that, The method includes: A first connection is established based on the debugging device and the relay server; specifically, this includes: establishing a WebSocket connection between the debugging device and the relay server based on the WebSocket protocol to realize the connection between the debugging device and the relay server; wherein, the WebSocket protocol is related to the browser's web application; the WebSocket protocol is used to encapsulate ADB data, thereby removing the ADB Server and ADBClient that need to be installed on the debugging device, and all encapsulation and parsing of ADB data are completed in the browser application; A second connection is established between the Android device to be debugged and the relay server; specifically, this includes establishing an intranet penetration TCP connection between the relay server and the Android device to be debugged to realize the connection between the relay server and the Android device to be debugged. The relay server converts the first connection and connects the converted first connection to the second connection to establish a command sending link; specifically, it includes: converting the WebSocket connection into an HTTP proxy connection through the relay server and connecting the HTTP proxy connection to the intranet-penetrating TCP connection; The process of issuing debugging commands through the debugging device specifically includes: encapsulating the debugging command through the browser WEB application corresponding to the debugging device; issuing the encapsulated debugging command through the debugging device; and sending the debugging command to the Android device to be debugged based on the command sending link to remotely debug the Android device to be debugged. Specifically, this includes: sending the debugging command to the relay server through the first connection; sending the debugging command to the Android device to be debugged through the relay server and the second connection to remotely debug the Android device to be debugged. Specifically, this includes: extracting ADB data wrapped in WebSocket through the relay server; encapsulating the extracted ADB data wrapped in WebSocket into HTTP proxy protocol data again through a pre-installed WEB service program in the relay server; and connecting the HTTP proxy protocol data to an intranet-penetrating TCP connection to send it to the Android device to be debugged. After remotely debugging the Android device to be debugged, the method further includes: Upon receiving the remote debugging shutdown command, close the first connection and the second connection, and shut down the corresponding debugging-related service processes.
2. An Android device remotely connects to a debugging device, comprising: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, enables the at least one processor to perform the Android device remote connection debugging method as described in claim 1.
3. A non-volatile computer storage medium storing computer-executable instructions, said computer-executable instructions being capable of executing the Android device remote connection debugging method described in claim 1.
Citation Information
Patent Citations
Remote debugging system and method for IOT equipment, electronic equipment and storage medium
CN112187869A
Program debugging method and device and computer equipment
CN114691486A