Data transmission method and device and storage medium
By using the cache manager in the called terminal to write data to the local cache file first and then to the distributed file system, the problem of application unresponsiveness during cross-device application calls is solved, and the stability and user experience of data writeback are improved.
Patent Information
- Application Number
- CN202311386446.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-23
- Publication Date
- 2025-05-02
AI Technical Summary
During cross-device application call, the application of the called terminal is prone to the application's unresponsiveness (ANR) when writing back data to the calling terminal, which affects the user's user experience.
By introducing a cache management program in the called terminal, the target data is first written to the local target cache file, and then when it is detected that the set read conditions are met, the data is written to the distributed file system to ensure the stability of the data write back process.
It effectively reduces the probability that the target application in the called terminal will not respond during the data writing back process, and improves the user experience.
Smart Images

Figure CN119917338A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data transmission method, device and storage medium. Background Art
[0002] As the types of electronic devices increase, different types of electronic devices are configured with different functions to meet the needs of different scenarios. For example, mobile phones are small and easy to carry, suitable for outdoor scenes, so they can be configured with high-performance shooting components so that users can use their mobile phones to take pictures at any time; while tablet computers are large and suitable for indoor scenes, and their shooting performance is often lower than that of mobile phones.
[0003] In the related art, in order to improve the user experience, cross-device application calls can be made between applications of different electronic devices. Assuming that there is a tablet computer and a mobile phone that can make cross-device application calls, taking cross-device photo taking as an example, the memo application in the tablet computer can call the camera application in the mobile phone, so that the camera application takes photos, and writes the photos back to the memo application in the tablet computer after the photos are taken. Therefore, even if the tablet computer has low shooting performance, high-quality photos can be obtained by calling the camera application in the mobile phone.
[0004] However, in the above cross-device application calling process, when the application of the called terminal writes data back to the application of the calling terminal, the called terminal application often fails to respond (Application Not Responding, ANR for short), affecting the user experience. Summary of the invention
[0005] Multiple aspects of the present application provide a data transmission method, device, and storage medium to reduce the probability of an application program of a called terminal becoming unresponsive.
[0006] In a first aspect, an embodiment of the present application provides a data transmission method, applied to a called terminal, comprising:
[0007] In response to a calling request of a calling terminal to a target application in the called terminal, acquiring target data generated by the target application;
[0008] Writing the target data into a local target cache file through the target application;
[0009] If it is detected that the set reading condition is met, the target data in the target cache file is written into the distributed file system corresponding to the called terminal through the cache management program running in the called terminal, so that the calling terminal reads the target data from the distributed file system.
[0010] In a second aspect, an embodiment of the present application further provides an electronic device, comprising: a memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the data transmission method described in the first aspect is implemented.
[0011] In a third aspect, an embodiment of the present application further provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the data transmission method described in the first aspect.
[0012] In the data transmission method provided by the present application, both the called terminal and the calling terminal are electronic devices capable of calling applications across devices. In the process of calling applications across devices, the called terminal responds to the calling terminal's call request for the target application in the called terminal, and obtains the corresponding target data through the target application. For example, if the target application is a camera application, then in response to the call request, the camera application collects image data as the target data. After that, the called terminal writes the target data back to the calling terminal. In the specific write-back process, the called terminal first writes the target data to the local target cache file through the target application, and then, when it is detected that the set reading conditions are met (for example, the network quality is good), the cache management program running in the called terminal writes the target data in the target cache file to the distributed file system corresponding to the called terminal, thereby completing the write-back of the target data. Finally, the calling terminal can read the target data from the distributed file system.
[0013] In this solution, since the target application directly writes the target data into the local target cache file, the writing process of the target application will not be affected by the external network environment, nor will the writing fail due to a poor network environment, which will cause the target application to become unresponsive. In addition, in the process of writing the target data in the target cache file to the distributed file system corresponding to the called terminal, since the writing process is executed by the cache management program, whether the writing is completed or not will not affect the target application, nor will it cause the target application to become unresponsive. Therefore, this solution can effectively reduce the probability of the target application in the called terminal becoming unresponsive during the process of writing the target data back to the calling terminal. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0015] Figure 1a A scenario diagram 1 of a cross-device application call provided in an embodiment of the present application;
[0016] Figure 1b A scenario for calling a cross-device application program provided in an embodiment of the present application Figure 2 ;
[0017] Figure 1c A scenario for calling a cross-device application program provided in an embodiment of the present application Figure 3 ;
[0018] Figure 2 An interactive schematic diagram of a cross-device application call provided in an embodiment of the present application;
[0019] Figure 3 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0020] Figure 4 A software structure diagram provided for an embodiment of the present application;
[0021] Figure 5 An interactive flow chart of a data transmission method provided in an embodiment of the present application;
[0022] Figure 6 A flowchart of a target application writing back target data provided by an embodiment of the present application;
[0023] Figure 7 A schematic diagram of a scenario of multi-device cross-device application calling provided in an embodiment of the present application;
[0024] Figure 8 A flowchart of a cache management program writing back target data provided by an embodiment of the present application;
[0025] Fig. 9 A schematic diagram of interaction between software modules provided in an embodiment of the present application;
[0026] Fig.10 A flowchart of interaction between software modules provided in an embodiment of the present application;
[0027] Fig.11 An interactive flow chart of another data transmission method provided in an embodiment of the present application;
[0028] Fig.12 A schematic diagram of data sharding writing provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.
[0030] It should be noted that the descriptions such as "first" and "second" in the embodiments of the present application are used to distinguish different icons, contents, modules, applications, etc., and do not represent the order of precedence. Unless otherwise specified, the two are different. For example, the first application is different from the second application.
[0031] With the development of technology, different electronic devices can establish short-range wireless connections through, for example, Near Field Communication (NFC) technology. Electronic devices with the ability to call applications across devices can call applications across devices based on short-range wireless connections.
[0032] For the sake of distinction, in the embodiment of the present application, the electronic devices involved in the cross-device application call are divided into: a calling terminal and a called terminal according to the application call relationship between the electronic devices. The calling terminal is the electronic device that initiates the cross-device application call. Through the cross-device application call, the calling terminal can use the capabilities of the application in the called terminal.
[0033] During the specific implementation process, a certain application in the calling terminal can be used to call the corresponding target application in the called terminal, so that the target application performs the corresponding operation to obtain the target data, and writes the target data back to the application in the calling terminal. Among them, these applications can be embedded applications installed in electronic devices (i.e., system applications of electronic devices) or downloadable applications. Among them, embedded applications are applications provided as part of the implementation of electronic devices (such as mobile phones). A downloadable application is an application that can provide its own Internet Protocol Multimedia Subsystem (IMS) connection. The downloadable application can be an application pre-installed in the terminal or a third-party application that can be downloaded and installed in the terminal by the user.
[0034] The following combination Figure 1a to Figure 1cFrom the perspective of interface interaction between a user and an electronic device, an exemplary description is given of a cross-device application calling process between electronic devices.
[0035] Among them, Figure 1a to Figure 1c In the illustrated scenario, it is assumed that the calling terminal is Zhang San's tablet computer, on which the application "Memo" is installed; the called terminal is Zhang San's mobile phone, on which the application "Camera" is installed. The example of a user operating the memo in Zhang San's tablet computer to call the camera in Zhang San's mobile phone is used for explanation.
[0036] Figure 1a A cross-device application calling scenario diagram 1 is provided in the embodiment of the present application. Figure 1a As shown, Zhang San's tablet computer displays a memo program interface, which includes a toolbar 101 and an editable area.
[0037] The toolbar 101 includes a plurality of function control keys, such as a "start" control key, a "file" control key, an "insert" control key, etc. Each function control key has a corresponding secondary control key, for example, the "insert" control key has a corresponding secondary control key such as "blank page", "table" and "picture". The user can edit the content in the editable area by selecting these control keys.
[0038] For example, if a user wants to insert a picture while editing a travel check-in record in a memo, the user can first click the "Insert" control key to display the corresponding secondary control key; then click the "Picture" control key 102 in the secondary control key; in response to the user's click operation on the "Picture" control key 102, a window 103 is displayed on the program interface of the memo, and the window 103 is used to provide a method for obtaining the picture to be inserted, for example: it can be obtained from the gallery of Zhang San's tablet computer, that is, the local gallery, or it can be obtained through the camera of Zhang San's mobile phone. Among them, obtaining through the camera of Zhang San's mobile phone means calling the camera in Zhang San's mobile phone across devices to obtain the picture to be inserted.
[0039] In response to the user selecting the method of inserting the picture as "Zhang San's mobile phone camera", Zhang San's tablet sends a cross-device camera call request to Zhang San's mobile phone. In response to the call request, Zhang San's mobile phone starts the camera and displays the camera program interface, such as Figure 1b As shown, Figure 1b A scenario for calling a cross-device application program provided in an embodiment of the present application Figure 2 The user uses the camera in Zhang San's mobile phone to take a picture to be inserted, and then Zhang San's mobile phone writes the picture to be inserted back to Zhang San's tablet computer. After Zhang San's tablet computer obtains the picture to be inserted, it displays the picture to be inserted on the program interface of the memo, such as Figure 1cAs shown in Figure 104, Figure 1c A scenario for calling a cross-device application program provided in an embodiment of the present application Figure 3 At this point, the memo in Zhang San's tablet computer has completed a call to the camera in Zhang San's mobile phone.
[0040] It is understandable that, through cross-device application calls, even if Zhang San's tablet computer has low shooting performance, high-quality photos can be obtained by calling the camera in Zhang San's mobile phone. That is, Zhang San's tablet computer can use the camera capability of the camera in Zhang San's mobile phone through cross-device application calls, thereby improving the user experience.
[0041] However, in actual applications, when the target application in the called terminal writes back the target data to the calling terminal, it is often prone to write-back data timeout and target application no response (Application Not Responding, ANR) and other problems, affecting the user experience. For example, when the camera in Zhang San's mobile phone writes back the acquired picture to be inserted to Zhang San's tablet computer, the camera is prone to camera ANR due to write-back data timeout.
[0042] The following combination Figure 2 From the perspective of information interaction between the calling terminal and the called terminal, the reason why the ANR occurs when the called target application in the called terminal writes back the target data to the calling terminal during the cross-device application calling process is explained.
[0043] Figure 2 The following is a schematic diagram of an interactive cross-device application program call provided in an embodiment of the present application. Figure 2 As shown, still taking the case where the application initiating the cross-device application call is a memo and the called target application is a camera as an example, correspondingly, the target data written back is the image data collected by the camera.
[0044] like Figure 2 As shown, both the calling terminal and the called terminal include: an application (i.e., a memo or a camera), a distributed application framework, and a cross-device interaction module. The interaction between the application and the cross-device interaction module in any terminal is realized via the distributed application framework; the cross-device interaction module is used to realize information interaction between the calling terminal and the called terminal, i.e., cross-device information interaction. For ease of distinction, the distributed application frameworks in the calling terminal and the called terminal are referred to as distributed application framework 1 and distributed application framework 2, respectively, and the cross-device interaction modules are referred to as cross-device interaction module 1 and cross-device interaction module 2, respectively.
[0045] To elaborate, in the process of the memo in the calling terminal calling the camera in the called terminal, first, on the calling terminal side, the memo sends the cross-device application call request to the cross-device interaction module 1 via the distributed framework software development kit (SDK) via the distributed application framework 1. The cross-device interaction module 1 sends the cross-device application call request to the cross-device interaction module 2 of the called terminal through the network connection between the calling terminal and the called terminal. The cross-device interaction module 2 sends the cross-device application call request to the distributed application framework 2, and the distributed application framework 2 pulls up the component response and passes it to the camera through the distributed framework SDK to open the camera's application interface, so that the user can take pictures through the camera and obtain image data.
[0046] When the camera of the called terminal finishes taking a photo, on the one hand, the camera will write back the data. Specifically, the camera writes the image data into the distributed file system corresponding to the cross-device interaction module 2 of the called terminal, that is, writes the image data into a file in the distributed system. Among them, the file location corresponding to the file written with the image data in the distributed file system is a file location on the calling terminal.
[0047] On the other hand, the camera will send the cross-device application call result to the cross-device interaction module 2 through the distributed application framework via the distributed framework SDK. The cross-device interaction module 2 sends the cross-device application call result to the cross-device interaction module 1 of the calling terminal through the network connection between the calling terminal and the called terminal. The cross-device interaction module 1 sends the cross-device application call result to the distributed application framework 1. The distributed application framework 1 feeds back the cross-device application call result to the memo through the distributed framework SDK, so that the memo reads the data, that is, reads the image data written back by the camera in the called terminal in the distributed file system.
[0048] Since the file location corresponding to the file written into the image data in the distributed file system is a file location on the calling terminal, in the process of writing the image data into the distributed system, the image data needs to be transmitted across devices through the network. When the network environment is not good, the camera will write back data timeout and ANR will occur. In addition, it can be understood that when transmitting image data across devices, data is actually transmitted through cross-device interaction module 1 and cross-device interaction module 2. Since the information interaction capability of the cross-device interaction module in any terminal is limited, when the current information interaction capability of the cross-device interaction module has been fully occupied (that is, the current number of concurrent processes of the cross-device interaction module has reached the upper limit), even if the network status is good, the camera will not be able to write the image data back to the distributed file system within the preset time due to process blocking. At this time, the camera will also cause ANR due to timeout of writing back data.
[0049] In order to reduce the probability of ANR occurring when the application of the called terminal writes back the target data, an embodiment of the present application provides a data transmission method. The execution subject of the data transmission method provided by the present application is an electronic device that performs cross-device application calls, and the electronic device can be used as both a calling terminal and a called terminal. The electronic device includes but is not limited to mobile phones, tablet computers, laptops, wearable devices, etc.
[0050] Figure 3 This is a schematic diagram of the structure of an electronic device provided by an embodiment of the present application. The present application takes the electronic device 100 as a mobile phone as an example to introduce the electronic device 100 provided by the present application.
[0051] like Figure 3As shown, 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, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (Subscriber Identification Module, SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light 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.
[0052] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0053] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), and / or a baseband processor, etc. Different processing units may be independent devices or integrated into one or more processors. The controller may generate an operation control signal according to an instruction opcode and a timing signal to complete the control of fetching and executing instructions.
[0054] The processor 110 may also be provided with a memory for storing instructions and data.
[0055] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an Inter-integrated Circuit (I2C) interface, an Inter-integrated Circuit Sound (I2S) interface, a pulse code modulation (PCM) interface, a Universal Asynchronous Receiver / Transmitter (UART) interface, a Mobile Industry Processor Interface (MIPI), a General-purpose Input / Output (GPIO) interface, a Subscriber Identity Module (SIM) interface, and / or a Universal Serial Bus (USB) interface, etc.
[0056] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces.
[0057] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to achieve communication between the processor 110 and the audio module 170.
[0058] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface.
[0059] The UART interface is a universal serial data bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is generally used to connect the processor 110 and the wireless communication module 160.
[0060] The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. In some embodiments, the processor 110 and the camera 193 communicate via the MIPI interface to implement the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate via the MIPI interface to implement the display function of the electronic device 100.
[0061] The GPIO interface can be configured by software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 with the camera 193, the display 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0062] The USB interface 130 is an interface that complies with USB standard specifications. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and peripheral devices.
[0063] It should be understood that the interface connection relationship between the modules illustrated in the embodiment of the present application is merely a schematic illustration and does not constitute a structural limitation on the electronic device 100 .
[0064] The charging management module 140 is used to receive charging input from a wireless charger or a wired charger. While the charging management module 140 is charging the battery 142 , it can also power the electronic device through the power management module 141 .
[0065] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0066] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of the antennas.
[0067] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the electronic device 100 .
[0068] The wireless communication module 160 can provide wireless communication solutions including wireless local area network (WLAN), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) and the like applied to the electronic device 100. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify the signal, and convert it into electromagnetic waves for radiation through the antenna 2.
[0069] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Time-Division Code Division Multiple Access (TD-SCDMA), etc.
[0070] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor, etc. The GPU is a graphics processor, which connects the display screen 194 and the application processor.
[0071] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0072] The electronic device 100 can realize the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194 and the application processor, etc. The ISP is used to process the data fed back by the camera 193.
[0073] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0074] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement a data storage function.
[0075] The internal memory 121 may be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121 and / or the instructions stored in the memory provided in the processor.
[0076] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0077] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals.
[0078] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0079] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0080] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. The electronic device 100 may be provided with at least one microphone 170C. In other embodiments, the electronic device 100 may be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 may also be provided with three, four or more microphones 170C to realize collection of sound signals, noise reduction, identification of sound sources, realization of directional recording function, etc.
[0081] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130, or a 3.5 mm Open Mobile Terminal Platform (OMTP) standard interface, or a Cellular Telecommunications Industry Association of the USA (CTIA) standard interface.
[0082] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 194 .
[0083] The gyro sensor 180B may be used to determine the motion posture of the electronic device 100 .
[0084] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
[0085] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D.
[0086] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes), and can also be used to identify the posture of the electronic device, and is applied to applications such as horizontal and vertical screen switching, pedometers, etc.
[0087] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
[0088] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector. The electronic device 100 uses a photodiode to detect infrared reflected light from a nearby object. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100, otherwise there is no object near the electronic device 100.
[0089] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touch.
[0090] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.
[0091] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. In some embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 or boosts the output voltage of the battery 142 to prevent the electronic device 100 from shutting down abnormally due to low temperature.
[0092] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen". The touch sensor 180K is used to detect touch operations acting on or near it. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0093] The bone conduction sensor 180M can obtain a vibration signal. In some embodiments, the bone conduction sensor 180M can also contact the human pulse to receive a blood pressure pulse signal. The button 190 includes a power button, a volume button, etc. The button 190 can be a mechanical button. It can also be a touch button. The electronic device 100 can receive a button input and generate a key signal input related to the user settings and function control of the electronic device 100.
[0094] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. Indicator 192 can be an indicator light, which can be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0095] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting or removing the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1.
[0096] The data transmission methods in the following embodiments can all be implemented in the electronic device 100 having the above hardware structure.
[0097] After introducing the hardware structure of the electronic device 100, the software system architecture of the electronic device 100 is described. Optionally, the software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software structure of the electronic device 100.
[0098] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through interfaces. In some embodiments, the Android system may include an application layer, an application framework layer, an Android runtime (Android runtime) and a system library, as well as a kernel layer. It should be noted that the embodiments of the present application are illustrated by taking the Android system as an example. In other operating systems (such as Hongmeng system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the solutions of the present application can also be implemented.
[0099] Figure 4 A software structure block diagram provided for an embodiment of the present application.
[0100] like Figure 4 As shown, the application layer can include a series of application packages, such as: camera, memo, gallery, calendar, call, map, navigation, music, video, short message, lock screen application, setting application and other applications.
[0101] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 4As shown, the application framework layer may include: a distributed application framework, a cross-device interaction module, etc. Among them, the distributed application framework may include a session management module and a cache management module. The application can be accessed through the distributed application framework SDK ( Figure 4 (not shown) interacts with the distributed application framework.
[0102] In the process of calling an application across devices to write back the target data, the session management module is used to obtain the session identifier corresponding to the calling terminal and the called terminal and the data storage address provided by the calling terminal, and feed it back to the cache management module, so that the cache management module creates a local target cache file in the local cache file directory of the called terminal, so that the called target application in the called terminal can write the acquired target data into the target cache file. The cache management module is also used to read the target data from the target cache file and write it to the distributed file system corresponding to the cross-device interaction module. Here, only a brief description of the functions of the session management module and the cache management module involved in the data transmission method provided in the embodiment of the present application is given, and then a detailed description will be given in conjunction with the specific embodiment.
[0103] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0104] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0105] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0106] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0107] A 2D graphics engine is a drawing engine for 2D drawings.
[0108] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library.
[0109] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0110] The Hardware Abstraction Layer (HAL) is a package of the Linux kernel driver, providing an interface to the upper layer and shielding the implementation details of the low-level hardware. The HAL layer may include Wi-Fi HAL, Bluetooth HAL, audio HAL, camera HAL, and data transmission control module.
[0111] The kernel layer is a layer between hardware and software. The kernel layer includes at least a display driver, a camera driver, an audio driver, and a sensor driver. The following is an example of the workflow of electronic device software and hardware in conjunction with capturing a photo scene. When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into an original input event (including touch coordinates, timestamp of the touch operation, and other information). The original input event is stored in the kernel layer. The application framework layer obtains the original input event from the kernel layer and identifies the control corresponding to the input event. Taking the touch operation as a touch single-click operation, and the control corresponding to the single-click operation is the control of the camera application icon as an example, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer to capture a static image or video through the camera 193.
[0112] The data transmission method provided by the present application is described below in conjunction with specific embodiments. It should be noted that the data transmission methods in the following embodiments can all be implemented in an electronic device having the above hardware structure and the above system architecture.
[0113] Figure 5 An interactive flow chart of a data transmission method provided in an embodiment of the present application, such as Figure 5 As shown, the data transmission method at least includes the following steps:
[0114] 501. The calling terminal sends a calling request to the called terminal for calling a target application in the called terminal.
[0115] 502. The called terminal obtains target data generated by the target application in response to the calling request.
[0116] 503. The called terminal writes the target data into a local target cache file through the target application.
[0117] 504. If the called terminal detects that the set reading condition is met, the cache management program running in the called terminal writes the target data in the target cache file into the distributed file system corresponding to the called terminal.
[0118] 505. The calling terminal reads target data from the distributed file system.
[0119] The target application refers to the application in the called terminal that is called by the calling terminal, including but not limited to the camera application in the above example. The target data refers to the data generated by the target application in response to the calling request of the calling terminal, such as the image data generated by the camera in response to the calling request. The distributed file system corresponding to the called terminal is also called Figure 2 In the illustrated cross-device application calling process, the distributed file system corresponding to the cross-device interaction module of the called terminal.
[0120] like Figure 2 As shown, the calling terminal can initiate a call request to the target application through the application installed thereon (ie, a cross-device call request). In actual applications, the application used to initiate the call request on the calling terminal includes but is not limited to a memo.
[0121] After receiving the call request, the called terminal opens the target application. Optionally, the target application can be controlled to generate target data by manually intervening in an interface interaction with the target application, such as manually operating a camera application to take a photo and obtain image data. Optionally, the target application can also be directly controlled to generate target data through corresponding control instructions. This embodiment does not limit the way in which the target application generates target data.
[0122] After acquiring the target data generated by the target application, the called terminal needs to write the target data back to the calling terminal, that is, the target data needs to be written into the distributed file system corresponding to the called terminal.
[0123] In the embodiment of the present application, the target data write-back process is implemented by writing the target data twice. Specifically, first, the target data is written into the local target cache file of the called terminal by the target application; then, the target data in the target cache file is read by the cache management program running in the called terminal, and the target data is written into the distributed file system corresponding to the called terminal.
[0124] The process of writing the target data in the target cache file into the distributed file system through the cache management program can also be understood as the called terminal synchronizing the target data in the target cache file into the distributed file in the background.
[0125] Optionally, the synchronization condition of the target data in the target cache file can be preset, that is, the reading condition of the target data in the target cache file can be preset. When the called terminal detects that the set reading condition is met, the target data in the target cache file is read through the cache management program and written into the distributed file system corresponding to the called terminal. Optionally, the reading condition includes: the network quality meets the set condition, the called terminal has an idle process that can be used to transmit data across devices, etc.
[0126] To ensure that the calling terminal can read the target data from the distributed file system corresponding to the called terminal, the called terminal may optionally monitor the writing of the target data by the cache management program to the distributed file system. If a write result notification is received from the distributed file system through the cache management program, a call response message corresponding to the write result notification is sent to the calling terminal through the session management program, so that the calling terminal processes the call response message.
[0127] The write result notification fed back by the distributed file system includes at least one of the following: write success notification, write timeout notification, and write error notification. The write success notification is used to instruct the calling terminal to read the target data from the distributed file system; the write timeout notification and the write error notification are used to instruct the calling terminal not to read the target data from the distributed file system, because in the case of write timeout and write error, the target data may not exist in the distributed file system or there may be incomplete target data.
[0128] During the specific implementation process, if the calling terminal receives a call response message corresponding to a write success notification, the target data is read from the distributed file system; if the calling terminal receives a call response message corresponding to a write timeout notification or a write error notification, the target data is not read from the distributed file system, and the terminal continues to wait until it receives a call response message corresponding to a write success notification.
[0129] Optionally, if the calling terminal receives call response messages corresponding to write timeout notifications or write error notifications for multiple consecutive times, prompt information for prompting the user to re-call the cross-device application is output.
[0130] Optionally, if the write result notification fed back by the distributed file system received by the called terminal through the cache management program is a write timeout notification or a write error notification, the cache management program may be used to retry writing the target data in the target cache file into the distributed file system.
[0131] In the data transmission method provided in the embodiment of the present application, when the target application writes back the target data, the target data is written twice by the target application and the cache management program respectively. In the target data writing process executed by the target application, the target application directly writes the target data to the local target cache file. This writing process does not require cross-device information interaction with the calling terminal, and is not affected by the network environment, nor is it limited by the cross-device interaction capability between the called terminal and the calling terminal. Therefore, the target application can write the target data to the local target cache file within a preset time, and ANR will not occur due to a timeout in writing data. In the target data writing process executed by the cache management program, the execution subject of the write action is the cache management program. How long the cache management program can write the target data in the target cache file to the distributed file system has nothing to do with the target application, and the target application will not cause ANR because the cache management program takes too long to write the target data. In summary, this scheme can effectively reduce the probability of ANR occurring in the target application called in the called terminal during the process of writing back the target data to the calling terminal.
[0132] The following describes in detail the process in which the target application writes the target data into the local target cache file, and the process in which the cache management program writes the target data in the target cache file into the distributed file system.
[0133] To facilitate understanding, here is a brief description of the overall process of the program writing data to a file.
[0134] Take the example of program x writing data z to file y. First, program x calls the open function to open file y, obtains the file descriptor (FD) of file y, and then generates an output stream OutputStream based on file FD and feeds it back to program x. Then, program x writes data z to file y by calling the write function based on the output stream. Finally, after writing is completed, program x calls the close function to close file y. The specific implementation process can refer to the relevant technology, which will not be repeated in this embodiment.
[0135] Figure 6 A flowchart of a target application writing back target data provided by an embodiment of the present application. Figure 6 As shown, the above step "503, the called terminal writes the target data into the local target cache file through the target application" at least includes the following steps:
[0136] 601. The called terminal creates and opens a target cache file in a local cache file directory through a cache management program in response to a file opening instruction triggered by a target application.
[0137] 602. Generate a first output stream according to a first file descriptor corresponding to the target cache file.
[0138] 603. Feedback the first output stream to the target application, so that the target application writes the target data into the target cache file through the first output stream.
[0139] In this embodiment, after generating target data, the target application in the called terminal writes the target data into the local target cache file.
[0140] First, the called terminal responds to the file open instruction triggered by the target application calling the open function, and creates and opens the target cache file in the local cache file directory through the cache management program. Among them, the file descriptor corresponding to the target cache file is called the first file descriptor. Then, the called terminal generates a corresponding output stream (i.e., the first output stream) according to the first file descriptor and feeds it back to the target application. After that, the target application calls the write function to write the target data to the target cache file through the first output stream. Finally, the target application calls the close function to close the target cache file, completing the writing of the target data to the target cache file.
[0141] In actual application, multiple devices usually make cross-device application calls. Figure 7 A schematic diagram of a scenario of a multi-device cross-device application call provided in an embodiment of the present application, such as Figure 7 As shown, both tablet computer a and mobile phone b make cross-device application calls to mobile phone c, that is, mobile phone c is both the called terminal corresponding to tablet computer a and the called terminal corresponding to mobile phone b. In this scenario, the target data generated by the called target application in mobile phone c includes both target data related to the cross-device application call of tablet computer a and target data related to the cross-device application call of mobile phone b.
[0142] In order to ensure data isolation between target data corresponding to different devices and that the called terminal can correctly transmit the target data back to the corresponding calling terminal, optionally, in step 601, the called terminal creates and opens a target cache file in a local cache file directory through a cache management program, including:
[0143] First, the session identifier corresponding to the calling terminal and the called terminal and the data storage address provided by the calling terminal are obtained through the session management program running in the called terminal. Then, the session identifier and the data storage address are transmitted to the cache management program. Finally, the cache management program creates and opens the target cache file named with the session identifier and the data storage address in the local cache file directory.
[0144] It is understandable that when the calling terminal and the called terminal perform a cross-device application call, a corresponding session task will be established, and a corresponding session identifier such as Session ID will exist.
[0145] When the calling terminal sends a calling request to the called terminal, the calling request may include a data storage address provided by the calling terminal, and the data storage address indicates a file location in the calling terminal. Optionally, the data storage address may be identified by a Uniform Resource Identifier (URI).
[0146] Optionally, the session manager may associate the Session ID with the URI. Since the URI identifies a data storage address in the calling terminal, when the cache manager creates a target cache file in the local cache directory, it may name the target cache file with the Session ID and the URI.
[0147] For example, assuming that the session identifier corresponding to tablet a and mobile phone c is Session ac, and the data storage address provided by tablet a is identified by uri-a, after tablet a calls the camera in mobile phone c across devices to obtain image data 1 (i.e., target data), when the camera writes image data 1 to the local target cache file, the file name of the target cache file created by the cache manager in the local cache directory may be: Session ac-uri-a.jpeg. Similarly, if the session identifier corresponding to mobile phone b and mobile phone c is Session bc, and the data storage address provided by mobile phone b is identified by uri-b, after mobile phone b calls the camera in mobile phone c across devices to obtain image data 2 (i.e., target data), when the camera writes image data 2 to the local target cache file, the file name of the target cache file created by the cache manager in the local cache directory may be: Session bc-uri-b.jpe.
[0148] Furthermore, tablet computer a calls the camera in mobile phone c across devices to obtain image data 1, and writes the image data 1 into the target cache file Session ac-uri-a.jpeg through the camera; thereafter, the cache management program running in mobile phone c reads image data 1 from Session ac-uri-a.jpeg, and writes image data 1 into the distributed file system corresponding to mobile phone c, so that tablet computer a reads image data 1 from the distributed file system.
[0149] Similarly, mobile phone b calls the camera in mobile phone c across devices to obtain image data 2, and writes it into the target cache file Session bc-uri-b.jpe through the camera; thereafter, the cache management program running in mobile phone c reads image data 2 from Session bc-uri-b.jpe, and writes image data 2 into the distributed file system corresponding to mobile phone c, so that mobile phone b reads image data 2 from the distributed file system.
[0150] It should be noted that the above-mentioned naming of the target cache file with the session identifier and the data storage address is to distinguish the target cache files corresponding to different calling terminals. In actual applications, the target cache file can also be named in other ways, as long as the naming result can uniquely identify the calling terminal corresponding to the target cache file.
[0151] In this solution, on the one hand, the target application directly writes the target data to the local target cache file, without the need for cross-device information interaction with the calling terminal, and is not affected by the network environment, nor is it limited by the cross-device interaction capabilities between the called terminal and the calling terminal. The target application will not experience ANR due to a timeout in writing data. On the other hand, the cache manager names the target cache file with the session identifier and the data storage address, and can distinguish the calling terminals corresponding to different target cache files based on the file name of the target cache file, which can ensure both the correct writing of the target data and the correct reading of the target data in the target cache file by the cache manager.
[0152] Figure 8 A flowchart of a cache management program writing back target data provided by an embodiment of the present application. Figure 8 As shown, the above step "504, writing the target data in the target cache file into the distributed file system corresponding to the called terminal through the cache management program running in the called terminal" at least includes the following steps:
[0153] 801. The called terminal creates and opens a target storage file in a distributed file system through a cache management program.
[0154] 802. Generate a second output stream according to a second file descriptor corresponding to the target storage file.
[0155] 803. Based on the second output stream, write the target data in the target cache file into the target storage file through the cache management program.
[0156] In this embodiment, when the called terminal detects that the set reading condition is met, the target data is read from the local target cache file to write the target data into the target storage file in the distributed file system corresponding to the called terminal.
[0157] In the specific implementation process, first, the called terminal responds to the file open instruction triggered by the cache management program calling the open function, and creates and opens the target storage file in the distributed file system corresponding to the called terminal through the cache manager. Among them, the file descriptor corresponding to the target storage file is called the second file descriptor, and the second file descriptor points to a file location on the calling terminal. Optionally, the file location matches the data storage address provided by the calling terminal, such as the same file address, or a file address with a mapping relationship. Then, the cache management program generates a corresponding output stream (i.e., the second output stream) according to the second file descriptor. Afterwards, the cache management program calls the write function to write the target data read from the target cache file to the target storage file through the second output stream. Finally, the cache management program calls the close function to close the target storage file, completing the cache management program writing the target data to the target storage file.
[0158] In this solution, the process of the cache manager writing the target data in the target cache file into the distributed file system is independent of the target application, so the target application will not experience ANR due to the cache manager taking too long to write the target data.
[0159] In an optional embodiment, the cache management program and the session management program are both located in the distributed application framework of the called terminal. The distributed application framework is a software module in the application framework layer in the software structure corresponding to the electronic device. Figure 2 and Figure 4 .
[0160] In this embodiment, the module corresponding to the cache management program is called a cache management module, and the module corresponding to the session management program is called a session management module. The distributed application framework includes: a cache management module and a session management module. Fig. 9 and Fig.10 The software module interactions involved in the data transmission method provided in the embodiment of the present application are described. Fig. 9 A schematic diagram of interaction between software modules provided in an embodiment of the present application, Fig.10 A flowchart of the interaction between software modules provided in an embodiment of the present application.
[0161] Combination Fig. 9 and Fig.10When an application in a calling terminal wants to call a target application in a called terminal across devices, first, the application in the calling terminal determines a local data storage address, which can be identified by a URI; then, the application in the calling terminal sends a call request for calling the target application in the called terminal to the cross-device interaction module of the called device through the distributed application framework and the cross-device interaction module on the calling terminal. The call request contains the data storage address.
[0162] After receiving the call request sent by the calling terminal, the cross-device interaction module of the called terminal sends the call request to the distributed application framework. On the one hand, the distributed application framework sends the call request to the target application to open the target application and control the target application to generate target data by, for example, manually intervening in the interface interaction with the target application; on the other hand, the data storage address in the call request is sent to the session management module so that the session management module associates the session identifiers corresponding to the calling terminal and the called terminal with the data storage address, for example, to establish a "session identifier-data storage address" list.
[0163] After generating the target data, the target application needs to write the target data back to the distributed file system in the cross-device interaction model module of the called terminal. Specifically, in response to the file opening instruction triggered by the target application calling the open function, the cache management program in the distributed application framework obtains the session identifier corresponding to the calling terminal and the called terminal and the data storage address provided by the calling terminal (i.e., the data storage address contained in the call request) from the session management module, and creates and opens the target cache file named with the session identifier and the data storage address in the local cache file directory. Among them, the file descriptor corresponding to the target cache file is called the first file descriptor. The distributed application framework performs encapsulation and other operations according to the first file descriptor, generates a first data stream, and feeds the first output stream back to the target application. The target application calls the write function to write the target data to the target cache file through the first output stream. Finally, the target application calls the close function to close the target cache file (not shown in the figure), completing the writing of the target data to the target cache file.
[0164] After the target data is written into the target cache file by the target application, the cache management component shall synchronize the target data in the target cache file to the distributed file system. Specifically, the distributed file system in the cross-device interaction module creates and opens the target storage file in response to the file open instruction triggered by the cache management program calling the open function. Among them, the file descriptor corresponding to the target storage file is called the second file descriptor, and the second file descriptor points to a file location on the calling terminal, and the file location matches the data storage address provided by the calling terminal, such as the same file address, or a file address with a mapping relationship. Then, the cache management program generates a corresponding output stream (i.e., the second output stream) according to the second file descriptor. Afterwards, the cache management program calls the write function to write the target data read from the target cache file to the target storage file through the second output stream. Finally, the cache management program calls the close function to close the target storage file (not shown in the figure), completing the cache management program writing the target data to the target storage file.
[0165] It should be noted that although Fig. 9 and Fig.10 The cache management component shown writes the target data to the target storage file of the distributed file system on the called terminal side. However, since the second file descriptor of the target storage file points to a file location on the calling terminal, writing the target data to the target storage file is actually a cross-device data write.
[0166] The called terminal can monitor the writing status of the target data written by the cache management component to the distributed file system. If the cache management component receives a write result notification fed back by the distributed file system, the write result notification is sent to the session management component, so that the distributed application framework where the session management component is located sends a call response message corresponding to the write result notification to the cross-device interaction module of the calling terminal through the cross-device interaction module. After obtaining the call response message through the distributed application framework, the application in the calling terminal processes the call response message.
[0167] The write result notification includes at least one of the following: write success notification, write timeout notification, and write error notification. Optionally, if the write result notification received by the session management component of the called terminal is a write timeout notification or a write error notification, the cache management component is notified to retry writing the target data in the target cache file to the target storage file in the distributed file system.
[0168] In the specific implementation process, if the write result notification fed back by the distributed file system is a write success notification, the application of the calling terminal reads the target data from the target storage file in the distributed file system according to the received call response message corresponding to the write success notification. If the write result notification fed back by the distributed file system is a write timeout notification or a write error notification, the application of the calling terminal does not read the target data from the target storage file in the distributed file system according to the received call response message corresponding to the write timeout notification or the write error notification, and continues to wait until the call response message corresponding to the write success notification is received.
[0169] Optionally, if the application of the calling terminal receives call response messages corresponding to write timeout notifications or write error notifications for multiple consecutive times, a prompt message is output to prompt the user to re-call the cross-device application, for example: "Please re-call the cross-device application" is output in the form of a pop-up window on the program interface of the application of the calling terminal.
[0170] The above is the software module interaction involved in the data transmission method provided in the embodiment of the present application. The specific implementation process can refer to the aforementioned embodiment and will not be repeated in this embodiment.
[0171] In actual applications, the data types corresponding to the target data generated by the target application are divided into streaming data and non-streaming data. For example, when the camera takes a photo, the image data generated is non-streaming data; when the camera records a video, the video data generated is streaming data. Since streaming data is continuously output, its data volume cannot be estimated in advance. If all the streaming target data generated by the target application are stored in a local target cache file, when the cache application subsequently writes the target data in the target cache file to the distributed file system, the corresponding write efficiency will be low, that is, the speed of synchronizing the target data in the target cache file to the distributed file system will be slow.
[0172] In order to improve the speed at which the cache management program synchronizes streaming target data to the distributed file system, the embodiment of the present application provides a data transmission method, such as Fig.11 As shown, Fig.11 The interactive flow chart of another data transmission method provided in the embodiment of the present application includes at least the following steps:
[0173] 1101. A calling terminal sends a calling request to a called terminal for calling a target application in the called terminal.
[0174] 1102. The called terminal obtains target data generated by the target application in response to the calling request.
[0175] 1103. If the target data is streaming data, the called terminal generates multiple data slices in sequence through the target application program, and writes the multiple data slices into different target cache files respectively.
[0176] 1104. If the called terminal detects that the set reading condition is met, the cache management program running in the called terminal writes the data segments in different target cache files into the distributed file system corresponding to the called terminal.
[0177] 1105. The calling terminal reads target data from the distributed file system.
[0178] The specific implementation process of steps 1101, 1102 and 1105 can refer to the aforementioned embodiment and will not be described in detail in this embodiment.
[0179] In this embodiment, optionally, the data type of the target data generated by the target application can be determined according to the opening method when the target application is called.
[0180] If the target data is non-streaming data, the called terminal creates and opens a target cache file in the local cache file directory through the cache management program, and then writes the target data into the target cache file.
[0181] If the target data is streaming data, the called terminal first creates and opens a target cache file (1) in the local cache file directory through the cache management program, and then the target application writes the target data of the preset data volume (for example, 10M) output first as a data slice into the target cache file (1) according to the order of target data transmission; then, the cache management program creates and opens a target cache file (2) in the local cache file directory, and the target application writes the target data of the preset data volume output next as a data slice into the target cache file (2). This process is repeated until the target application writes all the data slices corresponding to the target data into different local target cache files.
[0182] The cache management program can establish a shard task queue. Each time the target application writes a data shard into the corresponding target cache file, the cache management program puts the target cache file written into the data shard into the shard task queue. Correspondingly, when there are target cache files in the shard task queue, the cache management program writes the data shards in different target cache files into the distributed file system according to the order in which different target cache files are queued in the shard task queue.
[0183] Optionally, after the data slices in the target cache file k are written into the distributed file system, the cache management program deletes the target cache file k in the local cache file directory.
[0184] For ease of understanding, combined Fig.12 To illustrate with an example, Fig.12 A schematic diagram of data slicing writing provided in an embodiment of the present application. Fig.12 As shown, the streaming target data generated by the target application can be divided into data slice 1, data slice 2, ..., data slice N of the same data size according to a preset data volume (for example: 10M), where N is an integer greater than 1.
[0185] When the target application writes back the target data, first, the called terminal creates and opens a target cache file (1) in the local cache file directory through the cache management program, and the target application writes data slice 1 into the target cache file (1). At this time, since there is still data in the target data that has not been written locally (i.e., data slice 2, ..., data slice N), the called terminal then creates and opens a target cache file (2) in the local cache file directory through the cache management program, and the target application writes data slice 2 into the target cache file (2). This process is repeated in this way until the called terminal creates and opens a target cache file (N) in the local cache file directory through the cache management program, and the target application writes data slice N into the target cache file (N).
[0186] When the target application writes data shard 1 to the target cache file (1), the cache management program puts the target cache file (1) into the shard task queue and writes data shard 1 in the target cache file (1) into the distributed file system. When the target application writes data shard 2 to the target cache file (2), the cache management program puts the target cache file (2) into the shard task queue and writes data shard 2 in the target cache file (2) into the distributed file system. And so on, similarly, until the target cache file (N) is put into the shard task queue and data shard N in the target cache file (N) is written into the distributed file system.
[0187] In this solution, when the target data is streaming data, the target data is segmented and different data segments are written into different target cache files in the local cache file directory. This enables the cache management program to write the data segments in the target cache file that have been written into the data segments into the distributed file system while the target application is writing the data segments to the target cache file, thereby improving the efficiency of synchronizing the target data from the target cache file to the distributed file system.
[0188] Some embodiments of the present application provide an electronic device, which may include: a memory, a processor, and a communication interface. The memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the data transmission method provided in the above embodiments. The structure of the electronic device can refer to Figure 3 The structure of the electronic device 100 is shown.
[0189] In addition, an embodiment of the present application also provides a non-temporary machine-readable storage medium, on which executable code is stored. When the executable code is executed by a processor of an electronic device, the processor can at least implement the data transmission method provided in the aforementioned embodiment.
[0190] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0191] The present application is described with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, and the combination of the process and / or box in the flowchart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.
[0192] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0193] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0194] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0195] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0196] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0197] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0198] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A data transmission method, characterized in that: Applied to the called terminal, including: In response to a calling request of a calling terminal to a target application in the called terminal, acquiring target data generated by the target application; Writing the target data into a local target cache file through the target application; If it is detected that the set reading condition is met, the target data in the target cache file is written into the distributed file system corresponding to the called terminal through the cache management program running in the called terminal, so that the calling terminal reads the target data from the distributed file system.
2. The method according to claim 1, characterized in that The step of writing the target data into a local target cache file through the target application comprises: In response to a file opening instruction triggered by the target application, creating and opening the target cache file in a local cache file directory through the cache management program; Generate a first output stream according to a first file descriptor corresponding to the target cache file; The first output stream is fed back to the target application so that the target application writes the target data into the target cache file through the first output stream.
3. The method according to claim 2, characterized in that The step of creating and opening the target cache file in the local cache file directory by the cache management program includes: Acquiring, through a session management program running in the called terminal, a session identifier corresponding to the calling terminal and the called terminal and a data storage address provided by the calling terminal; The session identifier and the data storage address are transmitted to the cache management program, so that the target cache file named with the session identifier and the data storage address is created and opened in the local cache file directory through the cache management program.
4. The method according to claim 3, characterized in that The cache management program and the session cache management program are both located in the distributed application framework of the called terminal.
5. The method according to claim 1, characterized in that The step of writing the target data into a local target cache file through the target application comprises: If the target data is streaming data, a plurality of data slices are sequentially generated by the target application program, and the plurality of data slices are respectively written into different target cache files.
6. The method according to any one of claims 1 to 5, characterized in that The step of writing the target data in the target cache file into a distributed file system corresponding to the called terminal through a cache management program running in the called terminal includes: Creating and opening the target storage file in the distributed file system through the cache management program; Generate a second output stream according to the second file descriptor corresponding to the target storage file; Based on the second output stream, the target data in the target cache file is written into the target storage file through the cache management program.
7. The method according to claim 6, characterized in that The method further comprises: If the write result notification fed back by the distributed file system is received through the cache management program, a call response message corresponding to the write result notification is sent to the calling terminal through the session management program, so that the calling terminal processes the call response message.
8. The method according to claim 7, characterized in that The write result notification includes at least one of the following: a write success notification, a write timeout notification, and a write error notification; wherein the write success notification is used to instruct the calling terminal to read the target data from the distributed file system.
9. An electronic device, characterized in that: include: A memory, a processor, and a communication interface; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the data transmission method as described in any one of claims 1 to 8.
10. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the data transmission method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Data transmission method, device and equipment and computer readable storage medium
CN111367853A
Data synchronization method and device, terminal and storage medium
CN114138908A
Data transmission method, first terminal, second terminal and storage medium
CN115617725A
Data transmission method, electronic equipment and device
CN115941762A
Data processing method, terminal, system, equipment, medium and product
CN116170508A