CN112764946B - Cross-process data transmission method and device, electronic equipment and storage medium - Google Patents

Cross-process data transmission method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN112764946B
CN112764946B CN202110023483.7A CN202110023483A CN112764946B CN 112764946 B CN112764946 B CN 112764946B CN 202110023483 A CN202110023483 A CN 202110023483A CN 112764946 B CN112764946 B CN 112764946B
Authority
CN
China
Prior art keywords
data
transmission
memory space
transmission data
data transmission
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN202110023483.7A
Other languages
Chinese (zh)
Other versions
CN112764946A (en
Inventor
李廷
蔡蓉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing JoInovate Technology Co.,Ltd.
Original Assignee
Chongqing Chuangtong Lianzhi Internet Of Things Co ltd
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 Chongqing Chuangtong Lianzhi Internet Of Things Co ltd filed Critical Chongqing Chuangtong Lianzhi Internet Of Things Co ltd
Priority to CN202110023483.7A priority Critical patent/CN112764946B/en
Publication of CN112764946A publication Critical patent/CN112764946A/en
Application granted granted Critical
Publication of CN112764946B publication Critical patent/CN112764946B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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/544Buffers; Shared memory; Pipes
    • 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/546Message passing systems or structures, e.g. queues
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a cross-process data transmission method and device, electronic equipment and storage medium, wherein the method is applied to a data transmission layer in an android operating system, and the method comprises the following steps: receiving transmission data of a first process through a data transmission interface realized in the first process; writing the transmission data into the memory space; receiving a request for acquiring transmission data from the second process through a data transmission interface realized in the second process; according to the acquisition request, extracting transmission data from the memory space and sending the transmission data to the second process; the data transmission interface realized in the first process and the data transmission interface realized in the second process are realized based on the data transmission interface defined by the data transmission layer. According to the cross-process data transmission method, the data transmission interface is arranged in the process, so that the data can be transmitted in two directions through one-time communication connection, and the data transmission direction and the data transmission efficiency are improved.

Description

Cross-process data transmission method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of data transmission technologies, and in particular, to a cross-process data transmission method, apparatus, electronic device, and storage medium.
Background
A Process (Process) is a running activity of a program in a computer on a certain data set, is a basic unit of resource allocation and scheduling by a system, and is a basis of an operating system structure. Android (Android) operating systems often need to partition processes for applications during development based on functional isolation, process security, process keep-alive, etc., however such operations have to face the challenges of cross-process communication and cross-process sharing of data.
The purpose of cross-process communication is to realize the sharing and interaction of data among processes. The most typical application scenario of cross-process communication is the copying and pasting of data on a clipboard, but the manner of cross-process communication is limited to the transfer of some String-type data. In the Android system, transmission of data between processes is limited to an AIDL (Android Interface Definition Language, i.e. Android interface definition language) mode, but data transmission under the mode is limited to basic data types, such as int, long, list, string, if an object needs to be transmitted, the class needs to be serialized, such as Parcelable (packetizable) or Serializable (serializing), and Parcelable or Serializable needs an interface for additional serialization. And AIDL belongs to unidirectional communication, i.e. one set of AIDL schemes only allows process a to transmit to process B, but another set of AIDL schemes is needed for process B to transmit to process a.
Disclosure of Invention
In view of the foregoing, the present application has been developed to provide a cross-process data transmission method, apparatus, electronic device, and storage medium that overcome, or at least partially solve, the foregoing problems.
According to a first aspect of the present application, there is provided a cross-process data transmission method, the method being applied to a data transmission layer in an android operating system, the method comprising:
receiving transmission data of a first process through a data transmission interface realized in the first process;
writing the transmission data into a memory space;
receiving an acquisition request of the second process for the transmission data through a data transmission interface realized in the second process;
extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process;
the data transmission interface realized in the first process and the data transmission interface realized in the second process are realized based on the data transmission interface defined by the data transmission layer.
Optionally, the writing the transmission data into the memory space includes:
analyzing the transmission data, and determining the data type of the transmission data according to the analysis result, wherein the data type comprises basic data and/or object data;
Encapsulating the transmission data according to the data type of the transmission data to obtain encapsulated transmission data;
and writing the encapsulated transmission data into the memory space.
Optionally, the encapsulating the transmission data according to the data type of the transmission data, and obtaining the encapsulated transmission data includes:
and if the transmission data comprises the basic data and the object data, respectively packaging the basic data and the object data.
Optionally, the encapsulating the object data includes:
determining whether the object data has been serialized;
if the object data is serialized, directly packaging the object data;
if the object data is not serialized, recording the object format of the object data, and packaging the object data so as to write the object format of the object data and the packaged object data into the memory space.
Optionally, the extracting the transmission data from the memory space according to the obtaining request and sending the transmission data to the second process includes:
acquiring the transmission data from the memory space according to the acquisition request;
Analyzing the transmission data, and determining the data type of the transmission data according to the analysis result, wherein the data type comprises basic data and/or object data;
restoring the analyzed transmission data according to the data type of the transmission data to obtain restored transmission data;
and sending the restored transmission data to the second process through a data transmission interface realized in the second process.
Optionally, the restoring the parsed transmission data according to the data type of the transmission data, to obtain restored transmission data includes:
and if the transmission data comprises the basic data and the object data, respectively restoring the basic data and the object data.
Optionally, the restoring the object data includes:
acquiring an object format of the object data from the memory space;
and restoring the object data according to the object format of the object data.
Optionally, after receiving the transmission data of the first process through the data transmission interface implemented in the first process, the method further includes:
handshake verification is performed with the first process;
If the handshake verification is successful, writing the transmission data into a memory space;
after receiving, through a data transmission interface implemented in a second process, an acquisition request of the second process for the transmission data, the method further includes:
carrying out handshake verification with the second process;
and if the handshake verification is successful, extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process.
Optionally, the method further comprises:
if the transmission data of the first process is received, opening up a memory space in the android operating system so as to write the transmission data into the memory space;
and if the handshake verification with the second process fails or the return parameter of the second process is successful in data transmission, releasing the memory space.
According to a second aspect of the present application, there is provided a cross-process data transmission device, the device being applied to a data transmission layer in an android operating system, the device comprising:
the first receiving unit is used for receiving the transmission data of the first process through a data transmission interface realized in the first process;
the first writing unit is used for writing the transmission data into the memory space;
The second receiving unit is used for receiving the acquisition request of the second process for the transmission data through a data transmission interface realized in the second process;
the first sending unit is used for extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process;
the data transmission interface realized in the first process and the data transmission interface realized in the second process are realized based on the data transmission interface defined by the data transmission layer.
According to a third aspect of the present application, there is provided an electronic device comprising: a processor; and a memory arranged to store computer executable instructions that, when executed, cause the processor to perform a cross-process data transmission method as described in any of the above.
According to a fourth aspect of the present application, there is provided a computer readable storage medium storing one or more programs which when executed by a processor implement a cross-process data transmission method as described in any of the above.
From the above, the technical solution of the present application achieves the following technical effects: the cross-process data transmission method is mainly applied to a data transmission layer in an android operating system, and data transmission interfaces for data transmission are respectively realized in the first process and the second process aiming at any two first processes and second processes needing data transmission, wherein the data transmission interfaces are realized based on data transmission interfaces defined by the data transmission layer. When the cross-process data transmission is carried out, firstly, the transmission data of the first process is received through a data transmission interface realized in the first process; then writing the transmission data into the memory space of the android operating system; then, through a data transmission interface realized in the second process, receiving an acquisition request of the second process for transmission data; and finally, extracting transmission data from the memory space according to the acquisition request and sending the transmission data to the second process. According to the cross-process data transmission method, a data transmission interface is arranged in a process, and the data transmission interface supports data transmission and data reception; the method not only supports the data transmission of basic types such as int, long, list, string and the like, but also supports the data transmission of complex types such as class objects and the like, so that the realization of the data transmission is simpler, the bidirectional transmission of the data can be realized by one-time communication connection, and the transmission direction and the transmission efficiency of the data are improved.
The foregoing description is only an overview of the technical solutions of the present application, and may be implemented according to the content of the specification in order to make the technical means of the present application more clearly understood, and in order to make the above-mentioned and other objects, features and advantages of the present application more clearly understood, the following detailed description of the present application will be given.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to designate like parts throughout the figures. In the drawings:
FIG. 1 illustrates a flow diagram of a cross-process data transmission method according to one embodiment of the present application;
FIG. 2 illustrates a flow diagram of a cross-process data transmission method according to one embodiment of the present application;
FIG. 3 illustrates a logical block diagram of cross-process data transfer according to one embodiment of the present application;
FIG. 4 illustrates a schematic diagram of a cross-process data transmission device according to one embodiment of the present application;
FIG. 5 shows a schematic structural diagram of an electronic device according to one embodiment of the present application;
Fig. 6 illustrates a schematic structure of a computer-readable storage medium according to an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
The android operating system is developed based on Linux kernels of different versions, and in a Linux environment, each process has different user address spaces due to the fact that the process address spaces are mutually independent. The global variable of any process cannot be seen in the other process, so that the processes cannot access each other, data to be exchanged must pass through the kernel, by opening a block buffer in the kernel, the process a copies the data from the user space to the kernel buffer, the process B reads the data from the kernel buffer, the block memory space for storing the data can be accessed by two processes, which is called shared memory, and the mechanism provided by the kernel is called shared memory-based inter-process Communication (IPC, interProcess Communication).
However, since memory entities exist in a computer system, they can only be shared by processes residing in the same computer system. The android operating system opens up a virtual machine for each process, which makes it difficult to implement IPC by using shared memory in the android operating system.
In view of the above, the proposal provided by the application is to realize a data transmission layer in the android operating system, the data transmission layer or the data transmission module is used for carrying out memory caching of data to be transmitted, and define a data transmission interface which can realize data transmission and data reception, thereby solving the problem that two AIDL schemes are needed to be realized in the prior art to respectively carry out data transmission and data reception.
Based on this, the embodiment of the application provides a cross-process data transmission method, which is applied to a data transmission layer in an android operating system, as shown in fig. 1, and includes the following steps S110 to S140:
step S110, receiving the transmission data of the first process through a data transmission interface realized in the first process.
The cross-process data transmission method is mainly applied to a data transmission layer in an android operating system. For any two processes needing to perform cross-process data transmission, data transmission interfaces which can be used for performing data transmission can be respectively arranged in the two processes in advance so as to establish a communication bridge with other processes. The data transmission interface is understood to be a data transmission interface defined by a data transmission layer according to an embodiment of the present application, and the data transmission interface not only can implement data transmission, but also can implement data reception, that is, implement bidirectional data transfer.
When the cross-process data transmission is carried out, the transmission data of the first process is received through a data transmission interface realized in the first process. In the practical application scenario, the process herein may be understood as an execution entity of an application program installed in various terminal devices implemented based on the android operating system, so the transmission data of the first process may be understood as data of the application program.
Step S120, writing the transmission data into the memory space.
After receiving the transmission data of the first process, the transmission data can be stored in the memory space, so that other processes can acquire the transmission data of the first process from the memory space. The memory space refers to the memory space of the android operating system, which can be regarded as a buffer area for storing the database, and any process can store own data into the memory space or read data from the memory space.
Step S130, receiving, by a data transmission interface implemented in a second process, an acquisition request of the second process for the transmission data.
In an actual application scene, the second process can initiate an acquisition request of the transmission data of the first process according to actual requirements, and the acquisition request usually carries a corresponding process identifier so as to acquire the corresponding transmission data according to the process identifier. Specifically, the data transmission interface implemented in the second process may receive the request for acquiring the transmission data by the second process, where the data transmission interface implemented in the second process is the same as the data transmission interface implemented in the first process, and may be understood as a data transmission interface defined based on a data transmission layer, so that not only can data be received, but also data transmission can be achieved.
Step S140, extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process; the data transmission interface realized in the first process and the data transmission interface realized in the second process are realized based on the data transmission interface defined by the data transmission layer.
After obtaining the request for obtaining the transmission data by the second process, the corresponding transmission data can be extracted from the memory space of the android operating system according to the request for obtaining, and then the extracted transmission data is sent to the second process through the data transmission interface realized in the second process, so that the transmission process of the data is completed once.
Therefore, the memory space for storing the transmission data is not directly accessed by the first process and the second process, but is read and written by the data transmission layer, the transmission data cannot generate copies due to the access of a plurality of processes, and the data consistency is ensured.
In addition, since the data transmission interface in the embodiment of the present application is a data transmission interface defined by the data transmission layer, through which data can be received and data can be sent, the above-mentioned "first process" and "second process" can be regarded as both a data sender and a data receiver, and further, bidirectional communication between processes is achieved.
The existing scheme for implementing inter-process communication based on AIDL is unidirectional transmission, for example, when a process a wants to transmit data to a process B, an interface X required for the process B is defined in an AIDL file, through which only the data transmission of the process a directly to the process B can be implemented, and if the data transmission of the process B to the process a is implemented, another AIDL file is required to define another interface Y required for the process a.
The embodiment of the application realizes bidirectional transmission of data through the data transmission interface arranged in the process, so that data transmission and data reception are supported; the method not only supports the data transmission of basic types such as int, long, list, string and the like, but also supports the data transmission of complex types such as class objects and the like, so that the realization of the data transmission is simpler, the bidirectional transmission of the data can be realized by one-time communication connection, and the transmission direction and the transmission efficiency of the data are improved. In addition, the data transmission interface set in the process of the embodiment of the application is not used for directly transmitting data between the process A and the process B, but is realized through a data transmission layer between the process A and the process B, so that the consistency of transmitted data is ensured.
In one embodiment of the present application, when writing transmission data into a memory space, the received transmission data may be parsed, then the type of the transmission data is determined according to the parsing result, where the data type may include basic data and object data, then the corresponding transmission data is encapsulated according to the parsed data type, and finally the obtained encapsulated transmission data is stored into the memory space for subsequent transmission.
The above-mentioned basic data mainly includes int, long, list, string and the like, for example, a keyword in Java (an object-oriented programming language) that specifies basic data is started in lowercase letters, and the basic data has only a numeric value and no ID (i.e., a position in memory space). At the same time, the type of basic data is not variable, memory is allocated in the stack, which makes the overhead of basic data relatively low. The object data mainly includes Integer, boolean, double and the like, and for example, keywords in Java specifying the object data are all written with capital letters, and the object data has both numerical values and IDs. Furthermore, the type of object data is both an immutable type and a variable type, which allocates memory in the heap at a relatively high cost.
The above-mentioned data encapsulation can be understood as mapping data into a payload of a certain encapsulation protocol, then filling a packet header of a corresponding protocol to form a data packet of the encapsulation protocol, and completing rate adaptation, where the main purpose of encapsulation is to ensure security of critical data, and conceal implementation details and isolate complexity from the outside.
Because the formats of the basic data and the object data are different, and the data packaging modes are different, in one embodiment of the application, if the received transmission data of the first process is analyzed to include the basic data and the object data, the basic data and the object data can be packaged respectively and finally stored in the memory space respectively.
In an actual application scenario, if the transmission data of the first process includes data of an object type, the object data is usually required to be subjected to serialization, which is a process of converting state information of the object into a form capable of being stored or transmitted, that is, converting the object into a character sequence, and capable of completely restoring the byte sequence into the original object later, so as to facilitate storage and transmission. The existing method for serializing the objects is to independently realize the Parcelable or Serializable interfaces in the process, so that the cost and the complexity are high.
In one embodiment of the present application, since a serialized interface may already be implemented in some processes, when the parsed data type includes the object data, whether the object data is serialized may be determined first, and if the object data is serialized, the object data may be directly encapsulated; if the object data is not serialized, the object format of the object data can be recorded, then the object data is encapsulated, and finally the object format of the object data and the encapsulated object data are written into the memory space so as to facilitate the subsequent data transmission.
The embodiment of the application can be compatible with the process which has realized the serialization interface, and for the object data without serialization, the interface for serializing the object is not needed to be additionally realized in the process, and the requirements of data storage and transmission can be met by recording the object format and storing the object format into the memory space, and meanwhile, the development cost and the development complexity are reduced.
In one embodiment of the present application, when the second process wants to acquire the transmission data of the first process, an acquisition request for the transmission data is initiated, so that the corresponding transmission data can be acquired from the memory space according to the received acquisition request, and since the data stored in the memory space is encapsulated data, the transmission data acquired from the memory space can be resolved first, then a specific data type including basic data and/or object data can be obtained according to the resolving result, and then the resolved transmission data can be restored, namely, decapsulated according to the resolved data type, to obtain restored transmission data; and finally, sending the restored transmission data to the second process through a data transmission interface realized in the second process, thereby completing a complete data transmission process.
It should be noted that, the "parsing" mentioned in the process of extracting the transmission data from the memory space and sending the transmission data to the second process is different from the "parsing" mentioned in the process of storing the transmission data of the first process into the memory space, that is, specific parsing objects and parsing manners are different.
Because the formats of the basic data and the object data are different, and the data restoring modes are different, in one embodiment of the application, if the transmission data of the first process acquired from the memory space is analyzed to include the basic data and the object data, the basic data and the object data can be restored respectively, and finally the restored basic data and the object data are sent to the second process together through a data transmission interface implemented in the second process.
For the object data, the application stores the object format of the object data in the memory space in the data storage stage, so in one embodiment of the application, if the analyzed data type includes the object data, the object format of the object data can be directly obtained from the memory space, and then the object data is restored, i.e. unpacked, by using the object format of the object data, so as to obtain the transmission data in the original form.
The cross-process data transmission method is realized based on inter-process communication, and specifically solves the problem of mutual communication between different processes on the same host, and the existing LocalSocket is a main means for solving the problem. LocalSocket is based on UNIX-domain Socket (UNIX domain Socket), which is an IPC communication mechanism derived on the Socket basis. Compared with a socket used for network communication, the Localsocket does not need to pass through a network protocol stack, does not need to be packaged and unpacked, calculates and checks, has high natural execution efficiency, and is widely used as an IPC communication means in an Android system.
In particular, when data transmission between the first process and the second process is performed, a communication connection with the first process may be established through a LocalSocket, that is, handshake verification is performed with the first process, where handshake refers to that parameters, such as an information transmission rate, an alphabet, parity check, an interrupt process, and other protocol characteristics, are achieved through handshake before information transmission starts after a communication link is established. If the handshake check is successful, the transmission data of the first process may be stored into the memory space.
When the second process needs to acquire the transmission data, communication connection with the second process can be established through the Localsocket, namely handshake verification is carried out on the second process, and if the handshake verification is successful, the corresponding transmission data can be extracted from the memory space according to the acquisition request and sent to the second process.
The memory space in an android operating system generally includes two parts, namely physical memory, i.e., RAM (Random Access Memory ) on a mobile device, and process memory, and when a program in the device is started, the system allocates a fixed memory space (e.g., 16m,32 m) to the RAM, and the program runs on the RAM. The process memory is only virtual memory (or called logical memory), while the program operation requires real memory, i.e., physical memory. Therefore, if necessary, the operating system maps the memory (virtual memory) applied during the program running to the RAM, so that the process can use the physical memory.
The memory space in the embodiment of the application may refer to a physical memory or a process memory of the android operating system. When the data transmission of the process A is required, a small area for caching the transmission data of the process A can be opened up in a process memory of the android system, and then the small area can be mapped to a certain area on the RAM, so that the process A can run on the certain area of the RAM. By adopting the mode of only temporarily opening up the memory space during data transmission, the resource allocation rate and the utilization rate of the memory space of the android operating system can be greatly improved.
In one embodiment of the present application, if handshake verification with the second process fails, it is indicated that the data of the first process cannot be transmitted to the second process at this time, and at this time, the memory space in the android operating system may be released; or when the return parameter of the second process is that the data transmission is successful, the second process is indicated to have successfully received the transmission data of the first process, and the memory space can be released at the moment, so that the released memory space can be used for storing the transmission data of other processes, and the resource utilization rate of the memory space is improved.
For the situation that the handshake verification with the second process fails, when the first handshake verification fails, the handshake verification can be performed again by calling a retry mechanism, and if the handshake verification still fails within a period of time, the memory space in the android operating system can be released and the communication link can be released at the same time.
As shown in fig. 2, a flow chart of a cross-process data transmission method according to an embodiment of the present application is provided. Taking the process A as an example of transmitting data to the process B, firstly establishing the IPC communication connection relation between the process A and the process B, after successfully establishing the communication connection relation, the process A can transmit the transmission data to a data transmission layer through a data communication interface realized in the process A, then analyze and package the transmission data in the data transmission layer, and then write the packaged transmission data into a memory space of an android operating system.
When the transmission data of the process A in the memory space is transmitted to the process B, the transmission data in the memory space can be analyzed and restored first, and finally the restored transmission data is transmitted to the process B, so that a data transmission process from the process A to the process B is completed.
The scene of transmitting data from the process B to the process A is the same as the process, but the process does not need to establish the IPC communication connection relationship with the process A and the process B again, namely, the bidirectional transmission of the data between the process A and the process B can be realized only by establishing the IPC communication connection once, so that the data transmission efficiency is greatly improved.
As shown in fig. 3, a logic block diagram of a cross-process data transmission according to an embodiment of the present application is provided. Taking the process a to transmit data to the process B as an example, firstly, establishing an IPC communication connection relationship with the process a and the process B, and after successfully establishing the communication connection relationship, the process a will write the data for transmission to the data transmission interface. And then carrying out handshake verification with the process A, if the handshake verification is passed, analyzing the transmission data of the process A, opening up a memory space, obtaining the type of the transmission data according to the analysis result, if the transmission data is basic data, directly packaging, if the transmission data is object data, further judging whether the object data is serialized, if the transmission data is serialized, directly packaging the object data, if the transmission data is not serialized, recording the object format of the object data, and then packaging the object data. And finally, storing the encapsulated basic data, object data and object formats into the opened memory space.
When the process B needs to acquire the transmission data, handshake verification can be carried out with the process B, if the first handshake verification fails, a retry mechanism is called, and if the first handshake verification still fails within a period of time, the memory space in the android operating system is released and the communication link is released. If the handshake verification is successful, corresponding transmission data is obtained from the memory space and analyzed to obtain a data type, if the data type contains object data, an object format is obtained from the memory space, then the object data is restored according to the object format, the basic data can be restored directly, finally the restored transmission data is sent to the process B through a data transmission interface of the process B, parameters are returned in the process B, if the returned parameters are successful in data transmission, the process A is considered to successfully transmit the data to the process B, namely, a complete data transmission process is completed, and then the memory space can be released to provide a storage space for other processes.
The embodiment of the application provides a cross-process data transmission device 400, which is applied to a data transmission layer in an android operating system, as shown in fig. 4, the device 400 includes:
A first receiving unit 410, configured to receive, through a data transmission interface implemented in a first process, transmission data of the first process;
a first writing unit 420, configured to write the transmission data into a memory space;
a second receiving unit 430, configured to receive, through a data transmission interface implemented in a second process, an acquisition request of the second process for the transmission data;
a first sending unit 440, configured to extract the transmission data from the memory space according to the acquisition request and send the transmission data to the second process;
the data transmission interface realized in the first process and the data transmission interface realized in the second process are realized based on the data transmission interface defined by the data transmission layer.
In one embodiment of the present application, the first writing unit 420 is specifically configured to: analyzing the transmission data, and determining the data type of the transmission data according to the analysis result, wherein the data type comprises basic data and/or object data; encapsulating the transmission data according to the data type of the transmission data to obtain encapsulated transmission data; and writing the encapsulated transmission data into the memory space.
In one embodiment of the present application, the first writing unit 420 is specifically configured to: and if the transmission data comprises the basic data and the object data, respectively packaging the basic data and the object data.
In one embodiment of the present application, the first writing unit 420 is specifically configured to: determining whether the object data has been serialized; if the object data is serialized, directly packaging the object data; if the object data is not serialized, recording the object format of the object data, and packaging the object data so as to write the object format of the object data and the packaged object data into the memory space.
In one embodiment of the present application, the first transmitting unit 440 is specifically configured to: acquiring the transmission data from the memory space according to the acquisition request; analyzing the transmission data, and determining the data type of the transmission data according to the analysis result, wherein the data type comprises basic data and/or object data; restoring the analyzed transmission data according to the data type of the transmission data to obtain restored transmission data; and sending the restored transmission data to the second process through a data transmission interface realized in the second process.
In one embodiment of the present application, the first transmitting unit 440 is specifically configured to: and if the transmission data comprises the basic data and the object data, respectively restoring the basic data and the object data.
In one embodiment of the present application, the first transmitting unit 440 is specifically configured to: acquiring an object format of the object data from the memory space; and restoring the object data according to the object format of the object data.
In one embodiment of the present application, the apparatus further comprises: the first handshake checking unit is used for performing handshake checking with the first process after receiving the transmission data of the first process through a data transmission interface realized in the first process; the second writing unit is used for writing the transmission data into the memory space if the handshake verification is successful; the second handshake checking unit is used for performing handshake checking with the second process after receiving the request of the second process for acquiring the transmission data through a data transmission interface realized in the second process; and the second sending unit is used for extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process if the handshake verification is successful.
In one embodiment of the present application, the apparatus further comprises: the memory space opening unit is used for opening up a memory space in the android operating system if the transmission data of the first process is received, so that the transmission data is written into the memory space; and the memory space releasing unit is used for releasing the memory space if handshake verification with the second process fails or the return parameter of the second process is successful in data transmission.
It should be noted that, the specific implementation manner of each embodiment of the apparatus may be performed with reference to the specific implementation manner of the corresponding embodiment of the method, which is not described herein.
In summary, according to the technical scheme of the application, the data transmission interface is arranged in the process, so that the bidirectional transmission of the data can be realized through one-time communication connection, and the transmission direction and the transmission efficiency of the data are improved; in addition, in the cross-process data transmission process, the transmission of complex data types such as object data is increased, and the process does not need to realize a serialization interface in the process, so that the development cost and the development complexity are greatly reduced.
It should be noted that:
the algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may also be used with the teachings herein. The required structure for the construction of such devices is apparent from the description above. In addition, the present application is not directed to any particular programming language. It will be appreciated that a variety of programming languages may be used to implement the teachings of the present application as described herein, and the above description of specific languages is provided for disclosure of preferred embodiments of the present application.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the present application may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the application, various features of the application are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the application and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed as reflecting the intention that: i.e., the claimed application requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this application.
Those skilled in the art will appreciate that the modules in the apparatus of the embodiments may be adaptively changed and disposed in one or more apparatuses different from the embodiments. The modules or units or components of the embodiments may be combined into one module or unit or component and, furthermore, they may be divided into a plurality of sub-modules or sub-units or sub-components. Any combination of all features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or units of any method or apparatus so disclosed, may be used in combination, except insofar as at least some of such features and/or processes or units are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings), may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features but not others included in other embodiments, combinations of features of different embodiments are meant to be within the scope of the present application and form different embodiments. For example, in the following claims, any of the claimed embodiments can be used in any combination.
Various component embodiments of the present application may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in a cross-process data transmission apparatus according to embodiments of the present application. The present application may also be embodied as an apparatus or device program (e.g., computer program and computer program product) for performing a portion or all of the methods described herein. Such a program embodying the present application may be stored on a computer readable medium, or may have the form of one or more signals. Such signals may be downloaded from an internet website, provided on a carrier signal, or provided in any other form.
For example, fig. 5 shows a schematic structural diagram of an electronic device according to an embodiment of the present application. The electronic device 500 comprises a processor 510 and a memory 520 arranged to store computer executable instructions (computer readable program code). The memory 520 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. The memory 520 has a memory space 530 storing computer readable program code 531 for performing any of the method steps described above. For example, the memory space 530 for storing computer readable program code may include respective computer readable program code 531 for implementing the respective steps in the above method, respectively. The computer readable program code 531 may be read from or written to one or more computer program products. These computer program products comprise a program code carrier such as a hard disk, a Compact Disc (CD), a memory card or a floppy disk. Such a computer program product is typically a computer readable storage medium, such as shown in fig. 6. Fig. 6 illustrates a schematic structure of a computer-readable storage medium according to an embodiment of the present application. The computer readable storage medium 600 stores computer readable program code 531 for performing the steps of the method according to the present application, which can be read by the processor 510 of the electronic device 500, which when the computer readable program code 531 is executed by the electronic device 500 causes the electronic device 500 to perform the steps of the method described above, in particular, the computer readable program code 531 stored by the computer readable storage medium can perform the method shown in any of the embodiments described above. The computer readable program code 531 may be compressed in a suitable form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the application, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The application may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, third, etc. do not denote any order. These words may be interpreted as names.

