WO2019157891A1 - 应用安装方法、应用安装包的生成方法 - Google Patents

应用安装方法、应用安装包的生成方法 Download PDF

Info

Publication number
WO2019157891A1
WO2019157891A1 PCT/CN2019/071104 CN2019071104W WO2019157891A1 WO 2019157891 A1 WO2019157891 A1 WO 2019157891A1 CN 2019071104 W CN2019071104 W CN 2019071104W WO 2019157891 A1 WO2019157891 A1 WO 2019157891A1
Authority
WO
WIPO (PCT)
Prior art keywords
application installation
application
file
installation package
executable file
Prior art date
Application number
PCT/CN2019/071104
Other languages
English (en)
French (fr)
Inventor
李焰峰
张建
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2019157891A1 publication Critical patent/WO2019157891A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/41Compilation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation

Definitions

  • the present application relates to, but is not limited to, the field of computer technology, for example, to an application installation method and a method for generating an application installation package.
  • the embodiment of the present application provides an application installation method and a method for generating an application installation package, which can improve application installation speed.
  • An embodiment of the present application provides an application installation method, including:
  • An application installation operation is performed based on the application installation package; wherein the application installation operation skips the operation of compiling the dex bytecode into an executable file in the oat format.
  • An embodiment of the present application provides a method for generating an application installation package, including:
  • the optimized application file is packaged to generate an application installation package of the application.
  • the embodiment of the present application provides a terminal device, including: a first memory and a first processor, where the first memory is adapted to store an application installer, where the application installer is implemented by the first processor to implement the foregoing An application installation method provided on the one hand.
  • An embodiment of the present application provides a computing device, including: a second memory and a second processor, where the second memory is adapted to store a generating program of an application installation package, where the generating program is implemented by the second processor The method for generating an application installation package provided by the above second aspect.
  • the embodiment of the present application further provides a computer readable medium storing an application installation program, where the application installation program is executed by a processor to implement the application installation method provided by the first aspect.
  • the embodiment of the present application further provides a computer readable medium storing a generating program of an application installation package, where the generating program is executed by a processor to implement a method for generating an application installation package provided by the second aspect.
  • FIG. 1 is a flowchart of an application installation method according to an embodiment of the present application
  • FIG. 2 is a schematic diagram of an application installation operation process provided by an embodiment of the present application.
  • FIG. 3 is a flowchart of an example of an executable file parsing process in an embodiment of the present application
  • FIG. 5 is a schematic diagram of an application installation apparatus according to an embodiment of the present application.
  • FIG. 6 is a flowchart of a method for generating an application installation package according to an embodiment of the present application
  • FIG. 7 is a schematic diagram of an apparatus for generating an application installation package according to an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a terminal device according to an embodiment of the present application.
  • FIG. 1 is a flowchart of an application installation method according to an embodiment of the present application.
  • the application installation method provided in this embodiment can be executed by a terminal device (for example, a portable terminal such as a mobile phone or a notebook computer, or a fixed terminal such as a desktop computer).
  • a terminal device for example, a portable terminal such as a mobile phone or a notebook computer, or a fixed terminal such as a desktop computer.
  • this application is not limited thereto.
  • the application installation method provided in this embodiment includes: step S101 and step S102.
  • step S101 an application installation package is acquired.
  • the application installation package is optimized by compiling the dex bytecode into an executable file in the oat format; in other words, in this step, the application installation package optimized by the dex2oat operation is obtained.
  • step S102 an application installation operation is performed based on the application installation package.
  • the application installation operation skips the dex2oat operation.
  • the application installation package optimized by the dex2oat operation (the operation of compiling the dex bytecode into the oat format executable file) is obtained; and the application installation operation is performed based on the application installation package; wherein, the application installation operation is performed.
  • Skip the dex2oat operation In the embodiment of the present application, the pre-optimized application installation package is provided, and the dex2oat operation is skipped during the application installation process, thereby improving the application installation speed and improving the user experience.
  • the application installation method provided in this embodiment can be used to improve the installation speed of the Android application, thereby improving the experience of the Android user.
  • the terminal device may download the pre-optimized application installation package from the application mall or the application download website, and then perform an application installation or an overlay installation operation.
  • the pre-optimized application installation package may include various files that have been optimized by the dex2oat operation, such as DEX files, JAR files, and APK files.
  • the dex2oat operation refers to an operation of compiling the dex bytecode into an executable file in the oat format.
  • the DEX file after downloading the application installation package, the DEX file can be loaded into the memory, and the corresponding resource file is parsed and copied to the system installation directory; then, the class.dex file is decompressed to the system installation path.
  • the execution instruction dex2oat is executed, the execution of the instruction is skipped, and the odex file generated by the pre-compilation period (that is, the DEX file after pre-optimization) is installed to the system path.
  • the execution of other instructions does not affect.
  • FIG. 2 is a diagram showing an example of an application installation operation process according to an embodiment of the present application. As shown in FIG. 2, in this embodiment, performing an application installation operation may include: step S1021, step S1022, and step S1023.
  • step S1021 the application installation package is parsed.
  • step S1022 information verification and registration are performed based on the analysis result.
  • step S1023 an application authority update operation is performed.
  • step S1021 the reading of the xml file in the application installation package is completed, and the applied authority, various components (such as Activity), broadcast, and service are obtained; in step S1022, the permission and the right can be verified. Whether the signature is correct, and completing the registration of the broadcast, the service, etc.; in step S1023, according to the executable file (for example, the DEX file) in the pre-optimized application installation package, the system is notified of the permissions applied to all components and components of the application. Load and update. After the above process is finished, the application can be launched.
  • various components such as Activity
  • S102 may include performing an application installation operation based on the code that has been injected within the application installation package.
  • the DEX file obtained by the pre-existing dex2oat operation can be directly used in the application installation process, and the application installation process skips the dex2oat operation through the code injection technology, thereby improving the application installation speed.
  • S102 may include performing an application installation operation based on an Hook point that has been injected in an executable file of the application installation package. Among them, during the execution of the application installation operation, skip the dex2oat instruction (the instruction to compile the dex bytecode into an executable file in oat format).
  • Hook technology refers to the technique of filtering (or hooking) messages. It refers to filtering some key function calls. Before the function is executed, it executes a custom hook function to monitor function calls and change function functions.
  • the application installation operation is performed based on the injected Hook points in the executable file of the application installation package, which may include:
  • skipping loading the dex2oat instruction during the parsing of the executable file may include: when the function read() is read from the memory, if the content is read When the first Hook point is obtained, it jumps to the start address of the custom function read_handle() to skip loading the dex2oat instruction.
  • skipping execution of the dex2oat instruction during execution of the instruction may include: when the function execv() is read from the memory and executed, if the instruction is read And execute to the second Hook point, then jump to the start address of the custom function execv_handle () to skip the execution of the dex2oat instruction.
  • the application installation process sends the installation request to the package management service (PackageManagerService of the service layer) through the interprocess communication method. PMS); After receiving the installation request, the PMS can invoke the service process to perform an application installation operation.
  • PackageManagerService of the service layer
  • FIG. 3 is a flowchart of an example of an executable file parsing process in an embodiment of the present application.
  • the executable file (for example, DEX file) parsing process corresponds to a read_handle() instruction execution process, jump to the custom process through read_handle(), skip the loading process of the original dex2oat instruction, and then Read_handle() executes the execution before the jump back to the execution stack, and then parses the next instruction.
  • the PMS can load the DEX file into memory first, and then read the memory contents for parsing by running the read() function.
  • the read () function is a system function for reading content from the corresponding address.
  • the process of the present example may include: in steps S301 to S306.
  • step S301 the PMS call service process runs to the read() function, reads the memory contents, and records the read ith byte as read[i].
  • the read() function can sequentially read the byte structure of the set length from the memory, for example, according to 32 bits or 64 bits of word length.
  • step S302 the read byte is sequentially processed to determine whether read[i] is the address of the custom function read_handle(); if it is judged that read[i] is not the address of the custom function read_handle(), then read[i] For normal program content, you can only load read[i] into memory; if read[i] is the address of the custom function read_handle(), then read[i] is the Hook point (corresponding to the first Hook above) Point), jump to the start address of the custom function read_handle(), and then execute step S303 to skip loading the dex2oat instruction.
  • read_handle () is a custom function in this example, Hook jump function, you can add custom implementation functions in the custom function.
  • step S303 the read_handle() function is loaded into the memory.
  • memory copying by the mmap function will save the data to the buffer area of the memory; where the mmap function is used to map a file or object into memory.
  • the acquired data may include data included in the application, such as a code file, a resource file, a declaration file, and a class file, and are represented in binary form in the memory.
  • j 0, 1, ... i; that is, the read[j] instruction is read.
  • read the read[0] instruction from the memory of the read() function read the read[1] instruction from the memory of the read() function, and record the corresponding instruction content in memory, such as ldr pc ( The data is transferred to the PC register).
  • step S305 it is determined whether the read j-th segment byte is the address of read[i+1], and if it is determined that the read j-th segment byte is not the address of read[i+1], then returning to step S304, The reading of the j-th byte is continued, and if it is judged that the read j-th byte is the address of read[i+1], step S306 is performed.
  • step S306 after the reading and copying of the above instruction content is completed, the read_handle() function jump is terminated and returned to the original read() function.
  • FIG. 4 is a flowchart of an example of an instruction execution process according to an embodiment of the present application.
  • the instruction execution process can find the custom function at runtime and skip the execution of the dex2oat instruction.
  • the instruction execution process can be implemented by the PMS based on the parsing result of the DEX file and running the execv() function after parsing the DEX file.
  • the execv () function usually runs after the fork sub-thread, execv () will stop executing the current process, according to the parameters passed into the target function process.
  • the process of the present example may include steps S401 to S410.
  • step S401 the execv() function is executed by the PMS calling service process, and the command line parameters passed by the system runtime are read and executed by the execv() function.
  • the command line parameters include the instructions to be executed in the memory.
  • the ith byte read is recorded as execv[i].
  • BX instruction jump to the target address specified in the instruction, the instruction at the target address can be either an ARM instruction or a Thumb instruction;
  • Nop instruction A null instruction that does not perform any processing when it is run, but takes up one instruction.
  • the meaning of the instructions can be defined by reference to the assembly standard instructions. This application is not limited thereto.
  • the ARM instruction is taken as an example for explanation.
  • the Advanced RISC Machine (ARM) instruction set refers to the computer ARM operating instruction system. There are two ways to implement program jumps in ARM: one is a jump instruction; the other is to write the target address value directly into the PC register (R15).
  • the instructions are sequentially read according to the specified byte size.
  • the read command 1 is Bx pc
  • the read command 2 is an empty command, and such instructions are sequentially read into the register.
  • step S402 it is determined whether execv[i] is an empty command; if it is determined that execv[i] is an empty command, then returning to step 401 to continue reading the next instruction; if it is determined that execv[i] is not an empty instruction, then executing the step S403.
  • step S403 it is determined whether execv[i] is the address of the custom function execv_handle(). If it is determined that execv[i] is not the address of the custom function execv_handle(), then returning to step S401, if it is judged that execv[i] is self Defining the address of the function execv_handle() means that execv[i] is a Hook point (corresponding to the second Hook point mentioned above), jumping to the start address of the custom function exec_handle(), executing step S404 to skip execution of dex2oat instruction.
  • execv_handle () is a custom function in this example, Hook jump function, you can add custom implementation functions in the custom function.
  • step S404 the execv_handle() function is executed.
  • step S406 it is determined whether execv[j] is an ARM instruction, and if so, S407 is executed, otherwise, S408 is executed.
  • step S407 the execv[j] instruction is switched to the execution mode of the ARM instruction, for example, the instruction ldr pc is executed, and then S408 is executed.
  • step S408 the instruction at the execv[j+1] byte is read and executed.
  • step S409 it is determined whether the j+1th byte is an address of exevc[i+1], and if it is determined that the j+1th byte is not the address of exevc[i+1], then returning to step S405, if it is determined If the j+1th byte is the address of exevc[i+1], step S410 is performed.
  • step S410 after the reading and execution of the above instruction is completed, the execv_handle() function jump is ended, and the execv() function is returned.
  • FIG. 5 is a schematic diagram of an application installation apparatus according to an embodiment of the present application.
  • the application installation apparatus provided in this embodiment includes: an acquisition module 501 and an installation module 502.
  • the obtaining module 501 is configured to obtain an application installation package optimized by the dex2oat operation.
  • the installation module 502 is configured to perform an application installation operation based on the application installation package, wherein the application installation operation skips the dex2oat operation.
  • FIG. 6 is a flowchart of a method for generating an application installation package according to an embodiment of the present application. As shown in FIG. 6, the generating method provided in this embodiment includes: step S601 and step S602.
  • step S601 after the file is compiled by the application, the dex2oat operation is performed to obtain the optimized application file.
  • step S602 the optimized application file is packaged, and an application installation package of the application is generated.
  • This embodiment can be executed by an computing device (for example, a personal computer or the like) in an application development environment.
  • an application development environment By executing a dex2oat operation after compilation, a pre-optimized DEX file is obtained, so that the application installation process can skip the dex2oat operation.
  • the application includes an Android application.
  • the Android app is written in Java, compiles the code using the Software Development Kit (Android SDK), and packages all the data and resource files into a single compressed file (the app install package) that contains an Android app. All content, based on the compressed file to achieve the installation of Android applications on the Android platform.
  • the dex2oat operation is performed, that is, the optimization operation of the file such as DEX. This operation is time consuming, so it is completed before the packaging is completed.
  • the packaged content of the packaging process of step S602 is switched to the file optimized by the dex2oat operation.
  • the normal packaging process may include: using the packaging tool aapt, compiling the application declaration file and the resource file to generate the R.java file and the resource package file respectively; the class file generated by the javac compiled code source file, and converting the class file by using the dx tool, The classes.dex file is generated.
  • the optimized DEX file is pre-processed in the compile stage.
  • the apkbuilder packages the above content to generate a compressed file; the compressed file is signed and other operations to generate the final publishable application installation package.
  • step S602 may include injecting a Hook point that skips the dex2oat operation in the application file by calling a function of the native layer when the optimized application file is packaged. In this way, it is supported to skip the dex2oat operation during the application installation process to improve the application installation speed.
  • FIG. 7 is a schematic diagram of an apparatus for generating an application installation package according to an embodiment of the present application.
  • the apparatus for generating an application installation package provided by this embodiment includes: an optimization operation module 701 and a packaging module 702.
  • the optimization operation module 701 is configured to perform a dex2oat operation after the file is compiled by the application, to obtain an optimized application file.
  • the packaging module 702 is configured to package the optimized application file and generate an application installation package of the application.
  • FIG. 8 is a schematic diagram of a terminal device according to an embodiment of the present application.
  • the terminal device 800 provided in this embodiment includes: a first memory 801 and a first processor 802, where the first memory 801 is adapted to store an application installer, where the application installer is executed by the first processor 802.
  • the application installation method provided by the corresponding embodiment of FIG. 1 is implemented.
  • the first processor 802 may include, but is not limited to, a processing device such as a Micro Controller Unit (MCU) or a Field Programmable Gate Array (FPGA).
  • the first memory 801 may be configured as a software program and a module for storing application software, such as program instructions or modules corresponding to the application installation method in the embodiment, and the first processor 802 runs the software program stored in the first memory 801 and The module, thereby performing various functional applications and data processing, such as implementing the application installation method provided by the embodiment.
  • the first memory 801 can include a high speed random access memory, and can also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid state memory.
  • the first memory 801 can include memory remotely located relative to the first processor 802, which can be connected to the terminal device 800 over a network.
  • networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the terminal device 800 may further include a first communication unit 803; the first communication unit 803 may receive or transmit data via a network.
  • the first communication unit 803 can be a Radio Frequency (RF) module for communicating with the Internet wirelessly.
  • RF Radio Frequency
  • the embodiment of the present application further provides a computing device, including: a second memory and a second processor, where the second memory is adapted to store a generating program of an application installation package, and the generating program is implemented by the second processor to implement FIG. 6 Corresponding to the method for generating an application installation package provided by the embodiment.
  • the embodiment of the present application further provides a computer readable medium storing an application installation program, where the application installation program is executed by the processor, and the application installation method provided by the embodiment corresponding to FIG. 1 .
  • the embodiment of the present application further provides a computer readable medium, which is configured to generate a program for generating an application installation package, and when the generated program is executed by the processor, the method for generating an application installation package provided by the embodiment corresponding to FIG. 6 is implemented.
  • computer storage medium includes volatile and nonvolatile, implemented in any method or technology for storing information, such as computer readable instructions, data structures, program modules or other data. Sex, removable and non-removable media.
  • Computer storage media include, but are not limited to, Random Access Memory (RAM), Read-Only Memory (ROM), and Electrically Erasable Programmable Read Only Memory (EEPROM). , flash memory or other memory technology, Compact Disc Read-Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical disc storage, magnetic box, magnetic tape, disk storage or other magnetic storage A device, or any other medium that can be used to store desired information and that can be accessed by a computer.
  • communication media typically includes computer readable instructions, data structures, program modules, or other data in a modulated data signal, such as a carrier wave or other transport mechanism, and can include any information delivery media. .

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)

