CN113326078A - Method, equipment and storage medium for dynamically updating software development kit - Google Patents

Method, equipment and storage medium for dynamically updating software development kit Download PDF

Info

Publication number
CN113326078A
CN113326078A CN202110672436.5A CN202110672436A CN113326078A CN 113326078 A CN113326078 A CN 113326078A CN 202110672436 A CN202110672436 A CN 202110672436A CN 113326078 A CN113326078 A CN 113326078A
Authority
CN
China
Prior art keywords
plug
target
host application
file
application program
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110672436.5A
Other languages
Chinese (zh)
Inventor
郭树霞
舒玉强
雷声伟
李薇
蔡志杰
陈洁丹
卢道和
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202110672436.5A priority Critical patent/CN113326078A/en
Publication of CN113326078A publication Critical patent/CN113326078A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/445Program loading or initiating
    • G06F9/44521Dynamic linking or loading; Link editing at or after load time, e.g. Java class loading
    • G06F9/44526Plug-ins; Add-ons

Abstract

The application provides a method, equipment and computer readable storage medium for dynamically updating a software development kit, wherein the method comprises the following steps: when the host application program is started, determining that a target plug-in included in a software development kit corresponding to the host application program of the tool development end is updated; copying the updated target plug-in to the engineering directory of the host application program; the loading mechanism of the class is changed through the hook, the class of the target plug-in is loaded in the host application program based on the changed loading mechanism, and the method of calling the class of the target plug-in is reflected, so that the target plug-in is realized.

Description

