WO2020014926A1 - 一种补丁包生成方法及设备 - Google Patents

一种补丁包生成方法及设备 Download PDF

Info

Publication number
WO2020014926A1
WO2020014926A1 PCT/CN2018/096318 CN2018096318W WO2020014926A1 WO 2020014926 A1 WO2020014926 A1 WO 2020014926A1 CN 2018096318 W CN2018096318 W CN 2018096318W WO 2020014926 A1 WO2020014926 A1 WO 2020014926A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
source code
code
server
apk
Prior art date
Application number
PCT/CN2018/096318
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 华为技术有限公司
Priority to US17/260,495 priority Critical patent/US11321080B2/en
Priority to CN201880072150.XA priority patent/CN111316230B/zh
Priority to PCT/CN2018/096318 priority patent/WO2020014926A1/zh
Publication of WO2020014926A1 publication Critical patent/WO2020014926A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/40Transformation of program code
    • G06F8/53Decompilation; Disassembly

Definitions

  • the present application relates to the field of communication technologies, and in particular, to a method and device for generating a patch package.
  • the Android installation package (APK) of each application in the application layer will also be updated due to the update of the application framework layer.
  • Update For the update content of the application, currently, a differential package can be generated by using a differential technology. Specifically, an APK of an old version of an application is compared with an APK generated after the update, and the compared difference is compressed into a differential package.
  • the application that is updated due to the update of the application framework layer generates a differential APK, so while fixing the problems of the application framework layer, the server also needs to package the differential packages of these applications to the application framework layer.
  • the patch package of the application framework layer generated in the end will be very large (usually hundreds of megabytes).
  • the terminal uses the patch package of the application framework layer issued by the server to upgrade, the air interface resources and The user's traffic causes great losses.
  • the present application provides a method and a device for generating a patch package, which are used to generate a patch package with a relatively small amount of data, thereby reducing the calculation amount of running a patch package on a terminal, reducing air interface resources and traffic consumption, and improving the efficiency of the upgrade.
  • an embodiment of the present application provides a method for generating a patch package.
  • the method includes: when an application framework layer code in an Android operating system source code is updated, a server obtains a compilation result, and the compilation result includes code update.
  • the Android installation package APK of the pre-installed application in the application layer in the Android operating system source code described later, and the APK of the pre-installed application in the application layer in the Android operating system source code described before the code update occurs.
  • the server determines the APK of the target application from the APK of the pre-installed application.
  • the so-called target application is an application in which only one or more of a check value, a timestamp, and a register corresponding to a constant are changed in an application code.
  • the server differentiates an APK of an application other than the target application in the pre-installed application after the code update, and an APK of an application other than the target application in the pre-installed application before the code update, to generate a first difference packet.
  • the data amount of the first differential packet generated by the foregoing method is relatively reduced.
  • the terminal operation patch can be reduced. It can reduce the amount of computing, reduce the consumption of air interface resources, and improve the efficiency of the upgrade.
  • the compilation result obtained by the server may further include the system files of the application framework layer after the code is updated and the system files of the application framework layer before the code is updated.
  • the server may update the code after the code is updated.
  • the system file of the application framework layer is differentiated from the system file of the application framework layer before the code is updated to generate a second difference package, and then the server combines the first difference package and the second difference package into one.
  • the patch package generated in this way only includes the second differential package of the application framework layer and the first differential package of the target application. Compared with the prior art, the data volume of the patch package is reduced, which can reduce the consumption of air interface resources. This patch pack upgrade also reduces traffic loss.
  • the server obtains an APK of the first application after code update and an APK of the first application before code update from the compilation result, where the first application is the pre-installed application One of the applications, and then the server determines that the APK before and after the code update of the first application is different, decompiles the system files in the APK of the first application after the code update to the first source code, and The system file of the APK of the first application is decompiled into the second source code.
  • the server determines whether only the check value, timestamp, and one or more of the registers corresponding to the constants in the first source code and the second source code are different. If so, the server determines that the first application is the target application, and determines The APK of the first application is the APK of the target application.
  • the server finally only differentiates APKs of applications other than these target applications to generate a first differential package, so the file size of the patch package that is finally generated and sent can be reduced, thereby reducing
  • the terminal runs the calculation amount of the patch package, reduces the consumption of air interface resources, and improves the efficiency of the upgrade.
  • the server determines whether only the registers corresponding to the constants in the first source code and the second source code are different: the server first compares whether the first source code and the second source code are different If different, the server converts the first source code into a first semantic tree and the second source code into a second semantic tree. If the first semantic tree is the same as the second semantic tree after transposition, the server determines Only the registers corresponding to the constants in the first source code and the second source code are different.
  • the server may determine that the code of the first application is different only in the register corresponding to the constant, and the function implementation of the first application has not changed.
  • the server may determine whether one or more of only the check value and the timestamp in the first source code and the second source code are different:
  • the server compares whether the first source code and the second source code are different; if they are different, the server determines whether the fields corresponding to different code portions in the first source code and the second source code are timestamp fields, and if so , The server determines that only the check value is different between the first source code and the second source code.
  • the server may determine whether one or more of only the check value and the timestamp in the first source code and the second source code are different:
  • the server compares whether the first source code and the second source code are different; if they are different, the server determines whether the fields corresponding to different code portions in the first source code and the second source code are check value fields; if so, the server It is determined that only the timestamps are different in the first source code and the second source code.
  • the server may determine that the codes of the first application only have different timestamps and check values, and the function implementation of the first application has not changed.
  • the server obtains the APK of the first application after the code update and the APK of the second application before the code update from the compilation result, where the second application is the pre-installed One of the applications, and then when the server determines that the APK before and after the code update of the second application is different, the server obtains the third source code of the second application after the code update from the Android operating system source code and before the code update The fourth source code of the second application, when the server finds that the third source code is the same as the fourth source code, it determines that the APK of the first application is the APK of the target application.
  • the server determines that the third source code and the fourth source code are the same, it means that the code of the first application has not been changed, so the function implementation of the first application has not changed, so the first application does not need to It is packaged into a patch package, so the file size of the patch package that is finally generated and sent can be reduced, thereby reducing the calculation amount of the terminal running the patch package, reducing the consumption of air interface resources, and improving the efficiency of the upgrade.
  • an embodiment of the present application provides a server, including a processor and a memory.
  • the memory is used to store one or more computer programs, and the Android operating system source code, and the compilation result generated by compiling the Android operating system source code; wherein the compilation result generated by the Android operating system source code compilation includes the Android operation described after the code is updated.
  • the Android operating system source code includes the source code of the pre-installed application in the application layer in the Android operating system source code after the code update, and the pre-installed application in the application layer in the Android operating system source code before the code update. Source code.
  • the server is enabled to implement any one of the possible design methods of the first aspect.
  • an embodiment of the present application further provides a server, where the server includes a module / unit that executes the first aspect or a method of any possible design of the first aspect.
  • modules / units can be implemented by hardware, and can also be implemented by hardware executing corresponding software.
  • an embodiment of the present application further provides a computer-readable storage medium, where the computer-readable storage medium includes a computer program, and when the computer program runs on a server, the server causes the server to execute the first aspect or the foregoing first Any one of the possible design methods.
  • an embodiment of the present application further provides a computer program product that, when the computer program product runs on a server, causes the server to execute the first aspect or any one of the foregoing possible designs of the first aspect. method.
  • FIG. 1 is a schematic diagram of an OTA application scenario provided by an embodiment of this application
  • FIG. 2 is a schematic structural diagram of a terminal according to an embodiment of the present application.
  • FIG. 3 is a schematic structural diagram of an operating system in a terminal according to an embodiment of the present application.
  • 4a to 4b are schematic diagrams of a difference method provided by an embodiment of the present application.
  • FIG. 5 is a schematic architecture diagram of a server according to an embodiment of the present application.
  • FIG. 6 is a schematic flowchart of a method for generating a patch package according to an embodiment of the present application
  • FIG. 7 is a schematic diagram of a semantic tree transposition method according to an embodiment of the present application.
  • 8a is a schematic diagram of a text file comparison result provided by an embodiment of the present application.
  • FIG. 8b is a schematic diagram of a comparison result of source code according to an embodiment of the present application.
  • FIG. 9 is a first flowchart of another method for generating a patch package according to an embodiment of the present application.
  • FIG. 10 is a schematic interface diagram of a terminal update patch package according to an embodiment of the present application.
  • OTA over-the-air
  • an embodiment of the present application provides a scenario architecture for OTA upgrade.
  • the scenario architecture includes a server 100, a terminal 200, and the terminal 200 and the server 100 communicate with each other through a communication network.
  • the communication network may be a local area network or a wide area network transferred through a relay device.
  • the communication network may be a short-distance communication network such as a wifi hotspot network, a wifi direct connection network, a Bluetooth network, a zigbee network, or a near field communication (NFC) network.
  • a short-distance communication network such as a wifi hotspot network, a wifi direct connection network, a Bluetooth network, a zigbee network, or a near field communication (NFC) network.
  • the communication network may be a 3rd-generation wireless communication technology (3G) network, a 4th generation mobile communication technology (4G) ) Networks, 5th-generation mobile communication technology (5G) networks, public land mobile networks (PLMN) or the Internet that are evolving in the future.
  • 3G 3rd-generation wireless communication technology
  • 4G 4th generation mobile communication technology
  • 5G 5th-generation mobile communication technology
  • PLMN public land mobile networks
  • the server 100 stores a program package.
  • the program package is usually uploaded to the server by a developer of the program package.
  • the program package may have two types: differential APK or full APK.
  • the terminal 200 downloads the program package from the server, saves it locally, and updates the installed software on the terminal.
  • the terminal 200 obtains the full APK from the server, the terminal 200 directly uses the full APK to upgrade.
  • the terminal 200 obtains a differential APK from the server, the terminal 200 uses the differential APK to synthesize a new APK with an image file that it has installed, so as to upgrade using the new APK.
  • the terminal 200 may be a terminal device such as a mobile phone, a tablet computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA).
  • UMPC ultra-mobile personal computer
  • PDA personal digital assistant
  • a mobile phone is taken as an example for illustration.
  • FIG. 2 is a block diagram showing a partial structure of the terminal 200 related to each embodiment of the present invention.
  • the terminal 200 is a mobile phone, and the mobile phone includes: an RF (radio frequency) circuit 201, a Wi-Fi system module 202, a memory 203, an input unit 204, a display unit 205, a processor 206, and an audio circuit 207 And power supply 208 and other components.
  • RF radio frequency
  • the structure of the mobile phone shown in FIG. 200 does not constitute a limitation on the mobile phone, and may include more or fewer parts than those shown in the figure, or combine certain parts, or arrange different parts.
  • the Wi-Fi system module 202 is configured to scan Wi-Fi access points existing in the surrounding environment of the terminal 200 to obtain related information, so that the terminal 200 can access the Wi-Fi access point according to the related information.
  • the RF circuit 201 is used for receiving and transmitting information or transmitting or receiving signals during a call. In particular, after receiving downlink information of a base station, it is processed by the processor 206. In addition, the uplink data is transmitted to the base station.
  • the RF circuit 201 is connected to a Wi-Fi antenna of a Wi-Fi system module, and controls scanning of the Wi-Fi network by the Wi-Fi antenna.
  • the RF circuit 201 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, and the like.
  • the RF circuit 201 can also communicate with a network and other devices through wireless communication.
  • the memory 203 is configured to store a software program of the terminal 200.
  • the memory 203 may include a high-speed random access memory, and may further include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
  • the processor 206 is the control center of the terminal 200. It uses various interfaces and lines to connect various parts of the entire mobile phone. By running or executing software programs stored in the memory 203, and calling data stored in the memory 203, the terminal 200 is executed. Various functions and data processing.
  • the processor 206 may include one or more processing units.
  • the processor 206 may integrate an application processor and a modem processor.
  • the application processor mainly processes an operating system, a user interface, and an application program.
  • the modem processor mainly handles wireless communication. It can be understood that the foregoing modem processor may not be integrated into the processor 206.
  • the input unit 204 may be used to receive inputted numeric or character information, and generate key signal inputs related to user settings and function control of the terminal 200.
  • the input unit 204 may include a touch screen and other input devices.
  • the touch screen is also called a touch panel, which can collect user's touch operations on or near it and drive the corresponding connection device according to a preset program.
  • Other input devices may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, power switch keys, etc.), trackballs, mice, joysticks, and the like.
  • the display unit 205 may be configured to display information input by the user or information provided to the user and various menus of the mobile phone 200.
  • the display unit 205 may include a display panel.
  • the display panel may be configured by using a liquid crystal display (Liquid Crystal Display, LCD), an organic light emitting diode (Organic Light-Emitting Diode, OLED), or the like.
  • the audio circuit 207 is connected to a speaker and a microphone, and can provide an audio interface between the user and the mobile phone 200.
  • the audio circuit 207 may transmit the received electrical data converted electrical signals to a speaker, which is converted into a sound signal and output by the speaker; on the other hand, the microphone converts the collected sound signal into an electrical signal and is converted by the audio circuit into
  • the audio data is output to the RF circuit 201 for transmission to another mobile phone, or the audio data is output to the memory 203 for further processing.
  • the mobile phone 200 further includes a power source 208 (such as a battery) for supplying power to various components.
  • a power source 208 such as a battery
  • the power source can be logically connected to the processor 206 through a power management system, so as to implement functions such as managing charging, discharging, and power consumption management through the power management system.
  • the terminal 200 may further include a Bluetooth module, a sensor, a GPS, etc., and details are not described herein again.
  • the software system of the terminal 200 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture.
  • the embodiment of the present invention takes the layered architecture Android system as an example to exemplify the software structure of the terminal 200.
  • FIG. 3 is a software structural block diagram of a terminal 200 according to an embodiment of the present invention.
  • the layered architecture divides the software into several layers, each of which has a clear role and division of labor.
  • the layers communicate with each other through a software interface.
  • the Android system is divided into four layers, which are an application layer, an application framework layer, an Android runtime and a system library, and a kernel layer from top to bottom.
  • the application layer can include a series of application packages.
  • the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, etc.
  • the application framework layer provides an application programming interface (API) and a programming framework for applications at the application layer.
  • API application programming interface
  • the application framework layer includes some predefined functions.
  • the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
  • the window manager is used to manage window programs.
  • the window manager can obtain the display size, determine whether there is a status bar, lock the screen, take a screenshot, etc.
  • Content providers are used to store and retrieve data and make it accessible to applications.
  • the data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, and so on.
  • the view system includes visual controls, such as controls that display text, controls that display pictures, and so on.
  • the view system can be used to build applications.
  • the display interface can consist of one or more views.
  • the display interface including the SMS notification icon may include a view that displays text and a view that displays pictures.
  • the call manager is used to provide a communication function of the terminal 200. For example, management of call status (including connection, hang up, etc.).
  • the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, and so on.
  • the notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages that can disappear automatically after a short stay without user interaction.
  • the notification manager is used to inform download completion, message reminders, etc.
  • the notification manager can also be a notification that appears in the status bar at the top of the system as a chart or scroll bar text, such as a notification from an application running in the background, or a notification that appears on the screen in the form of a dialog window.
  • text messages are displayed in the status bar, sounds are emitted, electronic equipment vibrates, and the indicator light flashes.
  • Android Runtime includes core libraries and virtual machines. Android runtime is responsible for the scheduling and management of the Android system.
  • the core library contains two parts: one is the functional functions that the Java language needs to call, and the other is the Android core library.
  • the application layer and the application framework layer run in a virtual machine.
  • the virtual machine executes the java files of the application layer and the application framework layer as binary files.
  • Virtual machines are used to perform object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
  • the system library can include multiple functional modules. For example: surface manager (media manager), media library (Media library), three-dimensional graphics processing library (for example: OpenGL ES), 2D graphics engine (for example: SGL) and so on.
  • surface manager media manager
  • media library Media library
  • Three-dimensional graphics processing library for example: OpenGL ES
  • 2D graphics engine for example: SGL
  • the Surface Manager is used to manage the display subsystem and provides a fusion of 2D and 3D layers for multiple applications.
  • the media library supports a variety of commonly used audio and video formats for playback and recording, as well as still image files.
  • the media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
  • the 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
  • the 2D graphics engine is a graphics engine for 2D graphics.
  • the kernel layer is the layer between hardware and software.
  • the kernel layer contains at least a display driver, a camera driver, an audio driver, and a sensor driver.
  • the following describes the workflow of the software and hardware of the electronic device 100 by way of example in conjunction with capturing a photographing scene.
  • a corresponding hardware interrupt is sent to the kernel layer.
  • the kernel layer processes touch operations into raw input events (including touch coordinates, time stamps of touch operations, and other information). Raw input events are stored at the kernel level.
  • the application framework layer obtains the original input event from the kernel layer and identifies the control corresponding to the input event. Taking the touch operation as a touch and click operation, and the control corresponding to the click operation is the control of the camera application icon as an example, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer. The camera captures still images or videos.
  • the patch package sent by the server 100 to the terminal 200 is usually a differential package. Because the differential package is usually only a few megabytes, it can greatly reduce the consumption of user processes during the upgrade.
  • the differential packet is generated by the server 100 using a differential technique. Differential technologies are generally divided into two types, one is based on block difference (such as the open source tool bsdiff), and the other is based on file difference (such as the open source tool imgdiff).
  • the original code 401 is the source code of an application before the system update.
  • the new code 402 is the source code updated and generated on the original code 401.
  • the original code 401 and the new code 402 can be compiled to generate an APK.
  • APK403 is an Android installation package compiled from the original source code
  • APK404 is an Android installation package compiled from the new code.
  • the file size of the differential package 405a is larger than the file of the differential package 405b, but the terminal synthesizes the image file faster after obtaining the differential package 405a from the server; the file of the differential package 405b is smaller, but the terminal from the server The speed of synthesizing the image file after obtaining the differential package 405a is relatively slow.
  • an embodiment of the present application provides a method for generating a patch package, which can implement that when the application framework layer is repaired, the server determines from the pre-installed application in the operating system source code that only the check value changes. , The target application where the timestamp changes, and the register corresponding to the constant changes.
  • pre-installed applications refer to pre-installed applications in the Android operating system source code released by Google, and pre-installed applications based on the Android operating system source code released by Google from different vendors. These pre-installed applications are different from The third-party applications that users download from the application store are mainly that these pre-installed applications have an irrevocable feature on the user terminal.
  • the server After the target application is determined, the server generates first differential packets of applications other than the target applications in the pre-installed applications.
  • the data amount of the first differential packet generated by the server is relatively large. It is small, thereby reducing the calculation amount of the terminal running the patch package, reducing air interface resources and traffic consumption, and improving the efficiency of the upgrade.
  • the server 100 for executing the method for generating a patch package may be a server having a compiling function or a cloud server.
  • FIG. 5 is a block diagram showing a partial structure of the server 100 related to the embodiments of the present application.
  • the server 100 may include a processor 501, a memory 502, and a transceiver 503.
  • the one or more computer programs are stored in the memory 501 and configured to be executed by the one or more processors 502.
  • the processor 501 may be a central processing unit (CPU) or a digital processing unit.
  • the processor 501 is the control center of the server 100, and uses various interfaces and lines to connect various parts of the entire server.
  • the computer program stored in the memory 502 is executed, and the data stored in the memory 502 is called to perform various functions and data processing of the server 100.
  • the memory 502 is configured to store a computer program to be run. If the server 100 is a cloud server, the memory 502 further stores a compilation result compiled by the Android operating system obtained from a server with a compilation function, where the compilation result includes code generation. After the update, the APK of the pre-installed application in the application layer in the Android operating system source code and the code occur. The system files and code of the application framework layer are updated as described above. In addition, the memory 502 also stores source code of a pre-installed application obtained from a server having a compiling function. The source code of the pre-installed application mainly includes: The source code of the installed application, and the source code of the pre-installed application in the application layer in the source code of the Android operating system described before the code update.
  • the memory 502 stores an Android operating system source code and a compilation result generated by compiling the Android operating system source code.
  • the Android operating system source code includes at least the code of the application framework layer and the source code of the pre-installed application in the application layer.
  • the compilation result includes the APK of the pre-installed application in the application layer in the Android operating system source code after the code update, and the APK of the pre-installed application in the application layer in the Android operating system source code before the code update, And the system files of the application framework layer before the code update and the system files of the application framework layer before the code update.
  • the source code of the pre-installed application in the application layer mainly includes: the source code of the pre-installed application in the application layer in the Android operating system source code after the code is updated, and the The source code of the pre-installed application in the application layer.
  • the transceiver 503 is configured to send the patch package generated by the processor 501 to the terminal side.
  • a specific connection medium between the processor 501 and the memory 502 is not limited in the embodiment of the present application.
  • the memory 502, the processor 501, and the transceiver 503 are connected by a bus 504 in FIG. 4.
  • the bus is indicated by a thick line in FIG. It is not limited.
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only a thick line is used in FIG. 4, but it does not mean that there is only one bus or one type of bus.
  • the memory 502 may be a volatile memory, such as a random-access memory (RAM); the memory 503 may also be a non-volatile memory, such as a read-only memory, A flash memory (hard memory, hard disk drive (HDD) or solid-state drive (SSD), or memory 502) can be used to carry or store program code in the form of instructions or data structures and can be used by Any other media that the computer accesses, but is not limited to.
  • the memory 503 may be a combination of the above-mentioned memories.
  • the server 100 is caused to execute the following processing procedures:
  • the processor 501 of the server 100 obtains the compilation result from the memory 502. Because the compilation result includes the APK of the pre-installed application in the application layer in the Android operating system source code after the code update, and the APK of the pre-installed application in the application layer in the Android operating system source code before the code update, The processor 501 determines an APK of a target application from the APK of the pre-installed application, and these target applications are applications in which only one or more of the check value, the timestamp, and the register corresponding to the constant are changed in the application code. .
  • the server After the target application is determined, the server generates first differential packets of applications other than the target applications in the pre-installed applications. In this way, compared with the prior art, the data amount of the first differential packet generated by the server is relatively small. Thereby reducing the calculation amount of the patch package running on the terminal, reducing the consumption of air interface resources, and improving the efficiency of the upgrade.
  • the application framework layer provides an activity manager service (ActivityManagerService, AMS) module.
  • the AMS mainly provides functions: 1, uniformly schedule the Activity of each application, 2, memory management, and 3, process management.
  • ActivityManagerService ActivityManagerService
  • the AMS mainly provides functions: 1, uniformly schedule the Activity of each application, 2, memory management, and 3, process management.
  • the application framework layer changes the onCreate () API interface, many applications in the application layer may change.
  • One of the situations is that pre-installed applications that call the onCreate () API interface will change. .
  • Another situation is that some applications do not call the onCreate () API interface, but because the API interface of onCreate () changes, the check value of the image file of the application framework layer changes, or the application framework The timestamp of the image file of the layer changes, so the pre-installed application associated with the image file of the application framework layer changes.
  • the server can only differentiate the APKs of the pre-installed applications that meet the first case, generate differential packages, and then package only these differential packages into the patch package of the application framework layer, so it can The number of differential files of the finally generated patch package is reduced.
  • the operation amount of the patch package running on the terminal is reduced, the air interface resource consumption is reduced, and the upgrade efficiency is improved.
  • the embodiment of the present application further describes the foregoing method of generating a patch package in combination with FIG. 6 to FIG. 9.
  • FIG. 6 a flowchart of a method for generating a patch package is provided according to an embodiment of the present application. The specific steps are as follows.
  • Step 601 When the application framework layer code in the Android operating system source code is updated, the server processor generates a compilation result, and the compilation result includes the pre-installed application in the application layer in the Android operating system source code after the code update. APK.
  • the compilation result is stored in the memory of the server.
  • the APK of the pre-installed application in the application layer in the source code of the Android operating system before the code is updated is also stored in the memory.
  • the APK for pre-installed applications can include META-INF (often seen in Jar files), res (directory for storing resource files), AndroidManifest.xml (program global configuration file), classes.dex (Dalvik bytecode), resources.arsc (compiled binary resource file). It should be noted that classes.dex can also be extracted to generate .odex files, so the differential APK includes META-INF, res, AndroidManifest.xml, resources.arsc, and .odex files other than APK. The reason why classes.dex is extracted in advance is to speed up the software loading speed and boot speed.
  • Step 602 The processor scans the pre-installed application APK in the compilation result.
  • the pre-installed application is the first application.
  • the processor obtains the first APK of the first application after the code is updated from the memory, and the first APK before the code is updated. Application of the second APK.
  • step 603 the processor compares whether the APKs before and after the code update of the pre-installed application are the same. If they are different, the processor continues to perform steps 604 to 613, otherwise, it skips to step 611.
  • the system files included in the first APK and the second APK may be .dex files, or may be both .odex files.
  • the processor can use a text file comparison tool to compare the system files in the APK. If the system files in the APK are encrypted or optimized, the processor needs to decrypt and expand the system files before comparing the system files. For example, if the system file is a .odex file, the processor needs to use the dump tool to process it before comparison, and then use the text file comparison tool to compare the processed files.
  • Step 604 The processor decompiles the system file in the first APK and the system file in the second APK of the pre-installed application to obtain the first source code corresponding to the first APK and the second source code corresponding to the second APK. Source code.
  • the decompilation process can use a progressive method, first locate the file, then locate the function, and then locate the code segment.
  • the positioning file uses the file name
  • the positioning function uses the function name
  • the positioning code segment uses the feature string to locate.
  • Step 605 The processor compares the first source code and the second source code of the pre-installed application to determine different code portions of the two.
  • step 606 the processor determines whether there are different function names and different parameter variables in different code portions of the two. If yes, the process proceeds to step 611, otherwise, the process proceeds to step 607 to step 613.
  • step 607 the processor determines whether the different parts of the first source code and the second source code differ only in one or more of the check value and the timestamp. If not, step 608 to step 613 are performed, and if yes, jump to Step 610.
  • Step 608 The processor converts the first source code and the second source code into a first semantic tree and a second semantic tree, respectively.
  • step 609 the processor determines whether the transposed in the first semantic tree is the same as the second semantic tree. If so, step 610 is performed, otherwise step 611 is performed.
  • Step 610 The processor determines that the pre-installed application is a target application.
  • Step 611 The processor determines that the pre-installed application is not the target application.
  • step 612 the processor determines whether there is an unscanned pre-installed application in the compilation result, and if so, returns to execute steps 602 to 611.
  • step 613 the processor determines applications other than the target application in the pre-installed applications, and the APKs of the applications whose codes are updated are differentiated from the APKs whose codes are updated to generate a first differential package.
  • the processor may also obtain from the compilation results the system files of the application framework layer after the code update and the system files of the application framework layer before the code is updated, and then the processor may update the code after the application framework is updated.
  • the system file of the layer is differentiated from the system file of the application framework layer described before the code is updated to generate a second difference package.
  • the processor may combine the first differential packet and the second differential packet into a patch packet, and send the patch packet to a terminal, or send the first differential packet and the second differential packet to terminal.
  • the patch package generated in this way only includes the second differential package of the application framework layer and the first differential package of the target application. Compared with the prior art, the data volume of the patch package is reduced, which can reduce the consumption of air interface resources. This patch pack upgrade also reduces traffic loss.
  • the reason why the semantic tree is used to compare different parts of the code is to further determine whether the two are the same after the transposition of the semantic tree.
  • the server can compare the tree according to the rules. Perform operations, including, but not limited to, the size ordering of leaves to transpose the semantic tree. If the two semantic trees are the same after transposition, then it can be determined that the difference is irrelevant to the code.
  • step 607 may also be replaced by the server storing constants in the function and corresponding register locations in the array for different parts of the first source code and the second source code, respectively.
  • step 608 may be replaced by the server comparing the two arrays, and if the constants in one of the arrays are interchanged with the other number, then step 608 is performed, otherwise skip to step 610.
  • step 607, step 608, and step 609 may not be performed in FIG. 6, or step 608 and step 609 are performed first, and then step 609 is performed. Finally, the final reduction to a certain extent can also be achieved. The amount of differential packet data generated.
  • the processor may also directly generate a differential package of the pre-installed application, such that step 613 is replaced by: the processor will pre-install the application The difference packets except the target application are merged into the first difference packet.
  • the embodiment of the present application exemplifies the steps of the method for generating a patch package in FIG. 6.
  • arryOfByte ah.a (locationStringBuilder.toSrting (). getBytes ("utf-8"), ""
  • the server When the function subString (0,16) of the application framework layer is changed, the server will compile the Android operating system source code, the server's processor obtains the compilation result, and updates the APK with the pre-installed application code and the pre-installed application. A version of the APK is compared. If the comparison finds a difference, the processor decompiles the .odex file in the APK with the pre-installed application code updated and the .odex file in the previous version of the APK into the first source code and the first, respectively. Second source code. After that, the server used a text file comparison tool to compare the first source code with the second source code and found the following differences (see the bold font section).
  • the processor converts the first source code and the second source code into the first semantic tree and the second semantic tree shown in FIG. 7 respectively, and the processor determines that the first semantic tree is the same as the second semantic tree after transposition.
  • the processor converts the above first source code and second source code into the following arrays respectively:
  • the constant 0 in the array obtained after the first source code conversion is stored in v8 16 is stored in v7
  • the constant 0 in the array obtained after the second source code conversion is stored in v7, 16 is stored in v8.
  • 0 and 16 in the array corresponding to the first source code part are the same as the array corresponding to the second source code part after being interchanged.
  • the processor determines that the first source code and the second source code differ only in the foregoing, it may determine that the pre-installed application is a target application.
  • the server will compile the Android operating system source code, the server's processor obtains the compilation result, and compares the updated APK of the pre-installed application code with the APK of the previous version of the pre-installed application.
  • the .odex file in the updated APK of the pre-installed application code and the .odex file in the APK of the previous version are decompiled into the first source code and the second source code, respectively.
  • the server uses a text file comparison tool to compare the first source code and the second source code. It is found that the offset address of this function is different, so it is determined that the code of the preinstalled application has changed, so the preinstalled application is not the target application. .
  • the pre-installed application B does not call the function interface Interface (), but the server processor obtains the compilation result and The updated APK of the pre-installed application B code is compared with the APK of the previous version of the pre-installed application B. If the comparison finds a difference, the processor updates the .odex file in the APK of the pre-installed application B code and the previous version. The .odex files in the APK are decompiled into the first source code and the second source code, respectively. After that, the server uses a comparison tool to compare the old version of the .odex file of the pre-installed application B with the new .odex file.
  • the server decompiles Figure 8a to obtain the The source code and the second source code are compared and found that the corresponding value of the check value field of the image file of the application framework layer in line 9 is different. Therefore, the server determines that the code of the pre-installed application B has not changed.
  • Equipment application B is the target application.
  • this embodiment of the present application also provides a schematic flowchart of another method for generating a patch package.
  • the specific steps are as follows.
  • Step 701 When the application framework layer code in the Android operating system source code is updated, the server processor generates a compilation result, and the compilation result includes the pre-installed application in the application layer in the Android operating system source code after the code update. APK.
  • the compilation result is stored in the memory of the server.
  • the APK of the pre-installed application in the application layer in the source code of the Android operating system before the code is updated is also stored in the memory.
  • Step 702 The processor scans the pre-installed application APK in the compilation result.
  • the pre-installed application is a second application.
  • the processor obtains the first APK of the second application after the code is updated from the memory, and the second APK before the code is updated. Application of the second APK.
  • step 703 the processor compares whether the APKs before and after the code update of the pre-installed application are the same. If they are different, the processor continues to perform steps 704 to 709, otherwise, it skips to step 708.
  • Step 704 The processor obtains the third source code of the pre-installed application and the fourth source code of the pre-installed application before the code update from the source code of the Android operating system.
  • the pre-installed application is a second application
  • the processor obtains the third source code of the second application after the code is updated from the source code of the Android operating system and the fourth source code of the second application before the code is updated.
  • step 705 the processor compares whether the third source code and the fourth source code of the pre-installed application are the same. If the third source code and the fourth source code are the same, step 706 to step 709 are performed;
  • step 706 the processor determines that the pre-installed application is a target application.
  • step 707 the processor determines that the pre-installed application is not a target application.
  • step 708 the processor determines whether there is an unscanned pre-installed application in the compilation result, and if so, returns to execute steps 702 to 611.
  • step 709 the processor determines applications other than the target application among the pre-installed applications, and the APKs of the applications whose codes are updated are differentiated from the APKs whose codes are updated to generate a first differential package.
  • the processor may also obtain the system files of the application framework layer after the code update from the compilation result and the system files of the application framework layer before the code is updated, and the processor may update the application framework layer after the code is updated.
  • the difference between the system file and the system file of the application framework layer described before the code update occurs to generate a second difference package.
  • the processor may combine the first difference package and the second difference package into a patch package, and The patch package is sent to the terminal, or the first differential packet and the second differential packet are sent to the terminal, respectively.
  • the patch package generated in this way only includes the second differential package of the application framework layer and the first differential package of the target application. Compared with the prior art, the data volume of the patch package is reduced, which can reduce the consumption of air interface resources. This patch pack upgrade also reduces traffic loss.
  • the processor may also directly generate a differential package of the pre-installed application, such that step 709 is replaced by: the processor will pre-install the application The difference packets except the target application are merged into the first difference packet.
  • the terminal can manually select an update patch package or the terminal automatically updates the patch package at a regular time.
  • the patch package is obtained from the server and updated, as shown in the figure.
  • the terminal pops up a prompt box, which includes the security patch of the application framework layer of this update, about 6M in size, this update fixes a problem, etc., and then the terminal Restart. After the restart, the security patches of the application framework layer take effect.
  • the server determines the target application where only the check value changes, the timestamp changes, and the register corresponding to the constant changes.
  • the server generates the pre-installed application.
  • the data amount of the first differential packet generated by the server is relatively small, thereby reducing the calculation amount of the terminal running the patch package, Reduce the consumption of air interface resources and improve the efficiency of the upgrade.
  • Various illustrative logic blocks, modules, and circuits described in the embodiments of the present application may be implemented by a general-purpose processing unit, a digital signal processing unit, an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic. Devices, discrete gate or transistor logic, discrete hardware components, or any combination of the above are designed to implement or operate the described functions.
  • the general-purpose processing unit may be a micro-processing unit. Alternatively, the general-purpose processing unit may also be any conventional processing unit, controller, microcontroller, or state machine.
  • the processing unit may also be implemented by a combination of computing devices, such as a digital signal processing unit and a micro processing unit, multiple micro processing units, one or more micro processing units combined with a digital signal processing unit core, or any other similar configuration. achieve.
  • a software module may be stored in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium in the art.
  • the storage medium may be connected to the processing unit, so that the processing unit can read information from the storage medium and can write information to the storage medium.
  • the storage medium may also be integrated into the processing unit.
  • the processing unit and the storage medium may be configured in an ASIC, and the ASIC may be configured in a user terminal.
  • the processing unit and the storage medium may also be configured in different components in the user terminal.
  • the above functions described in the embodiments of the present application may be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, these functions can be stored on a computer-readable medium or transmitted as one or more instructions or code on a computer-readable medium.
  • Computer-readable media includes computer storage media and communication media that facilitates transfer of computer programs from one place to another. Storage media can be any available media that can be accessed by a general purpose or special computer.
  • Such computer-readable media may include, but is not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage, or other magnetic storage devices, or any other device or instructions that can be used to carry or store instructions or data structures and Other media that can be read by a general or special computer or a general or special processing unit.
  • any connection can be appropriately defined as a computer-readable medium, for example, if the software is from a web site, server, or other remote resource via a coaxial cable, fiber optic computer, twisted pair, digital subscriber line (DSL) Or transmitted wirelessly such as infrared, wireless, and microwave are also included in the defined computer-readable media.
  • DSL digital subscriber line
  • the disks and discs include compact disks, laser disks, optical disks, DVDs, floppy disks and Blu-ray disks. Disks usually copy data magnetically, and disks usually copy data optically with lasers. A combination of the above may also be contained in a computer-readable medium.

Abstract

本申请提供一种补丁包生成方法及设备,该方法包括:当安卓操作系统源码中的应用程序框架层的代码发生更新时,服务器获取编译结果,然后服务器从所述预装应用的APK中确定出目标应用的APK,也就是服务器确定出应用的代码中仅校验值、时间戳、以及常量对应的寄存器其中一个或多个发生变化的应用,服务器将代码更新后所述预装应用中除了所述目标应用的应用的APK,以及代码更新前所述预装应用中除了所述目标应用的应用的APK进行差分,生成第一差分包。因为第一差分包的数据量相对减小,服务器将第一差分包下发到终端后,终端采用第一差分包升级可以减小终端运行补丁包的运算量、减少空口资源的消耗,提高升级的效率。

Description

一种补丁包生成方法及设备 技术领域
本申请涉及通信技术领域,尤其涉及一种补丁包生成方法及设备。
背景技术
目前开发人员在修复安卓(Android)终端的应用程序框架(framework)层问题的同时,对应用层中的各个应用的安卓安装包(android package,APK)也会因应用程序框架层的更新而进行更新。针对应用的更新内容,当前可以利用差分技术生成差分包,具体地,将某一应用的旧版本的APK与更新后生成的APK进行对比,将对比出来的区别部分压缩成差分包。
从上述差分技术可知,因应用程序框架层的更新而发生更新的应用生成了差分APK,所以在修复应用程序框架层的问题的同时,服务器也需要把这些应用的差分包打包到应用程序框架层的补丁包中,所以最终生成的应用程序框架层的补丁包会很大(一般有上百兆),当终端利用服务器下发的应用程序框架层的补丁包进行升级时,会对空口资源和用户的流量造成很大的损耗。
发明内容
本申请提供一种补丁包生成方法及设备,用以生成数据量相对较小的补丁包,从而减小终端运行补丁包的运算量、减少空口资源和流量的消耗,提高升级的效率。
第一方面,本申请实施例提供了一种补丁包生成方法,该方法包括:当安卓操作系统源码中的应用程序框架层的代码发生更新时,服务器获取编译结果,编译结果中包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的安卓安装包APK,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的APK。然后服务器从所述预装应用的APK中确定出目标应用的APK,所谓目标应用也就是应用的代码中仅校验值、时间戳、以及常量对应的寄存器其中一个或多个发生变化的应用。服务器将代码更新后所述预装应用中除了所述目标应用的应用的APK,以及代码更新前所述预装应用中除了所述目标应用的应用的APK进行差分,生成第一差分包。
在本申请实施例中,通过上述方法生成的第一差分包的数据量相对减小,当服务器将第一差分包下发到终端,终端采用第一差分包升级时,可以减小终端运行补丁包的运算量、减少空口资源的消耗,提高升级的效率。
在一种可能的实现中,服务器所获取的编译结果中还可以包括代码更新后应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件,服务器可以将代码发生更新后所述应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件进行差分,生成第二差分包,然后服务器将所述第一差分包和所述第二差分包合成一个补丁包,并将所述补丁包发送至终端,或者将所述第一差分包和所述第二差分包分别发送至终端。这样生成的补丁包仅包括应用程序框架层的第二差分包,和目标应用的第一差分包,与现有技术相比,补丁包的数据量减小,可以减少空口资源的消耗,终端采用这一补丁包升级也能够减少流量的损耗。
在一种可能的实现中,所述服务器从所述编译结果中获取代码更新后的第一应用的APK和代码更新前的所述第一应用的APK,该第一应用为所述预装应用中的一个应用,然后服务器确定所述第一应用的代码更新前后的APK不同时,将所述代码更新后第一应用的APK中的系统文件反编译成第一源代码,以及将代码更新前所述第一应用的APK的系统文件反编译成第二源代码。
接着,服务器确定是否第一源代码和第二源代码中仅校验值、时间戳、以及常量对应的寄存器中的一个或多个不同,若是,则服务器确定第一应用为目标应用,以及确定第一应用的APK为目标应用的APK。
在本申请实施例中,若第一应用的第一源代码和第二源代码仅校验值、时间戳、常量对应的寄存器这些不同,则可以说明第一应用的功能实现没有发生变化,所以不需要打包到补丁包,这样服务器最后仅将除了这些目标应用之外的应用的APK进行差分,生成第一差分包,所以可以减小最终生成和发送的的补丁包的文件大小,从而减小终端运行补丁包的运算量、减少空口资源的消耗,提高升级的效率。
在一种可能的实现中,服务器确定是否第一源代码和第二源代码中仅常量对应的寄存器不同的方式可以是:服务器先比较所述第一源代码和所述第二源代码是否不同,若不同,则服务器将所述第一源代码转换成第一语义树和将第二源代码转换成第二语义树,若第一语义树转置后与第二语义树相同,则服务器确定所述第一源代码和所述第二源代码中仅常量对应的寄存器不同。
在本申请实施例中,服务器可以确定出第一应用的代码仅常量对应的寄存器不同,第一应用的功能实现并没有发生变化。
在一种可能的实现中,服务器确定是否第一源代码和第二源代码中仅校验值、时间戳中的一个或多个不同的方式可以是:
服务器比较第一源代码和第二源代码是否不同;若不同,则服务器确定所述所述第一源代码和所述第二源代码中的不同代码部分对应的字段是否是时间戳字段,若是,则服务器确定所述第一源代码和所述第二源代码中仅校验值不同。
在一种可能的实现中,服务器确定是否第一源代码和第二源代码中仅校验值、时间戳中的一个或多个不同的方式可以是:
服务器比较第一源代码和第二源代码是否不同;若不同,则服务器确定第一源代码和所述第二源代码中的不同代码部分对应的字段是否是校验值字段;若是,则服务器确定第一源代码和所述第二源代码中仅时间戳不同。
在本申请实施例中,服务器可以确定出第一应用的代码仅时间戳、校验值不同,第一应用的功能实现并没有发生变化。
在另一种可能的实现中,所述服务器从所述编译结果中获取代码更新后的第一应用的APK和代码更新前的所述第二应用的APK,该第二应用为所述预装应用中的一个应用,然后服务器确定所述第二应用的代码更新前后的APK不同时,服务器从安卓操作系统源码中获取代码更新后所述第二应用的第三源代码和所述代码更新前的所述第二应用的第四源代码,当所述服务器比较发现所述第三源代码和所述第四源代码相同时,则确定所述第一应用的APK为目标应用的APK。
在本申请实施例中,若服务器确定第三源代码和第四源代码相同,则说明第一应用的代码并没有被改动,所以第一应用的功能实现没有变化,因此第一应用并不需要打包到补 丁包中,所以可以减小最终生成和发送的的补丁包的文件大小,从而减小终端运行补丁包的运算量、减少空口资源的消耗,提高升级的效率。
第二方面,本申请实施例提供一种服务器,包括处理器和存储器。其中,存储器用于存储一个或多个计算机程序,以及安卓操作系统源码、该安卓操作系统源码编译生成的编译结果;其中,安卓操作系统源码编译生成的编译结果包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新后所述应用程序框架层的系统文件和代码发生更新前所述应用程序框架层的系统文件。另外安卓操作系统源码包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的源代码,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的源代码。当存储器存储的一个或多个计算机程序被处理器执行时,使得服务器能够实现第一方面的任意一种可能的设计的方法。
第三方面,本申请实施例还提供了一种服务器,所述服务器包括执行第一方面或者第一方面的任意一种可能的设计的方法的模块/单元。这些模块/单元可以通过硬件实现,也可以通过硬件执行相应的软件实现。
第四方面,本申请实施例中还提供一种计算机可读存储介质,所述计算机可读存储介质包括计算机程序,当计算机程序在服务器上运行时,使得所述服务器执行第一方面或上述第一方面的任意一种可能的设计的方法。
第五方面,本申请实施例还提供一种包含计算机程序产品,当所述计算机程序产品在服务器上运行时,使得所述服务器执行第一方面或上述第一方面的任意一种可能的设计的方法。
本申请的这些方面或其他方面在以下实施例的描述中会更加简明易懂。
附图说明
图1为本申请实施例提供的一种OTA应用场景示意图;
图2为本申请实施例提供的一种终端的结构示意图;
图3为本申请实施例提供的一种终端内操作系统的架构示意图;
图4a至图4b为本申请实施例提供的差分方法示意图;
图5为本申请实施例提供的一种服务器的架构示意图;
图6为本申请实施例提供的一种补丁包生成方法流程示意图;
图7为本申请实施例提供的一种语义树转置方式示意图;
图8a为本申请实施例提供的一种文本文件比较结果示意图;
图8b为本申请实施例提供的一种源代码比较结果示意图;
图9为本申请实施例提供的另一种补丁包生成方法流程示意图一;
图10为本申请实施例提供的一种终端更新补丁包的界面示意图。
具体实施方式
下面将结合附图对本申请实施例作进一步地详细描述。
差分技术经常应用于空中下载技术(over the air,OTA)升级中。应用及内容服务商可以通过空中接口分发软件的新版本,软件的配置设置,以及新的秘钥。通过OTA,终端用 户只要进行简单操作,就可以按照个人喜好把应用及内容服务商所提供的各种业务菜单利用OTA机制下载到终端中,并且还可以根据自己的意愿定制具体业务。
如图1所示,本申请实施例提供一种OTA升级的场景架构,该场景架构包括服务器100、终端200,终端200和服务器100通过通信网络互相通信。其中,该通信网络可以是局域网,也可以是通过中继(relay)设备转接的广域网。当该通信网络为局域网时,示例性的,该通信网络可以是wifi热点网络、wifi直连网络、蓝牙网络、zigbee网络或近场通信(near field communication,NFC)网络等近距离通信网络。当该通信网络为广域网时,示例性的,该通信网络可以是第三代移动通信技术(3rd-generation wireless telephone technology,3G)网络、第四代移动通信技术(the 4th generation mobile communication technology,4G)网络、第五代移动通信技术(5th-generation mobile communication technology,5G)网络、未来演进的公共陆地移动网络(public land mobile network,PLMN)或因特网等。
其中,服务器100保存有程序包,程序包通常是程序包的开发人员上传到服务器的,程序包可以有差分APK或者全量APK这两种类型。
终端200从服务器下载程序包,然后保存至本地,并更新终端上的已安装的软件。当终端200从服务器获取的是全量APK时,则直接使用该全量APK进行升级。当终端200从服务器获取的是差分APK时,则使用该差分APK与自身已安装的镜像文件合成新的APK,从而使用该新的APK进行升级。
示例性的,上述终端200可以为手机、平板电脑、笔记本电脑、超级移动个人计算机(ultra-mobile personal computer,UMPC)、上网本、个人数字助理(personal digital assistant,PDA)等终端设备,下面以终端为手机为例进行说明,图2示出的是与本发明各实施例相关的终端200的部分结构的框图。
如图2所示,终端200为手机,该手机包括:RF(radio frequency,射频)电路201、Wi-Fi系统模块202、存储器203、输入单元204、显示单元205、处理器206、音频电路207以及电源208等部件。本领域技术人员可以理解,图200中示出的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
下面结合图2对终端200的各个构成部件进行具体的介绍:
Wi-Fi系统模块202用于扫描终端200周围环境存在的Wi-Fi接入点,获取相关信息,以便终端200根据所述相关信息接入所述Wi-Fi接入点。
RF电路201用于收发信息或通话过程中信号的接收和发送,特别地,将基站的下行信息接收后,给处理器206处理。另外,将上行的数据发送给基站。在本申请实施例中,所述RF电路201与Wi-Fi系统模块的Wi-Fi天线相连,控制Wi-Fi天线对Wi-Fi网络的扫描。通常,RF电路201包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(low noise amplifier,LNA)、双工器等。此外,RF电路201还可以通过无线通信与网络和其他设备通信。
该存储器203用于存储该终端200的软件程序。通常,该存储器203可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
处理器206是终端200的控制中心,利用各种接口和线路连接整个手机的各个部分, 通过运行或执行存储在存储器203内的软件程序,以及调用存储在存储器203内的数据,执行终端200的各种功能和数据处理。
其中,上述处理器206可包括一个或多个处理单元;优选的,处理器206可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器206中。
输入单元204可用于接收输入的数字或字符信息,以及产生与终端200的用户设置以及功能控制有关的键信号输入。具体地,输入单元204可包括触摸屏以及其他输入设备。触摸屏也称为触控面板,可收集用户在其上或附近的触摸操作并根据预先设定的程式驱动相应的连接装置。其他输入设备可以包括但不限于物理键盘、功能键(比如音量控制按键、电源开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元205可用于显示由用户输入的信息或提供给用户的信息以及手机200的各种菜单。显示单元205可包括显示面板,可选的,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板。
音频电路207连接扬声器和麦克风,可提供用户与手机200之间的音频接口。音频电路207可将接收到的音频数据转换后的电信号,传输到扬声器,由扬声器转换为声音信号输出;另一方面,麦克风将收集的声音信号转换为电信号,由音频电路接收后转换为音频数据,再将音频数据输出至RF电路201以发送给比如另一手机,或者将音频数据输出至存储器203以便进一步处理。
手机200还包括给各个部件供电的电源208(比如电池),优选的,电源可以通过电源管理系统与处理器206逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。
尽管未示出,终端200还可以包括蓝牙模块,传感器、GPS等,在此不再赘述。
另一方面,终端200的软件系统可以采用分层架构,事件驱动架构,微核架构,微服务架构,或云架构。本发明实施例以分层架构的Android系统为例,示例性说明终端200的软件结构。
图3是本发明实施例的终端200的软件结构框图。
分层架构将软件分成若干个层,每一层都有清晰的角色和分工。层与层之间通过软件接口通信。在一些实施例中,将Android系统分为四层,从上至下分别为应用程序层,应用程序框架层,安卓运行时(Android runtime)和系统库,以及内核层。
应用程序层可以包括一系列应用程序包。
如图3所示,应用程序包可以包括相机,图库,日历,通话,地图,导航,WLAN,蓝牙,音乐,视频,短信息等应用程序。
应用程序框架层为应用程序层的应用程序提供应用编程接口(application programming interface,API)和编程框架。应用程序框架层包括一些预先定义的函数。
如图3所示,应用程序框架层可以包括窗口管理器,内容提供器,视图系统,电话管理器,资源管理器,通知管理器等。
窗口管理器用于管理窗口程序。窗口管理器可以获取显示屏大小,判断是否有状态栏,锁定屏幕,截取屏幕等。
内容提供器用来存放和获取数据,并使这些数据可以被应用程序访问。所述数据可以 包括视频,图像,音频,拨打和接听的电话,浏览历史和书签,电话簿等。
视图系统包括可视控件,例如显示文字的控件,显示图片的控件等。视图系统可用于构建应用程序。显示界面可以由一个或多个视图组成的。例如,包括短信通知图标的显示界面,可以包括显示文字的视图以及显示图片的视图。
电话管理器用于提供终端200的通信功能。例如通话状态的管理(包括接通,挂断等)。
资源管理器为应用程序提供各种资源,比如本地化字符串,图标,图片,布局文件,视频文件等等。
通知管理器使应用程序可以在状态栏中显示通知信息,可以用于传达告知类型的消息,可以短暂停留后自动消失,无需用户交互。比如通知管理器被用于告知下载完成,消息提醒等。通知管理器还可以是以图表或者滚动条文本形式出现在系统顶部状态栏的通知,例如后台运行的应用程序的通知,还可以是以对话窗口形式出现在屏幕上的通知。例如在状态栏提示文本信息,发出提示音,电子设备振动,指示灯闪烁等。
Android Runtime包括核心库和虚拟机。Android runtime负责安卓系统的调度和管理。
核心库包含两部分:一部分是java语言需要调用的功能函数,另一部分是安卓的核心库。
应用程序层和应用程序框架层运行在虚拟机中。虚拟机将应用程序层和应用程序框架层的java文件执行为二进制文件。虚拟机用于执行对象生命周期的管理,堆栈管理,线程管理,安全和异常的管理,以及垃圾回收等功能。
系统库可以包括多个功能模块。例如:表面管理器(surface manager),媒体库(Media Libraries),三维图形处理库(例如:OpenGL ES),2D图形引擎(例如:SGL)等。
表面管理器用于对显示子系统进行管理,并且为多个应用程序提供了2D和3D图层的融合。
媒体库支持多种常用的音频,视频格式回放和录制,以及静态图像文件等。媒体库可以支持多种音视频编码格式,例如:MPEG4,H.264,MP3,AAC,AMR,JPG,PNG等。
三维图形处理库用于实现三维图形绘图,图像渲染,合成,和图层处理等。
2D图形引擎是2D绘图的绘图引擎。
内核层是硬件和软件之间的层。内核层至少包含显示驱动,摄像头驱动,音频驱动,传感器驱动。
下面结合捕获拍照场景,示例性说明电子设备100软件以及硬件的工作流程。
当触摸传感器180K接收到触摸操作,相应的硬件中断被发给内核层。内核层将触摸操作加工成原始输入事件(包括触摸坐标,触摸操作的时间戳等信息)。原始输入事件被存储在内核层。应用程序框架层从内核层获取原始输入事件,识别该输入事件所对应的控件。以该触摸操作是触摸单击操作,该单击操作所对应的控件为相机应用图标的控件为例,相机应用调用应用框架层的接口,启动相机应用,进而通过调用内核层启动摄像头驱动,通过摄像头捕获静态图像或视频。
在本申请实施例中,服务器100发送给终端200的补丁包通常是差分包,因差分包通常只有几兆,所以可以很大程度上减少升级时对用户流程的消耗。差分包是服务器100采用差分技术生成的。差分技术一般会分为两种,一种是基于块差分(例如开源工具bsdiff),一种是基于文件差分(例如开源工具imgdiff)。
如图4a和图4b所示,原有代码401是系统更新前的一个应用的源码,新代码402是在原有代码401上更新生成的源码,原有代码401和新代码402可以经过编译生成APK文件,APK403是原有源码编译生成的一个安卓安装包,APK404是新代码编译生成的一个安卓安装包。当采用开源工具bsdiff对APK403和APK404进行差分时,生成差分包405a,当采用开源工具imgdiff对APK403和APK404进行差分时,生成差分包405b。相比较而言,差分包405a的文件大小较差分包405b的文件较大,但是终端从服务器获取差分包405a后合成镜像文件的速度较快;差分包405b的文件较小,但是终端从服务器获取差分包405a后合成镜像文件的速度相对较慢。
目前无论哪种差分技术均不能精确定位代码修改部分和差分包中差分文件的对应关系,所以经常会因代码一处小小的改动会导致出现差分包很大(例如上百兆)的情况。特别是当终端的开发人员修复了应用程序框架层的问题,最终生成的补丁包中包含很多应用的差分APK,导致最终生成的补丁包非常大。
为解决这一问题,本申请实施例提供一种补丁包生成方法,该方法能够实现在应用程序框架层被修复时,服务器从操作系统源代码中预装应用中确定出仅仅校验值发生变化、时间戳发生变化、以及常量对应的寄存器发生变化的目标应用。其中,预装应用指的是谷歌所发布的安卓操作系统源码中的已预先安装的应用,以及不同的厂商在谷歌所发布的安卓操作系统源码基础上预先安装的应用,这些预装应用不同于用户从应用商店下载的第三方应用,主要是这些预装应用在用户终端上具有不可删除的特点。当确定出目标应用之后,服务器生成预装应用中除了这些目标应用之外的应用的第一差分包,这样的话,与现有技术相比,服务器所生成的第一差分包的数据量相对较小,从而减小终端运行补丁包的运算量、减少空口资源和流量的消耗,提高升级的效率。
示例性的,用以执行该补丁包生成方法的服务器100可以为具有编译功能的服务器或者云服务器。图5示出的是与本申请各实施例相关的服务器100的部分结构的框图。
如图5所示,该服务器100可以包括:包括处理器501、存储器502以及收发器503。其中该一个或多个计算机程序被存储在上述存储器501中并被配置为被该一个或多个处理器502执行。
处理器501,可以是中央处理单元(central processing unit,CPU),或者为数字处理单元等,处理器501是服务器100的控制中心,利用各种接口和线路连接整个服务器的各个部分,通过运行或执行存储在存储器502内的计算机程序,以及调用存储在存储器502内的数据,执行服务器100的各种功能和数据处理。
存储器502,用于存储待运行的计算机程序,若该服务器100是云服务器,则存储器502中还存储有从具有编译功能的服务器获取的安卓操作系统编译生成的编译结果,其中编译结果包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新后所述应用程序框架层的系统文件和代码发生更新前所述应用程序框架层的系统文件。另外该存储器502还存储有从具有编译功能的服务器上获取的预装应用的源代码,其中预装应用的源代码主要包括:代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的源代码,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的源代码。
另外,若该服务器100是具有编译功能的服务器,则存储器502中存储有安卓操作系 统源码和该安卓操作系统源码编译生成的编译结果。其中该安卓操作系统源码至少包括应用框架层的代码,以及应用层中预装应用的源代码。
其中,编译结果包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新后所述应用程序框架层的系统文件和代码发生更新前所述应用程序框架层的系统文件。另外,应用层中预装应用的源代码主要包括:代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的源代码,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的源代码。
收发器503,用于将处理器501生成的补丁包发送至终端侧。
本申请实施例中不限定上述处理器501以及存储器502之间的具体连接介质。本申请实施例在图4中以存储器502、处理器501以及收发器503之间通过总线504连接,总线在图4中以粗线表示,其它部件之间的连接方式,仅是进行示意性说明,并不引以为限。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图4中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
其中,存储器502可以是易失性存储器(volatile memory),例如随机存取存储器(random-access memory,RAM);存储器503也可以是非易失性存储器(non-volatile memory),例如只读存储器,快闪存储器(flash memory),硬盘(hard disk drive,HDD)或固态硬盘(solid-state drive,SSD)、或者存储器502是能够用于携带或存储具有指令或数据结构形式的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器503可以是上述存储器的组合。
当存储器502存储的一个或多个计算机程序被所述处理器501执行时,使得服务器100执行如下处理过程:
当安卓操作系统源码中的应用程序框架层的代码发生更新时,服务器100的处理器501从存储器502中获取编译结果。因为编译结果包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的APK,所以处理器501从所述预装应用的APK中确定出目标应用的APK,这些目标应用是指应用的代码中仅校验值、时间戳、以及常量对应的寄存器其中一个或多个发生变化的应用。当确定出目标应用之后,服务器生成预装应用中除了这些目标应用之外的应用的第一差分包,这样与现有技术相比,服务器所生成的第一差分包的数据量相对较小,从而减小终端运行补丁包的运算量、减少空口资源的消耗,提高升级的效率。
例如说,应用程序框架层提供有活动管理器服务(ActivityManagerService,AMS)模块,AMS中主要提供功能:1、统一调度各个应用程序的Activity,2、内存管理,3、进程管理。如果应用程序框架层改动了onCreate()这一API接口,就可能导致应用层的很多应用会发生变化,其中一种情况是,凡是调用了onCreate()这一API接口的预装应用会发生变化。另一种情况是,部分应用并没有调用onCreate()这一API接口,但因onCreate()这一API接口发生改变,导致应用程序框架层的镜像文件的校验值发生变化,或者应用程序框架层的镜像文件的时间戳会发生变化,因此与应用程序框架层的镜像文件相关联的预装应用会发生变化。如果按照现有技术,可能会对所有发生变化的预装应用的APK进行差分,生成差分包,将这些差分包全部打包到应用程序框架层的补丁包中。而本申请提供的上述实现方案,服务器可以仅将满足第一种情况的预装应用的APK进行差分,生成差分包, 然后将仅将这些差分包打包到应用程序框架层的补丁包,所以可以减少最终生成的补丁包的差分文件数量,另外,终端更新了该补丁包后,从而减小终端运行补丁包的运算量、减少空口资源的消耗,提高升级的效率。
具体来说,本申请实施例进一步结合图6至图9,对上述补丁包生成方法进行详细阐述。
如图6所示,为本申请实施例提供一种补丁包生成方法流程示意图,具体步骤如下。
步骤601,当安卓操作系统源码中的应用程序框架层的代码发生更新时,服务器的处理器生成编译结果,该编译结果包括代码更新后该安卓操作系统源码中的应用层中的预装应用的APK。该编译结果被存储在服务器的存储器中,另外存储器中还存储有代码发生更新前该安卓操作系统源码中的应用层中的预装应用的APK。
其中,预装应用的APK可以包括META-INF(Jar文件中常可以看到)、res(存放资源文件的目录)、AndroidManifest.xml(程序全局配置文件)、classes.dex(Dalvik字节码)、resources.arsc(编译后的二进制资源文件)。需要说明的是,classes.dex也可以被提取出来生成.odex文件,这样差分APK就包括META-INF、res、AndroidManifest.xml、resources.arsc,以及APK之外的.odex文件。之所以把classes.dex预先提取出来,作用是能加快软件加载速度和开机速度。
步骤602,处理器扫描编译结果中预装应用APK,例如预装应用是第一应用,处理器从存储器中获取代码更新后的该第一应用的第一APK,以及代码更新前的该第一应用的第二APK。
步骤603,该处理器比较该预装应用的代码更新前后的APK是否相同,若不同,则继续执行步骤604至步骤613,否则跳转至步骤611。
其中,第一APK和第二APK中包括的系统文件可能都是.dex文件,也可能都是.odex文件。处理器可以采用文本文件比较工具对APK中的系统文件进行比较。如果APK中的系统文件是经过加密或者是经过优化的,那么处理器在比较系统文件前需要对该系统文件进行解密和展开。比如说系统文件是.odex文件,那么在处理器在比较之前需要用dump工具对其进行处理,然后再利用文本文件比较工具对处理后的文件进行比较。
步骤604,处理器将该预装应用的第一APK中的系统文件和第二APK中的系统文件进行反编译处理,分别得到第一APK对应的第一源代码和第二APK对应的第二源代码。
其中,反编译的过程可以采用层级递进的方法,先定位文件,再定位函数,再定位代码段。例如,定位文件使用文件名,定位函数使用函数名,定位代码段使用特征字符串来定位。
步骤605,处理器对该预装应用的第一源代码和第二源代码进行对比,确定出二者不同的代码部分。
步骤606,处理器确定二者不同的代码部分是否存在函数名不同、参数变量不同,若是,则跳转至步骤611,否则继续执行步骤607至步骤613。
步骤607,处理器判断第一源代码和第二源代码不同的部分是否仅校验值、时间戳中的一个或多个不同,若否,则执行步骤608至步骤613,若是则跳转至步骤610。
步骤608,处理器将第一源代码和第二源代码分别转换为第一语义树和第二语义树。
步骤609,处理器判断第一语义树中转置后与第二语义树是否相同,若是,则执行步骤610,否则执行步骤611。
步骤610,处理器确定该预装应用是目标应用。
步骤611,处理器确定该预装应用不是目标应用。
步骤612,处理器判断编译结果是否有未扫描的预装应用,若有,则返回执行步骤602至611。
步骤613,处理器确定出预装应用中的除了目标应用之外的应用,该这些应用的代码更新后APK与代码更新的APK进行差分,生成第一差分包。
另外,处理器还可以从编译结果中获取代码更新后应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件,然后处理器可以将代码发生更新后所述应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件进行差分,生成第二差分包。处理器可以将所述第一差分包和所述第二差分包合成一个补丁包,并将所述补丁包发送至终端,或者将所述第一差分包和所述第二差分包分别发送至终端。这样生成的补丁包仅包括应用程序框架层的第二差分包,和目标应用的第一差分包,与现有技术相比,补丁包的数据量减小,可以减少空口资源的消耗,终端采用这一补丁包升级也能够减少流量的损耗。
补充来说,在上述步骤608中,之所以用语义树来比较代码中的不同部分,是为了后面进一步判断语义树转置之后二者是否相同,在语义树生成之后,服务器可以依据规则对树进行操作,包括但是不限于树叶的大小排序规则来转置语义树,如果两个语义树转置后相同,那么可以确定该差异是与代码无关的。
需要说明的是,这里并不限于树的形式,也可以是其他数据结构,比如链表,数组等能够进行平面或者空间变换的数据结构。比如说,步骤607也可以替换为,服务器针对第一源代码和第二源代码中的不同部分,分别将函数中的常量和对应的寄存器位置对应保存在数组中。步骤608可以替换为,服务器比较两个数组,若其中一个数组中的常量互换后与另一个数字相同则执行步骤608,否则跳转至步骤610。
另外,需要说明的是,图6中也可以不执行步骤607,或者不执行步骤608和步骤609,或者是先执行步骤608和步骤609,再执行步骤609,最终也能够实现一定程度上减少最终生成的差分包数据量大小。
在一种可能的实现方式中,图6中在执行步骤603之后以及执行步骤604之前,处理器也可以直接生成该预装应用的差分包,这样步骤613被替换为:处理器将预装应用中除了目标应用的差分包合并成第一差分包。
进一步地,本申请实施例对图6中的补丁包生成方法的步骤进行举例说明。
示例1
假设开发人员改动了应用程序框架层的函数subString(0,16),见下文代码部分。
Try{
arryOfByte=ah.a(locationStringBuilder.toSrting().getBytes(“utf-8”),“…”
.substring(0,16).getBytes(“utf-8”));
}
当应用程序框架层的函数subString(0,16)改动之后,服务器会对安卓操作系统源码进行编译,服务器的处理器获取编译结果,并将预装应用代码更新后的APK与该预装应用上一版本的APK进行比较,若比较发现不同,则处理器将该预装应用代码更新后的APK中.odex文件和上一版本的APK中的.odex文件分别反编译成第一源代码和第二源代码。之后,服务器采用文本文件比较工具,比较第一源代码和第二源代码发现存在如下不同(见 加粗字体部分)。
Figure PCTCN2018096318-appb-000001
处理器将上述第一源代码和第二源代码分别转换成图7所示的第一语义树和第二语义树,并且处理器确定第一语义树经过转置后与第二语义树相同。
或者,另一种方式可以是,处理器经上述第一源代码和第二源代码分别转换成如下数组:
第一源源代码部分对应的数组:
Figure PCTCN2018096318-appb-000002
第二源代码部分对应的数组:
Figure PCTCN2018096318-appb-000003
可见,第一源代码转换后得到的数组中常量0存储在v8里面,16存储在v7上面,而第二源代码转换后得到的数组中常量0存储在v7里面,16存储在v8里面。第一源代码部分对应的数组中的0和16互换后与第二源代码部分对应的数组相同。
如果处理器确定第一源代码和第二源代码仅存在上述不同,则可以确定该预装应用是目标应用。
示例2
假设应用程序框架层改动Interface()这一函数的偏移地址,就可能导致调用该函数的应用的逻辑实现发生变化。服务器会对安卓操作系统源码进行编译,服务器的处理器获取编译结果,并将预装应用代码更新后的APK与该预装应用上一版本的APK进行比较,若比较发现不同,则处理器将该预装应用代码更新后的APK中.odex文件和上一版本的APK中的.odex文件分别反编译成第一源代码和第二源代码。之后,服务器采用文本文件比较工具,比较发现第一源代码和第二源代码发现这一函数的偏移地址不同,所以确定该预装应用的代码发生变化,所以将该预装应用不是目标应用。
再比如说,如果应用程序框架层改动Interface()这一函数接口的偏移地址,预装应用B并没有调用了Interface()这一函数接口,但是服务器的处理器获取编译结果,并将预装应用B代码更新后的APK与该预装应用B上一版本的APK进行比较,若比较发现不同,则处理器将该预装应用B代码更新后的APK中.odex文件和上一版本的APK中的.odex文件分别反编译成第一源代码和第二源代码。之后,服务器采用比较工具,比较该预装应用B的旧版本的.odex文件和新的.odex文件有部分字段不同,如图8a所示,服务器将图8a反编译得到图8b所示的第一源代码和第二源代码,经比较发现第9行中应用程序框架层的镜像文件的校验值字段对应的取值不同,所以服务器确定预装应用B的代码没有发生改动, 因此该预装应用B是目标应用。
如图9所示,为本申请实施例还提供另一种补丁包生成方法流程示意图,具体步骤如下。
步骤701,当安卓操作系统源码中的应用程序框架层的代码发生更新时,服务器的处理器生成编译结果,该编译结果包括代码更新后该安卓操作系统源码中的应用层中的预装应用的APK。该编译结果被存储在服务器的存储器中,另外存储器中还存储有代码发生更新前该安卓操作系统源码中的应用层中的预装应用的APK。
步骤702,处理器扫描编译结果中预装应用APK,例如预装应用是第二应用,处理器从存储器中获取代码更新后的该第二应用的第一APK,以及代码更新前的该第二应用的第二APK。
步骤703,该处理器比较该预装应用的代码更新前后的APK是否相同,若不同,则继续执行步骤704至步骤709,否则跳转至步骤708。
步骤704,处理器从安卓操作系统源码中获取代码更新后该预装应用的第三源代码和所述代码更新前的该预装应用的第四源代码。
例如,预装应用是第二应用,处理器从从安卓操作系统源码中获取代码更新后该第二应用的第三源代码和所述代码更新前的该第二应用的第四源代码。
步骤705,处理器比较该预装应用的第三源代码和第四源代码是否相同,若相同,则执行步骤706至步骤709,否则跳转至步骤707。
步骤706,处理器确定该预装应用是目标应用。
步骤707,处理器确定该预装应用不是目标应用。
步骤708,处理器判断编译结果是否有未扫描的预装应用,若有,则返回执行步骤702至611。
步骤709,处理器确定出预装应用中的除了目标应用之外的应用,该这些应用的代码更新后APK与代码更新的APK进行差分,生成第一差分包。
另外,处理器还可以从编译结果中获取代码更新后应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件,处理器可以将代码发生更新后所述应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件进行差分,生成第二差分包,处理器可以将所述第一差分包和所述第二差分包合成一个补丁包,并将所述补丁包发送至终端,或者将所述第一差分包和所述第二差分包分别发送至终端。这样生成的补丁包仅包括应用程序框架层的第二差分包,和目标应用的第一差分包,与现有技术相比,补丁包的数据量减小,可以减少空口资源的消耗,终端采用这一补丁包升级也能够减少流量的损耗。
在一种可能的实现方式中,图9中在执行步骤703之后以及执行步骤704之前,处理器也可以直接生成该预装应用的差分包,这样步骤709被替换为:处理器将预装应用中除了目标应用的差分包合并成第一差分包。
这样,当服务器按照上述步骤生成应用程序框架层的安全补丁之后,终端可以在用户手动选择更新补丁包,或者终端定时自动更新补丁包是,从服务器获取这一补丁包,并进行更新,如图10所示,当终端用户手动选择更新补丁包,然后终端弹出提示框,提示框内容包括本次更新应用程序框架层的安全补丁,约6M大小,本次更新修复了某一问题等, 然后终端重启,重启之后,应用程序框架层的安全补丁生效。
综上,服务器从操作系统源代码中预装应用中确定出仅仅校验值发生变化、时间戳发生变化、以及常量对应的寄存器发生变化的目标应用,当确定出目标应用之后,服务器生成预装应用中除了这些目标应用之外的应用的第一差分包,这样与现有技术相比,服务器所生成的第一差分包的数据量相对较小,从而减小终端运行补丁包的运算量、减少空口资源的消耗,提高升级的效率。
本所属领域的技术人员可以清楚地了解到,本发明提供的各实施例的描述可以相互参照,为描述的方便和简洁,关于本申请实施例提供的各装置、设备的功能以及执行的步骤可以参照本发明方法实施例的相关描述,在此不做赘述。
本领域技术人员还可以了解到本申请实施例列出的各种说明性逻辑块(illustrative logical block)和步骤(step)可以通过电子硬件、电脑软件,或两者的结合进行实现。为清楚展示硬件和软件的可替换性(interchangeability),上述的各种说明性部件(illustrative components)和步骤已经通用地描述了它们的功能。这样的功能是通过硬件还是软件来实现取决于特定的应用和整个系统的设计要求。本领域技术人员可以对于每种特定的应用,可以使用各种方法实现所述的功能,但这种实现不应被理解为超出本申请实施例保护的范围。
本申请实施例中所描述的各种说明性的逻辑块,模块和电路可以通过通用处理单元,数字信号处理单元,专用集成电路(ASIC),现场可编程门阵列(FPGA)或其它可编程逻辑装置,离散门或晶体管逻辑,离散硬件部件,或上述任何组合的设计来实现或操作所描述的功能。通用处理单元可以为微处理单元,可选地,该通用处理单元也可以为任何传统的处理单元、控制器、微控制器或状态机。处理单元也可以通过计算装置的组合来实现,例如数字信号处理单元和微处理单元,多个微处理单元,一个或多个微处理单元联合一个数字信号处理单元核,或任何其它类似的配置来实现。
本申请实施例中所描述的方法或算法的步骤可以直接嵌入硬件、处理单元执行的软件模块、或者这两者的结合。软件模块可以存储于RAM存储器、闪存、ROM存储器、EPROM存储器、EEPROM存储器、寄存器、硬盘、可移动磁盘、CD-ROM或本领域中其它任意形式的存储媒介中。示例性地,存储媒介可以与处理单元连接,以使得处理单元可以从存储媒介中读取信息,并可以向存储媒介存写信息。可选地,存储媒介还可以集成到处理单元中。处理单元和存储媒介可以配置于ASIC中,ASIC可以配置于用户终端中。可选地,处理单元和存储媒介也可以配置于用户终端中的不同的部件中。
在一个或多个示例性的设计中,本申请实施例所描述的上述功能可以在硬件、软件、固件或这三者的任意组合来实现。如果在软件中实现,这些功能可以存储与电脑可读的媒介上,或以一个或多个指令或代码形式传输于电脑可读的媒介上。电脑可读媒介包括电脑存储媒介和便于使得让电脑程序从一个地方转移到其它地方的通信媒介。存储媒介可以是任何通用或特殊电脑可以接入访问的可用媒体。例如,这样的电脑可读媒体可以包括但不限于RAM、ROM、EEPROM、CD-ROM或其它光盘存储、磁盘存储或其它磁性存储装置,或其它任何可以用于承载或存储以指令或数据结构和其它可被通用或特殊电脑、或通用或特殊处理单元读取形式的程序代码的媒介。此外,任何连接都可以被适当地定义为电脑可读媒介,例如,如果软件是从一个网站站点、服务器或其它远程资源通过一个同轴电缆、光纤电脑、双绞线、数字用户线(DSL)或以例如红外、无线和微波等无线方式传输的也 被包含在所定义的电脑可读媒介中。所述的碟片(disk)和磁盘(disc)包括压缩磁盘、镭射盘、光盘、DVD、软盘和蓝光光盘,磁盘通常以磁性复制数据,而碟片通常以激光进行光学复制数据。上述的组合也可以包含在电脑可读媒介中。
本申请的上述描述可以使得本领域技术任何可以利用或实现本申请的内容,任何基于所公开内容的修改都应该被认为是本领域显而易见的,本申请所描述的基本原则可以应用到其它变形中而不偏离本申请的发明本质和范围。因此,本申请所公开的内容不仅仅局限于所描述的实施例和设计,还可以扩展到与本申请原则和所公开的新特征一致的最大范围。

Claims (15)

  1. 一种补丁包生成方法,其特征在于,包括:
    当安卓操作系统源码中的应用程序框架层的代码发生更新时,服务器获取编译结果,所述编译结果包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的安卓安装包APK,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的APK;
    所述服务器从所述预装应用的APK中确定出目标应用的APK,所述目标应用是指应用的代码中仅校验值、时间戳、以及常量对应的寄存器其中一个或多个发生变化的应用;
    所述服务器将代码更新后所述预装应用中除了所述目标应用的应用的APK,以及代码更新前所述预装应用中除了所述目标应用的应用的APK进行差分,生成第一差分包。
  2. 如权利要求1所述的方法,其特征在于,所述编译结果还包括代码发生更新后所述应用程序框架层的系统文件和代码发生更新前所述应用程序框架层的系统文件;
    所述方法还包括:
    所述服务器将代码发生更新后所述应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件进行差分,生成第二差分包;
    所述服务器将所述第一差分包和所述第二差分包合成一个补丁包,并将所述补丁包发送至终端;
    或者,所述服务器将所述第一差分包和所述第二差分包分别发送至所述终端。
  3. 如权利要求1或2所述的方法,其特征在于,所述服务器从所述预装应用的APK中确定出目标应用的APK,包括:
    所述服务器从所述编译结果中获取代码更新后的第一应用的APK和代码更新前的所述第一应用的APK,所述第一应用为所述预装应用中的一个应用;
    所述服务器确定所述第一应用的代码更新前后的APK不同时,将所述代码更新后第一应用的APK中的系统文件反编译成第一源代码,以及将代码更新前所述第一应用的APK的系统文件反编译成第二源代码;
    所述服务器确定是否所述第一源代码和所述第二源代码中仅校验值、时间戳、以及常量对应的寄存器中的一个或多个不同;
    若是,则所述服务器确定所述第一应用为目标应用,以及确定所述第一应用的APK为目标应用的APK。
  4. 如权利要求3所述的方法,其特征在于,所述服务器确定是否所述第一源代码和所述第二源代码中仅校验值、时间戳、以及常量对应的寄存器中的一个或多个不同,包括:
    所述服务器比较所述第一源代码和所述第二源代码是否不同;
    若不同,则所述服务器将所述所述第一源代码转换成第一语义树和将所述第二源代码转换成第二语义树;
    若所述第一语义树转置后与所述第二语义树相同,则所述服务器确定所述第一源代码和所述第二源代码中仅常量对应的寄存器不同。
  5. 如权利要求3所述的方法,其特征在于,所述服务器确定是否所述第一源代码和所述第二源代码中仅校验值、时间戳、以及常量对应的寄存器中的一个或多个不同,包括:
    所述服务器比较所述第一源代码和所述第二源代码是否不同;
    若不同,则所述服务器确定所述所述第一源代码和所述第二源代码中的不同代码部分对应的字段是否是时间戳字段;
    若是,则所述服务器确定所述第一源代码和所述第二源代码中仅校验值不同。
  6. 如权利要求3所述的方法,其特征在于,所述服务器确定是否所述第一源代码和所述第二源代码中仅校验值、时间戳、以及常量对应的寄存器中的一个或多个不同,包括:
    所述服务器比较所述第一源代码和所述第二源代码是否不同;
    若不同,则所述服务器确定所述所述第一源代码和所述第二源代码中的不同代码部分对应的字段是否是校验值字段;
    若是,则所述服务器确定所述第一源代码和所述第二源代码中仅时间戳不同。
  7. 如权利要求1或2所述的方法,其特征在于,所述服务器从所述预装应用的APK中确定出目标应用的APK,包括:
    所述服务器从所述编译结果中获取代码更新后第二应用的APK和代码更新前所述第二应用的APK,所述第二应用为所述预装应用中的一个应用;
    所述服务器确定所述代码更新前后的APK不同时,所述服务器从安卓操作系统源码中获取代码更新后所述第二应用的第三源代码和所述代码更新前的所述第二应用的第四源代码;
    所述服务器比较发现所述第三源代码和所述第四源代码相同时,则确定所述第二应用为目标应用,以及确定所述第二应用的APK为目标应用的APK。
  8. 一种服务器,其特征在于,包括处理器和存储器;
    所述存储器用于存储一个或多个计算机程序,还存储有安卓操作系统源码编译生成的编译结果,其中,所述安卓操作系统源码包括应用程序框架层的代码,所述编译结果包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的APK,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的APK;
    当所述存储器存储的一个或多个计算机程序被所述处理器执行时,使得所述服务器执行:
    当所述安卓操作系统源码中的应用程序框架层的代码发生更新时,获取所述编译结果,从所述预装应用的APK中确定出目标应用的APK,所述目标应用是指应用的代码中仅校验值、时间戳、以及常量对应的寄存器其中一个或多个发生变化的应用;
    将所述预装应用中除了所述目标应用的应用的APK,以及代码更新前所述预装应用中除了所述目标应用的应用的APK进行差分,生成第一差分包。
  9. 如权利要求8所述的服务器,其特征在于,所述存储器存储的编译结果中还包括代码发生更新后所述应用程序框架层的系统文件和代码发生更新前所述应用程序框架层的系统文件;所述服务器还包括收发器;
    当所述存储器存储的一个或多个计算机程序被所述处理器执行时,还使得所述服务器执行:
    将代码发生更新后所述应用程序框架层的系统文件与代码发生更新前所述应用程序框架层的系统文件进行差分,生成第二差分包;
    将所述第一差分包和所述第二差分包合成一个补丁包;
    通过所述收发器将所述补丁包发送至终端,或者,通过所述收发器将所述第一差分包和所述第二差分包分别发送至所述终端。
  10. 如权利要求8或9所述的服务器,其特征在于,当所述存储器存储的一个或多个计算机程序被所述处理器执行时,还使得所述服务器执行:
    从所述编译结果中获取代码更新后的第一应用的APK和代码更新前的所述第一应用的APK,所述第一应用为所述预装应用中的一个应用;
    确定所述第一应用的代码更新前后的APK不同时,将所述代码更新后第一应用的APK中的系统文件反编译成第一源代码,以及将代码更新前所述第一应用的APK的系统文件反编译成第二源代码;
    确定是否所述第一源代码和所述第二源代码中仅校验值、时间戳、以及常量对应的寄存器中的一个或多个不同;
    若是,则确定所述第一应用为目标应用,以及确定所述第一应用的APK为目标应用的APK。
  11. 如权利要求10所述的服务器,其特征在于,当所述存储器存储的一个或多个计算机程序被所述处理器执行时,还使得所述服务器执行:
    比较所述第一源代码和所述第二源代码是否不同;
    若不同,则将所述所述第一源代码转换成第一语义树和将所述第二源代码转换成第二语义树;
    若所述第一语义树转置后与所述第二语义树相同,则确定所述第一源代码和所述第二源代码中仅常量对应的寄存器不同。
  12. 如权利要求10所述的服务器,其特征在于,当所述存储器存储的一个或多个计算机程序被所述处理器执行时,还使得所述服务器执行:
    比较所述第一源代码和所述第二源代码是否不同;
    若不同,则确定所述所述第一源代码和所述第二源代码中的不同代码部分对应的字段是否是时间戳字段;
    若是,则确定所述第一源代码和所述第二源代码中仅校验值不同。
  13. 如权利要求10所述的服务器,其特征在于,当所述存储器存储的一个或多个计算机程序被所述处理器执行时,还使得所述服务器执行:
    比较所述第一源代码和所述第二源代码是否不同;
    若不同,则确定所述所述第一源代码和所述第二源代码中的不同代码部分对应的字段是否是校验值字段;
    若是,则确定所述第一源代码和所述第二源代码中仅时间戳不同。
  14. 如权利要求8或9所述的服务器,其特征在于,所述存储器还存储有安卓操作系统源码,其中,所述安卓操作系统源码包括代码发生更新后所述安卓操作系统源码中的应用层中的预装应用的源代码,以及代码发生更新前所述安卓操作系统源码中的应用层中的预装应用的源代码;
    当所述存储器存储的一个或多个计算机程序被所述处理器执行时,还使得所述服务器执行:
    从所述编译结果中获取代码更新后第二应用的APK和代码更新前所述第二应用的APK,所述第二应用为所述预装应用中的一个应用;
    确定所述代码更新前后的APK不同时,从安卓操作系统源码中获取代码更新后所述第二应用的第三源代码和所述代码更新前的所述第二应用的第四源代码;
    比较发现所述第三源代码和所述第四源代码相同时,则确定所述第二应用为目标应用,以及确定所述第二应用的APK为目标应用的APK。
  15. 一种计算机存储介质,其特征在于,所述计算机可读存储介质包括计算机程序,当计算机程序在终端上运行时,使得所述终端执行如权利要求1至7任一所述的方法。
PCT/CN2018/096318 2018-07-19 2018-07-19 一种补丁包生成方法及设备 WO2020014926A1 (zh)

Priority Applications (3)

Application Number Priority Date Filing Date Title
US17/260,495 US11321080B2 (en) 2018-07-19 2018-07-19 Patch package generation method and device
CN201880072150.XA CN111316230B (zh) 2018-07-19 2018-07-19 一种补丁包生成方法及设备
PCT/CN2018/096318 WO2020014926A1 (zh) 2018-07-19 2018-07-19 一种补丁包生成方法及设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/096318 WO2020014926A1 (zh) 2018-07-19 2018-07-19 一种补丁包生成方法及设备

Publications (1)

Publication Number Publication Date
WO2020014926A1 true WO2020014926A1 (zh) 2020-01-23

Family

ID=69164186

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/096318 WO2020014926A1 (zh) 2018-07-19 2018-07-19 一种补丁包生成方法及设备

Country Status (3)

Country Link
US (1) US11321080B2 (zh)
CN (1) CN111316230B (zh)
WO (1) WO2020014926A1 (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112286564A (zh) * 2020-10-22 2021-01-29 上海艾拉比智能科技有限公司 一种针对iot设备二进制系统文件的差分升级算法
CN113434165A (zh) * 2021-06-02 2021-09-24 武汉天喻信息产业股份有限公司 一种嵌入式操作系统的补丁更新方法及系统

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113760300B (zh) * 2021-09-13 2023-10-27 武汉联影智融医疗科技有限公司 软件持续集成方法、装置、计算机设备和存储介质
CN116149716A (zh) * 2021-11-19 2023-05-23 华为终端有限公司 补丁方法及相关设备

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081535A (zh) * 2010-12-17 2011-06-01 东莞宇龙通信科技有限公司 基于Android的应用程序升级方法、系统及应用开发平台
CN102707977A (zh) * 2012-05-17 2012-10-03 江苏中科梦兰电子科技有限公司 一种基于Android应用软件的增量升级方法
CN107168733A (zh) * 2017-04-25 2017-09-15 北京五八信息技术有限公司 差分文件包的生成及应用程序的更新方法、装置和系统

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9075693B2 (en) * 2012-06-27 2015-07-07 Google Inc. Methods for updating applications
CN105404521B (zh) * 2014-05-30 2017-05-31 广州市动景计算机科技有限公司 一种增量升级方法及相关装置
US9448769B1 (en) * 2015-03-30 2016-09-20 International Business Machines Corporation Employing code overlays to facilitate software development
US9727324B2 (en) * 2015-05-22 2017-08-08 VMware. Inc. Application management in enterprise environments using cloud-based application recipes
KR102400477B1 (ko) * 2015-10-21 2022-05-23 삼성전자주식회사 어플리케이션을 관리하는 방법 및 그 장치
US10083024B2 (en) * 2015-12-01 2018-09-25 Salesforce.Com, Inc. Application aware virtual patching
CN105573785A (zh) 2015-12-11 2016-05-11 青岛海信电器股份有限公司 一种差分包的制作方法及装置
CN107346252B (zh) 2016-05-07 2021-05-25 腾讯科技(深圳)有限公司 应用更新方法和装置
US10360017B1 (en) * 2018-01-02 2019-07-23 Microsoft Technology Licensing, Llc Updating program packages at distribution endpoint
US10656922B2 (en) * 2018-05-25 2020-05-19 Paypal, Inc. Systems and methods for providing an application transformation tool

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102081535A (zh) * 2010-12-17 2011-06-01 东莞宇龙通信科技有限公司 基于Android的应用程序升级方法、系统及应用开发平台
CN102707977A (zh) * 2012-05-17 2012-10-03 江苏中科梦兰电子科技有限公司 一种基于Android应用软件的增量升级方法
CN107168733A (zh) * 2017-04-25 2017-09-15 北京五八信息技术有限公司 差分文件包的生成及应用程序的更新方法、装置和系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112286564A (zh) * 2020-10-22 2021-01-29 上海艾拉比智能科技有限公司 一种针对iot设备二进制系统文件的差分升级算法
CN113434165A (zh) * 2021-06-02 2021-09-24 武汉天喻信息产业股份有限公司 一种嵌入式操作系统的补丁更新方法及系统

Also Published As

Publication number Publication date
CN111316230B (zh) 2021-08-03
US11321080B2 (en) 2022-05-03
CN111316230A (zh) 2020-06-19
US20210311725A1 (en) 2021-10-07

Similar Documents

Publication Publication Date Title
US11709668B2 (en) Systems and methods for application program and application program update deployment to a mobile device
WO2021018005A1 (zh) 一种跨进程通信方法、装置及设备
US8989715B2 (en) Method and system for rendering content on a wireless device
US8103865B2 (en) Server method and system for rendering content on a wireless device
WO2020014926A1 (zh) 一种补丁包生成方法及设备
CN105302587B (zh) 数据更新方法及装置
CN107741844B (zh) 一种应用安装包的生成方法和装置
US20060248069A1 (en) Method and system for implementing customizable container services as component wireless applications
US9875109B2 (en) Method and apparatus for generating user adaptive application in mobile terminal
CN110865837B (zh) 一种进行系统升级的方法和终端
CN113727333A (zh) 定制应用的下载方法和系统
WO2021027772A1 (zh) 一种应用切换运行的方法及设备
WO2021057411A1 (zh) 一种组件加载方法、装置及系统
US20230216732A1 (en) Network Configuration Method and Device
US20230139886A1 (en) Device control method and device
CN112235132A (zh) 动态配置服务的方法、装置、介质以及服务器
KR101154717B1 (ko) 데이터 언어로 다수 언어들을 관리하기 위한 방법 및 장치
KR20170020366A (ko) 구독자 정의 동적 이벤팅 기법
CN114422637B (zh) 媒体请求处理方法和跨平台引擎系统
WO2023202406A1 (zh) 显示方法及电子设备
CN112764832A (zh) 一种应用程序安装、卸载方法及通信终端
CN117827228A (zh) 快应用部署方法及相关设备
CN115826994A (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: 18926728

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18926728

Country of ref document: EP

Kind code of ref document: A1