Abstract

一种应用安装方法、应用安装包的生成方法;上述应用安装方法,包括:获取经过dex2oat操作优化后的应用安装包(S101);基于应用安装包,进行应用安装操作(S102);其中,应用安装操作跳过dex2oat操作。

Description

应用安装方法、应用安装包的生成方法
本申请要求在2018年02月13日提交中国专利局、申请号为201810150852.7的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。
技术领域
本申请涉及但不限于计算机技术领域,例如涉及一种应用安装方法、应用安装包的生成方法。
背景技术
随着终端设备(比如,手机、笔记型电脑等便携式终端,或者台式电脑等固定终端)的配置越来越高,显示效果越来越好,应用(Application,APP)占用的空间也越来越大,动辄都几十MB(兆)甚至几百MB,随之而来的是APP下载安装的速度越来越慢,常用APP的安装都需要几十秒甚至更长时间。而且,随着APP安装包越来越大,APP新安装或者覆盖安装时的速度慢、效率低,导致用户体验不佳。
发明内容
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。
本申请实施例提供一种应用安装方法、应用安装包的生成方法,能够提高应用安装速度。
本申请实施例提供一种应用安装方法,包括:
获取应用安装包,其中,所述应用安装包经过以下操作优化:将dex字节码编译成oat格式的可执行文件;
基于所述应用安装包,进行应用安装操作;其中,所述应用安装操作跳过所述将dex字节码编译成oat格式的可执行文件的操作。
本申请实施例提供一种应用安装包的生成方法,包括:
对一应用进行文件编译之后,执行将dex字节码编译成oat格式的可执行文件的操作,得到优化后的应用文件;
打包所述优化后的应用文件,生成所述应用的应用安装包。
本申请实施例提供一种终端设备,包括:第一存储器以及第一处理器,所述第一存储器适于存储应用安装程序,所述应用安装程序被所述第一处理器执行时实现上述第一方面提供的应用安装方法。
本申请实施例提供一种计算设备,包括:第二存储器以及第二处理器,所述第二存储器适于存储应用安装包的生成程序,所述生成程序被所述第二处理器执行时实现上述第二方面提供的应用安装包的生成方法。
此外,本申请实施例还提供一种计算机可读介质,存储有应用安装程序,所述应用安装程序被处理器执行时实现上述第一方面提供的应用安装方法。
此外,本申请实施例还提供一种计算机可读介质,存储有应用安装包的生成程序,所述生成程序被处理器执行时实现上述第二方面提供的应用安装包的生成方法。
在阅读并理解了附图和详细描述后,可以明白其他方面。
附图概述
图1为本申请实施例提供的应用安装方法的流程图;
图2为本申请实施例提供的应用安装操作过程的示例图;
图3为本申请实施例中可执行文件解析过程的示例流程图;
图4为本申请实施例中指令执行过程的示例流程图;
图5为本申请实施例提供的应用安装装置的示意图;
图6为本申请实施例提供的应用安装包的生成方法的流程图;
图7为本申请实施例提供的应用安装包的生成装置的示意图;
图8为本申请实施例提供的终端设备的示意图。
具体实施方式
以下结合附图对本申请实施例进行详细说明,应当理解,以下所说明的实施例仅用于说明和解释本申请,并不用于限定本申请。
在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机***中执行。并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
图1为本申请实施例提供的应用安装方法的流程图。本实施例提供的应用安装方法可以由终端设备(比如,手机、笔记型电脑等便携式终端,或者台式 电脑等固定终端)执行。然而,本申请对此并不限定。
如图1所示,本实施例提供的应用安装方法,包括:步骤S101和步骤S102。
在步骤S101中,获取应用安装包。
其中,应用安装包经过以下操作优化:将dex字节码编译成oat格式的可执行文件;换言之,在本步骤,获取经过dex2oat操作优化后的应用安装包。
在步骤S102中,基于应用安装包,进行应用安装操作。
其中,应用安装操作跳过dex2oat操作。
在本申请实施例中,获取经过dex2oat操作(将dex字节码编译成oat格式的可执行文件的操作)优化后的应用安装包;基于应用安装包,进行应用安装操作;其中,应用安装操作跳过dex2oat操作。本申请实施例中,提供预优化后的应用安装包,并且在应用安装过程跳过dex2oat操作,从而提高应用安装速度,提升用户体验。
本实施例提供的应用安装方法能够用于提高安卓应用的安装速度,进而提升安卓用户的使用体验。
本实施例中,终端设备可以从应用商城或应用下载网站下载预优化后的应用安装包,然后进行应用新安装或覆盖安装操作。其中,预优化后的应用安装包可以包括已经过dex2oat操作优化后的各种文件,比如,DEX文件、JAR文件、以及APK文件等。
本实施例中,dex2oat操作指将dex字节码编译成oat格式的可执行文件的操作。
在本实施例中,在下载应用安装包之后,可以加载DEX文件到内存中,并将相应的资源文件解析并复制到***安装目录;然后,将class.dex文件解压到***安装路径。其中,当执行到安装指令dex2oat时,跳过此指令执行,而将预编译时期生成的odex文件(即预优化之后的DEX文件)安装到***路径。其他指令的执行不影响。
图2为本申请实施例的应用安装操作过程的示例图。如图2所示,在本实施例中,执行应用安装操作,可以包括:步骤S1021、步骤S1022和步骤S1023。
在步骤S1021中,解析应用安装包。
在步骤S1022中,根据解析结果,进行信息校验和注册。
在步骤S1023中,进行应用权限更新操作。
其中,在步骤S1021完成对应用安装包中xml文件的读取,可以得到所申 请权限、所用的各种组件(比如,Activity)、广播、以及服务等;在步骤S1022中,可以校验权限和签名是否正确,并完成对广播、服务等的注册;在步骤S1023中,根据预优化的应用安装包内的可执行文件(比如,DEX文件),通知***对应用所有的组件及组件申请的权限进行加载和更新。上述过程结束后,可以启动应用。
在示例性实施方式中,S102可以包括:基于应用安装包内已注入的代码,执行应用安装操作。
在本示例中,在应用安装过程中可以直接使用预先进行的dex2oat操作得到的DEX文件,并且通过代码注入技术,使得应用安装流程跳过dex2oat操作,从而提高应用安装速度。
在示例性实施方式中,S102可以包括:基于应用安装包的可执行文件中已注入的挂钩(Hook)点,执行应用安装操作。其中,在执行应用安装操作过程中,跳过dex2oat指令(即将dex字节码编译成oat格式的可执行文件的指令)。
本示例所采用的代码注入技术为Hook技术。Hook技术指过滤(或叫挂钩)消息的技术,指过滤一些关键函数调用,在函数执行前,先执行自定义的挂钩函数,从而能够监控函数调用,改变函数功能。
在本示例中,基于应用安装包的可执行文件中已注入的Hook点,执行应用安装操作,可以包括:
基于可执行文件中注入的第一Hook点,在可执行文件的解析过程中,跳过加载dex2oat指令;
基于可执行文件中注入的第二Hook点,在指令执行过程中,跳过执行dex2oat指令。
在一实施例中,基于可执行文件中注入的第一Hook点,在可执行文件的解析过程中,跳过加载dex2oat指令,可以包括:运行函数read()从内存读取内容时,若读取到第一Hook点,则跳转至自定义函数read_handle()的开始地址,以跳过加载dex2oat指令。
在一实施例中,基于可执行文件中注入的第二Hook点,在指令执行过程中,跳过执行dex2oat指令,可以包括:运行函数execv()从内存读取并执行指令时,若读取并执行到第二Hook点,则跳转到自定义函数execv_handle()的开始地址,以跳过执行dex2oat指令。
下面参照图3和图4说明代码注入的实现示例。
在本示例中,终端设备下载安卓应用的应用安装包之后,若用户以点击等方式触发应用安装进程,则应用安装进程通过进程间通信方式将安装请求发送给服务层的包管理服务(PackageManagerService,PMS);PMS接收安装请求后,可以调用服务进程执行应用安装操作。
图3为本申请实施例中可执行文件解析过程的示例流程图。本示例中,可执行文件(比如,DEX文件)解析过程对应一次read_handle()指令执行过程,通过read_handle()跳转到自定义的流程中,跳过原有的dex2oat指令的加载过程,然后在read_handle()执行结束跳转回之前执行堆栈,接着解析下一条指令。
在本示例中,PMS可以将DEX文件先加载到内存,然后,通过运行read()函数,依次读取内存内容进行解析。其中,read()函数为***函数,用于从相应地址读取内容。
如图3所示,本示例的过程可以包括:步骤S301至步骤S306中。
在步骤S301中,在PMS调用服务进程运行到read()函数,读取内存内容,并将读取的第i段字节记为read[i]。
其中,read()函数可以依次从内存读取设定长度的字节结构,比如,按照32比特(bit)或64比特字长读取。
在步骤S302中,依次处理读取的字节,判断read[i]是否为自定义函数read_handle()的地址;若判断read[i]不是自定义函数read_handle()的地址,则表示read[i]为程序正常内容,可以仅将read[i]加载入内存;若判断read[i]是自定义函数read_handle()的地址,则表示read[i]为Hook点(对应于上述的第一Hook点),跳转到自定义函数read_handle()的开始地址,然后执行步骤S303,以跳过加载dex2oat指令。
其中,read_handle()为本示例中的自定义函数,Hook跳转函数,可以在自定义函数中加入自定义实现功能。
在步骤S303中,将read_handle()函数载入内存。
在本步骤中,由mmap函数进行内存复制,将获得到数据保存到内存的缓存(buffer)区域;其中,mmap函数用于将一个文件或者对象映射进内存。
其中,获取的数据可以包括应用包含的数据,比如,代码文件、资源文件、声明文件、以及类(class)文件等,在内存中均是以二进制形式表示。
在步骤S304中,由函数read()的内存中读取第j段字节,其中,j=0,1,…i;即读取read[j]指令。比如,将read[0]指令从read()函数的内存中读出,将read[1] 指令从read()函数的内存中读出,并在内存中记录相应的指令内容,比如ldr pc(即将数据传送到PC寄存器)。
在步骤S305中,判断读取的第j段字节是否为read[i+1]的地址,若判断读取的第j段字节不是read[i+1]的地址,则返回步骤S304,继续读取第j段字节进行复制,若判断读取的第j段字节是read[i+1]的地址,则执行步骤S306。
在步骤S306中,在完成上述指令内容的读取和复制之后,结束read_handle()函数跳转,返回到原来的read()函数中。
图4为本申请实施例的指令执行过程的示例流程图。在本示例中,指令执行过程能够在运行时找到自定义函数,并跳过dex2oat指令的执行。指令执行过程可以在解析DEX文件后,由PMS基于DEX文件的解析结果,运行execv()函数实现。其中,execv()函数通常在fork子线程后运行,execv()会停止执行当前的进程,根据传入的参数,转入到目标函数进程。
如图4所示,本示例的过程可以包括:步骤S401至步骤S410。
在步骤S401中,通过PMS调用服务进程运行execv()函数,由execv()函数读取并执行***运行时传递的命令行参数。
其中,命令行参数包括内存中解析得到的要执行的指令。其中,将读取的第i段字节记为execv[i]。
下面列举其中两条指令作为示例进行说明:
BX指令:跳转到指令中所指定的目标地址,目标地址处的指令既可以是ARM指令,也可以是Thumb指令;
Nop指令:空指令,运行该指令时不进行任何处理,但是会占用一个指令的时间。
关于指令的含义可以参考汇编标准指令定义。本申请对此并不限定。在本示例中,以ARM指令为例进行说明。进阶精简指令集机器(Advanced RISC Machine,ARM)指令集是指计算机ARM操作指令***。在ARM中有两种方式可以实现程序的跳转:一种是跳转指令;另一种是直接向PC寄存器(R15)中写入目标地址值。
在本步骤中,按规定的字节大小依次读取指令,当读取指令1为Bx pc,然后接着读取指令2为空指令,如此类指令则依次读取入寄存器中。
在步骤S402中,判断execv[i]是否为空指令;若判断execv[i]为空指令,则返回步骤401继续读取下一个指令;若判断execv[i]不为空指令,则执行步骤S403。
在步骤S403中,判断execv[i]是否为自定义函数execv_handle()的地址,若判断execv[i]不是自定义函数execv_handle()的地址,则返回步骤S401,若判断execv[i]是自定义函数execv_handle()的地址,则表示execv[i]为Hook点(对应于上述的第二Hook点),跳转到自定义函数exec_handle()的开始地址,执行步骤S404,以跳过执行dex2oat指令。
其中,execv_handle()为本示例中的自定义函数,Hook跳转函数,可以在自定义函数中加入自定义实现功能。
在步骤S404中,执行execv_handle()函数。
比如,在本步骤中,根据mmap复制的内存缓存(buffer)区域的首地址,依次从execv_handle()函数的地址参数execv[0]开始到地址参数execv[5],读取指令到运行时内存中被调用执行。
在本示例中,在跳转到execv_handle()函数后,执行的指令是根据read_handle()加载得到的。
在步骤S405中,由函数execv()的内存中读取第j段字节,其中,j=0,1,…i;即读取execv[j]指令,并执行读取的指令,其中,该指令为read_handle()堆栈空间内的。
在步骤S406中,判断execv[j]是否为ARM指令,若是,则执行S407,否则,执行S408。
在步骤S407中,将execv[j]指令切换为ARM指令的执行方式,比如,执行指令ldr pc,然后执行S408。
在步骤S408中,读取execv[j+1]字节处指令并执行。
在步骤S409中,判断第j+1段字节是否为exevc[i+1]的地址,若判断第j+1段字节不是exevc[i+1]的地址,则返回步骤S405,若判断第j+1段字节是exevc[i+1]的地址,则执行步骤S410。
在步骤S410中,在完成上述指令的读取和执行之后,结束execv_handle()函数跳转,并返回execv()函数。
图5为本申请实施例提供的应用安装装置的示意图。如图5所示,本实施例提供的应用安装装置,包括:获取模块501和安装模块502。
获取模块501,配置为获取经过dex2oat操作优化后的应用安装包。
安装模块502,配置为基于应用安装包,进行应用安装操作,其中,应用安装操作跳过dex2oat操作。
关于本实施例提供的应用安装装置的相关说明可以参照图1对应的方法实施例的描述,故于此不再赘述。
图6为本申请实施例提供的应用安装包的生成方法的流程图。如图6所示,本实施例提供的生成方法,包括:步骤S601和步骤S602。
在步骤S601中,对应用进行文件编译之后,执行dex2oat操作,得到优化后的应用文件。
在步骤S602中,打包优化后的应用文件,生成该应用的应用安装包。
本实施例可以由计算设备(比如,个人电脑等)在应用开发环境下执行,通过在编译之后执行dex2oat操作,得到预优化的DEX文件,使得应用安装过程可以跳过dex2oat操作。
本实施例中,应用包括安卓(Android)应用。安卓应用是用Java编写的,利用软件开发工具(Software Development Kit,Android SDK)编译代码,并且把所有的数据和资源文件打包成一个压缩文件(即应用安装包),该压缩文件包含一个安卓应用的所有内容,基于该压缩文件实现在安卓平台安装安卓应用。
在本实施例中,在编译阶段,首先正常Android应用编译完成后执行dex2oat操作,也就是DEX等文件的优化操作,本操作比较耗时,因此放在打包之前即编译阶段完成。步骤S602的打包过程打包的内容都切换成了经过dex2oat操作优化后的文件。其中,正常打包流程可以包括:使用打包工具aapt,将应用声明文件、资源文件编译分别生成R.java文件和资源包文件;javac编译代码源文件生成的class文件,用dx工具将class文件转换,生成classes.dex文件,这一步优化后打包的DEX文件是在编译阶段预先处理得到的;通过apkbuilder打包上述内容生成压缩文件;压缩文件经过签名等操作生成最终可发布应用安装包。
在示例性实施方式中,步骤S602可以包括:在打包优化后的应用文件时,通过调用原生(Native)层的函数,在应用文件中注入跳过dex2oat操作的Hook点。如此,支持在应用安装过程中跳过dex2oat操作,以提升应用安装速度。
图7为本申请实施例提供的应用安装包的生成装置的示意图。如图7所示,本实施例提供的应用安装包的生成装置,包括:优化操作模块701和打包模块702。
优化操作模块701,配置为对应用进行文件编译之后,执行dex2oat操作,得到优化后的应用文件。
打包模块702,配置为打包优化后的应用文件,生成应用的应用安装包。
关于本实施例提供的应用安装装置的相关说明可以参照图6对应的方法实施例的描述,故于此不再赘述。
图8为本申请实施例提供的终端设备的示意图。如图8所示,本实施例提供的终端设备800,包括:第一存储器801以及第一处理器802,第一存储器801适于存储应用安装程序,该应用安装程序被第一处理器802执行时实现图1对应实施例提供的应用安装方法。
其中,第一处理器802可以包括但不限于微处理器(Microcontroller Unit,MCU)或可编程逻辑器件(Field Programmable Gate Array,FPGA)等的处理装置。第一存储器801可设置为存储应用软件的软件程序以及模块,如本实施例中的应用安装方法对应的程序指令或模块,第一处理器802通过运行存储在第一存储器801内的软件程序以及模块,从而执行各种功能应用以及数据处理,比如实现本实施例提供的应用安装方法。第一存储器801可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些示例中,第一存储器801可包括相对于第一处理器802远程设置的存储器,这些远程存储器可以通过网络连接至终端设备800。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
在一实施例中,终端设备800还可以包括第一通信单元803;第一通信单元803可以经由一个网络接收或者发送数据。在一个实例中,第一通信单元803可以为射频(Radio Frequency,RF)模块,其用于通过无线方式与互联网进行通信。
此外,本申请实施例还提供一种计算设备,包括:第二存储器以及第二处理器,第二存储器适于存储应用安装包的生成程序,该生成程序被第二处理器执行时实现图6对应实施例提供的应用安装包的生成方法。
关于本实施例提供的计算设备的第二处理器和第二存储器的相关说明可以参照第一处理器和第一存储器的说明,故于此不再赘述。
此外,本申请实施例还提供一种计算机可读介质,存储有应用安装程序,该应用安装程序被处理器执行时图1对应实施例提供的应用安装方法。
此外,本申请实施例还提供一种计算机可读介质,存储有应用安装包的生成程序,该生成程序被处理器执行时实现图6对应实施例提供的应用安装包的生成方法。
本领域普通技术人员可以理解,上文中所公开方法中的全部或某些步骤、***、装置中的功能模块或单元可以被实施为软件、固件、硬件及其适当的组合。在硬件实施方式中,在以上描述中提及的功能模块或单元之间的划分不一定对应于物理组件的划分;例如,一个物理组件可以具有多个功能,或者一个功能或步骤可以由若干物理组件合作执行。某些组件或所有组件可以被实施为由处理器,如数字信号处理器或微处理器执行的软件,或者被实施为硬件,或者被实施为集成电路,如专用集成电路。这样的软件可以分布在计算机可读介质上,计算机可读介质可以包括计算机存储介质(或非暂时性介质)和通信介质(或暂时性介质)。如本领域普通技术人员公知的,术语计算机存储介质包括在用于存储信息(诸如计算机可读指令、数据结构、程序模块或其他数据)的任何方法或技术中实施的易失性和非易失性、可移除和不可移除介质。计算机存储介质包括但不限于随机存取存储器(Random Access Memory,RAM)、只读存储器(Read-Only Memory,ROM)、电可擦除可编程只读存储器(Electrically Erasable Programmable Read Only Memory,EEPROM)、闪存或其他存储器技术、只读光盘(Compact Disc Read-Only Memory,CD-ROM)、数字多功能盘(Digital Versatile Disc,DVD)或其他光盘存储、磁盒、磁带、磁盘存储或其他磁存储装置、或者可以用于存储期望的信息并且可以被计算机访问的任何其他的介质。此外,本领域普通技术人员公知的是,通信介质通常包含计算机可读指令、数据结构、程序模块或者诸如载波或其他传输机制之类的调制数据信号中的其他数据,并且可包括任何信息递送介质。

