Cross-platform application running method and device, electronic equipment and storage medium

By receiving the interface call request in the application and establishing a binding relationship with the implementation library of the target device, it solves the problem that the application can only run on specific devices due to differences in device platforms, and realizes the compatibility and functionality of the application on different devices. Isolation reduces development workload and supports compatibility of old and new interfaces.

CN118796498APending Publication Date: 2024-10-18CHINA MOBILE COMM GRP TERMINAL +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311540830.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-17
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

Differences in the hardware platforms of various devices result in applications that can only run on specific devices and cannot be used on other devices.

Method used

By receiving the interface call request of the target application, the response establishes a binding relationship between the pre-developed functional interface library and the implementation library of the target device, and forwards the interface call request to the implementation library based on this relationship to realize the target function and realize the application in different applications. running on the device.

Benefits of technology

It realizes the compatibility of applications on different devices, including support for unknown devices, isolates and decouples the implementation libraries of applications and devices, reduces the development workload, and supports the compatibility of new and old interfaces to facilitate function repair and optimization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118796498A_ABST
    Figure CN118796498A_ABST
Patent Text Reader

Abstract

The invention discloses a cross-platform application running method and device, electronic equipment and a storage medium, and the method comprises the steps: receiving an interface calling request of a target application, the interface calling request being used for requesting to call a target function interface required for realizing a target function; in response to the interface calling request, establishing a binding relationship between a pre-developed functional interface library and an implementation library of target equipment; and based on the binding relationship, forwarding the interface calling request to the implementation library so as to implement the target function through the target device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computing application technology, and in particular to a cross-platform application running method, device, electronic device and storage medium. Background Art

[0002] Generally speaking, applications can obtain corresponding functions by running on devices. For example, in the field of Extended Reality (XR), many mobile devices, customized devices, embedded terminal devices, etc., applications can obtain functions such as augmented reality, virtual reality, and real-time interaction by running on these devices.

[0003] However, the hardware platforms of various devices are different and cannot fully meet the application running requirements, resulting in the application only being able to run on specific devices and unable to run on other devices to obtain corresponding functions. Summary of the invention

[0004] The purpose of the embodiments of the present application is to provide a cross-platform application running method, device, electronic device and storage medium, which are used to solve the problem that the application can only run on a specific device and cannot be used on other devices due to differences in the hardware platforms of the devices.

[0005] In order to achieve the above objectives, the present application embodiment adopts the following technical solutions:

[0006] In a first aspect, an embodiment of the present application provides a cross-platform application running method, including:

[0007] Receiving an interface call request from a target application, wherein the interface call request is used to request to call a target function interface required to implement a target function;

[0008] In response to the interface call request, establishing a binding relationship between a pre-developed functional interface library and an implementation library of a target device;

[0009] Based on the binding relationship, the interface call request is forwarded to the implementation library to implement the target function through the target device.

[0010] In a second aspect, an embodiment of the present application provides a cross-platform application running device, including:

[0011] A receiving unit, used to receive an interface call request of a target application, wherein the interface call request is used to request to call a target function interface required to implement a target function;

[0012] A binding unit, configured to establish a binding relationship between a pre-developed functional interface library and an implementation library of a target device in response to the interface call request;

[0013] A forwarding unit is used to forward the interface call request to the implementation library based on the binding relationship, so as to implement the target function through the target device.

[0014] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a processor; and a memory for storing instructions executable by the processor; wherein the processor is configured to execute the instructions to implement the method described in the first aspect.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium. When instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method described in the first aspect.

[0016] At least one of the above-mentioned technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: based on the fact that each device has a corresponding implementation library, in order to realize the operation of the application on each device, the present application establishes a binding relationship between the pre-developed functional interface library and the implementation library of the target device by receiving the call request of the target application and responding to it; based on the binding relationship, the call request of the target application is forwarded to the implementation library of the target device, so as to realize the target function required by the target application through the target device, and realize the operation of the target application on the target device; since the functional interface library and the implementation library of the target device are bound when the target application is running, the implementation libraries of other devices can be dynamically bound according to needs, so as to realize the operation of the target application on different devices, even if it is an unknown device in the future, if the unknown device has a corresponding implementation library, the target application can also be used in the future It can run on known devices and is well compatible with unknown interfaces. In addition, after establishing a binding relationship between the pre-developed function interface library and the implementation library of the target device, the call request of the target application is forwarded to the implementation library of the target device, so as to implement the target function through the target device, thereby realizing the isolation and decoupling of the target application and the specific function implementation. There is no need to package the implementation library of the target device into the target application, and the target application can also be run on the target device. If there are vulnerabilities in the function implementation, they need to be repaired and optimized. There is no need to perform any operation on the application side. The vulnerability can be repaired and repaired on the target device and the implementation library, and the corresponding vulnerability repair and optimization effects can be achieved. It is well compatible with new and old interfaces, making application function development more convenient. There is no need to develop different versions of applications for unknown devices and new and old devices, thus reducing the development workload. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0018] Figure 1A schematic diagram of a flow chart of a cross-platform application running method provided for one embodiment of the present application;