Claims (10)

1. A cross-process data transmission method, wherein the method is applied to a data transmission layer in an android operating system, and the method comprises the following steps:
receiving transmission data of a first process through a data transmission interface realized in the first process;
Writing the transmission data into a memory space;
receiving an acquisition request of the second process for the transmission data through a data transmission interface realized in the second process;
extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process;
the data transmission interface realized in the first process and the data transmission interface realized in the second process are realized based on the data transmission interface defined by the data transmission layer;
the memory space is the memory space of the android operating system, is a buffer area for storing data, and any process can store own data into the memory space or read data from the memory space through a data transmission layer;
the data transmission interface is used for realizing bidirectional transmission of data;
the writing the transmission data into the memory space includes:
analyzing the transmission data, and determining the data type of the transmission data according to the analysis result, wherein the data type comprises basic data and/or object data;
encapsulating the transmission data according to the data type of the transmission data to obtain encapsulated transmission data;
Writing the encapsulated transmission data into the memory space;
the encapsulating the transmission data according to the data type of the transmission data comprises:
determining whether the object data has been serialized;
if the object data is serialized, directly packaging the object data;
if the object data is not serialized, recording the object format of the object data, and packaging the object data so as to write the object format of the object data and the packaged object data into the memory space.
2. The method of claim 1, wherein encapsulating the transmission data according to the data type of the transmission data, the obtaining encapsulated transmission data comprises:
and if the transmission data comprises the basic data and the object data, respectively packaging the basic data and the object data.
3. The method of claim 1, wherein the extracting the transmission data from the memory space and sending the transmission data to the second process according to the fetch request comprises:
acquiring the transmission data from the memory space according to the acquisition request;
Analyzing the transmission data, and determining the data type of the transmission data according to the analysis result, wherein the data type comprises basic data and/or object data;
restoring the analyzed transmission data according to the data type of the transmission data to obtain restored transmission data;
and sending the restored transmission data to the second process through a data transmission interface realized in the second process.
4. The method of claim 3, wherein the restoring the parsed transmission data according to the data type of the transmission data includes:
and if the transmission data comprises the basic data and the object data, respectively restoring the basic data and the object data.
5. The method of claim 4, wherein the restoring the object data comprises:
acquiring an object format of the object data from the memory space;
and restoring the object data according to the object format of the object data.
6. The method of claim 1, wherein the step of determining the position of the substrate comprises,
After receiving the transmission data of the first process through the data transmission interface implemented in the first process, the method further includes:
handshake verification is performed with the first process;
if the handshake verification is successful, writing the transmission data into a memory space;
after receiving, through a data transmission interface implemented in a second process, an acquisition request of the second process for the transmission data, the method further includes:
carrying out handshake verification with the second process;
and if the handshake verification is successful, extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process.
7. The method of claim 6, wherein the method further comprises:
if the transmission data of the first process is received, opening up a memory space in the android operating system so as to write the transmission data into the memory space;
and if the handshake verification with the second process fails or the return parameter of the second process is successful in data transmission, releasing the memory space.
8. A cross-process data transmission device, wherein the device is applied to a data transmission layer in an android operating system, the device comprising:
The first receiving unit is used for receiving the transmission data of the first process through a data transmission interface realized in the first process;
the first writing unit is used for writing the transmission data into the memory space;
the second receiving unit is used for receiving the acquisition request of the second process for the transmission data through a data transmission interface realized in the second process;
the first sending unit is used for extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process;
the data transmission interface realized in the first process and the data transmission interface realized in the second process are realized based on the data transmission interface defined by the data transmission layer;
the memory space is the memory space of the android operating system, is a buffer area for storing data, and any process can store own data into the memory space or read data from the memory space through a data transmission layer;
the data transmission interface is used for realizing bidirectional transmission of data;
the first writing unit is specifically configured to:
analyzing the transmission data, and determining the data type of the transmission data according to the analysis result, wherein the data type comprises basic data and/or object data;
Encapsulating the transmission data according to the data type of the transmission data to obtain encapsulated transmission data;
writing the encapsulated transmission data into the memory space;
the first writing unit is specifically configured to:
determining whether the object data has been serialized;
if the object data is serialized, directly packaging the object data;
if the object data is not serialized, recording the object format of the object data, and packaging the object data so as to write the object format of the object data and the packaged object data into the memory space.
9. An electronic device, wherein the electronic device comprises: a processor; and a memory arranged to store computer executable instructions which, when executed, cause the processor to perform the cross-process data transmission method of any one of claims 1 to 7.
10. A computer readable storage medium storing one or more programs which, when executed by a processor, implement the cross-process data transmission method of any of claims 1 to 7.
CN202110023483.7A 2021-01-08 2021-01-08 Cross-process data transmission method and device, electronic equipment and storage medium Active CN112764946B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110023483.7A CN112764946B (en) 2021-01-08 2021-01-08 Cross-process data transmission method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110023483.7A CN112764946B (en) 2021-01-08 2021-01-08 Cross-process data transmission method and device, electronic equipment and storage medium

