Data transmission method and electronic device

By creating shared memory for each business process and performing data writing and notification reading on electronic devices, the problem of IPC communication exceeding memory limits and crashing in multi-business concurrent scenarios is solved, thereby increasing the number of concurrent data transmissions.

CN120256155BActive Publication Date: 2026-03-03HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-25
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

In scenarios with multiple concurrent services, inter-process communication (IPC) is prone to memory overload and crashes, resulting in limited data transmission.

Method used

By creating shared memory for each business process in the electronic device, the business process writes data to the shared memory and then notifies the transmission process to read it. The transmission process reads the data from the shared memory and sends it, which reduces the data size of a single communication and avoids IPC communication exceeding memory limits and crashes.

Benefits of technology

It increases the number of concurrent data transmissions, solves the data size limitation of IPC communication in multi-service concurrent scenarios, and avoids the problems of communication exceeding memory and crashing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120256155B_ABST
    Figure CN120256155B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data transmission method and an electronic device. The method is applied to a first electronic device and includes: when a plurality of service processes in the first electronic device exist service data to be sent to a second electronic device, writing, by a first service process in the first electronic device, the service data to be sent into a first shared memory, wherein the service processes of different service applications correspond to different shared memories; sending, by the first service process, a first notification message to a first transmission process in the first electronic device based on an inter-process communication (IPC) communication mechanism, the first notification message being used to instruct the first transmission process to read the service data to be sent from the first shared memory, and the first notification message not carrying the service data to be sent; reading, by the first transmission process, the service data to be sent from the first shared memory, and sending the service data to be sent to the second electronic device. In this way, problems such as IPC communication exceeding memory and crashing are avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of electronic technology, specifically to a data transmission method and an electronic device. Background Technology

[0002] Currently, data transmission between two (or more) electronic devices can support not only single-service data transmission but also concurrent data transmission of multiple services. For example, if electronic device A is casting its screen to electronic device B and simultaneously initiates a super keyboard and mouse service on electronic device B, then electronic device A needs to transmit both the screen casting data and the super keyboard and mouse service data to electronic device B, thus achieving concurrent data transmission of multiple services.

[0003] The most popular data transmission method currently is inter-process communication (IPC). In this method, the service process and the transmission process in electronic device A are separate processes. The service process needs to send its data to the transmission process via IPC, and the transmission process then forwards the data to electronic device B. If multiple services are running in electronic device A, multiple service processes will be transmitting data with the transmission process. However, because the IPC communication mechanism has limitations on the size of data transmitted in a single transaction, if the data from multiple services is large, problems such as IPC exceeding memory limits or memory crashes may occur during data transmission. Summary of the Invention

[0004] This application provides a data transmission method and an electronic device that can avoid problems such as IPC communication exceeding memory limits and crashes in multi-service concurrent scenarios, while increasing the number of concurrent data transmissions.

[0005] In a first aspect, this application provides a data transmission method applied to a first electronic device, wherein a communication connection exists between the first electronic device and a second electronic device. The method includes: when multiple service processes in the first electronic device have service data to be sent to the second electronic device, the first service process in the first electronic device writes the service data to be sent into a first shared memory, wherein different service processes correspond to different shared memories, and the first service process is any one of the multiple service processes, corresponding to the first shared memory; the first service process sends a first notification message to a first transmission process in the first electronic device based on an inter-process communication (IPC) mechanism, the first notification message instructing the first transmission process to read the service data to be sent from the first shared memory, the first notification message not carrying the service data to be sent; the first transmission process reads the service data to be sent from the first shared memory and sends the service data to be sent to the second electronic device.

[0006] In this application, during the transmission of service data from the first electronic device (i.e., electronic device A) to the second electronic device (i.e., electronic device B), the service data originates from the service application within the first electronic device. After the service application runs, a first service process (i.e., service process A) is initiated. In this application, the first service process does not directly send the service data to be sent to the first transmission process (i.e., transmission process A). Instead, it writes the service data into the created first shared memory and sends a first notification message to the first transmission process via IPC communication to notify it that there is service data to be sent. The first transmission process then reads the service data from the first shared memory. It should be noted that the first notification message sent by the first service process does not carry service data. Therefore, the first service process and the first transmission process only need to communicate the notification message. Even if multiple services execute concurrently, the size of the communication messages will not exceed the data size limit of IPC communication. This reduces the size of the data sent in a single transmission, solves the data size limitation of IPC communication in multi-service concurrent scenarios, avoids problems such as communication exceeding memory limits and crashes, and simultaneously increases the number of concurrent data transmissions.

[0007] In conjunction with the first aspect, in some implementations of the first aspect, before the service data to be sent is written to the first shared memory by the first service process in the first electronic device, the above method further includes: determining whether it is necessary to create shared memory by the first transmission process, and if it is determined that it is necessary to create shared memory, creating the first shared memory corresponding to the first service process.

[0008] As described above, the first business process needs to write business data to the first shared memory. Therefore, the first shared memory needs to be created in advance. In this application, after the business thread starts, it will instruct the start of the business transmission service and launch the first transmission process, which will then create the first shared memory. Specifically, the first transmission process can first determine whether shared memory needs to be created, and if so, create the first shared memory corresponding to the first business process.

[0009] In some implementations, the above-mentioned determination of whether to create shared memory through the first transmission process includes: determining whether to create shared memory through the first transmission process based on the service information corresponding to the first service process, wherein the service information includes service type and / or service priority.

[0010] In this application, because some business applications require large amounts of data transfer while others require small amounts, to achieve a dynamic and intelligent data transmission process, this application can determine whether shared memory needs to be created based on the business type and / or business priority. Shared memory is created when it is required (e.g., large data transfer volume), and not created when it is not required (e.g., small data transfer volume). It can be understood that, without creating shared memory, the first business process can directly send business data to the first transmission process, which then sends the business data to the second electronic device.

[0011] When determining whether shared memory is needed based on the type of service, it is necessary to create shared memory for file transfers or screen mirroring, as these types of services typically involve transferring large amounts of data. If it is not a file transfer or screen mirroring service, then shared memory is not required.

[0012] When determining whether to create shared memory based on business priority, shared memory needs to be created if the priority is high, and it does not need to be created if the priority is low.

[0013] In some scenarios, whether or not shared memory needs to be created can be specified by the business application itself, such as when a screen mirroring application specifies that shared memory needs to be created.

[0014] In conjunction with the first aspect, in some implementations of the first aspect, when it is determined that shared memory needs to be created, the above method further includes: the first electronic device sending a request message to the second electronic device, requesting the second electronic device to create a corresponding second shared memory, the request message carrying an identifier of whether to create shared memory.

