CN109933381B - Kernel loading method and device - Google Patents

Kernel loading method and device Download PDF

Info

Publication number
CN109933381B
CN109933381B CN201910168640.6A CN201910168640A CN109933381B CN 109933381 B CN109933381 B CN 109933381B CN 201910168640 A CN201910168640 A CN 201910168640A CN 109933381 B CN109933381 B CN 109933381B
Authority
CN
China
Prior art keywords
loading
file
kernel
class loader
virtual machine
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.)
Active
Application number
CN201910168640.6A
Other languages
Chinese (zh)
Other versions
CN109933381A (en
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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201910168640.6A priority Critical patent/CN109933381B/en
Publication of CN109933381A publication Critical patent/CN109933381A/en
Application granted granted Critical
Publication of CN109933381B publication Critical patent/CN109933381B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention discloses a loading method and a device of a kernel, wherein the method comprises the following steps: when an application program is started, acquiring a loading instruction of a kernel corresponding to a software development kit of the application program, wherein the loading instruction is used for judging whether the kernel is loaded for the first time after the kernel is installed; when the kernel is loaded for the first time after the kernel is installed, setting a machine code instruction storage path in a virtual machine execution code to be empty so that the virtual machine execution code does not compile a loading file of the kernel; the application program obtains the browsing service provided by the kernel through the software development toolkit, and the loading file is loaded through a virtual machine used for creating a virtual environment on the android system. The method and the device shorten the time for loading the loading file of the kernel, ensure the compatibility of the virtual machine for loading the kernel to the android system version and/or the related terminal equipment, and enable the kernel to provide high-efficiency and high-quality browsing service for the application program.

Description

Kernel loading method and device
Technical Field
The invention relates to the technical field of internet communication, in particular to a kernel loading method and device.
Background
With the development of internet communication technology, applications on terminal devices are in a wide range, and users experience better and better through the applications. For example, a user may browse web content through a browser on a mobile terminal; playing videos and music through a player on the mobile terminal; chat interaction and the like are carried out through the social application on the mobile terminal.
The more perfect the function and the more comprehensive the coverage field of the application program, the larger the scale of the application program and the more the modules. The scenes that the Application program uses the dynamic loading technology are increased, the kernel is used for providing browsing service for the help of the Application program, however, the problems of time consumption, easiness in generation of ANR (Application Not Responding) and the like often exist when the kernel is loaded for the first time after being installed, and user experience is influenced.
Disclosure of Invention
In order to solve the problems of slow response of an application program and the like when the application is loaded for the first time after kernel installation in the prior art, the invention provides a kernel loading method and a kernel loading device, wherein the kernel loading method comprises the following steps:
in one aspect, the present invention provides a kernel loading method, where the method includes:
when an application program is started, acquiring a loading instruction of a kernel corresponding to a software development kit of the application program, wherein the loading instruction is used for judging whether the kernel is loaded for the first time after the kernel is installed;
when the kernel is loaded for the first time after the kernel is installed, setting a machine code instruction storage path in a virtual machine execution code to be empty so that the virtual machine execution code does not compile a loading file of the kernel;
the application program obtains the browsing service provided by the kernel through the software development toolkit, and the loading file is loaded through a virtual machine used for creating a virtual environment on the android system.
Another aspect provides a kernel loading apparatus, including:
a first loading judgment module: the method comprises the steps that when an application program is started, a loading instruction of a kernel corresponding to a software development kit of the application program is obtained, and the loading instruction is used for judging whether the kernel is loaded for the first time after the kernel is installed;
deposit the route and set up the module: when the kernel loads for the first time after installation, setting a machine code instruction storage path in a virtual machine execution code to be null, so that the virtual machine execution code does not compile a loading file of the kernel;
the application program obtains the browsing service provided by the kernel through the software development toolkit, and the loading file is loaded through a virtual machine used for creating a virtual environment on the android system.
In another aspect, a terminal device is provided, where the terminal device includes the loader apparatus of a kernel as described above.
Another aspect provides a computer readable storage medium having stored therein at least one instruction, at least one program, set of codes, or set of instructions, which is loaded and executed by a processor to implement a method of loading a kernel as described above.
The kernel loading method and the kernel loading device provided by the invention have the following technical effects:
when the application program is started, the storage path of the machine code instruction in the virtual machine execution code is set to be empty under the condition that the kernel loads the application program for the first time after the kernel is installed, and the virtual machine does not need to compile the loading file of the kernel and directly loads the corresponding loading file, so that the time of the virtual machine for creating the virtual environment on the android system for loading the loading file of the kernel is shortened, the compatibility of the virtual machine for loading the kernel on the android system version and/or related terminal equipment is ensured, and the kernel can provide high-efficiency and high-quality browsing service for the application program.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions and advantages of the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a schematic diagram of an application environment provided by an embodiment of the invention;
fig. 2 is a flowchart illustrating a kernel loading method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating setting a machine code instruction deposit path in the virtual machine execution code to null according to an embodiment of the present invention;
fig. 4 is a schematic flowchart of transferring the class processing task of the load file class loader to the load file base class loader for execution, and setting an optimized path in the execution code of the load file base class loader to be empty according to the embodiment of the present invention;
fig. 5 is a flowchart illustrating a loading method of a kernel according to an embodiment of the present invention;
fig. 6 is a block diagram illustrating a loading apparatus of a kernel according to an embodiment of the present invention;
fig. 7 is a block diagram of a loading apparatus of a kernel according to an embodiment of the present invention;
fig. 8 is a schematic flowchart of loading a Dex file by using an ART virtual machine according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of the operation of a load file class loader according to an embodiment of the present invention;
FIG. 10 is a diagram illustrating an example of a core loading apparatus according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of a terminal according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
It should be noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present invention and the above-described drawings, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
Referring to fig. 1, fig. 1 is a schematic diagram of an application environment according to an embodiment of the present invention, as shown in fig. 1, in the application environment, some application programs in a terminal device are installed with a Software Development Kit (SDK) corresponding to a kernel, and the application programs can access the kernel through the SDK, so as to use a browsing service provided by the kernel. When an application is to use a browsing service (e.g., to browse web page content) in response to a user's operation, the application may load the kernel through a software development kit. It should be noted that fig. 1 is only an example.
Specifically, browsing services include, but are not limited to, browsing enhancement, content framing, advertising architecture, H5 game distribution, and big data services. The browsing enhancement service may include: providing a perfect safety guarantee system for the application browsing scene; compressing the webpage and the resource flow at the cloud end, and optimizing the webpage loading full flow at the terminal; sharing a kernel with certain application hosts; file opening capability, video support capability, etc. are enhanced. In practical applications, for example, in a TBS kernel in an Tencent browsing service scenario, the TBS kernel can provide content loading and rendering of a webpage, and clearly obtains the content and the structure of the webpage: an auxiliary panel can be quickly generated for the article with clear structure, and page display can be realized by inserting the link of the corresponding content; for the articles with an unclear structure, the content summaries of the various sections of the articles can be taken out by means of an intelligent learning algorithm, and then the articles are arranged into a simple tree structure according to a natural structure.
In the embodiment of the present invention, the terminal device may support an Android (Android) system, and the terminal device includes, but is not limited to, a smart phone, a smart wearable device, and a PDA (tablet computer). The application programs include, but are not limited to, social applications (e.g., WeChat applications), entertainment-enabled applications (e.g., video applications, audio playback applications, gaming applications, and reading software), and service-enabled applications (e.g., map navigation applications, group buying applications).
The following describes a loading method of a kernel according to the present invention, and fig. 2 is a flowchart of a loading method of a kernel according to an embodiment of the present invention, where the present specification provides the method operation steps as described in the embodiment or the flowchart, but may include more or less operation steps based on conventional or non-creative labor. The order of steps recited in the embodiments is merely one manner of performing the steps in a multitude of orders and does not represent the only order of execution. In practice, the system or server product may be implemented in a sequential or parallel manner (e.g., parallel processor or multi-threaded environment) according to the embodiments or methods shown in the figures. Specifically, as shown in fig. 2, the method may include:
s201: when an application program is started, acquiring a loading instruction of a kernel corresponding to a software development kit of the application program, wherein the loading instruction is used for judging whether the kernel is loaded for the first time after the kernel is installed;
in the embodiment of the present invention, the application program obtains the browsing service provided by the kernel through the software development kit, and the loading file of the kernel is loaded through a virtual machine (ART virtual machine) for creating a virtual environment on the android system. The kernel has a lot of logic in the loading file (such as a Dex file, a corresponding loading and execution file of java code on the Android system during runtime). As shown in fig. 8, the loading of the loaded file passes through the java layer and the c + + layer in sequence, and accordingly, the loaded file may be presented in different file formats as the loading process proceeds. For example, the loadfile may be compiled at the java level to appear as a class file (a byte code file). The ART virtual machine may be used to compile a load file presented in byte code format into a load file presented in machine code format in c + +. Similarly, even though FIG. 8 shows two DexFile boxes in a box, the data structure and function are completely unrelated in different hierarchies. Wherein, the byte is the unit of data volume in the computer. A Byte-code (Byte-code) file is a binary file containing an execution program, consisting of a sequence of op (operation code) code/data pairs. Bytecode is an intermediate code that is more abstract than machine code. It is often viewed as a binary file containing an executive, much like an object model. Machine Code (machine Code) files, which may also be referred to as machine language instructions and Native Code (Native Code), are data that a computer's Central Processing Unit (CPU) can directly interpret.
Specifically, the first loading of the kernel after installation refers to the first loading of the kernel in a process after installation. Generally, after a new kernel is installed, the new kernel cannot be used immediately, and the new kernel is really used only when a process which needs to be provided with browsing service is restarted next time. In practical applications, when the user first installs the application a, there is no kernel (such as the TBS kernel) and the system kernel is used. With application a installed, the TBS kernel is installed in the "tmp directory" and sets the kernel enabled flag. When the process of the TBS kernel is restarted, the SDK corresponding to the TBS kernel in the application program A changes the installation position of the TBS kernel from a tmp directory to a core _ share directory, and then the SDK guides the TBS kernel to load from the core _ share directory, and browsing service can be provided after the loading is successful. After the TBS kernel is installed, when the TBS is loaded for the first time in a certain process, the directory where the TBS kernel is located is reset along with the enabling of the TBS kernel. Since the directory where the kernel is located is reset, a machine code instruction corresponding to the Dex cannot be found in the process of loading the kernel and loading the Dex file, and the machine code instruction can be an Oat file (an ELF file private to the android system; an ELF file, an executable and linkable format file). The ART virtual machine will attempt to create a copy of the Oat file first, and thus complete the actual load, since the corresponding Oat file cannot be found. The process of generating Oat files by the ART virtual machine is referred to as dex2 oat. However, this work takes a long time, even longer than 10s on some terminal devices, and even causes a large impact on the user experience and ANR. For ANR, on an Android system, if an Application is Not sensitive enough in response for a while, the system displays a dialog box called an Application No Response (ANR) dialog box through a UI interface. At this time, the user may choose to "wait" to allow the application to continue running, or may choose to "force close" the application. The appearance of ANR dialog severely restricts the smooth running of applications.
S202: when the kernel is loaded for the first time after the kernel is installed, setting a machine code instruction storage path in a virtual machine execution code to be empty so that the virtual machine execution code does not compile a loading file of the kernel;
in the embodiment of the present invention, as shown in fig. 8, the machine code instruction deposit path oat _ location in the execution code of the ART virtual machine is set to null (nullptr). And loading a DexFile by a DexFile & loadDex () mode at a java layer, wherein a DexFile object is newly established by the loadDex. In the constructor of the DexFile, openDexFile is called to load the Dex file. The openDexFile calls openDexFileNative, and corresponds to a DexFile _ openDexFileNative static method in art/runtime/native/dalivk _ system _ DexFile. Checking the loading file in a class connector by using an ART virtual machine to call an open view function: opendexfilesfrom oat of classslinker (class connector) is called in DexFile _ openDexFileNative to load the Dex file. The ClassLinker is a key class in the ART virtual machine and is responsible for loading class, code analysis processing in the class and the like. Member variables that can traverse ClassLinker: oat files to see if the current Dex file has already been parsed into Oat files. Then, when the oat _ location is empty (nullptr), it indicates that there is Oat corresponding to the Dex file at present, however, the kernel loaded for the first time after installation does not have the corresponding Oat file, which is equivalent to performing a disguise through a null pointer, so that the compilation for generating Oat file for the Dex file is not performed in the execution logic of the ART virtual machine, but the Dex file is directly loaded and used.
Specifically, as shown in fig. 3, the step of setting the machine code instruction storage path in the virtual machine execution code to be empty includes:
s301: creating a loading file class loader, wherein the loading file class loader inherits to a loading file base class loader, and the loading file base class loader is used for analyzing the loading file into classes;
in some embodiments, the load file class loader (DexClassLoader) is a one-layer simple wrapper to the load file base class loader (BaseDexClassLoader), with core logic such as loading Dex files implemented in BaseDexClassLoader. The DexClassLoader executes the code fragments as follows:
Figure BDA0001987193550000071
DexClassLoader passes depPath, new File, libraryPath, parent among them to BaseDexClassLoader. dexPath (full path where the file to be analyzed is located), ClassLoader will find the specified target class in the dex file specified in the path. The optimized path refers to a path for generating a file to store after the virtual machine optimizes a Dex file in an apk (android package), such as an Oat file path generated by an ART virtual machine. This path must be the internal storage path of the current application, and Google considers that if placed under a public path, there is a risk of being maliciously injected. The libraryPath is a specified native layer code storage path.
As shown in fig. 8 and 9, the kernel has a large amount of logic in the Dex file and needs to be dynamically loaded. It is necessary to create a class loader ClassLoader and then perform an operation of loading the Dex file inside the ClassLoader. As shown in FIG. 9, the triangles of the arrows in the figure indicate that the underlying class loader inherits (inheriting properties and methods that may cause a child to have a parent class or redefining, appending properties and methods, etc. it may be declared by the extensions key that a class is inherited from another class) from the above class loader; in the figure, the diamond of the arrow indicates the combination relationship of the classes involved at the two ends of the arrow, and whether the diamond is solid indicates whether the two classes possess the membership relationship, such as an example that the class in BaseDexClassLoader possesses a DexPathList (load file path directory) class. When DexClassLoader dynamically loads the class in the Dex file, the DexClassLoader simply packages the BaseDexClassLoader at once, and the specific implementation is still in the parent BaseDexClassLoader. A DexPrhList class is created, looked up and then stored in the Element object array. The DexClassLoader finally calls the DexFile class to cache the loaded Dex file in the DexDathList class.
S302: and transferring the class processing task of the loading file class loader to the loading file base class loader for execution, and setting an optimized path in an execution code of the loading file base class loader to be empty.
In some embodiments, there is no mandatory requirement that optimizedDirectory (optimized path) must be non-empty in the executing code of basedexcsloader. As shown in fig. 4 and 10 (the triangles and diamonds of the arrows in fig. 10 mean the same as those in fig. 9), S401: and constructing a loading file derived class loader (speedydexclasloadloader), wherein the loading file derived class loader is inherited to the loading file base class loader. The SpeedyDexClassLoader inherits from basedexcsloader, i.e. automatically owns the capabilities of basedexcsloader. S402: decoupling the loaded file derivation class loader and the loaded file class loader by a proxy mode. By constructing a DexClassLoaderProvider agent, the place where DexClassLoader is originally needed is changed into BaseDexClassLoader, so that the workload of modifying codes is reduced, and the cost is reduced. In practical applications, the purpose (oat _ location ═ nullptr) can be achieved by constructing the following code:
Figure BDA0001987193550000081
Figure BDA0001987193550000091
as shown in fig. 5, the loading method of the kernel further includes:
s203: calling a compiling function through the virtual machine for creating the virtual environment on the android system to directly load the loading file;
as shown in FIG. 8, at this time at _ location is set to null (null), the ART virtual machine calls DexFile:: Open loads Dex file directly to load, using class.
S204: newly building a kernel loading thread, and calling a corresponding function through the virtual machine for creating a virtual environment on the android system to generate a machine code instruction corresponding to the loading file;
in the embodiment of the present invention, to avoid interference, step S204 is performed after the loading of the Dex file in step S203 is completed. In practical applications, on a lower-version Android operating system (for example, Android5.x or more), compatibility problems on individual ROMs (images of Android systems) may exist in newly building a kernel loading thread. In this case, a background Service (Android Service component) may be started in which the conversion process of the Dex file to Oat file (machine code instructions) is performed.
Specifically, a thread may be additionally started to load a Dex file (Oat file is generated), so that efficient execution can be ensured by normally using an AOT (Ahead of time) mode under an ART virtual machine when the Dex file is loaded next time. The method and the device ensure the peaceful and reasonable use of the first loading situation of the Dex file of the kernel and the AOT mode, and realize the efficient provision of browsing service.
As shown in fig. 8, a Dex file is loaded in a java layer by a DexFile. In the constructor of the DexFile, openDexFile is called to load the Dex file. The openDexFile calls openDexFileNative, and corresponds to a DexFile _ openDexFileNative static method in art/runtime/native/dalivk _ system _ DexFile.
The step of creating the kernel loading thread, which is to generate the machine code instruction corresponding to the loading file by calling the compiling function through the virtual machine for creating the virtual environment on the android system, includes:
firstly, using the virtual machine for creating the virtual environment on the android system to call an open view function to check the loading file in a class connector;
in practical applications, opendexfilesfrom oat (open view function) of classslinker is called in DexFile _ openDexFileNative to load the Dex file. The ClassLinker is a key class in the ART virtual machine and is responsible for loading class, code analysis processing in the class and the like. Member variables that can traverse ClassLinker: oat files to see if the current Dex file has already been parsed into Oat files. The procedure of the OpenDexFilesFromOat check is: check if there is already an available Oat file; if there is no Oat file available, checking if there is one Oat file already generated on the disk; if there is an Oat file already generated on the disk, check if the Oat file is expired and contains all the Dex files; if the above is not satisfied, the Oat file is regenerated.
Then, when the loading file is not analyzed, using the virtual machine for creating a virtual environment on the android system to call the compiling function to create a process for compiling the loading file into the machine code instruction.
In practical applications, opendexfilefrompot constructs an OatFileAssistant object, MakeUpToDate of OatFileAssistant may call GenerateOatFile to generate corresponding Oat file for DEX. dex2 at procedure is implemented by calling execv to execute/system/bin/dex 2 at in Android system).
As can be seen from the above technical solutions provided in the embodiments of the present specification, when an application program is started, for a case where a kernel is loaded for the first time after installation of the application program, a machine code instruction storage path in a virtual machine execution code is set to be empty, and the virtual machine does not need to compile a loaded file of the kernel and directly loads a corresponding loaded file, so that the time for loading a Dex file of the kernel by an ART virtual machine is shortened, and the consumed time can be optimized to within 1 second on some application programs (such as a QQ browser), thereby reducing the waiting time of a user. The compatibility of the virtual machine loaded with the kernel to the android system version and/or related terminal equipment is guaranteed, universality is high, access cost is low, and performance is stable, so that the kernel can provide efficient and high-quality browsing service for the application program.
An embodiment of the present invention further provides a kernel loading device, as shown in fig. 6, the kernel loading device includes:
first loading judgment module 61: the method comprises the steps that when an application program is started, a loading instruction of a kernel corresponding to a software development kit of the application program is obtained, and the loading instruction is used for judging whether the kernel is loaded for the first time after the kernel is installed;
storage path setting module 62: and when the kernel loads the kernel for the first time after installation, setting a machine code instruction storage path in the virtual machine execution code to be null, so that the virtual machine execution code does not compile a loading file of the kernel. Specifically, the storage path setting module 62 includes: a creation unit: the system comprises a loader, a file management module and a file management module, wherein the loader is used for creating a loading file class loader, the loading file class loader inherits to a loading file base class loader, and the loading file base class loader is used for analyzing a loading file into classes; an adjusting unit: and the system is used for transferring the class processing task of the loading file class loader to the loading file base class loader for execution, and setting an optimized path in an execution code of the loading file base class loader to be null. Wherein the adjusting unit includes: a construction subunit: the system comprises a base class loader, a file derivation class loader and a file derivation class loader, wherein the base class loader is used for constructing a loading file derivation class loader, and the loading file derivation class loader is inherited from the loading file base class loader; a decoupling subunit: and the method is used for decoupling the loaded file derivation class loader and the loaded file class loader in a proxy mode.
The application program obtains the browsing service provided by the kernel through the software development toolkit, and the loading file is loaded through a virtual machine used for creating a virtual environment on the android system.
As shown in fig. 7, the apparatus further includes:
the first load module 63: the virtual machine is used for creating a virtual environment on the android system, and calling a corresponding function to directly load the loading file based on the loading file;
the second load module 64: and the method is used for newly building a kernel loading thread, and calling a compiling function through the virtual machine for creating the virtual environment on the android system to generate a machine code instruction corresponding to the loading file. Specifically, the second loading module 64 includes: an inspection unit: checking the load file in a class connector using the virtual machine call open view function for creating a virtual environment on the android system; an analysis unit: and when the loading file is not analyzed, using the virtual machine for creating the virtual environment on the android system to call the compiling function to create a process for compiling the loading file into the machine code instruction.
It should be noted that the device and method embodiments in the device embodiment are based on the same inventive concept.
The embodiment of the invention provides terminal equipment, and the terminal equipment comprises the loading side device of the kernel.
Fig. 11 is a schematic structural diagram of a terminal device according to an embodiment of the present invention, where the terminal device is configured to implement the data backup method provided in the foregoing embodiment. Specifically, the method comprises the following steps:
terminal device 1100 can include RF (radio frequency) circuitry 1110, memory 1120 including one or more computer-readable storage media, input unit 1130, display unit 1140, video sensor 1150, audio circuitry 1160, WiFi (wireless fidelity) module 1170, processor 1180 including one or more processing cores, and power supply 110, among other components. Those skilled in the art will appreciate that the terminal device configuration shown in fig. 11 does not constitute a limitation of the terminal device, and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components. Wherein:
RF circuit 1110 may be used for receiving and transmitting signals during a message transmission or communication process, and in particular, for receiving downlink messages from a base station and then processing the received downlink messages by one or more processors 1180; in addition, data relating to uplink is transmitted to the base station. In general, RF circuitry 1110 includes, but is not limited to, an antenna, at least one amplifier, a tuner, one or more oscillators, a Subscriber Identity Module (SIM) card, a transceiver, a coupler, an LNA (low noise amplifier), a duplexer, and the like. In addition, the RF circuitry 1110 may also communicate with networks and other devices via wireless communications. The wireless communication may use any communication standard or protocol, including but not limited to GSM (global system for mobile communications), GPRS (general packet radio service), CDMA (code division multiple access), WCDMA (wideband code division multiple access), LTE (long term evolution), email, SMS (short messaging service), etc.
The memory 1120 may be used to store software programs and modules, and the processor 1180 may execute various functional applications and data processing by operating the software programs and modules stored in the memory 1120. The memory 1120 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as video data, a phonebook, and the like) created according to the use of the terminal device 1100, and the like. Further, the memory 1120 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device. Accordingly, the memory 1120 may also include a memory controller to provide the processor 1180 and the input unit 1130 access to the memory 1120.
The input unit 1130 may be used to receive input numeric or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control. Specifically, the input unit 1130 may include an image input device 1131 and other input devices 1132. The image input device 1131 may be a camera or a photoelectric scanning device. The input unit 1130 may include other input devices 1132 in addition to the image input device 1131. In particular, other input devices 1132 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 1140 may be used to display information input by or provided to the user and various graphical user interfaces of the terminal device 1300, which may be made up of graphics, text, icons, video, and any combination thereof. The display unit 1140 may include a display panel 1141, and optionally, the display panel 1141 may be configured in the form of an LCD (liquid crystal display), an OLED (organic light-emitting diode), or the like.
The terminal device 1100 may include at least one video sensor 1150 for acquiring video information of a user. Terminal device 1100 can also include other sensors (not shown), such as light sensors, motion sensors, and other sensors. Specifically, the light sensor may include an ambient light sensor that adjusts the brightness of the display panel 1141 according to the brightness of ambient light, and a proximity sensor that turns off the display panel 1141 and/or the backlight when the terminal device 1100 moves to the ear. As one of the motion sensors, the gravity acceleration sensor can detect the magnitude of acceleration in each direction (generally, three axes), can detect the magnitude and direction of gravity when the mobile phone is stationary, and can be used for applications of recognizing the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer and tapping), and the like; as for other sensors such as a gyroscope, a barometer, a hygrometer, a thermometer, and an infrared sensor, which can be configured in the terminal device 1100, detailed descriptions thereof are omitted.
Video circuitry 1160, speakers 1161, and microphone 1162 may provide a video interface between a user and terminal device 1100. The audio circuit 1160 may transmit the electrical signal converted from the received audio data to the speaker 1161, and convert the electrical signal into a sound signal for output by the speaker 1161; on the other hand, the microphone 1162 converts the collected sound signal into an electric signal, receives the electric signal by the audio circuit 1160, converts the electric signal into audio data, processes the audio data by the audio data output processor 1180, and transmits the processed audio data to, for example, another terminal device through the RF circuit 1111, or outputs the audio data to the memory 1120 for further processing. The audio circuitry 1160 may also include an earbud jack to provide communication of peripheral headphones with the terminal device 1100.
WiFi belongs to short-distance wireless transmission technology, and the terminal device 1100 can help the user send and receive e-mails, browse web pages, access streaming media, etc. through the WiFi module 1170, and it provides the user with wireless broadband internet access. Although fig. 11 shows the WiFi module 1170, it is understood that it does not belong to the essential constitution of the terminal device 1100, and can be omitted entirely as needed within the scope not changing the essence of the invention.
The processor 1180 is a control center of the terminal device 1100, connects various parts of the entire mobile phone by using various interfaces and lines, and executes various functions and processes data of the terminal device 1100 by running or executing software programs and/or modules stored in the memory 1120 and calling data stored in the memory 1120, thereby performing overall monitoring of the mobile phone. Optionally, processor 1180 may include one or more processing cores; preferably, the processor 1180 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated within processor 1180.
Terminal device 1100 also includes a power supply 110 (e.g., a battery) for powering the various components, which may preferably be logically connected to processor 1180 via a power management system that may be configured to manage charging, discharging, and power consumption. The power supply 110 may also include any component of one or more dc or ac power sources, recharging systems, power failure detection circuitry, power converters or inverters, power status indicators, and the like.
Although not shown, the terminal device 1100 may further include a bluetooth module or the like, which is not described in detail herein.
In particular, in this embodiment, the terminal device 1100 further includes a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors. The one or more programs include instructions for performing the data backup method provided by the above-described method embodiments.
An embodiment of the present invention further provides a computer storage medium, where the storage medium may be disposed in a terminal device to store at least one instruction, at least one program, a code set, or a set of instructions related to implementing a loading method of a kernel in the method embodiment, where the at least one instruction, the at least one program, the code set, or the set of instructions are loaded and executed by the processor to implement the loading method of the kernel provided in the method embodiment.
Optionally, in this embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-only memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
It should be noted that: the precedence order of the above embodiments of the present invention is only for description, and does not represent the merits of the embodiments. And specific embodiments thereof have been described above. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. Especially, for the embodiments of the apparatus and the terminal device, since they are basically similar to the embodiments of the method, the description is relatively simple, and for the relevant points, refer to the partial description of the embodiments of the method.
It will be understood by those skilled in the art that all or part of the steps for implementing the above embodiments may be implemented by hardware, or may be implemented by a program instructing relevant hardware, where the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like that fall within the spirit and principle of the present invention are intended to be included therein.

