CN112764946A - 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
CN112764946A
CN112764946A CN202110023483.7A CN202110023483A CN112764946A CN 112764946 A CN112764946 A CN 112764946A CN 202110023483 A CN202110023483 A CN 202110023483A CN 112764946 A CN112764946 A CN 112764946A
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.)
Granted
Application number
CN202110023483.7A
Other languages
Chinese (zh)
Other versions
CN112764946B (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 Chuangtong Lianzhi Internet Of Things 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

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/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

Abstract

The application discloses a cross-process data transmission method and device, electronic equipment and a storage medium, wherein the method is applied to a data transmission layer in an android operating system, and 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; extracting 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 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 application relates to the field of data transmission technologies, and in particular, to a cross-process data transmission method and apparatus, an electronic device, and a storage medium.
Background
A Process (Process) is a running activity of a program in a computer on a data set, is a basic unit of resource allocation and scheduling of a system, and is the basis of an operating system structure. In the development process of an Android (Android) operating system, processes are often required to be divided for applications based on the considerations of function isolation, process security, process keep-alive and the like, but the operation has to face the challenges of cross-process communication and cross-process data sharing.
The purpose of cross-process communication is to realize data sharing and interaction among processes. The most typical application scenario of cross-process communication is copying and pasting of data on a clipboard, but the cross-process communication mode is limited to the transmission of some String-type data. In the Android system, the transmission of inter-process data is limited to an aid l (Android Interface Definition Language) mode, but the data transmission in this mode is limited to basic data types, such as int, long, list, String, and the like, and if an object needs to be transmitted, it is necessary to serialize the classes, such as performing parsablization (packetization) or Serializable (serialization), but the parsablization or Serializable needs an Interface for additionally implementing serialization. And the aid l belongs to one-way communication, that is, one set of aid l scheme only allows the process a to transmit to the process B, but another set of aid l scheme is required to make the process B transmit to the process a.
Disclosure of Invention
In view of the above, the present application is proposed to provide a cross-process data transmission method, apparatus, electronic device and storage medium that overcome or at least partially solve the above-mentioned problems.
According to a first aspect of the present application, a cross-process data transmission method is provided, where the method is applied to a data transmission layer in an android operating system, and the method includes:
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 a request for acquiring the transmission data by a second process 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;
wherein the data transmission interface implemented in the first process and the data transmission interface implemented in the second process are implemented 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;
packaging the transmission data according to the data type of the transmission data to obtain packaged transmission data;
and writing the packaged transmission data into the memory space.
Optionally, the encapsulating the transmission data according to the data type of the transmission data to obtain 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;
and 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 and sending the transmission data to the second process according to the obtaining request 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 analyzed transmission data according to the data type of the transmission data, and obtaining 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 transmission data of the first process through a data transmission interface implemented in the first process, the method further includes:
performing handshake check 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:
performing handshake check with the second process;
and if the handshake check 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 are received, opening a memory space in the android operating system 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 apparatus, which is applied to a data transmission layer in an android operating system, the apparatus including:
a first receiving unit, configured to receive transmission data of a first process through a data transmission interface implemented in the first process;
the first writing unit is used for writing the transmission data into a memory space;
a second receiving unit, 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, configured to extract the transmission data from the memory space according to the acquisition request and send the transmission data to the second process;
wherein the data transmission interface implemented in the first process and the data transmission interface implemented in the second process are implemented based on the data transmission interface defined by the data transmission layer.
In accordance with 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 any one of the above.
According to a fourth aspect of the present application, there is provided a computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement a cross-process data transmission method as described in any one of the above.
As can be seen 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 aiming at any two first processes and any two second processes which need data transmission, data transmission interfaces for data transmission are respectively realized in the first processes and the second processes, and the data transmission interfaces are realized based on data transmission interfaces defined by the data transmission layer. When cross-process data transmission is carried out, firstly, transmission data of a first process is received through a data transmission interface realized in the first process; then writing the transmission data into a memory space of an android operating system; then, receiving a request for acquiring the transmission data by the second process through a data transmission interface realized in the second process; 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, the data transmission interface is arranged in the process, and the data transmission interface supports data sending and data receiving; the method and the device support data transmission of basic types such as int, long, list and String and data transmission of complex types such as class objects, so that the data transmission is simpler to realize, bidirectional data transmission can be realized through one-time communication connection, and the data transmission direction and efficiency are improved.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
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 refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow diagram illustrating a cross-process data transmission method according to an embodiment of the present application;
FIG. 2 illustrates a block 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 is a schematic diagram illustrating an architecture of a cross-process data transmission apparatus according to an embodiment of the present application;
FIG. 5 shows a schematic structural diagram of an electronic device according to an embodiment of the present application;
FIG. 6 shows a schematic structural diagram 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 different versions of Linux kernels, and in a Linux environment, because process address spaces are mutually independent, each process has a different user address space. The global variables of any process cannot be seen in another process, so that the processes cannot access each other, data to be exchanged must pass through the kernel, a buffer is created in the kernel, the process a copies data from a user space to the kernel buffer, the process B reads data from the kernel buffer, the memory space in the kernel where the data is stored can be accessed by the two processes, and the process is called shared memory, and the mechanism provided by the kernel is called inter-process Communication (IPC) based on shared memory.
However, since the memory entity exists in the computer system, it can only be shared by processes in the same computer system. And the android operating system opens up a virtual machine for each process, which causes that IPC is difficult to be realized by using a shared memory in the android operating system.
In view of the above, the solution proposed in the present application is to implement a data transmission layer in an android operating system, perform memory caching of data to be transmitted by the data transmission layer or a data transmission module, and define a data transmission interface that can implement both data transmission and data reception, thereby solving the problem in the prior art that two sets of aid dl solutions need to be implemented to respectively perform data transmission and reception.
Based on this, an embodiment of the present 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, the method includes the following steps S110 to S140:
step S110, receiving transmission data of the first process through a data transmission interface implemented 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 cross-process data transmission, data transmission interfaces for data transmission can be arranged in the two processes in advance respectively so as to establish a communication bridge with other processes. The data transmission interface here can be understood as a data transmission interface defined based on the data transmission layer of the embodiment of the present application, and the data transmission interface not only can implement sending of data, but also can implement receiving of data, that is, implement bidirectional transfer of data.
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 an actual application scenario, the process may be understood as an execution entity of an application installed in various terminal devices implemented based on an android operating system, and therefore, the transmission data of the first process may be understood as data of the application.
Step S120, writing the transmission data into a memory space.
After receiving the transmission data of the first process, the transmission data may be stored in the memory space, so that other processes may obtain the transmission data of the first process from the memory space. The memory space refers to a memory space of an android operating system, the memory space can be regarded as a buffer area for storing a database, and any process can store own data in the memory space or read data from the memory space.
Step S130, receiving, through a data transmission interface implemented in a second process, an acquisition request of the second process for the transmission data.
In an actual application scenario, the second process may initiate an acquisition request for the transmission data of the first process according to an actual requirement, where the acquisition request usually carries a corresponding process identifier, so as to acquire corresponding transmission data according to the process identifier. Specifically, the request for acquiring the transmission data by the second process may be received through a data transmission interface implemented in the second process, where the data transmission interface implemented in the second process may be understood as a data transmission interface defined based on a data transmission layer, as in the data transmission interface implemented in the first process, and both data reception and data transmission may be implemented.
Step S140, according to the obtaining request, extracting the transmission data from the memory space and sending the transmission data to the second process; wherein the data transmission interface implemented in the first process and the data transmission interface implemented in the second process are implemented based on the data transmission interface defined by the data transmission layer.
After obtaining the request of the second process for acquiring the transmission data, the corresponding transmission data can be extracted from the memory space of the android operating system according to the acquisition request, 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 can not generate copies due to 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 refers to a data transmission interface defined by a data transmission layer, and data can be received and transmitted through the data transmission interface, the "first process" and the "second process" may be regarded as both a data transmitting side and a data receiving side, so as to implement bidirectional communication between processes.
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 which needs to be provided for the process B is defined in an AIDL file, only the data transmission of the process A to the process B can be implemented through the interface X, and if the data transmission of the process B to the process A is to be implemented, another AIDL file is needed to define another interface Y which needs to be provided for the process A.
The embodiment of the application realizes the bidirectional transmission of data through the data transmission interface arranged in the process, and supports both data transmission and data reception; the method and the device support data transmission of basic types such as int, long, list and String and data transmission of complex types such as class objects, so that the data transmission is simpler to realize, bidirectional data transmission can be realized through one-time communication connection, and the data transmission direction and efficiency are improved. In addition, the data transmission interface set in the process in the embodiment of the application is not directly used for data transmission 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 data transmission is ensured.
In an embodiment of the present application, when the transmission data is written into the memory space, the received transmission data may be analyzed first, then the type of the transmission data is determined according to the analysis result, where the data type may include basic data and object data, then the corresponding transmission data is encapsulated according to the analyzed data type, and finally the obtained encapsulated transmission data is stored in the memory space for subsequent transmission.
The basic data mainly includes int, long, list, String, etc., for example, a key word of the basic data specified in Java (an object-oriented programming language) starts with a lower case letter, and the basic data only has a numerical value and no ID (i.e., a position in a memory space). Meanwhile, the type of the basic data is invariable, and the memory is allocated in the stack, so that the cost of the basic data is relatively low. The object data mainly includes Integer, Boolean, Double, etc., for example, the keywords of the object data specified in Java all start with capital letters, and the object data has both numerical value and ID. In addition, the types of object data are both immutable and mutable, which allocates memory in the heap at a relatively high cost.
The data encapsulation may be understood as mapping data to 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.
Because the formats of the basic data and the object data are different, and the data encapsulation modes are also different, in an embodiment of the present application, if the received transmission data of the first process is analyzed to include both the basic data and the object data, the basic data and the object data may be encapsulated respectively, and finally, the basic data and the object data may be stored in the memory space respectively.
In an actual application scenario, if the transmission data of the first process contains data of an object type, serialization processing is generally required to be performed on the object data, and the serialization is a process of converting state information of an object into a form capable of being stored or transmitted, that is, converting the object into a character sequence, and being capable of completely restoring the character sequence to an original object later so as to facilitate storage and transmission. The existing object serialization method is to realize a Parcellable or Serializable interface in a process independently, and has high cost and complexity.
In an embodiment of the present application, because some processes may have implemented a serialized interface, when the data type obtained by parsing includes object data, it may be determined whether the object data has been serialized first, and if the object data has been 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 packaged, and finally the object format of the object data and the packaged object data are both written into the memory space, so that subsequent data transmission is facilitated.
The method and the device for processing the object data can be compatible with the process which realizes the serialization interface, and for the object data which is not serialized, the interface which carries out serialization on the object is not required to be additionally realized in the process, 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 an embodiment of the present application, when a second process wants to obtain transmission data of a first process, an obtaining request for the transmission data is initiated, so that corresponding transmission data can be obtained from a memory space according to the received obtaining request, because data stored in the memory space is encapsulated data, the transmission data obtained from the memory space can be analyzed first, then a specific data type including basic data and/or object data can be obtained according to an analysis result, and then the analyzed transmission data can be restored, that is, decapsulated, according to the analyzed data type to obtain restored transmission data; and finally, the restored transmission data is sent to the second process through a data transmission interface realized in the second process, so that a complete data transmission process is completed.
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 in the memory space, that is, the specific parsing object and parsing manner are different.
Because the formats of the basic data and the object data are different, and the data reduction modes are also different, in an embodiment of the present application, if the transmission data of the first process obtained from the memory space is analyzed to include both the basic data and the object data, the basic data and the object data can be respectively reduced, and finally, the reduced basic data and the object data are sent to the second process through a data transmission interface implemented in the second process.
For the object data, the object format of the object data is already stored in the memory space in the data storage stage, so in an embodiment of the present application, if the data type obtained by parsing includes the object data, the object format of the object data may be directly obtained from the memory space, and then the object data is restored, that is, decapsulated, by using the object format of the object data, so as to obtain the original form of transmission data.
The cross-process data transmission method is realized based on inter-process communication, specifically solves the problem of inter-process communication on the same host, and the existing local socket is a main means for solving the problem. The Localsocket is based on UNIX-domain Socket (UNIX domain Socket), which is an IPC communication mechanism derived on the basis of Socket. 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 packed, unpacked and calculated and checked, and has high natural execution efficiency, so that the Localsocket is widely used as an IPC communication means in an Android system.
In specific implementation, when data transmission is performed between the first process and the second process, a communication connection with the first process may be established through localcocket, that is, a handshake check may be performed with the first process, where the handshake refers to that after a communication link is established and before information transmission starts, parameters, such as an information transmission rate, an alphabet, a parity check, an interrupt process, and other protocol characteristics, are achieved through handshake. If the handshake check is successful, the transmission data of the first process may be stored in the memory space.
When the second process needs to acquire the transmission data, a communication connection with the second process can be established through the localcocket, that is, handshake verification is performed with 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 usually includes two parts, namely a physical Memory and a process Memory, namely a Random Access Memory (RAM) on the mobile device, when a program in the device is started, the system allocates a fixed Memory space (e.g., 16M, 32M indeterminate) to the program, the Memory space in the program is mapped to a certain area on the RAM, and then the program runs on the Memory space. Process memory is simply virtual memory (or referred to as logical memory), while program execution requires real memory, i.e., physical memory. Thus, when necessary, the operating system maps the memory (virtual memory) requested during program execution to RAM, allowing processes to use physical memory.
The memory space in the embodiment of the application may refer to a physical memory or a process memory of an android operating system. When data transmission of the process a needs to be performed, a small area can be opened in a process memory of the android system for caching transmission data of the process a, and then the small area can be mapped to a certain area on the RAM, so that the process a can run on the area of the RAM. By the mode of temporarily opening up the memory space only 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 an embodiment of the application, if the handshake verification with the second process fails, it indicates that the data of the first process cannot be transmitted to the second process at this time, and at this time, a memory space in an android operating system may be released; or when the return parameter of the second process is data transmission success, it indicates that the second process has successfully received the transmission data of the first process, and at this time, the memory space may also be released, so that the released memory space may be used to store the transmission data of other processes, and the resource utilization rate of the memory space is improved.
For the above situation of the handshake verification failure with the second process, when the first handshake verification failure occurs, the handshake verification may be performed again by invoking a retry mechanism, and if the verification fails within a period of time, the memory space in the android operating system may be released and the communication link may be released at the same time.
As shown in fig. 2, a flow chart diagram of a cross-process data transmission method according to an embodiment of the present application is provided. Taking the example that the process A transmits data to the process B, firstly, an IPC communication connection relation between the process A and the process B is established, after the communication connection relation is successfully established, the process A can transmit the transmission data into a data transmission layer through a data communication interface realized in the process A, then the transmission data is analyzed and encapsulated in the data transmission layer, and then the encapsulated transmission data is written 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 may be analyzed and restored first, and finally the restored transmission data is sent to the process B, thereby completing a data transmission process from the process a to the process B.
For the scene that the process B transmits data to the process A, the process is the same as the process, but the IPC communication connection relation does not need to be established with the process A and the process B again in the process, namely, the two-way transmission of the data between the process A and the process B can be realized only through one-time establishment of the IPC communication connection, and the data transmission efficiency is greatly improved.
As shown in fig. 3, a logic block diagram of cross-process data transmission according to an embodiment of the present application is provided. Still taking the example that the process a transmits data to the process B, first, an IPC communication connection relationship with the process a and the process B is established, and after the communication connection relationship is successfully established, the process a writes data for transmission to the data transmission interface. And then carrying out handshake check with the process A, if the handshake check is passed, analyzing the transmission data of the process A and 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 the transmission data, if the transmission data is object data, further judging whether the object data is serialized, if the object data is serialized, directly packaging the object data, and if the object data is not serialized, recording the object format of the object data, and then packaging the object data. And finally, storing the packaged basic data, the packaged object data and the packaged object format 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 fails within a period of time, the memory space in the android operating system is released and the communication link is released at the same time. If the handshake check is successful, acquiring corresponding transmission data from the memory space and analyzing the transmission data to obtain a data type, if the data type comprises object data, acquiring an object format from the memory space, then restoring the object data according to the object format, and directly restoring basic data, finally sending the restored transmission data to a process B through a data transmission interface of the process B, returning parameters in the process B, and if the returning parameters are data transmission success, considering that the process A successfully transmits the data to the process B, namely completing a complete data transmission process, releasing the memory space at this time to provide a storage space for other processes.
An embodiment of the present application provides a cross-process data transmission apparatus 400, where the apparatus is applied to a data transmission layer in an android operating system, and as shown in fig. 4, the apparatus 400 includes:
a first receiving unit 410, configured to receive transmission data of a first process through a data transmission interface implemented in 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 obtaining request and send the transmission data to the second process;
wherein the data transmission interface implemented in the first process and the data transmission interface implemented in the second process are implemented based on the data transmission interface defined by the data transmission layer.
In an 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; packaging the transmission data according to the data type of the transmission data to obtain packaged transmission data; and writing the packaged transmission data into the memory space.
In an 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 an 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; and 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 an embodiment of the present application, the first sending 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 an embodiment of the present application, the first sending 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 an embodiment of the present application, the first sending 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 check unit is used for performing handshake check with a first process after receiving 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 check unit is used for performing handshake check with a second process after receiving an acquisition request of the second process for 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 to write the transmission data into the memory space if the transmission data of the first process is received; and the memory space releasing unit is used for releasing the memory space if the handshake check with the second process fails or the return parameter of the second process is data transmission success.
It should be noted that, for the specific implementation of each apparatus embodiment, reference may be made to the specific implementation of the corresponding method embodiment, which is not described herein again.
In summary, according to the technical scheme of the application, the data transmission interface is arranged in the process, and the data can be transmitted in two directions through one-time communication connection, so that the data transmission direction and the data transmission efficiency are improved; in addition, in the process of cross-process data transmission, the transmission of complex data types such as object data is increased, and a serialization interface is not required to be realized 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 be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. In addition, this 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 any descriptions of specific languages are provided above to disclose the best modes of the present application.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the 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 interpreted as reflecting an intention that: this application is intended to cover such departures from the present disclosure as come within known or customary practice in the art to which this invention pertains. 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 device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. 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. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements 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 included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the application and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The 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. It will be appreciated by those skilled in the art 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 arrangement according to embodiments of the present application. The present application may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present application may be stored on a computer readable medium or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or 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 storage space 530 storing computer readable program code 531 for performing any of the method steps in the above described method. For example, the storage space 530 for storing the computer readable program code may include respective computer readable program codes 531 for respectively implementing various steps in the above method. 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 that shown in fig. 6. FIG. 6 shows a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer readable storage medium 600 has stored thereon a computer readable program code 531 for performing the steps of the method according to the application, readable by the processor 510 of the electronic device 500, which computer readable program code 531, when 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 on the computer readable storage medium may 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 usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.

Claims (12)

1. A cross-process data transmission method is applied to a data transmission layer in an android operating system, and 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 a request for acquiring the transmission data by a second process 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;
wherein the data transmission interface implemented in the first process and the data transmission interface implemented in the second process are implemented based on the data transmission interface defined by the data transmission layer.
2. The method of claim 1, wherein writing the transfer data into a memory space comprises:
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;
packaging the transmission data according to the data type of the transmission data to obtain packaged transmission data;
and writing the packaged transmission data into the memory space.
3. The method of claim 2, wherein encapsulating the transmission data according to the data type of the transmission data to obtain 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.
4. The method of claim 3, wherein encapsulating the object data comprises:
determining whether the object data has been serialized;
if the object data is serialized, directly packaging the object data;
and 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.
5. 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 obtaining 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.
6. The method according to claim 5, wherein the restoring the parsed transmission data according to the data type of the transmission data to obtain restored transmission data comprises:
and if the transmission data comprises the basic data and the object data, respectively restoring the basic data and the object data.
7. The method of claim 6, 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.
8. The method of claim 1,
after receiving transmission data of a first process through a data transmission interface implemented in the first process, the method further includes:
performing handshake check 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:
performing handshake check with the second process;
and if the handshake check is successful, extracting the transmission data from the memory space according to the acquisition request and sending the transmission data to the second process.
9. The method of claim 8, further comprising:
if the transmission data of the first process are received, opening a memory space in the android operating system 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.
10. A cross-process data transmission device is applied to a data transmission layer in an android operating system, and comprises the following steps:
a first receiving unit, configured to receive transmission data of a first process through a data transmission interface implemented in the first process;
the first writing unit is used for writing the transmission data into a memory space;
a second receiving unit, 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, configured to extract the transmission data from the memory space according to the acquisition request and send the transmission data to the second process;
wherein the data transmission interface implemented in the first process and the data transmission interface implemented in the second process are implemented based on the data transmission interface defined by the data transmission layer.
11. An electronic device, wherein the electronic device comprises: 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 claimed in any one of claims 1 to 9.
12. A computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement the cross-process data transmission method of any one of claims 1 to 9.
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 true CN112764946A (en) 2021-05-07
CN112764946B 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)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113778714A (en) * 2021-09-13 2021-12-10 北京技德系统技术有限公司 Linux-compatible Android-compatible shear plate sharing method and device
CN114039963A (en) * 2021-11-08 2022-02-11 浙江岩华文化科技有限公司 Data transmission method, device, electronic device and storage medium
CN115202891A (en) * 2022-09-15 2022-10-18 北京科云时代信息技术有限公司 Cross-process data acquisition and transmission method and system based on big data and storage medium
WO2023093675A1 (en) * 2021-11-25 2023-06-01 北京字节跳动网络技术有限公司 Bidirectional communication method, apparatus and device, and medium

