Application installation method, device, server and computer readable medium

By precompiling the application installation files on the server side and sending machine code, the problem of excessively long application installation in the existing technology is solved, and a more efficient installation process is achieved.

CN112631622BActive Publication Date: 2024-11-12GUANGDONG OPPO MOBILE TELECOMMUNICATIONS CORP LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202011595405.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-29
Publication Date
2024-11-12
Estimated Expiration
2040-12-29

AI Technical Summary

Technical Problem

During the installation of existing applications, the terminal needs to download the installation package and compile it locally, which results in too long installation and consumes a lot of resources, especially when multiple applications are installed, which affects efficiency.

Method used

The application installation files are obtained and compiled in advance on the server side, generated machine code, and sent the installation files and compiled output files to the user terminal. The user terminal directly uses machine code to install, skipping the local compilation process.

Benefits of technology

Reduces application installation time, improves installation efficiency, and reduces the consumption of user terminal resources, especially when multiple applications are installed, which significantly improves speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112631622B_ABST
    Figure CN112631622B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses an application installation method, device, server and computer-readable medium, which relates to the field of computer technology. The method includes: obtaining a download request of a target application sent by a user terminal; obtaining the installation file of the target application and the compiled output file corresponding to the installation file based on the download request, wherein the compiled output file includes the machine code of the installation file; sending the installation file and the compiled output file corresponding to the installation file to the user terminal, instructing the user terminal to install the target application according to the installation file and the compiled output file. Therefore, the compilation operation of the installation file is performed by the server, and then the user terminal can obtain the installation file and the corresponding machine code at the same time, and can skip the compilation link of the installation file when installing locally, thereby reducing the installation time and improving the installation efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to an application installation method, device, server, and computer-readable medium. Background Art

[0002] Currently, the application installation / upgrade process is that the terminal downloads the installation package from the cloud, parses the installation package to extract application parameters, generates compilation instructions, executes the compilation instructions to generate compilation output files, and completes the installation. This will cause the installation process to take too long. Summary of the invention

[0003] The present application proposes an application installation method, device, server and computer-readable medium to improve the above-mentioned defects.

[0004] In a first aspect, an embodiment of the present application provides an application installation method, which is applied to a server, and the method includes: obtaining a download request for a target application sent by a user terminal; obtaining an installation file of the target application and a compiled output file corresponding to the installation file based on the download request, wherein the compiled output file includes a machine code of the installation file; sending the installation file and the compiled output file corresponding to the installation file to the user terminal, instructing the user terminal to install the target application according to the installation file and the compiled output file.

[0005] In a second aspect, an embodiment of the present application also provides an application installation method, which is applied to a user terminal, and the method includes: sending a download request for a target application to a server; obtaining an installation file of the target application sent by the server based on the download request and a compiled output file corresponding to the installation file, wherein the compiled output file includes a machine code of the installation file; and installing the target application according to the installation file and the compiled output file.

[0006] In a third aspect, an embodiment of the present application further provides an application installation device, which is applied to a server, and the device includes: an acquisition unit, a search unit, and a sending unit. The acquisition unit is used to acquire a download request of a target application sent by a user terminal. The search unit is used to acquire an installation file of the target application and a compiled output file corresponding to the installation file based on the download request, wherein the compiled output file includes a machine code of the installation file. The sending unit is used to send the installation file and the compiled output file corresponding to the installation file to the user terminal, instructing the user terminal to install the target application according to the installation file and the compiled output file.

[0007] In a fourth aspect, an embodiment of the present application further provides an application installation device, which is applied to a user terminal, and the device includes: a request unit, a determination unit, and an installation unit. The request unit is used to send a download request of a target application to a server. The determination unit is used to obtain an installation file of the target application sent by the server based on the download request and a compiled output file corresponding to the installation file, wherein the compiled output file includes a machine code of the installation file. The installation unit is used to install the target application according to the installation file and the compiled output file.

[0008] In the fifth aspect, an embodiment of the present application also provides a server, comprising: one or more processors; a memory; one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the above method.

[0009] In a sixth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the readable storage medium stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the above method.

[0010] The application installation method, device, server and computer-readable medium provided by the present application, after the server obtains the download request of the target application sent by the user terminal, obtains the installation file of the target application and the compiled output file corresponding to the installation file based on the download request. The compiled output file includes the machine code of the installation file, and sends the installation file and the compiled output file corresponding to the installation file to the user terminal, instructing the user terminal to install the target application according to the installation file and the compiled output file. Thus, the compilation operation of the installation file is performed by the server, and then the user terminal can obtain the installation file and the corresponding machine code at the same time, and can skip the compilation of the installation file when installing locally, thereby reducing the installation time and improving the installation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 A schematic diagram of an application scenario of the method and device provided in an embodiment of the present application is shown;

[0013] Figure 2A schematic diagram showing an installation interface of an application provided in an embodiment of the present application is shown;

[0014] Figure 3 A method flow chart of an application installation method provided by an embodiment of the present application is shown;

[0015] Figure 4 A method flow chart of an application installation method provided by another embodiment of the present application is shown;

[0016] Figure 5 A method flow chart of an application installation method provided by another embodiment of the present application is shown;

[0017] Figure 6 A method flow chart of an application installation method provided by another embodiment of the present application is shown;

[0018] Figure 7 A module block diagram of an application installation device provided by an embodiment of the present application is shown;

[0019] Figure 8 A module block diagram of an application installation device provided by another embodiment of the present application is shown;

[0020] Fig. 9 A module block diagram of an electronic device provided in an embodiment of the present application is shown;

[0021] Fig.10 A storage unit for storing or carrying program code for implementing the application installation method according to an embodiment of the present application is provided in an embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.