[0015] In other words, when the first electronic device creates shared memory, it sends a request to the second electronic device, requesting the second electronic device to also create shared memory, to ensure that both electronic devices can perform IPC communication normally. The request message sent from the first electronic device to the second electronic device can carry an indicator indicating whether shared memory should be created. This indicator can be represented by an integer parameter; for example, 1 indicates creating shared memory, and 0 indicates not creating shared memory. When the indicator is 1, the second electronic device will also create shared memory upon receiving the request.

[0016] In conjunction with the first aspect, in some implementations of the first aspect, writing the service data to be sent into the first shared memory through the first service process in the first electronic device includes: writing the service data to be sent and the message length corresponding to the service data to be sent into the first shared memory through the first service process.

[0017] To ensure the accuracy of data reads and writes to the first shared memory, i.e., to prevent reading erroneous business data, this application can also perform security verification on the business data in the shared memory. In this implementation, the business data written to the first shared memory adopts a data format of message length + message content. The message length refers to the length of the business data to be sent, for example, the message length can occupy 4 bytes. The message content refers to the specific content of the business data to be sent by the first business process. When the first business process writes business data to the first shared memory, it first writes the message length, for example, 4 bytes of message length, and then writes the business data to be sent at a 4-byte offset after writing the message length.

[0018] In this implementation, after the first business process writes the business data into the first shared memory, the first notification message sent by the first business process to the first transmission process can carry the message length corresponding to the business data to be sent, but does not carry the business data.

[0019] In some implementations, the above-mentioned reading of service data to be sent from the first shared memory via the first transmission process includes: reading a first message length from the first shared memory via the first transmission process; if the read first message length is equal to the message length corresponding to the service data to be sent carried in the first notification message, then reading the service data to be sent from the first shared memory.

[0020] In other words, after receiving the first notification message, the first transmission process can read the message length (length) carried in the first notification message. Then, the first transmission process reads the first message length (length') from the first shared memory. If length' equals length, it means the message verification is successful, and the first transmission process can read the business data from a position offset 4 bytes after the message length in the first shared memory. If length' does not equal length, it means the message verification fails, and the first transmission process will not read the business data, i.e., the data transmission fails. This improves the accuracy of the data transmission process.

[0021] In conjunction with the first aspect, in some implementations of the first aspect, writing the service data to be sent into the first shared memory through the first service process in the first electronic device includes: writing the service data to be sent from the beginning position of the first shared memory through the first service process;

[0022] Reading service data to be sent from the first shared memory through the first transmission process includes: reading service data to be sent from the beginning position of the first shared memory through the first transmission process.

[0023] In other words, the process of the first service process writing service data to the first shared memory and the process of the first transmission process reading service data from the first shared memory in this application can be serialized, i.e., a write is followed by a read, and a write is followed by a read. For the first shared memory, each write starts from the beginning (i.e., writing to the beginning position of the shared memory), and each read also starts from the beginning. After each read, the read service data can be deleted, and the writing is repeated in a loop. This can prevent problems such as data being overwritten or data loss when data is not accessed.

[0024] In conjunction with the first aspect, in some implementations of the first aspect, the first electronic device includes a transmission service platform and a transmission dynamic library. The above-mentioned sending a first notification message to the first transmission process in the first electronic device through the first service process based on the IPC communication mechanism includes: sending a first notification message to the transmission service platform through the first service process based on the IPC communication mechanism, and the transmission service platform notifying the transmission dynamic library to read the service data to be sent from the first shared memory, wherein the first transmission process is the process started when the transmission service platform starts.

[0025] Once the first service process is started, it can instruct the transmission service platform to start the service transmission service, and correspondingly launch the first transmission process. Then, the first service process can send a first notification message to the transmission service platform based on the IPC communication mechanism. The transmission service platform then notifies (or calls) the transmission dynamic library to read the service data to be sent from the first shared memory. After the transmission dynamic library reads the service data from the first shared memory, it can send it to the second electronic device.

[0026] In some implementations, before the service data to be sent is written to the first shared memory by the first service process in the first electronic device, the method further includes: instructing the transmission service platform to start the service transmission service through the first service process; determining whether shared memory needs to be created through the transmission service platform, and creating the first shared memory corresponding to the first service process if it is determined that shared memory needs to be created; notifying the transmission dynamic library to start the client through the transmission service platform, and saving the identifier of the first shared memory when the transmission dynamic library starts the client.

[0027] In other words, the transport service platform can determine whether shared memory needs to be created based on the service type and / or service priority. If shared memory creation is required, it creates the first shared memory corresponding to the first service process and records the identifier of the first shared memory (e.g., the shared memory file descriptor fd). The address of the shared memory can be found through this shared memory fd1, allowing data to be read and written to the shared memory corresponding to that address. Then, the transport service platform can notify the transport dynamic library to start the client, carrying the identifier of the first shared memory in the notification. The transport dynamic library can then start the client, save the identifier of the first shared memory, and return a successful client start message to the transport service platform. This allows subsequent first service processes to write service data to the first shared memory without having to send service data directly to the first transport process, thus avoiding problems such as IPC communication exceeding memory limits and crashes.

[0028] Secondly, this application provides a data transmission method applied to a second electronic device, wherein a communication connection exists between a first electronic device and the second electronic device. The method includes: receiving service data from the first electronic device through a second transmission process in the second electronic device, and writing the service data into a second shared memory; sending a second notification message to a second service process in the second electronic device through the second transmission process based on an IPC communication mechanism, the second notification message being used to instruct the second service process to read service data from the second shared memory, the second notification message not carrying service data; reading the service data from the second shared memory through the second service process, and processing the service data.

[0029] In conjunction with the second aspect, in some implementations of the second aspect, before writing the business data into the second shared memory, the above method further includes: receiving a request message from the first electronic device through a second transmission process, determining whether it is necessary to create shared memory based on the request message, and creating the second shared memory if it is determined that it is necessary to create shared memory, wherein the request message carries an identifier indicating whether to create shared memory.

[0030] The second electronic device (i.e., electronic device B) can also employ a shared memory mechanism. After receiving a request message from the first electronic device, if the second electronic device determines that shared memory needs to be created, it creates the second shared memory. Subsequently, upon receiving service data sent by the first electronic device, the second transmission process (i.e., transmission process B) can write the service data into the second shared memory and send a second notification message to the second service process (i.e., service process B) to notify it of the service data that is currently waiting to be received. The second service process then reads the service data from the second shared memory. It should be noted that the second notification message sent by the second transmission process does not carry service data. Therefore, the second service process and the second transmission process only need to communicate notification messages. Even if multiple services are executed concurrently, the size of the communication messages will not exceed the data size limit of IPC communication. This reduces the size of the data sent in a single instance, solves the limitation on the data size of IPC communication in multi-service concurrent scenarios, avoids problems such as communication exceeding memory limits and crashes, and increases the number of concurrent data transmissions.

[0031] Thirdly, this application provides an apparatus included in an electronic device. This apparatus has the function of implementing the electronic device behavior described in the first aspect and its possible implementations, or it has the function of implementing the electronic device behavior described in the second aspect and its possible implementations. The function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules or units corresponding to the above functions. For example, a receiving module or unit, a processing module or unit, etc.

[0032] Fourthly, this application provides an electronic device, which includes a processor, a memory, and an interface; the processor, memory, and interface cooperate with each other to enable the electronic device to execute any method of the technical solution in the first aspect, or to execute any method of the technical solution in the second aspect.

[0033] Fifthly, this application provides a chip including a processor. The processor is configured to read and execute a computer program stored in a memory to perform the methods of the first aspect and any possible implementation thereof, or to perform the methods of the second aspect and any possible implementation thereof.

[0034] Optionally, the chip may also include a memory, which is connected to the processor via a circuit or wire.

[0035] Alternatively, the chip may also include a communication interface.

[0036] Sixthly, this application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform any method of the technical solution of the first aspect, or any method of the technical solution of the second aspect.

[0037] In a seventh aspect, this application provides a computer program product comprising: computer program code, which, when executed on an electronic device, causes the electronic device to perform any method of the technical solution of the first aspect, or to perform any method of the technical solution of the second aspect. Attached Figure Description

[0038] Figure 1 This is a schematic diagram of a data transmission process provided by related technologies;

[0039] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0040] Figure 3 This is a software structure block diagram of an electronic device provided in an embodiment of this application;

