WO2015158219A1 - Remote debugging method and apparatus for mobile terminal - Google Patents

Remote debugging method and apparatus for mobile terminal Download PDF

Info

Publication number
WO2015158219A1
WO2015158219A1 PCT/CN2015/076323 CN2015076323W WO2015158219A1 WO 2015158219 A1 WO2015158219 A1 WO 2015158219A1 CN 2015076323 W CN2015076323 W CN 2015076323W WO 2015158219 A1 WO2015158219 A1 WO 2015158219A1
Authority
WO
WIPO (PCT)
Prior art keywords
mobile terminal
server
data channel
connection identifier
port
Prior art date
Application number
PCT/CN2015/076323
Other languages
French (fr)
Inventor
Liang Fang
Peng Wang
Dejun Zhang
Dawei Sun
Original Assignee
Tencent Technology (Shenzhen) Company Limited
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology (Shenzhen) Company Limited filed Critical Tencent Technology (Shenzhen) Company Limited
Publication of WO2015158219A1 publication Critical patent/WO2015158219A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W24/00Supervisory, monitoring or testing arrangements
    • H04W24/02Arrangements for optimising operational condition

Definitions

  • the present disclosure relates to the field of mobile communications, and in particular, to a remote debugging method and apparatus for a mobile terminal.
  • Remote debugging is debugging, by using a debugging client running on a machine A, an application program running on a remote machine B, for example, debugging, by using a debugging client running on a personal computer (PC), an application program running on a mobile terminal (such as a smartphone), where the mobile terminal is not directly inserted into the PC.
  • PC personal computer
  • a mobile terminal such as a smartphone
  • a program development engineer often needs to deploy a program on a server (sometimes, joint debugging is limited by a source IP of another party, or an application program sometimes must runs on a specific machine), and a source code is local.
  • the program development engineer is generally used to debugging by using a log, and when having no alternative, the program development engineer may run a proxy on the server to solve a problem of limitation of the source IP, so as to debug locally in an integrated development environment (IDE).
  • IDE integrated development environment
  • An existing remote debugging method for a mobile terminal is: connecting a mobile terminal to a PC in a wireless manner, where during connection, the mobile terminal is connected to the PC in a TCP manner; and starting, by the mobile terminal, a port 5555, to implement remote debugging by exposing the port to an end user.
  • the mobile terminal is connected to the PC in a wireless manner, such as WiFi
  • a remote debugging method has the following defects: on one hand, during remote debugging, a WiFi module needs to be used for performing a simulation test about a network (for example, changing a network speed or a packet loss rate), which affects remote debugging; on the other hand, when multiple mobile terminals are connected to WiFi to perform massive data volume transmission simultaneously, a wireless connection is unstable, and a transmission speed is sometimes fast and sometimes slow, which affects normal use of functions.
  • Embodiments of the present invention provide a remote debugging method and apparatus for a mobile terminal, to create a good debugging environment, so that remote debugging is performed normally and smoothly.
  • An embodiment of the present invention provides a remote debugging method for a mobile terminal, including:
  • USB universal serial bus
  • TCP Transmission Control Protocol
  • Another embodiment of the present invention provides a remote debugging apparatus for a mobile terminal, including:
  • an identification module configured to identify a mobile terminal inserted into a USB port of a server, the server establishing a TCP connection to a PC by using a socket port;
  • an establishment module configured to establish a mapping relationship between the socket port and the USB port
  • a forwarding module configured to forward data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
  • a mobile terminal is directly inserted into a USB port of a server, and a user data channel obtained according to a mapping relationship is used for forwarding data, that is, a user performs remote debugging on the mobile terminal from a side of a PC through the user data channel.
  • a connection in the method of the present disclosure is more reliable, and a debugging environment is more stable.
  • the server establishes a TCP connection to the PC, and there is a mapping relationship between a socket port and the USB port, for a user, the mobile terminal is "inserted" into the PC of the user, and the user can debug the mobile terminal on a side of the server by using various tools that can be used on the PC, which provides great convenience for the user to debug the mobile terminal, so that remote debugging is performed easily.
  • FIG. 1 is a basic schematic flowchart of a remote debugging method for a mobile terminal according to an embodiment of the present invention
  • FIG. 2 is a schematic flowchart of authenticating, by a server, an Android mobile terminal inserted into a USB port of the server according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a user interface, which can be seen by a user from a side of a PC, of an Android mobile terminal after the Android mobile terminal is inserted into the server according to an embodiment of the present invention
  • FIG. 4 is a schematic flowchart of establishing a private data channel between a server and a mobile terminal according to an embodiment of the present invention
  • FIG. 5 is a schematic diagram of connecting a logical module 1 in a mobile terminal to a logical module 2 in a server by using an established private data channel according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to an embodiment of the present invention
  • FIG. 7 is a schematic diagram showing that an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal according to an embodiment of the present invention
  • FIG. 8 is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • FIG. 9 is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • FIG. 10-a is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • FIG. 10-b is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • FIG. 10-c is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • FIG. 11-a is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • FIG. 11-b is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • FIG. 11-c is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
  • An embodiment of the present invention provides a remote debugging method for a mobile terminal.
  • the method includes: identifying a mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port; establishing a mapping relationship between the socket port and the USB port; and forwarding data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
  • An embodiment of the present invention further provides a corresponding remote debugging apparatus for a mobile terminal. Descriptions are separately made below in detail.
  • the remote debugging method for a mobile terminal may be applied to a server in a system using a client/server (C/S) architecture, and may be executed by the server or a functional module, such as an AdbHooker process module in the server; a mobile terminal may be a mobile terminal whose operating system is Android, such as a smartphone whose operating system is Android.
  • the remote debugging method for a mobile terminal provided in this embodiment of the present invention is described below by using an example in which the mobile terminal is an Android mobile terminal, and for a basic procedure of the method, reference may be made to FIG. 1.
  • the basic process mainly includes step S101 to step S103, and detailed descriptions are as follows:
  • S101 Identify a mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port.
  • an AdbHooker process module may traverse, by invoking an adb drive layer method, Android mobile terminals currently inserted into the server, acquire sequence numbers of the Android mobile terminals, when identifying a sequence number of a to-be-connected Android mobile terminal, store a USB handle of the Android mobile terminal, enable input and output, and prepare for authentication.
  • the server establishes the TCP connection to the PC by using the socket port.
  • an Adbh process which is used by a user for debugging, in the PC establishes the TCP connection to an AdbHooker process in the server by using the socket port.
  • the user can transmit a command required for debugging from the PC to the server through the TCP connection by using an Adb.
  • the Android mobile terminal may pop up an authentication prompt box, to ask a user whether to debug the currently inserted Android mobile terminal by using the PC.
  • the PC may only be connected to the Android mobile terminal after it is confirmed that the currently inserted Android mobile terminal is debugged by using the PC.
  • the method further includes authenticating the Android mobile terminal inserted into the USB port of the server.
  • An authentication process is shown in FIG. 2, and includes step S201 to step S209:
  • S201 A server sends CONN to an Android mobile terminal.
  • CONN that is, a connection request is sent by an AdbHooker process module to the Android mobile terminal, from the perspective of the Android mobile terminal, the connection request comes from a PC on a side of the user.
  • S202 The Android mobile terminal generates a token.
  • S203 The Android mobile terminal sends the token to the server.
  • An objective of sending the token to the server by the Android mobile terminal is to require the server to use the token to provide a key.
  • S204 The server signs a key by using the token.
  • S205 The server sends the key to the Android mobile terminal.
  • the key sent by the server to the Android mobile terminal is a key signed by using a token previously sent by the Android mobile terminal to the server.
  • the Android mobile terminal If the Android mobile terminal does not find, at a local end, a key that can match the key sent in step S205, the Android mobile terminal requests the server to send a new key.
  • the server generates the new key according to the request sent by the Android mobile terminal.
  • S208 The server requests authentication of the Android mobile terminal.
  • the Android mobile terminal returns device information of the Android mobile terminal to the server.
  • the Android mobile terminal After finding, at the local end, a key that can match the new key, the Android mobile terminal accepts the connection request to connect, and returns the device information of the Android mobile terminal to the server.
  • the foregoing disadvantages existing in the debugging whitelist mechanism in the remote debugging method for an Android mobile terminal provided in the existing technology can be effectively avoided, that is, when the AdbHooker process module is connected to the Android mobile terminal, authentication on the Android mobile terminal is completed, and when the PC sends the connection request CONN, the AdbHooker process module directly returns, to the PC, a response to the connection request CONN and the device information of the Android mobile terminal. In this way, the PC of the user can be directly connected to the Android mobile terminal successfully, thereby solving the problems existing in the debugging whitelist mechanism in the existing technology.
  • the establishing a mapping relationship between the socket port and the USB port includes the following step S1021 to step S1023:
  • S1021 Start the socket port to establish a connection to the PC.
  • the AdbHooker process module starts a socket port, and waits for the user to connect to the socket port from a side of the PC. For example, the user sends a command "adb connect address: port" from a side of the PC, to establish a connection between the PC and the server.
  • the user After the connection between the server and the PC is established, the user sends the device connection command to the server by using the adb on the side of the PC, and the server receives the device connection command sent by the PC, where the device connection command indicates that the user wants to connect the PC to the Android mobile terminal.
  • S1023 Send the device information of the Android mobile terminal to the PC.
  • the server has completed authentication on the Android mobile terminal. After receiving the device connection command sent by the PC, the server may send the device information of the Android mobile terminal to the PC. Once the PC receives the device information of the Android mobile terminal sent by the server, the user considers that the PC is successfully connected to the Android mobile terminal. In this case, the mapping relationship between the socket port and the USB port is established.
  • S103 Forward data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
  • Establishing the mapping relationship between the socket port and the USB port means establishing a user data channel between the PC and the server. Subsequently, data (including an adb command line) sent by the PC only needs to be sent to the Android mobile terminal through the USB port, or data (except a message on a private data channel) received through the USB port may be sent to the PC. All of the data is transmitted through the user data channel.
  • the Android mobile terminal in this case is "inserted" into a currently operated PC, and the user can see a user interface of an Android mobile terminal exemplified in FIG. 3 and perform corresponding operations.
  • the user may operate the Android mobile terminal by using an adb command, or may debug an application in the Android mobile terminal by using a tool such as Eclipse or MonkeyRunner.
  • the user may further have other requirements, for example, the user may hope to see a screen image of the Android mobile terminal, and in this case, the screen image of the Android mobile terminal needs to be transmitted to the PC by using the server, to be displayed to the user.
  • the screen image of the Android mobile terminal needs to be transmitted to the PC by using the server, to be displayed to the user.
  • a private data channel needs to be established between the server and the Android mobile terminal, and a procedure of establishing the private data channel between the server and the Android mobile terminal is shown in FIG. 4. In the procedure exemplified in FIG.
  • parameters local_id thereof are used for identifying senders or/and generators of the commands, data, or the like
  • parameters remote_id are used for identifying receivers or/and processors of the commands, data, or the like.
  • the procedure exemplified in FIG. 4 is described below in detail, and mainly includes step S401 to step S405.
  • S401 The server sends an OPEN (local_id, remote_id, cmd) command to the Android mobile terminal.
  • OPEN local_id, remote_id, cmd
  • a parameter local_id of the OPEN command sent by the server to the Android mobile terminal is further used for identifying a sender or/and a generator, that is, the server, of the OPEN command
  • a parameter remote_id is used for identifying a receiver or/and a processor, that is, the Android mobile terminal, of the OPEN command.
  • a value of the parameter remote_id is 0, and cmd is a specific execution action of an operation in the OPEN command.
  • the Android mobile terminal returns a READY (local_id, remote_id) response message to the server.
  • a parameter local_id of the READY response message returned by the Android mobile terminal to the server is used for identifying a sender or/and a generator, that is, the Android mobile terminal, of the READY response message, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the server, of the READY response message.
  • a value of the parameter remote_id of the READY response message should be equal to a value of the parameter local_id of the OPEN command.
  • S403 The server sends a WRITE (local_id, remote_id, data) command to the Android mobile terminal.
  • a parameter local_id of the WRITE (local_id, remote_id, data) command sent by the server to the Android mobile terminal is used for identifying a sender or/and a generator, that is, the server, of the WRITE command, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the Android mobile terminal, of the WRITE command.
  • a value of the parameter local_id of the WRITE command should be equal to the value of the parameter remote_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
  • a value of the parameter remote_id of the WRITE command should be equal to the value of the parameter local_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
  • S404 The Android mobile terminal returns a READY (local_id, remote_id) response message to the server.
  • meanings of parameters local_id and remote_id of the READY (local_id, remote_id) response message returned by the Android mobile terminal to the server are respectively the same as meanings of the parameters local_id and remote_id of the READY (local_id, remote_id) response message returned by the Android mobile terminal to the server in step S402.
  • a difference only lies in that the response message returned in this step is a response to the WRITE command sent by the server to the Android mobile terminal. Therefore, the meanings of the parameters of the READY response message are not described again.
  • data is bidirectionally written between the Android mobile terminal and the server, that is, the Android mobile terminal may also write data to the server, and the server may also return a response message to the Android mobile terminal, as described in step S'403 and step S'404.
  • the Android mobile terminal sends a WRITE (local_id, remote_id, data) command to the server.
  • WRITE local_id, remote_id, data
  • a parameter local_id of the WRITE command sent by the Android mobile terminal to the server is used for identifying a sender or/and a generator, that is, the Android mobile terminal, of the WRITE command, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the server, of the WRITE command.
  • a value of the parameter local_id of the WRITE command should be equal to the value of the parameter local_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server
  • a value of the parameter remote_id of the WRITE command should be equal to the value of the parameter remote_id in the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
  • S'404 The server returns a READY (local_id, remote_id) response message to the Android mobile terminal.
  • a parameter local_id of the READY response message sent by the server to the Android mobile terminal is used for identifying a sender or/and a generator, that is, the server, of the READY response message
  • a parameter remote_id is used for identifying a receiver or/and a processor, that is, the Android mobile terminal, of the READY response message.
  • a value of the parameter local_id of the READY response message should be equal to the value of the parameter local_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
  • a value of the parameter remote_id of the READY response message should be equal to the value of the parameter remote_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
  • S405 The server sends a CLOSE (local_id, remote_id) command to the Android mobile terminal.
  • FIG. 5 is a schematic diagram of connecting a logical module 1 in an Android mobile terminal to a logical module 2 in a server by using an established private data channel.
  • connection identifiers are used for identifying the private data channel and the user data channel, for example, the private data channel is identified by using a first connection identifier, and the user data channel is identified by using a second connection identifier, where both the first connection identifier and the second connection identifier are indicated by numbers.
  • a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
  • the "being much greater than” means that: once it is determined that the first connection identifier is indicated by a fixed number, in consideration of a value of the fixed number, in a practical application, if the number for indicating the second connection identifier increases as the number of user data channels increases, a value of the number for indicating the second connection identifier does not reach or exceed a value of the number for indicating the first connection identifier however large the value of the number for indicating the second connection identifier becomes, in which manner it may be avoided that a value of the first connection identifier (indicated by local_id) is equal to a value of the second connection identifier (indicated by local_id), so that the private data channel is effectively distinguished from the user data channel (which can both be indicated by local_id).
  • an embodiment of the present invention further provides a method for distinguishing the private data channel from the user data channel, that is, after the private data channel between the server and the Android mobile terminal is established, corresponding connection identifiers are regenerated according to sources of establishment requests for establishing the private data channel and the user data channel, a regenerated connection identifier corresponding to the private data channel is mapped to a third connection identifier, and a regenerated connection identifier corresponding to the user data channel is mapped to a fourth connection identifier.
  • the server can know, according to the mapping relationship, that the data is from the private data channel established between the server and the Android mobile terminal.
  • the server can know, according to the mapping relationship, that the data is from the user data channel established between the server and the PC.
  • an Android mobile terminal is directly inserted into a USB port of a server, and a user data channel obtained according to a mapping relationship is used for forwarding data, that is, a user performs remote debugging on the Android mobile terminal from a side of a PC through the user data channel.
  • a connection in the method in the present disclosure is more reliable, and a debugging environment is more stable.
  • the server establishes a TCP connection to the PC, and there is a mapping relationship between a socket port and the USB port, for a user, the Android mobile terminal is "inserted" into the PC of the user, and the user can debug the Android mobile terminal on a side of the server by using various tools that can be used on the PC, which provides great convenience for the user to debug the Android mobile terminal, so that remote debugging is performed easily.
  • the remote debugging apparatus for an Android mobile terminal that is provided in an embodiment of the present invention and is used to perform the foregoing remote debugging method for an Android mobile terminal is described below, and for a basic logical structure of the apparatus, reference is made to FIG. 6. For ease of description, only content related to this embodiment of the present invention is shown.
  • the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6 may be a server for performing remote debugging on an Android mobile terminal or a functional module, such as an AdbHooker process module in the server.
  • the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6 mainly includes an identification module 601, an establishment module 602, and a forwarding module 603. The modules are described in detail as follows:
  • the identification module 601 is configured to identify an Android mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port.
  • the establishment module 602 is configured to establish a mapping relationship between the socket port and the USB port.
  • the forwarding module 603 is configured to forward data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
  • the identification module may be hardware, such as a recognizer, for identifying the Android mobile terminal inserted into the USB port of the server, or may be a general processor or another hardware device that can execute a corresponding computer program so as to implement the foregoing functions.
  • the forwarding module may be hardware, such as a forwarder, for implementing the function of forwarding the data on the socket port to the USB port and the data on the USB port to the socket port through the user data channel obtained according to the mapping relationship, or may be a general processor or another hardware device that can execute a corresponding computer program so as to implement the foregoing functions (the foregoing description rules can be applied to all of the embodiments provided in the specification).
  • the identification module 601 identifying an Android mobile terminal, the establishment module 602 establishing a mapping relationship, and the forwarding module 603 forwarding data are all performed by the AdbHooker process module.
  • an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal, that is, the AdbHooker process module uses a multi-threaded process design, and each AdbHooker process module is only connected to one Android mobile terminal, as shown in FIG. 7.
  • adbmgr is responsible for managing the Android mobile terminal inserted into the server, and after the Android mobile terminal is inserted into the server, adbmgr is the first to know, and then adbmgr starts an AdbHooker process module to connect to the Android mobile terminal, to implement a real service function.
  • adbmgr restarts an AdbHooker process to perform fault tolerance processing.
  • adbmgr monitors the Android mobile terminal inserted into the server, and when a new Android mobile terminal is inserted, a new AdbHooker process is started, and a sequence number of the Android mobile terminal is used as a parameter for transmission. After being started, the AdbHooker process module is connected to the Android mobile terminal having a specified sequence number.
  • the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6 may further include an authentication module 801.
  • the authentication module 801 is configured to authenticate, after the identification module identifies the Android mobile terminal inserted into the USB port of the server, the Android mobile terminal inserted into the USB port of the server.
  • the establishment module 602 exemplified in FIG. 8 may include a start unit 901, a receiving unit 902, and a sending unit 903, where
  • the start unit 901 is configured to start the socket port to establish a connection to the PC;
  • the receiving unit 902 is configured to receive a device connection command sent by the PC.
  • the sending unit 903 is configured to send device information of the Android mobile terminal to the PC.
  • the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6, FIG. 8, or FIG. 9 may further include a private data channel establishment module 1001.
  • the private data channel establishment module 1001 is configured to establish a private data channel between the server and the Android mobile terminal.
  • the private data channel is identified by using a first connection identifier
  • the user data channel is identified by using a second connection identifier
  • both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
  • the remote debugging apparatus for an Android mobile terminal exemplified in any one of FIG. 10-a to FIG. 10-c may further include a connection identifier regeneration module 1101 and a mapping module 1102, where
  • connection identifier regeneration module 1101 is configured to regenerate, after the private data channel between the server and the Android mobile terminal is established, corresponding connection identifiers according to sources of establishment requests for establishing the private data channel and the user data channel;
  • the mapping module 1102 is configured to map a regenerated connection identifier corresponding to the private data channel to a third connection identifier, and map a regenerated connection identifier corresponding to the user data channel to a fourth connection identifier.
  • An embodiment of the present invention further provides a remote debugging server for a mobile terminal, and the remote debugging server for a mobile terminal may be used to perform the remote debugging method for a mobile terminal provided in the foregoing embodiment.
  • the remote debugging server for a mobile terminal may include a memory having one or more computer readable storage media, a processor having one or more processing cores, and other components.
  • the structure of the memory does not constitute a limitation to the remote debugging server for a mobile terminal, and the structure of the memory may include more components or fewer components, or some components may be combined, or a different component deployment may be used.
  • the memory may be used to store a software program and module.
  • the processor runs the software program and module stored in the memory, to implement various functional applications and data processing.
  • the memory may mainly include a program storage area and a data storage area.
  • the program storage area may store an operating system, an application program required by at least one function (such as a sound playback function or an image display function), and the like.
  • the data storage area may store data created according to use of the remote debugging server for a mobile terminal, and the like.
  • the memory may include a high speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory, or another volatile solid-state storage device.
  • the memory may further include a memory controller, so as to provide access of the processor to the memory.
  • the remote debugging server for a mobile terminal further includes a memory and one or more programs.
  • the one or more programs are stored in the memory and configured to be executed by one or more processors.
  • the one or more programs contain instructions used for performing the following operations:
  • the identifying a mobile terminal, the establishing a mapping relationship, and the forwarding data are all performed by an AdbHooker process module, and an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal.
  • the memory of the remote debugging server for a mobile terminal further includes the following instruction:
  • the memory of the remote debugging server for an Android mobile terminal further includes the following instructions:
  • the memory of the remote debugging server for a mobile terminal further includes the following instruction:
  • the private data channel is identified by using a first connection identifier
  • the user data channel is identified by using a second connection identifier
  • both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
  • the memory of the remote debugging server for a mobile terminal further includes the following instructions:
  • Still another embodiment of the present invention further provides a computer readable storage medium.
  • the computer readable storage medium may be the computer readable storage medium included in the memory in the foregoing embodiment, or may be a computer readable storage medium that exists independently, and is not assembled into the remote debugging server for a mobile terminal.
  • the computer readable storage medium stores one or more programs, the one or more programs are used by one or more processors to perform a remote debugging method for a mobile terminal, and the method includes:
  • the identifying a mobile terminal, the establishing a mapping relationship, and the forwarding data are all performed by an AdbHooker process module, and an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal.
  • the method further includes: authenticating the Android mobile terminal inserted into the USB port of the server.
  • the establishing a mapping relationship between the socket port and the USB port includes:
  • the method further includes: establishing a private data channel between the server and the Android mobile terminal.
  • the private data channel is identified by using a first connection identifier
  • the user data channel is identified by using a second connection identifier
  • both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
  • the method further includes:
  • the program may be stored in a computer readable storage medium.
  • the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disc, and the like.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Telephone Function (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present disclosure discloses a remote debugging method and apparatus for a mobile terminal, to create a good debugging environment, so that remote debugging is performed normally and smoothly. The method includes: identifying a mobile terminal inserted into a universal serial bus (USB) port of a server; establishing a mapping relationship between a socket port and the USB port; and forwarding data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.

Description

REMOTE DEBUGGING METHOD AND APPARATUS FOR MOBILE TERMINAL
FIELD OF THE TECHNOLOGY
The present disclosure relates to the field of mobile communications, and in particular, to a remote debugging method and apparatus for a mobile terminal.
BACKGROUND OF THE DISCLOSURE
Remote debugging is debugging, by using a debugging client running on a machine A, an application program running on a remote machine B, for example, debugging, by using a debugging client running on a personal computer (PC), an application program running on a mobile terminal (such as a smartphone), where the mobile terminal is not directly inserted into the PC. In operation, a program development engineer often needs to deploy a program on a server (sometimes, joint debugging is limited by a source IP of another party, or an application program sometimes must runs on a specific machine), and a source code is local. In this case, the program development engineer is generally used to debugging by using a log, and when having no alternative, the program development engineer may run a proxy on the server to solve a problem of limitation of the source IP, so as to debug locally in an integrated development environment (IDE). However, anyway, remote debugging is still an important debugging manner in various debugging manners.
An existing remote debugging method for a mobile terminal is: connecting a mobile terminal to a PC in a wireless manner, where during connection, the mobile terminal is connected to the PC in a TCP manner; and starting, by the mobile terminal, a port 5555, to implement remote debugging by exposing the port to an end user.
However, in the foregoing existing remote debugging method for a mobile terminal, the mobile terminal is connected to the PC in a wireless manner, such as WiFi, and such a remote debugging method has the following defects: on one hand, during remote debugging, a WiFi module needs to be used for performing a simulation test about a network (for example, changing a network speed or a packet loss rate), which affects remote debugging; on the other hand, when multiple mobile terminals are connected to WiFi to perform massive data volume transmission simultaneously, a wireless connection is unstable, and a transmission speed is sometimes fast and sometimes slow, which affects normal use of functions.
SUMMARY
Embodiments of the present invention provide a remote debugging method and apparatus for a mobile terminal, to create a good debugging environment, so that remote debugging is performed normally and smoothly.
An embodiment of the present invention provides a remote debugging method for a mobile terminal, including:
identifying a mobile terminal inserted into a universal serial bus (USB) port of a server, the server establishing a Transmission Control Protocol (TCP) connection to a PC by using a socket port;
establishing a mapping relationship between the socket port and the USB port; and
forwarding data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
Another embodiment of the present invention provides a remote debugging apparatus for a mobile terminal, including:
an identification module, configured to identify a mobile terminal inserted into a USB port of a server, the server establishing a TCP connection to a PC by using a socket port;
an establishment module, configured to establish a mapping relationship between the socket port and the USB port; and
a forwarding module, configured to forward data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
It can be known from the foregoing embodiments of the present invention that, a mobile terminal is directly inserted into a USB port of a server, and a user data channel obtained according to a mapping relationship is used for forwarding data, that is, a user performs remote debugging on the mobile terminal from a side of a PC through the user data channel. On one hand, compared with the wireless connection manner WiFi in the existing technology, because the mobile terminal is inserted into the USB port of the server, such a connection in the method of the present disclosure is more reliable, and a debugging environment is more stable. On the other hand, because the server establishes a TCP connection to the PC, and there is a mapping relationship between a socket port and the USB port, for a user, the mobile terminal is "inserted" into the PC of the user, and the user can debug the mobile terminal on a side of the server by using various tools that can be used on the PC, which provides great convenience for the user to debug the mobile terminal, so that remote debugging is performed easily.
BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 is a basic schematic flowchart of a remote debugging method for a mobile terminal according to an embodiment of the present invention;
FIG. 2 is a schematic flowchart of authenticating, by a server, an Android mobile terminal inserted into a USB port of the server according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a user interface, which can be seen by a user from a side of a PC, of an Android mobile terminal after the Android mobile terminal is inserted into the server according to an embodiment of the present invention;
FIG. 4 is a schematic flowchart of establishing a private data channel between a server and a mobile terminal according to an embodiment of the present invention;
FIG. 5 is a schematic diagram of connecting a logical module 1 in a mobile terminal to a logical module 2 in a server by using an established private data channel according to an embodiment of the present invention;
FIG. 6 is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to an embodiment of the present invention;
FIG. 7 is a schematic diagram showing that an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention;
FIG. 9 is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention;
FIG. 10-a is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention;
FIG. 10-b is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention;
FIG. 10-c is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention;
FIG. 11-a is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention;
FIG. 11-b is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention; and
FIG. 11-c is a schematic diagram of a basic logical structure of a remote debugging apparatus for a mobile terminal according to another embodiment of the present invention.
DESCRIPTION OF EMBODIMENTS
An embodiment of the present invention provides a remote debugging method for a mobile terminal. The method includes: identifying a mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port; establishing a mapping relationship between the socket port and the USB port; and forwarding data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship. An embodiment of the present invention further provides a corresponding remote debugging apparatus for a mobile terminal. Descriptions are separately made below in detail.
The remote debugging method for a mobile terminal according to this embodiment of the present invention may be applied to a server in a system using a client/server (C/S) architecture, and may be executed by the server or a functional module, such as an AdbHooker process module in the server; a mobile terminal may be a mobile terminal whose operating system is Android, such as a smartphone whose operating system is Android. The remote debugging method for a mobile terminal provided in this embodiment of the present invention is described below by using an example in which the mobile terminal is an Android mobile terminal, and for a basic procedure of the method, reference may be made to FIG. 1. The basic process mainly includes step S101 to step S103, and detailed descriptions are as follows:
S101: Identify a mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port.
Specifically, an AdbHooker process module may traverse, by invoking an adb drive layer method, Android mobile terminals currently inserted into the server, acquire sequence numbers of the Android mobile terminals, when identifying a sequence number of a to-be-connected Android mobile terminal, store a USB handle of the Android mobile terminal, enable input and output, and prepare for authentication.
In this embodiment of the present invention, the server establishes the TCP connection to the PC by using the socket port. Specifically, an Adbh process, which is used by a user for debugging, in the PC establishes the TCP connection to an AdbHooker process in the server by using the socket port. In this way, the user can transmit a command required for debugging from the PC to the server through the TCP connection by using an Adb.
In a remote debugging method for a mobile terminal provided in the existing technology, when an Android mobile terminal is inserted to a PC, the Android mobile terminal may pop up an authentication prompt box, to ask a user whether to debug the currently inserted Android mobile terminal by using the PC. The PC may only be connected to the Android mobile terminal after it is confirmed that the currently inserted Android mobile terminal is debugged by using the PC. This is a so-called debugging whitelist mechanism, and as far as remote debugging is concerned, the mechanism has disadvantages because the Android mobile terminal is not by the side of the user but is in a laboratory, and in many cases, the user cannot or is not that convenient to go to the laboratory (for example, can only enter the laboratory with multifarious authentication procedures) for confirmation, causing that the user cannot connect the Android mobile terminal to the PC.
In view of the foregoing disadvantages in the remote debugging method for an Android mobile terminal provided in the existing technology, in this embodiment of the present invention, after the Android mobile terminal inserted into the USB port of the server is identified, the method further includes authenticating the Android mobile terminal inserted into the USB port of the server. An authentication process is shown in FIG. 2, and includes step S201 to step S209:
S201: A server sends CONN to an Android mobile terminal.
Although CONN, that is, a connection request is sent by an AdbHooker process module to the Android mobile terminal, from the perspective of the Android mobile terminal, the connection request comes from a PC on a side of the user.
S202: The Android mobile terminal generates a token.
S203: The Android mobile terminal sends the token to the server.
An objective of sending the token to the server by the Android mobile terminal is to require the server to use the token to provide a key.
S204: The server signs a key by using the token.
S205: The server sends the key to the Android mobile terminal.
The key sent by the server to the Android mobile terminal is a key signed by using a token previously sent by the Android mobile terminal to the server.
S206: The Android mobile terminal requests the server to send a new key.
If the Android mobile terminal does not find, at a local end, a key that can match the key sent in step S205, the Android mobile terminal requests the server to send a new key.
S207: The server generates a new key.
The server generates the new key according to the request sent by the Android mobile terminal.
S208: The server requests authentication of the Android mobile terminal.
S209: The Android mobile terminal returns device information of the Android mobile terminal to the server.
After finding, at the local end, a key that can match the new key, the Android mobile terminal accepts the connection request to connect, and returns the device information of the Android mobile terminal to the server.
Once authentication on the Android mobile terminal inserted into the USB port of the server is completed, the foregoing disadvantages existing in the debugging whitelist mechanism in the remote debugging method for an Android mobile terminal provided in the existing technology can be effectively avoided, that is, when the AdbHooker process module is connected to the Android mobile terminal, authentication on the Android mobile terminal is completed, and when the PC sends the connection request CONN, the AdbHooker process module directly returns, to the PC, a response to the connection request CONN and the device information of the Android mobile terminal. In this way, the PC of the user can be directly connected to the Android mobile terminal successfully, thereby solving the problems existing in the debugging whitelist mechanism in the existing technology.
S102: Establish a mapping relationship between the socket port and the USB port.
As an embodiment of the present invention, the establishing a mapping relationship between the socket port and the USB port includes the following step S1021 to step S1023:
S1021: Start the socket port to establish a connection to the PC.
In this embodiment of the present invention, the AdbHooker process module starts a socket port, and waits for the user to connect to the socket port from a side of the PC. For example, the user sends a command "adb connect address: port" from a side of the PC, to establish a connection between the PC and the server.
S1022: Receive a device connection command sent by the PC.
After the connection between the server and the PC is established, the user sends the device connection command to the server by using the adb on the side of the PC, and the server receives the device connection command sent by the PC, where the device connection command indicates that the user wants to connect the PC to the Android mobile terminal.
S1023: Send the device information of the Android mobile terminal to the PC.
As described above, the server has completed authentication on the Android mobile terminal. After receiving the device connection command sent by the PC, the server may send the device information of the Android mobile terminal to the PC. Once the PC receives the device information of the Android mobile terminal sent by the server, the user considers that the PC is successfully connected to the Android mobile terminal. In this case, the mapping relationship between the socket port and the USB port is established.
S103: Forward data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
Establishing the mapping relationship between the socket port and the USB port means establishing a user data channel between the PC and the server. Subsequently, data (including an adb command line) sent by the PC only needs to be sent to the Android mobile terminal through the USB port, or data (except a message on a private data channel) received through the USB port may be sent to the PC. All of the data is transmitted through the user data channel. For the user, the Android mobile terminal in this case is "inserted" into a currently operated PC, and the user can see a user interface of an Android mobile terminal exemplified in FIG. 3 and perform corresponding operations. For example, the user may operate the Android mobile terminal by using an adb command, or may debug an application in the Android mobile terminal by using a tool such as Eclipse or MonkeyRunner.
When performing remote debugging on the Android mobile terminal, the user may further have other requirements, for example, the user may hope to see a screen image of the Android mobile terminal, and in this case, the screen image of the Android mobile terminal needs to be transmitted to the PC by using the server, to be displayed to the user. Because data volume is large when an image is being transmitted, a private data channel needs to be established between the server and the Android mobile terminal, and a procedure of establishing the private data channel between the server and the Android mobile terminal is shown in FIG. 4. In the procedure exemplified in FIG. 4, for commands such as OPEN, REDY, WRITE, and CLOSE, parameters local_id thereof are used for identifying senders or/and generators of the commands, data, or the like, and parameters remote_id are used for identifying receivers or/and processors of the commands, data, or the like. The procedure exemplified in FIG. 4 is described below in detail, and mainly includes step S401 to step S405.
S401: The server sends an OPEN (local_id, remote_id, cmd) command to the Android mobile terminal.
Besides being used for identifying the private data channel established between the server and the Android mobile terminal, a parameter local_id of the OPEN command sent by the server to the Android mobile terminal is further used for identifying a sender or/and a generator, that is, the server, of the OPEN command, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the Android mobile terminal, of the OPEN command. Definitely, when the server sends the OPEN command to the Android mobile terminal for the first time, a value of the parameter remote_id is 0, and cmd is a specific execution action of an operation in the OPEN command.
S402: The Android mobile terminal returns a READY (local_id, remote_id) response message to the server.
A parameter local_id of the READY response message returned by the Android mobile terminal to the server is used for identifying a sender or/and a generator, that is, the Android mobile terminal, of the READY response message, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the server, of the READY response message. According to unified definitions of the parameters local_id and remote_id, a value of the parameter remote_id of the READY response message should be equal to a value of the parameter local_id of the OPEN command.
S403: The server sends a WRITE (local_id, remote_id, data) command to the Android mobile terminal.
A parameter local_id of the WRITE (local_id, remote_id, data) command sent by the server to the Android mobile terminal is used for identifying a sender or/and a generator, that is, the server, of the WRITE command, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the Android mobile terminal, of the WRITE command. In addition, according to the foregoing unified definitions of the parameters local_id and remote_id, a value of the parameter local_id of the WRITE command should be equal to the value of the parameter remote_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server. In this case, a value of the parameter remote_id of the WRITE command should be equal to the value of the parameter local_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
S404: The Android mobile terminal returns a READY (local_id, remote_id) response message to the server.
In this step, meanings of parameters local_id and remote_id of the READY (local_id, remote_id) response message returned by the Android mobile terminal to the server are respectively the same as meanings of the parameters local_id and remote_id of the READY (local_id, remote_id) response message returned by the Android mobile terminal to the server in step S402. A difference only lies in that the response message returned in this step is a response to the WRITE command sent by the server to the Android mobile terminal. Therefore, the meanings of the parameters of the READY response message are not described again.
Definitely, data is bidirectionally written between the Android mobile terminal and the server, that is, the Android mobile terminal may also write data to the server, and the server may also return a response message to the Android mobile terminal, as described in step S'403 and step S'404.
S'403: The Android mobile terminal sends a WRITE (local_id, remote_id, data) command to the server.
A parameter local_id of the WRITE command sent by the Android mobile terminal to the server is used for identifying a sender or/and a generator, that is, the Android mobile terminal, of the WRITE command, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the server, of the WRITE command. In addition, according to the foregoing unified definitions of the parameters local_id and remote_id, in this case, a value of the parameter local_id of the WRITE command should be equal to the value of the parameter local_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server, and a value of the parameter remote_id of the WRITE command should be equal to the value of the parameter remote_id in the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
S'404: The server returns a READY (local_id, remote_id) response message to the Android mobile terminal.
A parameter local_id of the READY response message sent by the server to the Android mobile terminal is used for identifying a sender or/and a generator, that is, the server, of the READY response message, and a parameter remote_id is used for identifying a receiver or/and a processor, that is, the Android mobile terminal, of the READY response message. In addition, according to the unified definitions of the foregoing parameters local_id and remote_id, a value of the parameter local_id of the READY response message should be equal to the value of the parameter local_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server. In this case, a value of the parameter remote_id of the READY response message should be equal to the value of the parameter remote_id of the READY response message that immediately follows the OPEN command and is returned by the Android mobile terminal to the server.
S405: The server sends a CLOSE (local_id, remote_id) command to the Android mobile terminal.
Meanings of parameters local_id and remote_id of the CLOSE (local_id, remote_id) command sent by the server to the Android mobile terminal are respectively the same as meanings of the parameters local_id and remote_id of the OPEN command sent by the server to the Android mobile terminal in step S401. Therefore, meanings of the parameters of the CLOSE command are not described again.
FIG. 5 is a schematic diagram of connecting a logical module 1 in an Android mobile terminal to a logical module 2 in a server by using an established private data channel.
Because both the user data channel between the PC and the Android mobile terminal and the private data channel between the server and the Android mobile terminal pass through the USB port, in order to distinguish the two channels, that is, distinguishing where data on the USB port comes from and where the data on the USB port is sent, in this embodiment of the present invention, connection identifiers are used for identifying the private data channel and the user data channel, for example, the private data channel is identified by using a first connection identifier, and the user data channel is identified by using a second connection identifier, where both the first connection identifier and the second connection identifier are indicated by numbers.
In this embodiment of the present invention, a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier. The "being much greater than" means that: once it is determined that the first connection identifier is indicated by a fixed number, in consideration of a value of the fixed number, in a practical application, if the number for indicating the second connection identifier increases as the number of user data channels increases, a value of the number for indicating the second connection identifier does not reach or exceed a value of the number for indicating the first connection identifier however large the value of the number for indicating the second connection identifier becomes, in which manner it may be avoided that a value of the first connection identifier (indicated by local_id) is equal to a value of the second connection identifier (indicated by local_id), so that the private data channel is effectively distinguished from the user data channel (which can both be indicated by local_id). This is because a value of the second connection identifier (local_id) used for identifying the user data channel starts from 0, and each time a new user data channel is established, the value of the second connection identifier increases progressively. Because establishing the user data channel is not a frequent action, and in a practical application, the value of the second connection identifier used for identifying the user data channel cannot be very large, the private data channel can be distinguished from the user data channel provided that the value of the first connection identifier (local_id) used for identifying the private data channel starts from a very large number, for example, local_id=0x06000000.
In addition to the foregoing method, an embodiment of the present invention further provides a method for distinguishing the private data channel from the user data channel, that is, after the private data channel between the server and the Android mobile terminal is established, corresponding connection identifiers are regenerated according to sources of establishment requests for establishing the private data channel and the user data channel, a regenerated connection identifier corresponding to the private data channel is mapped to a third connection identifier, and a regenerated connection identifier corresponding to the user data channel is mapped to a fourth connection identifier. In this way, when data received by the server carries the third connection identifier, the server can know, according to the mapping relationship, that the data is from the private data channel established between the server and the Android mobile terminal. When the data received by the server carries the fourth connection identifier, the server can know, according to the mapping relationship, that the data is from the user data channel established between the server and the PC.
It can be known from the foregoing remote debugging method for an Android mobile terminal provided in this embodiment of the present invention that, an Android mobile terminal is directly inserted into a USB port of a server, and a user data channel obtained according to a mapping relationship is used for forwarding data, that is, a user performs remote debugging on the Android mobile terminal from a side of a PC through the user data channel. On one hand, compared with the wireless connection manner WiFi in the existing technology, because the Android mobile terminal is inserted into the USB port of the server, such a connection in the method in the present disclosure is more reliable, and a debugging environment is more stable. On the other hand, because the server establishes a TCP connection to the PC, and there is a mapping relationship between a socket port and the USB port, for a user, the Android mobile terminal is "inserted" into the PC of the user, and the user can debug the Android mobile terminal on a side of the server by using various tools that can be used on the PC, which provides great convenience for the user to debug the Android mobile terminal, so that remote debugging is performed easily.
A remote debugging apparatus for an Android mobile terminal that is provided in an embodiment of the present invention and is used to perform the foregoing remote debugging method for an Android mobile terminal is described below, and for a basic logical structure of the apparatus, reference is made to FIG. 6. For ease of description, only content related to this embodiment of the present invention is shown. The remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6 may be a server for performing remote debugging on an Android mobile terminal or a functional module, such as an AdbHooker process module in the server. The remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6 mainly includes an identification module 601, an establishment module 602, and a forwarding module 603. The modules are described in detail as follows:
The identification module 601 is configured to identify an Android mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port.
The establishment module 602 is configured to establish a mapping relationship between the socket port and the USB port.
The forwarding module 603 is configured to forward data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
It should be noted that, in the implementation manner of the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6, division of the functional modules is only described for exemplary purposes. In actual applications, the functions may be allocated to different functional modules according to a specific need, such as a configuration requirement of corresponding hardware or a convenience consideration of implementation of software, which means that the internal structure of the remote debugging apparatus for an Android mobile terminal is divided to different functional modules to implement all or some of the above-described functions. In addition, in practical applications, corresponding functional modules in this embodiment may be implemented by using corresponding hardware, or may be implemented by corresponding hardware executing corresponding software. For example, the identification module may be hardware, such as a recognizer, for identifying the Android mobile terminal inserted into the USB port of the server, or may be a general processor or another hardware device that can execute a corresponding computer program so as to implement the foregoing functions. For another example, the forwarding module may be hardware, such as a forwarder, for implementing the function of forwarding the data on the socket port to the USB port and the data on the USB port to the socket port through the user data channel obtained according to the mapping relationship, or may be a general processor or another hardware device that can execute a corresponding computer program so as to implement the foregoing functions (the foregoing description rules can be applied to all of the embodiments provided in the specification).
In the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6, the identification module 601 identifying an Android mobile terminal, the establishment module 602 establishing a mapping relationship, and the forwarding module 603 forwarding data are all performed by the AdbHooker process module.
It should be noted that, in the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6, an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal, that is, the AdbHooker process module uses a multi-threaded process design, and each AdbHooker process module is only connected to one Android mobile terminal, as shown in FIG. 7. In an architecture exemplified in FIG. 7, adbmgr is responsible for managing the Android mobile terminal inserted into the server, and after the Android mobile terminal is inserted into the server, adbmgr is the first to know, and then adbmgr starts an AdbHooker process module to connect to the Android mobile terminal, to implement a real service function. On one hand, when an exception occurs in the AdbHooker process module or the AdbHooker process module exits abnormally, adbmgr restarts an AdbHooker process to perform fault tolerance processing. On the other hand, adbmgr monitors the Android mobile terminal inserted into the server, and when a new Android mobile terminal is inserted, a new AdbHooker process is started, and a sequence number of the Android mobile terminal is used as a parameter for transmission. After being started, the AdbHooker process module is connected to the Android mobile terminal having a specified sequence number.
For the architecture exemplified in FIG. 7, on one hand, performance of a multi-core CPU can be fully used; on the other hand, if an exception occurs, the Android mobile terminals do not affect each other, and it is beneficial for recovery from an error.
Referring to FIG. 8 which shows a remote debugging apparatus for an Android mobile terminal provided in another embodiment of the present invention, the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6 may further include an authentication module 801. The authentication module 801 is configured to authenticate, after the identification module identifies the Android mobile terminal inserted into the USB port of the server, the Android mobile terminal inserted into the USB port of the server.
Referring to FIG. 9 which shows a remote debugging apparatus for an Android mobile terminal provided in another embodiment of the present invention, the establishment module 602 exemplified in FIG. 8 may include a start unit 901, a receiving unit 902, and a sending unit 903, where
the start unit 901 is configured to start the socket port to establish a connection to the PC;
the receiving unit 902 is configured to receive a device connection command sent by the PC; and
the sending unit 903 is configured to send device information of the Android mobile terminal to the PC.
Referring to any one of FIG. 10-a to FIG. 10-c that shows a remote debugging apparatus for an Android mobile terminal, the remote debugging apparatus for an Android mobile terminal exemplified in FIG. 6, FIG. 8, or FIG. 9 may further include a private data channel establishment module 1001. The private data channel establishment module 1001 is configured to establish a private data channel between the server and the Android mobile terminal.
In the remote debugging apparatus for an Android mobile terminal exemplified in any one of FIG. 10-a to FIG. 10-c, the private data channel is identified by using a first connection identifier, the user data channel is identified by using a second connection identifier, both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
Referring to any one of FIG. 11-a to FIG. 11-c that shows a remote debugging apparatus for an Android mobile terminal, the remote debugging apparatus for an Android mobile terminal exemplified in any one of FIG. 10-a to FIG. 10-c may further include a connection identifier regeneration module 1101 and a mapping module 1102, where
the connection identifier regeneration module 1101 is configured to regenerate, after the private data channel between the server and the Android mobile terminal is established, corresponding connection identifiers according to sources of establishment requests for establishing the private data channel and the user data channel; and
the mapping module 1102 is configured to map a regenerated connection identifier corresponding to the private data channel to a third connection identifier, and map a regenerated connection identifier corresponding to the user data channel to a fourth connection identifier.
An embodiment of the present invention further provides a remote debugging server for a mobile terminal, and the remote debugging server for a mobile terminal may be used to perform the remote debugging method for a mobile terminal provided in the foregoing embodiment. Specifically, the remote debugging server for a mobile terminal may include a memory having one or more computer readable storage media, a processor having one or more processing cores, and other components. A person skilled in the art may understand that the structure of the memory does not constitute a limitation to the remote debugging server for a mobile terminal, and the structure of the memory may include more components or fewer components, or some components may be combined, or a different component deployment may be used.
The memory may be used to store a software program and module. The processor runs the software program and module stored in the memory, to implement various functional applications and data processing. The memory may mainly include a program storage area and a data storage area. The program storage area may store an operating system, an application program required by at least one function (such as a sound playback function or an image display function), and the like. The data storage area may store data created according to use of the remote debugging server for a mobile terminal, and the like. In addition, the memory may include a high speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory, or another volatile solid-state storage device. Correspondingly, the memory may further include a memory controller, so as to provide access of the processor to the memory.
Although not shown in the figure, the remote debugging server for a mobile terminal further includes a memory and one or more programs. The one or more programs are stored in the memory and configured to be executed by one or more processors. The one or more programs contain instructions used for performing the following operations:
identifying a mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port;
establishing a mapping relationship between the socket port and the USB port; and
forwarding data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
Assuming that the foregoing description is a first possible implementation manner, in a second possible implementation manner provided based on the first possible implementation manner, the identifying a mobile terminal, the establishing a mapping relationship, and the forwarding data are all performed by an AdbHooker process module, and an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal.
Assuming that the foregoing description is the second possible implementation manner, in a third possible implementation manner provided based on the second possible implementation manner, the memory of the remote debugging server for a mobile terminal further includes the following instruction:
authenticating the Android mobile terminal inserted into the USB port of the server.
Assuming that the foregoing description is the second possible implementation manner, in a fourth possible implementation manner provided based on the second possible implementation manner, the memory of the remote debugging server for an Android mobile terminal further includes the following instructions:
starting the socket port to establish a connection to the PC;
receiving a device connection command sent by the PC; and
sending device information of the Android mobile terminal to the PC.
Assuming that the foregoing description is the fourth possible implementation manner, in a fifth possible implementation manner provided based on any one of the first to the fourth possible implementation manners, the memory of the remote debugging server for a mobile terminal further includes the following instruction:
establishing a private data channel between the server and the Android mobile terminal.
Assuming that the foregoing description is the fifth possible implementation manner, in a sixth possible implementation manner provided based on the fifth possible implementation manner, the private data channel is identified by using a first connection identifier, the user data channel is identified by using a second connection identifier, both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
Assuming that the foregoing description is the fifth possible implementation manner, in a seventh possible implementation manner based on the fifth possible implementation manner, the memory of the remote debugging server for a mobile terminal further includes the following instructions:
regenerating corresponding connection identifiers according to sources of establishment requests for establishing the private data channel and the user data channel; and
mapping a regenerated connection identifier corresponding to the private data channel to a third connection identifier, and mapping a regenerated connection identifier corresponding to the user data channel to a fourth connection identifier.
As another aspect, still another embodiment of the present invention further provides a computer readable storage medium. The computer readable storage medium may be the computer readable storage medium included in the memory in the foregoing embodiment, or may be a computer readable storage medium that exists independently, and is not assembled into the remote debugging server for a mobile terminal. The computer readable storage medium stores one or more programs, the one or more programs are used by one or more processors to perform a remote debugging method for a mobile terminal, and the method includes:
identifying a mobile terminal inserted into a USB port of a server, where the server establishes a TCP connection to a PC by using a socket port;
establishing a mapping relationship between the socket port and the USB port; and
forwarding data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
Assuming that the foregoing description is a first possible implementation manner, in a second possible implementation manner provided based on the first possible implementation manner, the identifying a mobile terminal, the establishing a mapping relationship, and the forwarding data are all performed by an AdbHooker process module, and an AdbHooker process module is in a one-to-one mapping with an Android mobile terminal.
Assuming that the foregoing description is the second possible implementation manner, in the third possible implementation manner provided based on the second possible implementation manner, after the identifying a mobile terminal inserted into a USB port of a server, the method further includes: authenticating the Android mobile terminal inserted into the USB port of the server.
Assuming that the foregoing description is the second possible implementation manner, in a fourth possible implementation manner provided based on the second possible implementation manner, the establishing a mapping relationship between the socket port and the USB port includes:
starting the socket port to establish a connection to the PC;
receiving a device connection command sent by the PC; and
sending device information of the Android mobile terminal to the PC.
Assuming that the foregoing description is the fourth possible implementation manner, in a fifth possible implementation manner provided based on any one of the first to the fourth possible implementation manners, after the establishing a mapping relationship between the socket port and the USB port, the method further includes: establishing a private data channel between the server and the Android mobile terminal.
Assuming that the foregoing description is the fifth possible implementation manner, in a sixth possible implementation manner provided based on the fifth possible implementation manner, the private data channel is identified by using a first connection identifier, the user data channel is identified by using a second connection identifier, both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
Assuming that the foregoing description is the fifth possible implementation manner, in a seventh possible implementation manner provided based on the fifth possible implementation manner, after the establishing a private data channel between the server and the Android mobile terminal, the method further includes:
regenerating corresponding connection identifiers according to sources of establishment requests for establishing the private data channel and the user data channel; and
mapping a regenerated connection identifier corresponding to the private data channel to a third connection identifier, and mapping a regenerated connection identifier corresponding to the user data channel to a fourth connection identifier.
It should be noted that, because content such as information interactions between various modules/units of the apparatus, execution processes, and the like is based on the same concept as the method embodiment of the present invention, technical effects brought by the content is the same as that of the method embodiment of the present invention. For specific content, reference may be made to descriptions in the method embodiment of the present invention, and details are not described herein again.
A person of ordinary skill in the art may understand that all or some of the steps in the various methods of the foregoing embodiments may be implemented by a program instructing relevant hardware. The program may be stored in a computer readable storage medium. The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk, an optical disc, and the like.
The foregoing descriptions are merely preferred embodiments of the present invention, but are not intended to limit the present disclosure. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present disclosure shall fall within the protection scope of the present disclosure.

Claims (14)

  1. A remote debugging method for a mobile terminal, comprising:
    identifying a mobile terminal inserted into a universal serial bus (USB) port of a server, the server establishing a Transmission Control Protocol (TCP) connection to a personal computer (PC) by using a socket port;
    establishing a mapping relationship between the socket port and the USB port; and
    forwarding data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
  2. The method according to claim 1, wherein the mobile terminal is an Android mobile terminal, the identifying a mobile terminal, the establishing a mapping relationship, and the forwarding data are all performed by an AdbHooker process module, and the AdbHooker process module is in a one-to-one mapping with the Android mobile terminal.
  3. The method according to claim 2, after the identifying a mobile terminal inserted into a USB port of a server, further comprising:
    authenticating the Android mobile terminal inserted into the USB port of the server.
  4. The method according to claim 2, wherein the establishing a mapping relationship between the socket port and the USB port comprises:
    starting the socket port to establish a connection to the PC;
    receiving a device connection command sent by the PC; and
    sending device information of the Android mobile terminal to the PC.
  5. The method according to any one of claims 1 to 4, after the establishing a mapping relationship between the socket port and the USB port, further comprising:
    establishing a private data channel between the server and the mobile terminal.
  6. The method according to claim 5, wherein the private data channel is identified by using a first connection identifier, the user data channel is identified by using a second connection identifier, both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
  7. The method according to claim 5, after the establishing a private data channel between the server and the mobile terminal, further comprising:
    regenerating corresponding connection identifiers according to sources of establishment requests for establishing the private data channel and the user data channel; and
    mapping a regenerated connection identifier corresponding to the private data channel to a third connection identifier, and mapping a regenerated connection identifier corresponding to the user data channel to a fourth connection identifier.
  8. A remote debugging apparatus for a mobile terminal, comprising:
    an identification module, configured to identify a mobile terminal inserted into a USB port of a server, the server establishing a TCP connection to a PC by using a socket port;
    an establishment module, configured to establish a mapping relationship between the socket port and the USB port; and
    a forwarding module, configured to forward data on the socket port to the USB port and data on the USB port to the socket port through a user data channel obtained according to the mapping relationship.
  9. The apparatus according to claim 8, wherein the mobile terminal is an Android mobile terminal, the identification module identifying a mobile terminal, the establishment module establishing a mapping relationship, and the forwarding module forwarding data are all performed by an AdbHooker process module, and the AdbHooker process module is in a one-to-one mapping with the Android mobile terminal.
  10. The apparatus according to claim 9, wherein the apparatus further comprises:
    an authentication module, configured to authenticate, after the identification module identifies the mobile terminal inserted into the USB port of the server, the Android mobile terminal inserted into the USB port of the server.
  11. The apparatus according to claim 9, wherein the establishment module comprises:
    a start unit, configured to start the socket port to establish a connection to the PC;
    a receiving unit, configured to receive a device connection command sent by the PC; and
    a sending unit, configured to send device information of the Android mobile terminal to the PC.
  12. The apparatus according to any one of claims 8 to 11, wherein the apparatus further comprises:
    a private data channel establishment module, configured to establish a private data channel between the server and the mobile terminal.
  13. The apparatus according to claim 12, wherein the private data channel is identified by using a first connection identifier, the user data channel is identified by using a second connection identifier, both the first connection identifier and the second connection identifier are indicated by numbers, and a number for indicating the first connection identifier is much greater than a number for indicating the second connection identifier.
  14. The apparatus according to claim 12, wherein the apparatus further comprises:
    a connection identifier regeneration module, configured to regenerate, after the private data channel between the server and the mobile terminal is established, corresponding connection identifiers according to sources of establishment requests for establishing the private data channel and the user data channel; and
    a mapping module, configured to map a regenerated connection identifier corresponding to the private data channel to a third connection identifier, and map a regenerated connection identifier corresponding to the user data channel to a fourth connection identifier.
PCT/CN2015/076323 2014-04-15 2015-04-10 Remote debugging method and apparatus for mobile terminal WO2015158219A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410151422.9 2014-04-15
CN201410151422.9A CN104967585B (en) 2014-04-15 2014-04-15 A kind of method and apparatus of remote debugging mobile terminal

Publications (1)

Publication Number Publication Date
WO2015158219A1 true WO2015158219A1 (en) 2015-10-22

Family

ID=54221531

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/076323 WO2015158219A1 (en) 2014-04-15 2015-04-10 Remote debugging method and apparatus for mobile terminal

Country Status (2)

Country Link
CN (1) CN104967585B (en)
WO (1) WO2015158219A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112084537A (en) * 2020-09-02 2020-12-15 英博超算(南京)科技有限公司 JTAG protection mechanism
CN112822081A (en) * 2021-01-08 2021-05-18 广州视源电子科技股份有限公司 Debugging data transmission method and device
CN112968889A (en) * 2021-02-08 2021-06-15 深圳市慧为智能科技股份有限公司 Host right management method, terminal, device and computer readable storage medium

Families Citing this family (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106708489B (en) * 2015-11-17 2020-01-17 杭州海康威视数字技术股份有限公司 Debugging method and system of equipment
CN107026764B (en) * 2016-02-02 2020-01-14 腾讯科技(深圳)有限公司 Remote debugging method, device, server and system
CN105868109B (en) * 2016-03-28 2019-03-05 北京奇虎科技有限公司 A kind of improved mobile terminal application testing method and system
CN106250455B (en) * 2016-07-27 2020-02-11 北京奇虎科技有限公司 Mobile terminal file management method and system
CN106383785B (en) * 2016-09-21 2018-11-27 网易(杭州)网络有限公司 The adjustment method and device of mobile application
CN108628683B (en) * 2017-03-20 2021-04-09 腾讯科技(深圳)有限公司 Data transmission method and device
CN107329868A (en) * 2017-07-07 2017-11-07 阔地教育科技有限公司 Terminal control method, storage device, terminal control mechanism and system
CN109413010B (en) * 2017-08-18 2021-01-05 深圳兆日科技股份有限公司 Terminal authentication method, device and system
CN109842550A (en) * 2017-11-28 2019-06-04 中国电信股份有限公司 Remote debugging system, method, apparatus and computer readable storage medium
CN109189629B (en) * 2018-08-14 2022-04-12 福建天泉教育科技有限公司 Method for realizing terminal remote control based on USB device and storage medium
WO2021003694A1 (en) * 2019-07-10 2021-01-14 Micro Focus Llc Device debugging connection control and maintenance
CN112671814B (en) * 2019-10-15 2022-04-12 北京奇艺世纪科技有限公司 Cross-platform equipment development method, device and system
CN111459840A (en) * 2020-04-26 2020-07-28 恩亿科(北京)数据科技有限公司 Process debugging method and device
CN112306874A (en) * 2020-10-30 2021-02-02 广州朗国电子科技有限公司 Remote maintenance system, method and device of software and storage medium
CN112583893B (en) * 2020-11-19 2024-04-30 银捷尼科(福建)科技有限公司 Unified channel communication method for Android terminal and terminal
CN112486392A (en) * 2020-12-02 2021-03-12 广州朗国电子科技有限公司 Android main board parameter configuration method, system and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1780334A (en) * 2004-11-22 2006-05-31 乐金电子(中国)研究开发中心有限公司 Remote testing device and method for telephone connection service of mobile communication terminals
CN102253882A (en) * 2004-12-31 2011-11-23 英特尔公司 Remote recording mechanism
CN102438116A (en) * 2011-08-17 2012-05-02 中国科学院光电技术研究所 High-speed image recording device based on embedded Linux system
US20120151452A1 (en) * 2010-12-14 2012-06-14 Microsoft Corporation Remote debugging of server side code without blocking or high-level privileges

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR100664180B1 (en) * 2004-11-22 2007-01-04 엘지전자 주식회사 Remote data download apparatus and method for mobile communication device
US9514065B2 (en) * 2010-11-29 2016-12-06 Mce-Sys Ltd. Host device coupled to a USB peripheral and method of operating the same
US9609020B2 (en) * 2012-01-06 2017-03-28 Optio Labs, Inc. Systems and methods to enforce security policies on the loading, linking, and execution of native code by mobile applications running inside of virtual machines
US9251039B2 (en) * 2012-02-17 2016-02-02 Microsoft Technology Licensing, Llc Remote debugging as a service
KR101969726B1 (en) * 2012-05-02 2019-04-17 삼성전자주식회사 Method for idntifying universal serial bus host and an electronic device thereof

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1780334A (en) * 2004-11-22 2006-05-31 乐金电子(中国)研究开发中心有限公司 Remote testing device and method for telephone connection service of mobile communication terminals
CN102253882A (en) * 2004-12-31 2011-11-23 英特尔公司 Remote recording mechanism
US20120151452A1 (en) * 2010-12-14 2012-06-14 Microsoft Corporation Remote debugging of server side code without blocking or high-level privileges
CN102438116A (en) * 2011-08-17 2012-05-02 中国科学院光电技术研究所 High-speed image recording device based on embedded Linux system

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112084537A (en) * 2020-09-02 2020-12-15 英博超算(南京)科技有限公司 JTAG protection mechanism
CN112084537B (en) * 2020-09-02 2023-09-08 英博超算(南京)科技有限公司 JTAG debugging system
CN112822081A (en) * 2021-01-08 2021-05-18 广州视源电子科技股份有限公司 Debugging data transmission method and device
CN112968889A (en) * 2021-02-08 2021-06-15 深圳市慧为智能科技股份有限公司 Host right management method, terminal, device and computer readable storage medium

Also Published As

Publication number Publication date
CN104967585B (en) 2018-07-20
CN104967585A (en) 2015-10-07

Similar Documents

Publication Publication Date Title
WO2015158219A1 (en) Remote debugging method and apparatus for mobile terminal
WO2019205280A1 (en) Server testing method, apparatus, and device, and computer readable storage medium
WO2013154380A1 (en) Method for operating software defined radio application
WO2019045474A1 (en) Method and device for processing audio signal using audio filter having non-linear characteristics
WO2021157934A1 (en) Apparatus and method for generating network slice in wireless communication system
WO2016029594A1 (en) Method and system for terminal to connect with display device
WO2017054481A1 (en) Information verification and processing method and apparatus, and information processing system
WO2018149190A1 (en) Component debugging method, device and apparatus, and computer readable storage medium
WO2019104876A1 (en) Insurance product pushing method and system, terminal, client terminal, and storage medium
WO2016032021A1 (en) Apparatus and method for recognizing voice commands
WO2015103864A1 (en) Method for memory management and linux terminal
WO2019100531A1 (en) Digital signature generation method and device thereof, verification method and device thereof, and storage medium
WO2019161597A1 (en) Information sending method, apparatus and device based on instant messaging, and storage medium
WO2015139594A1 (en) Security verification method, apparatus, and system
WO2018188342A1 (en) Method, apparatus and device for generating script file, and computer-readable storage medium
WO2019041851A1 (en) Home appliance after-sales consulting method, electronic device and computer-readable storage medium
WO2015106716A1 (en) Method and system for network interconnection between devices
WO2019062112A1 (en) Method and device for controlling air conditioner, air conditioner, and computer readable storage medium
WO2019056733A1 (en) Concurrent volume control method, application server, system and storage medium
WO2019143081A1 (en) Method and electronic device for controlling data communication
WO2017185480A1 (en) Multi-screen interaction connection method, device and system
WO2017045444A1 (en) Remote controller key allocation method and device
WO2019210574A1 (en) Message processing method, apparatus, device, and readable storage medium
WO2019017665A1 (en) Electronic apparatus for processing user utterance for controlling an external electronic apparatus and controlling method thereof
WO2019024543A1 (en) Code generation method and apparatus, code generator and readable storage medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15780019

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 14.03.2017)

122 Ep: pct application non-entry in european phase

Ref document number: 15780019

Country of ref document: EP

Kind code of ref document: A1