[0023] Android has two virtual machine execution environments: Dalvik and Art. Under the Dalvik virtual machine, every time an application runs, the bytecode needs to be converted into machine code through a just-in-time compiler (JIT) before it can be run by the machine, which slows down the execution efficiency of the application. In Android 4.4, the Art virtual machine began to replace Dalvik. In the earliest Art virtual machine, when the application was installed for the first time, the system would use a tool called dex2oat to compile the dex file in the APK into an oat file containing local machine code and store it. Specifically, dex2oat can be executed to compile classes.dex in the APK to generate machine code (base.odex). After doing this, when the program is executed, the compiled machine code can be used directly to speed up efficiency. This mechanism of pre-compiling machine code is called AOT.

[0024] Specifically, see Figure 1 , shows an application scenario diagram of the method and device provided in the embodiment of the present application. Figure 1 As shown in , the user terminal 10 and the server 20 are located in a wireless network or a wired network, and the user terminal 10 and the server 20 perform data interaction.

[0025] In the embodiment of the present application, the user terminal 10 may be a mobile terminal device, such as a smart phone, a tablet computer, an e-book reader, a laptop computer, a car computer, a wearable mobile terminal, etc.

[0026] In some embodiments, the client is installed in the user terminal 10, for example, it can be an application installed in the user terminal 10. In the embodiment of the present application, the client is an application center client, and the application center client is a service software. The user can download new applications through the application center client, and can also update and start an installed application. The user logs in to the application center client through an account, and all information corresponding to the account can be stored in the storage space of the server 20. The server 20 can be a separate server or a server cluster, a local server or a cloud server. Among them, the login account of the application center client is bound to the mobile terminal on which the application center client is currently installed, and the server can store relevant data of the application in the mobile terminal, such as information such as the installed applications and the version number of the applications.

[0027] Specifically, the application center client includes multiple interfaces, and different interfaces display different content. Figure 2As shown, the application installation interface of the application center client is shown. In this interface, multiple applications and operation buttons corresponding to each application are generally displayed. The operation button can be installation or update, that is, the user can perform installation or update operations on the application in this interface.

[0028] The inventor found in the study that when the user terminal downloads a certain application, it first downloads the installation package of the application from the server 20, then parses the installation package to extract application parameters, generates compilation instructions, executes the compilation instructions to generate compilation output files, and completes the installation. However, the compilation process is executed in the user terminal, which consumes a lot of resources (such as CPU, memory and power consumption) of the user terminal. Moreover, the compilation of the machine code is triggered during the installation process of the application, which means that the time-consuming compilation (the larger the amount of code, the more and more compilation optimizers, the more complex, and the greater the execution time-consuming) will greatly increase the installation time. Limited by the resources of the user terminal (mainly CPU and memory), it is impossible to execute too complex optimizers in the user terminal, which has a great impact on the quality of the compiled machine code. In addition, when the user terminal needs to install multiple applications, the installation or update of each application requires the compilation operation to be performed in the user terminal, which means that the compilation time of the application is proportional to the number of applications installed in the user terminal, and the more the number, the longer the total compilation time of the application.

[0029] Therefore, in order to overcome the above defects, the embodiment of the present application provides an application installation method, which is applied to the above server 20. Specifically, Figure 3 As shown, the method includes: S301 to S303.

[0030] S301: Obtain a download request for a target application sent by a user terminal.

[0031] As an implementation method, the server can be a business server or a data server. Specifically, the data server can be a server corresponding to a client, and the client can be a server corresponding to an application center. As an implementation method, the application center client can be a client for users to download and update applications. Users download applications to user terminals or update applications in user terminals through the application center client. The developer of the application uploads the installation package of the application to the data server, so that each user terminal can download the installation package of the application from the data server.

[0032] Among them, the business server can be a server for performing compilation-related operations on the application in the data server, wherein the compilation-related operations include compiling the installation package of the application and collecting hotspot codes of the application. The business server can obtain the installation package of the application from the data server, compile the installation package in the business server, and perform the operations of the embodiment of the method of the present application. As an implementation method, the business server can also send the compiled output file to the data server for storage after compiling the installation package.

[0033] Therefore, the server 20 may be a business server or a cluster server composed of a business server and a data server.

[0034] After the user terminal sends a download request to the server, the server parses the download request to obtain the application identifier of the target application and the user identifier corresponding to the user terminal. Among them, the user identifier corresponding to the user terminal is the user account currently logged in to the user terminal. As an implementation method, the server is a business server corresponding to an application center client (for example, an application store APP), then the user account is the user ID for logging in to the application center client. As another implementation method, the user account can also be the terminal identifier of the user terminal, and the terminal identifier can be the device ID of the user terminal, for example, the processor ID, IP address or MAC address of the user terminal.

[0035] In addition, the target application may be an application that the user requests to download or update. As an implementation mode, the user terminal is installed with an application center client, and the application center client includes a download interface, and the download interface displays multiple application identifiers and corresponding download buttons or update buttons, wherein the application identifier may be an application icon and name, and the user clicks the name or icon of the target application corresponding to the download button, and the user terminal detects that the download button is triggered and sends a download request corresponding to the application identifier of the target application to the business server.

[0036] S302: Acquire the installation file of the target application and the compiled output file corresponding to the installation file based on the download request.

[0037] The compiled output file includes the machine code of the installation file, and the compiled output file is obtained in advance by the server. The download request may be an installation request or an update request. Specifically, the server may pre-compile the installation file by specifying a compiler to obtain the compiled output file, or other terminals may pre-compile the installation file to obtain the compiled output file and then upload the compiled output file to the server. The other terminals are terminals other than the user terminal that sends the download request.

[0038] As an implementation mode, the download request may be sent to the server when the user terminal requests to update the target application, and the download request is an update request. The download request carries the target version number of the target application installed in the user terminal, and the server can find the installation file based on the target version number. Specifically, the installation data between the target version number and the latest version of the target application may be determined as the installation file, wherein the installation file is used to upgrade the target application of the target version number to the latest version of the target application.