Claims (14)

  1. 一种应用安装方法,包括:
    获取应用安装包,其中,所述应用安装包经过以下操作优化:将dex字节码编译成oat格式的可执行文件;
    基于所述应用安装包,进行应用安装操作;其中,所述应用安装操作跳过所述将dex字节码编译成oat格式的可执行文件的操作。
  2. 根据权利要求1所述的方法,其中,所述基于所述应用安装包,进行应用安装操作,包括:
    基于所述应用安装包内已注入的代码,执行应用安装操作。
  3. 根据权利要求2所述的方法,其中,所述基于所述应用安装包内已注入的代码,执行应用安装操作,包括:
    基于所述应用安装包的可执行文件中已注入的挂钩Hook点,执行应用安装操作。
  4. 根据权利要求3所述的方法,其中,所述基于所述应用安装包的可执行文件中已注入的挂钩Hook点,执行应用安装操作,包括:
    基于所述可执行文件中注入的第一挂钩Hook点,在所述可执行文件的解析过程中,跳过加载将dex字节码编译成oat格式的可执行文件的指令;
    基于所述可执行文件中注入的第二挂钩Hook点,在指令执行过程中,跳过执行所述将dex字节码编译成oat格式的可执行文件的指令。
  5. 根据权利要求4所述的方法,其中,所述基于所述可执行文件中注入的第一挂钩Hook点,在所述可执行文件的解析过程中,跳过加载将dex字节码编译成oat格式的可执行文件的指令,包括:
    运行函数read()从内存读取内容时,基于读取到第一挂钩Hook点,跳转至自定义函数read_handle()的开始地址,以跳过加载所述将dex字节码编译成oat格式的可执行文件的指令。
  6. 根据权利要求4所述的方法,其中,所述基于所述可执行文件中注入的第二挂钩Hook点,在指令执行过程中,跳过执行所述将dex字节码编译成oat格式的可执行文件的指令,包括:
    运行函数execv()从内存读取并执行指令时,基于读取并执行到第二挂钩Hook点,跳转到自定义函数execv_handle()的开始地址,以跳过执行所述将dex字节码编译成oat格式的可执行文件的指令。
  7. 根据权利要求1所述的方法,其中,所述基于所述应用安装包,进行应 用安装操作,包括:
    解析所述应用安装包;
    根据解析结果,进行信息校验和注册;
    根据所述应用安装包内的可执行文件,进行应用权限更新操作。
  8. 一种应用安装包的生成方法,包括:
    对一应用进行文件编译之后,执行将dex字节码编译成oat格式的可执行文件的操作,得到优化后的应用文件;
    打包所述优化后的应用文件,生成所述应用的应用安装包。
  9. 根据权利要求8所述的方法,其中,所述打包所述优化后的应用文件,生成所述应用的应用安装包,包括:
    在打包所述优化后的应用文件时,通过调用原生Native层的函数,在所述应用文件中注入跳过所述将dex字节码编译成oat格式的可执行文件的操作的挂钩Hook点。
  10. 根据权利要求8所述的方法,其中,所述应用包括安卓应用。
  11. 一种终端设备,包括:
    存储器以及处理器,所述存储器适于存储应用安装程序,所述应用安装程序被所述处理器执行时实现如权利要求1至7中任一项所述的应用安装方法。
  12. 一种计算设备,包括:
    存储器以及处理器,所述存储器适于存储应用安装包的生成程序,所述生成程序被所述处理器执行时实现如权利要求8至10中任一项所述的应用安装包的生成方法。
  13. 一种计算机可读介质,存储有应用安装程序,所述应用安装程序被处理器执行时实现如权利要求1至7中任一项所述的应用安装方法。
  14. 一种计算机可读介质,存储有应用安装包的生成程序,所述生成程序被处理器执行时实现如权利要求8至10中任一项所述的应用安装包的生成方法。