Claims (10)

1. A method for loading a kernel, the method comprising:
when an application program is started, acquiring a loading instruction of a kernel corresponding to a software development kit of the application program, wherein the loading instruction is used for judging whether the kernel is loaded for the first time after the kernel is installed;
when the kernel is loaded for the first time after the kernel is installed, setting a storage path of a machine code instruction corresponding to a loading file of the kernel in a virtual machine execution code to be empty so that the virtual machine execution code does not compile the loading file of the kernel;
the application program obtains the browsing service provided by the kernel through the software development toolkit, and the loading file is loaded through a virtual machine used for creating a virtual environment on the android system.
2. The method of claim 1, wherein the step of setting a machine code instruction deposit path in the virtual machine execution code to null when the kernel is first loaded after installation thereof comprises:
creating a loading file class loader, wherein the loading file class loader inherits to a loading file base class loader, and the loading file base class loader is used for analyzing the loading file into classes;
and transferring the class processing task of the loading file class loader to the loading file base class loader for execution, and setting an optimized path in an execution code of the loading file base class loader to be null.
3. The method according to claim 2, wherein the step of transferring the class processing task of the load file class loader to the load file base class loader for execution and setting the optimized path in the execution code of the load file base class loader to be empty comprises:
constructing a loading file derived class loader, wherein the loading file derived class loader is inherited to the loading file base class loader;
decoupling the loaded file derivation class loader and the loaded file class loader by a proxy mode.
4. The method of claim 1, wherein the step of setting a machine code instruction deposit path in the virtual machine execution code to empty when the kernel is first loaded after installation thereof, comprises:
calling a corresponding function through the virtual machine for creating the virtual environment on the android system to directly load the loading file;
and newly building a kernel loading thread, and calling a compiling function through the virtual machine for creating the virtual environment on the android system to generate a machine code instruction corresponding to the loading file.
5. The method of claim 4, wherein the step of generating the machine code instructions corresponding to the loaded file by calling a compiled function through the virtual machine for creating a virtual environment on the android system comprises:
using the virtual machine for creating a virtual environment on the android system to call an open view function to check the loading file in a class connector;
and when the loading file is not analyzed, using the virtual machine for creating the virtual environment on the android system to call the compiling function to create a process for compiling the loading file into the machine code instruction.
6. An apparatus for loading a kernel, the apparatus comprising:
a first loading judgment module: the method comprises the steps that when an application program is started, a loading instruction of a kernel corresponding to a software development kit of the application program is obtained, and the loading instruction is used for judging whether the kernel is loaded for the first time after the kernel is installed;
deposit the route and set up the module: when the kernel is loaded for the first time after the kernel is installed, setting a storage path of a machine code instruction corresponding to a loading file of the kernel in a virtual machine execution code to be null, so that the virtual machine execution code does not compile the loading file of the kernel;
the application program obtains the browsing service provided by the kernel through the software development toolkit, and the loading file is loaded through a virtual machine used for creating a virtual environment on the android system.
7. The apparatus of claim 6, wherein the storage path setting module comprises:
a creation unit: the system comprises a loader, a file management module and a file management module, wherein the loader is used for creating a loading file class loader, the loading file class loader inherits to a loading file base class loader, and the loading file base class loader is used for analyzing a loading file into classes;
an adjusting unit: and the system is used for transferring the class processing task of the loading file class loader to the loading file base class loader for execution, and setting an optimized path in an execution code of the loading file base class loader to be null.
8. The apparatus of claim 7, wherein the adjusting unit comprises:
a construction subunit: the system comprises a base class loader, a file derivation class loader and a file derivation class loader, wherein the base class loader is used for constructing a loading file derivation class loader, and the loading file derivation class loader is inherited from the loading file base class loader;
a decoupling subunit: and the method is used for decoupling the loaded file derivation class loader and the loaded file class loader in a proxy mode.
9. The apparatus of claim 6, further comprising:
a first loading module: the loading file is directly loaded by calling a corresponding function through the virtual machine for creating the virtual environment on the android system;
a second loading module: and the method is used for newly building a kernel loading thread, and calling a compiling function through the virtual machine for creating the virtual environment on the android system to generate a machine code instruction corresponding to the loading file.
10. The apparatus of claim 9, wherein the second load module comprises:
an inspection unit: checking the load file in a class connector using the virtual machine call open view function for creating a virtual environment on the android system;
an analysis unit: and when the loading file is not analyzed, using the virtual machine for creating the virtual environment on the android system to call the compiling function to create a process for compiling the loading file into the machine code instruction.
CN201910168640.6A 2019-03-06 2019-03-06 Kernel loading method and device Active CN109933381B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910168640.6A CN109933381B (en) 2019-03-06 2019-03-06 Kernel loading method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910168640.6A CN109933381B (en) 2019-03-06 2019-03-06 Kernel loading method and device

