Data sending method and device, storage medium and electronic device

By avoiding data format conversion in JNI calls and using TLV format data transmission, JNI call efficiency is improved, the problem of low JNI efficiency is solved, and the system performance is improved.

CN118963867APending Publication Date: 2024-11-15HAIER YOUJIA INTELLIGENT TECH (BEIJING) CO LTD +3
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411116343.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-14
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Java Native Interface (JNI) calls are low, resulting in frequent switching between Java virtual machines and local code, affecting system performance.

Method used

The data in TLV format is obtained through the first communication module and sent to the second communication module through JNI to avoid the conversion of the data format by JNI and optimize the data transmission process.

Benefits of technology

It improves data transmission efficiency, solves the problem of low JNI call efficiency, and optimizes system performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118963867A_ABST
    Figure CN118963867A_ABST
Patent Text Reader

Abstract

The invention discloses a data sending method and device, a storage medium and an electronic device, and relates to the technical field of smart home, and the data sending method comprises the following steps: obtaining first data in a TLV format sent by a first service module through a first communication module, the first communication module and the first service module are modules written by using non-Java codes; the first data in the TLV format is sent to a second communication module through a Java local interface JNI, and the second communication module is a module written by using Java codes. By the adoption of the technical scheme, the problem that JNI calling efficiency is low is solved, and then the calling speed of JNI calling is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of smart home technology, and more specifically, to a data sending method and device, a storage medium, and an electronic device. Background Art

[0002] In Java applications, the Java Native Interface (JNI) allows Java code to interact with native code to implement performance- or permission-sensitive operations. However, in scenarios where JNI calls are required, such as graphics processing and data processing, the Java Virtual Machine (JVM) and native code need to switch frequently, resulting in slow JNI calls, high overhead, and low data transmission efficiency, which seriously affects system performance.

[0003] In the related art, methods such as memory management optimization and thread synchronization optimization are often used. However, although these methods can improve the speed of JNI calls to a certain extent, there are still performance bottlenecks and they cannot fully meet the demand for efficient JNI calls.

[0004] With regard to the problem of low JNI calling efficiency in related technologies, no effective solution has been proposed yet.

[0005] Therefore, it is necessary to improve the related technology to overcome the above-mentioned defects in the related technology. Summary of the invention

[0006] The embodiments of the present invention provide a data sending method and device, a storage medium, and an electronic device to at least solve the problem of low JNI calling efficiency.

[0007] According to one aspect of an embodiment of the present invention, a data sending method is provided, comprising: obtaining, through a first communication module, first data in a TLV format sent by a first service module, wherein the first communication module and the first service module are modules written in non-Java code; and sending the first data in the TLV format to a second communication module through a Java native interface JNI, wherein the second communication module is a module written in Java code.

[0008] In an exemplary embodiment, after acquiring the first data in TLV format sent by the first business module through the first communication module, the method further includes: determining a data type of the first data, wherein the data type includes a first type and a second type, the first type of data does not allow delayed processing, and the second type of data allows delayed processing; sending the first data in TLV format to the second communication module through the Java native interface JNI, including: when the first data is the first type of data, sending the first data in TLV format to the second communication module through the Java native interface JNI.

[0009] In an exemplary embodiment, the method further includes: when the first data is data of the second type, storing the first data in a data cache area of ​​the first communication module; when the amount of data in the data cache area is greater than a preset amount, sending the multiple data stored in the data cache area to the second communication module via the JNI.

[0010] In an exemplary embodiment, the method also includes: when the first communication module is about to call the target field in the target JAVA class, obtaining the class identifier of the target JAVA class and the field identifier of the target field from the cache through the JNI; calling the target field in the target JAVA class based on the class identifier and the field identifier through the JNI; and / or when the first communication module is about to call the target method in the target JAVA class, obtaining the class identifier of the target JAVA class and the method identifier of the target method from the cache through the JNI; calling the target method in the target JAVA class based on the class identifier and the method identifier through the JNI; wherein the class identifier, the field identifier and the method identifier in the cache are identifiers stored in the cache when the target JAVA class is initialized.

[0011] In an exemplary embodiment, the method also includes: obtaining, through the JNI, the second data in the TLV format sent by the second communication module; and sending the second data to the second business module through the first communication module, wherein the second business module is a module written in non-Java code and is to process the second data.

[0012] In an exemplary embodiment, after sending the second data to the second service module through the first communication module, the method further includes: instructing the second service module to call a TLV parser to parse the second data.

[0013] In an exemplary embodiment, when the first business module and the second business module are different modules, the first business module and the second business module use the data in the TLV format to exchange information, or use the data in the target format to exchange information, and the target format is different from the TLV format.

[0014] According to another aspect of an embodiment of the present invention, a data sending device is also provided, including: an acquisition module, used to acquire first data in TLV format sent by a first business module through a first communication module, wherein the first communication module and the first business module are modules written using non-Java code; a sending module, used to send the first data in TLV format to a second communication module through a Java local interface JNI, wherein the second communication module is a module written using Java code.

[0015] According to another aspect of an embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the above-mentioned data sending method when running.

[0016] According to another aspect of an embodiment of the present invention, there is provided an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the data sending method through the computer program.

[0017] According to another aspect of the embodiments of the present application, a computer program product is provided, including a computer program, and the computer program performs the above-mentioned data sending method when executed by a processor.

[0018] The present invention obtains data in TLV format sent by the first business module through the first communication module, and then sends the obtained data in TLV format to the second communication module through JNI. Since JNI avoids converting the format of the data when calling JNI, the efficiency of data transmission is improved, thereby solving the problem of low JNI calling efficiency and optimizing system performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0020] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0021] Figure 1 is a schematic diagram of a hardware environment of a data sending method according to an embodiment of the present application;

[0022] Figure 2 is a flow chart of a data sending method according to an embodiment of the present invention;

[0023] Figure 3 is an optional JNI calling Java field process code segment according to an embodiment of the present invention;

[0024] Figure 4 is an optional modified JNI calling Java field process code segment according to an embodiment of the present invention;

[0025] Figure 5 is an overall architecture diagram of an optional JNI call according to an embodiment of the present invention;

[0026] Figure 6 It is an optional architecture diagram of JNI calling when distinguishing data real-time according to an embodiment of the present invention;

[0027] Figure 7 is a structural block diagram of a data sending device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0028] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. 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 creative work should fall within the scope of protection of the present application.

[0029] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0030] According to one aspect of an embodiment of the present application, a data transmission method is provided. The data transmission method is widely used in smart home (Smart Home), smart home, smart home device ecology, smart residential (IntelligenceHouse) ecology and other whole-house intelligent digital control application scenarios. Optionally, in this embodiment, the above data transmission method can be applied to Figure 1 In the hardware environment composed of the terminal device 102 and the server 104 shown in FIG. Figure 1 As shown, the server 104 is connected to the terminal device 102 via a network, and can be used to provide services (such as application services, etc.) for the terminal or a client installed on the terminal. A database can be set on the server or independently of the server to provide data storage services for the server 104. Cloud computing and / or edge computing services can be configured on the server or independently of the server to provide data computing services for the server 104.

[0031] The above network may include but is not limited to: wired network, wireless network. The above wired network may include but is not limited to: wide area network, metropolitan area network, local area network, and the above wireless network may include but is not limited to: WIFI (Wireless Fidelity), Bluetooth. The terminal device 102 may be but is not limited to a PC, a mobile phone, a tablet computer, a smart air conditioner, a smart range hood, a smart refrigerator, a smart oven, a smart stove, a smart washing machine, a smart water heater, a smart washing equipment, a smart dishwasher, a smart projection equipment, a smart TV, a smart clothes drying rack, a smart curtain, a smart audio and video, a smart socket, a smart speaker, a smart speaker, a smart fresh air equipment, a smart kitchen and bathroom equipment, a smart bathroom equipment, a smart sweeping robot, a smart window cleaning robot, a smart mopping robot, a smart air purification equipment, a smart steamer, a smart microwave oven, a smart kitchen treasure, a smart purifier, a smart water dispenser, a smart door lock, etc.

[0032] In order to solve the above problem, a data sending method is provided in this embodiment. Figure 2 is a flow chart of a data sending method according to an embodiment of the present invention, including but not limited to being applied to a terminal device or a server, the process includes the following steps S202-S204:

[0033] Step S202: acquiring first data in TLV format sent by a first service module through a first communication module, wherein the first communication module and the first service module are modules written in non-Java code;

[0034] It should be noted that the Type Length Value (TLV) format is a data exchange format. In the TLV format, data is divided into three parts: type tag (Type), length (Length) and value (Value). Type indicates the type of data, Length indicates the length of data, and Value indicates the actual data value. The TLV format is usually used for data exchange and communication between different systems, and can well adapt to data of different structures and lengths.