Method, equipment and storage medium for dynamically updating software development kit
Technical Field
The embodiment of the application relates to the technical field of data processing of financial technology (Fintech), and relates to but is not limited to a method, equipment and a computer-readable storage medium for dynamically updating a software development kit.
Background
With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually changing to financial technology (Fintech), however, the financial technology also puts higher demands on the technology due to the requirements of security and real-time performance of the financial industry.
In the field of financial technology, various information can be directly displayed to a user through various application programs on a mobile terminal, and a common way for displaying information to the user through the application programs is to embed a Software Development Kit (SDK) into an application as a whole. The update of the SDK needs to be performed through the component linker, and each time the update needs to generate a patch, there is a possibility that the patch synthesis fails, and the rollback to the old version increases the cost. The existing SDK updating mode is to update the SDK by decompressing, repackaging and copying a dex file or a so file.
However, this updating method is not only cumbersome, but also is prone to have an abnormality in the process of operating the file, such as a sudden exit of the program or a power failure of the device, which may cause a failure in writing the file.
Disclosure of Invention
Embodiments of the present application provide a method, a device, and a computer-readable storage medium for dynamically updating a software development kit, so as to solve a problem that an update failure is easily caused in a manner of updating an SDK by copying a dex file or a so file in the related art.
The technical scheme of the embodiment of the application is realized as follows:
the embodiment of the application provides a method for dynamically updating a software development kit, which comprises the following steps:
when a host application program is started, determining that a target plug-in included in a software development kit corresponding to the host application program at a tool development end is updated;
copying the updated target plug-in to the engineering directory of the host application program;
changing a loading mechanism of a class through a hook, loading the class of the target plug-in the host application program based on the changed loading mechanism, and reflecting a method for calling the class of the target plug-in to realize the target plug-in.
An embodiment of the present application provides an apparatus, including:
a memory for storing executable instructions; a processor, when executing executable instructions stored in the memory, implements the method described above.
Embodiments of the present application provide a computer-readable storage medium storing executable instructions for causing a processor to implement the above-mentioned method when executed.
The embodiment of the application has the following beneficial effects:
when a host application program is started, determining that a target plug-in included in a software development kit corresponding to the host application program of a tool development end is updated; copying the updated target plug-in to the engineering directory of the host application program; changing a loading mechanism of the class through a hook, loading the class of the target plug-in a host application program based on the changed loading mechanism, and reflecting a method for calling the class of the target plug-in to realize the target plug-in; therefore, the method for updating the SDK by packaging and copying the dex file of the plug-in is abandoned, the plug-in updating of the SDK is achieved, the probability of file operation failure is reduced, the SDK can be split into a plurality of plug-ins, and therefore the plug-ins can be updated as fine as possible, namely the SDK is updated by adopting the plug-in updating mode under the condition that a certain plug-in is updated, and therefore the flow of downloading the plug-ins and the time for integrating the plug-ins are saved.
Drawings
FIG. 1 is a schematic diagram of a multithreading concurrency scenario provided by an embodiment of the present application;
FIG. 2 is an alternative flow chart diagram of a method for dynamically updating a software development kit according to an embodiment of the present application;
FIG. 3 is an alternative flow chart diagram of a method for dynamically updating a software development kit according to an embodiment of the present application;
fig. 4 is a schematic diagram of an alternative architecture of an access control face-brushing SDK provided in an embodiment of the present application;
fig. 5 is a schematic diagram of a plug-in update scene corresponding to the method for dynamically updating a software development kit according to the embodiment of the present application;
FIG. 6 is an alternative flow diagram of a method for dynamically updating a software development kit according to an embodiment of the present application;
FIG. 7 is a schematic diagram of a class loader loading new host dexElements according to an embodiment of the present disclosure;
FIG. 8 is an alternative flow diagram of a method for dynamically updating a software development kit provided by an embodiment of the present application;
fig. 9 is an alternative flowchart of a method for dynamically updating a software development kit according to an embodiment of the present application.
Detailed Description
In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be described in further detail with reference to the attached drawings, the described embodiments should not be considered as limiting the present application, and all other embodiments obtained by a person of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or different subsets of all possible embodiments, and may be combined with each other without conflict. Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the embodiments of the present application belong. The terminology used in the embodiments of the present application is for the purpose of describing the embodiments of the present application only and is not intended to be limiting of the present application.
An exemplary application of the device for dynamically updating the software development kit according to the embodiment of the present application is described below, and the device for dynamically updating the software development kit according to the embodiment of the present application may be implemented as any terminal having an on-screen display function, such as a laptop computer, a tablet computer, a desktop computer, a mobile device (e.g., a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, and a portable game device), an intelligent robot, and the like, and may also be implemented as a server. Next, an exemplary application when the apparatus for dynamically updating the software development kit is implemented as a terminal will be described.
Referring to fig. 1, fig. 1 is a schematic structural diagram of a terminal 100 according to an embodiment of the present application, where the terminal 100 shown in fig. 1 includes: at least one processor 110, at least one network interface 120, a user interface 130, and memory 150. The various components in terminal 100 are coupled together by a bus system 140. It is understood that the bus system 140 is used to enable connected communication between these components. The bus system 140 includes a power bus, a control bus, and a status signal bus in addition to a data bus. For clarity of illustration, however, the various buses are labeled as bus system 140 in fig. 1.
The Processor 110 may be an integrated circuit chip having Signal processing capabilities, such as a general purpose Processor, a Digital Signal Processor (DSP), or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like, wherein the general purpose Processor may be a microprocessor or any conventional Processor, or the like.
The user interface 130 includes one or more output devices 131, including one or more speakers and/or one or more visual display screens, that enable the presentation of media content. The user interface 130 also includes one or more input devices 132 including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.
The memory 150 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, and the like. Memory 150 optionally includes one or more storage devices physically located remotely from processor 110. The memory 150 includes volatile memory or nonvolatile memory, and may include both volatile and nonvolatile memory. The nonvolatile Memory may be a Read Only Memory (ROM), and the volatile Memory may be a Random Access Memory (RAM). The memory 150 described in embodiments herein is intended to comprise any suitable type of memory. In some embodiments, memory 150 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplified below.
An operating system 151 including system programs for processing various basic system services and performing hardware-related tasks, such as a framework layer, a core library layer, a driver layer, etc., for implementing various basic services and processing hardware-based tasks;
a network communication module 152 for communicating to other computing devices via one or more (wired or wireless) network interfaces 120, exemplary network interfaces 120 including: bluetooth, wireless compatibility authentication (WiFi), and Universal Serial Bus (USB), etc.;
an input processing module 153 for detecting one or more user inputs or interactions from one of the one or more input devices 132 and translating the detected inputs or interactions.
In some embodiments, the apparatus provided by the embodiments of the present application may be implemented in software, and fig. 1 shows an apparatus 154 for dynamically updating a software development kit stored in the memory 150, where the apparatus 154 for dynamically updating a software development kit may be an apparatus for dynamically updating a software development kit in the terminal 100, and may be software in the form of programs and plug-ins, and includes the following software modules: processing module 1541, and retrieving module 1542, which are logical and therefore arbitrarily combined or further divided according to the implemented functions. The functions of the respective modules will be explained below.
In other embodiments, the apparatus provided in the embodiments of the present Application may be implemented in hardware, and for example, the apparatus provided in the embodiments of the present Application may be a processor in the form of a hardware decoding processor, which is programmed to execute the method for dynamically updating a software development kit provided in the embodiments of the present Application, for example, the processor in the form of the hardware decoding processor may be implemented by one or more Application Specific Integrated Circuits (ASICs), DSPs, Programmable Logic Devices (PLDs), Complex Programmable Logic Devices (CPLDs), Field Programmable Gate Arrays (FPGAs), or other electronic components.
The method for dynamically updating the software development kit provided by the embodiment of the present application will be described below in conjunction with an exemplary application and implementation of the terminal 100 provided by the embodiment of the present application. Referring to fig. 2, fig. 2 is an alternative flowchart of a method for dynamically updating a software development kit according to an embodiment of the present application, which will be described in conjunction with the steps shown in fig. 2,
step S201, when the host application is started, determining that the target plug-in included in the software development kit corresponding to the tool development end host application is updated.
According to the method for dynamically updating the software development kit, the modules are split in the finest granularity based on the componentized framework idea, all the component modules are made into plug-ins, and the software development kit SDK is updated in the plug-ins manner. Here, the componentization and the plug-in are explained, the componentization refers to dividing an Application (APP) into a plurality of code modules, each of which is a component (Module), and during the development, the components can be interdependent or a part of the components can be debugged separately, but when the components are finally released, the components are merged into an Android Application Package (APK). The plug-in is to split the whole APP into a plurality of functional modules, the functional modules include a host and a plurality of plug-ins, each functional module is an APK, and the host APK and the plug-ins APK are packaged separately or jointly during final packaging.
In this embodiment of the present application, in step S201, when the host application is started, it is determined that the target plug-in included in the software development kit corresponding to the tool development end host application is updated, and the following steps are performed:
firstly, when a host application program is started, acquiring the version number of the same plug-in of a local plug-in and a cloud terminal;
and secondly, when a target association relationship exists between the version number corresponding to the same plugin locally and the version number corresponding to the cloud, determining that the same plugin is updated, wherein the target plugin comprises the same plugin.
For example, if the terminal determines that the version number of the same plug-in locally corresponds to be smaller than the version number of the same plug-in corresponding to the cloud, the terminal determines that a target association relationship exists between the version number of the same plug-in locally corresponding to the version number of the same plug-in and the version number of the same plug-in corresponding to the cloud, and at this time, it is determined that the plug-in is updated.
In practical applications, the SDK includes each plug-in with a name and version number. When the plug-in is updated, the plug-in to be updated exists in the cloud, and the version number of the plug-in is detected to determine whether to download the plug-in for updating when the host application program is started every time. If so, the terminal replaces the plug-in after downloading is successful.
In addition, in order to improve the flexibility, the target plug-in included in the software development kit corresponding to the tool development end host application program is determined to be updated, and the method can also be realized by the following steps:
when a host application program is started, acquiring the latest updating time of the local plug-in;
and if the time length of the latest updating time and the current time is greater than the preset time length, determining the plug-in as a target plug-in, and thinning the target plug-in from the cloud. The current time may be understood as the time when the host application starts.
It can be understood that, by the above-mentioned method, when the plug-in is updated, the update is performed according to the local update time length in addition to the version number, so as to achieve the flexibility of updating the target plug-in.
And step S202, copying the updated target plug-in to the project directory of the host application program.
In the embodiment of the application, when the terminal determines that an updated target plug-in exists in a local plug-in at the cloud, the updated target plug-in is copied to the engineering directory of the host application program, so that the step of updating the SDK in a plug-in mode is executed subsequently.
Step S203, the loading mechanism of the class is changed through the hook, the class of the target plug-in is loaded in the host application program based on the changed loading mechanism, and the method of calling the class of the target plug-in is reflected, so that the target plug-in is realized.
The method comprises the steps that a host application program is an APK installed and operated, when a JVM of an android system loads a dex file of the host application program, a method for calling a class of the host application program can be called, the host application program needs to call a method of a plug-in unit for realizing the function of the plug-in unit, the class of a target plug-in unit is loaded in the host application program through a changed loading mechanism, the method for calling the class of the target plug-in unit is reflected, and the target plug-in unit can realize the target plug-in unit, so that the target plug-in unit can execute the methods of the classes.
In the embodiment of the application, the downloaded updated target plug-in is a new plug-in, and the SDK performs hook (hook) android system bottom code in a reflection mode. According to the class loading process of a Java Virtual Machine (JVM) of an android system, after a class loader is acquired in a host application program, a class loading object is changed, dex in an updated target plug-in apk is inserted into an executable file array dexElements of the host application program to run the updated target plug-in apk, and therefore the method that the host application program can call the updated target plug-in is achieved.
Here, the implementation process of changing the object loaded by the Class is further described, in the embodiment of the present application, when the loading mechanism of the Class is changed by hook, the implementation may be realized by calling basedexclassloader. When the host program is started, the JVM automatically loads the dex file of the host, all the dex files of the host are in the dexElements of the host at the moment, and the class and the method of the host can be directly called. But the class dex file of the plug-in is not in the dexElements of the host, so the class of the plug-in cannot be called directly. Because the dexElements are arrays, the application proposes to load the classes of the hook host in a reflection mode, specifically, the dexElements of the host and the dexElements of the plug-in are obtained and combined to generate a new dexElements, and the host is enabled to load the new dexElements, so that the plug-in and the dex of the host are loaded into the host, and the change of the objects of class loading is realized.
When the SDK is updated at present, a differential upgrading mode of the SDK is adopted, plug-in differential processing is required to be carried out through a cloud issuing platform and plug-in restoring processing is required to be carried out at an application terminal of a tool, and dynamic updating of the plug-ins is required to be carried out by relying on a component linker. In addition, the plug-in patch is updated by decompressing, repackaging and copying the file, and the updating mechanism is complicated; copying the dex file or the so file to update the SDK is very problematic, resulting in an update failure. However, the application area just abandons the way of updating the SDK by packaging and copying the dex file of the plug-in, so that the plug-in updating the SDK is realized, the probability of file operation failure is reduced, and the plug-in can be updated as fine as possible, so that the flow of downloading the plug-in and the time for integrating the plug-in are saved.
According to the method for dynamically updating the software development kit, when the host application program is started, the target plug-in included in the software development kit corresponding to the host application program of the tool development end is determined to be updated; copying the updated target plug-in to the engineering directory of the host application program; changing a loading mechanism of the class through a hook, loading the class of the target plug-in a host application program based on the changed loading mechanism, and reflecting a method for calling the class of the target plug-in to realize the target plug-in; therefore, the method for updating the SDK by packaging and copying the dex file of the plug-in is abandoned, the plug-in updating the SDK is realized, the probability of file operation failure is reduced, the plug-in can be updated with fine granularity as far as possible, the flow of the plug-in and the time for integrating the plug-in are saved, and the maintenance cost is reduced.
Of course, in other embodiments of the present application, the entire SDK may be divided into one plug-in or a small number of plug-ins. The SDK can be updated in a plug-in mode through the dividing mode, but compared with a fine-grained splitting module and a plug-in mode of making all component modules, the SDK is updated at a side length, and consumption processes are increased.
In some embodiments, in step S201, when the host application is started, before it is determined that the target plug-in included in the software development kit corresponding to the tool development end host application is updated, the host application may be obtained through the steps shown in fig. 3:
step S301, acquiring a software development kit issued by a tool development end.
The software development kit comprises a binary archive file and at least two plug-ins, wherein the at least two plug-ins comprise a target plug-in. Here, the binary archive file includes an aar file, which provides an interface for the terminal to call at least two plug-ins.
Step S302, copying the binary archive file and at least two plug-ins to the project directory of the application program.
Step S303, calling an interface in the binary archive file through the application program, and integrating at least two plug-ins to obtain a host application program.
Here, the terminal copies the binary archive file and the at least two plug-ins to the engineering directory of the application program, the terminal calls an interface in the aar file through the application program, the at least two plug-ins are integrated, and a host application program is obtained, wherein the host application program is a method for calling the class of the host application program by installing and running an APK, and the dex file of the host application program is loaded by the JVM of the android system, and the host application program needs to call the plug-ins to realize the function of the plug-ins.
For example, referring to fig. 4, taking updating an access control face-brushing SDK as an example, the architecture of the access control face-brushing SDK is shown in fig. 4, where an access control face-brushing SDK401 is composed of an aar file 402 and a plurality of plug-ins 403, and different functions are made into plug-ins by using a plug-in update SDK. Illustratively, the access control face-brushing SDK includes an initialization plug-in, a face recognition plug-in, a detail reporting plug-in, a task issuing plug-in, a network request plug-in, an android local Database such as a WeChat Database (WCDB) Database plug-in, an Artificial Intelligence (AI) algorithm face detection plug-in, an AI algorithm infrared living plug-in, an AI algorithm rephotography living plug-in, an AI algorithm face retrieval plug-in, a standard (normal) public library plug-in, a data analysis reporting plug-in, a log library plug-in, and a camera library plug-in. When the terminal loads the plug-in, a dex file and a so file are needed, and the plug-in is an APK and contains the dex file, the so file and a resource file. The terminal downloads the flow required by the new plug-in and loads the size of the plug-in package, and the function is made into a plurality of plug-ins. When a bug or a certain plug-in is upgraded, the terminal finds the corresponding plug-in from the cloud end to be updated, and other plug-ins do not need to be updated, so that the flow consumption can be greatly reduced by downloading new plug-ins by the terminal. The division of a plurality of plug-ins adopts a modular architecture scheme, so that each module is divided into independent plug-ins with the smallest granularity as possible. Here, aar is a shell for calling the SDK method to start the SDK, so that the terminal can better access the cloud SDK.
The application provides a mode of plug-in updating of an entrance guard face brushing SDK, and provides an aar file and a plurality of plug-ins. Because the entrance guard face-brushing SDK comprises a plurality of modules, especially a plurality of sets of algorithm model files are very large, the entrance guard face-brushing SDK consumes a large amount of flow if the SDK is updated according to the copied dex file or so file, and especially if a plurality of entrance guard devices are internet of things, the flow is high in requirement. Therefore, the method and the device provide a modular architecture idea, and the module is split into a plurality of plug-ins to update the access control face-brushing SDK with the granularity as fine as possible, so that the flow of plug-ins downloading and the plug-in loading time are saved. When the entrance guard face brushing SDK needs to be upgraded, the plug-in of the entrance guard face brushing SDK end is issued to the equipment end for dynamic updating. When the terminal is integrated, the aar and all the plug-ins are copied to an engineering directory, and the access control face brushing can be realized by calling an interface provided in the aar of the SDK. The principle of realizing the updating of the door access face-brushing SDK in a plug-in mode is that according to the principle of loading android JM types and reading system bottom source codes, a host application program loads a dex file of an updated plug-in, and then the host application program can call the type of the updated plug-in and a method thereof.
In some embodiments, the step S202 of copying the updated target plug-in into the engineering directory of the host application may be implemented by the following steps: and loading the executable file and the dynamic library file of the virtual machine contained in the updated target plug-in into the project directory. The executable file of the virtual machine comprises a dex file, and the dynamic library file comprises a so file.
For example, referring to fig. 5, in an implementation plug-in update scenario, the tool development side 501, also called SDK side, updates a plug-in and pushes the updated plug-in to the cloud 502, and the user terminal 503 obtains the updated plug-in from the cloud and implements the plug-in on the terminal side.
Here, the name of each plug-in is used to identify different plug-ins, each plug-in has a version number inside, and is stored in a text document (TXT) inside the APK. When the SDK end updates the plug-in, the new plug-in is pushed to the cloud. When the application of the user terminal is started each time, the cloud end is requested to check whether a new plug-in exists. The comparison method comprises the following steps: finding a plug-in with the same name as the cloud plug-in at the terminal, and comparing whether the version numbers of the plug-ins and the cloud plug-ins are the same or not so as to determine whether the cloud plug-ins are downloaded or not; if the plug-in with the same name is not found, the plug-in is not required to be updated. The downloaded new plug-in can be uniformly placed at the position of the original old plug-in for replacement, the plug-in can select a Secure Digital Memory Card (SD) or a built-in Memory, and the SDK selects the inside of the application program by the access control face swiping, so that the content of the SD Card is prevented from being deleted by the user carelessly. If the download fails, the plug-in naturally leaves the old plug-in unaffected, as is the plug-in version number.
The plug-in is the APK, i.e. the compressed package, which contains dex, libs, res. The dex stores a compiled class binary byte code file, a front-end resource (assets) file storage algorithm model library, a libs storage so library and a res storage resource file. The entrance guard refreshes the face SDK without resource files such as interfaces, so the res directory is empty. The APK after the entrance guard refreshes the face SDK is integrated on the user terminal, and the user terminal is called a host. The host is to install the running APK, and the JVM of the android system loads the dex file of the host so as to call the method of the class of the host. And the host has to call a method of the plug-in the SDK to realize the face brushing function of the entrance guard. The plug-in is also an APK, is copied into a project as part of the SDK and is an uninstalled APK, so that the host is a method which cannot call the class of the plug-in. The method and the system realize the loading of the plug-in class in the host through a hook change class loading mechanism. Class loading, class method calling through reflection and class attribute obtaining. In the class loading phase, the JVM does three things: first, a binary byte stream defining a class is obtained by a fully qualified name for such class. Second, the static storage structure represented by this byte stream is converted into the runtime data structure of the method region. And thirdly, generating a Class object representing the Class in the java heap as an access entry of the method area data. That is, after the JVM loads each class in the dex through the class loader ClassLoader, the method of these classes can be executed.
Further, the executable file of the virtual machine includes a dex file, and the loading of the executable file of the virtual machine included in the updated target plug-in into the project directory can be implemented by the steps shown in fig. 6:
step S601, the dexElements of the host application program and the dexElements of the target plug-in are obtained in a reflection mode.
Here, the terminal performs the bottom source code of the hook system in a reflection mode. After a host application program class loader is obtained, a dexElements array object of a host application program is obtained in a reflection mode; and creating a class loader of the target plug-in, and obtaining the dexElements object of the target plug-in a reflection mode.
Step S602, merging the dexElements of the host application program and the dexElements of the target plug-in to obtain the target dexElements.
Step S603, assigning the target dexElements to the dexElements of the host application program.
Here, the terminal merges the dexElements of the host application and the dexElements of the target plug-in into the target dexElements, namely a new dexElements array, and then assigns the new dexElements array object to the dexElements of the host through reflection. That is, as shown in fig. 7, at this time, the dexElements of the host application, i.e., the new host dexElements701, become the dexElements of the host application and the dexElements of the target plug-in. Thus, all classes of dex of the target plug-in can be loaded as soon as the host application starts and the method thereof.
Further, to further illustrate the loading of the class, a java program is composed of a plurality of class classes, and during the process of running the program, the class classes need to be loaded into the JVM through the ClassLoader to run normally. The Android program needs to run normally, and a class mechanism is also needed to load class into Dalvik/ART of Android, but the class is packaged in APK of Android unlike ClassLoader in java, the class file is packaged into one or more dex files, and then the dex files are processed by BaseDexClassLoader. By checking the source code, the method determines that the loading of the class can load one dex file through the DexClassLoader, so that all classes corresponding to the dex are loaded successfully. The loading of the class is finally the loading of the findClass () implementation class calling BaseDexClassLoader. The whole loading process is as follows: firstly, whether the class is loaded or not is detected, and if the class is loaded, the class is directly acquired and returned. If the parent is not loaded and is not null, calling parent.
Further, the dynamic library file includes a so file, and the loading of the dynamic library file included in the updated target plug-in into the project directory can be implemented by the steps shown in fig. 8:
step S801, merging the native LibraryPathElements of the host application program and the native LibraryPathElements of the target plug-in to obtain the target native LibraryPathElements.
The native library pathelements array refers to a dynamic library path array.
Step S802, assigning the target native LibraryPathElements to the native LibraryPathElements of the host application program.
In this embodiment of the application, because dex is a binary byte code file of a common class, if a method of a plug-in so package is to be called, hook can be performed in a reflection manner, a native librarypathelementof a host is set as a native librarypathelementof the host and a native librarypathelementof the plug-in, and a merged array is assigned to the native librarypathelementof the host. The above is a generic class of calls. We also need a method that can call to the add-in's so for the so file under the libs directory. If plug-in Dex is inserted into host dexElements using the Add Dex Path (addDexPath) method only, then the presence of a load so in plug-in APK will throw an Unsitsfield LinkError exception because there is no so file inside Dex. The method comprises the steps that a system is adopted, a loadLibrary source code is used for traversing and inquiring a child element through a native LibraryPathElement array in BaseDexClassLoader to obtain the library, the method is positioned to the native LibraryPathElement array, the native LibraryPathElement array is constructed and generated through a makePathElement method, the makePathElement method is called through reflection, a library SearchPath path is transmitted, a new native LibraryPathElement array is obtained, and then the new library and the old library are combined. Hook is the same way as the general class above.
For the algorithm model files under the assets directory in the plug-in, because the SDK only needs to load the files under the corresponding directory, after the plug-in is downloaded, the plug-in APK is decompressed, the algorithm model files under the assets directory are copied to the data assets directory corresponding to the host APK, and replacement and installation are carried out.
In other embodiments of the present application, the software development kit further includes at least two algorithm plug-ins, and the host application may switch between different algorithms, and the method for dynamically updating the software development kit provided in the present application further includes the steps shown in fig. 9:
step S901, when the host application detects an algorithm switching event, acquiring at least two algorithm type flag bits issued by the cloud.
And S902, selecting a target algorithm flag bit corresponding to the algorithm switching event from at least two algorithm type flag bits through the intermediate layer, and loading a target algorithm plug-in from the cloud based on the target algorithm flag bit.
In the embodiment of the Application, the terminal realizes free loading and switching among a plurality of sets of algorithms through the intermediate layer, when the host Application program detects an algorithm switching event, the terminal issues a request to load the switched algorithm based on the algorithm switching event, namely, loads the switched algorithm plug-in, and then calls an algorithm Application Program Interface (API) of the intermediate layer. It should be noted that, when the algorithm needs to be switched, the algorithm type flag bit only needs to be changed in the intermediate layer of the terminal according to the algorithm type flag bit issued by the cloud. The method for calling the middle layer is that the middle layer loads a specific plug-in of the cloud according to the internal algorithm zone bit. This can greatly reduce the volume of the bag and also provide low maintenance costs.
And step S903, decompressing the target algorithm plug-in, copying the decompressed algorithm model file to the data native resource file directory corresponding to the host application program to replace the algorithm model file in the data native resource file directory, and installing the decompressed algorithm model file.
Continuing with the exemplary structure of the dynamic update software development kit apparatus 154 provided in the embodiments of the present application implemented as a software module, in some embodiments, as shown in fig. 1, the software module stored in the dynamic update software development kit apparatus 154 of the memory 150 may be the dynamic update software development kit apparatus in the terminal 100, including:
the processing module 1541 is configured to determine that, when the host application is started, a target plug-in included in the software development kit corresponding to the tool development end host application is updated.
And the processing module 1541 is configured to copy the updated target plug-in to the engineering directory of the host application.
The processing module 1541 is configured to change a class loading mechanism through a hook, load a class of the target plug-in the host application based on the changed loading mechanism, and reflect a method for calling the class of the target plug-in to implement the target plug-in.
In some embodiments, the means for dynamically updating the software development kit 154 further comprises an obtaining module 1542 for obtaining the software development kit published by the tool development end, wherein the software development kit comprises the binary archive file and at least two plug-ins, the at least two plug-ins comprising the target plug-in.
A processing module 1541 further configured to copy the binary archive file and the at least two plug-ins to a project directory of the application; and calling an interface in the binary archive file through the application program, and integrating at least two plug-ins to obtain the host application program.
In some embodiments, the processing module 1541 is further configured to load an executable file and a dynamic library file of the virtual machine included in the updated target plug-in into the project directory.
In some embodiments, the executable file of the virtual machine includes a dex file, a processing module 1541, and is further configured to obtain dexElements of the host application and dexElements of the target plug-in a reflection manner; merging dexElements of the host application program and dexElements of the target plug-in to obtain the target dexElements; the target dexElements are assigned to the dexElements of the host application.
In some embodiments, the dynamic library file includes a so file, the processing module 1541 is further configured to merge native librarypathelements of the host application and native librarypathelements of the target plug-in to obtain target native librarypathelements; and assigning the target native LibraryPathElements to the native LibraryPathElements of the host application program.
In some embodiments, the obtaining module 1542 is further configured to obtain at least two algorithm type flag bits issued by the cloud when the host application detects an algorithm switching event;
the processing module 1541 is further configured to select, from the at least two algorithm type flag bits, a target algorithm flag bit corresponding to the algorithm switching event through the intermediate layer, and load the target algorithm plug-in from the cloud based on the target algorithm flag bit.
In some embodiments, the processing module 1541 is further configured to decompress the target algorithm plug-in, copy the decompressed algorithm model file to a data native resource file directory corresponding to the host application, replace the algorithm model file in the data native resource file directory, and install the decompressed algorithm model file.
In some embodiments, the processing module 1541 is further configured to obtain, when the host application is started, a version number of a same plug-in the local and cloud; and when a target association relation exists between the version number of the same plug-in the local and the version number of the same plug-in the cloud, determining that the same plug-in is updated, wherein the target plug-in comprises the same plug-in.
It should be noted that the description of the apparatus in the embodiment of the present application is similar to the description of the method embodiment, and has similar beneficial effects to the method embodiment, and therefore, the description is not repeated. For technical details not disclosed in the embodiments of the apparatus, reference is made to the description of the embodiments of the method of the present application for understanding.
Embodiments of the present application provide a storage medium having stored therein executable instructions, which when executed by a processor, will cause the processor to perform a method provided by embodiments of the present application, for example, the method as shown in fig. 2.
In some embodiments, the storage medium may be a computer-readable storage medium, such as a Ferroelectric Random Access Memory (FRAM), a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read Only Memory (EPROM), a charged Erasable Programmable Read Only Memory (EEPROM), a flash Memory, a magnetic surface Memory, an optical disc, or a Compact disc Read Only Memory (CD-ROM), among other memories; or may be various devices including one or any combination of the above memories.
In some embodiments, executable instructions may be written in any form of programming language (including compiled or interpreted languages), in the form of programs, software modules, scripts or code, and may be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
By way of example, executable instructions may correspond, but do not necessarily have to correspond, to files in a file system, and may be stored in a portion of a file that holds other programs or data, such as in one or more scripts in a hypertext Markup Language (hypertext Markup Language) document, in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub-programs, or portions of code). By way of example, executable instructions may be deployed to be executed on one computing device or on multiple computing devices at one site or distributed across multiple sites and interconnected by a communication network.
The above description is only an example of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, and improvement made within the spirit and scope of the present application are included in the protection scope of the present application.