[0019] Figure 2 A schematic diagram of an application scenario of a cross-platform application running method provided by an embodiment of the present application;

[0020] Figure 3 A schematic diagram of the structure of a cross-platform application running device provided for one embodiment of the present application;

[0021] Figure 4 A schematic diagram of the structure of an electronic device provided for one embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0023] The terms "first", "second", etc. in this specification and claims are used to distinguish similar objects, and are not used to describe a particular order or precedence. It should be understood that the terms used in this way can be interchanged where appropriate so that the embodiments of the present application are implemented in a sequence other than those illustrated or described herein. In addition, "and / or" in this specification and claims means at least one of the connected objects, and the character " / " generally means that the objects associated with each other are in an "or" relationship.

[0024] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.

[0025] See also Figure 1 , is a flow chart of a cross-platform application running method provided by an embodiment of the present application. Figure 1 As shown, an embodiment of the present application provides a cross-platform application running method, which may include the following steps:

[0026] S102: Receive an interface call request from a target application.

[0027] The interface call request is used to request to call the target function interface required to implement the target function.

[0028] The embodiment of the present application receives an interface call request sent by a target application, calls a target function interface according to the call request, and implements a target function required by the target application through the target function interface.

[0029] It should be understood that the target function interface does not include specific function implementations, and the specific function implementations are provided by the implementation library of the device. Specifically, the embodiments of the present application will be explained through the following steps or embodiments.

[0030] S104, in response to the interface call request, establishing a binding relationship between the pre-developed functional interface library and the implementation library of the target device.

[0031] The embodiment of the present application receives an interface call request from a target application, establishes a binding relationship between a pre-developed functional interface library and an implementation library of a target device in response to the interface call request, and generates a response and sends it to the target application.

[0032] Among them, the functional interface library is a pre-developed library containing multiple functional interfaces, which contains a set of interface forwarding architectures. The interface forwarding architecture is a software design pattern that can be used to receive requests from one application or service and forward them to another application or service. The specific implementation of the interface forwarding function will be described in the corresponding embodiments later.

[0033] The device implementation library is a library provided by the device manufacturer and used to drive the device to perform corresponding functions. The implementation library contains specific function implementations or implementation functions.

[0034] In the process of establishing a binding relationship between the pre-developed functional interface library and the implementation library of the target device in response to the interface call request, the implementation library of the target device is loaded, specifically:

[0035] As an optional implementation, the above S104 may include the following steps:

[0036] S140 , in response to the interface call request, obtaining path information of the implementation library based on a configuration file associated with the functional interface library.

[0037] S142, loading the implementation library of the target device based on the path information.

[0038] S144, establishing a binding relationship between the function interface library and the implementation library of the target device.

[0039] The configuration file contains the path information of the pre-configured implementation library of each device and is associated with the pre-developed functional interface library.

[0040] The embodiment of the present application responds to an interface call request by obtaining the path information of the implementation library of the target device from a configuration file, loads the implementation library of the target device according to the path information of the implementation library of the target device, and establishes a binding relationship between the functional interface library and the implementation library of the target device based on the loaded implementation library of the target device.

[0041] The embodiments of the present application generally save the configuration file with the configured path information to the specified path, read the configuration file from the specified path in response to the interface call request, obtain the path information of the implementation library of the target device, load the implementation library of the target device based on the obtained path information, and establish a binding relationship between the functional interface library and the implementation library of the target device based on the loaded implementation library of the target device.

[0042] In the embodiment of the present application, since the configuration file contains the path information of the implementation library of each device, the implementation library of each device can be dynamically loaded according to demand, and a binding relationship can be established with the functional interface library. Based on the interface forwarding function of the functional interface library, the interface call request of the target application is forwarded to the implementation library of the device bound to the functional interface library, thereby enabling the target application to run on each device. For future unknown devices, if the unknown device has an implementation library corresponding to the unknown device, the path of the implementation library of the unknown device is configured to the configuration file. At runtime, the implementation library of the unknown device is loaded through the configuration file and a binding relationship is established with the functional interface library, thereby enabling the target application to run on the unknown device, which can be well compatible with unknown interfaces. , to implement the same functional interface on different platforms, the corresponding implementation library can be called. In addition, the path information of the implementation library of the target device is dynamically obtained through the configuration file, the implementation library of the target device is loaded, and a binding relationship is established with the functional interface library to achieve isolation and decoupling of the target application and the implementation library of the target device. There is no need to package the implementation library of the target device into the target application, and the target application can also be run on the target device. If there are vulnerabilities that need to be repaired and optimized, there is no need to perform any operations on the application side. Vulnerabilities can be repaired and repaired on the target device and implementation library, and the corresponding vulnerability repair and optimization effects can be achieved. It is well compatible with new and old interfaces, making application function development more convenient.

[0043] Specifically, as an optional implementation, in the process of establishing a binding relationship between the pre-developed functional interface library and the implementation library of the target device, the following steps may be specifically included: obtaining, from a function table of the implementation library, a function address of an implementation function required to run the target application in the implementation library;