[0035] It should be noted that compared with the data formats of JavaScript Object Notation (JSON) and Extensible Markup Language (XML) used in related technologies, the TLV format is more lightweight and the parsing process is more efficient. Using the TLV format to transmit data can effectively improve the data transmission efficiency, thereby effectively improving the efficiency of JNI calls.

[0036] Step S204: sending the first data in TLV format to the second communication module through the Java native interface JNI, wherein the second communication module is a module written in Java code.

[0037] Alternatively, if Figure 5 As shown, the first communication module ( Figure 5 The local Java communication module) is located on the local code side (the local code side uses C / C++ to write the module), and the second communication module ( Figure 5 The Java local communication module) is located on the Java side, and the local code side and the Java side each have a corresponding TLV parser, wherein the local code side has a TLV parser written in C / C++, and the Java side has a TLV parser written in Java.

[0038] Alternatively, if Figure 5 As shown, data in TLV format is transmitted between the local Java communication module and the Java local communication module. The local Java communication module interacts with the Java Virtual Machine (JVM) through JNI. After the first data is sent to the Java local communication module, the Java business module in the Java side will call the TLV parser written in Java in the Java side to parse the first data and perform subsequent processes. In other words, the JNI interface does not convert the transmitted data format, thereby improving data transmission efficiency.

[0039] It should be noted that JVM is the core component of the Java programming language, which can convert Java bytecode into native machine code for a specific platform for execution, thus achieving cross-platform characteristics. Through JVM, Java programs can be run on different operating systems and hardware platforms without modifying the source code.

[0040] It should be noted that since JNI does not perform complex data protocol conversion, a large amount of data copying and conversion operations are avoided during the JNI call process, the overhead of JNI calls is reduced, and data transmission efficiency is improved. At the same time, since the relevant business thread calls the interface of its TLV protocol parser to perform protocol conversion and subsequent business processing after receiving the data, the advantages of multi-threaded concurrent processing are fully utilized, thereby improving the system's concurrency performance and throughput, and the business thread can be flexibly processed according to specific business needs, enhancing the flexibility and scalability of the system.

[0041] In the above steps, the data in TLV format sent by the first business module is obtained through the first communication module, and then the obtained data in TLV format is sent to the second communication module through JNI. Since JNI avoids converting the data format during the JNI call, the efficiency of data transmission is improved, thereby solving the problem of low JNI call efficiency and optimizing system performance.

[0042] In an exemplary embodiment, after the above step S202, the method includes the following steps: determining a data type of the first data, wherein the data type includes a first type and a second type, the first type of data does not allow delayed processing, and the second type of data allows delayed processing;

[0043] In an exemplary embodiment, sending the first data in TLV format to the second communication module through the Java native interface JNI includes: when the first data is data of the first type, sending the first data in TLV format to the second communication module through the Java native interface JNI.

[0044] It should be noted that since the first type of data does not allow delayed processing and is real-time data (such as audio and video streams, etc.), the respondent needs to process and respond in time, so the JNI interface is called immediately to send it.

[0045] In an exemplary embodiment, the method further comprises the following steps S21-S22:

[0046] Step S21: When the first data is data of the second type, storing the first data in a data buffer area of ​​the first communication module;

[0047] Step S22: When the amount of data in the data cache area is greater than a preset amount, the plurality of data stored in the data cache area is sent to the second communication module through the JNI.

[0048] Alternatively, if Figure 6 As shown, for real-time data, JNI is called immediately to send the data to the second communication module. For the second type of data that allows delayed processing, that is, non-real-time data (such as statistical information and log management information), a batch callback method is used.

[0049] Alternatively, if Figure 6 As shown, the native code side and the Java side each set up a corresponding data buffer area for storing non-real-time data, and at the same time add a data type flag bit in the JNI interface to distinguish between two different types of data.

[0050] It should be noted that by distinguishing the real-time nature of data, different JNI calling strategies can be adopted for different types of data, thereby optimizing the JNI calling process, improving the JNI calling efficiency, and enhancing system performance.

[0051] In an exemplary embodiment, the method further includes the following steps S31 and / or S32:

[0052] Step S31: when the first communication module is to call a target field in a target JAVA class, obtain the class identifier of the target JAVA class and the field identifier of the target field from the cache through the JNI; call the target field in the target JAVA class based on the class identifier and the field identifier through the JNI;