Citations (9)

* 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
US20190138355A1 (en) * 2017-11-09 2019-05-09 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Method for Resource Allocation and Related Products
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

Patent Citations (9)

* 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
US20190138355A1 (en) * 2017-11-09 2019-05-09 Guangdong Oppo Mobile Telecommunications Corp., Ltd. Method for Resource Allocation and Related Products
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)》, pages 1628 *
胡波: "以太网与同步串行总线接口设计", 《CNKI优秀硕士学位论文全文库 信息科技辑》, no. 03, pages 139 - 543 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113778714A (en) * 2021-09-13 2021-12-10 北京技德系统技术有限公司 Linux-compatible Android-compatible shear plate sharing method and device
CN113778714B (en) * 2021-09-13 2024-01-09 北京技德系统技术有限公司 Shared shear plate method and device compatible with Android for Linux
CN114039963A (en) * 2021-11-08 2022-02-11 浙江岩华文化科技有限公司 Data transmission method, device, electronic device and storage medium
WO2023093675A1 (en) * 2021-11-25 2023-06-01 北京字节跳动网络技术有限公司 Bidirectional communication method, apparatus and device, and medium
CN115202891A (en) * 2022-09-15 2022-10-18 北京科云时代信息技术有限公司 Cross-process data acquisition and transmission method and system based on big data and storage 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