Publications (2)

Publication Number Publication Date
CN109933381A CN109933381A (en) 2019-06-25
CN109933381B true CN109933381B (en) 2021-07-16

Family

ID=66986301

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910168640.6A Active CN109933381B (en) 2019-03-06 2019-03-06 Kernel loading method and device

Country Status (1)

Country Link
CN (1) CN109933381B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110543338A (en) * 2019-09-09 2019-12-06 北京安云世纪科技有限公司 dynamic loading method and device for files
CN111240766B (en) * 2020-01-22 2023-12-29 抖音视界有限公司 Application starting method and device, electronic equipment and computer readable storage medium
CN111338636B (en) * 2020-02-21 2023-09-26 北京小米松果电子有限公司 Kernel preprocessing method, kernel preprocessing device and electronic equipment
CN112540929B (en) * 2020-12-25 2024-03-12 北京百度网讯科技有限公司 Detection method, detection device, detection equipment and storage medium
CN113934461B (en) * 2021-09-26 2023-10-13 厦门亿联网络技术股份有限公司 DEX-based android system formatting method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6698015B1 (en) * 2000-06-13 2004-02-24 Cisco Technology, Inc. Apparatus and method for improving performance of critical code execution
CN105303072A (en) * 2015-10-26 2016-02-03 李晖 ART mode based software hardening method and apparatus
CN108415737A (en) * 2018-02-07 2018-08-17 北京奇虎科技有限公司 A kind of method and electric terminal loading plug-in unit in virtual machine

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7150012B2 (en) * 2002-10-15 2006-12-12 Nokia Corporation Method and apparatus for accelerating program execution in platform-independent virtual machines

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6698015B1 (en) * 2000-06-13 2004-02-24 Cisco Technology, Inc. Apparatus and method for improving performance of critical code execution
CN105303072A (en) * 2015-10-26 2016-02-03 李晖 ART mode based software hardening method and apparatus
CN108415737A (en) * 2018-02-07 2018-08-17 北京奇虎科技有限公司 A kind of method and electric terminal loading plug-in unit in virtual machine

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
Android ART dex2oat 加载加速浅析;weixin_34417183;《https://blog.csdn.net/weixin_34417183/article/details/91393501》;20190108;第1-16页 *