[0039] As another implementation, the download request may be sent to the server when the user terminal requests to install the target application, and the download request is an installation request, that is, the target application is not currently installed in the user terminal. The installation file searched based on the installation request is the installation file of the latest version of the application, which is used as the installation file of the target application.

[0040] As an implementation, the compiled output file includes the machine code of the installation file, for example, the machine code may be code that can be directly executed by computer hardware. Specifically, the source code in the installation file (for example, java code) is compiled into a class file by javac, then converted into bytecode by dx / d8, and then converted into machine code by a designated compiler.

[0041] Among them, bytecode is a binary file containing an executable program and composed of a sequence of op code / data pairs. Bytecode is an intermediate code that is more abstract than machine code. It is often regarded as a binary file containing an executable program, more like an object model. The name bytecode comes from the fact that each op code is usually one byte long, but the length of the instruction code varies. Each instruction has a one-byte opcode from 0 to 255 (or hexadecimal: 00 to FF), followed by parameters such as registers or memory addresses. Bytecode is mainly used to implement specific software operations and software environments, and is independent of the hardware environment. It is compiled through a compiler and a virtual machine. The compiler compiles the source code into bytecode, and the virtual machine on a specific platform translates the bytecode into instructions that can be directly executed. For example, the JIT virtual machine on the Android platform can convert it into instructions that can be directly executed on the Android platform.

[0042] In an embodiment of the present application, the compiled output file is obtained by the server in advance by performing a compile operation on the installation file through a designated compiler. Specifically, the server converts the source code of the installation file into an intermediate bytecode for the subsequent compilation into a machine code. After obtaining the above intermediate code, the server can use the designated compiler to compile the intermediate code to obtain the final machine code. The electronic device can save the generated binary machine code, and when running the application, the machine code can be directly handed over to the processor for operation, thereby greatly improving the speed of the application at runtime. In some embodiments, the compiled file obtained by the electronic device compiling the intermediate code can at least include base.odex, which is the machine code. Of course, the compilation result can also include other files, for example, base.art (class initialization information), base.vdex (dex verification information), etc. In an embodiment of the present application, the designated compiler can be a just-in-time compiler (JIT).

[0043] As an implementation method, the designated compiler can be an AOT compiler (Ahead-of-Time Compiler). When the application is installed for the first time, the system will compile the dex file in the APK into an oat file containing local machine code through a tool called dex2oat. The compiler used in the compilation process is the AOT compiler. After doing so, when the program is executed, the compiled machine code can be directly used to speed up efficiency.

[0044] As an implementation mode, before or when the installation file of the target application is released, the server can obtain the installation file of the target application, compile the installation file by specifying a compiler, and obtain a compiled output file, and the compiled output file includes a machine code. Therefore, the server can pre-store the installation files of multiple applications and the compiled output files corresponding to the installation files of each application. For example, an installation correspondence table may be pre-set, and the installation correspondence table may include an application identifier of each application and a compiled output file corresponding to each application identifier. As an implementation mode, the application may include multiple versions, and each version number of the application corresponding to each application identifier corresponds to a compiled output file, or the corresponding table may include a compiled output file corresponding to the version number of the latest version of the application corresponding to the application identifier. The server parses the download request to obtain the application identifier of the target application, and searches the installation correspondence table for the compiled output file and the installation file corresponding to the application identifier based on the application identifier.

[0045] S303: Send the installation file and the compiled output file corresponding to the installation file to the user terminal.

[0046] Specifically, the server sends the installation file and the compiled output file corresponding to the installation file to the user terminal, and instructs the user terminal to install the target application according to the installation file and the compiled output file.

[0047] Among them, the installation file can be an installation package (Android Package, APK). The source code of the application is first compiled into a DEX file by the SDK. The DEX file and some resource files (pictures, videos, etc.), Native Code (.so files compiled by C language, etc.) will be directly packaged into the APK. The process of installing APK is actually the process of decompressing the installation package. Resource files, binary libraries, etc. are directly stored locally after decompression. DEX files are not only decompressed, but also processed into files of different formats according to the operating environment of the system, and stored locally, waiting for the program to start calling, thereby completing the installation process of the application. Among them, the files of different formats may include compiled output files.

[0048] Therefore, in an embodiment of the present application, after sending a download request for the target application, the user terminal obtains the installation file of the target application and the compiled output file corresponding to the installation file. The user terminal obtains the compiled output file and no longer needs to compile the installation file to obtain machine code, that is, the process of compiling the source code into machine code is skipped. Specifically, the process of compiling the class file (classes.dex) in the installation file to obtain machine code is skipped. In other words, dex2oat compilation is not performed, and the machine code in the compiled output file sent by the server is directly used to complete the installation of the target application.

[0049] See also Figure 4 , Figure 4 An application installation method provided in an embodiment of the present application is shown, and the method is applied to the above-mentioned server 20. Specifically, as Figure 4 As shown, the method includes: S401 to S408.

[0050] S401: Acquire hardware parameters of the user terminal.

[0051] The compilation logic of the user terminal is related to the hardware parameters of the user terminal.

[0052] As an implementation method, the compilation logic is instruction processing logic, specifically, it can be the code or function that needs to be called to achieve a certain function or effect, as well as the logic of the order of execution. When the hardware of the electronic device is different, its compilation logic is different. For example, the compilation logic of the ARM architecture processor and the x86 architecture processor are different. Among them, the ARM processor is based on the reduced instruction set computer (RISC) architecture, and the x86 is a complex instruction set computer (CISC) architecture. The addressing modes and instruction formats of the two are different.