[0053] Step S32: when the first communication module is to call a target method in a target JAVA class, obtaining a class identifier of the target JAVA class and a method identifier of the target method from the cache through the JNI; calling the target method in the target JAVA class based on the class identifier and the method identifier through the JNI;

[0054] It should be noted that in the related art, the process of local code accessing Java layer fields / methods is divided into three steps. First, the jclass class needs to be obtained, and then the field name / method name + descriptor is retrieved through the jclass class to obtain the jfieldID / jmethodID, and finally the ID is used to access the corresponding field / method. For example, Figure 3 The code segment of the target field in the target JAVA class called by JNI in the related art is shown as follows: Figure 3According to the code shown, if the native code is to access Java once, a total of three context switches are required, and the corresponding ID is retrieved, which is a time-consuming process.

[0055] Furthermore, in the embodiment of the present application, the field identifier and / or method identifier can be cached in advance when the Java class is initialized. For example, it can be cached in the JNI_OnLoad method, or a native method can be called for caching after loading the so library, such as Figure 4 The code segment shown in the modified NI calls the target field in the target JAVA class. After the modification, only one context switch is required, which effectively improves the calling efficiency of JNI.

[0056] It should be noted that the class identifier, the field identifier and the method identifier in the cache are identifiers stored in the cache when the target JAVA class is initialized.

[0057] In an exemplary embodiment, the method further includes the following steps S41-S42:

[0058] Step S41: acquiring the second data in the TLV format sent by the second communication module through the JNI;

[0059] Step S42: Sending the second data to a second service module through the first communication module, wherein the second service module is a module written in non-Java code and is to process the second data.

[0060] In an exemplary embodiment, after the above step S42, the method further includes the following steps: instructing the second service module to call a TLV parser to parse the second data.

[0061] In an exemplary embodiment, when the first business module and the second business module are different modules, the first business module and the second business module use the data in the TLV format to exchange information, or use the data in the target format to exchange information, and the target format is different from the TLV format.

[0062] That is to say, the TLV format is a data format for transmitting data between the first service module and the second service module in this embodiment, and other data formats are also applicable to the data sending method of this application.

[0063] It should be noted that the execution subject of the above steps is the first communication module.

[0064] Obviously, the above-described embodiments are only embodiments of a part of the present invention, rather than all embodiments. In order to better understand the above method, the above process is described below in conjunction with embodiments, but it is not intended to limit the technical solutions of the embodiments of the present invention, specifically:

[0065] 1. Reduce the context switching overhead when the native code calls back the Java method by caching the ID locally;

[0066] In the related art, the process of local code accessing Java layer fields / methods is divided into three steps. First, it is necessary to obtain the jclass class (that is, the class identifier of the target JAVA class mentioned above), then retrieve the field name / method name and descriptor through the jclass class, obtain jfieldID / jmethodID (that is, the above field identifier and / or method identifier), and finally use this ID to access the corresponding field / method. Among them, the code segment of JNI calling Java fields is as follows Figure 3 As shown, if a native code accesses Java, a total of three context switches are required, and the retrieval process of the corresponding ID is relatively time-consuming.

[0067] In the embodiment of the present application, when the Java class is initialized, the field / method ID is cached in advance, for example, in the JNI_OnLoad method, or a native method is called for caching after loading the so library. The modified code segment of JNI calling the Java field is as follows: Figure 4 shown.

[0068] Through the optimized design of local cache, the number of context switches is reduced when the local method calls Java, the context switching time and ID search time are reduced, and the JNI calling efficiency is improved.

[0069] 2. Design an efficient data transmission protocol to avoid data conversion during JNI interface calls and improve data transmission efficiency;

[0070] like Figure 5 As shown in the figure, the design uses TLV format data for transmission, and the local code and Java end implement the corresponding TLV parser respectively. The JNI interface does not perform complex data protocol conversion, but is only responsible for forwarding the original data to the relevant business thread, which calls the TLV protocol parser for protocol conversion and subsequent business processing.

[0071] The data transmission efficiency of TLV format is high: TLV (Type-Length-Value) is a simple and effective data transmission format. It divides data into three parts: type, length, and value. It can adapt well to data of different data structures and lengths. Compared with other complex data transmission formats, such as JSON or XML, TLV format is more lightweight and more efficient to parse, thus improving data transmission efficiency. By implementing TLV parsers on the native code side (C / C++) and the Java side, the advantages and characteristics of each language can be fully utilized to achieve efficient data parsing.