Also Published As

Publication number Publication date
CN109933381A (en) 2019-06-25

Similar Documents

Publication Publication Date Title
CN109933381B (en) Kernel loading method and device
CN109358936B (en) Information processing method, device, storage medium, electronic device and system
US9800609B2 (en) Method, device and system for detecting malware in a mobile terminal
CN109408136B (en) Information processing method, information processing apparatus, storage medium, and electronic device
US10186244B2 (en) Sound effect processing method and device, plug-in unit manager and sound effect plug-in unit
CN106502703B (en) Function calling method and device
CN110058850B (en) Application development method and device and storage medium
CN107741844B (en) Method and device for generating application installation package
CN114185491B (en) Partition file downloading method and device, storage medium and computer equipment
CN109800030B (en) Application program running method and device and terminal
KR20120088199A (en) Apparatus and method for providing advertisement information inserted application
US20150091935A1 (en) Method and device for browsing web under weak light with mobile terminal browser
CN104965722B (en) A kind of method and device of display information
CN107992498B (en) Method and system for importing data into data warehouse
WO2014161353A1 (en) Method for starting process of application and computer system
EP2869604B1 (en) Method, apparatus and device for processing a mobile terminal resource
CN111078316B (en) Layout file loading method and device, storage medium and electronic equipment
CN112308947A (en) Animation generation method and device and storage medium
CN110020338B (en) Browser and webpage opening method and device
EP4024208A1 (en) Method for launching quick application, and related device
CN107463395B (en) Component calling method and device
CN104615622A (en) Document opening method and device and mobile terminal
CN108920246B (en) Form draft component sharing method and device, terminal device and readable storage medium
CN109145598B (en) Virus detection method and device for script file, terminal and storage medium
CN109144692A (en) A kind of method, apparatus and terminal for the process of distributing

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
GR01 Patent grant
GR01 Patent grant