Generation method and installation method of upgrade package, equipment and storage medium

CN119731638APending Publication Date: 2025-03-28HONOR DEVICE CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202380060328.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-08-17
Filing Date
2023-04-17
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

In the existing upgrade package generation method, the upgrade package data obtained by differential processing of the old and new versions of the installation package is relatively large, resulting in long download time for the terminal device and high storage resource requirements, which cannot meet the version update needs of devices with small memory. .

Method used

Use slicing to process the installation packages of the old and new versions, and perform skip, XOR or differential processing based on the data similarity of the slice pairs to generate a smaller upgrade package that contains slice serial numbers and data processing type information to indicate data correlation and differences. sex.

Benefits of technology

It significantly reduces the data volume of the upgrade package, saves download time and storage resource requirements, and is suitable for version updates on terminal devices with limited memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119731638A_ABST
    Figure CN119731638A_ABST
Patent Text Reader

Abstract

The invention discloses an upgrade package generation method, an upgrade package installation method, equipment and a storage medium, and belongs to the technical field of communication. The method comprises the following steps: acquiring a first installation package and a second installation package of which the version is higher than that of the first installation package; the first installation package is sliced to obtain a first slice sequence, the second installation package is sliced to obtain a second slice sequence, and slices with the same sequence in the first slice sequence and the second slice sequence form a plurality of slice pairs; performing data processing on each slice pair according to the data similarity of each slice pair in the plurality of slice pairs to obtain upgrade package data corresponding to each slice pair, the data processing at least comprising skipping processing, XOR processing or differential processing; and generating an upgrade package according to the slice serial number of each slice pair and the data processing type and upgrade package data corresponding to each slice pair. Therefore, the upgrade package with relatively small data volume can be generated, the downloading time of the upgrade package is saved, and the requirement on storage resources of the terminal equipment is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Upgrade package generation method, installation method, device and storage medium

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on August 17, 2022, with application number 202210988967.X and application name “Upgrade package generation method, installation method, device and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of communication technology, and in particular to a method for generating, installing, device and storage medium for an upgrade package. Background Art

[0003] The systems or software of terminal devices such as mobile phones, tablets, and wearables can be upgraded after the vendor releases a new version. Current upgrade methods primarily employ a single-package upgrade strategy. Specifically, the terminal device initiates a software version check, and the server returns a download path to the terminal device. The terminal device then obtains an upgrade package based on the download path and then upgrades the version based on the package.

[0004] In related technologies, in order to save server storage resources and the time required for terminal devices to download upgrade packages, and to reduce development costs, upgrade packages are usually differential files between two adjacent versions. For example, when making an upgrade package for a system or software waiting to be upgraded, you can first obtain a first installation package and a second installation package for the object to be upgraded, where the version of the second installation package is higher than the version of the first installation package. Then, the first installation package and the second installation package are differentially processed to obtain a differential file, and the differential file is packaged into an upgrade package. After the terminal device obtains the upgrade package, it can perform a restore process based on the upgrade package and the stored first installation package to obtain the second installation package, and then implement the version upgrade by installing the second installation package.

[0005] However, the data volume of the upgrade package obtained by differentially processing the first installation package and the second installation package as a whole is still large, resulting in a long download time for the terminal device and requiring the storage resources of the terminal device to be large enough to meet the download and installation needs of the upgrade package.

[0006] Summary of the Invention

[0007] This application provides an upgrade package generation method, installation method, device, and storage medium that can significantly reduce the data size of the upgrade package, generate a relatively small upgrade package, save the download time of the upgrade package, and reduce the storage resource requirements of the terminal device. The technical solution is as follows:

[0008] In a first aspect, a method for generating an upgrade package is provided, which is applied to a first device, the method comprising:

[0009] Obtain the old version of the installation package and the new version of the installation package, slice the old and new versions of the installation package respectively, and obtain a first slice sequence corresponding to the old version of the installation package and a second slice sequence corresponding to the new version of the installation package. The slices in the second slice sequence that have the same order as those in the first slice sequence constitute a slice pair, and multiple slices in the second slice sequence and multiple slices in the first slice sequence constitute multiple slice pairs. Then, data processing is performed on each slice pair according to the data similarity of each slice pair in the multiple slice pairs to obtain the upgrade package data corresponding to each slice pair, and the data processing includes at least skip processing, XOR processing or differential processing. Afterwards, an upgrade package is generated according to the slice sequence number of each slice pair in the multiple slice pairs, and the data processing type and upgrade package data corresponding to each slice pair. The upgrade package includes upgrade package data corresponding to multiple slice sequence numbers and data processing type information corresponding to each slice sequence number.

[0010] Among them, skip processing means not processing the data of the corresponding slice pair, and the upgrade package data corresponding to the slice pair obtained by skip processing is empty. The upgrade package data corresponding to the data processing type of skip processing in the upgrade package is empty. XOR processing means outputting different results according to whether the data of the slice pair at different bits are the same, that is, the processing result of XOR processing is used to indicate whether the data of the slice pair at different bits are the same. For example, when the data of the slice pair is the same at a certain bit, the corresponding bit of the XOR processing result is the first value, and when the data of the slice pair is different at a certain bit, the XOR processing result is the second value at the corresponding bit. Differential processing refers to determining the data difference between the two slices in the slice pair, that is, the result of differential processing is used to reflect the data difference of each slice pair.

[0011] In an embodiment of the present application, when making an upgrade package, the installation packages of the new and old versions can be sliced ​​first, and then, based on the data similarity of each pair of slices corresponding to the new and old versions, each pair of slices can be subjected to differential processing, XOR processing, or skip processing. For example, skip processing is performed when the data is identical, XOR processing is performed when the data similarity is high, and differential processing is performed when the data similarity is low. Instead of performing differential processing on all pairs of slices corresponding to the new and old versions, differential processing is performed. By performing differential processing based on the data similarity of the slice pairs, the defects of performing differential processing on all pairs of slices can be overcome, the data volume of the upgrade package can be reduced to a large extent, and an upgrade package with a relatively small data volume can be generated, further saving the download time of the upgrade package and reducing the requirements for the storage resources of the terminal device.

[0012] As an example, the multiple slice pairs include a first slice pair, which is composed of a first slice in a first slice sequence and a second slice in a second slice sequence. The operations of processing data for each slice pair based on data similarity of each slice pair in the multiple slice pairs to obtain upgrade package data corresponding to each slice pair may include the following:

[0013] Case 1: If the data of the first slice and the second slice are the same, the first slice pair is skipped and the upgrade package data corresponding to the first slice pair is empty.

[0014] In the embodiment of the present application, for a slice pair with the same data, this slice pair may not be processed, and the old version of the slice may be directly used for data installation later.

[0015] The second case: If the data of the first slice and the second slice are different and the data similarity is greater than or equal to the first threshold, that is, the data are highly similar, then the first slice pair is XORed to obtain the first data, and the upgrade package data corresponding to the first slice pair is determined based on the first data.

[0016] In an embodiment of the present application, for a slice pair with highly similar data, an XOR process may be performed on the slice pair, and the XOR process result indicates which parts of the data in the slice pair are the same and which parts of the data are different.

[0017] As an example, performing an XOR process on the first slice pair to obtain the first data includes: performing an XOR process on data at corresponding byte positions in the first slice and the second slice to obtain the first data.

[0018] If the data at the corresponding byte position of the first slice and the second slice are the same, the data at the corresponding byte position of the first data is a first value; if the data at the corresponding byte position of the first slice and the second slice are different, the data at the corresponding byte position of the first data is a second value. That is, if the data at the same byte position of the first slice and the second slice are the same, the first value is output at the same byte position of the first data; if the data at the same byte position of the first slice and the second slice are different, the second value is output at the same byte position of the first data.

[0019] As an example, if the data of the first slice pair is not binary data, the data of the first slice pair can be converted into binary data first, and then the first slice pair converted into binary data is subjected to XOR processing. For example, the operation of performing XOR processing on the data at corresponding byte positions in the first slice and the second slice includes the following two cases:

[0020] If both the data of the first slice and the data of the second slice are binary data, an exclusive-OR operation is performed on the binary values ​​at corresponding byte positions in the first slice and the second slice to obtain first data. If the values ​​at corresponding byte positions in the first slice and the second slice are the same, the value at the corresponding byte position in the first data is 0; if the values ​​at corresponding byte positions in the first slice and the second slice are different, the value at the corresponding byte position in the first data is 1.

[0021] If the data of at least one of the first and second slices is not binary data, the data of the slice that is not binary data in the first and second slices is converted into binary data, and the binary values ​​at corresponding byte positions in the first and second slices after conversion into binary data are XORed to obtain first data. If the values ​​at corresponding byte positions in the first and second slices after conversion into binary data are the same, the value at the corresponding byte position in the first data is 0; if the values ​​at corresponding byte positions in the first and second slices after conversion into binary data are different, the value at the corresponding byte position in the first data is 1.

[0022] As an example, determining the upgrade package data corresponding to the first slice pair based on the first data may include: determining the first data as the upgrade package data corresponding to the first slice pair. Alternatively, compressing the first data to obtain third data, and determining the third data as the upgrade package data corresponding to the first slice.

[0023] The third case: if the data similarity between the first slice and the second slice is less than the first threshold, that is, the data difference is large, the first slice pair is differentially processed to obtain second data, and the upgrade package data corresponding to the first slice pair is determined based on the second data.

[0024] The second data is a differential processing result, that is, a differential file of the first slice pair.

[0025] In the embodiment of the present application, if the data difference between the first slice and the second slice is large, differential processing can be performed on the first slice pair, so that the data difference of the first slice pair is represented by the differential processing result.

[0026] As an example, determining the upgrade package data corresponding to the first slice pair based on the second data may include: determining the second data as the upgrade package data corresponding to the first slice pair. Alternatively, compressing the second data to obtain fourth data; and determining the fourth data as the upgrade package data corresponding to the first slice pair.

[0027] As an example, when generating an upgrade package based on the slice sequence number of each slice pair in a plurality of slice pairs, and the data processing type and upgrade package data corresponding to each slice pair, the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the plurality of slice sequence numbers can be written into the data information of the initial data packet, and the data processing type corresponding to the slice pair indicated by each slice sequence number, and the storage location information of the corresponding upgrade package data in the data information of the initial data packet can be written into the header information of the initial data packet. The initial data packet after the data is written is an upgrade package, and the plurality of slice sequence numbers are the slice sequence numbers of the plurality of slice pairs.

[0028] The storage location information of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet is used to indicate the storage location of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet. For example, the storage location information of the upgrade package data corresponding to each slice pair in the data information of the initial data packet may be an incremental offset of the upgrade package data corresponding to each slice pair in the data information of the initial data packet.

[0029] In this way, the header information of the generated upgrade package stores: the data processing type corresponding to each slice number in the multiple slice numbers, and the storage location information of the upgrade package data corresponding to each slice number in the data information of the upgrade package. The data information of the upgrade package stores the upgrade package data corresponding to each slice number.

[0030] The storage location information of the upgrade package data corresponding to the slice sequence number whose data processing type is skipped is empty, that is, there is no corresponding upgrade package data for the slice sequence number whose data processing type is skipped, and there is no storage location information of the corresponding upgrade package data in the upgrade package. The storage location information of the upgrade package data corresponding to each slice sequence number in the data information of the upgrade package can be an incremental offset of the upgrade package data corresponding to each slice sequence number in the data information of the upgrade package, etc.

[0031] The upgrade package generated in this way can indicate the relationship between the old and new versions of the installation package. Specifically, it can indicate which slice pairs in the corresponding slice sequence have the same data, which slice pairs have highly similar data, and which slice pairs have significantly different data. It can also indicate which data is the same and which data is different in pairs of highly similar slices, as well as the difference files for pairs of slices with significantly different data. In this way, after the device to be upgraded obtains the upgrade package, it can also restore the new version of the installation package based on the upgrade package and the stored old version of the installation package.

[0032] Furthermore, multiple slice numbers can be written into the header of the initial data packet. For example, multiple slice numbers, along with the data processing type corresponding to each slice number and the storage location of the corresponding upgrade package data within the upgrade package data information, can be written into the header of the initial data packet. In this way, the corresponding data processing type and upgrade package data can be indicated by the slice number.

[0033] In addition, the slice size can be written into the header information of the initial data packet, so that the header information of the generated upgrade package also includes the slice size. Furthermore, the number of slices can be written into the header information of the initial data packet, so that the header information of the generated upgrade package also includes the number of slices.

[0034] By writing the slice size and / or number of slices in the header information, it is convenient for the terminal device that receives the upgrade package to perform a restore installation. The old version of the installation package stored on the terminal device is sliced ​​according to the slice size and / or number of slices in the header information to obtain a slice sequence corresponding to the multiple slice numbers in the upgrade package.

[0035] The slice size is the size of the slices in the first slice sequence and the second slice sequence. The number of slices is the number of identically ordered slice pairs in the first slice sequence and the second slice sequence. For example, the slice size of each slice in the first slice sequence and the second slice sequence is a preset size, and the slice size written into the header information is the preset size. The number of slices in the first slice sequence and the number of slices in the second slice sequence are the same, both being preset numbers, and the number of slices written into the header information is the preset number.

[0036] By presetting the slice size and number of slices, when creating an upgrade package, the old and new versions of the installation package can be sliced ​​according to the preset slice size and the preset slice number, ensuring that the slice size and the slice number of the slice sequence of the new and old versions are aligned, which facilitates subsequent processing based on each slice pair in the aligned slice sequence of the old and new versions to generate the upgrade package. In addition, by writing the preset slice size and the preset slice number in the header information, when the terminal device that receives the upgrade package performs a restore installation, the old version of the installation package stored on the terminal device is also sliced ​​according to the preset slice size and the preset slice number in the header information, obtaining a slice sequence corresponding to the multiple slice sequence numbers in the upgrade package, which facilitates the subsequent restoration of the new version of the installation package based on the upgrade package data and slice data with the same sequence number.

[0037] In a second aspect, a device for generating an upgrade package is provided. The device is configured to implement the method for generating an upgrade package described in the first aspect. The device includes at least one module configured to implement the method for generating an upgrade package described in the first aspect.

[0038] In a third aspect, a device for generating an upgrade package is provided. The structure of the device for generating the upgrade package includes a processor and a memory. The memory is used to store a program that supports the device for generating the upgrade package to execute the upgrade package generation method provided in the first aspect, and to store data related to implementing the upgrade package generation method described in the first aspect. The processor is configured to execute the program stored in the memory. The device for generating the upgrade package may also include a communication bus, which is used to establish a connection between the processor and the memory.

[0039] In a fourth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on the computer, the computer executes the upgrade package generation method described in the first aspect.

[0040] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the upgrade package generation method described in the first aspect.

[0041] In a sixth aspect, a method for installing an upgrade package is provided, which is applied to a second device, the method comprising:

[0042] Obtain an upgrade package, which includes upgrade package data corresponding to multiple slice numbers and data processing type information corresponding to each slice number. Based on the data processing type corresponding to each slice number in the multiple slice numbers, restore the slice corresponding to each slice number to obtain installation package data corresponding to each slice number. Then, generate a new version of the installation package based on the installation package data corresponding to the multiple slice numbers, and install the new version of the installation package.

[0043] The data processing type includes at least skip processing, XOR processing, or differential processing. The upgrade package data corresponding to the skip processing type is empty. Different data processing types have different restoration processing methods. Specifically, according to different data processing types and the data processing type corresponding to each slice number in the multiple slice numbers, the restoration processing of the slice corresponding to each slice number includes the following situations:

[0044] The first case: when the data processing type corresponding to each slice serial number is skip processing, the slice corresponding to each slice serial number in the first slice sequence is copied to obtain the installation package data corresponding to each slice serial number.

[0045] The first slicing sequence is obtained by slicing the old version of the installation package stored on the second device.

[0046] That is, if the data of the slice pair indicated by the first slice sequence number is the same, the slice data at the corresponding position in the first slice sequence can be directly used as the slice data at the corresponding position in the new version of the installation package.

[0047] The second case: when the data processing type corresponding to each slice serial number is XOR processing, the upgrade package data corresponding to each slice serial number and the slice corresponding to each slice serial number in the first slice sequence are XOR processed to obtain the installation package data corresponding to each slice serial number.

[0048] The third case: when the data processing type corresponding to each slice serial number is differential processing, the upgrade package data corresponding to each slice serial number and the slice corresponding to each slice serial number in the first slice sequence are reverse differentially processed to obtain the installation package data corresponding to each slice serial number.

[0049] The reverse differential processing is the reverse operation of the differential processing, which is used to restore the original file based on the differential file.

[0050] In an embodiment of the present application, when installing an upgrade package, the slice data with the same slice sequence number in the old version of the installation package can be restored based on the data processing type corresponding to each slice sequence number in the upgrade package to restore the new version of the installation package, and then the new version of the installation package can be installed. Since the upgrade package has a small data volume, the storage resources required for restoring and installing the upgrade package are also small. This reduces the storage resource requirements of the terminal device and is suitable for version updates on terminal devices with smaller memory.

[0051] Furthermore, different forms of restoration processing can be performed on the slices corresponding to the respective slice numbers, depending on the data processing type corresponding to each slice number. For example, copy processing can be performed when the data processing type is skip processing, XOR processing can be performed when the data processing type is XOR processing, and reverse differential processing can be performed when the data processing type is differential processing. In this way, a new version of the installation package can be accurately restored from an upgrade package with a relatively small data volume, thus proposing a restoration and installation method suitable for upgrade packages generated according to the upgrade package generation method described in the first aspect above.

[0052] As an example, the header information of the upgrade package includes a slice size, and the old version of the installation package can be sliced ​​according to the slice size to obtain the first slice sequence. In this way, the size of each slice in the first slice sequence can be the slice size.

[0053] As another example, if the header information of the upgrade package includes a slice size and a slice count, the old version of the installation package can be sliced ​​according to the slice size and slice count to obtain a first slice sequence. In this way, the size of each slice in the first slice sequence can be the slice size, and the number of slices included in the first slice sequence can be the slice count.

[0054] As an example, if the header information of the upgrade package stores the data processing class type corresponding to each slice number in a plurality of slice numbers and the storage location information of the corresponding upgrade package data in the data information of the upgrade package, and the data information of the upgrade package stores the upgrade package data corresponding to each slice number in a plurality of slice numbers, then before generating the installation package data corresponding to each slice number, the data processing type corresponding to each slice number and the storage location information of the corresponding upgrade package data in the data information of the upgrade package can be obtained from the header information of the upgrade package. Based on the storage location information of the upgrade package data corresponding to each slice number in the data information of the upgrade package, the upgrade package data corresponding to each slice number can be obtained from the data information of the upgrade package. Then, based on the data processing type corresponding to each slice number, the slice corresponding to each slice number can be restored.

[0055] As an example, the installation package data corresponding to multiple slice numbers may be concatenated to obtain a second installation package.

[0056] In a seventh aspect, an apparatus for installing an upgrade package is provided, wherein the apparatus for installing the upgrade package has the function of implementing the method for installing the upgrade package described in the first aspect. The apparatus for installing the upgrade package includes at least one module, wherein the at least one module is configured to implement the method for installing the upgrade package described in the first aspect.

[0057] In an eighth aspect, an apparatus for installing an upgrade package is provided. The apparatus for installing the upgrade package includes a processor and a memory, wherein the memory is used to store a program that supports the apparatus for installing the upgrade package in executing the method for installing the upgrade package provided in the first aspect, and to store data involved in implementing the method for installing the upgrade package described in the first aspect. The processor is configured to execute the program stored in the memory. The apparatus for installing the upgrade package may further include a communication bus for establishing a connection between the processor and the memory.

[0058] In a ninth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium. When the computer-readable storage medium is run on a computer, the computer executes the method for installing the upgrade package described in the first aspect.

[0059] In a tenth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the method for installing the upgrade package described in the first aspect.

[0060] The upgrade package generation method provided in the embodiment of the present application has the following beneficial effects:

[0061] In an embodiment of the present application, the installation packages of the new and old versions can be sliced ​​first, and then, based on the data similarity of each pair of slices corresponding to the new and old versions, each pair of slices can be subjected to differential processing, XOR processing, or skip processing. For example, skip processing is performed when the data is the same, XOR processing is performed when the data similarity is high, and differential processing is performed when the data similarity is low, to obtain the upgrade package data corresponding to each pair of slices. Instead of performing differential processing on all pairs of slices corresponding to the new and old versions. Then, an upgrade package is generated based on the data processing type and upgrade package data corresponding to each pair of slices. In the process of generating the upgrade package, by performing differential processing based on the data similarity of the slice pairs, the defects of performing differential processing on all pairs of slices can be overcome, the data volume of the upgrade package can be reduced to a large extent, and an upgrade package with a relatively small data volume can be generated, further saving the download time of the upgrade package and reducing the requirements for the storage resources of the terminal device. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] FIG1 is a schematic diagram of a system for performing version update of a device provided in an embodiment of the present application;

[0063] FIG2 is a logic diagram of a process for generating and installing an upgrade package provided by the related art;

[0064] FIG3 is a schematic diagram of a system for performing version update on another device provided in an embodiment of the present application;

[0065] FIG4 is a logical diagram of a process for generating and installing an upgrade package provided in an embodiment of the present application;

[0066] FIG5 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application;

[0067] FIG6 is a schematic structural diagram of a terminal device provided in an embodiment of the present application;

[0068] 7 is a flowchart of a method for generating and installing an upgrade package provided in an embodiment of the present application;

[0069] FIG8 is a schematic diagram of a process for performing version update on a device provided in an embodiment of the present application;

[0070] FIG9 is a logical diagram of a process for generating and installing an upgrade package provided in an embodiment of the present application;

[0071] FIG10 is a schematic structural diagram of an upgrade package generation device provided in an embodiment of the present application;

[0072] FIG11 is a schematic structural diagram of an installation device for an upgrade package provided in an embodiment of the present application. DETAILED DESCRIPTION

[0073] In order to make the objectives, technical solutions and advantages of this application clearer, the implementation methods of this application will be further described in detail below with reference to the accompanying drawings.

[0074] It should be understood that the “multiple” mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, “ / ” means or, for example, A / B can mean A or B; “and / or” in this article is merely a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, words such as “first” and “second” are used to distinguish between identical or similar items with basically the same functions and effects. Those skilled in the art can 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 them to be different.

[0075] Before describing in detail the method for generating and installing an upgrade package provided in the embodiment of the present application, the application scenarios and implementation environment involved in the embodiment of the present application are first described.

[0076] Mobile phones, tablets, wearable devices, and other terminal devices need to update their systems or software based on the upgrade packages released by the vendor. For example, terminal devices can use over-the-air (OTA) upgrade technology to achieve version updates. OTA technology is a technology for downloading data via a wireless network. OTA upgrade technology is a technology that uses the wireless network interface of the terminal device to remotely update the version of the terminal device's system or software. It should be understood that terminal devices can also use other technologies to achieve version updates.

[0077] Please refer to Figure 1, which is a schematic diagram of a system for performing version updates on a device according to an embodiment of the present application. As shown in Figure 1, the system includes a first device 11, a second device 12, a third device 13, and a fourth device 14. The first device 11, the second device 12, the third device 13, and the fourth device 14 can communicate with each other via a wired or wireless network.

[0078] The first device 11 is used to create and upload the upgrade package, and may be a terminal device or server, for example. The second device 12 is used to store and distribute the upgrade package, such as a cloud server. The third device 13 is used to download the upgrade package, and may be a terminal device or server, for example. After downloading the upgrade package, the third device 13 can perform a version update based on the upgrade package, or forward the downloaded upgrade package to the fourth device 14, which then performs a version update based on the upgrade package. The fourth device 14 is used to perform version upgrades, and may be a terminal device or server, for example. The terminal device may be a mobile phone, tablet computer, computer, or wearable device, for example.

[0079] For example, first device 11 creates an upgrade package for the object to be upgraded and uploads it to second device 12, which then stores it. Third device 13 downloads the upgrade package from second device 12 and updates the version of the object to be upgraded based on the package. Alternatively, after downloading the upgrade package from second device 12, third device 13 may send the package to fourth device 14, which then updates its own version of the object to be upgraded based on the package.

[0080] There are two main methods for creating an upgrade package: one is a full upgrade, which packages all the data of the new version's installation package into the upgrade package. However, this upgrade package is larger in size. The other is a differential upgrade, which performs a differential operation on the new version's installation package and the old version's installation package to obtain a differential file. This differential file is then packaged into the upgrade package. The data size of this upgrade package is smaller than that of a full upgrade.

[0081] Currently, in order to save server storage resources and the time required for terminal devices to download upgrade packages, and to reduce development costs, upgrade packages are usually produced using a differential upgrade method, that is, the upgrade package is usually a differential file between two adjacent versions. For example, the first device 11 can perform differential processing on the old version installation package 1 and the new version installation package 2 as a whole to obtain a differential file, and package the differential file into the upgrade package, thereby obtaining an upgrade package for the object to be upgraded. After the third device 13 or the fourth device 14 obtains the upgrade package, it can perform a restoration process based on the upgrade package and the old version installation package 1 to obtain the new version installation package 2, and implement the version update by installing the second installation package. The restoration process is the reverse operation of the differential process, and is used to restore the original file based on the differential file.

[0082] However, the upgrade package obtained in this way still has a large data size, resulting in a long download time for the device downloading the upgrade package. Furthermore, the device to be updated has certain storage resource requirements, requiring the device's storage resources to be large enough to meet the installation requirements of the upgrade package. For example, small-memory devices such as wearables may not be able to store large upgrade packages due to their limited memory, nor can they restore and install large upgrade packages. Therefore, the upgrade package obtained in this way cannot meet the version update needs of small-memory devices.

[0083] To this end, the related art also provides another method for making an upgrade package. Please refer to Figure 2, which is a logical diagram of the generation and installation process of an upgrade package provided by the related art. As shown in Figure 2, the generation process of the upgrade package includes: obtaining the old version of the installation package 1 and the new version of the installation package 2. Then, the installation package 1 is sliced ​​to obtain the slice sequence 1, and the installation package 2 is sliced ​​to obtain the slice sequence 2. Afterwards, for each slice pair with the same order in the slice sequence 1 and the slice sequence 2, each slice pair is differentially processed to obtain the differential file corresponding to each slice pair, and then the differential files corresponding to the multiple slice pairs obtained by the differential processing are spliced ​​to obtain the upgrade package. The installation process of the upgrade package includes: after obtaining the upgrade package, the differential files corresponding to the multiple slice pairs in the upgrade package and the old version of the installation package 1 are restored to obtain the new version of the installation package 2.

[0084] In the above-mentioned method for producing an upgrade package, the differential files of the new and old versions are generated by first slicing the installation packages of the new and old versions, and then performing differential processing on all the slice pairs corresponding to the new and old versions. Although this can reduce the data size of the upgrade package to a certain extent, due to the defects of the differential algorithm, the data size of the upgrade package generated in this way may still be large. For example, if the installation packages of the new and old versions are small, the size of the slices obtained by slicing will also be small. For the slice pairs with smaller slice sizes, the differential files obtained by performing differential processing on them will be larger. For example, for the slice pairs with a size of 1 byte, the differential files obtained by performing differential processing on them will be larger than 1 byte.

[0085] In an embodiment of the present application, an alternative method for generating and installing an upgrade package is provided to significantly reduce the data size of the upgrade package, shorten the download time of the upgrade package, and reduce the storage resource requirements of the terminal device. For ease of understanding, the device version update process is described below using an example in which the first device 11 for generating the upgrade package is a packet capture server, the second device 12 for storing and issuing the upgrade package is a cloud server, the third device 13 for downloading the upgrade package is a mobile phone, and the fourth device 14 for performing the version update is a headset.

[0086] FIG3 is a schematic diagram of a system for performing version updates on another device provided in an embodiment of the present application. As shown in FIG3 , the system includes a packet server 21, a cloud server 22, a mobile phone 23, and a headset 24. The packet server 21, the cloud server 22, the mobile phone 23, and the headset 24 can be connected via a wired network or a wireless network. The headset 24 is a wireless headset, such as a wireless Bluetooth headset. The packet server 21 can obtain a new version of the installation package 1 and an old version of the installation package 2, generate an upgrade package based on the installation package 1 and the installation package 2, and upload the upgrade package to the cloud server 22. The mobile phone 23 downloads the upgrade package from the cloud server 22 and sends the upgrade package to the headset 24. The headset 24 receives the upgrade package and performs a version update by installing the upgrade package, for example, generating a new version of the installation package based on the old version of the installation package and the upgrade package, and installing the new version of the installation package.

[0087] With reference to FIG4 , the upgrade package generation process may include: slicing installation package 1 to obtain slice sequence 1, slicing installation package 2 to obtain slice sequence 2, wherein both slice sequence 1 and slice sequence 2 include multiple slices, slices with the same order in slice sequence 1 and slice sequence 2 constitute a slice pair, and multiple slices in slice sequence 1 and multiple slices in slice sequence 2 constitute multiple slice pairs. Data processing is performed on each slice pair based on the data similarity of each slice pair in the multiple slice pairs to obtain upgrade package data corresponding to each slice pair. Data processing includes skip processing, XOR processing, or differential processing, and the upgrade package data corresponding to the slice pair obtained by skip processing is empty. Then, based on the slice sequence number of each slice pair, the data processing type corresponding to each slice pair, and the upgrade package data, an upgrade package is generated. The upgrade package includes upgrade package data corresponding to the multiple slice sequence numbers and data processing type information corresponding to each slice sequence number. The upgrade package data corresponding to the data processing type of skip processing is empty.

[0088] Referring to Figure 4 , the upgrade package installation process includes: generating installation package 2 based on the upgrade package and installation package 1; and installing installation package 2. For example, installation package 1 is sliced ​​to obtain slice sequence 1. Based on the data processing type corresponding to each of the multiple slice sequence numbers included in the upgrade package, the slice corresponding to each slice sequence number in slice sequence 1 is restored to obtain the installation package data corresponding to each slice sequence number; and a second installation package is generated based on the installation package data corresponding to the multiple slice sequence numbers.

[0089] That is, when making an upgrade package, the embodiment of the present application, after slicing the installation packages of the old and new versions, can perform differential processing, XOR processing, or skip processing on each slice pair according to the data similarity of each slice pair corresponding to the old and new versions. For example, skip processing is performed when the data is the same, XOR processing is performed when the data similarity is high, and differential processing is performed when the data similarity is low. Instead of performing differential processing on all slice pairs corresponding to the old and new versions. By performing differential processing based on the data similarity of the slice pairs, the defects of performing differential processing on all slice pairs can be overcome, the data volume of the upgrade package can be reduced to a large extent, and an upgrade package with a relatively small data volume can be generated, further saving the download time of the upgrade package and reducing the requirements for the storage resources of the terminal device.

[0090] FIG5 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device may be the first device 11, the second device 12, the third device 13, or the fourth device 14 shown in FIG1 . Referring to FIG5 , the computer device includes at least one processor 501, a communication bus 502, a memory 503, and at least one communication interface 504.

[0091] The processor 501 may be a microprocessor (including a central processing unit (CPU), etc.), an application-specific integrated circuit (ASIC), or may be one or more integrated circuits used to control the execution of the program of the present application.

[0092] The communication bus 502 may include a pathway for transmitting information between the aforementioned components.

[0093] The memory 503 may be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compact disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 503 may exist independently and be connected to the processor 501 via the communication bus 502. The memory 503 may also be integrated with the processor 501.

[0094] The communication interface 504 uses any device such as a transceiver to communicate with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc.

[0095] In a specific implementation, as an embodiment, the processor 501 may include one or more CPUs, such as CPU0 and CPU1 shown in FIG5 .

[0096] In a specific implementation, as an embodiment, a computer device may include multiple processors, such as processor 501 and processor 505 shown in Figure 5. Each of these processors may be a single-core processor or a multi-core processor. The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as computer program instructions).

[0097] In a specific implementation, as an embodiment, the computer device may further include an output device 506 and an input device 507. The output device 506 communicates with the processor 501 and can display information in a variety of ways. For example, the output device 506 can be a liquid crystal display (LCD), a light emitting diode (LED) display device, a cathode ray tube (CRT) display device, or a projector. The input device 507 communicates with the processor 501 and can receive user input in a variety of ways. For example, the input device 507 can be a mouse, a keyboard, a touch screen device, or a sensor device.

[0098] The computer device may be a general-purpose computer device or a dedicated computer device. In a specific implementation, the computer device may be a desktop computer, a portable computer, a network server, a PDA, a mobile phone, a tablet computer, a wireless terminal device, a communication device, or an embedded device. The embodiments of the present application do not limit the type of computer device.

[0099] The memory 503 is used to store program code 510 for executing the solution of the present application, and the processor 501 is used to execute the program code 510 stored in the memory 503. The computer device can implement the generation and processing method of the upgrade package provided in the embodiment of Figure 6 below through the processor 501 and the program code 510 in the memory 503.

[0100] FIG6 is a schematic diagram of the structure of a terminal device 100 provided in an embodiment of the present application. The terminal device 100 may be the third device 13 or the fourth device 14 shown in FIG1 . Referring to FIG6 , the terminal device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identification module (SIM) card interface 195, etc.

[0101] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0102] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0103] The controller may be the nerve center and command center of the terminal device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0104] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0105] In some embodiments, the processor 110 may include one or more interfaces, such as an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0106] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is merely an illustrative illustration and does not constitute a structural limitation on the terminal device 100. In other embodiments of the present application, the terminal device 100 may also adopt a different interface connection method from the above embodiments, or a combination of multiple interface connection methods.

[0107] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. The power management module 141 is configured to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160.

[0108] The wireless communication function of the terminal device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0109] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in terminal device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0110] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the terminal device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0111] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium- or high-frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs sound signals through an audio device (including but not limited to the speaker 170A, the receiver 170B, etc.) or displays images or videos through the display screen 194.

[0112] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the terminal device 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0113] In some embodiments, antenna 1 of terminal device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that terminal device 100 can communicate with a network and other devices via wireless communication technology. Wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. GNSS may include the global positioning system (GPS), the global navigation satellite system (GLONASS), the Beidou navigation satellite system (BDS), the quasi-zenith satellite system (QZSS) and / or the satellite based augmentation system (SBAS).

[0114] The terminal device 100 implements display functions through a GPU, display screen 194, and an application processor. The GPU is a microprocessor for image processing that connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.

[0115] Display screen 194 is used to display images, videos, etc. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, terminal device 100 may include one or N display screens 194, where N is an integer greater than one.

[0116] The terminal device 100 can realize the shooting function through the ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0117] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0118] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the terminal device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created by the terminal device 100 during use (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0119] The terminal device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D and the application processor.

[0120] Next, the generation and installation process of the upgrade package provided in the embodiment of the present application is described in detail.

[0121] FIG7 is a flowchart of a method for generating and installing an upgrade package provided in an embodiment of the present application. The method is applied to the first device and the fourth device. As shown in FIG7 , the method includes the following steps:

[0122] Step 701: The first device obtains a first installation package and a second installation package, where the version of the second installation package is higher than the version of the first installation package.

[0123] The first installation package and the second installation package are installation packages of different versions of the object to be upgraded, and the version of the second installation package is higher than the version of the first installation package. The object to be upgraded may be an object such as a system or software that needs to be updated.

[0124] For example, the first installation package and the second installation package are both installation packages of the target software, the first installation package is the installation package of version 1, and the second installation package is the installation package of version 2, and version 2 is higher than version 1. The target software can be any software.

[0125] As an example, the first device may obtain the first installation package or the second installation package uploaded by the user. Alternatively, the first installation package may be obtained based on the storage path of the first installation package, and the second installation package may be obtained based on the storage path of the second installation package. Alternatively, the first installation package may be downloaded based on the download path of the first installation package, and the second installation package may be obtained based on the download path of the second installation package.

[0126] In one possible implementation, the first device is installed with upgrade package production software, and relevant personnel can upload the first installation package and the second installation package in the relevant interface of the upgrade package production software, and then trigger the upgrade package production instruction. In response to the upgrade package production instruction, the upgrade package production software of the first device can obtain the first installation package and the second installation package uploaded by the user, and then process the first installation package and the second installation package according to the following steps 702-704 to generate an upgrade package. Alternatively, relevant personnel can also enter or select the storage path of the first installation package and the storage path of the second installation package in the relevant interface of the upgrade package production software, and then trigger the upgrade package production instruction. In response to the upgrade package production instruction, the upgrade package production software of the first device can obtain the first installation package according to the storage path of the first installation package, and obtain the second installation package according to the storage path of the second installation package.

[0127] It should be understood that the first device can also obtain the first installation package and the second installation package in other ways, such as obtaining the first installation package and the second installation package from other devices, such as downloading the first installation package and the second installation package from a server. The embodiment of the present application does not limit the method of obtaining the first installation package and the second installation package.

[0128] Step 702: The first device slices the first installation package to obtain a first slice sequence, and slices the second installation package to obtain a second slice sequence. The second slice sequence and the slices with the same order in the first slice sequence form a slice pair, and multiple slices in the second slice sequence and multiple slices in the first slice sequence form multiple slice pairs.

[0129] The first slice sequence includes multiple slices, and the second slice sequence also includes multiple slices. Any two slices in the first slice sequence and the second slice sequence that have the same order can be referred to as a slice pair. For example, the first slice in the first slice sequence and the first slice in the second slice sequence are referred to as a slice pair, and the second slice in the first slice sequence and the second slice in the second slice sequence are referred to as a slice pair.

[0130] As an example, the first installation package and the second installation package can be sliced ​​according to the same slicing rule. The slicing rule includes a preset slice size. The preset slice size is used to indicate that the slices obtained by slicing are of the same size, that is, the preset slice size. In this way, the sizes of the slices in the first and second slice sequences can be guaranteed to be the same.

[0131] In addition, the slicing rule may further include a preset number of slices, which is used to indicate that the number of slices in the slice sequence obtained by slicing is the preset number of slices. In this way, it can be ensured that the number of slices in the first slice sequence and the second slice sequence is the same.

[0132] Generally speaking, the installation package sizes of the first installation package and the second installation package of different versions are the same or not much different, so after slicing the first installation package and the second installation package according to the same slicing rule, the number of slices in the first slicing sequence and the second slicing sequence is the same.

[0133] For example, assume that the preset slice size in the slicing rule is 16k. The first slice sequence obtained by slicing the first installation package according to the slicing rule includes 4 slices, and the slice size of each slice is 16k. The second slice sequence obtained by slicing the second installation package according to the slicing rule also includes 4 slices, and the slice size of each slice is 16k. For example, a slice can be identified as a block, abbreviated as blk. The 4 slices in the first slice sequence can be identified as: 1-blk0, 1-blk1, 1-blk2, 1-blk3, respectively, and the 4 slices in the second slice sequence can be identified as: 2-blk0, 2-blk1, 2-blk2, 2-blk3, respectively. The first slice sequence and the second slice sequence can constitute 4 slice pairs: 1-blk0 and 2-blk0, 1-blk1 and 2-blk1, 1-blk2 and 2-blk2, and 1-blk3 and 2-blk3.

[0134] Step 703: The first device performs data processing on each slice pair in the multiple slice pairs according to the data similarity of each slice pair to obtain the upgrade package data corresponding to each slice pair. The data processing at least includes skip processing, XOR processing or differential processing.

[0135] Among them, skip processing means not processing the data of the corresponding slice pair, and the upgrade package data corresponding to the slice pair obtained by skip processing is empty. XOR processing refers to data processing using XOR logic, and XOR logic means outputting a first value when two data are the same, and outputting a second value when two data are different. For example, XOR processing is performed on the data of corresponding bits in the two slices included in the slice pair. When the data of the slice pair is the same in a certain bit, the corresponding bit of the XOR processing result is the first value. When the data of the slice pair is different in a certain bit, the XOR processing result is the second value in the corresponding bit. Differential processing refers to determining the data difference between the two slices in the slice pair, that is, the result of differential processing is used to reflect the data difference of each slice pair.

[0136] In this embodiment of the present application, to reduce the data size of the upgrade package, each slice pair can be differentiated based on their data similarity, rather than using fixed differential processing for each slice pair. For example, if the data is identical, processing is skipped; if the data is highly similar, XOR processing is performed; if the data is significantly different, differential processing is performed. In this way, based on data similarity, the most matching data processing results can be used to indicate the data association between each slice pair, resulting in a smaller data size for the upgrade package generated based on the data processing results.

[0137] As an example, the plurality of slice pairs includes a first slice pair, which is composed of a first slice in a first slice sequence and a second slice in a second slice sequence. The operations of processing data for each slice pair based on data similarity of each slice pair to obtain upgrade package data corresponding to each slice pair may include the following:

[0138] Case 1: If the data of the first slice and the second slice are the same, the first slice pair is skipped and the upgrade package data corresponding to the first slice pair is empty.

[0139] The fact that the upgrade package data corresponding to the first slice pair is empty means that the first slice pair has no corresponding upgrade package data.

[0140] For slice pairs with the same data, the data of this slice pair does not need to be processed. It is only necessary to record the data processing type corresponding to this slice pair. Therefore, the upgrade package data corresponding to this slice pair is empty, that is, this slice pair has no corresponding upgrade package data.

[0141] Second case: If the data of the first slice and the second slice are different and the data similarity is greater than or equal to the first threshold, the first slice pair is XORed to obtain the first data, and the upgrade package data corresponding to the first slice pair is determined based on the first data.

[0142] The first threshold can be pre-set, for example, to a relatively high similarity threshold. When the data of the first slice and the second slice are different and the data similarity is greater than the first threshold, it indicates that the data of the first slice and the second slice are highly similar, with only a small portion of the data being different. For example, the first threshold can be 80% or 90%.

[0143] For a pair of slices with highly similar data, an XOR process may be performed on the pair of slices, and the XOR process result indicates which parts of the data in the pair of slices are the same and which parts of the data are different.

[0144] As an example, performing an XOR process on the first slice pair to obtain the first data includes: performing an XOR process on data at corresponding byte positions in the first slice and the second slice to obtain the first data.

[0145] Among them, if the data at the corresponding byte positions of the first slice and the second slice are the same, the data at the corresponding byte position of the first data is the first value; if the data at the corresponding byte positions of the first slice and the second slice are different, the data at the corresponding byte position of the first data is the second value.

[0146] The first data is the result of an exclusive-or operation. The first slice, the second slice, and the first data generally have the same number of bytes. The first value in the first data indicates that the data at corresponding byte positions of the first slice pair are identical, and the second value indicates that the data at corresponding byte positions of the first slice pair are different. The first value and the second value can be preset, for example, the first value is 0 and the second value is 1.

[0147] That is, if the data at the same byte position of the first slice and the second slice are the same, the first value is output at the same byte position of the first data; if the data at the same byte position of the first slice and the second slice are different, the second value is output at the same byte position of the first data.

[0148] Typically, the XOR processing object is generally binary data. If the data of the first slice pair is not binary data, the data of the first slice pair can be converted into binary data first, and then the XOR processing is performed on the first slice pair converted into binary data.

[0149] For example, performing XOR processing on the data at corresponding byte positions in the first slice and the second slice to obtain the first data includes the following two cases:

[0150] 1) If both the data of the first slice and the data of the second slice are binary data, an XOR process is performed on the binary values ​​of corresponding byte positions in the first slice and the second slice to obtain the first data.

[0151] Among them, if the values ​​of the corresponding byte positions of the first slice and the second slice are the same, the value of the corresponding byte position of the first data is 0; if the values ​​of the corresponding byte positions of the first slice and the second slice are different, the value of the corresponding byte position of the first data is 1.

[0152] For example, if the data of the first slice is "1100" and the data of the second slice is "1101", the first data obtained by XORing the first and second slices is "0001". The "0" in "0001" indicates that the data of the first slice pair at the corresponding byte position is different, and the "1" indicates that the data of the first slice pair at the corresponding byte position is different.

[0153] 2) If the data of at least one of the first slice and the second slice is not binary data, convert the data of the slice of the first slice and the second slice that is not binary data into binary data, and perform XOR processing on the binary values ​​of the corresponding byte positions in the first slice and the second slice after the conversion into binary data to obtain the first data.

[0154] Among them, if the values ​​of the corresponding byte positions of the first slice and the second slice after conversion into binary data are the same, the value of the corresponding byte position of the first data is 0; if the values ​​of the corresponding byte positions of the first slice and the second slice after conversion into binary data are different, the value of the corresponding byte position of the first data is 1.

[0155] For example, if the data of the first slice and the second slice are hexadecimal data, the corresponding hexadecimal data can be converted into binary data first, and then the first slice and the second slice converted into binary data are subjected to XOR processing.

[0156] The operation of determining the upgrade package data corresponding to the first slice according to the first data may include any one of the following two implementations:

[0157] A first implementation method: determining the first data as upgrade package data corresponding to the first slice pair.

[0158] That is, the XOR processing result is directly used as the upgrade package data corresponding to the first slice pair. For example, if the first data is "0001", "0001" is directly used as the upgrade package data corresponding to the first slice pair.

[0159] The second implementation method is: compressing the first data to obtain third data, and determining the third data as the upgrade package data corresponding to the first slice.

[0160] That is, the XOR processing result is first compressed, and then the compressed XOR processing result is used as the upgrade package data corresponding to the first slice pair.

[0161] As an example, if the first data is binary data, the 0s in the first data can be compressed to obtain the third data. For example, if the first data is "0001", the 0s in the first data "0001" can be compressed to obtain the third data "1". This can reduce the amount of data, thereby improving data space usage and data transmission efficiency.

[0162] After the 0s in the first data are compressed, the obtained third data includes 1s but does not include 0s. In addition, the third data may further include byte position information of the compressed 0s or byte position information corresponding to the remaining 1s, to indicate which byte positions of data are compressed, so that the compressed third data can be subsequently decompressed based on this information to obtain the first data.

[0163] It should be understood that other compression methods may also be used to compress the first data.

[0164] The third case: if the data similarity between the first slice and the second slice is less than the first threshold, the first slice pair is differentially processed to obtain second data, and the upgrade package data corresponding to the first slice pair is determined based on the second data.

[0165] If the data similarity between the first slice and the second slice is less than the first threshold, it means that the data difference between the first slice and the second slice is large. In this case, differential processing can be performed on the first slice pair to represent the data difference of the first slice pair through the differential processing result.

[0166] The second data is a differential processing result, that is, a differential file of the first slice pair.

[0167] Determining the upgrade package data corresponding to the first slice pair according to the second data may include any one of the following two implementations:

[0168] A first implementation method is to determine the second data as the upgrade package data corresponding to the first slice pair.

[0169] That is, the differential processing result is directly used as the upgrade package data corresponding to the first slice pair.

[0170] A second implementation manner is to compress the second data to obtain fourth data; and determine the fourth data as upgrade package data corresponding to the first slice pair.

[0171] That is, the differential processing result is first compressed, and then the compressed differential processing result is used as the upgrade package data corresponding to the first slice pair. The compression algorithm for compressing the second data can be pre-set as needed, and this embodiment of the application does not limit this.

[0172] By processing data for each pair of slices in the same order in the first and second slice sequences, upgrade package data corresponding to the plurality of slice pairs can be obtained. The upgrade package data corresponding to the slice pairs for which the data processing type is skipped is empty, i.e., the slice pairs for which the data processing type is skipped have no corresponding upgrade package data.

[0173] Step 704: The first device generates an upgrade package based on the slice sequence number of each slice pair in the multiple slice pairs, and the data processing type and upgrade package data corresponding to each slice pair. The upgrade package includes the upgrade package data corresponding to the multiple slice sequence numbers and the data processing type information corresponding to each slice sequence number.

[0174] The data processing type information is used to indicate the data processing type used for data processing of the corresponding slice pair. The data processing type includes skip processing, XOR processing, or differential processing.

[0175] After obtaining the upgrade package data corresponding to each slice pair, the data processing type and upgrade package data corresponding to the slice pair indicated by each slice sequence number in the plurality of slice sequence numbers can be packaged into an upgrade package to generate an upgrade package.

[0176] As an example, the slice sequence number of the first slice sequence or the second slice sequence can be represented by 0 to n-1, where n is the number of slices in the slice sequence. It should be understood that the slice sequence number of the slice sequence can also be represented by other methods, such as 1 to n, and this embodiment of the application is not limited to this.

[0177] As an example, based on the slice sequence number of each slice pair, and the data processing type and upgrade package data corresponding to each slice pair, the operation of generating an upgrade package includes: writing the upgrade package data corresponding to the slice pair indicated by each slice sequence number in multiple slice sequence numbers into the data information of the initial data packet, and writing the data processing type corresponding to the slice pair indicated by each slice sequence number, and the storage location information of the corresponding upgrade package data in the data information of the initial data packet into the header information of the initial data packet. The initial data packet after the data is written is an upgrade package, and the multiple slice sequence numbers are the slice sequence numbers of the multiple slice pairs.

[0178] For example, the upgrade package data corresponding to each slice pair is written into the data information of the initial data packet. The slice sequence number of each slice pair, the data processing type corresponding to each slice pair, and the storage location information of the upgrade package data corresponding to each slice pair in the data information of the initial data packet are written into the header information of the initial data packet. After the data is written, the initial data packet becomes the upgrade package. The upgrade package data corresponding to the slice pair whose data processing type is skipped and the storage location information of the upgrade package data are both empty.

[0179] The storage location information of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet is used to indicate the storage location of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet. For example, the storage location information of the upgrade package data corresponding to each slice pair in the data information of the initial data packet may be an incremental offset of the upgrade package data corresponding to each slice pair in the data information of the initial data packet.

[0180] Thus, the header information of the generated upgrade package stores: the data processing type corresponding to each slice number among the multiple slice numbers, and the storage location information of the upgrade package data corresponding to each slice number in the upgrade package data information. The upgrade package data information stores the upgrade package data corresponding to each slice number. The storage location information of the upgrade package data corresponding to the slice number with the data processing type of skipping is empty, that is, there is no corresponding upgrade package data for the slice number with the data processing type of skipping, and there is no storage location information of the corresponding upgrade package data in the upgrade package.

[0181] Furthermore, multiple slice numbers can be written into the header of the initial data packet. For example, multiple slice numbers, along with the data processing type corresponding to each slice number and the storage location of the corresponding upgrade package data within the upgrade package data information, can be written into the header of the initial data packet. In this way, the corresponding data processing type and upgrade package data can be indicated by the slice number.

[0182] In addition, the slice size can be written into the header information of the initial data packet, so that the header information of the generated upgrade package also includes the slice size. Furthermore, the number of slices can be written into the header information of the initial data packet, so that the header information of the generated upgrade package also includes the number of slices.

[0183] By writing the slice size and / or number of slices in the header information, it is convenient for the terminal device that receives the upgrade package to perform a restore installation. The old version of the installation package stored on the terminal device is sliced ​​according to the slice size and / or number of slices in the header information to obtain a slice sequence corresponding to the multiple slice numbers in the upgrade package.

[0184] The slice size is the size of the slices in the first slice sequence and the second slice sequence. The number of slices is the number of identically ordered slice pairs in the first slice sequence and the second slice sequence. For example, the slice size of each slice in the first slice sequence and the second slice sequence is a preset size, and the slice size written into the header information is the preset size. The number of slices in the first slice sequence and the number of slices in the second slice sequence are the same, both being preset numbers, and the number of slices written into the header information is the preset number.

[0185] By presetting the slice size and number of slices, when creating an upgrade package, the old and new versions of the installation package can be sliced ​​according to the preset slice size and the preset slice number, ensuring that the slice size and the slice number of the slice sequence of the new and old versions are aligned, which facilitates subsequent processing based on each slice pair in the aligned slice sequence of the old and new versions to generate the upgrade package. In addition, by writing the preset slice size and the preset slice number in the header information, when the terminal device that receives the upgrade package performs a restore installation, the old version of the installation package stored on the terminal device is also sliced ​​according to the preset slice size and the preset slice number in the header information, obtaining a slice sequence corresponding to the multiple slice sequence numbers in the upgrade package, which facilitates the subsequent restoration of the new version of the installation package based on the upgrade package data and slice data with the same sequence number.

[0186] For example, the header information of the upgrade package can be expressed in the following format:

[0187] Where block_size is the slice size, block_num is the number of slices, operate_type is the data processing type, blk_no and offset are the slice number corresponding to the data processing type and the incremental offset of the corresponding upgrade package data in the upgrade package, respectively.

[0188] Different data processing types can be represented by different data processing type identifiers. For example, the following data processing type identifiers can be used to identify different data processing types:

[0189] Assume that the first slice sequence includes four slices: 1-blk0, 1-blk1, 1-blk2, and 1-blk3; and the second slice sequence also includes four slices: 2-blk0, 2-blk1, 2-blk2, and 2-blk3. The slice size of each slice is 16KB. The data processing type corresponding to the first slice pair (1-blk0 and 2-blk0) with slice sequence number 0 is skip processing, and the data processing type identifier for skip processing is 0. The data processing type corresponding to the second slice pair (1-blk1 and 2-blk1) with slice sequence number 1 and the fourth slice pair (1-blk3 and 2-blk3) with slice sequence number 3 is exclusive-or processing, and the data processing type identifier for exclusive-or processing is 1. The incremental offsets of the upgrade package data corresponding to the second and fourth slice pairs in the upgrade package are 10 and 8, respectively. The data processing type corresponding to the third slice pair "1-blk2 and 2-blk2" with slice sequence number 2 is differential processing, and the data processing type identifier of differential processing is 2. The incremental offset of the upgrade package data corresponding to the third slice pair in the upgrade package is 5. The header information of the upgrade package can be:

[0190] In addition, if the first installation package and the second installation package are sliced ​​according to the same slicing rule and the two slice sequences have different numbers of slices, a specific number of blank slices can be added to the end of the slice sequence with fewer slices to obtain the first slice sequence and the second slice sequence with the same number of slices.

[0191] For a first slice sequence and a second slice sequence with the same number of slices obtained after supplementing with blank slices, in each pair of slices in the first and second slice sequences with the same order, some slice pairs have both slices stored with data. For ease of explanation, such slice pairs are referred to as first-type slice pairs. In contrast, some slice pairs have only one slice stored with data, while the other slice has no data. For ease of explanation, such slice pairs are referred to as second-type slice pairs. The data similarity of second-type slice pairs is very low.

[0192] In this embodiment of the present application, data processing can be performed on each slice pair based on the data similarity and the slice pair category to which it belongs, to obtain the upgrade package data corresponding to each slice pair. In addition to skipping, XOR processing, or differential processing, data processing can also include copying or deleting. Slice pairs can be classified into first-category slice pairs or second-category slice pairs.

[0193] The copy process refers to copying the slice belonging to the second slice sequence in the corresponding slice pair to obtain the upgrade package data corresponding to the slice pair. The deletion process also refers to not processing the data of the corresponding slice pair, and the upgrade package data corresponding to the slice pair obtained by the deletion process is also empty.

[0194] For example, for the first slice pair with the same order in the first and second slice sequences, if the data of the first slice pair is the same and the first slice pair belongs to the first category of slice pairs, the first slice pair is skipped and the upgrade package data corresponding to the first slice pair is empty. If the data of the first slice pair is different, the data similarity is greater than or equal to a first threshold, and the first slice pair belongs to the first category of slice pairs, the first slice pair is XORed to obtain first data, and the upgrade package data corresponding to the first slice pair is determined based on the first data. If the data similarity of the first slice pair is less than the first threshold and the first slice pair belongs to the first category of slice pairs, the first slice pair is differentially processed to obtain second data, and the upgrade package data corresponding to the first slice pair is determined based on the second data.

[0195] In addition, if the data similarity pair corresponding to the first slice pair is less than the first threshold, the first slice pair belongs to the second slice pair and the blank slice in the first slice pair belongs to the first slice sequence, it means that the second installation package has added some new data relative to the first installation package, then the first slice pair can be copied, that is, the slice in the first slice pair belonging to the second slice sequence is copied to obtain the upgrade package data corresponding to the first slice pair.

[0196] If the data similarity pair corresponding to the first slice pair is less than the first threshold, the first slice pair belongs to the second slice pair, and the blank slice in the first slice pair belongs to the second slice sequence, it means that the second installation package has deleted some data relative to the first installation package. Then the first slice pair can be deleted, and the upgrade package data corresponding to the first slice pair is empty.

[0197] In this way, the generated upgrade package includes the data processing type and upgrade package data corresponding to each slice sequence number among the multiple slice sequence numbers. The data processing type corresponding to each slice sequence number is skip processing, XOR processing, differential processing, copy processing, or delete processing. The upgrade package data corresponding to the data processing type of skip processing and delete processing is empty, that is, there is no corresponding upgrade package data for the slice sequence number corresponding to the data processing type of skip processing and delete processing. Correspondingly, if the header information of the upgrade package includes the storage location information of the upgrade package data corresponding to each slice sequence number in the data information of the upgrade package, then the storage location information corresponding to the slice sequence number corresponding to the data processing type of skip processing and delete processing is empty, that is, there is no corresponding storage location information for the slice sequence number corresponding to the data processing type of skip processing and delete processing.

[0198] It should be noted that the generated upgrade package can indicate the association relationship between the first installation package and the second installation package, and specifically can indicate which slice pairs in the corresponding slice sequence have the same data, which slice pairs have highly similar data, and which slice pairs have large data differences, as well as which data are the same and which data are different in the slice pairs with highly similar data, and the differential files of the slice pairs with large data differences.

[0199] Step 705: The first device sends an upgrade package to the fourth device.

[0200] The first device can directly send the upgrade package to the fourth device, or it can forward the upgrade package to the fourth device through another device, which is not limited in this embodiment of the present application. For example, referring to Figure 1 above, the first device can first upload the upgrade package to the second device, and then the third device can download the upgrade package from the second device and forward the downloaded upgrade package to the fourth device. Alternatively, the fourth device can also download the upgrade package from the second device.

[0201] Alternatively, the first device may first compress the upgrade package to obtain a compressed version of the upgrade package, and then send the compressed version of the upgrade package to the fourth device. For example, referring to Figure 1 above, the first device may compress the upgrade package and upload the compressed version of the upgrade package to the second device. The third device may then download the compressed version of the upgrade package from the second device and forward the downloaded compressed version of the upgrade package to the fourth device. Alternatively, after downloading the compressed version of the upgrade package from the second device, the third device may first decompress the compressed version of the upgrade package to obtain the upgrade package, and then send the decompressed version of the upgrade package to the fourth device. Alternatively, the fourth device may download the compressed version of the upgrade package from the second device.

[0202] Step 706: The fourth device receives the upgrade package from the first device.

[0203] As an example, the fourth device may receive a compressed package of the upgrade package and decompress the compressed package to obtain the upgrade package. It should be understood that the fourth device may also obtain the upgrade package in other ways, which is not limited in this embodiment of the present application.

[0204] Step 707: The fourth device generates a second installation package based on the upgrade package and the stored first installation package.

[0205] Since the upgrade package is generated based on the first installation package and the second installation package, it can indicate the association relationship between the first installation package and the second installation package. Therefore, after the fourth device obtains the upgrade package, it can restore the second installation package based on the upgrade package and the stored first installation package.

[0206] As an example, the operation of generating the second installation package according to the upgrade package and the stored first installation package may include the following steps:

[0207] 1) According to the data processing type corresponding to each slice sequence number in the multiple slice sequence numbers, the slice corresponding to each slice sequence number is restored to obtain the installation package data corresponding to each slice sequence number.

[0208] The data processing type corresponding to each slice number includes at least skip processing, XOR processing or differential processing. In the case of different data processing types, the restoration processing method is different.

[0209] Specifically, according to different data processing types and the data processing type corresponding to each slice number in the multiple slice numbers, the restoration processing of the slice corresponding to each slice number may include the following situations:

[0210] The first case: when the data processing type corresponding to each slice serial number is skip processing, the slice corresponding to each slice serial number in the first slice sequence is copied to obtain the installation package data corresponding to each slice serial number.

[0211] The first slicing sequence is obtained by slicing the old version of the installation package stored on the second device.

[0212] That is, if the data of the slice pair indicated by the first slice sequence number is the same, the slice data at the corresponding position in the first slice sequence can be directly used as the slice data at the corresponding position in the new version of the installation package. For example, if the data processing type corresponding to slice sequence number 0 is skip processing, the data corresponding to slice sequence number 0 in the first slice sequence will be used as the installation package data corresponding to slice sequence number 0.

[0213] The second case: when the data processing type corresponding to each slice serial number is XOR processing, the upgrade package data corresponding to each slice serial number and the slice corresponding to each slice serial number in the first slice sequence are XOR processed to obtain the installation package data corresponding to each slice serial number.

[0214] Among them, the specific XOR processing method can refer to the relevant description in the above embodiment, and the embodiment of this application will not be repeated here. For example, if the data processing type corresponding to slice number 1 is XOR processing, and the upgrade package data corresponding to slice number 1 is "0001", and the data of the slice corresponding to slice number 1 in the first slice sequence is "1100", then "0001" and "1100" are XORed, and the installation package data corresponding to slice number 1 is "1101".

[0215] The third case: when the data processing type corresponding to each slice serial number is differential processing, the upgrade package data corresponding to each slice serial number and the slice corresponding to each slice serial number in the first slice sequence are reverse differentially processed to obtain the installation package data corresponding to each slice serial number.

[0216] The reverse differential processing is the reverse operation of the differential processing, which is used to restore the original file based on the differential file.

[0217] For example, if the data processing type corresponding to slice number 2 is differential processing, the upgrade package data corresponding to slice number 2 and the data of the slice corresponding to slice number 2 in the first slice sequence are restored to obtain the installation package data corresponding to slice number 2.

[0218] As an example, if the header information of the upgrade package stores the data processing type corresponding to each slice number in a plurality of slice numbers and the storage location information of the corresponding upgrade package data in the data information of the upgrade package, and the data information of the upgrade package stores the upgrade package data corresponding to each slice number in a plurality of slice numbers, then before obtaining the installation package data corresponding to each slice number, the data processing type corresponding to each slice number in a plurality of slice numbers and the storage location information of the corresponding upgrade package data in the data information of the upgrade package can be obtained from the header information of the upgrade package. Based on the storage location information of the upgrade package data corresponding to each slice number in the data information of the upgrade package, the upgrade package data corresponding to each slice number can be obtained from the data information of the upgrade package. Then, based on the data processing type corresponding to each slice number, the slice corresponding to each slice number is restored to obtain the installation package data corresponding to each slice number.

[0219] In addition, if the data processing type corresponding to each slice number in the upgrade package can also include copy processing or deletion processing, then according to the data processing type corresponding to each slice number in the multiple slice numbers, the operation of restoring the slice corresponding to each slice number also includes the following fourth and fifth cases:

[0220] The fourth situation: when the data processing type corresponding to each slice number is copy processing, the upgrade package data corresponding to the first slice number is copied to obtain the installation package data corresponding to the first slice number, so as to insert the upgrade package data corresponding to the first slice number newly added in the first installation package into the second installation package.

[0221] The fifth case: When the data processing type corresponding to each slice serial number is deletion processing, the upgrade package data corresponding to each slice serial number and the slice corresponding to each slice serial number in the first slice sequence are XORed and skipped, and the upgrade package data corresponding to the first slice serial number obtained is empty, so as to delete the slice data corresponding to the slice serial number in the first installation package.

[0222] In addition, before generating the second installation package, the stored first installation package may be sliced ​​to obtain a first slice sequence. As an example, the upgrade package header information includes a slice size, and the first installation package may be sliced ​​according to the slice size, so that the size of each slice in the first slice sequence is the slice size. As another example, the upgrade package header information includes a slice size and a number of slices, and the first installation package may be sliced ​​according to the slice size and the number of slices, so that the size of each slice in the first slice sequence is the slice size, and the number of slices included in the first slice sequence is the slice number.

[0223] 2) Generate a second installation package based on the installation package data corresponding to the multiple slice serial numbers.

[0224] For example, the installation package data corresponding to multiple slice numbers may be concatenated to obtain a second installation package.

[0225] Step 708: The fourth device installs the second installation package.

[0226] By installing the second installation package, you can achieve version update.

[0227] In an embodiment of the present application, when making an upgrade package, the installation packages of the new and old versions can be sliced ​​first, and then, based on the data similarity of each pair of slices corresponding to the new and old versions, each pair of slices can be subjected to differential processing, XOR processing, or skip processing. For example, skip processing is performed when the data is identical, XOR processing is performed when the data similarity is high, and differential processing is performed when the data similarity is low. Instead of performing differential processing on all pairs of slices corresponding to the new and old versions, differential processing is performed. By performing differential processing based on the data similarity of the slice pairs, the defects of performing differential processing on all pairs of slices can be overcome, the data volume of the upgrade package can be reduced to a large extent, and an upgrade package with a relatively small data volume can be generated, further saving the download time of the upgrade package and reducing the requirements for the storage resources of the terminal device.

[0228] In addition, when installing the upgrade package, the slices corresponding to the slice numbers in the upgrade package can be restored according to the data processing type corresponding to each slice number, and the new version of the installation package can be restored, and then the new version of the installation package can be installed. Since the data volume of the upgrade package is small, the storage resources required for restoring and installing the upgrade package are also small, which reduces the requirements for the storage resources of the terminal device and is suitable for version updates of terminal devices with small memory. Moreover, different forms of restoration processing can be performed on the slices corresponding to the slice numbers according to the different data processing types corresponding to each slice number. For example, when the data processing type is skip processing, copy processing is performed, when the data processing type is exclusive OR processing, exclusive OR processing is performed, and when the data processing type is differential processing, reverse differential processing is performed. In this way, the new version of the installation package can be accurately restored based on the upgrade package with a small amount of data, and a restoration and installation method suitable for upgrade packages with a small amount of data is proposed.

[0229] Next, in combination with the above Figure 3, taking the device for making the upgrade package as the package server 21, the device for storing and issuing the upgrade package as the cloud server 22, the device for downloading the upgrade package as the mobile phone 23, and the device for performing the version update as the headset 24 as an example, the generation and installation method of the upgrade package provided in the embodiment of the present application is described in detail.

[0230] FIG8 is a schematic diagram of a process for performing version update on a device according to an embodiment of the present application. As shown in FIG8 , the method includes the following steps:

[0231] Step 801: The package server 21 obtains the old version installation package 1 and the new version installation package 2.

[0232] Installation package 1 and installation package 2 are installation packages of different versions of the object to be upgraded, and the version of installation package 2 is higher than the version of installation package 1. The object to be upgraded may be an object such as a system or software that requires a version update.

[0233] Step 802: The packet processing server 21 slices the installation package 1 to obtain a slice sequence 1, and slices the installation package 2 to obtain a slice sequence 2. The slices in the slice sequence 1 and the slice sequence 2 with the same order constitute a plurality of slice pairs.

[0234] Please refer to Figure 9, which is a schematic diagram of the generation and installation process of an upgrade package provided in an embodiment of the present application. As shown in Figure 9, during the generation process of the upgrade package, installation package 1 and installation package 2 can be sliced ​​according to the same slicing rule. The slicing rule includes a slice size = 16k, which is used to indicate that the slice size of each slice obtained by slicing is 16k. In addition, the slice sequence 1 obtained by slicing the installation package 1 includes 4 slices: 1-blk0, 1-blk1, 1-blk2, and 1-blk3. The slice sequence 2 obtained by slicing the installation package 2 also includes 4 slices: 2-blk0, 2-blk1, 2-blk2, and 2-blk3.

[0235] Step 803: The packet processing server 21 performs data processing on each slice pair according to the data similarity of each slice pair in the multiple slice pairs to obtain the upgrade package data corresponding to each slice pair. The data processing at least includes skip processing, XOR processing or differential processing.

[0236] Among them, skipping processing means not processing the data of the corresponding slice pair, and the upgrade package data corresponding to the slice pair obtained by skipping processing is empty.

[0237] If the data are the same, skip processing is performed; if the data are different and the data similarity is greater than or equal to a first threshold, XOR processing is performed; if the data similarity is less than the first threshold, differential processing is performed.

[0238] Referring to Figure 9, if the data for the slice pair "1-blk0 and 2-blk0" corresponding to slice number 0 is identical, "1-blk0 and 2-blk0" are skipped, and the upgrade package data corresponding to slice number 0 is empty, meaning there is no upgrade package data corresponding to slice number 0. If the data similarity for the slice pair "1-blk1 and 2-blk1" corresponding to slice number 1 exceeds a first threshold, meaning the data are highly similar, then "1-blk1 and 2-blk1" are XORed to obtain data p1. This data p1 is then compressed to obtain the upgrade package data p1' corresponding to slice number 1. If the data similarity for the slice pair "1-blk2 and 2-blk2" corresponding to slice number 2 is less than a first threshold, meaning the data are significantly different, then "1-blk2 and 2-blk2" are differentially processed to obtain the upgrade package data p2 corresponding to slice number 2. The data similarity of the slice pair "1-blk3 and 2-blk3" corresponding to slice number 3 is greater than the first threshold, that is, the data are highly similar, so "1-blk3 and 2-blk3" are XORed to obtain data p3, and the data p3 is compressed to obtain the upgrade package data p3' corresponding to slice number 3.

[0239] Step 804: The packet server 21 writes the upgrade package data corresponding to each slice pair into the data information of the initial data packet, and writes the number of slices, slice size, slice sequence number of each slice pair, data processing type corresponding to each slice pair, and storage location information of the upgrade package data corresponding to each slice pair in the data information of the initial data packet into the header information of the initial data packet. The initial data packet after the data is written is the upgrade package.

[0240] The storage location information of the upgrade package data corresponding to each slice pair in the data information of the initial data packet may be the incremental offset of the upgrade package data corresponding to each slice pair in the data information of the initial data packet, etc.

[0241] Referring to Figure 9 , the upgrade package data p1' corresponding to slice number 1, the upgrade package data p2 corresponding to slice number 2, and the upgrade package data p3' corresponding to slice number 3 can be written into the upgrade package's data information. The incremental offsets of p1', p2', and p3' in the upgrade package's data information are 10, 5, and 8, respectively. Furthermore, the number of slices, slice size, data processing type corresponding to slice number 0, data processing types corresponding to slices 1-3, and the incremental offset of the upgrade package data can also be written into the upgrade package's header information.

[0242] For example, the header information of the upgrade package includes the following:

[0243] Step 805: The package server 21 compresses the upgrade package to obtain a compressed package of the upgrade package.

[0244] Step 806 : The packet-snapping server 21 sends the compressed package of the upgrade package to the cloud server 22 .

[0245] That is, the package server 21 can upload the compressed package of the upgrade package to the cloud server 22 .

[0246] It should be understood that the package server 21 may also not compress the upgrade package and directly send the upgrade package to the cloud server 22.

[0247] Step 807: The cloud server 22 sends the compressed package of the upgrade package to the mobile phone 23.

[0248] Among them, the cloud server 22 can actively push the compressed package of the upgrade package to the mobile phone 23, or send the compressed package of the upgrade package to the mobile phone 23 according to the download request of the mobile phone 23. This embodiment of the present application does not limit this.

[0249] For example, the mobile phone 23 may send a version update request of the object to be upgraded to the cloud server 22 , and the cloud server 22 may send a compressed package of the upgrade package to the cloud server 22 according to the version update request.

[0250] Step 808: The mobile phone 23 decompresses the compressed package of the upgrade package to obtain the upgrade package.

[0251] Step 809 : The mobile phone 23 sends the upgrade package to the headset 24 .

[0252] The headset 24 is pre-bound to the mobile phone 23. The two devices are connected via a wireless local area network (WLAN), such as Bluetooth. For system or software upgrades in the headset 24, the mobile phone 3 can download the upgrade package or a compressed version of the upgrade package from the cloud server 22, and then send it to the headset 24 via the WLAN.

[0253] It should be understood that after receiving the compressed package of the upgrade package sent by the cloud server 22, the mobile phone 23 may not compress the compressed package, but directly send the compressed package to the headset 24. Alternatively, the mobile phone 23 may receive the upgrade package sent by the cloud server 22 and send the upgrade package to the headset 24.

[0254] Step 810: The headset 24 receives the upgrade package and obtains the number of slices, slice size, multiple slice numbers, the data processing type corresponding to each slice number, and the storage location information of the upgrade package data corresponding to each slice number in the data information of the upgrade package from the header information of the upgrade package.

[0255] Step 811: The headset 24 slices the old version of the installation package 1 according to the slice size and the number of slices to obtain a slice sequence 1.

[0256] Referring to FIG9 , during the installation of the upgrade package, a slice sequence 1 obtained by slicing the installation package 1 includes four slices: 1-blk0, 1-blk1, 1-blk2, and 1-blk3.

[0257] It should be understood that the headset 24 can also obtain the slice sequence 1 corresponding to the installation package 1 in other ways, such as obtaining the stored slice sequence 1, or obtaining the slice sequence 1 from other devices. This embodiment of the present application is not limited to this.

[0258] Step 812: The headset 24 obtains the upgrade package data corresponding to each of the multiple slice numbers from the data information of the upgrade package based on the multiple slice numbers and the storage location information of the upgrade package data corresponding to each slice number in the data information of the upgrade package.

[0259] After obtaining the upgrade package data corresponding to each slice number, if the upgrade package data corresponding to a certain slice number is compressed data, the obtained upgrade package data can also be decompressed, and then the following step 813 is executed according to the decompressed upgrade package data.

[0260] For example, referring to Figure 9 , the upgrade package data p1' corresponding to slice number 1, the upgrade package data p2 corresponding to slice number 2, and the upgrade package data p3' corresponding to slice number 3 can be obtained from the upgrade package data information. Then, the upgrade package data p1' corresponding to slice number 1 is decompressed to obtain data p1, and the upgrade package data p3' corresponding to slice number 3 is decompressed to obtain data p2.

[0261] Step 813: The headset 24 performs restoration processing on the slice corresponding to each slice number according to the data processing type corresponding to each slice number in the multiple slice numbers to obtain the installation package data corresponding to each slice number.

[0262] For example, if the data processing type corresponding to a certain slice sequence number is skip processing, the slice with the same slice sequence number in slice sequence 1 is copied to obtain the installation package data corresponding to the slice sequence number. If the data processing type corresponding to a certain slice sequence number is exclusive-or processing, the upgrade package data corresponding to the slice sequence number and the slice corresponding to each of the same slice sequence numbers in slice sequence 1 are exclusive-or processed to obtain the installation package data corresponding to the slice sequence number. If the data processing type corresponding to a certain slice sequence number is differential processing, the upgrade package data corresponding to each slice sequence number and the slice corresponding to the same slice sequence number in slice sequence 1 are reverse differential processed to obtain the installation package data corresponding to each slice sequence number.

[0263] Please refer to Figure 9. The data processing types corresponding to slice numbers 0 to 3 are skip processing, XOR processing, differential processing, and XOR processing, respectively. The slice of slice number 0 in slice sequence 1 is copied to obtain the installation package data corresponding to slice number 0, that is, 2-blk0. The decompressed upgrade package data p1 corresponding to slice number 1 and the data of 1-blk1 in slice sequence 1 are XORed to obtain the installation package data corresponding to slice number 1, that is, 2-blk1. The upgrade package data p2 corresponding to slice number 2 and the data in 1-blk2 in slice sequence 1 are reverse-differentialed to obtain the installation package data corresponding to slice number 2, that is, 2-blk2. The decompressed upgrade package data p3 corresponding to slice number 3 and the data of 1-blk3 in slice sequence 3 are XORed to obtain the installation package data corresponding to slice number 3, that is, 2-blk4.

[0264] Step 814: The headset 24 splices the installation package data corresponding to multiple slice numbers to obtain a new version of the installation package 2.

[0265] Refer to Figure 9 and concatenate 2-blk0, 2-blk1, 2-blk2, and 2-blk3 to obtain installation package 2.

[0266] Step 815: The headset 24 installs the installation package 2.

[0267] By installing the second installation package, you can achieve version update.

[0268] In an embodiment of the present application, when making an upgrade package, the installation packages of the new and old versions can be sliced ​​first, and then, based on the data similarity of each pair of slices corresponding to the new and old versions, each pair of slices can be subjected to differential processing, XOR processing, or skip processing. For example, skip processing is performed when the data is identical, XOR processing is performed when the data similarity is high, and differential processing is performed when the data similarity is low. Instead of performing differential processing on all pairs of slices corresponding to the new and old versions, differential processing is performed. By performing differential processing based on the data similarity of the slice pairs, the defects of performing differential processing on all pairs of slices can be overcome, the data volume of the upgrade package can be reduced to a large extent, and an upgrade package with a relatively small data volume can be generated, further saving the download time of the upgrade package and reducing the requirements for the storage resources of the terminal device.

[0269] In addition, when installing the upgrade package, the slices corresponding to the slice numbers in the upgrade package can be restored according to the data processing type corresponding to each slice number, and the new version of the installation package can be restored, and then the new version of the installation package can be installed. Since the data volume of the upgrade package is small, the storage resources required for restoring and installing the upgrade package are also small, which reduces the requirements for the storage resources of the terminal device and is suitable for version updates of terminal devices with small memory. Moreover, different forms of restoration processing can be performed on the slices corresponding to the slice numbers according to the different data processing types corresponding to each slice number. For example, when the data processing type is skip processing, copy processing is performed, when the data processing type is exclusive OR processing, exclusive OR processing is performed, and when the data processing type is differential processing, reverse differential processing is performed. In this way, the new version of the installation package can be accurately restored based on the upgrade package with a small amount of data, and a restoration and installation method suitable for upgrade packages with a small amount of data is proposed.

[0270] Figure 10 is a schematic diagram of the structure of an upgrade package generation device provided in an embodiment of the present application. The device can be implemented as part or all of a computer device using software, hardware, or a combination of both. The computer device can be the first device 11 shown in Figure 1 or the packet generation server 21 shown in Figure 3. Referring to Figure 10, the device includes an acquisition module 1001, a slicing module 1002, a processing module 1003, and a generation module 1004.

[0271] An acquisition module 1001 is configured to execute step 701 in the embodiment of FIG. 7 ;

[0272] Slicing module 1002, configured to execute step 702 in the embodiment of FIG. 7 ;

[0273] Processing module 1003, configured to execute step 703 in the embodiment of FIG. 7 ;

[0274] The generating module 1004 is configured to execute step 704 in the embodiment of FIG. 7 .

[0275] Optionally, the multiple slice pairs include a first slice pair, and the first slice pair consists of a first slice in a first slice sequence and a second slice in a second slice sequence; the processing module 1003 includes:

[0276] A first processing unit is configured to skip processing the first slice pair if the data of the first slice and the second slice are the same, and the upgrade package data corresponding to the first slice pair is empty;

[0277] a second processing unit, configured to, if the data of the first slice and the second slice are different and the data similarity is greater than or equal to a first threshold, perform an XOR process on the first slice pair to obtain first data, and determine the upgrade package data corresponding to the first slice pair based on the first data;

[0278] The third processing unit is configured to perform differential processing on the first slice pair to obtain second data if the data similarity between the first slice and the second slice is less than a first threshold, and determine the upgrade package data corresponding to the first slice pair according to the second data.

[0279] Optionally, the second processing unit is configured to:

[0280] An XOR process is performed on data at corresponding byte positions in the first slice and the second slice to obtain first data.

[0281] Optionally, the second processing unit is configured to:

[0282] If both the data of the first slice and the data of the second slice are binary data, performing an exclusive-OR operation on the binary values ​​of corresponding byte positions in the first slice and the second slice to obtain first data; wherein, if the values ​​of the corresponding byte positions in the first slice and the second slice are the same, the value of the corresponding byte position of the first data is 0; if the values ​​of the corresponding byte positions in the first slice and the second slice are different, the value of the corresponding byte position of the first data is 1;

[0283] If the data of at least one of the first slice and the second slice is not binary data, the data of the slice that is not binary data in the first slice and the second slice is converted into binary data, and the binary values ​​of the corresponding byte positions in the first slice and the second slice after conversion into binary data are XORed to obtain the first data; wherein, if the values ​​of the corresponding byte positions of the first slice and the second slice after conversion into binary data are the same, the value of the corresponding byte position of the first data is 0; if the values ​​of the corresponding byte positions of the first slice and the second slice after conversion into binary data are different, the value of the corresponding byte position of the first data is 1.

[0284] Optionally, the second processing unit is configured to:

[0285] Determine the first data as upgrade package data corresponding to the first slice pair;

[0286] or,

[0287] The first data is compressed to obtain third data, and the third data is determined as upgrade package data corresponding to the first slice.

[0288] Optionally, the second processing unit is configured to:

[0289] The 0s in the first data are compressed to obtain third data.

[0290] Optionally, the third processing unit is configured to:

[0291] Determine the second data as upgrade package data corresponding to the first slice pair;

[0292] or,

[0293] The second data is compressed to obtain fourth data; and the fourth data is determined as upgrade package data corresponding to the first slice pair.

[0294] Optionally, the generating module 1004 is used to:

[0295] The upgrade package data corresponding to the slice pair indicated by each slice sequence number in the multiple slice sequence numbers is written into the data information of the initial data packet, and the data processing type corresponding to the slice pair indicated by each slice sequence number and the storage location information of the corresponding upgrade package data in the data information of the initial data packet are written into the header information of the initial data packet. The initial data packet after the data is written is the upgrade package, and the multiple slice sequence numbers are the slice sequence numbers of the multiple slice pairs.

[0296] Optionally, the generating module 1004 is further configured to:

[0297] The number of slice pairs with the same order in the first slice sequence and the second slice sequence and the slice sizes of the slices in the first slice sequence and the second slice sequence are written into the header information of the initial data packet.

[0298] Optionally, the number of slices in the first slice sequence and the number of slices in the second slice sequence are both preset numbers, and the number of slice pairs with the same order written into the header information is a preset number; the slice size of each slice in the first slice sequence and the second slice sequence is both a preset size, and the slice size of the slices in the first slice sequence and the second slice sequence written into the header information is a preset size.

[0299] Optionally, the storage location information of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet is the incremental offset of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet.

[0300] In an embodiment of the present application, when making an upgrade package, the installation packages of the new and old versions can be sliced ​​first, and then, based on the data similarity of each pair of slices corresponding to the new and old versions, each pair of slices can be subjected to differential processing, XOR processing, or skip processing. For example, skip processing is performed when the data is identical, XOR processing is performed when the data similarity is high, and differential processing is performed when the data similarity is low. Instead of performing differential processing on all pairs of slices corresponding to the new and old versions, differential processing is performed. By performing differential processing based on the data similarity of the slice pairs, the defects of performing differential processing on all pairs of slices can be overcome, the data volume of the upgrade package can be reduced to a large extent, and an upgrade package with a relatively small data volume can be generated, further saving the download time of the upgrade package and reducing the requirements for the storage resources of the terminal device.

[0301] Figure 11 is a schematic diagram of the structure of an upgrade package installation device provided in an embodiment of the present application. The device can be implemented as part or all of a computer device using software, hardware, or a combination of both. The computer device can be the third device 13 or the fourth device 14 shown in Figure 1, or the mobile phone 23 or the headset 24 shown in Figure 3. Referring to Figure 11, the device includes: an acquisition module 1101, a generation module 1102, and an installation module 1103.

[0302] An acquisition module 1101 is configured to acquire an upgrade package, where the upgrade package includes upgrade package data corresponding to multiple slice numbers and data processing type information corresponding to each slice number.

[0303] A generating module 1102 is configured to execute step 707 in the embodiment of FIG. 7 ;

[0304] The installation module 1103 is used to execute step 708 in the embodiment of FIG. 7 .

[0305] Optionally, the generating module 1102 includes a first generating unit and a second generating unit;

[0306] A first generating unit is configured to perform a restoration process on a slice corresponding to each slice sequence number according to a data processing type corresponding to each slice sequence number in a plurality of slice sequence numbers, so as to obtain installation package data corresponding to each slice sequence number;

[0307] Wherein, when the data processing type corresponding to each slice sequence number is skip processing, the slice corresponding to each slice sequence number in the first slice sequence is copied to obtain installation package data corresponding to each slice sequence number, wherein the first slice sequence is obtained by slicing the first installation package stored on the second device;

[0308] When the data processing type corresponding to each slice sequence number is XOR processing, the upgrade package data corresponding to each slice sequence number and the slice corresponding to each slice sequence number in the first slice sequence are XORed to obtain the installation package data corresponding to each slice sequence number;

[0309] When the data processing type corresponding to each slice sequence number is differential processing, reverse differential processing is performed on the upgrade package data corresponding to each slice sequence number and the slice corresponding to each slice sequence number in the first slice sequence to obtain the installation package data corresponding to each slice sequence number;

[0310] The second generating unit is used to generate a second installation package according to the installation package data corresponding to the multiple slice sequence numbers.

[0311] Optionally, the multiple slice serial numbers are the slice serial numbers of multiple slice pairs consisting of slices with the same order in the first slice sequence and the second slice sequence, the second slice sequence is obtained by slicing the second installation package whose version is higher than the first installation package, and the upgrade package data corresponding to each slice serial number in the multiple slice serial numbers is obtained by performing data processing on the corresponding slice pair based on the data similarity of the corresponding slice pair, and the data processing includes at least skip processing, XOR processing or differential processing, and the upgrade package data corresponding to the data processing type of skip processing is empty.

[0312] Optionally, the second generation unit is configured to concatenate the installation package data corresponding to the multiple slice sequence numbers to obtain a second installation package.

[0313] Optionally, the header information of the upgrade package includes a data processing type corresponding to each slice sequence number in the multiple slice sequence numbers and storage location information of the corresponding upgrade package data in the data information of the upgrade package, and the data information of the upgrade package stores the upgrade package data corresponding to each slice sequence number in the multiple slice sequence numbers;

[0314] The generating module 1102 further includes an acquiring unit, configured to:

[0315] Obtaining, from the header information of the upgrade package, the data processing type corresponding to each slice serial number in the plurality of slice serial numbers and the storage location information of the corresponding upgrade package data in the data information of the upgrade package;

[0316] According to the storage location information of the upgrade package data corresponding to each slice number in the data information of the upgrade package, the upgrade package data corresponding to each slice number is obtained from the data information of the upgrade package.

[0317] Optionally, the header information of the upgrade package further includes a slice size; the device further includes a slice module;

[0318] The slicing module is used to slice the first installation package according to a slice size to obtain a first slice sequence.

[0319] Optionally, the acquisition module 1101 is used to:

[0320] Get the compressed package of the upgrade package. The compressed package is obtained by compressing the upgrade package.

[0321] Decompress the compressed package to obtain the upgrade package.

[0322] In an embodiment of the present application, when installing an upgrade package, the new version of the installation package can be restored based on the data processing type and upgrade package data corresponding to each slice sequence number in the upgrade package, as well as the slice data of the same slice sequence number in the old version of the installation package, and then the new version of the installation package can be installed. Since the data volume of the upgrade package is small, the storage resources required for restoring and installing the upgrade package are also small, which reduces the storage resource requirements of the terminal device and is suitable for version updates of terminal devices with small memory. Moreover, different forms of restoration processing can be performed on the slices corresponding to each slice sequence number according to the different data processing types corresponding to each slice sequence number. For example, when the data processing type is skip processing, copy processing is performed, when the data processing type is exclusive OR processing, exclusive OR processing is performed, and when the data processing type is differential processing, reverse differential processing is performed. In this way, the new version of the installation package can be accurately restored based on the upgrade package with a small data volume, and a restoration and installation method for the upgrade package generated according to the upgrade package generation method of the first aspect above is proposed.

[0323] It should be noted that: when the upgrade package generation device provided in the above embodiment generates the upgrade package, and when the upgrade package installation device provided in the above embodiment installs the upgrade package, only the division of the above-mentioned functional modules is used as an example. In actual application, 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.

[0324] The functional units and modules in the above embodiments 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 above integrated units may be implemented in the form of hardware or software functional units. In addition, the specific names of the functional units and modules are only for the purpose of distinguishing them from each other and are not intended to limit the scope of protection of the embodiments of this application.

[0325] The upgrade package generation device and the upgrade package generation method embodiment provided in the above embodiment belong to the same concept, and the upgrade package installation device and the upgrade package installation method embodiment provided in the above embodiment belong to the same concept. The specific working process of the units and modules in the above embodiment and the technical effects brought about can be found in the method embodiment part and will not be repeated here.

[0326] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (such as a coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital versatile disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0327] The above are optional embodiments provided for this application and are not intended to limit this application. Any modifications, equivalent replacements, improvements, etc. made within the technical scope disclosed in this application should be included in the scope of protection of this application.

Claims

1. A method for generating an upgrade package, characterized in that: Applied to a first device, the method includes: Obtain a first installation package and a second installation package, where the version of the second installation package is higher than the version of the first installation package; Slicing the first installation package to obtain a first slice sequence; Slicing the second installation package to obtain a second slice sequence, wherein slices in the second slice sequence that are in the same order as those in the first slice sequence constitute a slice pair, and multiple slices in the second slice sequence and multiple slices in the first slice sequence constitute multiple slice pairs; performing data processing on each slice pair among the plurality of slice pairs according to the data similarity of each slice pair to obtain upgrade package data corresponding to each slice pair, wherein the data processing includes at least skip processing, exclusive-OR processing, or differential processing, wherein the upgrade package data corresponding to the slice pair obtained by skip processing is empty; An upgrade package is generated according to the slice sequence number of each slice pair in the multiple slice pairs, and the data processing type and upgrade package data corresponding to each slice pair. The upgrade package includes the upgrade package data corresponding to the multiple slice sequence numbers and the data processing type information corresponding to each slice sequence number.

2. The method according to claim 1, wherein The plurality of slice pairs includes a first slice pair consisting of a first slice in the first slice sequence and a second slice in the second slice sequence; The performing data processing on each slice pair according to the data similarity of each slice pair in the plurality of slice pairs to obtain upgrade package data corresponding to each slice pair includes: If the data of the first slice and the second slice are the same, the first slice pair is skipped and the upgrade package data corresponding to the first slice pair is empty; If the data of the first slice and the second slice are different and the data similarity is greater than or equal to a first threshold, performing an XOR operation on the first slice pair to obtain first data, and determining the upgrade package data corresponding to the first slice pair based on the first data; If the data similarity between the first slice and the second slice is less than the first threshold, differential processing is performed on the first slice pair to obtain second data, and the upgrade package data corresponding to the first slice pair is determined based on the second data.

3. The method according to claim 2, wherein The performing an XOR process on the first slice pair to obtain first data includes: Perform an XOR process on the data at corresponding byte positions in the first slice and the second slice to obtain the first data.

4. The method according to claim 3, wherein The performing XOR processing on the data at corresponding byte positions in the first slice and the second slice to obtain the first data includes: If both the data of the first slice and the data of the second slice are binary data, performing an exclusive-OR operation on the binary values ​​at corresponding byte positions in the first slice and the second slice to obtain the first data; wherein, if the values ​​at the corresponding byte positions in the first slice and the second slice are the same, the value at the corresponding byte position in the first data is 0; and if the values ​​at the corresponding byte positions in the first slice and the second slice are different, the value at the corresponding byte position in the first data is 1; If the data of at least one of the first slice and the second slice is not binary data, the data of the slice that is not binary data in the first slice and the second slice is converted into binary data, and the binary values ​​of the corresponding byte positions in the first slice and the second slice after conversion into binary data are XORed to obtain the first data; wherein, if the values ​​of the corresponding byte positions of the first slice and the second slice after conversion into binary data are the same, the value of the corresponding byte position of the first data is 0; if the values ​​of the corresponding byte positions of the first slice and the second slice after conversion into binary data are different, the value of the corresponding byte position of the first data is 1.

5. The method according to any one of claims 2 to 4, characterized in that: The determining, according to the first data, upgrade package data corresponding to the first slice pair includes: Determining the first data as upgrade package data corresponding to the first slice pair; or, The first data is compressed to obtain third data, and the third data is determined as the upgrade package data corresponding to the first slice.

6. The method according to claim 5, wherein The first data is binary data, and compressing the first data to obtain the third data includes: The 0s in the first data are compressed to obtain the third data.

7. The method according to any one of claims 2 to 6, wherein: The determining, according to the second data, upgrade package data corresponding to the first slice pair includes: Determining the second data as upgrade package data corresponding to the first slice pair; or, The second data is compressed to obtain fourth data; and the fourth data is determined as upgrade package data corresponding to the first slice pair.

8. The method according to any one of claims 1 to 7, wherein: Generating the upgrade package according to the slice sequence number of each slice pair in the plurality of slice pairs, and the data processing type and upgrade package data corresponding to each slice pair, includes: The upgrade package data corresponding to the slice pair indicated by each slice sequence number among the multiple slice sequence numbers is written into the data information of the initial data packet, and the data processing type corresponding to the slice pair indicated by each slice sequence number and the storage location information of the corresponding upgrade package data in the data information of the initial data packet are written into the header information of the initial data packet. The initial data packet after the data is written is the upgrade package, and the multiple slice sequence numbers are the slice sequence numbers of the multiple slice pairs.

9. The method according to claim 8, wherein The method further comprises: The number of identically ordered slice pairs in the first slice sequence and the second slice sequence, and the slice sizes of the slices in the first slice sequence and the second slice sequence are written into header information of the initial data packet.

10. The method according to claim 9, wherein The number of slices in the first slice sequence and the number of slices in the second slice sequence are both preset numbers, and the number of the slice pairs with the same order written into the header information is the preset number; The slice size of each slice in the first slice sequence and the second slice sequence is a preset size, and the slice size of the slices in the first slice sequence and the second slice sequence written in the header information is the preset size. size.

11. The method according to any one of claims 8 to 10, characterized in that: The storage location information of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet is the incremental offset of the upgrade package data corresponding to the slice pair indicated by each slice sequence number in the data information of the initial data packet.

12. A method for installing an upgrade package, characterized in that: Applied to the second device, the method includes: Obtain an upgrade package, the upgrade package including upgrade package data corresponding to multiple slice numbers and data processing type information corresponding to each slice number; Performing restoration processing on the slice corresponding to each slice sequence number according to the data processing type corresponding to each slice sequence number in the multiple slice sequence numbers to obtain the installation package data corresponding to each slice sequence number; Wherein, when the data processing type corresponding to each slice sequence number is skip processing, the slice corresponding to each slice sequence number in the first slice sequence is copied to obtain installation package data corresponding to each slice sequence number, wherein the first slice sequence is obtained by slicing the first installation package stored on the second device; In a case where the data processing type corresponding to each slice sequence number is XOR processing, performing XOR processing on the upgrade package data corresponding to each slice sequence number and the slice corresponding to each slice sequence number in the first slice sequence to obtain the installation package data corresponding to each slice sequence number; When the data processing type corresponding to each slice sequence number is differential processing, performing reverse differential processing on the upgrade package data corresponding to each slice sequence number and the slice corresponding to each slice sequence number in the first slice sequence to obtain the installation package data corresponding to each slice sequence number; Generate a second installation package according to the installation package data corresponding to the multiple slice sequence numbers; Install the second installation package.

13. The method according to claim 12, characterized in that The multiple slice serial numbers are the slice serial numbers of multiple slice pairs composed of slices with the same order in the first slice sequence and the second slice sequence. The second slice sequence is obtained by slicing the second installation package with a version higher than that of the first installation package. The upgrade package data corresponding to each slice serial number in the multiple slice serial numbers is obtained by performing data processing on the corresponding slice pair based on the data similarity of the corresponding slice pair. The data processing includes at least skip processing, XOR processing or differential processing. The upgrade package data corresponding to the data processing type of skip processing is empty.

14. The method according to claim 12 or 13, wherein: The header information of the upgrade package includes the data processing type corresponding to each slice sequence number in the multiple slice sequence numbers and the storage location information of the corresponding upgrade package data in the data information of the upgrade package, and the data information of the upgrade package stores the upgrade package data corresponding to each slice sequence number in the multiple slice sequence numbers; Before performing restoration processing on the slice corresponding to each slice sequence number according to the data processing type corresponding to each slice sequence number in the plurality of slice sequence numbers to obtain the installation package data corresponding to each slice sequence number, the method further includes: Obtaining, from header information of the upgrade package, data processing type corresponding to each slice sequence number in the multiple slice sequence numbers and storage location information of corresponding upgrade package data in data information of the upgrade package; According to the storage location information of the upgrade package data corresponding to each slice number in the data information of the upgrade package, the upgrade package data corresponding to each slice number is obtained from the data information of the upgrade package.

15. The method according to claim 14, wherein The header information of the upgrade package also includes the slice size; Before performing restoration processing on the slice corresponding to each slice sequence number according to the data processing type corresponding to each slice sequence number in the plurality of slice sequence numbers to obtain the installation package data corresponding to each slice sequence number, the method further includes: The first installation package stored on the second device is sliced ​​according to the slice size to obtain the first slice sequence.

16. The method according to any one of claims 12 to 15, wherein: Generating the second installation package according to the installation package data corresponding to the plurality of slice sequence numbers includes: The installation package data corresponding to the multiple slice serial numbers are spliced ​​together to obtain the second installation package.

17. The method according to any one of claims 12 to 16, wherein: Obtaining the upgrade package includes: Obtaining a compressed package of the upgrade package, wherein the compressed package is obtained by compressing the upgrade package; Decompress the compressed package to obtain the upgrade package.

18. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the method according to any one of claims 1 to 11 or claims 12 to 17 is implemented.

19. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 11 or claims 12 to 17.

Citation Information

Cited By

  • Firmware upgrading method and device, storage medium and program product

    CN122285054A