[0072] In the JNI interface, it is only responsible for forwarding the TLV raw data to the relevant business thread without performing complex data protocol conversion. This can avoid a large number of data copying and conversion operations during the JNI call process, reduce the overhead of JNI calls, and improve data transmission efficiency. After that, the relevant business thread calls the TLV protocol parser interface for protocol conversion and subsequent business processing, which can fully utilize the advantages of multi-threaded concurrent processing and improve the system's concurrent performance and throughput. At the same time, business threads can perform flexible processing according to specific business needs, enhancing the flexibility and scalability of the system.

[0073] Through such an optimized design, the data transmission efficiency can be effectively improved, while giving full play to the advantages of each language and technology to optimize system performance and scalability.

[0074] 3. Distinguish the real-time nature of data, optimize the JNI calling process, batch callback of non-real-time data, and reduce the number of JNI calls.

[0075] The data sent through JNI is divided into real-time data and non-real-time data. Real-time data requires a timely response from the other party, such as audio and video streams. Non-real-time data does not require high real-time performance and can be processed delayed, such as some statistical information and log information. For real-time data, you can call the JNI interface immediately to send it. For non-real-time data, you can use the batch callback method, that is, wait for a certain amount of data to accumulate and then make a JNI call at one time.

[0076] In order to implement batch callbacks, such as Figure 6 As shown, a buffer can be set in the corresponding class or module to store non-real-time data. At the same time, a data type flag bit is added to the corresponding JNI interface so that the code can distinguish between two different types of data.

[0077] By distinguishing the real-time nature of the data, different JNI calling strategies can be adopted for different types of data, thereby optimizing the JNI calling process and improving the performance and efficiency of the system.

[0078] In summary, the implementation of the above inventions can significantly improve JNI calling efficiency and optimize system performance.

[0079] It should be noted that the present invention also has the following advantages:

[0080] (1) Improve Android system performance: By optimizing the JNI call speed, reduce system overhead, and improve overall system performance;

[0081] (2) Improve user experience: Reduce JNI call waiting time, improve system response speed, and enhance user experience.

[0082] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of various embodiments of the present invention.

[0083] In the present embodiment, a data transmission device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions thereof will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the equipment described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and contemplated.

[0084] Figure 7 is a structural block diagram of a data sending device according to an embodiment of the present invention, the device comprising:

[0085] An acquisition module 72, configured to acquire first data in a TLV format sent by a first service module through a first communication module, wherein the first communication module and the first service module are modules written in non-Java code;

[0086] The sending module 74 is used to send the first data in TLV format to the second communication module through the Java native interface JNI, wherein the second communication module is a module written in Java code.

[0087] The above-mentioned device obtains the TLV format data sent by the first business module through the first communication module, and then sends the obtained TLV format data to the second communication module through JNI. Since JNI avoids converting the data format during the JNI call, the efficiency of data transmission is improved, thereby solving the problem of low JNI call efficiency and optimizing system performance.

[0088] In an exemplary embodiment, the above-mentioned device also includes: a determination module, which is used to determine the data type of the first data in TLV format after obtaining the first data in TLV format sent by the first business module through the first communication module, wherein the data type includes a first type and a second type, the first type of data does not allow delayed processing, and the second type of data allows delayed processing; a sending module 74, which is also used to send the first data in TLV format to the second communication module through the Java local interface JNI when the first data is the first type of data.

[0089] In an exemplary embodiment, the sending module 74 is also used to store the first data in the data cache area of ​​the first communication module when the first data is the second type of data; and to send the multiple data stored in the data cache area to the second communication module through the JNI when the amount of data in the data cache area is greater than a preset amount.

[0090] In an exemplary embodiment, the acquisition module 72 is also used to, when the first communication module is about to call the target field in the target JAVA class, obtain the class identifier of the target JAVA class and the field identifier of the target field from the cache through the JNI; call the target field in the target JAVA class based on the class identifier and the field identifier through the JNI; and / or when the first communication module is about to call the target method in the target JAVA class, obtain the class identifier of the target JAVA class and the method identifier of the target method from the cache through the JNI; call the target method in the target JAVA class based on the class identifier and the method identifier through the JNI; wherein the class identifier, the field identifier and the method identifier in the cache are identifiers stored in the cache when the target JAVA class is initialized.

