Bluetooth interface automatic adaptation method and device, medium, equipment and program product
By generating and interacting the code of serialization and deserialization of interfaces, the complex problem of Bluetooth interface conversion code in Android system is solved, and the separation and separate maintenance of Bluetooth interface and protocol stack are realized, reducing debugging difficulty and adaptation frequency.
Patent Information
- Application Number
- CN202411073150.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-19
AI Technical Summary
In existing Android systems, the Bluetooth interface conversion code structure is complex and error-prone, and needs frequent adaptation when the interface changes, resulting in third-party Bluetooth protocol providers facing support difficulties for multiple software versions when on-board side.
By extracting the Java Bluetooth service module and JNI code, the Java code of the serialization interface and the C language code of the deserialization interface are generated, and the information interaction is realized using the process communication channel, the JNI call code is modified to call the serialization interface, and the original Java is replaced by the process communication channel. Bluetooth service module to realize the automatic adaptation of Bluetooth interface.
It realizes the separation of the Bluetooth interface version of the Android system and the protocol stack, allows separate maintenance and is compatible with different versions of the protocol stack, avoids the adaptation problem every time it is called, reduces debugging difficulty and ensures connection effect.
Smart Images

Figure CN118981305A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Bluetooth transmission technology, and in particular to a method, device, storage medium, electronic device and computer program product for automatic adaptation of a Bluetooth interface in an Android system. Background Art
[0002] In the prior art, the Bluetooth application layer protocol is generally divided into two roles: server and client. In the process of evolution, the Android system has given priority to the server-side related functions, that is, the common functions on mobile phones, such as hands-free phone AG, Bluetooth music Source and AVRCP TG, etc., while the Android system is applied to the in-vehicle entertainment system, and its main Bluetooth function is to realize communication with external Bluetooth devices such as mobile phones. Therefore, in-vehicle Bluetooth is generally used as a client role, such as HF device for hands-free phone, Sink for Bluetooth music and AVRCP CT, etc.
[0003] In early versions of Android (Android system), the client role's functional implementation was not complete, and its interface was constantly updated and changed during Android's upgrade and iteration process. This caused many inconveniences for third-party Bluetooth protocol providers when applying it to Android Bluetooth car terminals, which needed to support multiple different Bluetooth software versions.
[0004] The Bluetooth function interface in the Android system is constantly updated and improved, and the protocol stack supporting these function interfaces is also updated accordingly. The Bluetooth interface in the current Android system is implemented through the Java service module, which directly calls the interface of the protocol stack in the form of JNI. However, the code structure of this interface conversion code itself is complex and prone to errors, and the JNI conversion code needs to be adapted and adjusted when the interface changes. Summary of the invention
[0005] In view of the problem in the prior art that the conversion code structure is complex and requires adaptation conversion, the present application mainly provides a method, device, storage medium, electronic device and computer program product for automatic adaptation of the Bluetooth interface in an Android system.
[0006] In order to achieve the above-mentioned objectives, the first technical solution adopted in the present application is: to provide an automatic adaptation method for the Bluetooth interface in an Android system, which includes: extracting the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module; using the code and JNI code of the Java Bluetooth service module to generate the Java code of the serialization interface and the C language code of the deserialization interface; integrating the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and using the process communication channel between the client and the server to realize the information interaction between the Java code of the serialization interface and the C language code of the deserialization interface; using a code modifier to modify the JNI calling code in the Java Bluetooth service module to an interface that calls the Java code of the serialization interface; replacing the Java Bluetooth service module in the Android system with the modified Java Bluetooth service module and the C language code of the deserialization interface that communicates with it between processes.
[0007] Optionally, using the code and JNI code of the Java Bluetooth service module to generate Java code for the serialization interface and C language code for the deserialization interface includes: obtaining and identifying the interface in the Android system source code, and assigning the interface its corresponding unique tag in the tag space; saving the interface and interface parameters in the Android system source code in the form of a Bluetooth interface definition language as an intermediate file; generating Java code for the serialization interface and C language code for the deserialization interface according to predetermined parameter serialization rules and the interface and interface parameters saved in the form of an intermediate file.
[0008] Optionally, obtain and identify the interface in the Android system source code, and assign a corresponding unique label to the interface in the label space, including: extracting the interface and interface parameters in the Android system source code by using the native keyword in the Java language, the Java Bluetooth package name, the jniRegisterNativeMethods keyword and the corresponding class path in jniRegisterNativeMethods, and the JNINativeMethod signature list as feature values.
[0009] Optionally, generating Java code for a serialized interface and C language code for a deserialized interface according to predetermined parameter serialization rules and interfaces and interface parameters saved in the form of intermediate files includes: serializing the interfaces and interface parameters extracted from the Android system source code into byte streams according to predetermined parameter serialization rules, and using the byte-streamed interfaces and interface parameters to generate Java code for the serialized interface and C language code for the deserialized interface.
[0010] Optionally, the Java code of the serialization interface is integrated on the client and the C language code of the deserialization interface is integrated on the server, and the process communication channel between the client and the server is used to realize information interaction between the Java code of the serialization interface and the C language code of the deserialization interface, including: serializing the Java code of the serialization interface into a control byte stream, and transmitting the control byte stream to the server through the process communication channel; receiving the control byte stream on the server through the process communication channel, and deserializing the control byte stream into a call to the protocol stack interface of the C language code of the deserialization interface.
[0011] Optionally, the Java code of the serialization interface is integrated on the client side and the C language code of the deserialization interface is integrated on the server side, and the information interaction between the Java code of the serialization interface and the C language code of the deserialization interface is realized by utilizing the process communication channel between the client side and the server side, including: calling the required protocol stack interface by implementing the protocol stack interface code of the C language code on the server side.
[0012] The second technical solution adopted in the present application is: to provide an automatic adaptation device for a Bluetooth interface in an Android system, which includes: an information extraction module, used to extract the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module; a code generation module, used to use the code and JNI code of the Java Bluetooth service module to generate the Java code of the serialization interface and the C language code of the deserialization interface; an information interaction module, used to integrate the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and use the process communication channel between the client and the server to realize the information interaction between the Java code of the serialization interface and the C language code of the deserialization interface; a modification module, using a code modifier to modify the JNI calling code in the Java Bluetooth service module to an interface of the Java code that calls the serialization interface; and replace the Java Bluetooth service module in the Android system with the modified Java Bluetooth service module and the C language code of the deserialization interface that communicates with it between processes.
[0013] Optionally, the code generation module includes: obtaining and identifying interfaces in the Android system source code, and assigning corresponding unique tags to the interfaces in the tag space; saving the interfaces and interface parameters in the Android system source code as intermediate files in the form of Bluetooth interface definition language; generating Java code for the serialized interface and C language code for the deserialized interface according to predetermined parameter serialization rules and the interfaces and interface parameters saved in the form of intermediate files.
[0014] Optionally, the code generation module further includes: extracting the interface and interface parameters in the Android system source code by using the native keyword in the Java language, the Java Bluetooth package name, the jniRegisterNativeMethods keyword and the corresponding class path in jniRegisterNativeMethods, and the JNINativeMethod signature list as feature values.
[0015] Optionally, the code generation module further includes: serializing the interfaces and interface parameters extracted from the Android system source code into byte streams according to predetermined parameter serialization rules, and using the byte-streamed interfaces and interface parameters to generate Java code for the serialized interface and C language code for the deserialized interface.
[0016] Optionally, the information interaction module includes: serializing the Java code of the serialization interface into a control byte stream, transmitting the control byte stream to the server through the process communication channel; receiving the control byte stream at the server through the process communication channel, and deserializing the control byte stream into a call to the protocol stack interface of the C language code of the deserialization interface.
[0017] Optionally, the information interaction module includes: calling the required protocol stack interface by implementing the protocol stack interface code in the C language code on the server side.
[0018] The third technical solution adopted in the present application is: to provide a computer-readable storage medium storing a computer program / instruction, which is operated to execute the automatic adaptation method of the Bluetooth interface in the Android system in solution one.
[0019] The fourth technical solution adopted in the present application is: to provide a computer device, including a memory, a processor and a computer program stored in the memory, and the processor executes the computer program to implement the automatic adaptation method of the Bluetooth interface in the Android system in solution one.
[0020] The fifth technical solution adopted in the present application is: to provide a computer program product, including a computer program / instruction, which, when executed by a processor, implements the automatic adaptation method of the Bluetooth interface in the Android system as in Solution 1.
[0021] The beneficial effects that can be achieved by the technical solution of the present application are: it can realize the separation between the Android system Bluetooth interface version and the protocol stack, so as to realize the separate maintenance of the two, and then realize the use of the same protocol stack to be compatible with different Android systems and realize the replacement of different versions of the protocol stack with the same Android system, avoiding the problem of needing to adapt every time the different versions of the Android system Bluetooth interface are called, and by limiting the Android system's Bluetooth interface to interact with the protocol stack in a unified standard manner, it can reduce the difficulty of debugging and ensure the connection effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] 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, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0023] Figure 1 It is a schematic diagram of a specific implementation method of a Bluetooth interface automatic adaptation method in an Android system of the present application;
[0024] Figure 2 is a schematic diagram of the system generation method of the present application;
[0025] Figure 3 It is a schematic diagram of a specific implementation of a Bluetooth interface automatic adaptation device in an Android system of the present application.
[0026] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0027] The preferred embodiments of the present application are described in detail below in conjunction with the accompanying drawings so that the advantages and features of the present application can be more easily understood by those skilled in the art, thereby making a clearer and more definite definition of the protection scope of the present application.
[0028] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article 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, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0029] The inventive concept of the present application is: according to the Android software architecture and the implementation characteristics of the Bluetooth interface therein, by designing a tool for automatically matching the Bluetooth interface, the tool is used to automatically generate the intermediate code in the interface implementation, so as to separate the underlying protocol stack and the Bluetooth interface between different Android versions.
[0030] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The specific embodiments described below can be combined with each other to form new embodiments. The same or similar ideas or processes described in one embodiment may not be repeated in other embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0031] Figure 1 Schematic diagram of a specific implementation of a method for automatic Bluetooth interface adaptation in an Android system of the present application. Figure 1 The method for automatic adaptation of the Bluetooth interface in the Android system shown includes: step S101, extracting the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module;
[0032] Step S102, using the code of the Java Bluetooth service module and the JNI code, generating the Java code of the serialization interface and the C language code of the deserialization interface;
[0033] Step S103, integrating the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and using the process communication channel between the client and the server to realize information interaction between the Java code of the serialization interface and the C language code of the deserialization interface;
[0034] Step S104, using a code modifier, modifying the JNI calling code in the Java Bluetooth service module into an interface of a Java code that calls a serialization interface;
[0035] Step S105, replacing the Java Bluetooth service module in the Android system with the modified Java Bluetooth service module and the C language code of the deserialization interface for inter-process communication therewith.
[0036] Figure 1 The method for automatic adaptation of the Bluetooth interface in the Android system shown includes: step S101, extracting the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module.
[0037] Specifically, the present application extracts the code of the Java Bluetooth service module and the JNI code corresponding to the Java Bluetooth service module from the source code of any Android system, wherein the code of the Java Bluetooth service module and the JNI code corresponding to the Java Bluetooth service module contain all the Bluetooth function interfaces of the Android system and their corresponding callback codes, so as to better understand the format of the Bluetooth interface of the system and its corresponding protocol stack.
[0038] In a specific embodiment of the present application, the native keyword in the Java language, the Java Bluetooth package name, the jniRegisterNativeMethods keyword and the corresponding class path in jniRegisterNativeMethods, and the JNINativeMethod signature list are used as feature values to extract the interface and interface parameters in the Android system source code.
[0039] Specifically, the code of the Java Bluetooth service module and the JNI code corresponding to the Java Bluetooth service module are taken as input information, the native keyword in the Java language, the Java Bluetooth package name, the jniRegisterNativeMethods keyword and the corresponding class path in jniRegisterNativeMethods, and the JNINativeMethod signature list are taken as feature values, and the interface and interface parameters in the Android system source code are extracted from the code of the Java Bluetooth service module and the JNI code corresponding to the Java Bluetooth service module.
[0040] exist Figure 1 In the illustrated implementation, the method for automatic adaptation of the Bluetooth interface in the Android system includes step S102, using the code and JNI code of the Java Bluetooth service module to generate the Java code of the serialization interface and the C language code of the deserialization interface.
[0041] In a specific embodiment of the present application, step S102 includes obtaining and identifying the interface in the Android system source code, and assigning a corresponding unique label to the interface in the label space; saving the interface and the interface parameters in the Android system source code in the form of a Bluetooth interface definition language as an intermediate file; and generating Java code for the serialized interface and C language code for the deserialized interface according to predetermined parameter serialization rules and the interface and interface parameters saved in the form of an intermediate file.
[0042] Furthermore, generating Java code for the serialized interface and C language code for the deserialized interface according to predetermined parameter serialization rules and the interface and interface parameters saved in the form of an intermediate file includes: serializing the interface and interface parameters extracted from the Android system source code into a byte stream according to the predetermined parameter serialization rules, and using the byte-streamed interface and interface parameters to generate Java code for the serialized interface and C language code for the deserialized interface.
[0043] Specifically, a storage space with labels is defined, and corresponding unique labels are assigned to interfaces and interface parameters, that is, a unique interface class label is assigned to each extracted interface, a unique parameter class label is assigned to each parameter type, and storage space is allocated to interfaces and parameters corresponding to interfaces according to the labels. When storing, the extraction results are saved in the storage space in the form of a Bluetooth Interface Definition Language (BTDL) intermediate file, and the content saved in the storage space includes the callback list of the interface and the parameter column of each interface. A set of parameter serialization rules Serialization_Rule is designed to serialize all types of parameters and interface data corresponding to the interface into byte streams, and generate Java code for serialized interfaces and C language code for deserialized interfaces based on the serialized interface parameters and serialized interface data, wherein the Java code for serialized interfaces can provide code calling functions for Java service modules, and the C language code for deserialized interfaces can form the interface Stub code of the protocol stack.
[0044] exist Figure 1 In the illustrated implementation manner, the automatic adaptation method for the Bluetooth interface in the Android system includes step S103, integrating the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and utilizing the process communication channel between the client and the server to realize information interaction between the Java code of the serialization interface and the C language code of the deserialization interface.
[0045] In a specific embodiment of the present application, S103 includes: serializing the Java code of the serialization interface into a control byte stream, and transmitting the control byte stream to the server through the process communication channel; receiving the control byte stream at the server through the process communication channel, and deserializing the control byte stream into a call to the protocol stack interface of the C language code of the deserialization interface.
[0046] In a specific embodiment of the present application, S103 includes: calling the required protocol stack interface by implementing the protocol stack interface code of the C language code on the server side.
[0047] Specifically, the transmission content that needs to be exchanged between the server and the client is serialized through the process communication channel (IPC) to obtain a control byte stream, and the control byte stream is used to transmit data in the process communication channel. The Java code of the serialization interface is integrated on the client and the C language code of the deserialization interface is integrated on the server. These two sets of codes are compiled to generate two sets of communication libraries, that is, the Java code of the serialization interface is integrated on the client, an access interface for accessing the client is generated, and the relevant information of the interface is serialized to form a control byte stream, and the interface information is sent to the server through the IPC channel.
[0048] The C code of the deserialization interface is integrated on the server side, and after receiving the relevant information of the client interface transmitted through the control byte stream on the IPC channel, the server side deserializes the received relevant information of the client interface into a call to the protocol stack interface (Stub API).
[0049] exist Figure 1 In the illustrated implementation, the automatic adaptation method for the Bluetooth interface in the Android system includes step S104, using a code modifier to modify the JNI calling code in the Java Bluetooth service module to an interface of a Java code that calls a serialized interface.
[0050] Specifically, a code modifier is designed to modify the source code in the Java Bluetooth service module in the Android system, that is, first search for the declaration of the JNI native definition function and its corresponding calling code in the Android system, then delete the Android system's definition code for JNI and the related code that implements its functions, and convert the JNI calling code into the calling code for the interface of the Client library.
[0051] exist Figure 1 In the illustrated implementation, the method for automatic adaptation of the Bluetooth interface in the Android system includes step S105, replacing the Java Bluetooth service module in the Android system with the modified Java Bluetooth service module and the C language code of the deserialization interface for inter-process communication therewith.
[0052] Specifically, the modifications and changes in the above steps are integrated into the Android system, that is, the modified Bluetooth Java service module code and the C language code of the deserialization interface of the server are integrated into the Android system. In actual applications, when the protocol stack interface needs to be called, the modified Java Bluetooth service module first calls the interface of the Java code of the serialization interface integrated inside it, and then transmits the information to the server through the process communication between the client and the server, and calls the corresponding protocol stack interface on the server by using the protocol stack interface Stub code.
[0053] Figure 2 Schematic diagram of the system generation method of the present application. Figure 2 As shown, in the actual application process, firstly, by obtaining the system source code of any version of the Android system, then extracting the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module, then extracting the Java Bluetooth service module and the interface and the parameters related to the interface in the Java Bluetooth service module, and defining an interface storage space, defining the corresponding unique tags for each interface and multiple parameters of each interface respectively, and storing the interface and the interface related parameters in the defined storage space according to the tag classification, and then the related parameters of the interface are based on the predetermined serialization rules, and then according to the serialization rules and the saved interface and the related data of the parameters corresponding to the interface, the Java code of the serialized interface and the C language code of the deserialized interface are generated. Information is exchanged between the server and the client through the process communication channel to realize the separation of the protocol stack call and the Bluetooth interface call. Then modify the source code in the Java Bluetooth service module in the Android system, that is, convert the JNI call code into a call to the client serialization interface, and then realize the call to the deserialization interface of the server, so that the present application can be applied to different versions of Bluetooth systems, and no version adaptation is required. Finally, the modified code is integrated into the Android system, so that the Android system can access the client interface and protocol stack without interface adaptation and complex algorithms. This application can achieve a relatively high degree of coupling between the interface and the protocol stack interface, thereby better realizing the decoupling of interface connection and interface implementation, thereby realizing automatic generation of interface conversion code and independent maintenance and upgrade of the protocol stack.
[0054] Therefore, the present application can achieve the separation between the Android system Bluetooth interface version and the protocol stack, thereby achieving separate maintenance of the two, and further achieving compatibility with different Android systems using the same protocol stack and replacing different versions of the protocol stack with the same Android system, avoiding the problem of needing to adapt every time different versions of the Android system Bluetooth interface are called. In addition, by limiting the Android system's Bluetooth interface to interact with the protocol stack in a unified standard manner, the difficulty of debugging can be reduced and the connection effect can be guaranteed.
[0055] Figure 3 A specific implementation of a Bluetooth interface automatic adaptation device in an Android system of the present application is shown.
[0056] exist Figure 3 In the specific implementation shown, the automatic adaptation device for the Bluetooth interface in the Android system mainly includes: an information extraction module 301, which is used to extract the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module;
[0057] The code generation module 302 is used to generate Java code of the serialization interface and C language code of the deserialization interface by using the code and JNI code of the Java Bluetooth service module;
[0058] The information interaction module 303 is used to integrate the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and use the process communication channel between the client and the server to realize the information interaction between the Java code of the serialization interface and the C language code of the deserialization interface;
[0059] Modification module 304 uses a code modifier to modify the JNI calling code in the Java Bluetooth service module to an interface of a Java code that calls a serialization interface; and uses the modified Java Bluetooth service module and the C language code of the deserialization interface for inter-process communication with it to replace the Java Bluetooth service module in the Android system.
[0060] In a specific embodiment of the present application, the code generation module includes: obtaining and identifying interfaces in the Android system source code, and assigning corresponding unique tags to the interfaces in the tag space; saving the interfaces and interface parameters in the Android system source code as intermediate files in the form of Bluetooth interface definition language; generating Java code for the serialized interface and C language code for the deserialized interface according to predetermined parameter serialization rules and the interfaces and interface parameters saved in the form of intermediate files.
[0061] In a specific embodiment of the present application, the code generation module further includes: extracting the interface and interface parameters in the Android system source code by using the native keyword in the Java language, the Java Bluetooth package name, the jniRegisterNativeMethods keyword and the corresponding class path in jniRegisterNativeMethods, and the JNINativeMethod signature list as feature values.
[0062] In a specific embodiment of the present application, the code generation module further includes: according to a predetermined parameter serialization rule, serializing the interface and interface parameters extracted from the Android system source code into a byte stream, and using the byte streamed interface and interface parameters to generate Java code for the serialized interface and C language code for the deserialized interface.
[0063] In a specific embodiment of the present application, the information interaction module includes: serializing the Java code of the serialization interface into a control byte stream, transmitting the control byte stream to the server through a process communication channel; receiving the control byte stream at the server through the process communication channel, and deserializing the control byte stream into a call to the protocol stack interface of the C language code of the deserialization interface.
[0064] In a specific embodiment of the present application, the information interaction module includes: calling the required protocol stack interface through the protocol stack interface code implemented in the C language code on the server side.
[0065] The automatic adaptation device for the Bluetooth interface in the Android system provided in the present application can be used to execute the automatic adaptation method for the Bluetooth interface in the Android system described in any of the above embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0066] In a specific embodiment of the present application, each functional module in a Bluetooth interface automatic adaptation device in an Android system of the present application can be directly in hardware, in a software module executed by a processor, or in a combination of the two.
[0067] The software modules may reside in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, removable disk, CD-ROM or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from and write information to the storage medium.
[0068] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field programmable gate arrays (FPGA), or other programmable logic devices, discrete gates or transistor logic, discrete hardware components, or any combination thereof. A general-purpose processor may be a microprocessor, but in an alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. The processor may also be implemented as a combination of computing devices, such as a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors combined with a DSP core, or any other such configuration. In an alternative, the storage medium may be integrated with the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a user terminal. In an alternative, the processor and the storage medium may reside in a user terminal as discrete components.
[0069] In another specific embodiment of the present application, a computer-readable storage medium stores a computer program / instruction, and the computer program / instruction is operated to execute the Bluetooth interface automatic adaptation method in the Android system described in the above embodiment.
[0070] In a specific embodiment of the present application, a computer device includes a memory, a processor, and a computer program stored in the memory, and the processor executes the computer program to implement the automatic adaptation method of the Bluetooth interface in the Android system described in the above embodiment.
[0071] In a specific embodiment of the present application, a computer program product includes a computer program / instruction, which, when executed by a processor, implements the automatic adaptation method of the Bluetooth interface in the Android system described in the above embodiment.
[0072] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0073] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0074] The above description is only an embodiment of the present application and does not limit the patent scope of the present application. Any equivalent structural transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A method for automatic adaptation of a Bluetooth interface in an Android system, characterized in that: include: Extract the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module; Generate Java code for a serialization interface and C language code for a deserialization interface using the code of the Java Bluetooth service module and the JNI code; Integrate the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and use the process communication channel between the client and the server to realize the information interaction between the Java code of the serialization interface and the C language code of the deserialization interface; Using a code modifier, modify the JNI calling code in the Java Bluetooth service module to an interface of the Java code that calls the serialization interface; The Java Bluetooth service module in the Android system is replaced by the modified Java Bluetooth service module and the C language code of the deserialization interface for inter-process communication therewith.
2. The method for automatically adapting the Bluetooth interface in the Android system according to claim 1, characterized in that: The method of using the code of the Java Bluetooth service module and the JNI code to generate the Java code of the serialization interface and the C language code of the deserialization interface includes: Obtain and identify an interface in the Android system source code, and assign a corresponding unique label to the interface in the label space; The interface in the Android system source code and the parameters of the interface are saved as an intermediate file in the form of a Bluetooth interface definition language; The Java code of the serialization interface and the C language code of the deserialization interface are generated according to the predetermined parameter serialization rules and the interface and interface parameters saved in the form of the intermediate file.
3. The method for automatically adapting the Bluetooth interface in the Android system according to claim 2, characterized in that: The obtaining and identifying the interface in the Android system source code and assigning a corresponding unique label to the interface in the label space includes: The interface and interface parameters in the Android system source code are extracted by taking the native keyword in the Java language, the Java Bluetooth package name, the jniRegisterNativeMethods keyword and the corresponding class path in the jniRegisterNativeMethods, and the JNINativeMethod signature list as feature values.
4. The method for automatically adapting the Bluetooth interface in the Android system according to claim 2, characterized in that: The method of generating the Java code of the serialization interface and the C language code of the deserialization interface according to the predetermined parameter serialization rule and the interface and interface parameters saved in the form of the intermediate file includes: According to the predetermined parameter serialization rules, the interfaces and interface parameters extracted from the Android system source code are serialized into byte streams, and the byte streamed interfaces and interface parameters are used to generate Java code for the serialized interface and C language code for the deserialized interface.
5. The method for automatic Bluetooth interface adaptation in an Android system according to claim 1, characterized in that: The step of integrating the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and using the process communication channel between the client and the server to implement information interaction between the Java code of the serialization interface and the C language code of the deserialization interface includes: Serializing the Java code of the serialization interface into a control byte stream, and transmitting the control byte stream to the server through a process communication channel; The control byte stream is received at the service end through a process communication channel, and the control byte stream is deserialized into a call to a protocol stack interface of a C language code of the deserialization interface.
6. The method for automatic Bluetooth interface adaptation in an Android system according to claim 1, characterized in that: The step of integrating the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and using the process communication channel between the client and the server to implement information interaction between the Java code of the serialization interface and the C language code of the deserialization interface includes: By implementing the protocol stack interface code in the C language code on the server side, the required protocol stack interface is called.
7. A Bluetooth interface automatic adaptation device in an Android system, characterized in that: include: An information extraction module is used to extract the code of the Java Bluetooth service module corresponding to the Android system source code and the JNI code corresponding to the Java Bluetooth service module; A code generation module, used to generate Java code of a serialization interface and C language code of a deserialization interface by using the code of the Java Bluetooth service module and the JNI code; An information interaction module, used to integrate the Java code of the serialization interface on the client and the C language code of the deserialization interface on the server, and to realize information interaction between the Java code of the serialization interface and the C language code of the deserialization interface by using the process communication channel between the client and the server; A modification module is used to use a code modifier to modify the JNI calling code in the Java Bluetooth service module to an interface of the Java code that calls the serialization interface; and to replace the Java Bluetooth service module in the Android system with the modified Java Bluetooth service module and the C language code of the deserialization interface that communicates with the process.
8. A computer-readable storage medium storing a computer program / instruction, characterized in that: The computer program / instructions are operated to execute the Bluetooth interface automatic adaptation method in the Android system according to any one of claims 1-6.
9. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the Bluetooth interface automatic adaptation method in the Android system according to any one of claims 1-6.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by the processor, the automatic adaptation method of the Bluetooth interface in the Android system as described in any one of claims 1-6 is implemented.