PCT/CN2019/071104 2018-02-13 2019-01-10 应用安装方法、应用安装包的生成方法 WO2019157891A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810150852.7 2018-02-13
CN201810150852.7A CN110162311A (zh) 2018-02-13 2018-02-13 一种应用安装方法、应用安装包的生成方法

Publications (1)

Publication Number Publication Date
WO2019157891A1 true WO2019157891A1 (zh) 2019-08-22

Family

ID=67619113

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/071104 WO2019157891A1 (zh) 2018-02-13 2019-01-10 应用安装方法、应用安装包的生成方法

Country Status (2)

Country Link
CN (1) CN110162311A (zh)
WO (1) WO2019157891A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114996078B (zh) * 2021-12-07 2023-05-09 荣耀终端有限公司 dex文件的编译控制方法及装置

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104598809A (zh) * 2015-02-13 2015-05-06 北京奇虎科技有限公司 程序的监控方法及其防御方法以及相关装置
CN105100191A (zh) * 2015-05-22 2015-11-25 华为技术有限公司 一种云编译实现Java应用安装的方法、装置及***
CN106775828A (zh) * 2016-11-25 2017-05-31 广东欧珀移动通信有限公司 应用程序安装方法及装置、计算机设备
US20170269950A1 (en) * 2016-03-15 2017-09-21 Mediatek Inc. Selective execution of ahead-of-time compiled code
CN107506221A (zh) * 2017-09-28 2017-12-22 阿里巴巴集团控股有限公司 应用程序升级方法、装置及设备

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102262549B (zh) * 2011-03-02 2014-10-15 奇智软件(北京)有限公司 补丁安装方法与***
EP3026559A1 (en) * 2014-11-28 2016-06-01 Thomson Licensing Method and device for providing verifying application integrity

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104598809A (zh) * 2015-02-13 2015-05-06 北京奇虎科技有限公司 程序的监控方法及其防御方法以及相关装置
CN105100191A (zh) * 2015-05-22 2015-11-25 华为技术有限公司 一种云编译实现Java应用安装的方法、装置及***
US20170269950A1 (en) * 2016-03-15 2017-09-21 Mediatek Inc. Selective execution of ahead-of-time compiled code
CN106775828A (zh) * 2016-11-25 2017-05-31 广东欧珀移动通信有限公司 应用程序安装方法及装置、计算机设备
CN107506221A (zh) * 2017-09-28 2017-12-22 阿里巴巴集团控股有限公司 应用程序升级方法、装置及设备