[0091] In an exemplary embodiment, the acquisition module 72 is also used to obtain the second data in the TLV format sent by the second communication module through the JNI; the sending module 74 is also used to send the second data to the second business module through the first communication module, wherein the second business module is a module written in non-Java code and is to process the second data.

[0092] In an exemplary embodiment, the apparatus further includes: an instruction module, configured to instruct the second service module to call a TLV parser to parse the second data after the second data is sent to the second service module through the first communication module.

[0093] In an exemplary embodiment, when the first business module and the second business module are different modules, the first business module and the second business module use the data in the TLV format to exchange information, or use the data in the target format to exchange information, and the target format is different from the TLV format.

[0094] An embodiment of the present invention further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0095] Optionally, in this embodiment, the storage medium may be configured to store a computer program for performing the following steps:

[0096] S1, acquiring, through a first communication module, first data in a TLV format sent by a first service module, wherein the first communication module and the first service module are modules written in non-Java code;

[0097] S2. Send the first data in TLV format to a second communication module through a Java native interface JNI, wherein the second communication module is a module written in Java code.

[0098] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0099] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0100] An embodiment of the present invention further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0101] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program:

[0102] S1, acquiring, through a first communication module, first data in a TLV format sent by a first service module, wherein the first communication module and the first service module are modules written in non-Java code;

[0103] S2. Send the first data in TLV format to a second communication module through a Java native interface JNI, wherein the second communication module is a module written in Java code.

[0104] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0105] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0106] An embodiment of the present application further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the steps in any one of the above method embodiments are implemented.

[0107] An embodiment of the present application further provides another computer program product, including a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in any of the above method embodiments are implemented.

[0108] The embodiments of the present application also provide a computer program, which includes computer instructions, which are stored in a computer-readable storage medium; a processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps of any one of the above method embodiments.

[0109] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0110] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A data transmission method, characterized in that: include: Acquire, through a first communication module, first data in a TLV format sent by a first service module, wherein the first communication module and the first service module are modules written in non-Java code; The first data in TLV format is sent to the second communication module through a Java native interface JNI, wherein the second communication module is a module written in Java code.

2. The data transmission method according to claim 1, characterized in that: After acquiring, through the first communication module, first data in a TLV format sent by the first service module, the method further includes: determining a data type of the first data, wherein the data type includes a first type and a second type, the first type of data does not allow delayed processing, and the second type of data allows delayed processing; Sending the first data in TLV format to the second communication module through the Java native interface JNI includes: when the first data is data of the first type, sending the first data in TLV format to the second communication module through the Java native interface JNI.

3. The data transmission method according to claim 2, characterized in that: The method further comprises: When the first data is data of the second type, storing the first data in a data buffer area of ​​the first communication module; When the amount of data in the data buffer area is greater than a preset amount, the plurality of data stored in the data buffer area is sent to the second communication module through the JNI.

4. The data transmission method according to claim 1, characterized in that: The method further comprises: When the first communication module is about to call a target field in a target JAVA class, obtaining a class identifier of the target JAVA class and a field identifier of the target field from a cache through the JNI; calling the target field in the target JAVA class based on the class identifier and the field identifier through the JNI; and / or When the first communication module is about to call a target method in a target JAVA class, obtaining a class identifier of the target JAVA class and a method identifier of the target method from the cache through the JNI; calling the target method in the target JAVA class based on the class identifier and the method identifier through the JNI; The class identifier, the field identifier and the method identifier in the cache are identifiers stored in the cache when the target JAVA class is initialized.

5. The data transmission method according to claim 1, characterized in that: The method further comprises: The second data in the TLV format sent by the second communication module is obtained through the JNI; and the second data is sent to the second service module through the first communication module, wherein the second service module is a module written in non-Java code and is to process the second data.

6. The data transmission method according to claim 5, characterized in that: After sending the second data to the second service module through the first communication module, the method further includes: Instruct the second service module to call a TLV parser to parse the second data.

7. The data transmission method according to claim 5, characterized in that: In the case that the first service module and the second service module are different modules, the first service module and the second service module use the data in the TLV format to exchange information, or use the data in the target format to exchange information, and the target format is different from the TLV format.

8. A data sending device, characterized in that: include: An acquisition module, used for acquiring first data in TLV format sent by a first service module through a first communication module, wherein the first communication module and the first service module are modules written in non-Java code; The sending module is used to send the first data in TLV format to the second communication module through the Java native interface JNI, wherein the second communication module is a module written in Java code.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 7 when executed.

10. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 7 through the computer program.