[0044] Bind the function address to the function pointer in the interface virtual table.

[0045] Among them, the functional interface library includes an interface virtual table, which records function pointers of multiple functional interfaces. The interface virtual table is generated by defining each functional interface and the function pointer of each functional interface when developing the functional interface library. It can be understood as a data structure of each functional interface and the function pointer of each functional interface, and does not contain specific function implementation.

[0046] As an optional implementation method, the embodiment of the present application will initialize the functional interface library and the implementation library based on the implementation library of the loaded target device. For the specific initialization process, please refer to the corresponding embodiments below. At the same time, the implementation function in the implementation library will be exported and written into a predefined function table to obtain the function table of the implementation library, so that the implementation function and the function pointer in the interface virtual table form a corresponding relationship. The function address of the implementation function in the function table is used and bound to the corresponding function pointer, and the corresponding implementation function in the implementation library is subsequently called through the function pointer.

[0047] The embodiment of the present application obtains the function address of the implementation function required to run the target application in the implementation library from the function table of the implementation library, binds the function address to the function pointer in the interface virtual table, thereby binding the implementation function in the implementation library of the target device to the function pointer of the target function interface in the function interface library, and subsequently calls the implementation function corresponding to the function address bound to the target function pointer through the target function pointer of the target function interface, so as to implement the same function interface calling different implementation functions in the implementation library of the target device. Since the function pointer of the function interface and the function address of the implementation function in the implementation library are dynamically bound when the target application is running, if the manufacturer subsequently upgrades the function of the device and the implementation function is updated, it can be done by reloading the implementation library, obtaining the function address of the implementation function through the function table of the updated implementation library, and binding it to the function pointer of the function interface, and can also call the implementation function in the updated implementation library of the target device through the function pointer of the original function interface, which is well compatible with the new and old interfaces, and the code on the application side does not need to be modified, thereby making the function development of the target application more convenient and reducing the maintenance workload of the target application in the later stage.

[0048] S106, forwarding the interface call request to the implementation library based on the binding relationship, so as to implement the target function through the target device.

[0049] After the embodiment of the present application establishes a binding relationship between the function interface library and the implementation library of the target device, based on the binding relationship, the interface forwarding function of the function interface library is used to send the interface call request to the implementation library of the target device, call the corresponding implementation function in the implementation library, and drive the target device by running the implementation function to implement the target function through the target device. It should be understood that due to the interface forwarding function of the function interface library, the target application does not need to know the specific implementation function in the implementation library when actually calling, and can obtain the target function by calling the target function interface, and the specific function implementation of the target function is provided by the implementation library of the target device.

[0050] Based on the fact that each device has a corresponding implementation library, in order to enable the application to run on each device, the present application establishes a binding relationship between the pre-developed functional interface library and the implementation library of the target device by receiving the call request of the target application and responding to it. Based on the binding relationship, the call request of the target application is forwarded to the implementation library of the target device, so as to implement the target function required by the target application through the target device and enable the target application to run on the target device. Since the functional interface library and the implementation library of the target device are bound when the target application is running, the implementation libraries of other devices can be dynamically bound according to needs, so as to enable the target application to run on different devices, even if it is an unknown device in the future, if the unknown device has a corresponding implementation library, the target application can also run on the unknown device, which is well compatible with unknown interfaces. In addition, by establishing a binding relationship between the pre-developed function interface library and the implementation library of the target device, the call request of the target application is forwarded to the implementation library of the target device, so as to implement the target function through the target device, thereby realizing the isolation and decoupling of the target application and the specific function implementation. There is no need to package the implementation library of the target device into the target application, and the target application can be run on the target device. If there are vulnerabilities in the function implementation, they need to be repaired and optimized. There is no need to perform any operations on the application side. The corresponding vulnerability repair and optimization effects can be achieved by repairing and fixing the vulnerabilities on the target device and the implementation library. It is well compatible with new and old interfaces, making application function development more convenient. There is no need to develop different versions of applications for unknown devices and new and old devices, thereby reducing the development workload.

[0051] Specifically, the embodiment of the present application will describe the process of forwarding an interface call request to an implementation library based on a binding relationship to implement a target function through a target device.

[0052] As an optional implementation, the above S106 may include the following steps:

[0053] S160, based on the virtual table index carried in the interface call request, determine the target function pointer of the target functional interface from the interface virtual table.

[0054] S162, calling the target function pointer, forwarding the interface call request to the target function address bound to the target function pointer, so that the target device executes the implementation function corresponding to the target function address to realize the target function.

[0055] The interface virtual table of the functional interface library also includes the correspondence between the virtual table indexes of various functional interfaces and the function pointers. The target function pointer of the target functional interface can be determined from the virtual table through the virtual table index.

[0056] It should be understood that the virtual table index is generated based on the function pointers of each functional interface in the interface virtual table when the functional interface is developed, and is used by the application side to view the target function pointer to be called.

[0057] It should be understood that in the embodiment of the present application, the target application determines the target function interface to be called and the virtual table index corresponding to the target function pointer by checking the correspondence between the virtual table index and the function pointer of each function interface in the interface virtual table, and generates an interface call request for calling the target function interface, which is sent together with the virtual table index of the target function pointer used to determine the target function interface.