Claims (10)

1. A method for dynamically updating a software development kit, comprising:
when a host application program is started, determining that a target plug-in included in a software development kit corresponding to the host application program at a tool development end is updated;
copying the updated target plug-in to the engineering directory of the host application program;
changing a loading mechanism of a class through a hook, loading the class of the target plug-in the host application program based on the changed loading mechanism, and reflecting a method for calling the class of the target plug-in to realize the target plug-in.
2. The method according to claim 1, wherein before determining that a target plug-in included in a software development kit corresponding to a host application at a tool development end is updated when the host application is started, the method comprises:
acquiring the software development kit issued by the tool development terminal, wherein the software development kit comprises a binary archive file and at least two plug-ins, and the target plug-in is one of the at least two plug-ins;
copying the binary archive file and the at least two plug-ins to the project directory of an application;
and calling an interface in the binary archive file through the application program, and integrating the at least two plug-ins to obtain the host application program.
3. The method of claim 1, wherein the copying the updated target plug-in to the engineering directory of the host application comprises:
and loading the executable file and the dynamic library file of the virtual machine contained in the updated target plug-in into the project directory.
4. The method according to claim 3, wherein the executable file of the virtual machine comprises a dex file, and loading the updated executable file of the virtual machine included in the target plug-in into the project directory comprises:
acquiring an executable file array of the host application program and an executable file array of the target plug-in a reflection mode;
combining the executable file array of the host application program and the executable file array of the target plug-in to obtain a target executable file array;
and assigning the target executable file array to the executable file array of the host application program.
5. The method of claim 3, wherein the dynamic library file comprises a so file, and loading the dynamic library file contained in the updated target plug-in into the project directory comprises:
merging the dynamic library path array of the host application program and the dynamic library path array of the target plug-in to obtain a target dynamic library path array;
and assigning the target dynamic library path array to the dynamic library path array of the host application program.
6. The method of claim 1, further comprising:
when the host application program detects an algorithm switching event, acquiring at least two algorithm type flag bits issued by a cloud;
selecting a target algorithm flag bit corresponding to the algorithm switching event from the at least two algorithm type flag bits through a middle layer, and loading a target algorithm plug-in from the cloud based on the target algorithm flag bit.
7. The method of claim 6, wherein after loading a target algorithm plug-in from the cloud based on the target algorithm flag bit, the method further comprises:
and decompressing the target algorithm plug-in, copying the decompressed algorithm model file to the data native resource file directory corresponding to the host application program to replace the algorithm model file in the data native resource file directory, and installing the decompressed algorithm model file.
8. The method according to any one of claims 1 to 7, wherein when the host application is started, determining that a target plug-in included in a software development kit corresponding to the host application at a tool development end is updated comprises:
when the host application program is started, acquiring the version number of the same plug-in of a local plug-in and a cloud terminal;
and when a target association relation exists between the version number corresponding to the same plug-in the local and the version number corresponding to the cloud, determining that the same plug-in is updated, wherein the target plug-in comprises the same plug-in.
9. An apparatus for dynamically updating a software development kit, comprising:
a memory for storing executable instructions; a processor for implementing the method of any one of claims 1 to 8 when executing executable instructions stored in the memory.
10. A computer-readable storage medium having stored thereon executable instructions for causing a processor, when executed, to implement the method of any one of claims 1 to 8.
CN202110672436.5A 2021-06-17 2021-06-17 Method, equipment and storage medium for dynamically updating software development kit Pending CN113326078A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110672436.5A CN113326078A (en) 2021-06-17 2021-06-17 Method, equipment and storage medium for dynamically updating software development kit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110672436.5A CN113326078A (en) 2021-06-17 2021-06-17 Method, equipment and storage medium for dynamically updating software development kit