Publications (2)

Publication Number Publication Date
CN112764946A CN112764946A (en) 2021-05-07
CN112764946B true CN112764946B (en) 2024-02-02

Family

ID=75701014

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110023483.7A Active CN112764946B (en) 2021-01-08 2021-01-08 Cross-process data transmission method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN112764946B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113778714B (en) * 2021-09-13 2024-01-09 北京技德系统技术有限公司 Shared shear plate method and device compatible with Android for Linux
CN114039963B (en) * 2021-11-08 2024-08-06 浙江岩华文化科技有限公司 Data transmission method, device, electronic device and storage medium
CN116166448A (en) * 2021-11-25 2023-05-26 北京字节跳动网络技术有限公司 Bidirectional communication method, device, equipment and medium
CN115202891B (en) * 2022-09-15 2022-11-15 北京科云时代信息技术有限公司 Cross-process data acquisition and transmission method and system based on big data and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103176854A (en) * 2011-12-26 2013-06-26 腾讯科技(深圳)有限公司 Process-to-process communication method, device and system
WO2016035340A1 (en) * 2014-09-04 2016-03-10 セイコーエプソン株式会社 Processing device and data processing method
CN106980551A (en) * 2017-03-24 2017-07-25 山东浪潮商用系统有限公司 A kind of Way of Process Communication and device
CN107153583A (en) * 2017-05-24 2017-09-12 努比亚技术有限公司 A kind of striding course interaction processing method, mobile terminal and computer-readable recording medium
CN108664491A (en) * 2017-03-29 2018-10-16 北京京东尚科信息技术有限公司 Data transmission method, device and terminal device
CN110597640A (en) * 2019-08-29 2019-12-20 深圳市优必选科技股份有限公司 Inter-process data transmission method and device, terminal and computer storage medium
CN111400070A (en) * 2020-03-24 2020-07-10 广州华多网络科技有限公司 Terminal equipment and cross-process interface calling implementation and execution method thereof
CN112099967A (en) * 2020-08-20 2020-12-18 深圳市元征科技股份有限公司 Data transmission method, terminal, device, equipment and medium

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107894920A (en) * 2017-11-09 2018-04-10 广东欧珀移动通信有限公司 Resource allocation method and Related product

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103176854A (en) * 2011-12-26 2013-06-26 腾讯科技(深圳)有限公司 Process-to-process communication method, device and system
WO2016035340A1 (en) * 2014-09-04 2016-03-10 セイコーエプソン株式会社 Processing device and data processing method
CN106980551A (en) * 2017-03-24 2017-07-25 山东浪潮商用系统有限公司 A kind of Way of Process Communication and device
CN108664491A (en) * 2017-03-29 2018-10-16 北京京东尚科信息技术有限公司 Data transmission method, device and terminal device
CN107153583A (en) * 2017-05-24 2017-09-12 努比亚技术有限公司 A kind of striding course interaction processing method, mobile terminal and computer-readable recording medium
CN110597640A (en) * 2019-08-29 2019-12-20 深圳市优必选科技股份有限公司 Inter-process data transmission method and device, terminal and computer storage medium
CN111400070A (en) * 2020-03-24 2020-07-10 广州华多网络科技有限公司 Terminal equipment and cross-process interface calling implementation and execution method thereof
CN112099967A (en) * 2020-08-20 2020-12-18 深圳市元征科技股份有限公司 Data transmission method, terminal, device, equipment and medium

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
Yuanliang Wu等.Study of Error Control Method for High Performance Unidirectional Data Transmission.《2018 2nd IEEE Advanced Information Management,Communicates,Electronic and Automation Control Conference (IMCEC)》.2018,第1628 - 1631页. *
以太网与同步串行总线接口设计;胡波;《cnki优秀硕士学位论文全文库 信息科技辑》(第03期);第I139-543页 *