[0058] According to the received call request of the target application and the virtual table index carried in the call request, the target function interface is determined from the function interface library, and the target function pointer of the target function interface is determined from the interface virtual table of the function interface library. Based on the binding relationship between the function interface library and the implementation library of the target device, the target function address corresponding to the target function pointer is determined from the function table of the implementation library of the target device. Based on the target function address, the target implementation function corresponding to the target function address is determined from the implementation library of the target device. By calling the target function pointer, the interface call request is forwarded to the implementation function of the target function address pair, so that the target device executes the corresponding implementation function to realize the target function.

[0059] In the embodiment of the present application, based on the virtual table index carried in the interface call request, the target function pointer of the target function interface is determined from the interface virtual table, the target function pointer is called, and the interface call request is forwarded to the target function address bound to the target function pointer, so that the target device executes the implementation function corresponding to the target function address to realize the target function, thereby realizing that the target application calls the function pointer of the target function interface through the virtual table index in the interface virtual table, and calls the implementation function in the implementation library of the target device through the function pointer to realize the target function required by the target application, thereby realizing calling different implementation functions in the implementation library of the target device through the same function interface. Since the function pointer of the function interface and the function address of the implementation function in the implementation library are dynamically bound when the target application is running, if the subsequent manufacturer upgrades the function of the device and the implementation function is updated, it can be done by reloading the implementation library, and the function address of the implementation function is obtained from the function table of the updated implementation library, and bound to the function pointer of the function interface, and the implementation function in the updated implementation library of the target device can also be called through the function pointer of the original function interface. The new and old interfaces are well compatible, and the code on the application side does not need to be modified, thereby making the function development of the target application more convenient and reducing the maintenance workload of the target application in the later stage.

[0060] It should be understood that the process in which the target application calls the target function interface by sending an interface call request also involves data transmission between the target application and the target device or the implementation library of the target device. Specifically, different transmission methods are used for different types of data. The embodiments of the present application will illustrate the data transmission process between the target application and the target device or the implementation library of the target device.

[0061] For data transmission with uncertain parameters, the embodiment of the present application adopts a perfect forwarding method to achieve it, specifically:

[0062] As another optional implementation, when the call request of the target application also carries parameters and a return address, after the above S160, the following steps may be further included: writing the parameters and the return address into a designated stack;

[0063] Based on the jump instruction written in the preset assembly language, jump to the implementation function corresponding to the target function address bound to the target function pointer, so as to control the implementation function corresponding to the target function address to obtain parameters from the specified stack for corresponding logical processing, and return the processed return value to the call point pointed to by the return address.

[0064] The parameters are the parameters required by the target implementation function in the implementation library of the target device to perform corresponding logic processing. The transmission of this type of data has high real-time requirements and the amount is generally not too large.

[0065] The return address is used to return the return value obtained after the target function is executed to the specified call point, and the target application performs corresponding processing based on the return value.

[0066] A stack is a data structure used to store and manage data, following a last-in, first-out interface, where the last element put into the stack is the first to be retrieved. In the embodiment of the present application, the parameters and return address carried by the call request are pushed into a specified stack in a certain order or structure, and the target implementation function can be retrieved from the stack and processed.

[0067] Assembly language is a type of code that can interact directly with hardware. It jumps to the target implementation function based on the jump instruction written in the preset assembly language, controls the target implementation function to obtain parameters from the stack for processing and returns the return value to the call point pointed to by the return address.

[0068] It should be understood that the parameters transmitted in the embodiment of the present application are mainly for a type of data with high real-time requirements, and the application side has high requirements for time control when obtaining the return value. Implementing jumps through assembly language can better control the timeliness of data transmission.

[0069] The embodiment of the present application writes the parameters and the return address into the specified stack, and based on the jump instruction written in the preset assembly language, jumps to the implementation function corresponding to the target function address bound to the target function pointer. When the implementation function corresponding to the target function address is called, there is no need to push the stack through the operating system. The jump instruction controls the implementation function to obtain the parameters from the specified stack for corresponding logical processing, and returns the processed return value to the calling point indicated by the return address. In this way, the transmission of parameters and return values ​​can be controlled autonomously without converting and processing the parameters, just like there is no forwarding process of the intermediate call request, thereby achieving perfect forwarding of parameters and direct calling function implementation of the target application.

[0070] For data transmission with large data volume and low latency, the embodiment of the present application adopts a shared memory approach, specifically:

[0071] As another embodiment, when the call request also carries business data to be processed, after the above S160, the following steps may also be included: connecting to the shared memory preset in the implementation library, and obtaining the memory address of the shared memory mapped to the address space corresponding to the target application;

[0072] The business data to be processed is written into the shared memory through the memory address, so that the implementation function corresponding to the target function address obtains the business data to be processed from the shared memory for corresponding logical processing.

[0073] Among them, shared memory is a mechanism that allows multiple processes or threads to access the same storage area. Each thread or process can update the data in the shared memory through read or write operations and share it with other processes or threads, thereby realizing data sharing and interaction. For details, please refer to the relevant embodiment content below.

[0074] In the embodiment of the present application, a shared memory is preset in the implementation library of the target device, and data sharing and interaction are performed with the implementation library of the target device by connecting to the shared memory of the implementation library.

[0075] It should be understood that in the implementation of this application, the call request also carries business data to be processed, and such business data is mainly for data with low real-time requirements, large data volume, and low latency. When the target application needs to process business data, it can be connected to the shared memory, map the shared memory to the address space corresponding to the target application, obtain the memory address of the storage area mapped in the address space, access the shared memory, and write the business data to be processed carried in the call request into the shared memory, so that the implementation function corresponding to the target function address obtains the business data to be processed from the shared memory for corresponding logical processing.

[0076] The embodiment of the present application realizes the preset shared memory in the connection library, and obtains the memory address of the shared memory mapped to the address space corresponding to the target application. The business data to be processed is written into the shared memory through the memory address, so that the implementation function corresponding to the target function address obtains the business data to be processed from the shared memory for corresponding logical processing, and maps the shared memory to the address space corresponding to the target application to realize the connection between the target application and the shared memory in the implementation library. The business data with large amount of data and low latency can be passed to the implementation library through the write operation, thereby realizing zero-copy data transmission and avoiding waste of computer resources.

[0077] Through the shared memory in the implementation library, the target application's business data to be processed can be transmitted to the target device's implementation library, and the result data obtained after the target implementation function in the target device's implementation library can also be obtained through the shared memory. The details are as follows:

[0078] As another embodiment, after the above S106, the following steps may also be included: connecting to a shared memory preset in the implementation library, and obtaining a memory address of the shared memory mapped to an address space corresponding to the target application, wherein the shared memory contains result data obtained after the implementation function corresponding to the target function address implements the target function;

[0079] The result data is obtained from the shared memory through the memory address, so that the target application performs corresponding processing based on the result data.

[0080] It should be understood that in the implementation of this application, the target application also needs to obtain a large amount of low-latency result data from the implementation side. When the target application needs to obtain the result data for corresponding processing, it can be connected to the shared memory, map the shared memory to the address space corresponding to the target application, access the shared memory by obtaining the memory address of the storage area mapped in the address space, and obtain the result data from the shared memory through a read operation, so that the target application performs corresponding processing according to the obtained result data.

[0081] The embodiment of the present application realizes the preset shared memory in the library through connection, and obtains the memory address of the shared memory mapped to the address space corresponding to the target application. Through the memory address, the result data obtained after the library processing is obtained from the shared memory, that is, the shared memory is mapped to the address space corresponding to the target application, and the connection between the target application and the shared memory in the implementation library is realized. The result data of large data volume and low latency data can be obtained through the read operation, thereby realizing zero-copy data transmission and avoiding waste of computer resources.

[0082] Next, the embodiment of the present application will provide an interface forwarding method, the specific contents are as follows:

[0083] Define the interface: First, you need to define the prototype of the interface function, including the function's parameter list and return value type. This interface will be used as the type of the function pointer.

[0084] Write a dynamic library: implement the interface function as a function in the dynamic library and export the function. The dynamic library can be a shared library file written in a programming language (such as C / C++), such as .so (Linux) or .dll (Windows) format.

[0085] Export function table: Define a function table in the dynamic library to store all exported function addresses. You can use arrays, structures, or other data structures to represent the function table. Each element in the function table corresponds to the address of an interface function.

[0086] Function binding: The application loads the dynamic library at runtime and obtains the address of the export function table in the dynamic library. Then, the interface function is bound to the corresponding function pointer through the function address in the function table.

[0087] Calling an interface function: The application executes the interface function by calling a function pointer. Since the function pointer has been bound to the corresponding function address, the call will be directly forwarded to the corresponding dynamic library function.

[0088] This embodiment of the application will provide a dynamic library initialization method, the specific contents include:

[0089] Loading dynamic libraries: Before using a dynamic library, it needs to be loaded into memory. The operating system searches the dynamic library path, finds and reads the dynamic library file, generates a mapping object, and allocates virtual memory address space to store the mapping object;

[0090] Resolving symbols: After the dynamic library is loaded into memory, the symbols in it need to be resolved, that is, the symbols are associated with the corresponding addresses. Symbols can be function names, variable names, or other global names. The process of resolving symbols usually involves relocation, that is, replacing symbol reference points (such as function call instructions) with the actual addresses of symbols. This process may require multiple components such as dynamic linkers, loaders, and operating system kernels to work together;

[0091] Execute initializer: The initializer is a predefined code that will be executed when the dynamic library is loaded. It can perform some special initialization operations, such as setting global variables, creating threads, opening files, etc. The initializer in the dynamic library can be declared using the __attribute__((constructor)) macro provided by the GCC compiler;

[0092] Ready: Once the symbols of a dynamic library have been resolved and all initializers have been successfully executed, the dynamic library is in a "ready" state and can be used by other programs (such as applications or other dynamic libraries).

[0093] The present application embodiment provides a method for data transmission. The specific contents are as follows:

[0094] First, create shared memory in the implementation library. You need to create a shared memory area that can hold data. Use the interface provided by the operating system (for example, use shmat in Unix / Linux) to create the shared memory area and execute the required size. On Windows and Linux-based systems, you can directly use the system's built-in shared memory. For other situations such as embedded systems, since virtual memory is not involved, you can directly use static memory.

[0095] The created shared memory area is mapped to the address space corresponding to the current process or thread, and then the operating system returns a pointer to the shared memory area, which is the memory address after the shared memory area is mapped to the address space, also called the virtual memory address.

[0096] By mapping the shared memory area to the address space corresponding to the current process or thread, the target application has established a connection with the shared memory of the implementation library. The created shared memory area can be accessed through the pointer returned by the operating system, and the data in the shared memory area can be updated through read or write operations to achieve data sharing and interaction.

[0097] When you no longer need to share data, you can disconnect through the interface provided by the operating system, for example, using shmdt in Unix / Linux. If you want to continue sharing, you need to reconnect.

[0098] It should be understood that if the shared memory is disconnected, the previously created shared memory area still exists, and the target application and other applications can also connect to the shared memory, map the shared memory area to the address space corresponding to other applications, connect, and achieve data sharing and interaction. If multiple applications are connected to access the shared memory at the same time, it is also necessary to pay attention to the processing system of concurrency issues to ensure that multiple applications can perform read or write operations, achieve true data sharing and interaction, and improve the interactive experience of data sharing.

[0099] Transmitting data through shared memory can meet the transmission requirements of large data volumes, low latency, and low real-time requirements. The shared memory is connected when data sharing is needed and disconnected when it is not needed. Different processes or threads only read or write to the same physical storage area, and there is no need to copy data, thus achieving zero-copy data transmission and interaction and avoiding waste of computer resources.

[0100] Next, the present application embodiment will use an actual application scenario to illustrate the cross-platform application running method provided by the present application embodiment, which should not be understood as limiting the method of the present application embodiment. Figure 2 , is an application scenario of a cross-platform application running method provided by an embodiment of the present application. Figure 2 As shown, the actual application scenario of the cross-platform application running method provided in the embodiment of the present application is divided into an application side and a function implementation layer. The application side includes the application to be run, the function interface library, and the configuration file. The function implementation layer is the implementation library of each device. In this application scenario, the application on the application side implements the target function required by the application through the function interface in the function interface library by sending a call request to the function interface library. Since the function interface in the function interface library is developed using a custom interface virtual table, the function interface does not contain a specific function implementation. The specific function implementation is provided by the implementation library of each device in the function implementation layer.

[0101] Among them, the functional interface library is a library of various pre-developed functional interfaces. The functional interface is provided in the form of a C library, which contains a set of interface forwarding architectures that can obtain requests from the application and forward them to the implementation library of the device.

[0102] The configuration file contains the path information of the implementation library of each device, which is associated with the functional interface library and stored in the specified path.

[0103] The target application sends a call request to the function interface library, and calls the target function interface in the function interface library to implement the target function.

[0104] The function interface library receives the call request of the target application, reads the configuration file from the specified path, obtains the path information from the configuration file, loads the implementation library of the target device according to the path information, establishes a binding relationship between the function interface library and the implementation library of the target device, and forwards the call request to the implementation library of the target device through the target function interface based on the interface forwarding function of the function interface library.

[0105] After receiving the call request, the implementation library of the target device runs the corresponding implementation function in the implementation library to implement the target function of the target application through the target device.

[0106] Based on the fact that each device has a corresponding implementation library, in order to realize the application running on each device, by receiving the call request of the target application and responding, a binding relationship is established between the pre-developed functional interface library and the implementation library of the target device. Based on the binding relationship, the call request of the target application is forwarded to the implementation library of the target device, so as to realize the target function required by the target application through the target device, and realize the target application running on the target device. Since the functional interface library and the implementation library of the target device are bound when the target application is running, the implementation libraries of other devices can be dynamically bound according to needs, so as to realize the target application running on different devices, even if it is an unknown device in the future, if the unknown device has a corresponding implementation library, the target application can also run on the unknown device, which is very compatible with unknown interfaces. In addition, by establishing a binding relationship between the pre-developed function interface library and the implementation library of the target device, the call request of the target application is forwarded to the implementation library of the target device to implement the target function through the target device, thereby achieving isolation and decoupling of the target application and the specific function implementation. There is no need to package the implementation library of the target device into the target application, and the target application can be run on the target device. If there are vulnerabilities in the function implementation and they need to be repaired and optimized, there is no need to perform any operations on the application side. The corresponding vulnerability repair and optimization effects can be achieved by repairing and fixing the vulnerabilities on the target device and the implementation library. It is well compatible with new and old interfaces, making application function development more convenient. There is no need to develop different versions of applications for unknown devices and new and old devices, thus reducing the development workload.

[0107] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0108] With the above Figure 1 Corresponding to the cross-platform application running method shown, the present application embodiment also proposes a cross-platform application running device. Figure 3 , is a structural diagram of a cross-platform application running device 300 provided in an embodiment of the present application. The device 300 includes: a receiving unit 310, a binding unit 320, and a forwarding unit 330.

[0109] The receiving unit 310 is used to receive an interface call request of a target application, wherein the interface call request is used to request to call a target function interface required to implement a target function;

[0110] The binding unit 320 is used to establish a binding relationship between the pre-developed functional interface library and the implementation library of the target device in response to the interface call request;

[0111] The forwarding unit 330 is used to forward the interface call request to the implementation library based on the binding relationship, so as to implement the target function through the target device.

[0112] Optionally, when the binding unit 320 establishes a binding relationship between the pre-developed function interface library and the implementation library of the target device in response to the interface call request, the following steps may be performed: in response to the interface call request, acquiring path information of the implementation library based on a configuration file associated with the function interface library, the configuration file including path information of the implementation library of each device pre-configured;

[0113] Based on the path information, loading the implementation library of the target device;

[0114] A binding relationship is established between the functional interface library and the implementation library of the target device.

[0115] Optionally, in the case where the function interface library includes an interface virtual table, and the interface virtual table records function pointers of multiple function interfaces, the binding unit 320 may perform the following steps when establishing a binding relationship between the pre-developed function interface library and the implementation library of the target device: acquiring, from the function table of the implementation library, a function address of an implementation function required to run the target application in the implementation library;

[0116] The function address is bound to the function pointer in the interface virtual table.

[0117] Optionally, in the case where the interface virtual table includes a correspondence between virtual table indexes and function pointers of multiple functional interfaces, and the interface call request carries the virtual table index of the target functional interface, the forwarding unit 330 may perform the following steps when forwarding the interface call request to the implementation library based on the binding relationship to implement the target function through the target device: determining the target function pointer of the target functional interface from the interface virtual table based on the virtual table index carried in the interface call request;

[0118] The target function pointer is called, and the interface call request is forwarded to the target function address bound to the target function pointer, so that the target device executes the implementation function corresponding to the target function address to realize the target function.

[0119] Optionally, when the call request also carries parameters and a return address specified by the target application, the apparatus 300 further includes:

[0120] A writing unit is used to perform the following steps after the forwarding unit 330 determines the target function pointer of the target functional interface from the interface virtual table based on the virtual table index carried in the interface call request: write the parameter and the return address into a specified stack;

[0121] Based on the jump instruction written in the preset assembly language, jump to the implementation function corresponding to the target function address bound to the target function pointer, so as to control the implementation function corresponding to the target function address to obtain the parameters from the specified stack for corresponding logical processing, and return the processed return value to the calling point pointed to by the return address.

[0122] Optionally, when the call request also carries service data to be processed, the apparatus 300 further includes:

[0123] The acquisition unit is used to perform the following steps after the forwarding unit 330 determines the target function pointer of the target functional interface from the interface virtual table based on the virtual table index carried in the interface call request: connect the shared memory preset in the implementation library, and obtain the memory address mapped from the shared memory to the address space corresponding to the target application;

[0124] The business data to be processed is written into the shared memory through the memory address, so that the implementation function corresponding to the target function address obtains the business data to be processed from the shared memory to perform corresponding logic processing.

[0125] Optionally, the acquisition unit is further configured to, after the forwarding unit 330 forwards the interface call request to the implementation library based on the binding relationship so as to implement the target function through the target device, perform the following steps: connect to a shared memory preset in the implementation library, and obtain a memory address of the shared memory mapped to an address space corresponding to the target application, wherein the shared memory contains result data obtained after the implementation function corresponding to the target function address implements the target function;

[0126] The result data is obtained from the shared memory through the memory address, so that the target application performs corresponding processing based on the result data.

[0127] Obviously, the cross-platform application running device provided in the embodiment of the present application can be used as Figure 1 The execution body of the cross-platform application running method shown is, for example Figure 1 In the cross-platform application running method shown in FIG. 1 , step S102 may be performed by Figure 3 The receiving unit 310 in the cross-platform application running device shown in FIG. 1 is executed, and step S104 can be performed by Figure 3The binding unit 320 in the cross-platform application running device shown in FIG. 1 is executed, and step S106 can be performed by Figure 3 The forwarding unit 330 in the cross-platform application running device is shown to execute.

[0128] According to another embodiment of the present application, Figure 3 The various units in the cross-platform application running device shown can be separately or completely combined into one or several other units to constitute, or one (some) of the units can be further divided into multiple functionally smaller units to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In practical applications, the functions of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, the cross-platform application running device may also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0129] According to another embodiment of the present application, the program can be executed on a general computing device such as a computer including a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and other processing elements and storage elements. Figure 1 A computer program (including program code) for each step involved in the corresponding method shown in FIG. Figure 3 The cross-platform application running device shown in and the cross-platform application running method of the embodiment of the present application are implemented. The computer program can be recorded on, for example, a computer-readable storage medium, and transferred to an electronic device through the computer-readable storage medium and run therein.

