WO2018094951A1 - Inter-process communication method, apparatus and readable storage medium - Google Patents

Inter-process communication method, apparatus and readable storage medium Download PDF

Info

Publication number
WO2018094951A1
WO2018094951A1 PCT/CN2017/079614 CN2017079614W WO2018094951A1 WO 2018094951 A1 WO2018094951 A1 WO 2018094951A1 CN 2017079614 W CN2017079614 W CN 2017079614W WO 2018094951 A1 WO2018094951 A1 WO 2018094951A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
identification number
communicated
communication
target process
Prior art date
Application number
PCT/CN2017/079614
Other languages
French (fr)
Chinese (zh)
Inventor
丁鹏
Original Assignee
武汉斗鱼网络科技有限公司
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 武汉斗鱼网络科技有限公司 filed Critical 武汉斗鱼网络科技有限公司
Publication of WO2018094951A1 publication Critical patent/WO2018094951A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/541Interprogram communication via adapters, e.g. between incompatible applications
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/544Buffers; Shared memory; Pipes

Definitions

  • the present invention relates to the field of mobile phone application technologies, and in particular, to a method and device for cross-process communication and a readable storage medium.
  • the Android system is an operating system for handheld devices (such as mobile phones, tablets, etc.). Since the Android system is relatively closed, each application can only read files in the file system created for the program, and cannot be accessed elsewhere.
  • a communication method based on AIDL for a cross-application process.
  • the method needs to first define an AIDL interface and corresponding parameter configuration on the server, and then complete the server through the client.
  • the cross-process communication method that can be implemented by the above definition and configuration.
  • an object of the present invention is to provide a method and apparatus for inter-process communication, and a readable storage medium, which is simple in operation, strong in applicability, and capable of carrying high-traffic data communication, and has good practicability.
  • an embodiment of the present invention provides a method for communicating across processes, the method includes: acquiring a first identification number of a process to be communicated, where the to-be-communicated process belongs to a first application; and based on the first identifier No. establishing a communication channel between the target process and the to-be-communicated process, the target process belongs to a second application, and the second application and the first application are two different applications of the terminal; The communication channel sends an access request of the to-be-communicated process to the target process to perform communication between the first application and the second application.
  • the embodiment of the present invention provides a first possible implementation manner of the first aspect, wherein the acquiring a first identification number of a process to be communicated and the establishing a target process based on the first identification number
  • the communication channel between the processes to be communicated includes: acquiring a process queue of the terminal, where the process queue is a set of all application processes currently enabled by the terminal; for each of the process queues Extracting the corresponding second identifier by the application process And obtaining, according to each of the second identification numbers, a package name of an application corresponding to the application process to which the second identification number belongs; establishing a mapping relationship between the second identification number and the package name.
  • the embodiment of the present invention provides the second possible implementation manner of the first aspect, wherein the establishing between the second identification number and the package name is After mapping the relationship, including:
  • the establishing a communication channel between the target process and the to-be-communicated process based on the first identification number includes:
  • the embodiment of the present invention provides a third possible implementation manner of the first aspect, wherein the establishing a target process based on the first identification number
  • the communication channel between the processes to be communicated includes: configuring a socket connection to the target process based on the first identification number; establishing a communication channel between the target process and the to-be-communicated process based on the socket connection .
  • the embodiment of the present invention provides a fourth possible implementation manner of the first aspect, wherein the configuring a socket connection to the target process based on the first identification number
  • the step includes: using the first identification number as the port number of the socket connection communication, and using the local IP address of the terminal as the communication IP address of the socket connection.
  • the embodiment of the present invention provides a fifth possible implementation manner of the first aspect, further including:
  • the embodiment of the present invention provides a sixth possible implementation manner of the first aspect, wherein the establishing a communication channel between the target process and the to-be-communicated process based on the first identification number
  • An identification number establishing a one-way communication between the to-be-communicated process and the target process, to establish a communication channel for two-way communication between the target process and the to-be-communicated process.
  • the embodiment of the present invention further provides an apparatus for communicating across processes, where the apparatus includes: a first acquiring module, configured to acquire a first identification number of a process to be communicated, where the to-be-communicated process belongs to the first An application; a first establishing module configured to establish a communication channel between the target process and the to-be-communicated process based on the first identification number, where the target process belongs to a second application, the second application and The first application is two different applications of the terminal; the communication module is configured to send an access request of the to-be-communicated process to the target process through the communication channel, to perform the first application.
  • the program communicates with the second application.
  • the embodiment of the present invention provides a first possible implementation manner of the second aspect, further comprising: a second obtaining module, configured to acquire a process queue of the terminal, where the process queue is a collection of all application processes currently enabled by the terminal; the extraction module is configured to extract a corresponding second identification number for each of the application processes in the process queue; and the third obtaining module is configured to be based on each The second identification number acquires a package name of an application corresponding to the application process to which the second identification number belongs, and the second establishment module is configured to establish a mapping relationship between the second identification number and the package name.
  • the embodiment of the present invention provides a second possible implementation manner of the second aspect, further including a determining module.
  • the determining module is configured to determine, according to the mapping relationship, whether to obtain a third identification number of the target process corresponding to the second application; the first establishing module is further configured to determine that the After the third identifier corresponding to the second application, the communication channel between the target process and the to-be-communicated process is established based on the first identifier.
  • the embodiment of the present invention provides the third possible implementation manner of the second aspect, wherein the first establishing module includes: a configuration unit, configured Forming a socket connection to the target process based on the first identification number; the establishing unit is configured to establish a communication channel between the target process and the to-be-communicated process based on the socket connection.
  • the first establishing module includes: a configuration unit, configured Forming a socket connection to the target process based on the first identification number; the establishing unit is configured to establish a communication channel between the target process and the to-be-communicated process based on the socket connection.
  • the embodiment of the present invention provides a fourth possible implementation manner of the second aspect, wherein the configuration unit is further configured to use the first identification number as The port number of the communication of the socket connection, and the local IP address of the terminal is used as the communication IP address of the socket connection.
  • the embodiment of the present invention provides a fifth possible implementation manner of the second aspect, further including a monitoring module.
  • the monitoring module is configured to perform real-time monitoring on the communication between the first application and the second application based on the first identification number to determine whether the target process has received the to-be-communicated process.
  • the access request is configured to perform real-time monitoring on the communication between the first application and the second application based on the first identification number to determine whether the target process has received the to-be-communicated process.
  • the access request is configured to perform real-time monitoring on the communication between the first application and the second application based on the first identification number to determine whether the target process has received the to-be-communicated process.
  • the embodiment of the present invention provides a sixth possible implementation manner of the second aspect, wherein the first establishing module is further configured to establish the target according to the first identification number of the to-be-communicated process. a one-way communication between the process and the to-be-communicated process; obtaining a third identification number of the target process; establishing a one-way communication between the to-be-communicated process and the target process based on the third identification number of the target process, a communication channel for establishing two-way communication between the target process and the to-be-communicated process
  • an embodiment of the present invention further provides a readable storage medium, wherein the readable storage medium is stored in a computer, the readable storage medium includes a plurality of instructions, and the multiple instructions It is configured to cause a computer to implement the above method.
  • the method and device for the cross-process communication provided by the embodiment of the present invention and the communication method for the cross-application process in the prior art have higher complexity of parameter configuration, resulting in poor applicability, and the data carrying capacity of the communicable communication is relatively high.
  • Low compared to its First obtaining a first identification number of the to-be-communicated process corresponding to the first application, and then establishing a communication channel between the target process and the to-be-communicated process based on the first identification number, where the target process belongs to the second application, and the second application
  • the program and the first application are two different applications of the terminal, and finally the access request of the process to be communicated is sent to the target process through the communication channel, so that the communication between the first application and the second application is performed, and the parameter is unnecessary.
  • the configuration is simple, the applicability is strong, and the communication channel established based on the first identification number realizes high-traffic data carrying, and the utility model is better.
  • FIG. 1 is a flowchart of a method for cross-process communication according to an embodiment of the present invention
  • FIG. 2 is a flowchart of another method for cross-process communication according to an embodiment of the present invention.
  • FIG. 3 is a flowchart of another method for cross-process communication according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of an apparatus for cross-process communication according to an embodiment of the present invention.
  • FIG. 5 is a schematic structural diagram of a first establishing module in an apparatus for cross-process communication according to an embodiment of the present invention.
  • the complexity of the parameter configuration is high, resulting in poor applicability, and is limited by the size of the AIDL delivery parameter, resulting in a lower data carrying capacity of the communication.
  • the present invention provides a method and device for cross-process communication, which is simple in operation, strong in applicability, and capable of carrying high-traffic data communication, and has good practicability.
  • the embodiment of the present invention is to implement communication between two different applications in the same terminal device, where the application system of the terminal may be an Android system, an IOS system, or another application system. Then, the above application may be an application running on the Android platform, or an application running on the IOS platform to meet the different needs of different users. In view of the extensiveness and compatibility of the application of the Android system, the embodiment of the present invention preferably adopts an Android terminal.
  • the method specifically includes the following steps:
  • the method for cross-process communication provided by the embodiment of the present invention first acquires a first identification number of a process to be communicated.
  • the pid is a separate string of numbers for each process in the Android system, which is used to determine the uniqueness of the process in the system. Therefore, the pid of the process can be used as an anchor for interprocess communication. That is, other processes can connect and send data to the process through the pid.
  • the method for cross-process communication provided by the embodiment of the present invention can establish a communication channel between the target process and the process to be communicated, and the establishment of the communication channel depends on the first identification number.
  • the target process belongs to the second application process, and the second application process and the first application process belong to two different applications of the terminal, and the establishment of the communication channel can be implemented between the two different applications. Communication.
  • S103 Send an access request of the to-be-communicated process to the target process through the communication channel, to perform communication between the first application and the second application.
  • the method for cross-process communication provided by the embodiment of the present invention sends an access request sent by the to-be-communicated process to the target process through the communication channel to perform communication between the first application and the second application. .
  • the target process in the embodiment of the present invention can access the process to be communicated in one direction through the above communication channel, and can also establish a new communication channel to the target process, so as to realize one-way access of the process to be communicated to the target process, thereby Two-way communication between the process to be communicated and the target process is implemented.
  • the above two-way communication method can be:
  • the communication channel between the target process and the to-be-communicated process based on the first identification number in step S102 may be the above two-way communication.
  • the cross-process communication method provided by the embodiment of the present invention and the communication method of the cross-application process in the prior art have high complexity of parameter configuration, resulting in poor applicability, and the data carrying capacity of the communicable communication is relatively low.
  • the first identification number of the process to be communicated corresponding to the first application is obtained, and then the communication channel between the target process and the process to be communicated is established based on the first identification number, where the target process belongs to the second application.
  • the second application and the first application are two different applications of the terminal, and finally send an access request of the process to be communicated to the target process through the communication channel, to perform communication between the first application and the second application,
  • the utility model has the advantages of no parameter configuration, simple operation and strong applicability, and the communication channel established based on the first identification number realizes high-flow data bearing, and has good practicability.
  • the method for the cross-process communication establishes all the application processes and their correspondings after acquiring the first identification number of the process to be communicated and before establishing the communication channel.
  • the mapping relationship between the applications so as to determine whether the communication channel is pre-established according to the mapping relationship (that is, whether the application is started), as shown in FIG. 2, specifically implemented by the following steps:
  • the method for cross-process communication provided by the embodiment of the present invention further establishes a mapping relationship between an application process that has been started in the terminal and a corresponding application program, and the relationship between the application process and the application process that is being executed by the application is And can obtain the identification number of the application process.
  • the current system information of the Android system is obtained first, that is, the current process queue of the Android may be obtained by:
  • the above process queue is a collection of all application processes currently enabled by the terminal.
  • the embodiment of the present invention extracts the second identification number of each application process in the process queue, and obtains the package name of the corresponding application according to the second identification number, where
  • the package name of the application is specifically as follows:
  • All the acquired application processes are traversed by using a for loop, and the application package name and the second identification number (ie, process pid) of each item are stored as key value pairs in the newly created map (ie, established).
  • the mapping relationship between the second identification number and the package name is convenient for finding the corresponding identification number according to the corresponding application package name when establishing communication later.
  • the method for the cross-process communication determines whether the third identification number of the target process corresponding to the second application is obtained based on the mapping relationship, and can determine After obtaining the third identification number corresponding to the second application, the communication channel between the target process and the to-be-communicated process is established based on the first identification number.
  • the foregoing implementation manner of establishing a communication channel between the target process and the to-be-communicated process based on the first identification number is: establishing a communication connection of the target process to be communicated by the process to be communicated based on the third identification number, thereby establishing a target process and to be communicated
  • the communication channel between the processes refer to the above-mentioned two-way channel establishment manner, and details are not described herein.
  • another application that can be communicated by an application is defined in a negotiated manner.
  • the foregoing is based on the foregoing. Mapping a relationship, determining whether the third identification number of the target process corresponding to the second application is obtained, and if yes, establishing, according to the third identification number, the process to be communicated corresponding to the first application to access the second application a communication connection of the target process, and then establishing, according to the first identification number, a target process corresponding to the second application to access a communication connection of the process to be communicated corresponding to the first application, and then establishing a communication channel between the target process and the process to be communicated
  • the above-mentioned establishment manner of the bidirectional channel and details are not described herein.
  • the third identification number is not obtained, the corresponding second application is not started. Inter-process communication cannot be started when there is no startup. Therefore, if the case where the identification number cannot be found by the package name occurs, the establishment of the current interprocess communication is stopped, and the problem is returned to the first application.
  • the cross-process communication method provided by the embodiment of the present invention innovatively applies socket communication to the local application layer in consideration of the excellent characteristics of the socket at the network layer.
  • the process of establishing the foregoing communication channel in the embodiment of the present invention specifically includes the following steps:
  • the method for cross-process communication provided by the embodiment of the present invention performs socket connection by:
  • Socket new Socket()
  • the embodiment of the present invention preferably uses a socket to perform a communication connection, and the socket is originally a communication mode of the network layer, and the innovative method in the embodiment of the present invention achieves different local applications through different local ports.
  • the purpose of communication Each process in the Android system will have a corresponding process number, which is a unique identifier in the system after the application is opened, so the number can be used as the port number of a socket communication, so that each application does not need to go. Deliberately set your own unique port number, and can also guarantee that the number will not be repeated.
  • the above method is used to achieve the purpose of establishing a socket connection, and pid is the first identification number of the process to be communicated. After the above socket is established, a communication relationship (communication channel) between the target process and the process to be communicated can be established.
  • BufferedReader bff New BufferedReader(new putStreamReader(socket.getInputStream()));
  • the method for the cross-process communication provided by the embodiment of the present invention also monitors the first identification number as the port number of the socket communication.
  • the above monitoring is implemented by using a serverSocket, and the first identification number of the first application is filled in the serverSocket, and the accept method is executed to perform the monitoring.
  • the method will be built on a thread in Android and continuously loop to execute the monitoring method to achieve real-time monitoring of the communication between the first application and the second application. If there is information sent during the listening process, you can use the following code to achieve:
  • BufferedReaderbr new BufferedReader(new InputStreamReader(s.getInputStream()));
  • the message is judged by the above statement. If the message is not empty, it is determined that a message is received, then the message is started to be read. If the message is empty, it is determined that the message is not received, and the loop continues. .
  • the real communication can begin between the two.
  • the package name and pid of the first application are brought, when the receiver (the second application) receives After the message, a new socket can also be created to send information to the sender (first application) to implement communication.
  • the method for completing the establishment of the two-way communication by using the scoket is: first, acquiring a third identification number of the target process corresponding to the second application, and the target process corresponding to the second application by the communication process of the first application is The communication connection is established through the socket.
  • the third identification number of the target process corresponding to the second application is used as the port number of the socket communication, thereby establishing a one-way channel for the first application to access the second application.
  • the first application sends a message to the second application
  • the message carries the first identification number of the first application
  • the second application acquires the first identification number of the process to be communicated of the first application.
  • a communication connection between the target process corresponding to the second application and the to-be-communicated process of the first application is established by using a socket, and the first identification number of the process to be communicated of the first application is used as the port number of the socket communication, thereby establishing
  • the second application accesses the one-way channel of the first application, and then the bidirectional channel between the first application and the second application is completed.
  • the mobile phone Since then, the communication mode between the two applications of the process has been established, and in the embodiment of the present invention, since it is implemented by the local default ip127.0.0.1 (local IP address) in the mobile phone, the mobile phone can be used regardless of whether the mobile phone is connected to the network.
  • the method for cross-process communication provided by the embodiment of the present invention is not affected by the network, and has strong applicability.
  • the embodiment of the present invention may also close the communication between the first application and the second application by performing close on the socket connection.
  • the cross-process communication method provided by the embodiment of the present invention and the communication method of the cross-application process in the prior art have high complexity of parameter configuration, resulting in poor applicability, and the data carrying capacity of the communicable communication is relatively low.
  • the first identification number of the process to be communicated corresponding to the first application is obtained, and then the communication channel between the target process and the process to be communicated is established based on the first identification number, where the target process belongs to the second application.
  • the second application and the first application are two different applications of the terminal, and finally send an access request of the process to be communicated to the target process through the communication channel, to perform communication between the first application and the second application,
  • the utility model has the advantages of no parameter configuration, simple operation and strong applicability, and the communication channel established based on the first identification number realizes high-flow data bearing, and has good practicability.
  • the embodiment of the invention further provides an apparatus for communicating across processes, the apparatus for performing the above method of cross-process communication.
  • the apparatus includes:
  • the first obtaining module 11 is configured to acquire a first identification number of the to-be-communicated process, where the to-be-communication process belongs to the first application.
  • the first establishing module 22 is configured to establish, according to the first identification number, a communication channel between the target process and the process to be communicated, the target process belongs to the second application, and the second application and the first application are two different terminals of the terminal.
  • An application specifically, for establishing one-way communication between the target process and the to-be-communicated process based on the first identification number of the to-be-communicated process; acquiring a third identification number of the target process; a third identification number of the target process, establishing one-way communication between the to-be-communicated process and the target process, to establish a communication channel between the target process and the to-be-communicated process;
  • a communication module 33 configured to send, by using a communication channel, an access request of a process to be communicated to a target process, to perform An application communicates with a second application.
  • the apparatus for the inter-process communication provided by the embodiment of the present invention further includes:
  • a second acquiring module configured to acquire a process queue of the terminal, where the process queue is a set of all application processes currently enabled by the terminal;
  • An extraction module configured to extract a corresponding second identification number for each application process in the process queue
  • a third obtaining module configured to acquire, according to each second identification number, a package name of an application corresponding to the application process to which the second identification number belongs;
  • the second establishing module is configured to establish a mapping relationship between the second identification number and the package name.
  • the device for cross-process communication provided by the embodiment of the present invention further establishes a mapping relationship between an application process that has been started in the terminal and a corresponding application program, and the relationship between the application process and the application process that is being executed by the application is And can obtain the identification number of the application process.
  • the current system information of the Android system is obtained before the process queue of the terminal is obtained, that is, the current process queue of the Android may be obtained by:
  • the above process queue is a collection of all application processes currently enabled by the terminal.
  • the embodiment of the present invention extracts the second identification number of each application process in the process queue, and obtains the package name of the corresponding application according to the second identification number, where
  • the package name of the application is specifically as follows:
  • All the acquired application processes are traversed by using a for loop, and the application package name and the second identification number (ie, process pid) of each item are stored as key value pairs in the newly created map (ie, established).
  • the mapping relationship between the second identification number and the package name is convenient for finding the corresponding identification number according to the corresponding application package name when establishing communication later.
  • the device for the inter-process communication provided by the embodiment of the present invention further includes a determining module, and the determining module determines, according to the mapping relationship, whether the third identification number of the target process corresponding to the second application is obtained, and the foregoing determining After determining that the third identification number corresponding to the second application is obtained, the module is determined by the first establishing module 22 An identification number establishes a communication channel between the target process and the process to be communicated.
  • another application that is communicable by an application is defined in a negotiated manner, and after obtaining the second application in the embodiment of the present invention, based on the mapping relationship, Determining whether the second application obtains the third identification number of the corresponding target process, and if yes, establishing the communication channel between the target process and the to-be-communicated process based on the first identification number; if not, The third identification number indicates that the corresponding second application is not started. Inter-process communication cannot be started when there is no startup. Therefore, if the case where the identification number cannot be found by the package name occurs, the establishment of the current interprocess communication is stopped, and the problem is returned to the first application.
  • the device for cross-process communication provided by the embodiment of the present invention innovatively applies socket communication to the local application layer.
  • the first establishing module 22 in the embodiment of the present invention includes:
  • the configuration unit 221 is configured to configure a socket connection to the target process based on the first identification number.
  • the establishing unit 222 is configured to establish a communication channel between the target process and the process to be communicated based on the socket connection.
  • the device for cross-process communication provided by the embodiment of the present invention performs socket connection by:
  • Socket new Socket()
  • the embodiment of the present invention preferably uses a socket to perform a communication connection, and the socket is originally a communication mode of the network layer, and the innovative method in the embodiment of the present invention achieves different local applications through different local ports.
  • the purpose of communication Each process in the Android system will have a corresponding process number, which is a unique identifier in the system after the application is opened, so the number can be used as the port number of a socket communication, so that each application does not need to go. Deliberately set your own unique port number, and can also guarantee that the number will not be repeated.
  • the above method is used to achieve the purpose of establishing a socket connection, and pid is the first identification number of the process to be communicated. After the above socket is established, a communication relationship (communication channel) between the target process and the process to be communicated can be established.
  • BufferedReader bff New BufferedReader(new putStreamReader(socket.getInputStream()));
  • the intercepting module in the device for the inter-process communication provided by the embodiment of the present invention also monitors the first identification number as the port number of the socket communication.
  • the above monitoring use ServerSocket is used to implement the first identification number of the first application in the establishment of the serverSocket, and the accept method can be executed to perform the monitoring.
  • the method will be built on a thread in Android and continuously loop to execute the monitoring method to achieve real-time monitoring of the communication between the first application and the second application. If there is information sent during the listening process, you can use the following code to achieve:
  • BufferedReaderbr new BufferedReader(new InputStreamReader(s.getInputStream()));
  • the message is judged by the above statement. If the message is not empty, it is determined that a message is received, then the message is started to be read. If the message is empty, it is determined that the message is not received, and the loop continues. .
  • the real communication can begin between the two.
  • the package name and pid of the first application are carried, and when the receiver (the second application) receives the message, a new socket can also be established to send the information to the sender. An application) to achieve communication.
  • the mobile phone Since the communication between the two applications of the process has been established, and the embodiment of the present invention is implemented by the local default ip127.0.0.1 in the mobile phone, the mobile phone can be used regardless of whether the mobile phone is connected to the network.
  • the device provided for cross-process communication is not affected by the network, and has high applicability.
  • the embodiment of the present invention may also close the communication between the first application and the second application by performing close on the socket connection.
  • the device for cross-process communication provided by the embodiment of the present invention has a higher complexity of parameter configuration than the communication method of the cross-application process in the prior art, resulting in poor applicability and low data carrying capacity of the communicable communication.
  • the first identification number of the process to be communicated corresponding to the first application is obtained, and then the communication channel between the target process and the process to be communicated is established based on the first identification number, where the target process belongs to the second application.
  • the second application and the first application are two different applications of the terminal, and finally send an access request of the process to be communicated to the target process through the communication channel, to perform communication between the first application and the second application,
  • the utility model has the advantages of no parameter configuration, simple operation and strong applicability, and the communication channel established based on the first identification number realizes high-flow data bearing, and has good practicability.
  • the computer program product of the method for performing cross-process communication includes a computer readable storage medium storing program code, and the program code includes instructions for executing the method described in the foregoing method embodiment.
  • program code includes instructions for executing the method described in the foregoing method embodiment.
  • the device for cross-process communication provided by the embodiment of the present invention may be specific hardware on the device or software or firmware installed on the device.
  • the implementation principle and the technical effects of the device provided by the embodiments of the present invention are the same as those of the foregoing method embodiments.
  • a person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working processes of the foregoing system, the device and the unit can refer to the corresponding processes in the foregoing method embodiments, and details are not described herein again.
  • the disclosed apparatus and method may be in other manners. achieve.
  • the device embodiments described above are merely illustrative.
  • the division of the unit is only a logical function division.
  • multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some communication interface, device or unit, and may be electrical, mechanical or otherwise.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
  • each functional unit in the embodiment provided by the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the functions may be stored in a computer readable storage medium if implemented in the form of a software functional unit and sold or used as a standalone product.
  • the technical solution of the present invention which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including
  • the instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .

Abstract

An inter-process communication method, apparatus and readable storage medium, the method comprising: acquiring a first identification number of a process to be communicated, the process to be communicated belonging to a first application program (S101); establishing a communication channel between a target process and the process to be communicated on the basis of the first identification number, the target process belonging to a second application program, and the second application program and the first application program being two different application programs of a terminal (S102); and sending an access request of the process to be communicated to the target process by means of the communication channel so as to carry out communication between the first application program and the second application program (S103); Said method does not require parameter configuration, has a simple operation and has strong adaptability. Furthermore, the communication channel established on the basis of the first identification number implements a high traffic data bearing and is quite practical.

Description

一种跨进程通信的方法、装置及可读取存储介质Method, device and readable storage medium for cross-process communication
本申请要求于2016年11月28日提交中国专利局的申请号为CN201611058913.4、名称为“一种跨进程通信的方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。The present application claims priority to Chinese Patent Application No. CN201611058913.4, entitled "A Method and Apparatus for Inter-Process Communication", filed on November 28, 2016, the entire contents of In this application.
技术领域Technical field
本发明涉及手机应用技术领域,具体而言,涉及一种跨进程通信的方法、装置及可读取存储介质。The present invention relates to the field of mobile phone application technologies, and in particular, to a method and device for cross-process communication and a readable storage medium.
背景技术Background technique
Android系统是一种手持设备(如手机、平板电脑等)的操作系统。由于Android系统比较封闭,每个应用程序只能在为该程序创建的文件系统中读取文件,不可以去其它地方访问。The Android system is an operating system for handheld devices (such as mobile phones, tablets, etc.). Since the Android system is relatively closed, each application can only read files in the file system created for the program, and cannot be accessed elsewhere.
Android系统的上述特点在保证整个系统的安全性和稳定性的同时,也在其他方面存在着明显的缺陷。例如,由于android系统中应用程序之间不能共享内存,使得每个程序相互独立,导致不同的应用程序之间基本无法直接实现相互通信。The above characteristics of the Android system ensure the security and stability of the entire system, and there are obvious defects in other aspects. For example, since the android system cannot share memory between applications, each program is independent of each other, which makes it impossible for different applications to directly communicate with each other.
现有技术中提供了一种基于AIDL(接口定义语言)的跨应用程序进程的通信方法,该方法需要首先在服务端进行AIDL接口的定义和相应的参数配置,然后在客户端完成服务端通过上述定义和配置所能够实现的跨进程通信方法。In the prior art, a communication method based on AIDL (Interface Definition Language) for a cross-application process is provided. The method needs to first define an AIDL interface and corresponding parameter configuration on the server, and then complete the server through the client. The cross-process communication method that can be implemented by the above definition and configuration.
发明人在研究中发现,现有技术中的跨应用程序进程的通信方法,参数配置的复杂度较高,导致适用性较差,且受限于AIDL传递参数的大小而导致通信的数据承载量较低。The inventor found in the research that the communication method of the cross-application process in the prior art has a high complexity of parameter configuration, resulting in poor applicability, and is limited by the size of the AIDL delivery parameter and the data carrying capacity of the communication. Lower.
发明内容Summary of the invention
有鉴于此,本发明的目的在于提供一种跨进程通信的方法、装置及可读取存储介质,操作简单,适用性较强,且能够承载高流量的数据通信,实用性较佳。In view of this, an object of the present invention is to provide a method and apparatus for inter-process communication, and a readable storage medium, which is simple in operation, strong in applicability, and capable of carrying high-traffic data communication, and has good practicability.
第一方面,本发明实施例提供了一种跨进程通信的方法,所述方法包括:获取待通信进程的第一标识号,所述待通信进程属于第一应用程序;基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,所述目标进程属于第二应用程序,所述第二应用程序和所述第一应用程序为终端的两个不同的应用程序;通过所述通信通道将所述待通信进程的访问请求发送至所述目标进程,以进行所述第一应用程序与所述第二应用程序的通信。In a first aspect, an embodiment of the present invention provides a method for communicating across processes, the method includes: acquiring a first identification number of a process to be communicated, where the to-be-communicated process belongs to a first application; and based on the first identifier No. establishing a communication channel between the target process and the to-be-communicated process, the target process belongs to a second application, and the second application and the first application are two different applications of the terminal; The communication channel sends an access request of the to-be-communicated process to the target process to perform communication between the first application and the second application.
结合第一方面,本发明实施例提供了第一方面的第一种可能的实施方式,其中,所述获取待通信进程的第一标识号和所述基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道之间,包括:获取所述终端的进程队列,所述进程队列为所述终端当前启用的所有应用进程的集合;对所述进程队列中的每个所述应用进程均提取对应的第二标识 号;基于每个所述第二标识号获取该第二标识号所属的所述应用进程对应的应用程序的包名;建立所述第二标识号和所述包名之间的映射关系。With reference to the first aspect, the embodiment of the present invention provides a first possible implementation manner of the first aspect, wherein the acquiring a first identification number of a process to be communicated and the establishing a target process based on the first identification number The communication channel between the processes to be communicated includes: acquiring a process queue of the terminal, where the process queue is a set of all application processes currently enabled by the terminal; for each of the process queues Extracting the corresponding second identifier by the application process And obtaining, according to each of the second identification numbers, a package name of an application corresponding to the application process to which the second identification number belongs; establishing a mapping relationship between the second identification number and the package name.
结合第一方面的第一种可能的实施方式,本发明实施例提供了第一方面的第二种可能的实施方式,其中,所述建立所述第二标识号和所述包名之间的映射关系之后,包括:With reference to the first possible implementation manner of the first aspect, the embodiment of the present invention provides the second possible implementation manner of the first aspect, wherein the establishing between the second identification number and the package name is After mapping the relationship, including:
基于所述映射关系,判断是否获取到所述第二应用程序对应的目标进程的第三标识号;Determining, according to the mapping relationship, whether a third identification number of the target process corresponding to the second application is obtained;
所述基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,包括:The establishing a communication channel between the target process and the to-be-communicated process based on the first identification number includes:
在判断出获取到所述第二应用程序对应的所述第三标识号后,基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道。After determining that the third identification number corresponding to the second application is obtained, establishing a communication channel between the target process and the to-be-communicated process based on the first identification number.
结合第一方面或第一方面的第二种可能的实施方式,本发明实施例提供了第一方面的第三种可能的实施方式,其中,所述基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,包括:基于所述第一标识号对所述目标进程配置socket连接;基于所述socket连接建立所述目标进程与所述待通信进程之间的通信通道。With reference to the first aspect or the second possible implementation manner of the first aspect, the embodiment of the present invention provides a third possible implementation manner of the first aspect, wherein the establishing a target process based on the first identification number The communication channel between the processes to be communicated includes: configuring a socket connection to the target process based on the first identification number; establishing a communication channel between the target process and the to-be-communicated process based on the socket connection .
结合第一方面的第三种可能实施方式,本发明实施例提供了第一方面的第四种可能的实施方式,其中,所述的基于所述第一标识号对所述目标进程配置socket连接的步骤包括:将所述第一标识号作为socket连接的通讯的端口号,以所述终端的本地IP地址作为socket连接的通讯IP地址。In conjunction with the third possible implementation of the first aspect, the embodiment of the present invention provides a fourth possible implementation manner of the first aspect, wherein the configuring a socket connection to the target process based on the first identification number The step includes: using the first identification number as the port number of the socket connection communication, and using the local IP address of the terminal as the communication IP address of the socket connection.
结合第一方面,本发明实施例提供了第一方面的第五种可能的实施方式,其中,还包括:With reference to the first aspect, the embodiment of the present invention provides a fifth possible implementation manner of the first aspect, further including:
基于所述第一标识号对所述第一应用程序与所述第二应用程序的通信进行实时监听,以判断所述目标进程是否已经接收所述待通信进程的所述访问请求。And performing real-time monitoring on the communication between the first application and the second application based on the first identification number to determine whether the target process has received the access request of the to-be-communicated process.
结合第一方面,本发明实施例提供了第一方面的第六种可能的实施方式,其中,所述的基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道的步骤包括:基于所述待通信进程的第一标识号,建立所述目标进程与所述待通信进程的单向通信;获取所述目标进程的第三标识号;基于所述目标进程的第三标识号,建立所述待通信进程与所述目标进程的单向通信,以建立目标进程与所述待通信进程之间的双向通信的通信通道。With reference to the first aspect, the embodiment of the present invention provides a sixth possible implementation manner of the first aspect, wherein the establishing a communication channel between the target process and the to-be-communicated process based on the first identification number The step of: establishing a one-way communication between the target process and the to-be-communicated process based on the first identification number of the to-be-communicated process; acquiring a third identification number of the target process; and performing a third process based on the target process An identification number, establishing a one-way communication between the to-be-communicated process and the target process, to establish a communication channel for two-way communication between the target process and the to-be-communicated process.
第二方面,本发明实施例还提供了一种跨进程通信的装置,所述装置包括:第一获取模块,被配置成获取待通信进程的第一标识号,所述待通信进程属于第一应用程序;第一建立模块,被配置成基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,所述目标进程属于第二应用程序,所述第二应用程序和所述第一应用程序为终端的两个不同的应用程序;通信模块,被配置成通过所述通信通道将所述待通信进程的访问请求发送至所述目标进程,以进行所述第一应用程序与所述第二应用程序的通信。 In a second aspect, the embodiment of the present invention further provides an apparatus for communicating across processes, where the apparatus includes: a first acquiring module, configured to acquire a first identification number of a process to be communicated, where the to-be-communicated process belongs to the first An application; a first establishing module configured to establish a communication channel between the target process and the to-be-communicated process based on the first identification number, where the target process belongs to a second application, the second application and The first application is two different applications of the terminal; the communication module is configured to send an access request of the to-be-communicated process to the target process through the communication channel, to perform the first application. The program communicates with the second application.
结合第二方面,本发明实施例提供了第二方面的第一种可能的实施方式,其中,还包括:第二获取模块,被配置成获取所述终端的进程队列,所述进程队列为所述终端当前启用的所有应用进程的集合;提取模块,被配置成对所述进程队列中的每个所述应用进程均提取对应的第二标识号;第三获取模块,被配置成基于每个所述第二标识号获取该第二标识号所属的应用进程对应的应用程序的包名;第二建立模块,被配置成建立所述第二标识号和所述包名之间的映射关系。With reference to the second aspect, the embodiment of the present invention provides a first possible implementation manner of the second aspect, further comprising: a second obtaining module, configured to acquire a process queue of the terminal, where the process queue is a collection of all application processes currently enabled by the terminal; the extraction module is configured to extract a corresponding second identification number for each of the application processes in the process queue; and the third obtaining module is configured to be based on each The second identification number acquires a package name of an application corresponding to the application process to which the second identification number belongs, and the second establishment module is configured to establish a mapping relationship between the second identification number and the package name.
结合第二方面的第一种可能的实施方式,本发明实施例提供了第二方面的第二种可能的实施方式,其中,还包括判断模块。所述判断模块,被配置成基于所述映射关系,判断是否获取到所述第二应用程序对应的目标进程的第三标识号;所述第一建立模块,还被配置成在判断出获取到所述第二应用程序对应的所述第三标识号后,基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道。With reference to the first possible implementation manner of the second aspect, the embodiment of the present invention provides a second possible implementation manner of the second aspect, further including a determining module. The determining module is configured to determine, according to the mapping relationship, whether to obtain a third identification number of the target process corresponding to the second application; the first establishing module is further configured to determine that the After the third identifier corresponding to the second application, the communication channel between the target process and the to-be-communicated process is established based on the first identifier.
结合第二方面或第二方面的第二种可能的实施方式,本发明实施例提供了第二方面的第三种可能的实施方式,其中,所述第一建立模块包括:配置单元,被配置成基于所述第一标识号对所述目标进程配置socket连接;建立单元,被配置成基于所述socket连接建立所述目标进程与所述待通信进程之间的通信通道。With reference to the second aspect or the second possible implementation manner of the second aspect, the embodiment of the present invention provides the third possible implementation manner of the second aspect, wherein the first establishing module includes: a configuration unit, configured Forming a socket connection to the target process based on the first identification number; the establishing unit is configured to establish a communication channel between the target process and the to-be-communicated process based on the socket connection.
结合第二方面的第三种可能的实施方式,本发明实施例提供了第二方面的第四种可能的实施方式,其中,所述配置单元,还被配置成将所述第一标识号作为socket连接的通讯的端口号,以所述终端的本地IP地址作为socket连接的通讯IP地址。With reference to the third possible implementation manner of the second aspect, the embodiment of the present invention provides a fourth possible implementation manner of the second aspect, wherein the configuration unit is further configured to use the first identification number as The port number of the communication of the socket connection, and the local IP address of the terminal is used as the communication IP address of the socket connection.
结合第二方面,本发明实施例提供了第二方面的第五种可能的实施方式,其中,还包括监听模块。所述监听模块,被配置成基于所述第一标识号对所述第一应用程序与所述第二应用程序的通信进行实时监听,以判断所述目标进程是否已经接收所述待通信进程的所述访问请求。With reference to the second aspect, the embodiment of the present invention provides a fifth possible implementation manner of the second aspect, further including a monitoring module. The monitoring module is configured to perform real-time monitoring on the communication between the first application and the second application based on the first identification number to determine whether the target process has received the to-be-communicated process. The access request.
结合第二方面,本发明实施例提供了第二方面的第六种可能的实施方式,其中,第一建立模块,还被配置成基于所述待通信进程的第一标识号,建立所述目标进程与所述待通信进程的单向通信;获取所述目标进程的第三标识号;基于所述目标进程的第三标识号,建立所述待通信进程与所述目标进程的单向通信,以建立目标进程与所述待通信进程之间的双向通信的通信通道With reference to the second aspect, the embodiment of the present invention provides a sixth possible implementation manner of the second aspect, wherein the first establishing module is further configured to establish the target according to the first identification number of the to-be-communicated process. a one-way communication between the process and the to-be-communicated process; obtaining a third identification number of the target process; establishing a one-way communication between the to-be-communicated process and the target process based on the third identification number of the target process, a communication channel for establishing two-way communication between the target process and the to-be-communicated process
第三方面,本发明实施例还提供了一种可读取存储介质,其中,所述可读取存储介质存储于计算机内,所述可读取存储介质包括多条指令,所述多条指令被配置成使得计算机实现上述方法。In a third aspect, an embodiment of the present invention further provides a readable storage medium, wherein the readable storage medium is stored in a computer, the readable storage medium includes a plurality of instructions, and the multiple instructions It is configured to cause a computer to implement the above method.
本发明实施例提供的跨进程通信的方法及装置,与现有技术中的跨应用程序进程的通信方法,参数配置的复杂度较高,导致适用性较差,且可通信的数据承载量较低相比,其 首先获取第一应用程序对应的待通信进程的第一标识号,然后基于该第一标识号建立目标进程与待通信进程之间的通信通道,其中,目标进程属于第二应用程序,第二应用程序和上述第一应用程序为终端的两个不同的应用程序,最后通过通信通道将待通信进程的访问请求发送至目标进程,以进行第一应用程序与第二应用程序的通信,其无需参数配置,操作简单,适用性较强,且基于第一标识号建立的通信通道实现高流量的数据承载,实用性较佳。The method and device for the cross-process communication provided by the embodiment of the present invention and the communication method for the cross-application process in the prior art have higher complexity of parameter configuration, resulting in poor applicability, and the data carrying capacity of the communicable communication is relatively high. Low compared to its First, obtaining a first identification number of the to-be-communicated process corresponding to the first application, and then establishing a communication channel between the target process and the to-be-communicated process based on the first identification number, where the target process belongs to the second application, and the second application The program and the first application are two different applications of the terminal, and finally the access request of the process to be communicated is sent to the target process through the communication channel, so that the communication between the first application and the second application is performed, and the parameter is unnecessary. The configuration is simple, the applicability is strong, and the communication channel established based on the first identification number realizes high-traffic data carrying, and the utility model is better.
为使本发明的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。The above described objects, features and advantages of the present invention will become more apparent from the aspects of the appended claims.
附图说明DRAWINGS
为了更清楚地说明本发明实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,应当理解,以下附图仅示出了本发明的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the embodiments will be briefly described below. It should be understood that the following drawings show only certain embodiments of the present invention, and therefore It should be seen as a limitation on the scope, and those skilled in the art can obtain other related drawings according to these drawings without any creative work.
图1示出了本发明实施例所提供的一种跨进程通信的方法的流程图;FIG. 1 is a flowchart of a method for cross-process communication according to an embodiment of the present invention;
图2示出了本发明实施例所提供的另一种跨进程通信的方法的流程图;FIG. 2 is a flowchart of another method for cross-process communication according to an embodiment of the present invention;
图3示出了本发明实施例所提供的另一种跨进程通信的方法的流程图;FIG. 3 is a flowchart of another method for cross-process communication according to an embodiment of the present invention;
图4示出了本发明实施例所提供的一种跨进程通信的装置的结构示意图;FIG. 4 is a schematic structural diagram of an apparatus for cross-process communication according to an embodiment of the present invention;
图5示出了本发明实施例所提供的一种跨进程通信的装置中第一建立模块的结构示意图。FIG. 5 is a schematic structural diagram of a first establishing module in an apparatus for cross-process communication according to an embodiment of the present invention.
主要元件符号说明:The main component symbol description:
11、第一获取模块;22、第一建立模块;33、通信模块;221、配置单元;222、建立单元。11. The first acquisition module; 22, the first establishment module; 33, the communication module; 221, the configuration unit; 222, the establishment unit.
具体实施方式detailed description
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。通常在此处附图中描述和示出的本发明实施例的组件可以以各种不同的配置来布置和设计。因此,以下对在附图中提供的本发明的实施例的详细描述并非旨在限制要求保护的本发明的范围,而是仅仅表示本发明的选定实施例。基于本发明的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. It is a partial embodiment of the invention, and not all of the embodiments. The components of the embodiments of the invention, which are generally described and illustrated in the figures herein, may be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention in the claims All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
考虑到现有技术中的跨应用程序进程的通信方法,参数配置的复杂度较高,导致适用性较差,且受限于AIDL传递参数的大小而导致通信的数据承载量较低。基于此,本发明 实施例提供了一种跨进程通信的方法及装置,其操作简单,适用性较强,且能够承载高流量的数据通信,实用性较佳。Considering the communication method of the cross-application process in the prior art, the complexity of the parameter configuration is high, resulting in poor applicability, and is limited by the size of the AIDL delivery parameter, resulting in a lower data carrying capacity of the communication. Based on this, the present invention The embodiment provides a method and device for cross-process communication, which is simple in operation, strong in applicability, and capable of carrying high-traffic data communication, and has good practicability.
另外,在阐述本发明实施例提供的跨进程通信的方法及装置之前,首先对本发明实施例的应用场景做简要说明。In addition, before the method and apparatus for the inter-process communication provided by the embodiment of the present invention are described, the application scenario of the embodiment of the present invention is briefly described.
本发明实施例是实现同一个终端设备中的两个不同应用程序之间的通信,其中,上述终端的应用系统可以为Android系统,可以为IOS系统,还可以是其他应用系统。那么,上述应用程序可以是基于Android平台运行的应用程序,还可以是基于IOS平台运行的应用程序,以满足不同用户的不同需求。考虑到Android系统应用的广泛性和兼容性,本发明实施例优选的采用Android终端。The embodiment of the present invention is to implement communication between two different applications in the same terminal device, where the application system of the terminal may be an Android system, an IOS system, or another application system. Then, the above application may be an application running on the Android platform, or an application running on the IOS platform to meet the different needs of different users. In view of the extensiveness and compatibility of the application of the Android system, the embodiment of the present invention preferably adopts an Android terminal.
参见图1所示的本发明实施例所提供的跨进程通信的方法的流程图,所述方法具体包括如下步骤:Referring to the flowchart of the method for cross-process communication provided by the embodiment of the present invention shown in FIG. 1, the method specifically includes the following steps:
S101、获取待通信进程的第一标识号,待通信进程属于第一应用程序;S101. Acquire a first identification number of a process to be communicated, where the communication process belongs to the first application.
具体的,本发明实施例所提供的跨进程通信的方法,首先获取待通信进程的第一标识号。在Android应用中,本发明实施例使用int pid=android.os.Process.myPid()的方式来获取到第一应用程序的第一标识号(进程代号pid)。该pid为Android系统中每个进程的一个单独一串数字,使用该数字来确定进程在系统中的唯一性。因此,该进程的pid可以作为进程间通讯的一个锚点来使用。就是说,其他进程可以通过该pid来连接并发送数据给本进程。Specifically, the method for cross-process communication provided by the embodiment of the present invention first acquires a first identification number of a process to be communicated. In the Android application, the embodiment of the present invention uses int pid=android.os.Process.myPid() to obtain the first identification number (process code pid) of the first application. The pid is a separate string of numbers for each process in the Android system, which is used to determine the uniqueness of the process in the system. Therefore, the pid of the process can be used as an anchor for interprocess communication. That is, other processes can connect and send data to the process through the pid.
S102、基于第一标识号建立目标进程与待通信进程之间的通信通道,目标进程属于第二应用程序,第二应用程序和第一应用程序为终端的两个不同的应用程序;S102. Establish a communication channel between the target process and the to-be-communicated process based on the first identification number, where the target process belongs to the second application, and the second application and the first application are two different applications of the terminal.
具体的,本发明实施例所提供的跨进程通信的方法能够建立目标进程与待通信进程之间的通信通道,其该通信通道的建立依赖于上述第一标识号。Specifically, the method for cross-process communication provided by the embodiment of the present invention can establish a communication channel between the target process and the process to be communicated, and the establishment of the communication channel depends on the first identification number.
其中,上述目标进程属于第二应用进程,且该第二应用进程与上述第一应用进程属于终端的两个不同的应用程序,通过上述通信通道的建立即可实现这两个不同应用程序之间的通信。The target process belongs to the second application process, and the second application process and the first application process belong to two different applications of the terminal, and the establishment of the communication channel can be implemented between the two different applications. Communication.
S103、通过通信通道将待通信进程的访问请求发送至目标进程,以进行第一应用程序与第二应用程序的通信。S103. Send an access request of the to-be-communicated process to the target process through the communication channel, to perform communication between the first application and the second application.
具体的,本发明实施例所提供的跨进程通信的方法,对于待通信进程发送的访问请求,将通过上述通信通道发送至目标进程,以进行第一应用程序与第二应用程序之间的通信。Specifically, the method for cross-process communication provided by the embodiment of the present invention sends an access request sent by the to-be-communicated process to the target process through the communication channel to perform communication between the first application and the second application. .
值得提出的是,本发明实施例中的目标进程通过上述通信通道可以单向访问待通信进程,还可以对目标进程建立新的通信通道,以实现待通信进程对目标进程的单向访问,从而实现了待通信进程和目标进程之间的双向通信。 It is worth mentioning that the target process in the embodiment of the present invention can access the process to be communicated in one direction through the above communication channel, and can also establish a new communication channel to the target process, so as to realize one-way access of the process to be communicated to the target process, thereby Two-way communication between the process to be communicated and the target process is implemented.
上述的双向通信的方式可以是:The above two-way communication method can be:
在获取到待通信进程的第一标识号,基于第一标识号建立目标进程与待通信进程之间的连接,以实现目标进程访问待通信进程,从而建立了目标进程与待通信进程之间的单向通信。然后再获取目标进程的标识号,基于目标进程的标识号建立待通信进程与目标进程之间的连接,以实现待通信进程访问目标进程,从而建立了待通信进程与目标进程之间的单向通信,由此就建立了待通信进程与目标进程之间的双向通信。Obtaining a first identification number of the to-be-communicated process, establishing a connection between the target process and the to-be-communicated process based on the first identification number, so that the target process accesses the to-be-communicated process, thereby establishing a process between the target process and the to-be-communicated process. One-way communication. Then, the identification number of the target process is obtained, and the connection between the communication process and the target process is established based on the identification number of the target process, so that the process to be communicated is accessed to the target process, thereby establishing a one-way relationship between the communication process and the target process. Communication, thereby establishing a two-way communication between the process to be communicated and the target process.
因此,步骤S102中的基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,可以是上述双向通信。Therefore, the communication channel between the target process and the to-be-communicated process based on the first identification number in step S102 may be the above two-way communication.
本发明实施例提供的跨进程通信的方法,与现有技术中的跨应用程序进程的通信方法,参数配置的复杂度较高,导致适用性较差,且可通信的数据承载量较低相比,其首先获取第一应用程序对应的待通信进程的第一标识号,然后基于该第一标识号建立目标进程与待通信进程之间的通信通道,其中,目标进程属于第二应用程序,第二应用程序和上述第一应用程序为终端的两个不同的应用程序,最后通过通信通道将待通信进程的访问请求发送至目标进程,以进行第一应用程序与第二应用程序的通信,其无需参数配置,操作简单,适用性较强,且基于第一标识号建立的通信通道实现高流量的数据承载,实用性较佳。The cross-process communication method provided by the embodiment of the present invention and the communication method of the cross-application process in the prior art have high complexity of parameter configuration, resulting in poor applicability, and the data carrying capacity of the communicable communication is relatively low. First, the first identification number of the process to be communicated corresponding to the first application is obtained, and then the communication channel between the target process and the process to be communicated is established based on the first identification number, where the target process belongs to the second application. The second application and the first application are two different applications of the terminal, and finally send an access request of the process to be communicated to the target process through the communication channel, to perform communication between the first application and the second application, The utility model has the advantages of no parameter configuration, simple operation and strong applicability, and the communication channel established based on the first identification number realizes high-flow data bearing, and has good practicability.
为了进一步保证通信的安全性和实时性,本发明实施例所提供的跨进程通信的方法在获取待通信进程的第一标识号之后,以及建立通信通道之前还建立了所有的应用进程及其对应的应用程序之间的映射关系,以便于根据该映射关系对通信通道是否建立进行先决条件(即应用是否启动)的判断,参见图2,具体通过如下步骤进行实现:In order to further ensure the security and the real-time performance of the communication, the method for the cross-process communication provided by the embodiment of the present invention establishes all the application processes and their correspondings after acquiring the first identification number of the process to be communicated and before establishing the communication channel. The mapping relationship between the applications, so as to determine whether the communication channel is pre-established according to the mapping relationship (that is, whether the application is started), as shown in FIG. 2, specifically implemented by the following steps:
S201、获取终端的进程队列,进程队列为终端当前启用的所有应用进程的集合;S201: Obtain a process queue of the terminal, where the process queue is a set of all application processes currently enabled by the terminal;
S202、对进程队列中的每个应用进程均提取对应的第二标识号;S202. Extract a corresponding second identification number for each application process in the process queue.
S203、基于每个第二标识号获取该第二标识号所属的应用进程对应的应用程序的包名;S203. Acquire, according to each second identification number, a package name of an application corresponding to the application process to which the second identification number belongs;
S204、建立第二标识号和包名之间的映射关系。S204. Establish a mapping relationship between the second identification number and the package name.
具体的,本发明实施例所提供的跨进程通信的方法还建立了上述终端中已经开启的应用进程与对应的应用程序之间的映射关系,通过该关系,可以到应用程序正在进行的应用进程中,且能够获得该应用进程的标识号。Specifically, the method for cross-process communication provided by the embodiment of the present invention further establishes a mapping relationship between an application process that has been started in the terminal and a corresponding application program, and the relationship between the application process and the application process that is being executed by the application is And can obtain the identification number of the application process.
本发明实施例中在获取终端的进程队列之前,首先获取了Android系统的当前的系统信息,即可以通过如下方式获取Android当前的进程队列:In the embodiment of the present invention, before acquiring the process queue of the terminal, the current system information of the Android system is obtained first, that is, the current process queue of the Android may be obtained by:
ActivityManager mActivityManager=ActivityManager mActivityManager=
(ActivityManager)this.getSystemService(ACTIVITY_SERVICE);(ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo>mRunningProcess= mActivityManager.getRunningAppProcesses();List<ActivityManager.RunningAppProcessInfo>mRunningProcess= mActivityManager.getRunningAppProcesses();
上述进程队列是终端当前启用的所有应用进程的集合。在获取到进程队列后,本发明实施例将对该进程队列中的每个应用进程进行第二标识号的提取,并能够根据该第二标识号得到对应的应用程序的包名,其中,获取应用程序的包名具体通过如下方式:The above process queue is a collection of all application processes currently enabled by the terminal. After obtaining the process queue, the embodiment of the present invention extracts the second identification number of each application process in the process queue, and obtains the package name of the corresponding application according to the second identification number, where The package name of the application is specifically as follows:
Figure PCTCN2017079614-appb-000001
Figure PCTCN2017079614-appb-000001
通过使用一个for循环将该获取到的所有应用进程进行遍历,并将其中的每一项的应用包名和第二标识号(即进程pid)分别作为键值对存储到新建的map中(即建立了第二标识号和包名之间的映射关系),方便以后建立通讯的时候根据对应的应用包名查找对应的标识号。All the acquired application processes are traversed by using a for loop, and the application package name and the second identification number (ie, process pid) of each item are stored as key value pairs in the newly created map (ie, established). The mapping relationship between the second identification number and the package name is convenient for finding the corresponding identification number according to the corresponding application package name when establishing communication later.
另外,本发明实施例所提供的跨进程通信的方法在建立了上述映射关系后,将基于映射关系,判断是否获取到第二应用程序对应的目标进程的第三标识号,并能够在判断出获取到第二应用程序对应的第三标识号后,基于第一标识号建立目标进程与待通信进程之间的通信通道。具体地,上述的基于第一标识号建立目标进程与待通信进程之间的通信通道的实施方式为:基于第三标识号建立待通信进程访问目标进程的通信连接,进而建立目标进程与待通信进程之间的通信通道,具体可参考上述的双向通道的建立方式,在此不再赘述。In addition, after the foregoing mapping relationship is established, the method for the cross-process communication provided by the embodiment of the present invention determines whether the third identification number of the target process corresponding to the second application is obtained based on the mapping relationship, and can determine After obtaining the third identification number corresponding to the second application, the communication channel between the target process and the to-be-communicated process is established based on the first identification number. Specifically, the foregoing implementation manner of establishing a communication channel between the target process and the to-be-communicated process based on the first identification number is: establishing a communication connection of the target process to be communicated by the process to be communicated based on the third identification number, thereby establishing a target process and to be communicated For the communication channel between the processes, refer to the above-mentioned two-way channel establishment manner, and details are not described herein.
具体的,考虑到在Android系统开发时,已经通过协商的方式对一个应用程序可通信的其他应用程序进行了限定,本发明实施例中在获取到第二应用程序的包名后,将基于上述映射关系,判断是否获取到了第二应用程序对应的目标进程的第三标识号,如果已经获取到,则基于上述第三标识号建立第一应用程序对应的待通信进程访问第二应用程序对应的目标进程的通信连接,再基于第一标识号建立第二应用程序对应的目标进程访问第一应用程序对应的待通信进程的通信连接,进而进行目标进程与待通信进程之间的通信通道的建立,具体可参考上述的双向通道的建立方式,在此不再赘述;如果没有获取到第三标识号说明该对应的第二应用程序没有启动。在没有启动时,进程间的通讯是无法启动的。因此,如果出现通过包名找不到标识号的情况,则停止当前的进程间通讯的建立,并将其问题返回给第一应用程序。Specifically, in the development of the Android system, another application that can be communicated by an application is defined in a negotiated manner. In the embodiment of the present invention, after obtaining the package name of the second application, the foregoing is based on the foregoing. Mapping a relationship, determining whether the third identification number of the target process corresponding to the second application is obtained, and if yes, establishing, according to the third identification number, the process to be communicated corresponding to the first application to access the second application a communication connection of the target process, and then establishing, according to the first identification number, a target process corresponding to the second application to access a communication connection of the process to be communicated corresponding to the first application, and then establishing a communication channel between the target process and the process to be communicated For details, refer to the above-mentioned establishment manner of the bidirectional channel, and details are not described herein. If the third identification number is not obtained, the corresponding second application is not started. Inter-process communication cannot be started when there is no startup. Therefore, if the case where the identification number cannot be found by the package name occurs, the establishment of the current interprocess communication is stopped, and the problem is returned to the first application.
考虑到socket在网络层的优良特性,本发明实施例所提供的跨进程通信的方法创新性的将socket通信应用到本地应用层中。参见图3,本发明实施例的上述通信通道的建立过程具体包括如下步骤: The cross-process communication method provided by the embodiment of the present invention innovatively applies socket communication to the local application layer in consideration of the excellent characteristics of the socket at the network layer. Referring to FIG. 3, the process of establishing the foregoing communication channel in the embodiment of the present invention specifically includes the following steps:
S301、基于第一标识号对目标进程配置socket连接;S301. Configure a socket connection to the target process based on the first identification number.
S302、基于socket连接建立目标进程与待通信进程之间的通信通道。S302. Establish a communication channel between the target process and the to-be-communicated process based on the socket connection.
具体的,本发明实施例所提供的跨进程通信的方法通过如下方式进行socket连接:Specifically, the method for cross-process communication provided by the embodiment of the present invention performs socket connection by:
socket=new Socket();Socket=new Socket();
socket.connect(new InetSocketAddress("127.0.0.1",pid),5000);Socket.connect(new InetSocketAddress("127.0.0.1",pid),5000);
可见,本发明实施例优选的采用socket来进行通信连接,socket原本是网络层的一种通讯方式,而在本发明实施例中创新性的将该方式通过本地端口的不同而达到本地不同应用之间进行通讯的目的。Android系统中每个进程都会有一个对应的进程号,该进程号为该应用开启后在系统中的一个唯一标识,因此可以使用该号作为一个socket通讯的端口号,这样每个应用就不用去特意设置自己的唯一端口号了,而且也能保证该号不会重复。使用上述方法来达到建立socket连接的目的,pid为待通信进程的第一标识号。在建立上述socket后,将可以建立目标进程与待通信进程之间的通讯关系(通信通道)。It can be seen that the embodiment of the present invention preferably uses a socket to perform a communication connection, and the socket is originally a communication mode of the network layer, and the innovative method in the embodiment of the present invention achieves different local applications through different local ports. The purpose of communication. Each process in the Android system will have a corresponding process number, which is a unique identifier in the system after the application is opened, so the number can be used as the port number of a socket communication, so that each application does not need to go. Deliberately set your own unique port number, and can also guarantee that the number will not be repeated. The above method is used to achieve the purpose of establishing a socket connection, and pid is the first identification number of the process to be communicated. After the above socket is established, a communication relationship (communication channel) between the target process and the process to be communicated can be established.
其中,本发明实施例可以通过如下具体方式实现第一应用程序向第二应用程序发送访问需求的功能:The embodiment of the present invention can implement the function that the first application sends the access requirement to the second application by using the following specific manner:
OutputStream ou=socket.getOutputStream();OutputStream ou=socket.getOutputStream();
BufferedReader bff=New BufferedReader(new putStreamReader(socket.getInputStream()));BufferedReader bff=New BufferedReader(new putStreamReader(socket.getInputStream()));
ou.write("android一个应用".getBytes("gbk"));Ou.write("android one application".getBytes("gbk"));
ou.flush();Ou.flush();
通过和getInputStream和getOutputStream获取输入输出流,并通过ou.write向第二应用程序发送访问请求。Get the input and output streams with getInputStream and getOutputStream, and send an access request to the second application via ou.write.
本发明实施例所提供的跨进程通信的方法在获取到待通信进程的第一标识号后,还将该第一标识号作为socket通信的端口号进行监听。其中,上述监听使用serverSocket来实现,在建立serverSocket中填入第一应用程序的第一标识号,并执行accept方法即可执行监听。该方法将在Android中建立在一个线程上,并不断循环来执行监听方法,用以达到实时监听第一应用程序与第二应用程序的通信的目的。如果在监听过程中有信息发送过来,则可以使用如下代码来实现:After obtaining the first identification number of the to-be-communicated process, the method for the cross-process communication provided by the embodiment of the present invention also monitors the first identification number as the port number of the socket communication. Wherein, the above monitoring is implemented by using a serverSocket, and the first identification number of the first application is filled in the serverSocket, and the accept method is executed to perform the monitoring. The method will be built on a thread in Android and continuously loop to execute the monitoring method to achieve real-time monitoring of the communication between the first application and the second application. If there is information sent during the listening process, you can use the following code to achieve:
BufferedReaderbr=new BufferedReader(new InputStreamReader(s.getInputStream()));BufferedReaderbr=new BufferedReader(new InputStreamReader(s.getInputStream()));
String mess=br.readLine()。String mess=br.readLine().
在不断的监听循环中,通过上述语句对mess进行判断,如果mess不为空,则断定有消息被接收,则开始读取该消息,如果mess为空,则判定没有接收到该消息,继续循环。In the continuous listening loop, the message is judged by the above statement. If the message is not empty, it is determined that a message is received, then the message is started to be read. If the message is empty, it is determined that the message is not received, and the loop continues. .
在第二应用程序接收到访问请求后,两者之间就可以开始真正的通讯了。在本发明实施例中每次发送消息都会带上第一应用程序的包名和pid,当接收方(第二应用程序)接收 到该消息后同样可以建立新的socket来发送信息给发送方(第一应用程序)来实现通讯。具体地,利用scoket完成上述双向通信的建立的方式为:首先,获取第二应用程序对应的目标进程的第三标识号,第一应用程序的待通信进程与第二应用程序对应的目标进程之间通过socket建立通信连接,此时,将第二应用程序对应的目标进程的第三标识号作为socket通信的端口号,从而建立第一应用程序访问第二应用程序的单向通道。当第一应用程序向第二应用程序发送消息的时候,该消息内携带有第一应用程序的第一标识号,则第二应用程序获取到了第一应用程序的待通信进程的第一标识号,第二应用程序对应的目标进程与第一应用程序的待通信进程之间通过socket建立通信连接,则将第一应用程序的待通信进程的第一标识号作为socket通信的端口号,从而建立第二应用程序访问第一应用程序的单向通道,则此时完成了第一应用程序和第二应用程序之间的双向通道。After the second application receives the access request, the real communication can begin between the two. In the embodiment of the present invention, each time the message is sent, the package name and pid of the first application are brought, when the receiver (the second application) receives After the message, a new socket can also be created to send information to the sender (first application) to implement communication. Specifically, the method for completing the establishment of the two-way communication by using the scoket is: first, acquiring a third identification number of the target process corresponding to the second application, and the target process corresponding to the second application by the communication process of the first application is The communication connection is established through the socket. At this time, the third identification number of the target process corresponding to the second application is used as the port number of the socket communication, thereby establishing a one-way channel for the first application to access the second application. When the first application sends a message to the second application, the message carries the first identification number of the first application, and the second application acquires the first identification number of the process to be communicated of the first application. a communication connection between the target process corresponding to the second application and the to-be-communicated process of the first application is established by using a socket, and the first identification number of the process to be communicated of the first application is used as the port number of the socket communication, thereby establishing The second application accesses the one-way channel of the first application, and then the bidirectional channel between the first application and the second application is completed.
自此,进程间两个应用的通讯方式已经建立,而且本发明实施例中由于是手机中本地默认ip127.0.0.1(本地IP地址)来实现的,因此无论手机是否联网都可以使用,因此本发明实施例所提供的跨进程通信的方法不受网络的影响,适用性较强。Since then, the communication mode between the two applications of the process has been established, and in the embodiment of the present invention, since it is implemented by the local default ip127.0.0.1 (local IP address) in the mobile phone, the mobile phone can be used regardless of whether the mobile phone is connected to the network. The method for cross-process communication provided by the embodiment of the present invention is not affected by the network, and has strong applicability.
另外,本发明实施例还可以通过对socket连接执行close关闭第一应用程序和第二应用程序之间的通信。In addition, the embodiment of the present invention may also close the communication between the first application and the second application by performing close on the socket connection.
本发明实施例提供的跨进程通信的方法,与现有技术中的跨应用程序进程的通信方法,参数配置的复杂度较高,导致适用性较差,且可通信的数据承载量较低相比,其首先获取第一应用程序对应的待通信进程的第一标识号,然后基于该第一标识号建立目标进程与待通信进程之间的通信通道,其中,目标进程属于第二应用程序,第二应用程序和上述第一应用程序为终端的两个不同的应用程序,最后通过通信通道将待通信进程的访问请求发送至目标进程,以进行第一应用程序与第二应用程序的通信,其无需参数配置,操作简单,适用性较强,且基于第一标识号建立的通信通道实现高流量的数据承载,实用性较佳。The cross-process communication method provided by the embodiment of the present invention and the communication method of the cross-application process in the prior art have high complexity of parameter configuration, resulting in poor applicability, and the data carrying capacity of the communicable communication is relatively low. First, the first identification number of the process to be communicated corresponding to the first application is obtained, and then the communication channel between the target process and the process to be communicated is established based on the first identification number, where the target process belongs to the second application. The second application and the first application are two different applications of the terminal, and finally send an access request of the process to be communicated to the target process through the communication channel, to perform communication between the first application and the second application, The utility model has the advantages of no parameter configuration, simple operation and strong applicability, and the communication channel established based on the first identification number realizes high-flow data bearing, and has good practicability.
本发明实施例还提供了一种跨进程通信的装置,所述装置用于执行上述跨进程通信的方法。参见图4,所述装置包括:The embodiment of the invention further provides an apparatus for communicating across processes, the apparatus for performing the above method of cross-process communication. Referring to Figure 4, the apparatus includes:
第一获取模块11,用于获取待通信进程的第一标识号,待通信进程属于第一应用程序;The first obtaining module 11 is configured to acquire a first identification number of the to-be-communicated process, where the to-be-communication process belongs to the first application.
第一建立模块22,用于基于第一标识号建立目标进程与待通信进程之间的通信通道,目标进程属于第二应用程序,第二应用程序和第一应用程序为终端的两个不同的应用程序,具体地,用于基于所述待通信进程的第一标识号,建立所述目标进程与所述待通信进程的单向通信;获取所述目标进程的第三标识号;基于所述目标进程的第三标识号,建立所述待通信进程与所述目标进程的单向通信,以建立目标进程与所述待通信进程之间的通信通道;The first establishing module 22 is configured to establish, according to the first identification number, a communication channel between the target process and the process to be communicated, the target process belongs to the second application, and the second application and the first application are two different terminals of the terminal. An application, specifically, for establishing one-way communication between the target process and the to-be-communicated process based on the first identification number of the to-be-communicated process; acquiring a third identification number of the target process; a third identification number of the target process, establishing one-way communication between the to-be-communicated process and the target process, to establish a communication channel between the target process and the to-be-communicated process;
通信模块33,用于通过通信通道将待通信进程的访问请求发送至目标进程,以进行第 一应用程序与第二应用程序的通信。a communication module 33, configured to send, by using a communication channel, an access request of a process to be communicated to a target process, to perform An application communicates with a second application.
进一步的,为了进一步保证通信的安全性和实时性,本发明实施例所提供的跨进程通信的装置还包括:Further, in order to further ensure the security and the real-time performance of the communication, the apparatus for the inter-process communication provided by the embodiment of the present invention further includes:
第二获取模块,用于获取终端的进程队列,进程队列为终端当前启用的所有应用进程的集合;a second acquiring module, configured to acquire a process queue of the terminal, where the process queue is a set of all application processes currently enabled by the terminal;
提取模块,用于对进程队列中的每个应用进程均提取对应的第二标识号;An extraction module, configured to extract a corresponding second identification number for each application process in the process queue;
第三获取模块,用于基于每个第二标识号获取该第二标识号所属的应用进程对应的应用程序的包名;a third obtaining module, configured to acquire, according to each second identification number, a package name of an application corresponding to the application process to which the second identification number belongs;
第二建立模块,用于建立第二标识号和包名之间的映射关系。The second establishing module is configured to establish a mapping relationship between the second identification number and the package name.
具体的,本发明实施例所提供的跨进程通信的装置还建立了上述终端中已经开启的应用进程与对应的应用程序之间的映射关系,通过该关系,可以到应用程序正在进行的应用进程中,且能够获得该应用进程的标识号。Specifically, the device for cross-process communication provided by the embodiment of the present invention further establishes a mapping relationship between an application process that has been started in the terminal and a corresponding application program, and the relationship between the application process and the application process that is being executed by the application is And can obtain the identification number of the application process.
本发明实施例中在获取终端的进程队列之前首先获取了Android系统的当前的系统信息,即可以通过如下方式获取Android当前的进程队列:In the embodiment of the present invention, the current system information of the Android system is obtained before the process queue of the terminal is obtained, that is, the current process queue of the Android may be obtained by:
ActivityManager mActivityManager=ActivityManager mActivityManager=
(ActivityManager)this.getSystemService(ACTIVITY_SERVICE);(ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
List<ActivityManager.RunningAppProcessInfo>mRunningProcess=mActivityManager.getRunningAppProcesses();List<ActivityManager.RunningAppProcessInfo>mRunningProcess=mActivityManager.getRunningAppProcesses();
上述进程队列是终端当前启用的所有应用进程的集合。在获取到进程队列后,本发明实施例将对该进程队列中的每个应用进程进行第二标识号的提取,并能够根据该第二标识号得到对应的应用程序的包名,其中,获取应用程序的包名具体通过如下方式:The above process queue is a collection of all application processes currently enabled by the terminal. After obtaining the process queue, the embodiment of the present invention extracts the second identification number of each application process in the process queue, and obtains the package name of the corresponding application according to the second identification number, where The package name of the application is specifically as follows:
Figure PCTCN2017079614-appb-000002
Figure PCTCN2017079614-appb-000002
通过使用一个for循环将该获取到的所有应用进程进行遍历,并将其中的每一项的应用包名和第二标识号(即进程pid)分别作为键值对存储到新建的map中(即建立了第二标识号和包名之间的映射关系),方便以后建立通讯的时候根据对应的应用包名查找对应的标识号。All the acquired application processes are traversed by using a for loop, and the application package name and the second identification number (ie, process pid) of each item are stored as key value pairs in the newly created map (ie, established). The mapping relationship between the second identification number and the package name is convenient for finding the corresponding identification number according to the corresponding application package name when establishing communication later.
另外,本发明实施例所提供的跨进程通信的装置还包括判断模块,该判断模块,将基于映射关系,判断是否获取到第二应用程序对应的目标进程的第三标识号,另外,上述判断模块在判断出获取到第二应用程序对应的第三标识号后,将通过第一建立模块22基于第 一标识号建立目标进程与待通信进程之间的通信通道。In addition, the device for the inter-process communication provided by the embodiment of the present invention further includes a determining module, and the determining module determines, according to the mapping relationship, whether the third identification number of the target process corresponding to the second application is obtained, and the foregoing determining After determining that the third identification number corresponding to the second application is obtained, the module is determined by the first establishing module 22 An identification number establishes a communication channel between the target process and the process to be communicated.
具体的,考虑到在Android系统开发时,已经通过协商的方式对一个应用程序可通信的其他应用程序进行了限定,本发明实施例中在获取到第二应用程序后,将基于上述映射关系,判断该第二应用程序是否获取到了对应的目标进程的第三标识号,如果已经获取到,则基于上述第一标识号进行目标进程与待通信进程之间的通信通道的建立;如果没有获取到第三标识号说明该对应的第二应用程序没有启动。在没有启动时,进程间的通讯是无法启动的。因此,如果出现通过包名找不到标识号的情况,则停止当前的进程间通讯的建立,并将其问题返回给第一应用程序。Specifically, it is considered that, in the development of the Android system, another application that is communicable by an application is defined in a negotiated manner, and after obtaining the second application in the embodiment of the present invention, based on the mapping relationship, Determining whether the second application obtains the third identification number of the corresponding target process, and if yes, establishing the communication channel between the target process and the to-be-communicated process based on the first identification number; if not, The third identification number indicates that the corresponding second application is not started. Inter-process communication cannot be started when there is no startup. Therefore, if the case where the identification number cannot be found by the package name occurs, the establishment of the current interprocess communication is stopped, and the problem is returned to the first application.
考虑到socket在网络层的优良特性,本发明实施例所提供的跨进程通信的装置创新性的将socket通信应用到本地应用层中。参见图5,本发明实施例中的第一建立模块22包括:Considering the excellent characteristics of the socket at the network layer, the device for cross-process communication provided by the embodiment of the present invention innovatively applies socket communication to the local application layer. Referring to FIG. 5, the first establishing module 22 in the embodiment of the present invention includes:
配置单元221,用于基于第一标识号对目标进程配置socket连接;The configuration unit 221 is configured to configure a socket connection to the target process based on the first identification number.
建立单元222,用于基于socket连接建立目标进程与待通信进程之间的通信通道。The establishing unit 222 is configured to establish a communication channel between the target process and the process to be communicated based on the socket connection.
具体的,本发明实施例所提供的跨进程通信的装置通过如下方式进行socket连接:Specifically, the device for cross-process communication provided by the embodiment of the present invention performs socket connection by:
socket=new Socket();Socket=new Socket();
socket.connect(new InetSocketAddress("127.0.0.1",pid),5000);Socket.connect(new InetSocketAddress("127.0.0.1",pid),5000);
可见,本发明实施例优选的采用socket来进行通信连接,socket原本是网络层的一种通讯方式,而在本发明实施例中创新性的将该方式通过本地端口的不同而达到本地不同应用之间进行通讯的目的。Android系统中每个进程都会有一个对应的进程号,该进程号为该应用开启后在系统中的一个唯一标识,因此可以使用该号作为一个socket通讯的端口号,这样每个应用就不用去特意设置自己的唯一端口号了,而且也能保证该号不会重复。使用上述方法来达到建立socket连接的目的,pid为待通信进程的第一标识号。在建立上述socket后,将可以建立目标进程与待通信进程之间的通讯关系(通信通道)。It can be seen that the embodiment of the present invention preferably uses a socket to perform a communication connection, and the socket is originally a communication mode of the network layer, and the innovative method in the embodiment of the present invention achieves different local applications through different local ports. The purpose of communication. Each process in the Android system will have a corresponding process number, which is a unique identifier in the system after the application is opened, so the number can be used as the port number of a socket communication, so that each application does not need to go. Deliberately set your own unique port number, and can also guarantee that the number will not be repeated. The above method is used to achieve the purpose of establishing a socket connection, and pid is the first identification number of the process to be communicated. After the above socket is established, a communication relationship (communication channel) between the target process and the process to be communicated can be established.
其中,本发明实施例可以通过如下具体方式实现第一应用程序向第二应用程序发送访问需求的功能:The embodiment of the present invention can implement the function that the first application sends the access requirement to the second application by using the following specific manner:
OutputStream ou=socket.getOutputStream();OutputStream ou=socket.getOutputStream();
BufferedReader bff=New BufferedReader(new putStreamReader(socket.getInputStream()));BufferedReader bff=New BufferedReader(new putStreamReader(socket.getInputStream()));
ou.write("android一个应用".getBytes("gbk"));Ou.write("android one application".getBytes("gbk"));
ou.flush();Ou.flush();
通过和getInputStream和getOutputStream获取输入输出流,并通过ou.write向第二应用程序发送访问请求。Get the input and output streams with getInputStream and getOutputStream, and send an access request to the second application via ou.write.
本发明实施例所提供的跨进程通信的装置中的监听模块在获取到待通信进程的第一标识号后,还将该第一标识号作为socket通信的端口号进行监听。其中,上述监听使用 serverSocket来实现,在建立serverSocket中填入第一应用程序的第一标识号,并执行accept方法即可执行监听。该方法将在Android中建立在一个线程上,并不断循环来执行监听方法,用以达到实时监听第一应用程序与第二应用程序的通信的目的。如果在监听过程中有信息发送过来,则可以使用如下代码来实现:After obtaining the first identification number of the to-be-communicated process, the intercepting module in the device for the inter-process communication provided by the embodiment of the present invention also monitors the first identification number as the port number of the socket communication. Among them, the above monitoring use ServerSocket is used to implement the first identification number of the first application in the establishment of the serverSocket, and the accept method can be executed to perform the monitoring. The method will be built on a thread in Android and continuously loop to execute the monitoring method to achieve real-time monitoring of the communication between the first application and the second application. If there is information sent during the listening process, you can use the following code to achieve:
BufferedReaderbr=new BufferedReader(new InputStreamReader(s.getInputStream()));BufferedReaderbr=new BufferedReader(new InputStreamReader(s.getInputStream()));
String mess=br.readLine()。String mess=br.readLine().
在不断的监听循环中,通过上述语句对mess进行判断,如果mess不为空,则断定有消息被接收,则开始读取该消息,如果mess为空,则判定没有接收到该消息,继续循环。In the continuous listening loop, the message is judged by the above statement. If the message is not empty, it is determined that a message is received, then the message is started to be read. If the message is empty, it is determined that the message is not received, and the loop continues. .
在第二应用程序接收到访问请求后,两者之间就可以开始真正的通讯了。在本发明实施例中每次发送消息都会带上第一应用程序的包名和pid,当接收方(第二应用程序)接收到该消息后同样可以建立新的socket来发送信息给发送方(第一应用程序)来实现通讯。After the second application receives the access request, the real communication can begin between the two. In the embodiment of the present invention, each time the message is sent, the package name and pid of the first application are carried, and when the receiver (the second application) receives the message, a new socket can also be established to send the information to the sender. An application) to achieve communication.
自此,进程间两个应用的通讯方式已经建立,而且本发明实施例中由于是手机中本地默认ip127.0.0.1来实现的,因此无论手机是否联网都可以使用,因此本发明实施例所提供的跨进程通信的装置不受网络的影响,适用性较强。Since the communication between the two applications of the process has been established, and the embodiment of the present invention is implemented by the local default ip127.0.0.1 in the mobile phone, the mobile phone can be used regardless of whether the mobile phone is connected to the network. The device provided for cross-process communication is not affected by the network, and has high applicability.
另外,本发明实施例还可以通过对socket连接执行close关闭第一应用程序和第二应用程序之间的通信。In addition, the embodiment of the present invention may also close the communication between the first application and the second application by performing close on the socket connection.
本发明实施例提供的跨进程通信的装置,与现有技术中的跨应用程序进程的通信方法,参数配置的复杂度较高,导致适用性较差,且可通信的数据承载量较低相比,其首先获取第一应用程序对应的待通信进程的第一标识号,然后基于该第一标识号建立目标进程与待通信进程之间的通信通道,其中,目标进程属于第二应用程序,第二应用程序和上述第一应用程序为终端的两个不同的应用程序,最后通过通信通道将待通信进程的访问请求发送至目标进程,以进行第一应用程序与第二应用程序的通信,其无需参数配置,操作简单,适用性较强,且基于第一标识号建立的通信通道实现高流量的数据承载,实用性较佳。The device for cross-process communication provided by the embodiment of the present invention has a higher complexity of parameter configuration than the communication method of the cross-application process in the prior art, resulting in poor applicability and low data carrying capacity of the communicable communication. First, the first identification number of the process to be communicated corresponding to the first application is obtained, and then the communication channel between the target process and the process to be communicated is established based on the first identification number, where the target process belongs to the second application. The second application and the first application are two different applications of the terminal, and finally send an access request of the process to be communicated to the target process through the communication channel, to perform communication between the first application and the second application, The utility model has the advantages of no parameter configuration, simple operation and strong applicability, and the communication channel established based on the first identification number realizes high-flow data bearing, and has good practicability.
本发明实施例所提供的进行跨进程通信的方法的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行前面方法实施例中所述的方法,具体实现可参见方法实施例,在此不再赘述。The computer program product of the method for performing cross-process communication provided by the embodiment of the present invention includes a computer readable storage medium storing program code, and the program code includes instructions for executing the method described in the foregoing method embodiment. For specific implementations, refer to method embodiments, and details are not described herein again.
本发明实施例所提供的跨进程通信的装置可以为设备上的特定硬件或者安装于设备上的软件或固件等。本发明实施例所提供的装置,其实现原理及产生的技术效果和前述方法实施例相同,为简要描述,装置实施例部分未提及之处,可参考前述方法实施例中相应内容。所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,前述描述的系统、装置和单元的具体工作过程,均可以参考上述方法实施例中的对应过程,在此不再赘述。The device for cross-process communication provided by the embodiment of the present invention may be specific hardware on the device or software or firmware installed on the device. The implementation principle and the technical effects of the device provided by the embodiments of the present invention are the same as those of the foregoing method embodiments. For a brief description, where the device embodiment is not mentioned, reference may be made to the corresponding content in the foregoing method embodiments. A person skilled in the art can clearly understand that for the convenience and brevity of the description, the specific working processes of the foregoing system, the device and the unit can refer to the corresponding processes in the foregoing method embodiments, and details are not described herein again.
在本发明所提供的实施例中,应该理解到,所揭露装置和方法,可以通过其它的方式 实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be in other manners. achieve. The device embodiments described above are merely illustrative. For example, the division of the unit is only a logical function division. In actual implementation, there may be another division manner. For example, multiple units or components may be combined or Can be integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some communication interface, device or unit, and may be electrical, mechanical or otherwise.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, may be located in one place, or may be distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of the embodiment.
另外,在本发明提供的实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in the embodiment provided by the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本发明各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。The functions may be stored in a computer readable storage medium if implemented in the form of a software functional unit and sold or used as a standalone product. Based on such understanding, the technical solution of the present invention, which is essential or contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product, which is stored in a storage medium, including The instructions are used to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, and the like. .
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释,此外,术语“第一”、“第二”、“第三”等仅用于区分描述,而不能理解为指示或暗示相对重要性。It should be noted that similar reference numerals and letters indicate similar items in the following figures. Therefore, once an item is defined in a drawing, it is not necessary to further define and explain it in the subsequent drawings. Moreover, the terms "first", "second", "third", and the like are used merely to distinguish a description, and are not to be construed as indicating or implying a relative importance.
最后应说明的是:以上所述实施例,仅为本发明的具体实施方式,用以说明本发明的技术方案,而非对其限制,本发明的保护范围并不局限于此,尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本发明实施例技术方案的精神和范围。都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应所述以权利要求的保护范围为准。 Finally, it should be noted that the above-mentioned embodiments are merely specific embodiments of the present invention, and are used to explain the technical solutions of the present invention, and are not limited thereto, and the scope of protection of the present invention is not limited thereto, although reference is made to the foregoing. The present invention has been described in detail, and those skilled in the art should understand that any one skilled in the art can still modify the technical solutions described in the foregoing embodiments within the technical scope disclosed by the present invention. The changes may be easily conceived, or equivalents may be substituted for some of the technical features. The modifications, variations, and substitutions of the present invention do not depart from the spirit and scope of the technical solutions of the embodiments of the present invention. All should be covered by the scope of the present invention. Therefore, the scope of the invention should be determined by the scope of the claims.

Claims (15)

  1. 一种跨进程通信的方法,其特征在于,包括:A method for cross-process communication, comprising:
    获取待通信进程的第一标识号,所述待通信进程属于第一应用程序;Obtaining a first identification number of the process to be communicated, where the to-be-communicated process belongs to the first application;
    基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,所述目标进程属于第二应用程序,所述第二应用程序和所述第一应用程序为终端的两个不同的应用程序;Establishing a communication channel between the target process and the to-be-communicated process based on the first identification number, where the target process belongs to the second application, and the second application and the first application are two of the terminal Different applications;
    通过所述通信通道将所述待通信进程的访问请求发送至所述目标进程,以进行所述第一应用程序与所述第二应用程序的通信。And transmitting, by the communication channel, an access request of the to-be-communicated process to the target process, to perform communication between the first application and the second application.
  2. 根据权利要求1所述的方法,其特征在于,所述获取待通信进程的第一标识号和所述基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道之间,包括:The method according to claim 1, wherein the obtaining a first identification number of a process to be communicated and the communication channel between the target process and the to-be-communication process based on the first identification number ,include:
    获取所述终端的进程队列,所述进程队列为所述终端当前启用的所有应用进程的集合;Obtaining a process queue of the terminal, where the process queue is a set of all application processes currently enabled by the terminal;
    对所述进程队列中的每个所述应用进程均提取对应的第二标识号;Extracting a corresponding second identification number for each of the application processes in the process queue;
    基于每个所述第二标识号获取该第二标识号所属的应用进程对应的应用程序的包名;Obtaining, according to each of the second identification numbers, a package name of an application corresponding to the application process to which the second identification number belongs;
    建立所述第二标识号和所述包名之间的映射关系。Establishing a mapping relationship between the second identification number and the package name.
  3. 根据权利要求2所述的方法,其特征在于,所述建立所述第二标识号和所述包名之间的映射关系之后,包括:The method according to claim 2, wherein after the mapping relationship between the second identification number and the package name is established, the method includes:
    基于所述映射关系,判断是否获取到所述第二应用程序对应的目标进程的第三标识号;Determining, according to the mapping relationship, whether a third identification number of the target process corresponding to the second application is obtained;
    所述基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,包括:The establishing a communication channel between the target process and the to-be-communicated process based on the first identification number includes:
    在判断出获取到所述第二应用程序对应的所述第三标识号后,基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道。After determining that the third identification number corresponding to the second application is obtained, establishing a communication channel between the target process and the to-be-communicated process based on the first identification number.
  4. 根据权利要求1或3所述的方法,其特征在于,所述基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,包括:The method according to claim 1 or 3, wherein the establishing a communication channel between the target process and the to-be-communicated process based on the first identification number comprises:
    基于所述第一标识号对所述目标进程配置socket连接;基于所述socket连接建立所述目标进程与所述待通信进程之间的通信通道。Configuring a socket connection to the target process based on the first identification number; establishing a communication channel between the target process and the to-be-communicated process based on the socket connection.
  5. 根据权利要求4所述的方法,其特征在于,所述的基于所述第一标识号对所述目标进程配置socket连接的步骤包括:The method according to claim 4, wherein the step of configuring a socket connection to the target process based on the first identification number comprises:
    将所述第一标识号作为socket连接的通讯的端口号,以所述终端的本地IP地址作 为socket连接的通讯IP地址。Using the first identification number as the port number of the communication of the socket connection, and using the local IP address of the terminal The communication IP address that is connected to the socket.
  6. 根据权利要求1所述的方法,其特征在于,还包括:The method of claim 1 further comprising:
    基于所述第一标识号对所述第一应用程序与所述第二应用程序的通信进行实时监听,以判断所述目标进程是否已经接收所述待通信进程的所述访问请求。And performing real-time monitoring on the communication between the first application and the second application based on the first identification number to determine whether the target process has received the access request of the to-be-communicated process.
  7. 根据权利要求1所述的方法,其特征在于,所述的基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道的步骤包括:The method according to claim 1, wherein the step of establishing a communication channel between the target process and the to-be-communicated process based on the first identification number comprises:
    基于所述待通信进程的第一标识号,建立所述目标进程与所述待通信进程的单向通信;Establishing one-way communication between the target process and the to-be-communicated process based on the first identification number of the to-be-communicated process;
    获取所述目标进程的第三标识号;Obtaining a third identification number of the target process;
    基于所述目标进程的第三标识号,建立所述待通信进程与所述目标进程的单向通信,以建立目标进程与所述待通信进程之间的双向通信的通信通道。Establishing, by the third identification number of the target process, one-way communication between the to-be-communicated process and the target process to establish a communication channel for two-way communication between the target process and the to-be-communicated process.
  8. 一种跨进程通信的装置,其特征在于,包括:An apparatus for communicating across processes, comprising:
    第一获取模块,被配置成获取待通信进程的第一标识号,所述待通信进程属于第一应用程序;a first acquiring module, configured to acquire a first identification number of a process to be communicated, where the to-be-communicated process belongs to the first application;
    第一建立模块,被配置成基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道,所述目标进程属于第二应用程序,所述第二应用程序和所述第一应用程序为终端的两个不同的应用程序;a first establishing module, configured to establish, according to the first identification number, a communication channel between the target process and the to-be-communicated process, where the target process belongs to the second application, the second application, and the first An application for two different applications of the terminal;
    通信模块,被配置成通过所述通信通道将所述待通信进程的访问请求发送至所述目标进程,以进行所述第一应用程序与所述第二应用程序的通信。And a communication module configured to send an access request of the to-be-communicated process to the target process through the communication channel to perform communication between the first application and the second application.
  9. 根据权利要求8所述的装置,其特征在于,还包括:The device according to claim 8, further comprising:
    第二获取模块,被配置成获取所述终端的进程队列,所述进程队列为所述终端当前启用的所有应用进程的集合;a second obtaining module, configured to acquire a process queue of the terminal, where the process queue is a set of all application processes currently enabled by the terminal;
    提取模块,被配置成对所述进程队列中的每个所述应用进程均提取对应的第二标识号;An extraction module, configured to extract a corresponding second identification number for each of the application processes in the process queue;
    第三获取模块,被配置成基于每个所述第二标识号获取该第二标识号所属的应用进程对应的应用程序的包名;a third obtaining module, configured to acquire, according to each of the second identification numbers, a package name of an application corresponding to the application process to which the second identification number belongs;
    第二建立模块,被配置成建立所述第二标识号和所述包名之间的映射关系。The second establishing module is configured to establish a mapping relationship between the second identification number and the package name.
  10. 根据权利要求9所述的装置,其特征在于,还包括判断模块;The device according to claim 9, further comprising a determination module;
    所述判断模块,被配置成基于所述映射关系,判断是否获取到所述第二应用程序对应的目标进程的第三标识号;The determining module is configured to determine, according to the mapping relationship, whether a third identification number of the target process corresponding to the second application is obtained;
    所述第一建立模块,还被配置成在判断出获取到所述第二应用程序对应的所述第三标识号后,基于所述第一标识号建立目标进程与所述待通信进程之间的通信通道。 The first establishing module is further configured to: after determining that the third identification number corresponding to the second application is obtained, establishing a target process and the to-be-communicated process based on the first identification number Communication channel.
  11. 根据权利要求8或10所述的装置,其特征在于,所述第一建立模块包括:The device according to claim 8 or 10, wherein the first establishing module comprises:
    配置单元,被配置成基于所述第一标识号对所述目标进程配置socket连接;a configuration unit, configured to configure a socket connection to the target process based on the first identification number;
    建立单元,被配置成基于所述socket连接建立所述目标进程与所述待通信进程之间的通信通道。An establishing unit configured to establish a communication channel between the target process and the to-be-communicated process based on the socket connection.
  12. 根据权利要求11所述的装置,其特征在于;The device of claim 11 wherein:
    所述配置单元,还被配置成将所述第一标识号作为socket连接的通讯的端口号,以所述终端的本地IP地址作为socket连接的通讯IP地址。The configuration unit is further configured to use the first identification number as a port number of a socket connection communication, and the local IP address of the terminal as a communication IP address of the socket connection.
  13. 根据权利要求8所述的装置,其特征在于,还包括监听模块;The device according to claim 8, further comprising a listening module;
    所述监听模块,被配置成基于所述第一标识号对所述第一应用程序与所述第二应用程序的通信进行实时监听,以判断所述目标进程是否已经接收所述待通信进程的所述访问请求。The monitoring module is configured to perform real-time monitoring on the communication between the first application and the second application based on the first identification number to determine whether the target process has received the to-be-communicated process. The access request.
  14. 根据权利要求8所述的装置,其特征在于:The device of claim 8 wherein:
    第一建立模块,还被配置成基于所述待通信进程的第一标识号,建立所述目标进程与所述待通信进程的单向通信;获取所述目标进程的第三标识号;基于所述目标进程的第三标识号,建立所述待通信进程与所述目标进程的单向通信,以建立目标进程与所述待通信进程之间的双向通信的通信通道。a first establishing module, configured to establish, according to the first identification number of the to-be-communicated process, a one-way communication between the target process and the to-be-communicated process; acquiring a third identification number of the target process; And a third identification number of the target process, establishing a one-way communication between the to-be-communicated process and the target process, to establish a communication channel for two-way communication between the target process and the to-be-communicated process.
  15. 一种可读取存储介质,其特征在于,所述可读取存储介质存储于计算机内,所述可读取存储介质包括多条指令,所述多条指令被配置成使得所述计算机实现如权利要求1-7任一项所述的方法。 A readable storage medium, characterized in that the readable storage medium is stored in a computer, the readable storage medium comprising a plurality of instructions, the plurality of instructions being configured to cause the computer to implement The method of any of claims 1-7.
PCT/CN2017/079614 2016-11-28 2017-04-06 Inter-process communication method, apparatus and readable storage medium WO2018094951A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201611058913.4 2016-11-28
CN201611058913.4A CN106547634B (en) 2016-11-28 2016-11-28 Cross-process communication method and device

Publications (1)

Publication Number Publication Date
WO2018094951A1 true WO2018094951A1 (en) 2018-05-31

Family

ID=58395970

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/079614 WO2018094951A1 (en) 2016-11-28 2017-04-06 Inter-process communication method, apparatus and readable storage medium

Country Status (2)

Country Link
CN (1) CN106547634B (en)
WO (1) WO2018094951A1 (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111158935A (en) * 2019-12-31 2020-05-15 北京奇艺世纪科技有限公司 Application program detection method and device, computer equipment and storage medium
CN113032038A (en) * 2021-02-25 2021-06-25 武汉深之度科技有限公司 Application program management method and device, computing equipment and readable storage medium

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106547634B (en) * 2016-11-28 2020-07-31 武汉斗鱼网络科技有限公司 Cross-process communication method and device
CN106961482B (en) * 2017-04-01 2021-01-15 联想(北京)有限公司 Information processing method and device, storage medium and electronic equipment
CN107833614A (en) * 2017-10-26 2018-03-23 咪咕互动娱乐有限公司 A kind of energy monitoring method, device and storage medium
CN111385265A (en) * 2018-12-29 2020-07-07 北京奇虎科技有限公司 Communication method and device in iOS system
CN110569130B (en) * 2019-07-29 2021-12-14 华为技术有限公司 Cross-process communication method, device and equipment
CN114827154A (en) * 2021-01-18 2022-07-29 网宿科技股份有限公司 Port monitoring method, system and server
CN114615546B (en) * 2022-02-08 2024-04-12 武汉光庭信息技术股份有限公司 Video playing method and device, electronic equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102340410A (en) * 2010-07-21 2012-02-01 中兴通讯股份有限公司 Cluster management system and method
WO2015188330A1 (en) * 2014-06-11 2015-12-17 华为技术有限公司 Method and device for processing process of multicore operating system
CN105579969A (en) * 2013-09-23 2016-05-11 三星电子株式会社 Method and apparatus for device-specific communication between application programmes
CN106547634A (en) * 2016-11-28 2017-03-29 武汉斗鱼网络科技有限公司 A kind of method and device of striding course communication

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103455380A (en) * 2012-06-05 2013-12-18 上海斐讯数据通信技术有限公司 Multi-process communication system and establishment and communication method thereof
CN104869569A (en) * 2015-03-31 2015-08-26 小米科技有限责任公司 Network permission control method and apparatus of application program
CN104809046B (en) * 2015-05-27 2018-01-16 广东欧珀移动通信有限公司 A kind of application program networking control method and application program networking control device

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102340410A (en) * 2010-07-21 2012-02-01 中兴通讯股份有限公司 Cluster management system and method
CN105579969A (en) * 2013-09-23 2016-05-11 三星电子株式会社 Method and apparatus for device-specific communication between application programmes
WO2015188330A1 (en) * 2014-06-11 2015-12-17 华为技术有限公司 Method and device for processing process of multicore operating system
CN106547634A (en) * 2016-11-28 2017-03-29 武汉斗鱼网络科技有限公司 A kind of method and device of striding course communication

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111158935A (en) * 2019-12-31 2020-05-15 北京奇艺世纪科技有限公司 Application program detection method and device, computer equipment and storage medium
CN111158935B (en) * 2019-12-31 2023-07-25 北京奇艺世纪科技有限公司 Application program detection method and device, computer equipment and storage medium
CN113032038A (en) * 2021-02-25 2021-06-25 武汉深之度科技有限公司 Application program management method and device, computing equipment and readable storage medium

Also Published As

Publication number Publication date
CN106547634A (en) 2017-03-29
CN106547634B (en) 2020-07-31

Similar Documents

Publication Publication Date Title
WO2018094951A1 (en) Inter-process communication method, apparatus and readable storage medium
US11729594B2 (en) Network access method, device, and system
EP2898739B1 (en) Methods, terminals, and systems for facilitating data sharing
US9736767B2 (en) Identification-assisted wireless network connections
US9391800B2 (en) Dynamic and interoperable generation of stateful VPN connection profiles for computing devices
WO2013070811A1 (en) Geo-fence based on geo-tagged media
CN110049012B (en) Operation method of routing equipment, routing equipment and terminal equipment
CN103596246B (en) Recover the method and terminal of data service
US20140086179A1 (en) Methods, terminals, and systems for facilitating data sharing
CN108696523B (en) Response method and device for call service
US20230199502A1 (en) Apparatus and Method for Remotely Managing Devices, and Program Therefor
WO2018196463A1 (en) Method and apparatus for network access, storage medium, and processor
US11947640B2 (en) Adaptive, multi-channel, embedded application programming interface (API)
CN105744491B (en) It is a kind of difference Android device between communications management system and method
CN102891900B (en) A kind of method, apparatus and system of the domain name mapping in flow unloading
CN103517373B (en) A kind of method and apparatus of network insertion
US20140297719A1 (en) Receiving a communication event
CN103428357A (en) Method and apparatus for realizing local service sharing of mobile terminal operating system
CN112511569B (en) Method and system for processing network resource access request and computer equipment
US20140033057A1 (en) Method, apparatus, and system for managing information in a mobile device
CN107404504B (en) Communication method, device and system
US20160149855A1 (en) Service processing method, system, and relevant device
CA2879654C (en) Method, apparatus, and system for managing information in mobile device
CN204795241U (en) A net cell -phone is stepped on to single modem double cassette of developments download number is provided
WO2017124436A1 (en) Communication method, mobile terminal, issuing terminal and communication system

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: 17873149

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 17873149

Country of ref document: EP

Kind code of ref document: A1