[0053] In an embodiment of the present application, the hardware parameter may be architecture information of a processor of a user terminal. The server obtains the architecture information and determines the compilation logic of the user terminal based on the architecture information. The compilation logic may be pre-stored and stored corresponding to the hardware parameter. For example, a compilation correspondence table may be set, which includes a plurality of hardware parameters and a compilation logic corresponding to each hardware transmission.

[0054] As an implementation method, the compilation logic can be an instruction processing method. For example, if the hardware parameter is an arm architecture, the corresponding compilation logic is an instruction processing method corresponding to a reduced instruction set computing (RISC) architecture. If the hardware parameter is an x86 architecture, the corresponding compilation logic is an instruction processing method corresponding to a complex instruction set computing (CISC) architecture.

[0055] As another implementation, the hardware parameter may also be a processor model, and after obtaining the processor model, the server determines the compilation logic corresponding to the model. Specifically, the server may determine the architecture information corresponding to the processor model, and then determine the compilation logic based on the architecture information.

[0056] S402: Setting a designated compiler based on the hardware parameters, wherein the designated compiler matches the compilation logic of the user terminal.

[0057] As an implementation mode, an initial compiler is provided in the server, and the initial compiler may be a compiler that matches the hardware parameters of the server, that is, the initial compiler is related to the hardware parameters of the server. Then the implementation mode of setting the designated compiler based on the hardware parameters may be to determine whether the hardware parameters of the user terminal match the hardware parameters of the server, and if so, use the initial compiler as the designated compiler, and if not, modify the initial compiler based on the hardware parameters to obtain the designated compiler, wherein the designated compiler matches the compilation logic of the user terminal. Specifically, the compilation logic corresponding to the hardware parameters is determined according to the hardware parameters of the user terminal, and the compilation logic of the initial editor is modified based on the compilation logic, so that the compilation logic of the modified initial compiler is consistent with the compilation logic of the user terminal. As an implementation mode, the designated compiler is dex2oat.

[0058] Since the hardware parameters of the server are different from those of the user terminal, for example, the server is an x86 architecture and the user terminal is an arm architecture, the compilation logic of dex2oat in the server is adjusted so that the machine code output by the x86 and arm versions of dex2oat for compiling the installation files of the target application is consistent. In addition, the compilation logic part of dex2oat has an extensible interface that can introduce different compiler backends and optimization algorithms to achieve the purpose of optimizing machine code.

[0059] S403: Acquire the installation file of the target application and the system resources of the user terminal.

[0060] As an implementation method, the user terminal needs to rely on the system resources of the user terminal to execute the specified compiler. The system resources may include system images such as boot.art, system environment variables such as BOOTCLASSPATH, system configurations such as / system / build.prop, and system built-in libraries such as / system / etc / permissions / platform.xml. Specifically, the system resources serve as the compilation environment for the user terminal to run the specified compiler.

[0061] As an implementation mode, the server sends a resource acquisition request to the user terminal, and the user terminal sends the system resources of the user terminal based on the resource acquisition request.

[0062] As another implementation method, the server parses the flashing program of the user terminal and extracts the system resources therein. Specifically, it parses the flashing program of different versions of user terminals and extracts the configuration therein as required. Among them, the flashing program is the flashing package of different user terminals or operating systems (such as Android). The difference in user terminals will bring about hardware differences, and different Android versions will have code differences, resulting in differences in the Android Framework layer. The extracted content is mainly the Android system resources that the compilation depends on, including: all resources in the / system / framework directory (mainly system images such as boot.art and system classpath of the framework layer), system configuration files such as / build.prop and / system / build.prop, xml files in the / system / etc / permissions directory (mainly recording the system's built-in library, used to parse the classpath dependency in APK), and system environment variables such as BOOTCLASSPATH. These are all used to parse the installation file compilation command, as well as some system dependent resources for executing the compilation.

[0063] S404: Configuring a compilation environment matching the system resources of the user terminal in the server.

[0064] S405: Compiling the installation file through the specified compiler based on the compilation environment to obtain the compilation output file.

[0065] As an implementation method, a virtual machine is established in the server, and the virtual machine relies on the system resource configuration compilation environment of the user terminal, so that the server can simulate the compilation environment corresponding to the system resources of the user terminal, so that the server can compile the installation files of the target application under the compilation environment, so that the machine code compiled under the compilation environment can run normally in the user terminal and can match the compilation environment of the user terminal.

[0066] As an implementation method, according to the system environment of the user terminal where the APK needs to be installed, the compiler is matched with the Android version number, and the compilation environment of the mobile phone is matched with the OTA version number. In this way, it is ensured that the expected platform compilation can be correctly executed on the server side. Among them, the OTA version number is the unique version number of the operating system of the user terminal. According to this version number, the system resources and then the compilation environment can be uniquely determined, so that the compiled machine code can run in the system environment of the user terminal. For example, the OTA version number can be the ro.build.version.ota configuration in the operating system.

[0067] S406: Obtain a download request for the target application sent by the user terminal.

[0068] S407: Acquire the installation file of the target application and the compiled output file corresponding to the installation file based on the download request.

[0069] S408: Send the installation file and the compiled output file corresponding to the installation file to the user terminal.

[0070] As an implementation mode, for the parts of the above method not described in detail, please refer to the aforementioned embodiments and will not be repeated here.

[0071] Therefore, through the above method embodiment, a designated compiler is set based on the hardware parameters, and the designated compiler matches the compilation logic of the user terminal, so that the editor is migrated to the server, and a compilation environment that matches the system resources of the user terminal is configured, and based on the compilation environment, a compilation operation is performed on the installation file through the designated compiler to obtain the compilation output file, so that the compilation environment of the user terminal can be built in the server, so that the compilation output file edited in the server can be consistent with the compilation logic of the user terminal and can run in the operating system environment of the user terminal.

[0072] See also Figure 5 , Figure 5 An application installation method provided in an embodiment of the present application is shown, and the method is applied to the above-mentioned server 20. Specifically, as Figure 5 As shown, the method includes: S501 to S508.

[0073] S501: Acquire the installation file of the target application and the system resources of the user terminal.

[0074] S502: Configuring a compilation environment matching the system resources of the user terminal in the server.

[0075] S503: Compile the installation file using the specified compiler based on the compilation environment to obtain a machine code and a first verification file of the installation file.

[0076] The specified compiler and compilation environment obtained according to the above method embodiment perform a compilation operation on the installation file to obtain the machine code and the first verification file of the installation file. In some embodiments, the compilation result of the compilation operation may include not only the machine code and the first verification file, but also the class file initialization information. As an implementation method, the installation file is not modified during the entire compilation process, and the compilation result can obtain three files, namely the machine code (base.odex), the first verification file (base.vdex) and the file initialization information (base.art). Among them, the first verification file includes the class file in the installation file and the verification information corresponding to the class file, wherein the verification information is the verification result of the class file.

[0077] S504: Remove at least some of the class files from all the class files in the first verification file to obtain a second verification file.

[0078] Wherein, at least some of the class files may be some of the class files randomly selected from all the class files, or may be all the class files. Wherein, the random selection method may be to use the class files whose number of calls in a preset time period in all the class files meets the preset conditions as designated class files, and then delete the designated class files in all the class files of the first verification file to obtain the second verification file. Wherein, the preset time period and the preset conditions may be set according to actual needs. For example, the preset time period may be a month or a week, and the implementation method of the number of calls meeting the preset conditions may be the class files whose number of calls is less than the preset value or whose number of calls in all the class files ranks low. Specifically, the number of calls of each class file in the preset time period is obtained, and all the class files are sorted in a manner in which the number of calls gradually decreases, and the class files ranked after N are taken as designated class files, where N can be set according to actual experience, for example, it may be 10 or it may be 1 / M of the total number of class files, where M is a positive number. As an implementation method, the preset conditions and the number of calls correspond to the version of the application.

[0079] In an embodiment of the present application, the implementation method of removing at least some of the class files in all the class files from the first verification file to obtain the second verification file may be to remove all the class files from the first verification file to obtain the second verification file. Thus, by removing at least some of the class files in the first verification file, the size of the first verification file can be reduced, and the amount of data downloaded can be reduced.

[0080] As an implementation method, the second verification file can be obtained by differential processing. Specifically, the first verification file is differentially processed with all class files to remove all class files in the first verification file, and the first verification file after differential processing is used as the second verification file. The differential processing refers to taking the binary difference between file 1 and file 2 for two binary files, that is, removing the same parts of file 1 and file 2 from file 1, and only retaining the differences.

[0081] The compiled base.vdex contains the information of all dex in APK, that is, the binary compiled output file directly compiled by APK is base.vdex, where dex refers to the file after all java source codes of APK are merged. Therefore, in order to reduce the size of the generated compilation result, base.vdex is differentially processed to generate a differential package, which is the second verification file. As an implementation method, the bsdiff tool can be used for differential processing.

[0082] The purpose of differential processing is to reduce the total size of the compilation result. After the compilation is completed, the source APK remains unchanged, and three additional compilation output files are generated, namely base.odex, base.vdex, and base.art. These three files are the compilation output packages on the server side, namely the compilation output files mentioned above.

[0083] Therefore, differential processing can reduce the size of the compiled output file and reduce the time and traffic of network transmission. Among the three compiled output files, base.vdex will contain the information of classes.dex, and base.vdex is mainly composed of classes.dex and the verification result information of classes.dex. During installation, the source APK will be downloaded to the user terminal, that is, during installation, the user terminal can read the information of classes.dex from the source APK. Therefore, base.vdex (that is, the first verification file) can be differentially processed, and the compiled output package (release.zip) does not contain base.vdex, but the differentially processed file of base.vdex, that is, the second verification file (base.patch). During installation, classes.dex is read from the APK, and then combined with the differential package, it is restored back to base.vdex to install the target application.

[0084] As an implementation method, the installation file includes multiple class files. For the convenience of management and for the convenience of restoring the second verification file to the first verification file after differential processing, all class files in the APK can be sorted according to preset rules to obtain sorted class files. Therefore, during differential processing and when the user terminal subsequently restores the second verification file, the preset rules are used, so that the second verification file can be restored quickly and accurately.

[0085] The implementation method of removing at least part of all class files in the first verification file to obtain the second verification file may be to organize all class files according to preset rules to obtain organized class files; perform differential processing on the first verification file and the organized class files to remove at least part of all class files in the first verification file, and use the first verification file after differential processing as the second verification file.

[0086] The preset rule may be for naming each class file, and the files are sorted according to the naming rule of each class file. For example, class files with the same first letter are regarded as a subclass, and all subclasses are integrated to obtain the sorted class files. In the embodiment of the present application, all class files can be sorted in ascending alphabetical order and merged to obtain all.dex.

[0087] Specifically, there are multiple class files in the APK, and multiple class files generally use the naming rules of classes.dex, classes2.dex, classes3.dex, etc. As mentioned above, base.vdex contains the information of all class files (classes.dex). Therefore, the classes.dex in the APK can be merged into an all.dex in ascending alphabetical order to ensure that the differential package generated in this way is restored to base.vdex in the same way during installation, thereby ensuring that the user terminal is consistent with the base.vdex compiled and output by the server. Among them, all.dex is the sorted class file.

[0088] When the user terminal installs the target application, the user terminal generates all.dex according to the aforementioned arrangement method, performs bspatch on base.patch and all.dex, and restores them back to base.vdex, that is, performs the reverse operation of generating base.patch to obtain base.vdex.

[0089] Among them, bspatch can be regarded as the reverse process of bsdiff. Specifically, the process of bsdiff can be understood as comparing the binary differences of two files A and B. If bsdiff is performed on B based on A, the information stored in the generated differential packet is the binary difference of B relative to A. For example, if bytes 0 to 100 in B are the same as bytes 10 to 110 in A, then in the generated differential packet, bytes 0 to 100 in B will be removed and replaced with the position information corresponding to bytes 10 to 100 in A. The process of bspatch can be understood as restoring B based on A according to the difference information in the differential packet. For example, if the differential packet records the information that bytes 10 to 110 of A are the same as bytes 0 to 100 of B, then bytes 10 to 110 of A will be read as the 0 to 100 part of B.

[0090] S505: Obtain a compilation output file according to the second verification file and the machine code.

[0091] As an implementation method, the second verification file and the machine code may be packaged into a compilation output file.

[0092] As another implementation, the compilation result includes class file initialization information in addition to the second verification file and the machine code, and the second verification file, the machine code and the class file initialization information can be packaged into the compilation output file. Specifically, 3) compress base.art, base.odex, and base.patch into a zip package as a release package, i.e., a compilation output file. The server can upload the release package to the server of the application store, i.e., a data server, for downloading by the user terminal.