Also Published As

Publication number Publication date
CN112764946A (en) 2021-05-07

Similar Documents

Publication Publication Date Title
CN112764946B (en) Cross-process data transmission method and device, electronic equipment and storage medium
CN109933443B (en) Inter-process communication method and device, computer equipment and readable storage medium
CN109308224B (en) Cross-platform data communication and cross-platform data processing method, device and system
CN106415506B (en) For calling the group scheme of the object-oriented of safety zone
US7577707B2 (en) Method, system, and program for executing data transfer requests
CN111600909A (en) Data processing method, device, protocol conversion equipment and storage medium
US6947965B2 (en) System and method for communications in a distributed computing environment
US5375207A (en) Remote processing of a plurality of commands during a session between a first computer and a host computer
US20180027074A1 (en) System and method for storage access input/output operations in a virtualized environment
US20070033291A1 (en) System and method for support of legacy communications protocols in a smart card
WO2017148278A1 (en) Service implementation method, apparatus and system based on fix protocol
TW200404225A (en) Dynamic wizard interface system and method
CN108846129B (en) Storage data access method, device and storage medium
CN114064302B (en) Inter-process communication method and device
CN113986515A (en) Method and device for creating sandbox environment for plug-in operation and computing equipment
JP2006195979A (en) Web application architecture
CN111782319A (en) System and method for realizing shared access by mounting USBKey on cloud desktop
US8291432B2 (en) Providing invocation context to IMS service provider applications
CN112905304A (en) Communication method and device between virtual machines, physical host and medium
CN103677820A (en) Embedded development software output method and system
CN108496157B (en) System and method for providing runtime trace using an extended interface
US10353700B1 (en) Code base sharing between standalone and web-based versions of an application via an emulated network communication channel
WO2020000947A1 (en) Method, apparatus, and device for refreshing encapsulated bios data
CN105550050A (en) Hardware communication method and apparatus
CN111459819B (en) Software testing method and device, electronic equipment and computer readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240819

Address after: Building 2, No. 37 Jingyang Road, Huxi Street, High tech Zone, Shapingba District, Chongqing 401331, China

Patentee after: Chongqing JoInovate Technology Co.,Ltd.

Country or region after: China

Address before: 401336 Rongying building, technology entrepreneurship center, No.8 Yuma Road, Nan'an District, Chongqing

Patentee before: Chongqing chuangtong Lianzhi Internet of things Co.,Ltd.

Country or region before: China