Also Published As

Publication number Publication date
CN112764946B (en) 2024-02-02

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
USRE43375E1 (en) System and method for communications in a distributed computing environment
CN106415506B (en) For calling the group scheme of the object-oriented of safety zone
US20080222665A1 (en) System and Method for Support of Legacy Communications Protocols in a Smart Card
US20180027074A1 (en) System and method for storage access input/output operations in a virtualized environment
WO2017148278A1 (en) Service implementation method, apparatus and system based on fix protocol
CN101304373A (en) Method and system for implementing high-efficiency transmission chunk data in LAN
CN110287040B (en) Implementation system for remotely calling service framework
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
CN103677820A (en) Embedded development software output method and system
CN110333993B (en) Memory snapshot generation method and device, electronic equipment and storage medium
CN108496157B (en) System and method for providing runtime trace using an extended interface
US6212572B1 (en) Device for the utilization of exported pseudosockets
CN113010103B (en) Data storage method and device, related equipment and storage medium
CN1988479A (en) Method for recording system information and object pile
CN113918245A (en) Data calling method, device, equipment and computer readable storage medium
CN113971158A (en) Network card-based memory access method, device and system
CN109086380B (en) Method and system for compressing and storing historical data
CN101616149B (en) Information processing method, device and information transmission system
US20070033248A1 (en) System and method for support of legacy communications protocols in a smart card
CN112231409B (en) Database synchronization initialization loading method, device, equipment and storage 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