Publications (1)

Publication Number Publication Date
CN113326078A true CN113326078A (en) 2021-08-31

Family

ID=77423767

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110672436.5A Pending CN113326078A (en) 2021-06-17 2021-06-17 Method, equipment and storage medium for dynamically updating software development kit

Country Status (1)

Country Link
CN (1) CN113326078A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115904548A (en) * 2023-01-09 2023-04-04 北京六方云信息技术有限公司 Dynamic loading method, device and system for application recognition algorithm model
CN116048498A (en) * 2023-03-31 2023-05-02 苏州瑞云智服信息科技有限公司 Component library architecture based on multiple versions

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115904548A (en) * 2023-01-09 2023-04-04 北京六方云信息技术有限公司 Dynamic loading method, device and system for application recognition algorithm model
CN116048498A (en) * 2023-03-31 2023-05-02 苏州瑞云智服信息科技有限公司 Component library architecture based on multiple versions

Similar Documents

Publication Publication Date Title
CN106227579B (en) Docker container construction method and Docker management console
US10795660B1 (en) Live code updates
US10083025B2 (en) Dynamic update of an application in compilation and deployment with warm-swapping
US9934005B2 (en) Dynamically building locale objects or subsections of locale objects based on historical data
EP3336690B1 (en) Extensible data transformation authoring and validation system
KR102059705B1 (en) Adaptive portable libraries
US8196130B2 (en) Tri-phase boot process in electronic devices
CN101777006B (en) Methods and apparatus to optimize application program interfaces in a virtual machine environment
US20060064576A1 (en) Boot systems and methods
WO2022111097A1 (en) File update method and apparatus, device and storage medium
KR20140046402A (en) Application compatibility with library operating systems
US9116770B2 (en) Recipe-based application conversion
CN113326078A (en) Method, equipment and storage medium for dynamically updating software development kit
US20170068587A1 (en) Data dump for a memory in a data processing system
CN112667246A (en) Application function extension method and device and electronic equipment
CN113986402A (en) Function calling method and device, electronic equipment and storage medium
CN112732300A (en) Data packet updating method and device, electronic equipment and readable storage medium
CN116048644A (en) System migration method, device and readable storage medium
US10552135B1 (en) Reducing a size of an application package
CN108228266B (en) Method and device for starting Fragment component between different plug-ins under Android plug-in framework
CN115543224B (en) ZNS SSD-based file system control method, device and equipment
US20170083298A1 (en) Resilient format for distribution of ahead-of-time compiled code components
CN115964061A (en) Plug-in updating method and device, electronic equipment and computer readable storage medium
CN114461223A (en) Code generation method and device and terminal equipment
CN112379973A (en) Heavy loading method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination