Application updating method, communication system, and electronic device

By performing differential file signature verification and transmitting signature information on the server side, the terminal device only performs server signature verification, which solves the problem of high resource consumption of terminal devices in the existing technology and improves the speed and efficiency of application updates.

WO2024217140A1PCT designated stage expired Publication Date: 2024-10-24HUAWEI TECH CO LTD

Patent Information

Application Number
PCT/CN2024/077803
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-20
Filing Date
2024-02-20
Publication Date
2024-10-24

AI Technical Summary

Technical Problem

Existing application update methods require a large number of compression and decompression operations on the terminal device, resulting in high resource consumption and slow update speed.

Method used

The signature verification of the differential file is performed on the server side, and the signature information is sent to the terminal device. The terminal device only performs server signature verification to avoid the compression and decompression process of the synthesized file.

Benefits of technology

It reduces the compression algorithm calculation process on the terminal device, saves resources, and improves the speed and efficiency of application updates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024077803_24102024_PF_FP_ABST
    Figure CN2024077803_24102024_PF_FP_ABST
Patent Text Reader

Abstract

Provided are an application updating method, a communication system, and an electronic device, which relate to the technical field of terminals. Server signature verification is performed on a differential file, which is generated by a server, such that compression and decompression processes in a developer signature verification process are reduced, thereby saving on more device resources. The method comprises: a server acquiring a first installation package corresponding to a target application in a version to be updated, and a second installation package corresponding to the target application in a historical version, obtaining a target differential file according to the first installation package and the second installation package, and verifying the target differential file; after the verification is successful, generating first signature information of the target differential file, and sending the first signature information and the target differential file to a terminal device; the terminal device receiving the target differential file and the first signature information of the target differential file, and performing signature verification on the target differential file; and after the signature verification is successful, on the basis of the target differential file and the second installation package, installing the target application program in a version to be updated.
Need to check novelty before this filing date? Find Prior Art

Description

Application program updating method, communication system, and electronic device

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on April 20, 2023, with application number 202310463950.7 and application name “Application Update Method, Communication System and Electronic Device”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of terminal technology, and in particular to an application updating method, a communication system, and an electronic device. Background Art

[0003] Currently, when an application (APP) needs to be updated, the app developer first uploads the new version of the APP's installation package (Android package, APK), such as APK1, and its signature information to a server. The server then performs a differential operation on the old version of APK2 and the new version of APK1, obtaining the differential file and performing signature verification on the differential file. If the signature verification is successful, the new version of the APP's installation package can be made available on the server.

[0004] In the aforementioned app update method, when a terminal device needs to update the application, it downloads the latest installation package (i.e., the differential file) from the server. The terminal device first compresses File 1 to obtain APK1, then verifies APK1's developer signature. Only after the signature verification is successful can it be decompressed and installed. This process requires the terminal device to perform a large amount of computing and consumes a relatively large amount of device resources.

[0005] Summary of the Invention

[0006] The embodiments of the present application provide an application update method, a communication system, and an electronic device, which can perform server signature verification on the differential file generated by the server without verifying the developer signature of the synthesized first installation package on the terminal device side, thereby reducing the compression and decompression processes during the developer signature verification process and saving more device resources.

[0007] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0008] In a first aspect, a method for updating an application is provided, which is applied to a communication system, the communication system comprising a server and at least one terminal device, wherein the server establishes a communication connection with the at least one terminal device, and a target application is installed on the terminal device. In the above method, the server obtains a first installation package corresponding to a target application version to be updated, and obtains a second installation package corresponding to a historical version of the target application. Thereafter, the server obtains a target differential file based on the first installation package and the second installation package, and verifies the target differential file. After successful verification, the server generates first signature information for the target differential file and sends the first signature information and the target differential file to the at least one terminal device.

[0009] The terminal device receives the target differential file and the first signature information of the target differential file, and uses the first signature information to verify the signature of the target differential file. After the signature verification is successful, the terminal device installs the target application to be updated based on the target differential file and the second installation package.

[0010] In the above method, since the server signs the target differential file before sending it down, the terminal device only needs to verify the server signature (or application market signature) of the target differential file without verifying the developer signature of the synthesized first installation package. That is, there is no need to compress the file synthesized by the terminal device to obtain the first installation package and then decompress it. In this way, the calculation process of using the compression algorithm on the terminal device is reduced, and more device resources are saved.

[0011] In one implementation of the first aspect, when obtaining the target differential file, the server may obtain a first file of the first type and a second file of the second type based on the first installation package, and obtain a third file of the first type and a fourth file of the second type based on the second installation package. Subsequently, the server obtains a first differential file of the first type based on the first and third files, and obtains a second differential file of the second type based on the second and fourth files, wherein the target differential file includes the first differential file and the second differential file.

[0012] In some possible application scenarios, the server may obtain the first differential file using a first differential operation, and obtain the second differential file using a second differential operation. For example, the first differential operation may employ an algorithm such as bsdiff or hdiff, and the second differential operation may employ an xdelta algorithm. Furthermore, the first type may include types such as so, xml, and dex, and the second type may include other types besides so, xml, and dex.

[0013] In this implementation, the server can perform different differential operations on different types of files corresponding to the installation packages, that is, perform a first differential operation on the first type of files in the old and new versions of the target application installation packages, and perform a second differential operation on the second type of files in the old and new versions of the target application installation packages. The first differential operation can obtain a differential file with a higher differential rate, and the differential file is also relatively small. The second differential operation can improve the efficiency of the differential operation and the efficiency of file synthesis on the terminal device. Therefore, the above-mentioned application update method can not only reduce the size of the differential file and increase the differential rate, but also improve the efficiency of the differential operation and the efficiency of file synthesis on the terminal device, taking into account both the requirements of device performance and differential rate.

[0014] In one implementation of the first aspect, the server may verify the target differential file by performing a first signature verification. During the first signature verification, the server generates a first composite file based on the first differential file and the third file in the target differential file, and generates a second composite file based on the second differential file and the fourth file in the target differential file. The server then compresses the first composite file and the second composite file to obtain a compressed file, signs the compressed file, and obtains second signature information for the compressed file. Finally, the server verifies the target differential file using the second signature information, and determines that verification of the target differential file is successful when the second signature information is consistent with the signature information of the first installation package.

[0015] In this implementation, the server can verify the target differential file using the first signature verification method to verify whether the target differential file is usable. If the verification is successful, it means that the target differential file obtained by the server is usable, that is, the server can obtain the corresponding first installation package based on the target differential file.

[0016] In one implementation of the first aspect, the server's verification of the target differential file may further include hash value verification. During the hash value verification, the server generates a first composite file based on the first and third differential files in the target differential file, and generates a second composite file based on the second and fourth differential files in the target differential file. The server then obtains the hash value of the first composite file and the hash value of the first file, as well as the hash value of the second composite file and the hash value of the second file, and verifies the target differential file using the hash values. Verification of the target differential file is determined to be successful when the hash value of the first composite file is consistent with the hash value of the first file, and the hash value of the second composite file is consistent with the hash value of the second file.

[0017] In this implementation, the server can verify the target differential file using a hash value check to verify whether the target differential file is available. If the check succeeds, it means that the target differential file obtained by the server is available, that is, the server can obtain the corresponding first installation package based on the target differential file.

[0018] In one implementation method of the first aspect, since the installation package represents an installation package, a compressed package, etc. after the application installation file is compressed, after obtaining the first installation package and the second installation package, the server decompresses the first installation package to obtain a first file set, and the first file set includes a first file of the first type and a second file of the second type, and the server decompresses the second installation package to obtain a second file set, and the second file set includes a third file of the first type and a fourth file of the second type.

[0019] In one implementation of the first aspect, in response to a user's update operation on a target application, a terminal device sends an update request to a server. The update request instructs the server to send a target differential file and first signature information to the terminal device. The terminal device then receives the target differential file and first signature information.

[0020] In this implementation, the terminal device can obtain the target differential file and first signature information for updating the target application from the server in response to the user's update operation. In another possible implementation, after the server generates the first signature information, the terminal device can also actively obtain the target differential file and first signature information from the server. Alternatively, after generating the first signature information, the server automatically sends the target differential file and the first signature information of the target differential file to the terminal device. Thereafter, the terminal device can perform signature verification and other operations on the target differential file in response to the user's update operation.