[0093] S506: Obtain a download request for the target application sent by the user terminal.

[0094] S507: Acquire the installation file of the target application and the compiled output file corresponding to the installation file based on the download request.

[0095] S508: Send the installation file and the compiled output file corresponding to the installation file to the user terminal.

[0096] In an embodiment of the present application, the content downloaded by the user terminal includes at least the installation file (APK) and the compiled output file corresponding to the installation file, that is, the above-mentioned release package. In some embodiments, APK is a separate package, that is, the application package installed by the user terminal. APK is provided by various developers and published to the application store. The server compiles and generates a separate package, namely the release package, which is a compressed package in zip format consisting of base.art, base.odex and base.patch. For developers, the APK has not been modified, and the compiled output file obtained by compilation is imperceptible to developers and users. The server is used to obtain the compilation result based on the APK and the compilation environment. Therefore, the server can establish a corresponding relationship between the APK and the compiled output file. When the user downloads and installs the APK, the compiled output file corresponding to the APK is obtained together with the corresponding relationship and sent to the user terminal.

[0097] As an implementation mode, the second verification file obtained by differential processing can reduce the size of the compiled output file. When installing the application, the user terminal needs to perform a restore operation on the second verification file to obtain the first verification file. Then, before performing the operation of removing at least part of all class files from the first verification file to obtain the second verification file, the network parameters of the user terminal can be determined. If the network parameters meet the preset network conditions, the operation of removing at least part of all class files from the first verification file is performed. If the network parameters do not meet the preset network conditions, the operation of removing at least part of all class files from the first verification file is not performed, and the first verification file is directly used as part of the compiled output file, that is, the compiled output file is obtained according to the first verification file and the machine code. Specifically, the first verification file, the machine code and the class file initialization information are packaged into the compiled output file.

[0098] The network parameter may be the network type and network quality of the user terminal.

[0099] As an implementation method, the network parameter may be a network type. If the network type is a cellular data network, the network parameter is determined to meet the preset network conditions, thereby reducing the amount of data downloaded by the user terminal. If the network type is a wireless network, the network parameter is determined to meet the preset network conditions, thereby reducing the time consumed by the user terminal to perform the restoration operation on the second verification file. Among them, the cellular data network (Cellular network), also known as the mobile network (mobile network), is a mobile communication hardware architecture. Specifically, the network service area is divided into many cells (cells, that is, "cells"), and each cell is provided with a base station, which is responsible for the communication and control of each mobile station in the cell. The cellular data network may be a 5G (5th Generation, 5G) communication system (or a new radio (NR) system), a long term evolution (LTE, Long Term Evolution) network, a general packet radio service (GPRS, General Packet Radio Service) system, a global system for mobile communications (GSM, Global System for Mobile communications) network or a universal mobile telecommunications network (UMTS, Universal Mobile Telecommunications System), and of course, other cellular networks. The wireless network may be a wireless local area network (WLAN, Wireless Local Area Networks), and specifically may be Wi-Fi (Wireless Fidelity, Wireless Fidelity).

[0100] As an implementation method, it is possible to determine whether the target application corresponding to the download request sent by the user terminal is a popular application. If it is a popular application, the installation file is directly sent to the user terminal. If it is not a popular application, the installation file of the target application and the compiled output file corresponding to the installation file as well as subsequent steps can be obtained based on the download request.

[0101] Since popular applications are used more frequently by users, too many hot codes may be generated when they are used. Therefore, no compilation operation may be performed during installation. When idle, the application is compiled to obtain machine code and stored based on the user's usage data. Specifically, dex will not be compiled again when the application is installed. When the App is running, the dex file is first executed directly through the parser. Frequently run functions or code blocks will be identified as hot codes and stored in the jit code cache after being JIT-compiled. A profile file will be generated to record the information of hot functions. When the phone enters the IDLE and Charging states, the system will scan the profile files in the App directory and execute the AOT process for compilation.

[0102] Specifically, the vast majority of applications on the Android platform are written in Java. Java programs were initially interpreted and executed only through the JAVA interpreter, that is, the bytecodes were interpreted and executed line by line. This method is relatively slow, especially when a method or code block runs very frequently. The execution efficiency of this method is very low. Later, the JIT compiler was introduced into the virtual machine. When the virtual machine finds that a method or code block runs very frequently, it will identify these codes as "hot spot code" and record them and save them in the profile file. In simple terms, the profile file records the methods or code blocks that are frequently run by the application. After JIT or AOT compilation, the .odex / .oat file is obtained. The file contains the binary machine code compiled from these hot spot codes, which can be directly handed over to the underlying CPU for execution, thereby improving the running speed.

[0103] The hot applications may be determined based on the user's historical usage records of the application program, or may be determined based on the user's user profile, and the hot applications may reflect that the user has a high frequency of use of the application program.