[0041] Figure 4 This is a schematic diagram of a system architecture for an example of a data transmission process provided in an embodiment of this application;

[0042] Figure 5 This is a timing flowchart of an example data transmission method provided in an embodiment of this application;

[0043] Figure 6 This is a schematic diagram of an example of a serialized read / write process provided in an embodiment of this application;

[0044] Figure 7 This is a schematic diagram illustrating the format of data written to shared memory, provided in an embodiment of this application.

[0045] Figure 8 This is a timing flowchart of another data transmission method provided in an embodiment of this application;

[0046] Figure 9 This is a schematic diagram illustrating a performance comparison between creating shared memory and not creating shared memory, as provided in an embodiment of this application. Detailed Implementation

[0047] The technical solutions of the embodiments of this application will be described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; "and / or" in this text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.

[0048] Hereinafter, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first," "second," or "third" may explicitly or implicitly include one or more of that feature.

[0049] First, it should be noted that the concurrent data transmission of multiple services in this embodiment can be the data transmission between two (or more) electronic devices simultaneously initiating multiple services. Taking electronic device A and electronic device B as an example, electronic device A and electronic device B can simultaneously initiate multiple services such as super keyboard and mouse, super call, and screen casting (such as cross-source screen casting). To ensure the normal operation of multiple services, electronic device A needs to send the service data corresponding to each service to electronic device B. The service data sent by electronic device A to electronic device B can include, but is not limited to, message data, streaming media data, and file data.

[0050] Typically, when electronic device A transmits data to electronic device B, it uses inter-process communication (IPC). IPC is a capability provided by the operating system for data exchange and sharing between different processes. It allows different processes to pass messages, achieving inter-process communication and synchronization. So, how... Figure 1 As shown, the process of electronic device A transmitting service data to electronic device B using the IPC communication mechanism can include the following: the service process (which is started when electronic device A initiates a service) and the transmission process (the process used to transmit service data to electronic device B) in electronic device A are different processes. The service process needs to send service data to the transmission process through the IPC communication mechanism, and then the transmission process sends the service data to electronic device B (e.g., via the network air interface). After receiving the service data, the transmission process of electronic device B also sends the service data back to the service process through the IPC communication mechanism. If multiple services are started in electronic device A, multiple service processes will be started accordingly. These multiple service processes need to transmit data with the transmission process to send their respective service data to electronic device B.

[0051] In the Android system, the commonly used IPC communication mechanism is the Binder mechanism. The Binder mechanism is a client / server (C / S) based communication mechanism that allows one process to expose its services to other processes, enabling remote calls between them. It provides cross-process method calls, data transfer, and thread synchronization. However, the Binder mechanism only allows single data transmissions of up-layer user space (such as business processes and applications) to not exceed 1MB. This can lead to transmission limitations during concurrent data transmission of multiple services, resulting in Binder communication memory overflow and crashes. For example, when electronic device A and electronic device B simultaneously initiate screen mirroring and super call services, the business process corresponding to the screen mirroring service needs to send its service data to the transmission process via the Binder mechanism, and the super call service also needs to send its service data to the transmission process via the Binder mechanism. If the business process corresponding to the screen mirroring service sends 1MB of service data in a single Binder transmission, then the super call service may fail to send its service data normally via the Binder mechanism, resulting in Binder communication memory overflow and crashes.

[0052] In view of this, embodiments of this application provide a data transmission method. By creating shared memory, each service process corresponds to a shared memory. After a service process writes service data into the shared memory, it can notify the transmission process (without carrying the service data in the notification). The transmission process can then read the service data from the shared memory to send the service data to other electronic devices. Thus, the service process does not need to send service data to the transmission process via IPC communication; it only needs to send a notification message. This reduces the size of the data sent in a single instance, avoids the aforementioned communication memory overload and crash issues in multi-service concurrent scenarios, and simultaneously increases the number of concurrent data transmissions.

[0053] Furthermore, the data transmission method provided in this application embodiment can be applied to electronic devices that can interact with other electronic devices, such as mobile phones, tablets, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), and smart screens. This application embodiment does not impose any restrictions on the specific type of electronic device.

[0054] For example, Figure 2 This is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application. Taking a mobile phone as an example, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0055] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0056] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.

[0057] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0058] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.

[0059] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.

[0060] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.

[0061] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.

[0062] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data, phonebook, etc.). Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0063] Touch sensor 180K, also known as a "touch panel," can be located on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touch screen." Touch sensor 180K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be located on the surface of electronic device 100, in a different position than display screen 194.

[0064] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0065] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100.

[0066] Figure 3 This is a software structure block diagram of an electronic device 100 according to an embodiment of this application. The layered architecture divides the software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer. The application layer may include a series of application packages.

[0067] like Figure 3 As shown, the application package may include business applications, including but not limited to applications such as camera, gallery, call, map, navigation, WLAN, Bluetooth, music, video, and SMS.

[0068] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions.

[0069] like Figure 3 As shown, the application framework layer can include a transport service platform. The business process corresponding to the business application can invoke the transport service platform to initiate the business transport service. The transport service platform can determine whether to use a shared memory transport scheme based on information such as the business type, i.e., whether shared memory needs to be created. If shared memory needs to be created, it will create the shared memory and record its identifier, such as the shared memory file descriptor (fd).

[0070] In addition, the application framework layer may also include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc.

[0071] The window manager manages window applications. The content provider stores and retrieves data, making it accessible to applications. The view system includes visual controls, such as controls for displaying text and images. The phone manager provides communication functionality to electronic devices. The resource manager provides applications with various resources, such as localized strings, icons, images, layout files, video files, etc. The notification manager allows applications to display notifications in the status bar, which can be used to convey informational messages. Notifications can also appear as icons or scrollbar text in the system's top status bar.

[0072] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.

[0073] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.

[0074] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.

[0075] The system library may include a transport dynamic library. Specifically, when the transport service platform determines that shared memory needs to be created, the platform can send a notification message to the transport dynamic library to launch the client, simultaneously passing the shared memory file descriptor (fd). The transport dynamic library can launch the client, save the shared memory fd, and return a message to the transport service platform indicating successful client launch.

[0076] After the shared memory is successfully created, if a business application needs to use it to transfer data, it can write the business data into the shared memory and send a notification message to the transmission service platform via the IPC communication mechanism. This notification message only carries the notification content and not the actual business data. The transmission service platform then notifies the transmission dynamic library, which reads the business data from the shared memory, encapsulates it, and sends it to other electronic devices via the communication driver.

[0077] In addition, the system library may also include a surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.

[0078] The Surface Manager manages the display subsystem and provides fusion of 2D and 3D layers for multiple applications. The Media Library supports playback and recording of various common audio and video formats, as well as still image files, and supports multiple audio and video encoding formats. The 3D Graphics Processing Library implements 3D graphics drawing, image rendering, compositing, and layer processing. The 2D Graphics Engine is the drawing engine for 2D graphics.

[0079] The kernel layer is the layer between hardware and software. At a minimum, the kernel layer includes display drivers, communication drivers, audio drivers, and sensor drivers. Communication drivers can include Wi-Fi drivers, Bluetooth drivers, etc., and can be used for network communication with other electronic devices; for example, they can send the aforementioned service data to other electronic devices.

[0080] Based on an electronic device with the aforementioned software structure, if electronic device A transmits data to electronic device B, and both electronic device A and electronic device B possess the aforementioned software structure, then the system architecture composed of electronic device A and electronic device B can be as follows: Figure 4 As shown, in this system architecture, electronic device A includes business application A, transmission service platform A, transmission dynamic library A, and communication driver A, while electronic device B includes business application B, transmission service platform B, transmission dynamic library B, and communication driver B.

[0081] In implementing the data transmission method of this application embodiment, the system architecture may include a service startup process and a data transmission process. The service startup process may include: when a user clicks on the business application A of electronic device A, the business process A is started. Business process A calls the transmission service platform A through the system interface to start the business transmission service. The transmission service platform A determines whether shared memory needs to be created, and if so, creates shared memory and records the identifier A of the shared memory. The transmission service platform A instructs the transmission dynamic library A to launch the client and pass in the identifier A of the shared memory. After launching the client, the transmission dynamic library A saves the identifier A of the shared memory. The transmission dynamic library A returns a message to the transmission service platform A indicating that the client has been successfully launched. The transmission service platform A sends a notification message to the transmission service platform B of electronic device B to start the business transmission service. The transmission service platform B determines whether shared memory needs to be created, and if so, creates shared memory and records the identifier B of the shared memory. The transmission service platform B instructs the transmission dynamic library B to launch the server and pass in the identifier B of the shared memory. After launching the server, the transmission dynamic library B saves the identifier B of the shared memory. The transport dynamic library B returns a message to the transport service middleware B indicating that the server has been successfully started. Transport service middleware B sends a notification message to transport service middleware A indicating that the server has started. Transport service middleware A notifies business process A that the business transport service has started successfully, and transport service middleware B notifies business process B that the business transport service has started successfully.

[0082] The data transmission process may include: Business process A of electronic device A writes business data to shared memory; business process A notifies the transmission service platform A of the business data to be sent via IPC communication; the transmission service platform A notifies the transmission dynamic library A of the business data to be sent; the transmission dynamic library A reads the business data from shared memory, encapsulates it, and sends it to the kernel-level communication driver A; the communication driver A sends the business data to the communication driver B of electronic device B via the network; the communication driver B sends the business data to the transmission dynamic library B; the transmission dynamic library B receives the business data, writes it to shared memory, and notifies the transmission service platform B of the business data to be received; the transmission service platform B notifies business process B of the business data to be received via IPC communication; business process B reads the business data from shared memory and performs corresponding data processing.

[0083] For easier understanding, the following embodiments of this application will be described using the following methods: Figure 4 Taking the system architecture shown as an example, and in conjunction with the accompanying drawings and application scenarios, the data transmission method provided in this application embodiment will be specifically described.

[0084] Figure 5 This is a timing flowchart illustrating an example of a data transmission method provided in this application. Taking electronic device A sending service data to electronic device B as an example, the method may include:

[0085] S1. Business application A receives the user's first operation and starts business process A.

[0086] The first operation can be either the user's operation to run and start the business application A, or the operation to start a certain function on the business application A. For example, clicking the screen casting control will start the screen casting business process, and clicking the super keyboard and mouse control will start the super keyboard and mouse business process, etc.

[0087] S2, Business Process A instructs Transmission Service Platform A to start the business transmission service.

[0088] Here, business process A can call the transmission service interface to instruct the transmission service platform A to start the business transmission service, such as starting the screen mirroring service. In some implementations, when business process A instructs the transmission service platform A to start the business transmission service, it can carry corresponding business information, including but not limited to business type, business name (or service name), and business priority. It can be understood that when business process A instructs the transmission service platform A to start the business transmission service, it also correspondingly starts the transmission process.

[0089] S3. The transmission service platform A determines whether it is necessary to create shared memory. If it is necessary to create shared memory, then execute S4. If it is not necessary to create shared memory, then execute S34 in the following embodiment.

[0090] In this system, the transmission service platform A can determine whether shared memory needs to be created based on the service type and / or service priority. When determining the need for shared memory based on service type, file transfer and screen mirroring services, for example, require shared memory creation because these service types typically involve large amounts of data. This can also be understood as follows: if the transmission service platform A identifies a large volume of data required by the current service based on the service type and / or service priority, it determines that shared memory needs to be created; conversely, if it identifies a small volume of data required by the current service, it determines that shared memory does not need to be created. In some implementations, the need for shared memory creation can also be specified by the application itself, such as a screen mirroring application specifying that shared memory needs to be created.

[0091] S4. The transmission service platform A creates shared memory corresponding to business process A.

[0092] In some implementations, the transmission service platform A can request a region (e.g., a region of specified size) from the memory space of electronic device A via a system interface as shared memory for the aforementioned business processes. In this case, the identifier A of the shared memory (e.g., shared memory file descriptor fd1) can be recorded. Through this shared memory fd1, the address of the shared memory can be found, allowing data to be read and written to the shared memory corresponding to that address. It can be understood that the shared memory created for business process A here is created within the transmission process.

[0093] It should be noted that different business processes correspond to different shared memory. For example, the identifier of a business process or the identifier of a business service can be associated with the shared memory file descriptor (fd). Therefore, the shared memory between different businesses is independent of each other and there is no risk of it being used interchangeably.

[0094] S5. Transmission service platform A sends a notification message to transmission dynamic library A to start the client.

[0095] The notification message may carry the identifier A of the shared memory (e.g., shared memory fd1). The transport service platform A sends this notification message to the transport dynamic library A to instruct the transport dynamic library A to launch the client. It can be understood that the transport service platform A can send notification messages to the transport dynamic library A by calling the transport dynamic library A's interface.

[0096] S6. The dynamic library A is used to start the client and save the shared memory identifier A.

[0097] S7. The transmission dynamic library A returns a success message to the transmission service middleware A, indicating that the client has been successfully launched.

[0098] After receiving the notification message from the transport service platform A, transport dynamic library A can start the client and save the identifier A of the shared memory created above (such as shared memory fd1). Subsequently, transport dynamic library A can also return a message to transport service platform A that the client has been successfully started.

[0099] S8. Electronic device A's transmission service platform A sends a request to electronic device B's transmission service platform B to start the business transmission service.

[0100] In other words, after electronic device A starts the service and creates shared memory, it sends a request to electronic device B, requesting electronic device B to also start the service transmission service, create shared memory, and start the corresponding server.

[0101] In some implementations, the request sent from transmission service platform A to transmission service platform B may include the identifier of the service transmission service, the device identifier of electronic device A, and an identifier indicating whether shared memory is used. The identifier indicating whether shared memory is used can be represented by an integer parameter; for example, 1 indicates shared memory is used, and 0 indicates it is not. If the identifier is 1, electronic device B will also create shared memory upon receiving the request. Thus, electronic devices can interactively negotiate whether to use shared memory. If one electronic device uses shared memory, the other electronic device will also use shared memory, achieving the goal of preventing memory overload when multiple services are running concurrently on both sides.

[0102] S9. The transmission service platform B determines whether it is necessary to create shared memory. If it is necessary to create shared memory, then execute S10. If it is not necessary to create shared memory, then execute S40 in the following embodiment.

[0103] That is, the transmission service platform B can determine whether shared memory needs to be created based on the flag indicating whether shared memory is used in the above request. For example, if the flag is 1, electronic device B needs to create shared memory.

[0104] S10. The transmission service platform B creates shared memory corresponding to the business process B.

[0105] In some implementations, the transmission service platform B can request a region from the memory space of electronic device B via a system interface as shared memory for the business process B. Here, business process B is the process within electronic device B that will respond to and execute the service initiated by electronic device A. At this point, the identifier B of the shared memory (e.g., shared memory file descriptor fd2) can be recorded. Through this shared memory fd2, the address of the shared memory can be found, allowing data to be read and written to the shared memory corresponding to that address. It can be understood that the shared memory created here for business process B is created within the transmission process.

[0106] S11. Transmission service platform B sends a notification message to transmission dynamic library B to start the server.

[0107] The notification message may carry the identifier B of the shared memory (such as shared memory fd2). The transmission service platform B sends the notification message to the transmission dynamic library B to instruct the transmission dynamic library B to start the server.

[0108] S12. The dynamic library B is used to start the server and save the identifier B of the shared memory.

[0109] S13. The transmission dynamic library B returns a successful start message to the transmission service middleware B.

[0110] After receiving the notification message from the transport service platform B, transport dynamic library B can start the server and save the identifier B of the shared memory created above (such as shared memory fd2). Subsequently, transport dynamic library B can also return a message to transport service platform B that the server has been successfully started.

[0111] S14. Electronic device B's transmission service platform B sends a message to electronic device A's transmission service platform A indicating that the business transmission service has been successfully started.

[0112] In other words, after electronic device B starts the service transmission service and completes the creation of shared memory, it will send a message to electronic device A indicating that the service has been successfully started, notifying electronic device A to proceed to the next step.

[0113] S15, Transmission Service Platform A notifies the business process that the A business transmission service has started successfully.

[0114] S16. Business process A obtains the shared memory identifier A', and the business transmission service starts successfully.

[0115] When the transmission service platform A notifies the service process A that the service transmission service has started successfully, it can include a shared memory identifier A (e.g., shared memory fd1). Upon receiving this notification, service process A can convert the shared memory identifier A to create a shared memory identifier A' (e.g., shared memory fd1') that service process A can recognize. The shared memory identifiers A and A' correspond to the same shared memory, namely the shared memory created by the transmission service platform A. Therefore, the shared memory on the electronic device A side is successfully created, and the service transmission service starts successfully.

[0116] S17. The transmission service platform B notifies the business process that the B business transmission service has started successfully.

[0117] S18. Business process B is converted to obtain the shared memory identifier B', and the business transmission service starts successfully.

[0118] When the transmission service platform B notifies the business process B that the business transmission service has started successfully, it can include a shared memory identifier B (e.g., shared memory fd2). Upon receiving this notification, the business process B can convert the shared memory identifier B to create a shared memory identifier B' (e.g., shared memory fd2') that the business process B can recognize. The shared memory identifiers B and B' correspond to the same shared memory, namely the shared memory created by the transmission service platform B. Thus, the shared memory on the electronic device B side is successfully created, and the business transmission service starts successfully.

[0119] After the service transmission services of both electronic device A and electronic device B are successfully started, electronic device A can transmit data to electronic device B. The specific process is as follows:

[0120] S19. Business process A writes business data to shared memory.

[0121] In other words, when electronic device A transmits service data to electronic device B, service process A in electronic device A can write the service data to be sent into the shared memory created above. Service process A can find the address of the shared memory using the shared memory identifier A' obtained through the above conversion, and then write the service data into the shared memory.

[0122] S20. Business process A notifies the transmission service platform A of the business data that is currently waiting to be sent through the IPC communication mechanism.

[0123] S21. Transmission service platform A notifies transmission dynamic library A of the business data that is currently waiting to be sent.

[0124] After business process A writes business data to shared memory, it can notify the transmission service platform A of the business data to be sent, so that the transmission process can transmit the business data. It should be noted that when business process A notifies the transmission service platform A through the IPC communication mechanism, the notification message sent only carries the notification content (such as a notification message indicating that data should be read), and does not carry the business data content. This reduces the size of the data sent in a single transmission and avoids problems such as communication exceeding memory limits or crashes.

[0125] S22. The transport dynamic library A reads business data from shared memory.

[0126] S23. Transmission dynamic library A sends service data to transmission dynamic library B of electronic device B.

[0127] Specifically, transport dynamic library A can locate the address of shared memory based on the stored shared memory identifier A, and read the service data from the shared memory. Then, transport dynamic library A can send the service data to the kernel-level communication driver A, which in turn sends the service data to the communication driver B of electronic device B via the network. Communication driver B then sends the service data back to transport dynamic library B.

[0128] In some implementations, if multiple services are running concurrently and all services need to transmit business data, since different business processes correspond to different shared memory, such as the identifier of a business process or the identifier of a business service being associated with a shared memory file descriptor (fd), the transmission dynamic library A can find the corresponding shared memory file descriptor based on the identifier of each business process or the identifier of the business service, and then find the corresponding shared memory to read the corresponding business data, thus avoiding the risk of business data being used interchangeably.

[0129] In some implementations, the process of business process A writing business data to shared memory in S19 and the process of transport dynamic library A reading business data from shared memory in S22 can be serialized, i.e., a write is followed by a read, and a write is followed by a read. For example, Figure 6 As shown, for shared memory (assuming a size of 10MB), each write operation starts from the beginning (assuming 1MB of data is written), and each read operation also starts from the beginning. After each read, the read business data can be deleted, and the process is repeated cyclically. This prevents problems such as data being overwritten or data loss when data is not accessed.

[0130] In other implementations, to further ensure the accuracy of the read data and prevent the reading of erroneous business data during serialized writing and reading from shared memory, embodiments of this application can also perform security checks on the business data in shared memory. For example, Figure 7 As shown, for business data written to shared memory, a data format of message length + message content is adopted. The message length refers to the length of the business data to be sent, for example, a message length that can occupy 4 bytes. The message content refers to the specific content of the business data to be sent by the business process. When a business process writes business data to shared memory, it first writes the message length, for example, 4 bytes, and then writes the business data to be sent at a 4-byte offset. After the business process writes the business data to shared memory, when business process A in S20 notifies the transmission service platform A of the business data to be sent via the IPC communication mechanism, the notification message can carry the message length but does not carry the business data.