[0021] In one implementation method of the first aspect, in order to speed up file transmission, the target differential file sent by the server to the terminal device is a compressed file or compressed package, that is, the target differential file is a compressed package obtained by the server after compressing the first differential file and the second differential file.

[0022] In one implementation of the first aspect, when the terminal device performs signature verification on the target differential file, it may first sign the target differential file to obtain third signature information. The terminal device then uses the first signature information and the third signature information to perform signature verification on the target differential file, and determines that the signature verification is successful when the first signature information and the third signature information are consistent.

[0023] In this implementation, if the third signature information is identical to the first signature information, it indicates that the target differential file has not been tampered with or damaged during transmission, that the target differential file is available and secure, and that the signature verification of the target differential file is successful. Furthermore, the terminal device only needs to verify the third signature information and the first signature information of the target differential file, without having to verify the developer signature of the first installation package. This reduces the process of compressing the synthesized file into the first installation package and then decompressing it, and also reduces the computational process of the compression algorithm, saving more device resources and speeding up application updates.

[0024] In one implementation of the first aspect, when a terminal device installs the target application version to be updated, it first decompresses the target differential file to obtain a first differential file and a second differential file. The terminal device then generates a third composite file based on the first differential file and the third file, and generates a fourth composite file based on the second differential file and the fourth file. Finally, the terminal device installs the target application version to be updated based on the third composite file and the fourth composite file.

[0025] In this implementation, the third synthesized file generated by the terminal device is the same as the first file corresponding to the first installation package obtained by the server, and the fourth synthesized file is the same as the second file corresponding to the first installation package obtained by the server. After the third and fourth synthesized files are generated, the third and fourth synthesized files can be used to generate the first installation package, or the first file set corresponding to the first installation package, so that the terminal device installs the first installation package or the first file set to complete the installation of the target application to be updated.

[0026] In a second aspect, a method for updating an application is provided, which is applied to a server and establishes a communication connection with at least one terminal device, on which a target application is installed. In this method, the server obtains a first installation package corresponding to the target application version to be updated, and obtains a second installation package corresponding to a historical version of the target application. The server then obtains a target differential file based on the first and second installation packages, and verifies the target differential file. Finally, if the verification is successful, the server generates first signature information for the target differential file and sends the first signature information and the target differential file to the at least one terminal device.

[0027] In one implementation of the second aspect, when obtaining the target differential file, the server obtains a first file of the first type and a second file of the second type based on the first installation package, and obtains a third file of the first type and a fourth file of the second type based on the second installation package. The server then obtains a first differential file of the first type based on the first and third files, and obtains a second differential file of the second type based on the second and fourth files, wherein the target differential file includes the first differential file and the second differential file.

[0028] In one implementation of the second aspect, when verifying the target differential file, the server first generates a first composite file based on the first differential file and the third file in the target differential file, and then generates a second composite file based on the second differential file and the fourth file in the target differential file. The server then compresses the first and second composite files to obtain a compressed file, and signs the compressed file to obtain second signature information for the compressed file. Finally, the server verifies the target differential file using the second signature information, and determines that verification of the target differential file is successful when the second signature information matches the signature information of the first installation package.

[0029] In one implementation of the second aspect, when verifying the target differential file, the server first generates a first composite file based on the first and third files in the target differential file, and then generates a second composite file based on the second and fourth files in the target differential file. The server then obtains a hash value of the first composite file and a hash value of the first file, and obtains a hash value of the second composite file and a hash value of the second file. Finally, the server verifies the target differential file using the hash values, and determines that verification of the target differential file is successful when the hash value of the first composite file matches the hash value of the first file, and the hash value of the second composite file matches the hash value of the second file.

[0030] In one implementation of the second aspect, the server decompresses the first installation package to obtain a first file set, where the first file set includes a first file of a first type and a second file of a second type. Furthermore, the server decompresses the second installation package to obtain a second file set, where the second file set includes a third file of the first type and a fourth file of the second type.

[0031] In a third aspect, a method for updating an application is provided, which is applied to a terminal device, wherein the terminal device establishes a communication connection with a server, and a target application is installed on the terminal device. In this method, the terminal device receives a target differential file and first signature information of the target differential file, sent by the server. The target differential file is obtained by the server based on a first installation package corresponding to a target application version to be updated and a second installation package corresponding to a historical version of the target application; and the first signature information is generated by the server signing the target differential file after successfully verifying the target differential file. The terminal device then uses the first signature information to verify the signature of the target differential file. After successful signature verification, the terminal device installs the target application version to be updated based on the target differential file and the second installation package.

[0032] In one implementation of the third aspect, upon receiving the target differential file and the first signature information of the target differential file, the terminal device, in response to a user's update operation on the target application, sends an update request to the server, wherein the update request instructs the server to send the target differential file and the first signature information to the terminal device. Thereafter, the terminal device receives the target differential file and the first signature information.

[0033] In one implementation of the third aspect, when performing signature verification on the target differential file, the terminal device signs the target differential file to obtain third signature information. The terminal device then performs signature verification on the target differential file using the first signature information and the third signature information, and determines that the signature verification is successful when the first signature information and the third signature information are consistent.

[0034] In one implementation of the third aspect, when installing the target application version to be updated, the terminal device decompresses the target differential file to obtain a first differential file and a second differential file. The terminal device then generates a third composite file based on the first differential file and the third file, and generates a fourth composite file based on the second differential file and the fourth file. Finally, the terminal device installs the target application version to be updated based on the third composite file and the fourth composite file.

[0035] In a fourth aspect, a communication system is provided, including a server and at least one terminal device, wherein the server establishes a communication connection with the at least one terminal device, and a target application is installed on the terminal device.

[0036] The server is configured to obtain a first installation package corresponding to the target application version to be updated, and a second installation package corresponding to the historical version of the target application. The server is further configured to obtain a target differential file based on the first installation package and the second installation package. The server is further configured to verify the target differential file. Upon successful verification, the server is further configured to generate first signature information for the target differential file and transmit the first signature information and the target differential file to at least one terminal device.

[0037] The terminal device is configured to receive the target differential file and the first signature information of the target differential file. The terminal device is further configured to perform signature verification on the target differential file using the first signature information. After successful signature verification, the terminal device is further configured to install the target application to be updated based on the target differential file and the second installation package.

[0038] In a fifth aspect, an electronic device is provided, comprising a memory and one or more processors; the memory is coupled to the processor; wherein computer program code is stored in the memory, and the computer program code comprises computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the application update method as in the second aspect and any implementation thereof, or executes the application update method as in the third aspect and any implementation thereof.

[0039] In the sixth aspect, a computer-readable storage medium is provided, comprising computer instructions. When the computer instructions are executed on a chip, the chip executes an application update method as in the second aspect and any implementation thereof, or executes an application update method as in the third aspect and any implementation thereof.

[0040] In the seventh aspect, a computer program product is provided. When the computer program product runs on a computer, it enables the computer to execute the application update method as in the second aspect and any implementation thereof, or execute the application update method as in the third aspect and any implementation thereof.

[0041] It can be understood that the beneficial effects that can be achieved by the application update method described in the second aspect, the application update method described in the third aspect, the communication system described in the fourth aspect, the electronic device described in the fifth aspect, the computer-readable storage medium described in the sixth aspect, and the computer program product described in the seventh aspect can refer to the beneficial effects in the first aspect and any possible design method thereof, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] FIG1 is a schematic diagram of a commonly used APP upgrade method shown in an embodiment of the present application;

[0043] FIG2 is a schematic diagram of a communication system according to an embodiment of the present application;

[0044] FIG3 is a schematic diagram of the structure of a server according to an embodiment of the present application;

[0045] FIG4 is a schematic diagram of the structure of a terminal device according to an embodiment of the present application;

[0046] FIG5 is a flowchart of an APP update method according to an embodiment of the present application;

[0047] FIG6 is a schematic diagram of a file set shown in an embodiment of the present application;

[0048] FIG7 is a schematic diagram showing a comparison of differential file sizes according to an embodiment of the present application;

[0049] FIG8 is a second flow chart of an APP update method according to an embodiment of the present application;

[0050] FIG9 is a third flow chart of an APP update method according to an embodiment of the present application;

[0051] FIG10 is a fourth flow chart of an APP update method according to an embodiment of the present application;

[0052] FIG11 is a fifth flow chart of an APP update method according to an embodiment of the present application;

[0053] FIG12 is a schematic structural diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0054] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application. Among them, in the description of the present application, unless otherwise specified, " / " indicates that the objects associated before and after are in an "or" relationship, for example, A / B can represent A or B; "and / or" in the present application is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. In addition, in the description of the present application, unless otherwise specified, "multiple" refers to two or more than two. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple. In addition, in order to facilitate the clear description of the technical solutions of the embodiments of the present application, in the embodiments of the present application, words such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. Those skilled in the art will understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit differences. At the same time, in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way for easy understanding.

[0055] In addition, the business scenarios described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Ordinary technicians in this field can know that with the emergence of new business scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0056] When installing or updating an APP, the terminal device usually first obtains the installation package corresponding to the APP or the installation package corresponding to the new version of the APP from the server, and then decompresses and installs the installation package locally.

[0057] When an already installed APP1 on a terminal device needs to be updated, the installation process for the new installation package can be seen in Figure 1 (a). First, the developer of APP1 (e.g., "XX Music") uploads the new version of APK1 (e.g., huaweiyinyue.apk, version number 12.11.28.302) corresponding to APP1 and the signature information of APK1 to the server. The server then decompresses APK1 to obtain File 1. The server then performs a differential operation on File 2 and File 1, corresponding to the old version of APK2 (e.g., huaweiyinyue.apk, version number 12.11.28.301) corresponding to APP1, to obtain a differential file. The server then performs a first signature verification on the differential file. Specifically, the server uses the differential file and File 2 to synthesize a new file, compresses and signs the new file, and obtains the signature information of the compressed and signed file. If this signature information matches the signature information of APK1 uploaded by the developer, the first signature verification is successful and the differential file is valid.

[0058] In some possible application scenarios, when the first signature verification is successful, the server can send the differential file to the terminal device installed with APP1. As shown in (b) in Figure 1, after the terminal device receives the differential file, it can display the update option of the APP (such as "XX Music") on a display page such as the "Application Market", thereby prompting the user that a new version of "XX Music" is currently available. The user can choose whether to update or upgrade "XX Music" according to their needs. If the user chooses to update "XX Music", the update option of "XX Music" can be triggered by clicking, touching, and other operations.

[0059] If the user chooses to update "XX Music", the terminal device can use the received differential file and the file 2 corresponding to the current old version APK2 of APP1 to synthesize the file 1 corresponding to the new version APK1 of APP1. Afterwards, the terminal device compresses and signs the file 1 to obtain APK1 and the corresponding signature information, and performs a first signature verification on APK1 based on the signature information (or called: verification for the developer's signature). If the currently obtained signature information is consistent with the signature information uploaded by the developer, the first signature verification is successful, and the terminal device will decompress APK1 again to obtain file 1, and install file 1 to the specified directory, thereby completing the update of APP1. Among them, when the terminal device is installing file 1, the display page of the "Application Market" of the terminal device can prompt the user that "XX Music" is being updated, as shown in (b) of Figure 1; when the installation of file 1 is complete, the display page of the "Application Market" of the terminal device can also prompt the user to open "XX Music", as shown in (b) of Figure 1.

[0060] During the app upgrade process, the server performs differential operations and the server and terminal device combine files. A specific differential algorithm, such as the xdelta algorithm or the bsdiff or hdiff algorithm, must be used. It is understood that the server and terminal device will use the same algorithm for file combination as the server uses for differential operations.

[0061] Among them, xdelta is an open source differential update algorithm tool implemented based on the RFC3284 standard protocol. The algorithm generates differential files based on the VCDIFF format. The VCDIFF format is a data structure that is independent of the platform and CPU architecture. It is highly portable and uses a 128-base format, which can represent data more compactly and increase the compression rate. The advantage of the xdelta differential algorithm is that it improves the efficiency of differential operations and has low memory usage. However, File 1 and File 2 may include files in specific formats such as so, dex, and xml. The xdelta algorithm has a relatively poor differential effect on files in such formats, because a small modification of the source code may cause large differences in files in such formats, resulting in a large number of copy and insert operation instructions, making the size of the generated differential file much larger than expected, resulting in a low differential rate.

[0062] The bsdiff algorithm is optimized for specific file formats such as SO, DEX, and XML. It divides file content into a portion unaffected by the source code, a portion indirectly affected by code updates, and a portion directly affected by code updates. For the first two portions, the byte differences are either 0 or a fixed value, resulting in highly compressible data. The bsdiff algorithm compresses and stores the newly generated data in the third portion as an extra string. These optimizations enable the bsdiff algorithm to achieve a high difference rate when performing differences on these specific file formats. However, the bsdiff algorithm has high time and space complexity, which can lead to low efficiency in server differencing operations and file synthesis on both servers and end devices. This is because the bsdiff algorithm uses suffix sorting and binary search, resulting in a time complexity of O(nlogn) and a space complexity of O(n), where n represents the length of the old version of the file and m represents the size of the new version. The overall algorithm complexity is summarized as follows: when differencing, the time complexity is O((n+m)log n), and the space complexity is max(17*n,9*n+m)+O(1); when synthesizing, the time complexity is O(n+m), and the space complexity is n+m+O(1).

[0063] At present, when performing differential operations and file synthesis, only one of the above-mentioned differential algorithms is used on the server and terminal devices, making it difficult to ensure a high differential rate, as well as high differential operation efficiency and file synthesis efficiency, that is, it is difficult to take into account both the differential rate and device performance requirements.

[0064] Furthermore, the terminal device ultimately installs the decompressed file 1. However, since the developer signature of APK1 must be verified first, the terminal device needs to compress file 1 to obtain APK1, and then decompress and install it after the signature verification is successful. During this process, the compression algorithm used by the terminal device can be the deflate algorithm, and specific implementation tools include zlib, 7zip, advzip, zopfli, etc. However, the deflate algorithm includes two parts: lz77 encoding and Huffman encoding. The terminal device needs to perform a large number of LZ77 operations and Huffman encoding operations during compression, which consumes relatively more device resources, such as central processing unit (CPU) resources, memory resources, power resources, etc.

[0065] Based on the above content, an embodiment of the present application provides an application update method. In this method, the server obtains a first APK corresponding to the target APP of the version to be updated, and obtains a second APK corresponding to the historical version of the target APP. Afterwards, the server obtains a target differential file based on the first APK and the second APK. The server verifies the target differential file; after the verification is successful, the server generates a first signature information of the target differential file, and sends the target differential file and the first signature information to at least one terminal device. After the terminal device receives the target differential file and the first signature information, it uses the first signature information to verify the signature of the target differential file, and after the signature verification is successful, it installs the target APP of the version to be updated based on the target differential file and the second APK, thereby completing the update of the target APP.

[0066] In some possible application scenarios, the first APK mentioned above may represent the latest version of the APK corresponding to the target APP, and the second APK may represent the previous version of the APK corresponding to the target APP or the APK of the current version of the target APP installed on the terminal device.

[0067] In the above application update method, since the server signs the target differential file before sending it down, the terminal device only needs to verify the server signature of the target differential file, and there is no need to verify the developer signature of the synthesized first APK, that is, there is no need to compress the synthesized file into the first APK and then decompress it. In this way, the calculation process of using the compression algorithm on the terminal device is reduced, and more device resources are saved.

[0068] The above-mentioned application updating method of the embodiment of the present application can be applied to the communication system shown in Figure 2. The communication system includes at least one terminal device 100 and a server 200. Each terminal device 100 establishes a communication connection with the server 200 to achieve communication with the server 200.

[0069] In some possible application scenarios, when the terminal device 100 needs to install an APP, it can obtain the APK corresponding to the APP from the server 200 and use the APK to install the APP. Alternatively, when the terminal device 100 needs to update the APP, it can obtain the new version of the APK corresponding to the APP from the server 200 and use the new version of the APK to update the APP.

[0070] In other possible application scenarios, after the developer uploads a new version of the APK of the APP to the server 200, the server 200 can also actively send the new version of the APK to the terminal device 100 where the APP is installed. The terminal device 100 receives the APK and uses the APK to update the APP.

[0071] Compared to the old version (or historical version) of the APP, the new version of the APP will have changes in functions, attributes, etc. Therefore, the APK of the new version of the APP will also be different from the APK of the old version. After obtaining the APK of the new version of the APP, the server 200 will perform differential operations and verification based on the new version of the APK and the old version of the APK, and after the verification is successful, it will send the differential file obtained after the differential operation and the signature information of the server 200 on the differential file to the terminal device 100. After receiving the differential file and signature information, the terminal device 100 uses the signature information to verify the signature of the differential file. After the signature verification is successful, the new version of the APP is installed based on the differential file and the APK of the old version of the APP in the terminal device 100.

[0072] In some embodiments, when the terminal device 100 installs a new version of the APP, it can generate an installation file corresponding to the new version of the APK based on the differential file and the old version of the APK. The terminal device 100 then installs the installation file to the specified directory, thereby completing the update of the APP.

[0073] In some embodiments, after obtaining the APK of the new version of the app, the server 200 can first decompress the new version APK and the old version APK to obtain a first file set and a second file set, respectively. The first file set and the second file set each include multiple types of files. For example, the first file set includes a first file of a first type and a second file of a second type, and the second file set includes a third file of a first type and a fourth file of a second type. Then, the server 200 performs a differential operation based on the files in the first file set and the second file set to obtain a differential file.

[0074] In some possible application scenarios, the first type may include files in formats such as so, dex, and xml, while the second type of files may include files other than the first type.

[0075] When performing a differential operation, server 200 performs a first differential operation on the first file and the third file to obtain a first differential file of a first type, and performs a second differential operation on the second file and the fourth file to obtain a second differential file of a second type, thereby completing the differential operation. In some possible application scenarios, the first differential operation may represent a differential operation using an algorithm such as bsdiff or hdiff, and the second differential operation may represent a differential operation using an xdelta algorithm.

[0076] In some embodiments, when the server 200 verifies the target differential file, it may use the first differential file and the second differential file to verify the target differential file, where the target differential file includes the first differential file and the second differential file.

[0077] In some possible application scenarios, the verification method performed by the server 200 may include first signature verification or hash value verification, etc.

[0078] Among them, when performing the first signature verification, the server 200 can use the first differential file and the third file corresponding to the old version APK to generate a first synthetic file, and then use the second differential file and the fourth file corresponding to the old version APK to generate a second synthetic file. When synthesizing files, the server 200 can also use different differential algorithms for different types of files. Afterwards, the server 200 combines the first synthetic file and the second synthetic file for compression, signing, etc. The server 200 then compares the second signature information of the combined compressed file with the signature information of the new version APK uploaded by the developer. If the two are consistent, the first signature verification is successful.

[0079] When performing hash value verification, server 200 may determine the sha256 hash value of the first synthesized file, the sha256 hash value of the first file corresponding to the new version APK, the sha256 hash value of the second synthesized file, and the sha256 hash value of the second file corresponding to the new version APK. The hash value verification is successful when the sha256 hash value of the first synthesized file is the same as the sha256 hash value of the first file, and the sha256 hash value of the second synthesized file is the same as the sha256 hash value of the second file.

[0080] The successful verification of the target differential file indicates that the target differential file obtained by the server 200 is available, that is, the server 200 can obtain the corresponding new version APK based on the target differential file.

[0081] When the verification is successful, the server 200 generates first signature information of the target differential file and sends the first signature information and the target differential file to at least one terminal device 100 .

[0082] In some possible application scenarios, as shown in FIG3 , the server 200 may include a decompression module, a differential module, a synthesis module, a compression module, a verification module, a signature module, and the like. The decompression module is used to perform a decompression operation on the new version APK and the old version APK to obtain the first file set and the second file set mentioned above, respectively. The differential module is used to perform a first differential operation on the first file and the second file to obtain a first differential file, and to perform a second differential operation on the second file and the fourth file to obtain a second differential file. The synthesis module is used to generate a first synthetic file using the first differential file in the target differential file and the third file in the second file set, and then generate a second synthetic file using the second differential file in the target differential file and the fourth file in the second file set. The compression module is used to combine and compress the first synthetic file and the second synthetic file, and the verification module is used to verify whether the second signature information of the combined and compressed file is consistent with the signature information of the new version APK uploaded by the developer, thereby verifying the target differential file. The verification module is further configured to determine the sha256 hash value of the first composite file, the sha256 hash value of the first file, the sha256 hash value of the second composite file, and the sha256 hash value of the second file, and to verify whether the sha256 hash value of the first composite file is the same as the sha256 hash value of the first file, and whether the sha256 hash value of the second composite file is the same as the sha256 hash value of the second file, thereby verifying the target differential file. The signature module is configured to generate first signature information for the target differential file when the aforementioned verification is successful, and to send the first signature information and the target differential file to at least one terminal device.

[0083] It is understandable that the way the compression module signs the combined compressed file and the way the developer signs the new version of the APK can both use an asymmetric encryption algorithm, etc., and the embodiments of the present application do not make specific limitations on this.

[0084] In some possible application scenarios, the server 200 may also perform the above-mentioned verification and signing operations after obtaining the new version APK of the APP, and send a corresponding update notification message to the terminal device 100. After the terminal device 100 receives the update notification message, it can display the update option of the target APP on the display page of the APP, such as the "Application Market", thereby prompting the user that a new version of the APP is currently available. The user can choose whether to update or upgrade the APP according to their needs. If the user chooses to update the APP, the update option of the APP can be triggered by clicking, touching, etc., so that the terminal device 100 can respond to the user's update operation and send an update request to the server. After receiving the update request, the server 200 can send the corresponding target differential file and the first signature information of the target differential file to the terminal device 100.

[0085] In other possible application scenarios, after performing the above verification and signing, the server 200 may also automatically send the target differential file and the first signature information of the target differential file to the terminal device 100. Thereafter, the terminal device performs signature verification and other operations on the target differential file in response to the user's update operation.

[0086] After receiving the target differential file and the first signature information, the terminal device 100 uses the first signature information to perform signature verification on the target differential file. In some embodiments, the terminal device 100 can also perform signature verification on the target differential file by signing the received target differential file and then verifying whether the signed third signature information is consistent with the received first signature information. The signing method of the terminal device 100 and the signing method of the server 200 can also both use an asymmetric encryption algorithm, etc., which is not specifically limited in the embodiments of the present application.

[0087] If the signature verification of the target differential file is successful, it means that the target differential file has not been tampered with or invaded during the transmission from the server 200 to the terminal device 100, and the target differential file is safe and can be used.

[0088] In some embodiments, since the target differential file includes a first differential file and a second differential file, after the signature of the target differential file is successfully verified, the terminal device 100 can use the first differential file and the third file in the target differential file to generate a first composite file, and use the second differential file and the fourth file in the target differential file to generate a second composite file. The first composite file and the second composite file generate the first file set of the new version APK. When installing the app, the terminal device 100 can install the files in the first file set.

[0089] In some possible application scenarios, the terminal device 100 may also use different differential algorithms for different types of files to generate synthetic files, that is, perform a file synthesis operation.

[0090] In some possible application scenarios, as shown in FIG4 , the terminal device 100 may include a verification module, a synthesis module, and an installation module, etc. Among them, the verification module is used to receive the target differential file and the first signature information sent by the server 200, and perform signature verification on the target differential file based on the first signature information. The synthesis module is used to generate a first synthetic file using the first differential file and the third file in the target differential file, and to generate a second synthetic file using the second differential file and the fourth file in the target differential file. The installation module is used to install the installation file (i.e., the first file set) to a specified directory, wherein the installation file (i.e., the first file set) includes the first synthetic file and the second synthetic file.

[0091] It can be understood that in order to speed up file transfer, etc., the target differential file sent by the server 200 to the terminal device 100 is a compressed file of the above-mentioned first differential file and the second differential file. After the terminal device 100 receives and verifies it, it is necessary to decompress the compressed target differential file to obtain an uncompressed target differential file.

[0092] In some possible application scenarios, the terminal device 100 to which the above-mentioned application update method can be applied is a device that has already installed the corresponding APP, that is, the target APP to be updated has already been installed in the terminal device 100. In other possible application scenarios, the server 200 in the above-mentioned communication system can be a single device or a server cluster, which includes multiple servers 200. The data between the multiple servers 200 can be interconnected and shared. When a server 200 obtains a new version APK of the target APP, the terminal device 100 communicating with other servers 200 can also obtain the corresponding target differential file, thereby realizing the update and upgrade of the target APP on the terminal device 100.

[0093] In some possible application scenarios, the server 200 may also be used as an "application market" that can provide APKs of multiple APPs for at least one terminal device.

[0094] When the application update method provided in the embodiment of the present application is implemented in combination with the above-mentioned communication system, since the server signs the target differential file before sending the target differential file, the terminal device only needs to verify the server signature of the target differential file, and there is no need to verify the developer signature of the synthesized first APK, that is, there is no need to compress and then decompress the synthesized first file set. In this way, the calculation process of using the compression algorithm on the terminal device is reduced, and more device resources are saved.

[0095] In addition, the server can perform different differential operations on different types of files, that is, perform a first differential operation on the first type of files in the old and new versions of the target APP APK, and perform a second differential operation on the second type of files in the old and new versions of the target APP APK. The first differential operation can obtain a differential file with a higher differential rate, and the differential file is also relatively small. The second differential operation can improve the efficiency of the differential operation and the efficiency of file synthesis on the terminal device. It can be seen that the above-mentioned application update method can not only reduce the size of the differential file and increase the differential rate, but also improve the efficiency of the differential operation and the efficiency of file synthesis on the terminal device.

[0096] The above-mentioned terminal devices 100 include smartphones, smart TVs, smart watches, tablet computers, personal computers (PCs), laptops, car computers, car terminals, head-mounted display devices (such as virtual reality devices, augmented reality devices or mixed reality devices, etc.) that can install APPs.

[0097] The following describes the application updating method in the embodiment of the present application by taking the content shown in Figure 5 as an example. Referring to Figure 5 , the method includes S501-S506.

[0098] S501. The server obtains a first APK corresponding to a target APP of a to-be-updated version, and obtains a second APK corresponding to a historical version of the target APP.

[0099] In some possible application scenarios, the first APK obtained by the server may be the corresponding APK uploaded to the server by the developer of the target APP after completing the update of the target APP.

[0100] It is understandable that APK represents the installation package, compressed package, etc. after the APP installation file is compressed. In some embodiments, after obtaining the first APK, the server needs to decompress the first APK to obtain the installation file therein. Since the installation file can include at least one, the installation file after the first APK is decompressed can also be called the first file set. The first file set may include installation files of various formats, there may be multiple installation files of the same format, and installation files of a specific format may correspond to a file type. In some possible application scenarios, files in formats such as so, dex, xml, etc. can be determined as files belonging to the same file type (i.e., the first type), and other files except for formats such as so, dex, xml, etc. can be determined as files belonging to the same file type (i.e., the second type).

[0101] Considering that after an APP is launched or developed, the developer will upload the APP's APK to the server, there will also be a historical version, previous version, or old version of the APP's APK on the server. Therefore, in some embodiments, the server can also obtain the second APK corresponding to the historical version of the target APP, and decompress the second APK to obtain the installation file therein. Since the installation file can include at least one, the installation file after the second APK is decompressed can also be called a second file set. The second file set can also include installation files of various formats, and referring to the above embodiment, the installation files in the second file set can also be divided into multiple types.

[0102] S502: The server obtains a target differential file according to the first APK and the second APK.

[0103] In some embodiments, the server can obtain a first file of a first type and a second file of a second type based on the first APK, for example, by decompressing the first APK to obtain a first file set, and then obtaining the first file of the first type and the second file of the second type from the first file set. The server can also obtain a third file of the first type and a fourth file of the second type based on the second APK, for example, by decompressing the second APK to obtain a second file set, and then obtaining the third file of the first type and the fourth file of the second type from the second file set.

[0104] In other embodiments, the server may obtain a first differential file of a first type based on the first file and the third file, and obtain a second differential file of a second type based on the second file and the third file, wherein the target differential file includes the first differential file and the second differential file.

[0105] For example, as shown in (a) in Figure 6, the first file set includes files 601 in so format, files 602 in dex format, files 603 in xml format, etc., and also includes files 604 in other formats (such as other), etc. The first file in the first file set includes files 601, 602 and 603, etc., and the second file includes files 604 in other formats, etc.

[0106] Similarly, for example, as shown in (b) in Figure 6, the second file set includes files 611 in so format, files 612 in dex format, files 613 in xml format, etc., and also includes files 614 in other formats (such as other), etc. The third file in the second file set includes files 611, files 612 and files 613, etc., and the fourth file includes files 614 in other formats, etc.

[0107] It is understandable that the files 601, 602, 603, and 604 may also include at least one file of the corresponding format. For example, a file 601 may include at least one file in the so format, and a file 602 may include at least one file in the dex format. Similarly, the files 611, 612, 613, and 614 may also include at least one file of the corresponding format.

[0108] In some embodiments, when decompressing the first APK, the server may directly decompress the files in the so format, the dex format, and the xml format in the first APK into the aforementioned files 601, 602, and 603, respectively, and decompress files in other formats into the aforementioned file 604. Furthermore, in other embodiments, when decompressing the second APK, the server may also decompress the files in the so format, the dex format, and the xml format in the second APK into the aforementioned files 611, 612, and 613, respectively, and decompress files in other formats into the aforementioned file 614.

[0109] S503: The server verifies the target differential file.

[0110] In some embodiments, the server can obtain a first differential file based on the first file and the third file, for example, by performing a first differential operation on the first file and the third file to obtain the first differential file; and the server can also obtain a second differential file based on the second file and the fourth file, for example, by performing a second differential operation on the second file and the fourth file to obtain the second differential file. It is understood that the server performs corresponding differential operations on files of the same type, and different differential operations are performed on different types of files.

[0111] In some embodiments, the first differential operation mentioned above may represent a differential operation using algorithms such as bsdiff and hdiff, and the second differential operation may represent a differential operation using the xdelta algorithm. In addition, the first differential operation can ensure that the obtained differential file has a higher differential rate, ensure the differential effect, and the obtained differential file is smaller and highly compressible. For example, taking the differential operation of APKs of different APPs as an example, under the same conditions, when the bsdiff algorithm and the xdelta algorithm are used respectively, the sizes of the differential files generated by different types of files are shown in Figure 7. As can be seen from Figure 7, for any one of APP1, APP2, APP3, APP4 and APP5, the differential files of the first type of so format files, dex format files, xml format files, etc., obtained using the bsdiff algorithm are smaller than the differential files obtained using the xdelta algorithm.

[0112] The second differencing operation improves the efficiency of differencing and file synthesis. For example, as shown in Tables 1 and 2 below, for the same APK, the differencing time during the differencing phase and the synthesis time during the file synthesis phase when using the Xdelta algorithm are both shorter than when using the Bsdiff algorithm. This shows that the Xdelta algorithm is more efficient in differencing and file synthesis.

[0113] Table 1

[0114] Table 2

[0115] In some embodiments, since the first file and the third file may each include multiple files, when performing the first differential operation on the first file and the third file, the server may perform the first differential operation on files of the same format in the first file and the third file, respectively, and the obtained first differential file is of the first type. In this case, the obtained first differential file may also include at least one.

[0116] In other embodiments, since the second file and the fourth file can each include multiple files, the server can perform the second differential operation on the second and fourth files, or on files of the same format in the second and fourth files, respectively, to obtain a second differential file of the second type. Similarly, in this case, the obtained second differential file can also include at least one file.

[0117] For example, as shown in FIG8 , after decompressing the first and second file sets, the server obtains a first file from the first file set, including file 601, file 602, and file 603, and a second file from the second file set, including file 604. It also obtains a third file from the second file set, including file 611, file 612, and file 613, and a fourth file from the second file set, including file 614. The server then performs a first differential operation on file 601 and file 611 to obtain differential file 801; performs a first differential operation on file 602 and file 612 to obtain differential file 802; performs a first differential operation on file 603 and file 613 to obtain differential file 803; and performs a second differential operation on file 604 and file 614 to obtain differential file 804. It can be understood that the differential file 801 includes a differential file in so format, the differential file 802 includes a differential file in dex format, the differential file 803 includes a differential file in xml format, and the differential file 804 includes a differential file in other formats (such as other).

[0118] It is understandable that the first differential file in the embodiment of the present application may include differential file 801, differential file 802 and differential file 803 shown in FIG. 8 , and the second differential file may include differential file 804 shown in FIG. 8 .

[0119] In some embodiments, the server may verify the target differential file using the first differential file and the second differential file, and the server may verify the target differential file using methods including but not limited to first signature verification and hash value verification.

[0120] When performing the first signature verification, in some possible application scenarios, as shown in Figure 9, the server can generate a first composite file based on the first differential file and the third file, and then generate a second composite file based on the second differential file and the fourth file. Afterwards, the server performs a combined compression and signature operation on the first composite file and the second composite file. The server then compares the second signature information after the signature operation with the signature information of the first APK uploaded by the developer. If the two are consistent, the first signature verification is successful, and the target differential file passes the verification and is available. In some possible application scenarios, the process of the first signature verification can be the same as the first signature verification method shown in Figure 1.

[0121] Among them, the above-mentioned signing operation can correspond to the developer's signing operation on the first APK. In some possible application scenarios, the server and the developer side can use asymmetric encryption algorithms to perform signing operations separately. For example, the developer side can generate a key pair and use the private key in the key pair to encrypt the first APK or the developer signature information. Afterwards, the developer side sends the first APK, the public key in the key pair, and the developer signature information to the server. The server uses the public key in the key pair to encrypt the first APK, obtain the signature information, and compare the signature information with the developer signature information.

[0122] In some possible application scenarios, the server can obtain the developer's signature information for the first APK at the same time as obtaining the first APK.

[0123] When performing hash value verification, in some possible application scenarios, the server can determine the hash value of the file to be verified and compare whether the two hash values ​​are consistent. Exemplarily, the server can determine the sha256 hash value of the first composite file, the sha256 hash value of the first file, the sha256 hash value of the second composite file, and the sha256 hash value of the second file. When the sha256 hash value of the first composite file is the same as the sha256 hash value of the first file, and the sha256 hash value of the second composite file is the same as the sha256 hash value of the second file, the hash value verification is successful, and the target differential file has passed the verification and is usable.

[0124] In other possible application scenarios, since the first file, the second file, the third file, and the fourth file may each include multiple files, the server may also refer to the method shown in Figure 10 when performing hash value verification. In addition, the first synthetic file and the second synthetic file may each include at least one file. As shown in Figure 10, after obtaining differential file 801, differential file 802, differential file 803, and differential file 804, the server generates synthetic file 1001 using differential file 801 and file 611 in the second file set, generates synthetic file 1002 using differential file 802 and file 612 in the second file set, generates synthetic file 1003 using differential file 803 and file 613 in the second file set, and generates synthetic file 1004 using differential file 804 and file 614 in the second file set. It can be understood that the synthetic file 1001 includes a synthetic file in so format, the synthetic file 1002 includes a synthetic file in dex format, the synthetic file 1003 includes a synthetic file in xml format, and the synthetic file 1004 includes synthetic files in other formats (such as other).

[0125] Afterwards, the server determines the sha256 hash value of the synthetic file 1001 and the sha256 hash value of the file 601 in the first file set, and verifies whether the sha256 hash values ​​of the two are consistent; and determines the sha256 hash value of the synthetic file 1002 and the sha256 hash value of the file 602 in the first file set, and verifies whether the sha256 hash values ​​of the two are consistent; then determines the sha256 hash value of the synthetic file 1003 and the sha256 hash value of the file 603 in the first file set, and verifies whether the sha256 hash values ​​of the two are consistent; finally, determines the sha256 hash value of the synthetic file 1004 and the sha256 hash value of the file 604 in the first file set, and verifies whether the sha256 hash values ​​of the two are consistent.

[0126] If each of the above verification operations is successful, it means that the bytecode of the synthesized file is exactly the same as the bytecode of the file decompressed from the first APK, and the target differential file passes the availability check and is available.

[0127] It can be understood that, in FIG10 , the first composite file may include composite file 1001 , composite file 1002 , and composite file 1003 , and the second composite file may include composite file 1004 .

[0128] A successful verification indicates that the target differential file obtained by the server is usable, meaning that the server can obtain the corresponding first APK (i.e., the new version APK) based on the target differential file. In some possible application scenarios, if the verification fails, the server may regenerate the target differential file and verify it again until the target differential file is usable.

[0129] In some embodiments, when generating a composite file, the server may also use different differencing algorithms for different types of files. For example, when generating a first composite file using a first differential file and a third file, the server may use an algorithm corresponding to a first type or first differencing operation, such as bsdiff or hdiff. When generating a second composite file using a second differential file and a fourth file, the server may use an algorithm corresponding to a second type or second differencing operation, such as the xdelta algorithm.

[0130] S504. When the above verification is successful, the server generates first signature information of the target differential file and sends the first signature information and the target differential file to the terminal device.

[0131] It is understandable that in order to speed up file transfer, etc., the target differential file sent by the server to the terminal device is a compressed file or compressed package, that is, in some embodiments, the server can also compress the first differential file and the second differential file to obtain the target differential file.

[0132] In some embodiments, after generating the first signature information, the server may proactively send the target differential file and the first signature information to the terminal device. Alternatively, after generating the first signature information, the server may respond to an update request sent by the terminal device and send the target differential file and the first signature information to the terminal device.

[0133] In other embodiments, the server may send the first signature information to the terminal device at the same time as sending the target differential file. Alternatively, the server may send the first signature information to the terminal device periodically before or after sending the target differential file to the terminal device.

[0134] It can be understood that since the server can be regarded as an "application market" that provides APKs, the above-mentioned first signature information can be the signature information of the application market; in addition, the above-mentioned first signature information can also be the signature information of the third-party application to which the target APP belongs or the signature information of the target APP developer, etc. The embodiments of this application do not impose specific restrictions on this.

[0135] S505: The terminal device receives the target differential file and the first signature information of the target differential file sent by the server, and performs a second signature verification on the target differential file using the first signature information.

[0136] In some embodiments, the terminal device may perform the second signature verification by signing the target differential file and comparing the obtained third signature information with the first signature information. If the two are consistent, the second signature verification is successful. In some possible application scenarios, the signing operation of the target differential file by the terminal device corresponds to the signing operation of the server to generate the first signature information. For example, the signing operation used by the server may be an asymmetric encryption algorithm, and the signing operation used by the terminal device may also be the same asymmetric encryption algorithm.

[0137] Exemplarily, the server encrypts the target differential file using the private key in the key pair generated locally, thereby obtaining the first signature information. After receiving the target differential file and the first signature information, the terminal device encrypts the target differential file using the public key in the key pair generated by the server, obtaining the third signature information generated locally. If the third signature information is the same as the first signature information, it indicates that the target differential file has not been tampered with or damaged during transmission, that the target differential file is available and secure, and that the signature verification of the target differential file is successful.

[0138] If the third signature information is different from the first signature information, it can be considered that the target differential file has been tampered with or damaged during transmission. At this time, the target differential file signature verification fails and the target differential file is unusable. In this case, the terminal device can discard the received target differential file and notify the server to regenerate the target differential file.

[0139] Considering that the terminal device needs to use the public key generated by the server to perform signature verification on the target differential file, in some embodiments, when the server sends the target differential file and the first signature information to the terminal device, it can also send the server's public key to the terminal device to facilitate the terminal device's subsequent signature verification. Alternatively, in other embodiments, the server can also periodically or irregularly send the server's public key to the terminal device. This is not specifically limited in the embodiments of the present application.

[0140] S506: After the signature of the target differential file is successfully verified, the terminal device installs the target APP of the to-be-updated version based on the target differential file and the second APK.

[0141] In some embodiments, when installing the target APP to be updated, the terminal device can use the target differential file and the second APK to generate the first APK, that is, use the target differential file and the old version APK to generate a new version APK. The terminal device installs the new version APK, which can complete the installation of the target APP and the update of the target APP.

[0142] When the terminal device generates a new version APK, it can generate a third composite file based on the first differential file in the target differential file and the third file in the old version APK, and then generate a fourth composite file based on the second differential file in the target differential file and the fourth file in the old version APK. Afterwards, the third composite file and the fourth composite file are combined and compressed to obtain the new version APK. The installation module in the terminal device can perform the operation of installing the new version APK. During installation, the installation module decompresses the new version APK to obtain the third and fourth composite files, and installs the third and fourth composite files, thereby completing the installation of the target APP to be updated.

[0143] Alternatively, in other embodiments, after obtaining the third and fourth composite files, the terminal device may directly install the third and fourth composite files, thereby completing the installation of the target APP to be updated.

[0144] Considering that the target differential file may be a compressed package, in some embodiments, after the signature verification is successful, the terminal device may further decompress the received target differential file to obtain an uncompressed first differential file and a second differential file.

[0145] Since the first differential file and the second differential file may each further include at least one file, in some embodiments, when the terminal device generates the first file set using the target differential file and the second file set, the terminal device may generate a third composite file and a fourth composite file using files in the target differential file that correspond to the files in the second file set (e.g., files of the same type). The third composite file includes composite files of the first type, and the fourth composite file includes composite files of the second type.

[0146] For example, as shown in FIG11 , the target differential file includes differential file 801, differential file 802, differential file 803, and differential file 804. The terminal device decompresses the old version APK to obtain files 611, 612, 613, and 614 corresponding to the old version APK. The terminal device then generates a composite file 1101 using differential file 801 and file 611, generates a composite file 1102 using differential file 802 and file 612, generates a composite file 1103 using differential file 803 and file 613, and generates a composite file 1104 using differential file 804 and file 614. The third composite file includes composite file 1101, composite file 1102, and composite file 1103, and the fourth composite file includes composite file 1104. It can be understood that the synthetic file 1101 includes a synthetic file in so format, the synthetic file 1102 includes a synthetic file in dex format, the synthetic file 1103 includes a synthetic file in xml format, and the synthetic file 1104 includes synthetic files in other formats (such as other).

[0147] If the signature verification of the target differential file is successful, it means that the target differential file is available, and the terminal device can synthesize the new version APK based on the target differential file and the files of the old version APK. The synthesized new version APK here is the same as the new version APK obtained by the server. Based on this, it can be understood that the third synthesized file generated by the terminal device according to the above process is the same as the first file corresponding to the new version APK obtained by the server, and the fourth synthesized file is the same as the second file corresponding to the new version APK obtained by the server. Then, after the terminal device obtains the third and fourth synthesized files, it can use the third and fourth synthesized files to generate a new version of APK, or the first file set corresponding to the new version APK, thereby installing the new version APK or the first file set.

[0148] It is understandable that since the terminal device has already installed the target APP, the terminal device may save the APK of the old version of the target APP, or the terminal device may obtain the APK of the old version of the target APP from the server, and the old version may be the version currently installed on the terminal device.

[0149] In some embodiments, when generating a composite file, the terminal device may also use different differential algorithms for different types of files. For example, when generating a third composite file using the first differential file in the target differential file and the corresponding files in the second file set (e.g., files of the same type), the terminal device may use an algorithm corresponding to the first type or first differential operation, such as bsdiff, hdiff, etc., and when generating a fourth composite file using the second differential file in the target differential file and the corresponding files in the second file set (e.g., files of the same type), the terminal device may use an algorithm corresponding to the second type or second differential operation, such as the xdelta algorithm.

[0150] In some embodiments, when installing the target APP, the terminal device may install the files in the first file set to a designated directory of the terminal device, or to a directory where the old version APK file is installed, thereby completing the upgrade or update operation of the target APP. This embodiment of the application does not specifically limit this.

[0151] In some possible application scenarios, after receiving the target differential file, the terminal device can respond to the user's update operation on the target APP (for example, the user triggers the update option of the target APP in the application market through clicks, touches, etc.), perform signature verification on the target differential file, and after the signature verification is successful, generate the above-mentioned first file set and install the first file set.

[0152] In other possible application scenarios, after receiving the target differential file, the terminal device can automatically perform signature verification on the target differential file, and after the signature verification is successful, generate the above-mentioned first file set, and install the first file set in response to the user's update operation on the target APP, or automatically install the first file set after generating the first file set.

[0153] It can be seen from the above content that in the application update method provided in the embodiment of the present application, the server can perform different differential operations on different types of files corresponding to the APK, that is, perform a first differential operation on the first type of files in the old and new versions of the target APP APK, and perform a second differential operation on the second type of files in the old and new versions of the target APP APK. Among them, the first differential operation can obtain a differential file with a higher differential rate, and the differential file is also relatively small. The second differential operation can improve the efficiency of the differential operation and also improve the efficiency of file synthesis on the terminal device. It can be seen that the above-mentioned application update method can not only reduce the size of the differential file and increase the differential rate, but also improve the efficiency of the differential operation and the efficiency of file synthesis on the terminal device, taking into account the requirements of both device performance and differential rate.

[0154] Exemplarily, the bsdiff algorithm is used to perform differential analysis (an example of the first type) on files of types such as so, xml, dex, etc. (an example of the first type) in the new and old versions of the target APP APK to reduce the size of the differential file and improve the differential rate; the xdelta algorithm is used to perform differential analysis (an example of the second type) on files of other types (an example of the second type) in the new and old versions of the target APP APK to shorten the time of differential analysis and improve the differential efficiency.

[0155] In addition, since the server signs the target differential file before sending it down, the terminal device only needs to verify the server signature of the target differential file, without having to verify the developer signature of the synthesized first APK. That is, there is no need to compress the synthesized file into the first APK and then decompress it. In this way, the calculation process of using the compression algorithm on the terminal device is reduced, more device resources are saved, and the speed of application updates is accelerated.

[0156] It is understood that in the aforementioned embodiment, when the server verifies the differential file, it compresses the composite file generated based on the differential file and performs signature verification on the compressed file. The compression parameters used in this compression operation are consistent with the compression parameters used by the developer to compress the first APK. Therefore, the APK obtained by the server during this process is the same as the APK uploaded by the developer, ensuring APK consistency. Furthermore, in some possible application scenarios, the server can obtain the APK's compression parameters after decompressing the first APK.

[0157] Furthermore, since the terminal device does not need to compress and then decompress the synthesized first file set to verify the developer's signature, the terminal device does not need to obtain or search the developer's compression parameters for the APK. This can also reduce the processing complexity on the terminal device side, speed up the processing efficiency of the terminal device, and reduce the device power consumption of the terminal device, thereby ensuring the speed of application updates, reducing the time of application updates, and improving the user experience.

[0158] In some schemes, multiple embodiments of the present application can be combined, and the combined scheme can be implemented. Optionally, some operations in the process of each method embodiment are optionally combined, and / or the order of some operations is optionally changed. In addition, the execution order between the steps of each process is only exemplary and does not constitute a restriction on the execution order between the steps. There can also be other execution orders between the steps. It is not intended to indicate that the execution order is the only order in which these operations can be performed. Those of ordinary skill in the art will think of many ways to reorder the operations described in the embodiments of the present application. In addition, it should be noted that the process details involved in a certain embodiment of the present application are also applicable to other embodiments in a similar manner, or different embodiments can be used in combination.

[0159] Furthermore, some steps in the method embodiments may be equivalently replaced with other possible steps. Alternatively, some steps in the method embodiments may be optional and may be deleted in certain usage scenarios. Alternatively, other possible steps may be added to the method embodiments.

[0160] Furthermore, the various method embodiments may be implemented separately or in combination.

[0161] It is understandable that in order to implement the above functions, the aforementioned electronic devices such as servers and terminal devices include hardware and / or software modules that perform the corresponding functions. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of this application.

[0162] In this embodiment, electronic devices such as servers and terminal devices can be divided into functional modules based on the above-mentioned method examples. For example, each functional module can be divided according to each function, or two or more functions can be integrated into a single processing module. The above-mentioned integrated modules can be implemented in the form of hardware. It should be noted that the module division in this embodiment is illustrative and is only a logical functional division. In actual implementation, other division methods may be used.

[0163] An embodiment of the present application further provides an electronic device, as shown in FIG12 , which may include one or more processors 1201 , a memory 1202 , and a communication interface 1203 .

[0164] The memory 1202 and the communication interface 1203 are coupled to the processor 1201. For example, the memory 1202, the communication interface 1203 and the processor 1201 may be coupled together via a bus 1204.

[0165] The communication interface 1203 is used to transmit data with other devices. The memory 1202 stores computer program code. The computer program code includes computer instructions. When the computer instructions are executed by the processor 1201, the electronic device executes the application update method in the embodiment of the present application.

[0166] Among them, the processor 1201 can be a processor or a controller, for example, a central processing unit (CPU), a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute the various exemplary logic blocks, modules and circuits described in conjunction with the embodiments of the present application. The processor can also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0167] The bus 1204 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus 1204 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, FIG12 shows only one thick line, but this does not necessarily mean that there is only one bus or only one type of bus.

[0168] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program code is stored. When the processor executes the computer program code, the chip executes the relevant method steps in the method embodiment.

[0169] An embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the relevant method steps in the above method embodiment.

[0170] Among them, the electronic device, computer storage medium or computer program product provided in this application is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.

[0171] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0172] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0173] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0174] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0175] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the contributing part or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0176] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A method for updating an application program, It is characterized in that Applied to a communication system, the communication system includes a server and at least one terminal device, the server establishes a communication connection with at least one of the terminal devices, and a target application is installed on the terminal device; the method includes: The server obtains a first installation package corresponding to the target application of the to-be-updated version, and obtains a second installation package corresponding to the target application of the historical version; The server obtains a target differential file according to the first installation package and the second installation package; The server verifies the target differential file; After the verification is successful, the server generates first signature information of the target differential file, and sends the first signature information and the target differential file to at least one of the terminal devices; The terminal device receives the target differential file and the first signature information of the target differential file; The terminal device performs signature verification on the target differential file using the first signature information; After the signature verification succeeds, the terminal device installs the target application program of the to-be-updated version based on the target differential file and the second installation package.

2. The method according to claim 1, It is characterized in that The server obtains a target differential file according to the first installation package and the second installation package, including: The server obtains, according to the first installation package, a first file of a first type and a second file of a second type, and according to the second installation package, obtains, according to the second installation package, a third file of the first type and a fourth file of the second type; The server obtains a first differential file of a first type based on the first file and the third file, and obtains a second differential file of a second type based on the second file and the fourth file; the target differential file includes the first differential file and the second differential file.

3. The method according to claim 2, It is characterized in that The server verifies the target differential file, including: The server generates a first composite file based on the first differential file and the third file in the target differential file, and generates a second composite file based on the second differential file and the fourth file in the target differential file; The server combines and compresses the first synthetic file and the second synthetic file to obtain a compressed file; The server signs the compressed file to obtain second signature information of the compressed file; The server verifies the target differential file using the second signature information, and determines that the verification of the target differential file is successful when the second signature information is consistent with the signature information of the first installation package.

4. The method according to claim 2, It is characterized in that The server verifies the target differential file, including: The server generates a first composite file based on the first differential file and the third file in the target differential file, and generates a second composite file based on the second differential file and the fourth file in the target differential file; The server obtains a hash value of the first composite file and a hash value of the first file, and obtains a hash value of the second composite file and a hash value of the second file; The server verifies the target differential file using the hash value, and determines that the target differential file verification is successful when the hash value of the first synthetic file is consistent with the hash value of the first file, and the hash value of the second synthetic file is consistent with the hash value of the second file.

5. The method according to any one of claims 2 to 4, It is characterized in that The server obtains a first file of a first type and a second file of a second type according to the first installation package, including: the server decompresses the first installation package to obtain a first file set, where the first file set includes the first file of the first type and the second file of the second type; The server obtains a third file of the first type and a fourth file of the second type according to the second installation package, including: the server decompresses the second installation package to obtain a second file set, where the second file set includes the third file of the first type and the fourth file of the second type.

6. The method according to any one of claims 1 to 5, It is characterized in that The terminal device receives the target differential file and the first signature information of the target differential file, including: The terminal device sends an update request to the server in response to a user's update operation on the target application; The update request is used to instruct the server to send the target differential file and the first signature information to the terminal device; The terminal device receives the target differential file and the first signature information.

7. The method according to any one of claims 2 to 6, It is characterized in that The target differential file is a compressed package obtained after the server compresses the first differential file and the second differential file.

8. The method according to claim 7, It is characterized in that The terminal device performs signature verification on the target differential file using the first signature information, including: The terminal device signs the target differential file to obtain third signature information; The terminal device performs signature verification on the target differential file using the first signature information and the third signature information, and determines that the signature verification is successful when the first signature information is consistent with the third signature information.

9. The method according to claim 8, It is characterized in that The terminal device installs the target application of the to-be-updated version based on the target differential file and the second installation package, including: The terminal device decompresses the target differential file to obtain the first differential file and the second differential file; The terminal device generates a third composite file based on the first differential file and the third file, and generates a fourth composite file based on the second differential file and the fourth file; The terminal device installs the target application of the to-be-updated version based on the third synthesized file and the fourth synthesized file.

10. A method for updating an application program, It is characterized in that Applied to a terminal device, the terminal device establishes a communication connection with a server, and a target application is installed on the terminal device; the method comprises: receiving a target differential file and first signature information of the target differential file sent by the server; the target differential file is obtained by the server according to a first installation package corresponding to the target application of the to-be-updated version and a second installation package corresponding to the target application of the historical version; and the first signature information is generated by the server signing the target differential file after successfully verifying the target differential file; Using the first signature information to perform signature verification on the target differential file; After the signature verification succeeds, the target application program of the to-be-updated version is installed based on the target differential file and the second installation package.