[0104] Therefore, in the embodiment of the present application, the compilation process is migrated from the mobile phone (arm) to the server (x86) to achieve cross-platform compilation. The compilation process is advanced to before the APK is installed to achieve pre-compilation. The server-side compilation does not depend on the mobile phone, and the automatic parsing of the mobile phone execution environment is realized; the compilation process is not limited by the mobile phone version, hardware resources, etc. During the compilation and installation process, no modification will be made to the source APK, and the developer will not feel anything at all.

[0105] See also Figure 6 , Figure 6 An application installation method provided in an embodiment of the present application is shown, and the method is applied to the above-mentioned server 10. Specifically, as Figure 6 As shown, the method includes: S601 to S603.

[0106] S601: Send a download request for a target application to a server.

[0107] S602: Acquire the installation file of the target application and the compiled output file corresponding to the installation file sent by the server based on the download request.

[0108] S603: Install the target application according to the installation file and the compiled output file.

[0109] The above implementation methods can refer to the aforementioned embodiments and will not be described in detail here.

[0110] Furthermore, the user terminal may also obtain a class file from the installation file; restore the second verification file to the first verification file according to the obtained class file; and install the target application according to the installation file, the machine code and the first verification file. The specific implementation method may refer to the above embodiment and will not be described in detail here.

[0111] As an implementation mode, the user terminal can send download requests to the server in batches, and the server determines whether to execute the operation of sending the installation file and the compiled output file corresponding to the installation file to the user terminal or the operation of sending the installation file to the user terminal according to the current time period. Specifically, it is determined whether the current time period is an idle time period for the user, wherein the idle time period refers to a time period in which the possibility or frequency of the user using the user terminal is relatively small, and specifically, the idle time period can be determined according to the time distribution of the user using the user terminal.

[0112] If the current period is an idle period, the operation of sending the installation file to the user terminal is performed, that is, only the installation file is sent, and after the user terminal receives the installation file, the application is installed according to the installation file, that is, the compilation operation is performed in the user terminal, thereby reducing unnecessary network resource occupation.

[0113] See also Figure 7 , which shows a structural block diagram of an application installation device provided in an embodiment of the present application. The application installation device 700 is applied to a server, and the device may include: an acquisition unit 701, a search unit 702 and a sending unit 703.

[0114] The acquisition unit 701 is used to acquire a download request of a target application sent by a user terminal.

[0115] The search unit 702 is used to obtain the installation file of the target application and the compiled output file corresponding to the installation file based on the download request, wherein the compiled output file includes the machine code of the installation file, and the compiled output file is obtained by the server in advance by performing a compilation operation on the installation file through a specified compiler.

[0116] The sending unit 703 is used to send the installation file and the compiled output file corresponding to the installation file to the user terminal, and instruct the user terminal to install the target application according to the installation file and the compiled output file.

[0117] Furthermore, the application installation device 700 also includes a compilation unit, which is used to obtain the installation file of the target application and the system resources of the user terminal; configure a compilation environment that matches the system resources of the user terminal in the server; and perform a compilation operation on the installation file through the specified compiler based on the compilation environment to obtain the compiled output file.

[0118] Specifically, the compiling unit is further used to obtain hardware parameters of the user terminal, and the compiling logic of the user terminal is related to the hardware parameters of the user terminal; and to set a designated compiler based on the hardware parameters, and the designated compiler matches the compiling logic of the user terminal.

[0119] Specifically, the compilation unit is also used to perform a compilation operation on the installation file through the specified compiler based on the compilation environment to obtain the machine code and a first verification file of the installation file, wherein the first verification file includes the class files in the installation file and the verification information corresponding to the class files; at least part of the class files in all the class files are removed from the first verification file to obtain a second verification file; and a compilation output file is obtained according to the second verification file and the machine code.

[0120] Specifically, the compilation unit is also used to perform a compilation operation on the installation file through the specified compiler based on the compilation environment to obtain the machine code, the first verification file and the class file initialization information of the installation file; and package the second verification file, the machine code and the class file initialization information into the compilation output file.

[0121] Specifically, the compilation unit is further configured to remove all class files from the first verification file to obtain a second verification file.

[0122] Specifically, the compilation unit is also used to organize all class files according to preset rules to obtain organized class files; perform differential processing on the first verification file and the organized class files to remove at least part of the class files in all class files in the first verification file, and use the first verification file after differential processing as the second verification file.

[0123] See also Figure 8 , which shows a structural block diagram of an application installation device provided in an embodiment of the present application. The application installation device 800 is applied to a user terminal, and the device may include: a request unit 801, a determination unit 802 and an installation unit 803.

[0124] The request unit 801 is used to send a download request of a target application to a server.

[0125] The determination unit 802 is used to obtain the installation file of the target application sent by the server based on the download request and the compiled output file corresponding to the installation file, wherein the compiled output file includes the machine code of the installation file, and the compiled output file is obtained by the server in advance by performing a compilation operation on the installation file through a specified compiler.

[0126] The installation unit 803 is used to install the target application according to the installation file and the compiled output file.

[0127] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0128] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0129] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0130] Please refer to Fig. 9, which shows a structural block diagram of an electronic device provided in an embodiment of the present application. The electronic device 100 may be the above-mentioned server or user terminal. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more application programs, wherein the one or more application programs may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0131] The processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 110 can integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.

[0132] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the terminal 100 during use.

[0133] Please refer to Fig.10, which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 1000 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0134] The computer readable storage medium 1000 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 1000 includes a non-transitory computer-readable storage medium. The computer readable storage medium 1000 has storage space for program code 1010 that performs any method step in the above method. These program codes can be read from or written to one or more computer program products. The program code 1010 can be compressed, for example, in an appropriate form.