[0130] Figure 4 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 4 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.

[0131] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0132] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.

[0133] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a data processing device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:

[0134] Receiving an interface call request from a target application, wherein the interface call request is used to request to call a target function interface required to implement a target function;

[0135] In response to the interface call request, establishing a binding relationship between a pre-developed functional interface library and an implementation library of a target device;

[0136] Based on the binding relationship, the interface call request is forwarded to the implementation library to implement the target function through the target device.

[0137] The above application Figure 3The method executed by the cross-platform application running device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present application can be directly embodied as being executed by a hardware decoding processor, or executed by a combination of hardware and software modules in a decoding processor. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.

[0138] The electronic device may also perform Figure 1 The method and the cross-platform application running device are implemented in Figure 3 , Figure 1 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.

[0139] Of course, in addition to software implementation methods, the electronic device of the present application does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc. That is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.

[0140] The embodiment of the present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by a portable electronic device including a plurality of application programs, enable the portable electronic device to execute Figure 1 The method of the embodiment shown is specifically used to perform the following operations:

[0141] Receiving an interface call request from a target application, wherein the interface call request is used to request to call a target function interface required to implement a target function;

[0142] In response to the interface call request, establishing a binding relationship between a pre-developed functional interface library and an implementation library of a target device;

[0143] Based on the binding relationship, the interface call request is forwarded to the implementation library to implement the target function through the target device.

[0144] In short, the above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0145] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0146] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0147] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0148] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

Claims

1. A cross-platform application running method, characterized in that: include: Receiving an interface call request from a target application, wherein the interface call request is used to request to call a target function interface required to implement a target function; In response to the interface call request, establishing a binding relationship between a pre-developed functional interface library and an implementation library of a target device; Based on the binding relationship, the interface call request is forwarded to the implementation library to implement the target function through the target device.

2. The method according to claim 1, characterized in that The step of establishing a binding relationship between a pre-developed functional interface library and an implementation library of a target device in response to the interface call request includes: In response to the interface call request, acquiring path information of the implementation library based on a configuration file associated with the functional interface library, the configuration file including path information of the implementation library of each device pre-configured; Based on the path information, loading the implementation library of the target device; A binding relationship is established between the functional interface library and the implementation library of the target device.

3. The method according to claim 1, characterized in that The functional interface library includes an interface virtual table, and the interface virtual table records function pointers of multiple functional interfaces; The step of establishing a binding relationship between the pre-developed functional interface library and the implementation library of the target device includes: Obtaining, from a function table of the implementation library, a function address of an implementation function in the implementation library required to run the target application; The function address is bound to the function pointer in the interface virtual table.

4. The method according to claim 3, characterized in that The interface virtual table includes the correspondence between virtual table indexes of multiple functional interfaces and function pointers, and the interface call request carries the virtual table index of the target functional interface; The forwarding the interface call request to the implementation library based on the binding relationship to implement the target function through the target device includes: Determine the target function pointer of the target functional interface from the interface virtual table based on the virtual table index carried in the interface call request; The target function pointer is called, and the interface call request is forwarded to the target function address bound to the target function pointer, so that the target device executes the implementation function corresponding to the target function address to realize the target function.

5. The method according to claim 4, characterized in that The call request also carries parameters and a return address specified by the target application; After determining the target function pointer of the target functional interface from the interface virtual table based on the virtual table index carried in the interface call request, the method further includes: Writing the parameters and the return address into a specified stack; Based on the jump instruction written in the preset assembly language, jump to the implementation function corresponding to the target function address bound to the target function pointer, so as to control the implementation function corresponding to the target function address to obtain the parameters from the specified stack for corresponding logical processing, and return the processed return value to the calling point pointed to by the return address.

6. The method according to claim 4, characterized in that The call request also carries business data to be processed; After determining the target function pointer of the target functional interface from the interface virtual table based on the virtual table index carried in the interface call request, the method further includes: Connecting to the shared memory preset in the implementation library, and obtaining the memory address of the shared memory mapped to the address space corresponding to the target application; The business data to be processed is written into the shared memory through the memory address, so that the implementation function corresponding to the target function address obtains the business data to be processed from the shared memory to perform corresponding logic processing.

7. The method according to claim 4, characterized in that After forwarding the interface call request to the implementation library based on the binding relationship so as to implement the target function through the target device, the method further includes: Connecting to the shared memory preset in the implementation library, and obtaining the memory address of the shared memory mapped to the address space corresponding to the target application, wherein the shared memory contains the result data obtained after the implementation function corresponding to the target function address implements the target function; The result data is obtained from the shared memory through the memory address, so that the target application performs corresponding processing based on the result data.

8. A cross-platform application running device, characterized in that: include: A receiving unit, used to receive an interface call request of a target application, wherein the interface call request is used to request to call a target function interface required to implement a target function; A binding unit, configured to establish a binding relationship between a pre-developed functional interface library and an implementation library of a target device in response to the interface call request; A forwarding unit is used to forward the interface call request to the implementation library based on the binding relationship, so as to implement the target function through the target device.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method as claimed in any one of claims 1 to 7.