[0131] Next, when transport dynamic library A in S22 reads business data from shared memory, it first reads the message length (length'), for example, a message length of 4 bytes. If length' equals length, it means the message verification was successful, and transport dynamic library A can read the business data from a position offset 4 bytes after the message length in shared memory. If length' does not equal length, it means the message verification failed, and transport dynamic library A will no longer read the business data, i.e., the data transmission failed. This improves the accuracy of data transmission.

[0132] S24. The transport dynamic library B writes the business data into the shared memory.

[0133] After receiving the service data, the transport dynamic library B can find the address of the shared memory based on the saved shared memory identifier B, and write the service data into the shared memory.

[0134] S25. The transmission dynamic library B notifies the transmission service platform B of the business data that is currently waiting to be received.

[0135] S26. The transmission service platform B notifies the service process B of the service data that is currently waiting to be received through the IPC communication mechanism.

[0136] After the transport dynamic library B writes the service data into shared memory, it can notify the transport service platform B that there is currently service data to be received, and then notify the service process B to receive the service data. It should be noted that when the transport service platform B notifies the service process B through the IPC communication mechanism, the notification message sent only carries the notification content and does not carry the service data content. This reduces the size of the data sent in a single instance and avoids problems such as communication exceeding memory limits or crashes.

[0137] S27. Business process B reads business data from shared memory and performs corresponding data processing.

[0138] The business process B in electronic device B can read and process business data from shared memory, such as decoding and displaying screen projection data. Specifically, business process B can locate the address of the shared memory using the shared memory identifier B' obtained through the above conversion, and then read the business data from the shared memory.

[0139] As you can understand, the above describes the data transmission process using a single business process as an example. In the case of multiple concurrent services, multiple services can create multiple shared memory instances, with each service corresponding to one shared memory instance. When each service needs to send business data, it can write the business data into its corresponding shared memory instance, and then the transmission process can read the business data from the corresponding shared memory instance and send it to the peer electronic device. Thus, in the scenario of multiple concurrent services, reading and writing data through shared memory eliminates the need to send business data through the IPC communication mechanism; only notification messages need to be sent, which can overcome the data limitation bottleneck of the IPC communication mechanism.

[0140] In the aforementioned data transmission method, electronic devices create shared memory when business data traffic is high, so that each business process corresponds to a shared memory. After a business process writes business data into the shared memory, it can notify the transmission process to read the business data from the shared memory in order to send the business data to other electronic devices. When a business process notifies the transmission process to read business data through the IPC communication mechanism, only a notification message needs to be sent, and there is no need to send the business data again. This reduces the size of the data sent in a single transaction, solves the limitation on the size of data transmitted during IPC communication in multi-service concurrent scenarios, avoids problems such as communication exceeding memory or crashes, and improves the number of concurrent data transmissions.

[0141] The above embodiments describe a scenario where shared memory is created when business data traffic is high. If the transmission service platform A in S3 determines that shared memory does not need to be created, then shared memory can be left uncreated. The data transmission process in this scenario can be shown in the following embodiments. Figure 8 This is a timing flowchart illustrating another data transmission method provided in an embodiment of this application, which may specifically include:

[0142] S31. Business application A receives the user's first operation and starts business process A.

[0143] S32. Business process A instructs the transmission service middleware A to start the business transmission service.

[0144] The process of S31-S32 can be referred to as S1-S2 above, and will not be repeated here.

[0145] S33. The transmission service platform A determines whether it is necessary to create shared memory. If it is not necessary to create shared memory, then execute S34. If it is necessary to create shared memory, then execute S4 in the above embodiment.

[0146] In this system, the transmission service platform A can determine whether shared memory needs to be created based on the service type and / or service priority. If the decision is based on service type, then shared memory is not needed if it's not a file transfer or screen mirroring service, as these types typically involve larger amounts of data, while other service types involve smaller amounts. In other words, if the transmission service platform A determines that the current service requires relatively little transmission traffic based on service type and / or service priority, then it decides that shared memory does not need to be created. In some implementations, the decision to create shared memory can also be specified by the application itself.

[0147] S34. The transmission service platform A initializes the business transmission service.

[0148] S35. Transmission service platform A sends a notification message to transmission dynamic library A to start the client.

[0149] The notification message can carry the identifier of the service transmission service to notify the transmission dynamic library A to launch the client of the corresponding service.

[0150] S36, Transfer dynamic library A starts the client.

[0151] S37. The transmission dynamic library A returns a success message to the transmission service middleware A, indicating that the client has been successfully launched.

[0152] After receiving the notification message sent by the transport service platform A, transport dynamic library A can start the client. Then, transport dynamic library A can also return a message to transport service platform A that the client has been successfully started.

[0153] S38. The transmission service platform A of electronic device A sends a request to the transmission service platform B of electronic device B to start the business transmission service.

[0154] In other words, after electronic device A starts the service, it will send a request to electronic device B, requesting electronic device B to also start the service transmission service and launch the corresponding server.

[0155] In some implementations, the request sent by transmission service platform A to transmission service platform B may carry the identifier of the business transmission service, the device identifier of electronic device A, and an identifier indicating whether shared memory is used. The identifier indicating whether shared memory is used can be represented by an int parameter, for example, 1 indicates that shared memory is used, and 0 indicates that shared memory is not used. When the identifier is 0, electronic device B will not create shared memory after receiving the request.

[0156] S39. The transmission service platform B determines whether it is necessary to create shared memory. If it is not necessary to create shared memory, then execute S40. If it is necessary to create shared memory, then execute S10 in the above embodiment.

[0157] That is, the transmission service platform B can determine whether shared memory needs to be created based on the identifier of whether shared memory is used in the above request.

[0158] S40. The transmission service platform B initializes the business transmission service.

[0159] S41. Transmission service platform B sends a notification message to transmission dynamic library B to start the server.

[0160] The notification message can carry the identifier of the service transmission service to notify the transmission dynamic library B to start the corresponding service server.

[0161] S42, The dynamic library B is used to start the server.

[0162] S43. The transmission dynamic library B returns a successful start message to the transmission service middleware B.

[0163] After receiving the notification message sent by the transmission service platform B, the transmission dynamic library B can start the server. Subsequently, the transmission dynamic library B can also return a message to the transmission service platform B that the server has been successfully started.

[0164] S44. Electronic device B's transmission service platform B sends a message to electronic device A's transmission service platform A indicating that the business transmission service has been successfully started.

[0165] In other words, after electronic device B starts the service transmission service, it will send a message to electronic device A indicating that the service has been successfully started, notifying electronic device A to proceed to the next step.

[0166] S45. Transmission Service Platform A notifies the business process that the A business transmission service has started successfully.

[0167] S46. The transmission service platform B notifies the business process that the B business transmission service has started successfully.

[0168] After the service transmission services of both electronic device A and electronic device B are successfully started, electronic device A can transmit data to electronic device B. The specific process is as follows:

[0169] S47. Business process A acquires business data.

[0170] In this process, business process A can obtain business data to be sent to electronic device B, such as screen casting data in the screen casting service.

[0171] S48. Business process A notifies the transmission service platform A of the business data that is currently waiting to be sent through the IPC communication mechanism.

[0172] S49. Transmission service platform A notifies transmission dynamic library A of business data that is currently waiting to be sent.

[0173] After business process A obtains the business data, it can notify the transmission service platform A of the business data to be sent, so that the transmission process can transmit the business data. It should be noted that when business process A notifies the transmission service platform A through the IPC communication mechanism, the notification message sent carries the content of the business data.

[0174] S50, Transmit dynamic library A reads the business data of the notification.

[0175] S51. Transmission dynamic library A sends service data to transmission dynamic library B of electronic device B.

[0176] In other words, when the transmission dynamic library A receives a notification message from the transmission service platform A, it can read the service data carried in the notification message and send it to the transmission dynamic library B of the electronic device B.

[0177] In some implementations, to ensure data accuracy when sending business data, the business process can use a data format of message length + message content. The message length refers to the length of the business data to be sent, for example, it can occupy 4 bytes. The message content refers to the specific content of the business data to be sent by the business process. In S48, when business process A notifies the transmission service platform A of business data to be sent via the IPC communication mechanism, the notification message can carry the message length and the business data. When the transmission dynamic library A reads the business data from the notification message, it can first read the message length. If length' equals length, the message verification is successful, and the transmission dynamic library A can transmit the business data; if length' does not equal length, the message verification fails, and the transmission dynamic library A will not transmit the business data.

[0178] S52, Transmission Dynamic Library B receives and parses service data.

[0179] S53, The transmission dynamic library B notifies the transmission service platform B of the business data that is currently waiting to be received.

[0180] S54. The transmission service platform B notifies the service process B of the service data that is currently waiting to be received through the IPC communication mechanism.

[0181] After receiving the business data, the transmission dynamic library B hands it over to the transmission service middleware B for transmission to the business process B through the IPC communication mechanism. At this time, the notification message sent also carries the business data.

[0182] S55. Business process B performs corresponding data processing on the business data in the notification.

[0183] The business process B in electronic device B can process the business data in the notification message, such as decoding and displaying the screen projection business data.

[0184] In the above data transmission method, when the electronic device transmits data, it can determine the size of the business data traffic. When the business data traffic is large, it creates shared memory, and when the business data traffic is small, it does not create shared memory, thereby improving the adaptability of the data transmission process.

[0185] Regarding the data transmission method provided in the above embodiments, we also conducted performance comparison experiments in two scenarios: creating shared memory and not creating shared memory. Figure 9 As shown in the figure, the horizontal axis represents the amount of data transferred by the business process each time. In the scenario of creating shared memory, it represents the amount of data written to shared memory by the business process each time; in the scenario of not creating shared memory, it represents the amount of data transferred to the transmission process each time. The vertical axis represents the transmission rate, in MB / s. Curve 1 is the performance curve when creating shared memory, and curve 2 is the performance curve when not creating shared memory. It can be seen that when creating shared memory, even if the amount of data transferred by the business process each time is large (e.g., greater than 1MB), a high transmission rate can still be maintained. When not creating shared memory, when the amount of data transferred by the business process is large, the transmission rate is close to 0, which means that memory overload or memory crash may have occurred. Therefore, through performance experiment comparison, it can be seen that the data transmission performance is significantly higher when creating shared memory.

[0186] The foregoing has detailed examples of the data transmission methods provided in the embodiments of this application. It is understood that, in order to achieve the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, based on the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of this application.

[0187] This application embodiment can divide the electronic device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, such as a detection unit, a processing unit, a display unit, etc., or two or more functions can be integrated into one module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.

[0188] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0189] The electronic device provided in this embodiment is used to execute the above-described data transmission method, and therefore can achieve the same effect as the above-described implementation method.

[0190] When using integrated units, the electronic device may further include a processing module, a storage module, and a communication module. The processing module is used to control and manage the operation of the electronic device. The storage module supports the execution of stored program code and data. The communication module supports communication between the electronic device and other devices.

[0191] The processing module can be a processor or a controller. It can implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a digital signal processor (DSP), and a microprocessor, etc. The storage module can be a memory. The communication module can specifically be a radio frequency circuit, a Bluetooth chip, a Wi-Fi chip, or other devices that interact with other electronic devices.

[0192] In one embodiment, when the processing module is a processor and the storage module is a memory, the electronic device involved in this embodiment can be a device having... Figure 2 The device with the structure shown.

[0193] This application also provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor performs the data transmission method of any of the above embodiments. The storage medium may include various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0194] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the data transmission method described in the above embodiments.

[0195] In addition, embodiments of this application also provide an apparatus, which may specifically be a chip, component, or module. The apparatus may include a connected processor and a memory. The memory is used to store computer execution instructions. When the apparatus is running, the processor can execute the computer execution instructions stored in the memory to cause the chip to execute the data transmission methods in the above-described method embodiments.

[0196] In this embodiment, the electronic device, computer-readable storage medium, computer program product or chip are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects of the corresponding methods provided above, and will not be repeated here.

[0197] Through the above description of the embodiments, those skilled in the art will understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0198] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0199] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A data transmission method, the method being applied on a first electronic device, characterized in that, The first electronic device and a second electronic device are in communication connection, and the method comprises: When a plurality of service processes in the first electronic device have service data to be sent to the second electronic device, determining whether shared memory needs to be created according to service information corresponding to a first service process through a first transmission process, wherein the service information comprises a service type and / or a service priority; In the case of determining that shared memory needs to be created, creating a first shared memory corresponding to the first service process, and writing the service data to be sent into the first shared memory through the first service process, wherein the service processes of different service applications correspond to different shared memories, and the first service process is any one of the plurality of service processes; Sending a first notification message to the first transmission process in the first electronic device based on an inter-process communication (IPC) communication mechanism through the first service process, wherein the first notification message is used to instruct the first transmission process to read the service data to be sent from the first shared memory, and the first notification message does not carry the service data to be sent; Reading the service data to be sent from the first shared memory through the first transmission process, and sending the service data to be sent to the second electronic device; In the case of determining that shared memory does not need to be created, the first service process notifies the first transmission process that there is service data to be sent through the IPC communication mechanism, and the notification message sent carries the service data to be sent; Sending the service data to be sent to the second electronic device through the first transmission process.

2. The method of claim 1, wherein, The method further comprises: In the case of determining that shared memory needs to be created, the method further comprises: The first electronic device sends a request message to the second electronic device to request the second electronic device to create a corresponding second shared memory, and the request message carries an identifier of whether shared memory is created.

3. The method of claim 1, wherein, The method further comprises: The first service process writes the service data to be sent and a message length corresponding to the service data to be sent into the first shared memory.

4. The method according to any one of claims 1 to 3, characterized in that, The first notification message carries a message length corresponding to the service data to be sent. The method further comprises:

5. The method of claim 4, wherein, The first transmission process reads a first message length from the first shared memory, and if the read first message length is equal to a message length corresponding to the service data to be sent carried in the first notification message, the first transmission process reads the service data to be sent from the first shared memory.

6. The method of claim 5, wherein, ​ ​ 7. The method according to any one of claims 1 to 3, characterized in that, The writing, by the first service process, of the to-be-sent service data into the first shared memory comprises: The writing, by the first service process, of the to-be-sent service data into the first shared memory from a start position of the first shared memory; The reading, by the first transmission process, of the to-be-sent service data from the first shared memory comprises: The reading, by the first transmission process, of the to-be-sent service data from a start position of the first shared memory.

8. The method of claim 1, wherein, The first electronic device comprises a transmission service middle station and a transmission dynamic library, and the sending, by the first service process, of a first notification message to a first transmission process in the first electronic device based on an IPC communication mechanism comprises: The sending, by the first service process, of the first notification message to the transmission service middle station based on an IPC communication mechanism, the transmission service middle station notifying the transmission dynamic library to read the to-be-sent service data from the first shared memory, wherein the first transmission process is a process pulled up when the transmission service middle station is started.

9. The method of claim 8, wherein, Before the writing, by the first service process, of the to-be-sent service data into the first shared memory, the method further comprises: The first service process instructing the transmission service middle station to start a service transmission service; The transmission service middle station determining whether shared memory needs to be created, and creating the first shared memory corresponding to the first service process in a case where it is determined that shared memory needs to be created; The transmission service middle station notifying the transmission dynamic library to pull up a client, the transmission dynamic library saving an identifier of the first shared memory when the transmission dynamic library pulls up the client.

10. A data transmission method, the method being applied to a second electronic device, characterized in that, There is a communication connection between the first electronic device and the second electronic device, and the method comprises: A second transmission process in the second electronic device receiving a request message from the first electronic device, and determining whether shared memory needs to be created according to the request message, the request message carrying an identifier of whether shared memory needs to be created; In a case where it is determined that shared memory needs to be created, creating a second shared memory; The second transmission process receiving service data from the first electronic device, and writing the service data into the second shared memory; The second transmission process sending a second notification message to a second service process in the second electronic device based on an IPC communication mechanism, the second notification message being used to instruct the second service process to read the service data from the second shared memory, the second notification message not carrying the service data; The second service process reading the service data from the second shared memory, and processing the service data; In a case where it is determined that shared memory does not need to be created, the second transmission process notifying the second service process that there is to-be-received service data currently by using the IPC communication mechanism, the notification message sent carrying the service data; The second service process processing the service data.

11. An electronic device, comprising: Comprise: One or more processors; One or more memories; The memory stores one or more programs, which, when executed by the processor, cause the electronic device to perform the method of any one of claims 1-9, or perform the method of any one of claims 10.

12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, which, when executed by a processor, causes the processor to perform the method of any one of claims 1-9, or perform the method of any one of claims 10.

Citation Information

Patent Citations

  • Inter-process communication method and inter-process communication device

    CN113760560A

  • Data transmission method and equipment

    CN113950033A