[0135] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. An application installation method, characterized in that: Applied to a server, the method comprises: Obtain a download request for a target application sent by a user terminal; Acquire an installation file of the target application and a compiled output file corresponding to the installation file based on the download request, wherein the compiled output file includes a machine code of the installation file; The installation file and the compiled output file corresponding to the installation file are sent to the user terminal, instructing the user terminal to install the target application according to the installation file and the compiled output file; wherein, before obtaining the installation file of the target application and the compiled output file corresponding to the installation file based on the download request, the method further includes: Acquire the installation file of the target application and the system resources of the user terminal; Configuring a compilation environment in the server that matches the system resources of the user terminal; Compiling the installation file by specifying a compiler based on the compilation environment to obtain a machine code of the installation file and a first verification file, wherein the first verification file includes a class file in the installation file and verification information corresponding to the class file; Removing at least some of the class files from all the class files in the first verification file to obtain a second verification file; A compilation output file is obtained according to the second verification file and the machine code.

2. The method according to claim 1, characterized in that Before the step of performing a compiling operation on the installation file by specifying a compiler based on the compilation environment to obtain a machine code and a first verification file of the installation file, the step further includes: Acquiring hardware parameters of the user terminal, wherein the compilation logic of the user terminal is related to the hardware parameters of the user terminal; A designated compiler is set based on the hardware parameters, and the designated compiler matches the compilation logic of the user terminal.

3. The method according to claim 1, characterized in that: Compiling the installation file by using the specified compiler based on the compilation environment to obtain a machine code and a first verification file of the installation file, including: Based on the compilation environment, the installation file is compiled by the specified compiler to obtain the machine code, the first verification file and the class file initialization information of the installation file; The step of obtaining a compiled output file according to the second verification file and the machine code includes: The second verification file, the machine code and the class file initialization information are packaged into the compilation output file.

4. The method according to claim 1, characterized in that: The removing at least some of the class files from all the class files in the first verification file to obtain the second verification file includes: All class files are removed from the first verification file to obtain a second verification file.

5. The method according to claim 1, characterized in that: The removing at least some of the class files from all the class files in the first verification file to obtain the second verification file includes: Arrange all class files according to preset rules to obtain arranged class files; The first verification file and the sorted class file are differentially processed to remove at least part of all class files in the first verification file, and the first verification file after the differential processing is used as the second verification file.

6. An application installation method, characterized in that: Applied to a user terminal, the method comprises: Send a download request of the target application to the server; Acquire the installation file of the target application sent by the server based on the download request and a compiled output file corresponding to the installation file, wherein the compiled output file includes a machine code of the installation file; Install the target application according to the installation file and the compiled output file; The server pre-acquires the compiled output file based on the following method: Acquire the installation file of the target application and the system resources of the user terminal; Configuring a compilation environment in the server that matches the system resources of the user terminal; Compiling the installation file by specifying a compiler based on the compilation environment to obtain a machine code of the installation file and a first verification file, wherein the first verification file includes a class file in the installation file and verification information corresponding to the class file; Removing at least some of the class files from all the class files in the first verification file to obtain a second verification file; A compilation output file is obtained according to the second verification file and the machine code.

7. The method according to claim 6, characterized in that The step of installing the target application according to the installation file and the compiled output file comprises: Obtaining class files from the installation file; Restoring the second verification file to the first verification file according to the obtained class file; The target application is installed according to the installation file, the machine code and the first verification file.

8. An application installation device, characterized in that: Applied to a server, the device comprises: An acquisition unit, used for acquiring a download request of a target application sent by a user terminal; a search unit, configured to obtain, based on the download request, an installation file of the target application and a compiled output file corresponding to the installation file, wherein the compiled output file includes a machine code of the installation file; a sending unit, configured to send the installation file and a compiled output file corresponding to the installation file to the user terminal, and instruct the user terminal to install the target application according to the installation file and the compiled output file; A compilation unit, used for obtaining the installation file of the target application and the system resources of the user terminal before obtaining the installation file of the target application and the compilation output file corresponding to the installation file based on the download request; configuring a compilation environment matching the system resources of the user terminal in the server; performing a compilation operation on the installation file through a designated compiler based on the compilation environment to obtain a machine code and a first verification file of the installation file, wherein the first verification file includes a class file in the installation file and verification information corresponding to the class file; removing at least part of the class files in all the class files from the first verification file to obtain a second verification file; and obtaining a compilation output file according to the second verification file and the machine code.

9. An application installation device, characterized in that: Applied to a user terminal, the device comprises: A request unit, used for sending a download request of a target application to a server; a determining unit, configured to obtain an installation file of the target application sent by the server based on the download request and a compiled output file corresponding to the installation file, wherein the compiled output file includes a machine code of the installation file; An installation unit, used for installing the target application according to the installation file and the compiled output file; The server pre-acquires the compiled output file based on the following method: Acquire the installation file of the target application and the system resources of the user terminal; Configuring a compilation environment in the server that matches the system resources of the user terminal; Compiling the installation file by specifying a compiler based on the compilation environment to obtain a machine code of the installation file and a first verification file, wherein the first verification file includes a class file in the installation file and verification information corresponding to the class file; Removing at least some of the class files from all the class files in the first verification file to obtain a second verification file; A compilation output file is obtained according to the second verification file and the machine code.

10. A server, characterized in that: include: one or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method according to any one of claims 1-5.

11. A computer readable medium, characterized in that The computer-readable medium stores a program code executable by a processor, and when the program code is executed by the processor, the processor executes the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Method and device for protecting class files

    CN101957903A

  • Method, device and system for realizing Java application installation via cloud compilation

    CN105100191A

  • Application localized installation method and apparatus of Android device

    CN105843635A

  • Software package manufacturing method and device, and electronic equipment

    CN110780881A

  • Android function module development method

    CN111367510A