Also Published As

Publication number Publication date
CN110162311A (zh) 2019-08-23

Similar Documents

Publication Publication Date Title
US9454356B2 (en) Method of and terminal for updating library file in system application
WO2015055074A1 (zh) 动态加载和调用程序的方法及装置
CN107943485B (zh) 一种补丁编译平台及补丁编译方法
CN103677922A (zh) 对应用软件进行启动的方法和装置
CN104375849A (zh) 加载内核的方法及装置
CN107220074B (zh) 对支撑层软件功能的访问、升级方法及装置
CN107239309B (zh) 补丁生成方法及装置、更新方法、电子设备、存储介质
CN113835713B (zh) 源码包下载方法、装置、计算机设备和存储介质
US20100293540A1 (en) Recipe-based application conversion
CN111443939A (zh) 一种软件开发工具包的配置方法、装置和存储介质
CN111290740B (zh) 应用程序的开发方法、装置、计算机设备和存储介质
WO2023213263A1 (zh) 程序编译和启动方法、设备及存储介质
CN111596951A (zh) 一种工程文件的配置方法及装置
CN111562929A (zh) 补丁文件的生成方法、装置、设备及存储介质
TW201814546A (zh) 設備的組件加載方法、裝置以及物聯網系統
CN117707543A (zh) 一种应用安装包制作和安装方法、计算设备及存储介质
KR102141749B1 (ko) App 프로그램 실행 방법 및 장치
US10552135B1 (en) Reducing a size of an application package
WO2019157891A1 (zh) 应用安装方法、应用安装包的生成方法
CN114490103A (zh) 一种操作***接口调用方法、装置以及电子设备
CN113641389B (zh) 基于OpenCPU的软件升级方法、装置及设备
CN116643778A (zh) 一种应用程序优化方法及电子设备
CN108536444B (zh) 插件编译方法、装置、计算机设备和存储介质
CN110806891A (zh) 嵌入式设备软件版本的生成方法及装置
CN106778270B (zh) 一种恶意应用程序的检测方法及***

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19753635

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 12.01.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 19753635

Country of ref document: EP

Kind code of ref document: A1