A device debugging method and system based on remote adb running
Patent Information
- Application Number
- CN202611197388.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-07
- Publication Date
- 2026-11-03
AI Technical Summary
[0005]本发明的主要目的在于提供一种基于远程adb运行的设备调试方法及系统,旨在解决现有技术中通过adb对设备进行调试需要保证电脑与设备处于同一局域网,当不处于同一局域网时,则无法进行远程adb调试,从而导致设备无法正常工作的问题
[0016]本发明中,当接收到设备调试指令时,所述目标设备根据所述设备调试指令获取所述设备管理服务器的属性配置信息,并将所述属性配置信息发送至所述远程adb服务器;所述远程adb服务器根据所述属性配置信息生成端口配置信息,并根据所述端口配置信息建立与所述目标设备之间的反向隧道连接,得到反向加密通道;所述远程adb服务器通过所述反向加密通道对所述目标设备进行设备调试,得到设备调试结果。本发明通过建立远程adb服务器与目标设备之间的反向隧道连接,能够在不处于同一局域网的条件下,实现对目标设备准确且快速的调试。
Smart Images

Figure CN123035205A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of Internet technology, and in particular to a device debugging method and system based on remote ADB operation. Background Technology
[0002] Remote adb (Android Debug Bridge) refers to a way to allow a computer to connect to a device (such as a mobile phone, tablet, TV box, etc.) via a network (such as Wi-Fi or LAN) instead of a physical data cable and execute adb remote debugging commands. adb can generally connect to the device for debugging via USB and network.
[0003] However, in the existing technology, debugging devices via ADB requires that the computer and the device be on the same local area network. When they are not on the same local area network, remote ADB debugging cannot be performed, which will cause the device to malfunction.
[0004] Therefore, existing technologies still need to be improved and developed. Summary of the Invention
[0005] The main objective of this invention is to provide a device debugging method and system based on remote ADB operation, aiming to solve the problem in the prior art that debugging devices via ADB requires the computer and the device to be on the same local area network. When they are not on the same local area network, remote ADB debugging cannot be performed, which leads to the device not working properly.
[0006] To achieve the above objectives, the present invention provides a device debugging method based on remote ADB operation, the device debugging method based on remote ADB operation comprising the following steps: When a device debugging instruction is received, the target device obtains the attribute configuration information of the device management server according to the device debugging instruction, and sends the attribute configuration information to the remote adb server; The remote ADB server generates port configuration information based on the attribute configuration information, and establishes a reverse tunnel connection with the target device based on the port configuration information to obtain a reverse encrypted channel; The remote ADB server performs device debugging on the target device through the reverse encryption channel and obtains the device debugging results.
[0007] Optionally, the device debugging method based on remote ADB operation, wherein when a device debugging instruction is received, the target device obtains the attribute configuration information of the device management server according to the device debugging instruction, and sends the attribute configuration information to the remote ADB server, specifically includes: When a device debugging instruction is received, the target device that needs to be debugged is identified, and the device debugging instruction is sent to the target device. The target device generates an attribute configuration retrieval request according to the device debugging instructions, and sends the attribute configuration retrieval request to the device management server; The device management server searches for attribute configuration information based on the attribute configuration retrieval request, obtains the attribute configuration information, and sends the attribute configuration information to the target device; The target device determines the remote adb server based on the attribute configuration information and sends the attribute configuration information to the remote adb server.
[0008] Optionally, the device debugging method based on remote ADB operation, wherein the device management server searches for attribute configuration information according to the attribute configuration retrieval request, obtains the attribute configuration information, and sends the attribute configuration information to the target device, specifically includes: The device management server determines the current running service status based on the attribute configuration request. If the current running service status indicates that no remote program is running, then remote debugging is initiated. The device management server searches for attribute configuration information based on the attribute configuration retrieval request, obtains the attribute configuration information, and sends the attribute configuration information to the target device.
[0009] Optionally, the device debugging method based on remote ADB operation, wherein the remote ADB server generates port configuration information according to the attribute configuration information, and establishes a reverse tunnel connection with the target device according to the port configuration information to obtain a reverse encrypted channel, specifically includes: The remote ADB server generates remote debugging commands and port configuration information based on the attribute configuration information, and sends the remote debugging commands and port configuration information to the target device; The target device establishes a reverse tunnel connection with the remote adb server based on the remote debugging command and the port configuration information, thereby obtaining a reverse encrypted channel.
[0010] Optionally, the device debugging method based on remote ADB operation, wherein the remote ADB server generates remote debugging commands and port configuration information according to the attribute configuration information, and sends the remote debugging commands and the port configuration information to the target device, specifically includes: The remote adb server generates remote debugging commands and port configuration information based on the attribute configuration information, wherein the port configuration information includes the target allocated port and the SSH login key; The remote adb server sends the remote debugging command, the target allocated port, and the SSH login key to the target device.
[0011] Optionally, the device debugging method based on remote ADB operation, wherein the target device establishes a reverse tunnel connection with the remote ADB server according to the remote debugging command and the port configuration information to obtain a reverse encrypted channel, specifically includes: The target device decodes the target allocated port and the SSH login key to obtain the decoded target allocated port and decoded SSH login key; The target device determines the target dynamic library according to the remote debugging command, and searches in the target dynamic library according to the decoding target allocation port to obtain the device port corresponding to the target device; The target device establishes a reverse tunnel connection between the target allocated port in the remote adb server and the device port in the target device based on the decoded SSH login key, thereby obtaining a reverse encrypted channel.
[0012] Optionally, the device debugging method based on remote ADB operation, wherein the remote ADB server performs device debugging on the target device through the reverse encryption channel to obtain device debugging results, further includes: When the device management server receives a remote debugging shutdown command, it obtains the current running service status based on the remote debugging shutdown command. If the current running service status is determined to be remote debugging running status, then the remote debugging running status will be turned off.
[0013] Optionally, the device debugging method based on remote ADB operation, wherein if the current running service state is determined to be a remote debugging running state, then disabling the remote debugging running state specifically includes: If the device management server determines that the current running service status is remote debugging running status, then the remote debugging command will be re-executed; When the number of times the remote debugging command is executed reaches a preset number, the device debugging and adb debugging functions are turned off, the SSH login key is deleted, and the connection between the device port and the target allocated port is disconnected.
[0014] Optionally, the device debugging method based on remote ADB operation, wherein if it is determined that the current running service state is a remote debugging running state, then disabling the remote debugging running state, further includes: The device management server generates a disconnect request and sends the disconnect request to the target device, which then sends the disconnect request to the remote adb server. The remote adb server disconnects the reverse encryption channel and reclaims the target allocated port based on the disconnect request.
[0015] Furthermore, to achieve the above objectives, the present invention also provides a device debugging system based on remote ADB operation, wherein the device debugging system based on remote ADB operation includes a target device, a device management server, and a remote ADB server: The target device is configured to, upon receiving a device debugging instruction, obtain the attribute configuration information of the device management server according to the device debugging instruction, and send the attribute configuration information to the remote adb server; The remote ADB server is used to generate port configuration information based on the attribute configuration information, and to establish a reverse tunnel connection with the target device based on the port configuration information to obtain a reverse encrypted channel; The remote ADB server is used to perform device debugging on the target device through the reverse encryption channel and obtain the device debugging results.
[0016] In this invention, upon receiving a device debugging command, the target device obtains the attribute configuration information of the device management server according to the command and sends the attribute configuration information to the remote ADB server. The remote ADB server generates port configuration information based on the attribute configuration information and establishes a reverse tunnel connection with the target device based on the port configuration information, thus obtaining a reverse encrypted channel. The remote ADB server performs device debugging on the target device through the reverse encrypted channel and obtains the device debugging result. This invention, by establishing a reverse tunnel connection between the remote ADB server and the target device, enables accurate and rapid debugging of the target device even when they are not on the same local area network. Attached Figure Description
[0017] Figure 1 This is a flowchart of a preferred embodiment of the device debugging method based on remote ADB operation according to the present invention; Figure 2 This is a schematic diagram of the web page management interface of a preferred embodiment of the device debugging method based on remote ADB operation of the present invention; Figure 3 This is a schematic diagram of the port connection status of a preferred embodiment of the device debugging method based on remote adb operation of the present invention. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
[0019] Remote adb (Android Debug Bridge) refers to a way to connect a computer to a device (such as a mobile phone, tablet, TV box, etc.) via a network (such as Wi-Fi or LAN) instead of a physical data cable and execute adb remote debugging commands. adb can generally connect to the device for debugging via USB and network.
[0020] However, current technology requires that the computer and device be on the same local area network (LAN) for debugging via ADB. If they are not on the same LAN, remote ADB debugging is impossible, causing the device to malfunction. For example, when a customer's device malfunctions and requires ADB connection debugging, debugging cannot be performed because the engineer's computer and the customer's device are not on the same LAN.
[0021] To address the aforementioned issues, this invention proposes a device debugging method based on remote ADB operation. By establishing a reverse tunnel connection between the remote ADB server and the target device, accurate and rapid debugging of the target device can be achieved even when they are not on the same local area network.
[0022] The preferred embodiment of the device debugging method based on remote ADB operation described in this invention, such as... Figure 1 As shown, the device debugging method based on remote ADB operation includes the following steps: Step S10: When a device debugging instruction is received, the target device obtains the attribute configuration information of the device management server according to the device debugging instruction, and sends the attribute configuration information to the remote adb server.
[0023] This invention includes a reverse tunnel port management system (i.e., the remote adb server in this invention) and a device management system (i.e., the device management server in this invention). The reverse tunnel port management system is only responsible for managing the SSH reverse tunnel port and the remote adb connection. The device management system is used to manage various settings of the device, including notifying the device to start and stop remote debugging.
[0024] Specifically, upon receiving a device debugging instruction, the system identifies the target device requiring debugging and sends the debugging instruction to the target device. The target device generates an attribute configuration retrieval request based on the debugging instruction and sends the request to the device management server. The device management server determines the current running service status based on the attribute configuration retrieval request. If the current running service status indicates that no remote program is running, remote debugging is initiated. The device management server searches for attribute configuration information based on the attribute configuration retrieval request, obtains the attribute configuration information, and sends it to the target device. The target device identifies the remote ADB server based on the attribute configuration information and sends the attribute configuration information to the remote ADB server.
[0025] like Figure 2 As shown, for a remote ADB server, first run `ssh_tunnel_manager_v2`, which provides a web-based management interface. `ssh_tunnel_manager_v2` is a "reverse tunnel port management system" built on the server. Written in Python, it primarily manages reverse tunnel connections to devices. Engineers can use this system to view information about currently connected devices, including but not limited to device ID, LAN IP address, public IP address, and port number. By obtaining the corresponding device's port number from this interface, you can use ADB commands on the "reverse tunnel port management system" server to connect to the device for debugging.
[0026] The port allocation process is as follows: 1. The device (i.e., the target device) will send the device ID and local area network IP (i.e., the attribute configuration information of the device management server) to the "reverse tunnel port management" system server (i.e., the remote adb server) through an HTTP POST request (i.e., the port allocation POST interface request in this invention) to apply for an "adb reverse tunnel" port (wherein, the device ID and local area network IP are generated by the device management server). 2. The "Reverse Tunnel Port Management System" server will return the allocated port (i.e., the target allocated port in this invention) and the SSH login key to the target device. 3. Once the device obtains the port number and SSH key, it can start the SSH client (i.e., the target device) to establish a reverse tunnel connection with the "Reverse Tunnel Port Management System" server (i.e., the remote ADB server); 4. After a successful connection, the connection status and information of the corresponding device can be viewed in the backend management interface of the "Reverse Tunnel Port Management System" server.
[0027] The code process for port allocation is as follows: POST / api / allocate Content-Type: application / json { "device_id": "my_device_001", # Please use the device's UID "device_ip": "192.168.1.100"# Device's internal network IP } Response data { "success": true, "port": 10000 Message: "Port 10000 successfully allocated. Please establish an SSH connection within 10 minutes." "device_id": "my_device_001", "tunnel_key_url": " / api / download / tunnel_key", "tunnel_key": "base64 encoded key content" }
[0028] Furthermore, the target device and the "Device Management System" server (i.e., the device management server) will have a configuration update every 15 minutes. The device (i.e., the target device) will actively obtain the configuration data from the "Device Management System" server via an HTTP request. When the device obtains the configuration data and requests remote debugging, it will initiate the aforementioned port application and SSH reverse tunnel connection with the "Reverse Tunnel Port Management System" server.
[0029] The target device periodically receives configuration (i.e., attribute configuration information) from the "Device Management System" server. The configuration includes the following attributes: debug: true / false # Whether to enable remote adb debug_server: XXXX:5000# Remote ADB server address debug_port: 5555# Device-side ADB port debug_connect_timeout: 10# SSH connection timed out debug_connect_attempts: 3# Number of SSH connection attempts debug_alive_interval: 15# SSH heartbeat interval debug_alive_max_count: 2#Maximum number of SSH heartbeat packets.
[0030] Furthermore, when the debug value is true (i.e., when a remote debugging instruction is received), the system needs to determine whether the debug service is currently running. If it is not running, the debug service is started, and all the above attributes are passed to the debug service (i.e., the device management server determines the current running service status based on the attribute configuration request; if the current running service status is determined to be that no remote program is running, then remote debugging is started).
[0031] The specific process for determining whether the debug service is currently running is as follows: The device system (i.e., the device management server) obtains all running services through the ActivityManager.RunningServiceInfo command and compares them to see if there is a service named "com.clap.debug.service.DebugForegroundService". If so, it means that the debug service is running.
[0032] Step S20: The remote adb server generates port configuration information based on the attribute configuration information, and establishes a reverse tunnel connection with the target device based on the port configuration information to obtain a reverse encrypted channel.
[0033] Specifically, the remote ADB server generates remote debugging commands and port configuration information based on the attribute configuration information, wherein the port configuration information includes a target allocated port and an SSH login key; the remote ADB server sends the remote debugging commands, the target allocated port, and the SSH login key to the target device; the target device decodes the target allocated port and the SSH login key to obtain a decoded target allocated port and a decoded SSH login key; the target device determines the target dynamic library based on the remote debugging commands and searches within the target dynamic library based on the decoded target allocated port to obtain the device port corresponding to the target device; the target device establishes a reverse tunnel connection between the target allocated port in the remote ADB server and the device port in the target device based on the decoded SSH login key, thus obtaining a reverse encrypted channel.
[0034] The remote server pre-maintains a device information mapping data table. This table stores the unique device ID, real-time reported LAN IP address, device hardware identifier, and device operating status data for each connected terminal. Upon receiving a remote debugging trigger command from the upper-layer management platform, the remote ADB server retrieves the binding relationships within the matching data table, locates the unique device entry based on the device ID carried in the request, and retrieves the real-time reported LAN IP address of that entry. It then automatically assembles and generates the corresponding remote debugging command and associated configuration information based on a preset port allocation policy and SSH security authentication rules. The configuration information module is divided into network access parameters and identity verification credentials. The network access parameters are target allocated ports dynamically allocated from the port pool and not occupied by local processes. The identity verification credentials are a time-sensitive SSH login key generated in real-time using an asymmetric encryption algorithm. This key is bound to the lifetime of the current debugging session and automatically expires after a single debugging session, mitigating the access risks associated with long-term key leakage.
[0035] Furthermore, the remote adb server transmits the encapsulated and encrypted remote debugging commands, target allocation port parameter fields, and SSH login key encrypted data packets to the target device located in the local area network environment through an encrypted TCP communication channel. The data transmission process adopts a message checksum verification mechanism. After receiving the message, the target device first performs data packet integrity verification, and extracts various encrypted field data from the data packet if the verification is correct.
[0036] Furthermore, the target device has a built-in dedicated decryption and parsing module that calls a locally preset symmetric decryption key to sequentially decode the target allocation port and SSH login key in ciphertext form, stripping away the encrypted encapsulation format and redundant verification data, accurately parsing out the target allocation port and SSH login key in plaintext state, and simultaneously performing format validity verification on the parsing results. If the port value exceeds the valid port range or the key format does not conform to the preset standard, the current debugging message is directly discarded and the abnormal log is reported upwards.
[0037] After the target device parses the legitimate plaintext data, it first parses the instruction identifier, running parameters, and call path fields in the remote debugging command. Based on the instruction identifier, it matches the local dynamic library index list to accurately locate the target dynamic library file that needs to be loaded and run for this debugging service. Then, it reads the decoded target's allocated port value, uses this port value as a search index, and traverses the port-device port mapping table stored inside the target dynamic library. After field comparison and address matching search operations, it finally retrieves the dedicated device port (i.e., device port) specifically allocated to the current target device for adb remote communication interaction in the device management server. This provides an accurate port addressing basis for subsequently establishing an adb remote debugging link and SSH secure tunnel connection.
[0038] The debugging process for the device management server is as follows: 1. When the system invokes this debugging service, it will simultaneously pass in all debug-related attributes (which are returned by the "Device Management System" server to the device, and are obtained by the device actively initiating a request every 15 minutes). 2. The service starts a thread and executes the following steps in sequence: a. Configure system properties to enable system network adb.
[0039] The startup process is as follows: simply run the following two commands on the device to start the adb service. Then the device will listen on its own port 5555 to identify whether a computer is making an adb connection. Otherwise, even if an SSH reverse tunnel connection is established, the device will reject all adb connections.
[0040] b. Request a server port (target port) via the port allocation API. Note that the IP address must come from the IP address of the network interface card corresponding to the current default router. The code representation is as follows: POST / api / allocate Content-Type: application / json { "device_id": "my_device_001", # Please use the device's UID "device_ip": "192.168.1.100"# Device's internal network IP }
[0041] c. Decode the tunnel_key (i.e., the SSH login key) in the returned data using base64 encoding (decoding is standard base64 encoding; base64 encoding is used to convert data into characters for easier transmission in JSON data format) and store it in a local file. It is recommended to store it in the runtime environment directory in the next step for subsequent SSH connections.
[0042] d. Open a command-line environment and run the following command. The environment directory refers to the directory where all the .so files are stored in the APK after installation. The tunnel_key file is the file downloaded to the local machine in the previous step. The code for steps c and d is represented as follows: Runtime environment directory &&LD_LIBRARY_PATH=. / . / ssh -i . / tunnel_key -oConnectTimeout=ssh connection timeout -o ServerAliveInterval=ssh heartbeat interval -oServerAliveCountMax=ssh heartbeat maximum number -o StrictHostKeyChecking=no -oUserKnownHostsFile= / dev / null -N -v -R server port:device internal IP:device adb port root@adb server IP For example: / data / data / com.clap.debug / files&&LD_LIBRARY_PATH=. / . / ssh -i . / tunnel_key -o ConnectTimeout=10 -o ServerAliveInterval=15 -oServerAliveCountMax=2 -o StrictHostKeyChecking=no -o UserKnownHostsFile= / dev / null -N -v -R 10000:192.168.60.130:5555 root@xxx.xxx.xxx.xxx.
[0043] The specific meaning of step d is as follows: Switch the current running directory to the ` / data / data / com.clap.debug / files` directory, and run the `ssh` command to establish a reverse tunnel connection. The `ssh` command will first search for dynamic libraries in this directory, and then in the system directory. Use the `tunner_key` file in this directory as the key for SSH connection to the server. Set the connection timeout to 10 seconds, the heartbeat interval after the connection is established to 15 seconds, and allow a maximum of 2 failed heartbeats. Establish a reverse encrypted tunnel between server port 10000 and device port 5555. The server IP is `xxx.xxx.xxx.xxx`, and the username is `root`.
[0044] The target device establishes a reverse tunnel connection between the target allocated port in the remote adb server and the device port in the device management server based on the decoded SSH login key, thereby obtaining a reverse encrypted channel.
[0045] Understandably, the port connection establishes a reverse encrypted tunnel via SSH. This allows data sent from the "Reverse Tunnel Port Management System" server to the assigned port to be forwarded through the encrypted tunnel to the associated device's ADB port (default 5555). Thus, when running ADB commands on the server to connect to the device, all data sent is forwarded to the device's port 5555. Similarly, the device's response to port 5555 is forwarded back to the corresponding port on the "Reverse Tunnel Port Management System" via the encrypted tunnel. This establishes the ADB connection. The encrypted forwarding of the data is transparent to both the device and the "Reverse Tunnel Port Management System" server's ADB.
[0046] Step S30: The remote adb server performs device debugging on the target device through the reverse encryption channel and obtains the device debugging results.
[0047] When the device management server receives a remote debugging shutdown command, it obtains the current running service status according to the remote debugging shutdown command. If the device management server determines that the current running service status is a remote debugging running status, it re-executes the remote debugging command. When the number of times the remote debugging command is executed reaches a preset number, it sets the device debugging and disables the adb debugging function, deletes the SSH login key, and disconnects the connection between the device port and the target allocated port.
[0048] When the debug command is received as false (shutdown), the system needs to determine if the debug service is already running. If it is, the debug service should be shut down. Shutting down the debug service should allow it to exit normally on its own, rather than being forcibly killed. Ideally, a forced kill should only be performed when the debug service cannot shut down normally on its own. For example, if a normal shutdown was initiated after receiving a debug command as false, but the debug service is still running when the debug command is received again as false, a forced kill can be performed in this case.
[0049] The process of forcibly killing the service is as follows: The Android system provides a code interface for stopping services. Normally, it calls the normal service stop function. To forcibly kill the service, you may use the following command: am force-stop com.clap.debug.service.DebugForegroundService.
[0050] Furthermore, under normal circumstances, the above command execution environment will not exit until the server disconnects. When the above execution environment exits, you need to immediately try running the command again. The maximum number of attempts is debug_connect_attempts times (to cope with unstable network connections, this value is usually set to 3. When the SSH connection is disconnected for various reasons, the device will retry according to this value).
[0051] Furthermore, when the command execution environment reaches the maximum number of attempts and exits, the following properties need to be set, and the originally stored tunnel_key file needs to be deleted.
[0052] Furthermore, the process of calling the disconnect port connection is as follows: when the service receives the shutdown command initiated by the system, it only needs to call the disconnect port connection API. At this time, the service's running command environment will enter the connection attempt process until it completely exits.
[0053] Furthermore, the device management server generates a disconnect request and sends the disconnect request to the target device, which then sends the disconnect request to the remote adb server. The remote adb server disconnects the reverse encryption channel according to the disconnect request and reclaims the target allocated port.
[0054] When the device receives a request from the "Device Management System" server to stop remote debugging, it will simultaneously send this HTTP request to the remote ADB server to disconnect the SSH reverse tunnel connection and reclaim the allocated port.
[0055] The code that disconnects the port connection to the API is as follows: POST / api / disconnect Content-Type: application / json { "port": 10000 "device_id": "my_device_001 }
[0056] like Figure 3 As shown, in the specific implementation process, the workflow for operations and maintenance personnel to use remote adb is as follows: 1. Enable remote ADB on a specified machine through the management backend and set the IP address of the remote ADB server it needs to connect to; 2. Open the management webpage corresponding to the adb server: http: / / IP:5000 / ; 3. Wait for the corresponding device to appear on the management page and be in a connected state (it may take up to 15 minutes to connect); 4. Log in to the adb server via SSH (the "Reverse Tunnel Port Management System" server with Ubuntu installed; you can log in using the SSH command, formatted as follows:) To SSH into the server's IP address, enter the above command in the Linux system's terminal; it will prompt you for a username and password. 5. Use the adb connect command to connect to the specified device. The port in the command is the port number of the corresponding device that you can see on the management page: adb connect 127.0.0.1:port.
[0057] 6. If you want to push related files to the device, you can use WinSCP to push the files to the ADB server first, and then use ADB commands to push them to the device. The rest of the usage is exactly the same as local ADB.
[0058] This invention allows engineers to debug customer equipment as conveniently as in the office, enabling them to locate and resolve problems more quickly than traditional log analysis, and rapidly improve product stability.
[0059] Furthermore, based on the above-mentioned device debugging method based on remote ADB operation, the present invention also provides a device debugging system based on remote ADB operation, wherein the device debugging system based on remote ADB operation includes a target device, a device management server, and a remote ADB server. The target device is configured to, upon receiving a device debugging instruction, obtain the attribute configuration information of the device management server according to the device debugging instruction, and send the attribute configuration information to the remote adb server; The remote ADB server is used to generate port configuration information based on the attribute configuration information, and to establish a reverse tunnel connection with the target device based on the port configuration information to obtain a reverse encrypted channel; The remote ADB server is used to perform device debugging on the target device through the reverse encryption channel and obtain the device debugging results.
[0060] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
Claims
1. A device debugging method based on remote ADB operation, characterized in that, The device debugging method based on remote ADB operation is applied to a device debugging system based on remote ADB operation, which includes a target device, a device management server, and a remote ADB server. The device debugging method based on remote ADB operation includes: When a device debugging instruction is received, the target device obtains the attribute configuration information of the device management server according to the device debugging instruction, and sends the attribute configuration information to the remote adb server; The remote ADB server generates port configuration information based on the attribute configuration information, and establishes a reverse tunnel connection with the target device based on the port configuration information to obtain a reverse encrypted channel; The remote ADB server performs device debugging on the target device through the reverse encryption channel and obtains the device debugging results.
2. The device debugging method based on remote ADB operation according to claim 1, characterized in that, When a device debugging command is received, the target device obtains the attribute configuration information of the device management server according to the device debugging command, and sends the attribute configuration information to the remote adb server, specifically including: When a device debugging instruction is received, the target device that needs to be debugged is identified, and the device debugging instruction is sent to the target device. The target device generates an attribute configuration retrieval request according to the device debugging instructions, and sends the attribute configuration retrieval request to the device management server; The device management server searches for attribute configuration information based on the attribute configuration retrieval request, obtains the attribute configuration information, and sends the attribute configuration information to the target device; The target device determines the remote adb server based on the attribute configuration information and sends the attribute configuration information to the remote adb server.
3. The device debugging method based on remote ADB operation according to claim 2, characterized in that, The device management server searches for attribute configuration information based on the attribute configuration retrieval request, obtains the attribute configuration information, and sends the attribute configuration information to the target device, specifically including: The device management server determines the current running service status based on the attribute configuration request. If the current running service status indicates that no remote program is running, then remote debugging is initiated. The device management server searches for attribute configuration information based on the attribute configuration retrieval request, obtains the attribute configuration information, and sends the attribute configuration information to the target device.
4. The device debugging method based on remote ADB operation according to claim 3, characterized in that, The remote ADB server generates port configuration information based on the attribute configuration information, and establishes a reverse tunnel connection with the target device based on the port configuration information to obtain a reverse encrypted channel, specifically including: The remote ADB server generates remote debugging commands and port configuration information based on the attribute configuration information, and sends the remote debugging commands and port configuration information to the target device; The target device establishes a reverse tunnel connection with the remote adb server based on the remote debugging command and the port configuration information, thereby obtaining a reverse encrypted channel.
5. The device debugging method based on remote ADB operation according to claim 4, characterized in that, The remote ADB server generates remote debugging commands and port configuration information based on the attribute configuration information, and sends the remote debugging commands and port configuration information to the target device, specifically including: The remote adb server generates remote debugging commands and port configuration information based on the attribute configuration information, wherein the port configuration information includes the target allocated port and the SSH login key; The remote adb server sends the remote debugging command, the target allocated port, and the SSH login key to the target device.
6. The device debugging method based on remote ADB operation according to claim 5, characterized in that, The target device establishes a reverse tunnel connection with the remote adb server based on the remote debugging command and the port configuration information, thereby obtaining a reverse encrypted channel, specifically including: The target device decodes the target allocated port and the SSH login key to obtain the decoded target allocated port and decoded SSH login key; The target device determines the target dynamic library according to the remote debugging command, and searches in the target dynamic library according to the decoding target allocation port to obtain the device port corresponding to the target device; The target device establishes a reverse tunnel connection between the target allocated port in the remote adb server and the device port in the target device based on the decoded SSH login key, thereby obtaining a reverse encrypted channel.
7. The device debugging method based on remote ADB operation according to claim 6, characterized in that, The remote ADB server performs device debugging on the target device through the reverse encryption channel, obtains the device debugging results, and then further includes: When the device management server receives a remote debugging shutdown command, it obtains the current running service status based on the remote debugging shutdown command. If the current running service status is determined to be remote debugging running status, then the remote debugging running status will be turned off.
8. The device debugging method based on remote ADB operation according to claim 7, characterized in that, If the current running service status is determined to be a remote debugging running status, then the remote debugging running status will be turned off, specifically including: If the device management server determines that the current running service status is remote debugging running status, then the remote debugging command will be re-executed; When the number of times the remote debugging command is executed reaches a preset number, the device debugging and adb debugging functions are turned off, the SSH login key is deleted, and the connection between the device port and the target allocated port is disconnected.
9. The device debugging method based on remote ADB operation according to claim 7, characterized in that, If the current running service status is determined to be a remote debugging running status, then the remote debugging running status is turned off, and the process further includes: The device management server generates a disconnect request and sends the disconnect request to the target device, which then sends the disconnect request to the remote adb server. The remote adb server disconnects the reverse encryption channel and reclaims the target allocated port based on the disconnect request.
10. A device debugging system based on remote ADB operation, characterized in that, The device debugging system based on remote ADB operation is used to implement the device debugging method based on remote ADB operation as described in any one of claims 1-9. The device debugging system based on remote ADB operation includes: a target device, a device management server, and a remote ADB server. The target device is configured to, upon receiving a device debugging instruction, obtain the attribute configuration information of the device management server according to the device debugging instruction, and send the attribute configuration information to the remote adb server; The remote ADB server is used to generate port configuration information based on the attribute configuration information, and to establish a reverse tunnel connection with the target device based on the port configuration information to obtain a reverse encrypted channel; The remote ADB server is used to perform device debugging on the target device through the reverse encryption channel and obtain the device debugging results.