11. The method according to claim 10, It is characterized in that The receiving the target differential file and the first signature information of the target differential file sent by the server includes: In response to a user's update operation on the target application, sending an update request to the server; the update request is used to instruct the server to send the target differential file and the first signature information to the terminal device; The target differential file and the first signature information are received.

12. The method according to claim 10 or 11, It is characterized in that The target differential file includes a first differential file of a first type and a second differential file of a second type; the target differential file is a compressed package obtained by the server after compressing the first differential file and the second differential file.

13. The method according to claim 12, It is characterized in that Using the first signature information to perform signature verification on the target differential file includes: Signing the target differential file to obtain third signature information; The target differential file is signature-verified using the first signature information and the third signature information, and when the first signature information is consistent with the third signature information, it is determined that the signature verification is successful.

14. The method according to claim 13, It is characterized in that Installing the target application program of the to-be-updated version based on the target differential file and the second installation package includes: Decompressing the target differential file to obtain the first differential file and the second differential file; generating a third composite file based on the first differential file and the third file, and generating a fourth composite file based on the second differential file and the fourth file; The target application of the to-be-updated version is installed based on the third synthesized file and the fourth synthesized file.

15. A communication system, It is characterized in that It includes a server and at least one terminal device, wherein the server establishes a communication connection with at least one of the terminal devices, and a target application is installed on the terminal device; The server is used to obtain a first installation package corresponding to the target application program of the version to be updated, and obtain a historical version a second installation package corresponding to the target application; The server is further configured to obtain a target differential file according to the first installation package and the second installation package; The server is further used to verify the target differential file; After the verification succeeds, the server is further configured to generate first signature information of the target differential file, and send the first signature information and the target differential file to at least one of the terminal devices; The terminal device is used to receive the target differential file and the first signature information of the target differential file; The terminal device is further used to perform signature verification on the target differential file using the first signature information; After the signature verification succeeds, the terminal device is further used to install the target application program of the to-be-updated version based on the target differential file and the second installation package.

16. An electronic device, It is characterized in that It includes a memory and one or more processors; the memory is coupled to the processor; wherein the memory stores computer program code, and the computer program code includes computer instructions, and when the computer instructions are executed by the processor, the electronic device executes the application update method as described in any one of claims 10-14.

17. A computer-readable storage medium, It is characterized in that It comprises computer instructions, and when the computer instructions are executed on a chip, the electronic device executes the application updating method as described in any one of claims 10 to 14.

Citation Information

Patent Citations

  • Incremental file generating method, and application program installing file updating method and device

    CN103713928A

  • Method of verifying integrity of application program installation package, mobile terminal and server

    CN107766747A

  • Application program update method and device, electronic apparatus, server, and storage medium

    CN109189459A

  • File differential upgrading method and system based on reverse differential logic

    CN114237681A

  • Differential upgrading method based on national cryptographic algorithm

    CN114968323A

Cited By

  • Installation package uploading method, installation package distribution method and installation package verification method

    CN119629159A