Compression method, decompression method and related apparatus

By selecting different compression algorithms according to the category and access frequency of application data, the problem of difficult to take into account both the compression speed and the compression effect in the prior art is solved, and more efficient data compression and a better user experience are achieved.

WO2025065219A1PCT designated stage expired Publication Date: 2025-04-03HUAWEI TECH CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/121390
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-09-26
Publication Date
2025-04-03

AI Technical Summary

Technical Problem

The existing lossless compression technology is difficult to improve the compression speed while ensuring the compression effect, which makes it difficult to make a trade-off between profit and time consumption.

Method used

By identifying the category of application data as hot or cold data, different compression algorithms are selected according to the access frequency, and the compression time or compression rate is given priority to achieve a better user experience.

Benefits of technology

While meeting compression needs, it improves compression speed, reduces the storage pressure of electronic devices, and provides users with a better user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023121390_03042025_PF_FP_ABST
    Figure CN2023121390_03042025_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a compression method, a decompression method and a related apparatus. The compression method is applied to an electronic device, comprising: identifying the category of first application data as a first category; determining a first selection criterion on the basis of the first category, the first selection criterion being related to the compression time when an access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion being related to the compression ratio when the access frequency of the first application data is smaller than a second frequency threshold, and the first frequency threshold being greater than or equal to the second frequency threshold; on the basis of the first selection criterion, the size of the first application data and a compression speed of the first application data, determining a first compression algorithm; and compressing the first application data by using the first compression algorithm. For application data with different access frequencies, the electronic device can use different selection criterions to determine compression algorithms, so as to targetedly balance the compression gain and time consumption, thereby providing better user experience while satisfying compression requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Compression method, decompression method and related devices Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a compression method, a decompression method, and related devices. Background Art

[0002] Currently, the industry is focusing on lossless compression technology, which preserves the integrity of the original data during the compression and decompression process and is widely used in fields requiring high data fidelity. However, since compression algorithms with high compression ratios often require more computing resources and time to process and analyze data, a key research direction in lossless compression technology is to improve compression speed while maintaining compression effectiveness. In other words, the main challenge of lossless compression technology is to strike a balance between benefits and time consumption. Industry technicians are committed to providing users with a better user experience while meeting compression requirements.

[0003] Summary of the Invention

[0004] The present application provides a compression method, a decompression method, and related devices, which can use different methods to determine the compression algorithms for different categories of data in an application, and specifically weigh the benefits and time consumption of compression, thereby providing a better user experience while meeting compression requirements.

[0005] In a first aspect, the present application provides a compression method applied to an electronic device, the method comprising: identifying the category of first application data of the electronic device as a first category; determining a first selection criterion based on the first category; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to the compression time, and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold; determining a first compression algorithm based on the first selection criterion, the size of the first application data and the compression speed of the first application data; and compressing the first application data using the first compression algorithm.

[0006] In some examples, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first category is hot data, and the electronic device evaluates the compression requirement of the first application data, which is hot data, as low compression time. In some examples, when the access frequency of the first application data is less than a second frequency threshold, the first category is cold data, and the electronic device evaluates the compression requirement of the first application data, which is cold data, as high compression gain. In some examples, the first selection criterion is determined by the electronic device based on the evaluated compression requirement of the first application data.

[0007] In some examples, when the first selection criterion is related to compression time, the first selection criterion is used to give priority to a compression algorithm with a short compression time; when the first selection criterion is related to compression rate, the first selection criterion is used to give priority to a compression algorithm with a low compression rate.

[0008] In some examples, the electronic device is preset with parameters related to multiple compression algorithms, where the parameters related to one compression algorithm include multiple compression speeds, each corresponding to a plurality of data types. For example, the compression speeds are statistically and / or learned. Therefore, the compression speed of the first application data is the compression speed corresponding to the data type of the first application data. The compression speed of the first application data varies when the compression algorithm is different, that is, different compression algorithms correspond to different compression speeds for the first application data.

[0009] In the above method, when the access frequency of the first application data meets different conditions (i.e., different categories of the first application data), the electronic device can use different selection criteria to determine the compression algorithm. The compression algorithm determined in this way can well meet the different compression requirements of different categories of application data. It can also be understood as taking into account the benefits and time consumption of the compression algorithm for the different requirements of different categories of data, reducing the storage pressure of the electronic device, and providing users with a better usage experience while meeting the compression requirements.

[0010] In one possible implementation, the using the first compression algorithm to compress the first application data includes: when the first application data is uncompressed data, compressing the first application data using the first compression algorithm; when the first application data is compressed data, decompressing the first application data and compressing the decompressed first application data using the first compression algorithm.

[0011] In some examples, the electronic device is preset with multiple compression algorithms. The first application data is uncompressed data, including: the first application data is data that has not been compressed by any compression algorithm among the multiple compression algorithms; the first application data is compressed data, including: the first application data is data that has been compressed by any compression algorithm among the multiple compression algorithms.

[0012] In one possible implementation, the identifying that the category of the first application data of the electronic device is the first category includes: identifying that the category of the first application data in the first state is the first category; after compressing the first application data using the first compression algorithm, the method also includes: identifying that the category of the first application data in the second state is the second category; when the first category and the second category are different, determining a second selection criterion based on the second category, and the access frequency of the first application data in the first state and the first application data in the second state is different; determining a second compression algorithm based on the second selection criterion, the size of the first application data and the compression speed of the first application data; and compressing the first application data in the second state using the second compression algorithm.

[0013] In some examples, the access frequency of the first application data in the first state is greater than or equal to a first frequency threshold, and the access frequency of the first application data in the second state is less than a second frequency threshold. In other examples, the access frequency of the first application data in the first state is less than the second frequency threshold, and the access frequency of the first application data in the second state is greater than or equal to the first frequency threshold.

[0014] In the above method, the access frequency of the first application data in different states may be different, and the category may also change. When the category of the first application data changes, the electronic device can redefine the selection criteria and redefine the compression algorithm based on the selection criteria. That is, the electronic device can adjust the compression strategy in real time according to actual conditions, so as to better meet actual user needs.

[0015] In one possible implementation, the use of the first compression algorithm to compress the first application data includes: using the first compression algorithm to compress the first application data in the first state and obtaining second application data; the use of the second compression algorithm to compress the first application data in the second state includes: using a first decompression algorithm to decompress the second application data and obtain the first application data in the second state, the first decompression algorithm and the first compression algorithm corresponding to each other; and using the second compression algorithm to compress the first application data in the second state.

[0016] In some examples, decompressing the second application data using the first decompression algorithm includes: obtaining first indication information from the second application data, the first indication information being used to indicate the first compression algorithm; determining the first compression algorithm based on the first indication information; obtaining the first decompression algorithm corresponding to the first compression algorithm; and decompressing the second application data using the first decompression algorithm. Optionally, the electronic device may store a correspondence between compression algorithms and decompression algorithms, and obtaining the first decompression algorithm corresponding to the first compression algorithm includes: obtaining the first decompression algorithm corresponding to the first compression algorithm based on the correspondence.

[0017] In one possible implementation, the method further includes: after identifying that the category of the first application data in the second state is the second category, when the first category and the second category are the same, using a first decompression algorithm to decompress the first application data in the first state, and the first decompression algorithm corresponds to the first compression algorithm.

[0018] In some examples, when the first category and the second category are the same, decompressing the first application data in the first state using the first decompression algorithm includes: when the first category and the second category are the same, if an event triggering access to the first application data is detected, decompressing the first application data in the first state using the first decompression algorithm. In other examples, when the first category and the second category are the same, if the electronic device does not detect an event triggering access to the first application data, neither decompressing nor compressing the first application data.

[0019] In the above method, the access frequency of the first application data in different states may be different, and the category may also change. When the category of the first application data does not change, the electronic device will not re-determine the compression algorithm, nor will it decompress and re-compress the first application data, thereby reducing unnecessary power consumption and processing resources and improving device availability.

[0020] In one possible implementation, determining the first compression algorithm based on the first selection criterion, the size of the first application data, and the compression speed of the first application data includes: determining the first compression algorithm based on a first parameter, the first parameter is related to the first selection criterion, the first parameter is related to a first ratio, and the first ratio is the ratio of the size of the first application data to the compression speed of the first application data.

[0021] In some examples, when the access frequency of the first application data is greater than or equal to the first frequency threshold, the first selection criterion is related to the compression time, and the first parameter is the data compression cost DCC, which is related to the compression time; when the access frequency of the first application data is less than the second frequency threshold, the first selection criterion is related to the compression rate, and the first parameter is the weighted compression delay of the first application data. The electronic device will determine the first compression algorithm based on the first parameter and the compression rate.

[0022] In one possible implementation, the access frequency of the first application data is greater than or equal to the first frequency threshold, and the first selection criterion is related to the compression time; the first compression algorithm is determined based on the first selection criterion, the size of the first application data and the compression speed of the first application data, including: determining the first compression algorithm based on the data compression cost DCC; the DCC is related to the compression time, the DCC is the ratio of the first duration and the first data volume, the first duration includes the first compression duration and the first decompression duration, the first compression duration is the ratio of the data size of the first application data before compression to the compression speed, the first decompression duration is the ratio of the data size of the first application data before compression to the decompression speed, and the first data volume is the difference between the data size of the first application data before compression and the data size of the first application data after compression.

[0023] In some examples, the DCC is the total time consumed when compressing to save space per unit data size, the first time is the sum of the compression time and the decompression time, and the first data amount is the size of the space saved by compression.

[0024] In some examples, the expression of the DCC is as follows:

[0025] Among them, Size o is the data size of the first application data before compression, Speed c The compression speed corresponding to the data type of the first application data, Speed d is the decompression speed corresponding to the data type of the first application data, is the first compression duration, The first decompression duration, Size c is the data size of the first application data after compression.

[0026] In the above method, when the access frequency of the first application data is greater than or equal to the first frequency threshold (that is, the category of the first application data is hot data), the first selection criterion is related to the compression time. In this case, the electronic device can choose to use DCC to determine the compression algorithm of the first application data (for example, select the compression algorithm with the smallest DCC). DCC takes into account the compression time, decompression time and compression saved space. The electronic device does not simply use the compression time to determine the compression algorithm (for example, select the compression algorithm with the shortest compression time). The compression algorithm determined in this way will not have the following situation: although the compression time is very short, the decompression time is long and / or the compression saved space is small, which further takes into account the benefits and time consumption of compression and improves the user experience.

[0027] In a possible implementation, the first compression algorithm is a compression algorithm with the smallest corresponding DCC among multiple preset compression algorithms.

[0028] In the above method, when the access frequency of the first application data is greater than or equal to the first frequency threshold (that is, the category of the first application data is hot data), the electronic device can select the compression algorithm with the smallest DCC as the first compression algorithm, so that when the first application data is compressed by the first compression algorithm, the fastest possible compression speed and / or decompression speed can be obtained under a limited compression rate, effectively meeting the compression requirements of the hot data evaluated by the electronic device and meeting actual needs.

[0029] In one possible implementation, the first application data includes data of a first data type, the electronic device is preset with multiple compression algorithms and corresponding DCCs, any one of the multiple compression algorithms corresponds to multiple DCCs, and the multiple DCCs respectively correspond to different data types; determining the first compression algorithm based on the first selection criterion, the size of the first application data, and the compression speed of the first application data includes: determining the first compression algorithm based on the DCC corresponding to the first data type.

[0030] In the above method, the DCC used to determine the first compression algorithm is the DCC corresponding to the first data type included in the first application data. It takes into account the different "performance" (such as DCC) of application data of different data types during compression, and can more accurately determine the compression algorithm suitable for different application data, effectively improve the compression effect, and better meet the compression requirements.

[0031] In one possible implementation, the access frequency of the first application data is less than the second frequency threshold, and the first selection criterion is related to the compression ratio; the first compression algorithm is determined based on the first selection criterion, the size of the first application data and the compression speed of the first application data, including: determining the first compression algorithm based on the weighted compression delay and compression ratio of the first application data; the compression ratio is the ratio of the compressed data size to the data size before compression, the weighted compression delay of the first application data is related to the second compression duration and the first coefficient of the third application data, the first application data includes the third application data, the second compression duration is the ratio of the data size of the third application data before compression to the compression speed of the third application data, and the first coefficient is the proportion of the third application data to the first application data.

[0032] In some examples, the weighted compression delay of the first application data is a total compression duration of the first application data weightedly calculated based on the proportion of application data in the first application data (eg, the first coefficient).

[0033] In the above method, when the access frequency of the first application data is less than the second frequency threshold (that is, the category of the first application data is cold data), the first selection criterion is related to the compression rate. In this case, the electronic device can choose to use the weighted compression delay and compression rate to determine the compression algorithm of the first application data. The electronic device does not simply use the compression rate to determine the compression algorithm (for example, select the compression algorithm with the smallest compression rate). It takes into account that the compression time of some application data in the first application data may be very long. Therefore, the compression algorithm determined by combining the weighted compression delay and compression rate will not have the following situation: although the compression rate is very small, the compression time is very long (for example, exceeding the maximum compression time allowed by the electronic device), which further takes into account the benefits and time consumption of compression, thereby improving the user experience.

[0034] In one possible implementation, the first compression algorithm is a compression algorithm that satisfies a first condition among a plurality of preset compression algorithms, and the first condition includes: when the compression rates are arranged in ascending order, the compression rate corresponding to the first compression algorithm is arranged in the first N positions, and the weighted compression delay of the first application data is less than or equal to a third compression duration, where N is a positive integer, and the third compression duration is the preset maximum compression duration of the first application data.

[0035] In the above method, when the access frequency of the first application data is less than the second frequency threshold (that is, the category of the first application data is cold data), the electronic device can select: a compression algorithm with a weighted compression delay less than a preset maximum compression time and a lower (that is, better) compression rate as the first compression algorithm, so that when the first application data is compressed by the first compression algorithm, the highest possible compression gain can be obtained within a limited compression time. Not only is it considered that a good compression rate should be given priority, but also that the total compression time cannot be too long, so as to avoid the compression time cost exceeding the acceptable maximum range in order to achieve a higher compression gain. This well balances the compression gain and compression time, further improving the user experience.

[0036] In one possible implementation, the first application data includes fourth application data and fifth application data, the compression rate of the fourth application data per unit time is less than or equal to a first compression threshold, the compression rate of the fifth application data per unit time is greater than a second compression threshold, the first compression threshold is less than or equal to the second compression threshold, the weighted compression delay of the first application data includes a first value and a second value, the first value is related to the fourth compression duration and the second coefficient of the fourth application data, the second value is related to the fifth compression duration and the third coefficient of the fifth application data, the fourth compression duration is the ratio of the data size of the fourth application data to the compression speed of the fourth application data, the second coefficient is the proportion of the fourth application data to the first application data, the fifth compression duration is the ratio of the data size of the fifth application data to the compression speed of the fifth application data, and the third coefficient is the proportion of the fifth application data to the first application data.

[0037] In some examples, the third application data is the fourth application data or the fifth application data.

[0038] In the above method, considering that the first application data of cold data includes: the fourth application data that is "easy to compress" and the fifth application data that is "difficult to compress", the electronic device can obtain the weighted compression delay of the first application data according to the compression time and proportion of each application data, rather than simply using the total compression time of the first application data to determine the compression algorithm, which is more in line with the actual compression situation.

[0039] In one possible implementation, the second value is also related to a fourth coefficient, where the fourth coefficient is the proportion of compressed application data in the fifth application data to the fifth application data, and the third coefficient is related to the fourth coefficient, wherein when the third coefficient is less than a preset coefficient threshold, the fourth coefficient is 1, and when the third coefficient is greater than or equal to the preset coefficient threshold, the fourth coefficient is less than 1.

[0040] In some examples, the expression for the weighted compression delay of the first application data is as follows:

[0041] Among them, Size1 is the data size of the fourth application data, Size2 is the data size of the fifth application data, Speed1 is the compression speed corresponding to the data type of the fourth application data, Speed2 is the compression speed corresponding to the data type of the fifth application data, P1 is the second coefficient, P2 is the third coefficient, K2 is the fourth coefficient, P1, P2, and K2 are all greater than 0 and less than or equal to 1, P1+P2=1.

[0042] In the above method, for the "difficult to compress" fifth application data, the fourth coefficient is additionally used when calculating the weighted compression delay. The fourth coefficient is related to the proportion of the fifth application data in the first application data. When the proportion is small, all the fifth application data can be compressed. When the proportion is large, part of the fifth application data can be compressed. This can effectively avoid the following situation: when there is a lot of fifth application data, compressing all the fifth application data results in the compression benefit being far less than the compression cost (including compression time and processing resources). For example, the compression time is very long but the space saved is small, which further balances the compression benefit and compression time, and improves the user experience.

[0043] In one possible implementation, the first application data includes data of a second data type, and the electronic device is preset with multiple compression algorithms, corresponding compression rates, and corresponding compression speeds. Any one of the multiple compression algorithms corresponds to multiple compression rates and multiple compression speeds, and the multiple compression rates correspond to different data types, and the multiple compression speeds correspond to different data types; determining the first compression algorithm based on the first selection criterion, the size of the first application data, and the compression speed of the first application data includes: determining the first compression algorithm based on the weighted compression delay of the first application data and the compression rate corresponding to the second data type; the second compression duration is the ratio of the data size of the third application data before compression to the compression speed corresponding to the second data type.

[0044] In some examples, the data type of the third application data is the second data type.

[0045] In the above method, the compression speed and compression rate used when determining the first compression algorithm are: the compression speed and compression rate corresponding to the first data type included in the first application data, which takes into account the different "performance" (such as compression speed and compression rate) of application data of different data types during compression, and can more accurately determine the compression algorithm suitable for different application data, effectively improve the compression effect, and better meet compression requirements.

[0046] In one possible implementation, determining the first compression algorithm based on the first selection criterion, the size of the first application data, and the compression speed includes: determining the first compression algorithm based on the first selection criterion, the size of the first application data, the compression speed of the first application data, and the compression algorithm historically used for the first application data.

[0047] In the above method, the electronic device may also determine the first compression algorithm currently in use in combination with the compression algorithm historically used by the first application data, so that the first compression algorithm is more in line with actual scenarios.

[0048] In one possible implementation, before using the first compression algorithm to compress the first application data and using the second compression algorithm to compress the second application data, the method further includes: determining the parameters of the first compression algorithm based on the hardware performance of the electronic device and the first selection criteria, and determining the parameters of the second compression algorithm based on the hardware performance of the electronic device and the second selection criteria.

[0049] In the above method, the electronic device can use its own hardware performance and current selection criteria to determine the parameters of the first compression algorithm, taking into account the following situation: when the parameters of the compression algorithm are different, the compression time and compression rate may be different. The first compression algorithm determined in this way can further meet the compression requirements of the first application data and improve the compression effect.

[0050] In one possible implementation, the first application data is a plurality of virtual machine executable dex files in the first application of the electronic device, any two dex files among the plurality of dex files are a first dex file and a second dex file, and the names of the plurality of segments in the first dex file are respectively the same as the names of the plurality of segments in the second dex file; before compressing the first application data using the first compression algorithm, the method further includes: obtaining a plurality of index files according to the first application data, any one of the plurality of index files being a first index file, the first index file including the content of the first segment block in the first dex file and the content of the second segment block in the second dex file, and the names of the first segment block and the second segment block are the same; compressing the first application data using the first compression algorithm includes: compressing the plurality of index files using the first compression algorithm.

[0051] In some examples, the first segment block and the second segment block have the same name, and therefore describe the same content type. For example, the first segment block and the second segment block are both string identifier lists in the index area (assuming that the names are both string_ids), and are both used to describe the strings in the dex file to which they belong.

[0052] In the above method, the electronic device can split and reorganize multiple dex files according to the structure based on the structured characteristics of the dex file, store the split blocks with the same name in multiple dex files together, and store the split blocks with different names separately, thereby improving the analysis and processing efficiency of the dex file. Therefore, during subsequent compression, the electronic device can directly compress the multiple index files after splitting and reorganization, instead of compressing the original multiple dex files, thereby achieving better compression rate and shorter compression time.

[0053] In one possible implementation, the first application data includes at least one shared object so file, and any one of the at least one so file can be called by at least one application of the electronic device, and the contents of so files with the same name in the electronic device are also the same; before using the first compression algorithm to compress the first application data, the method also includes: querying the electronic device whether there is a so file with the same name as the first so file, the first so file is any one of the at least one so file; when there is a so file with the same name as the first so file, deleting the first so file.

[0054] In some examples, so files with the same name have the same functions and contents.

[0055] In the above method, based on the specific application scenarios and functions of so files, electronic devices can deduplicate so files by name. That is, only one so file with the same name (same function and content) is retained, and all others are deleted. During subsequent compression, the electronic device will not compress duplicate so files, avoiding the waste of storage and processing resources, resulting in better compression rates and shorter compression times, and optimizing the storage and management of so files.

[0056] In a second aspect, the present application provides another compression method, which is applied to an electronic device, and the method includes: receiving a first user operation; in response to the first user operation, displaying a first interface, the first interface including a first name, a first data size, and a second data size of the first application data, the first data size being the data size of the first application data before compression, the second data size being the data size of the first application data after compression, and the second data size being related to the access frequency of the first application data; wherein, when the access frequency of the first application data is the first frequency, the second data size is a first value, and when the access frequency of the first application data is the second frequency, the second data size is a second value, the first frequency is greater than or equal to a first frequency threshold, the second frequency is less than a second frequency threshold, the first frequency threshold is greater than or equal to the second frequency threshold, and the first value is greater than the second value.

[0057] In some examples, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first category is hot data. In some examples, when the access frequency of the first application data is less than a second frequency threshold, the first category is cold data. In some examples, when the access frequency of the first application data changes from the first frequency to the second frequency, the second data size changes from the first value to the second value, that is, when the category of the first application data changes from hot data to cold data, the second data size decreases. In some examples, when the access frequency of the first application data changes from the second frequency to the first frequency, the second data size changes from the second value to the first value, that is, when the category of the first application data changes from cold data to hot data, the second data size increases.

[0058] In the above method, the electronic device can intuitively display the name of the first application data, the data size before compression, and the data size after compression to the user for viewing, and the compressed data size displayed by the electronic device is obtained in real time, that is, the user can intuitively obtain the latest compression information of the first application data through the first interface, thereby improving the user experience.

[0059] In a possible implementation, the first interface further includes first indication information, where the first indication information indicates an access frequency of the first application data.

[0060] In the above method, the electronic device may further display the first indication information so that the user can intuitively obtain the access frequency of the first application data.

[0061] In one possible implementation, the first interface also includes a third data size of the first application data, the second data size is the data size of the first application data in the first state after compression, the third data size is the data size of the first application data in the second state after compression, the access frequency of the first application data in the first state and the first application data in the second state are different, the first state is the state of the first application data when the first interface is displayed, and the second state is the state of the first application data before the first state.

[0062] In the above method, the electronic device may further display the third data size of the first application data, ie, the size of the historically compressed data, in the first interface, so that the user can intuitively view more compression information.

[0063] In one possible implementation, the second data size is the data size of the first application data after being compressed by a first compression algorithm, and the first compression algorithm is determined based on a first selection criterion, the size of the first application data, and the compression speed of the first application data; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to the compression time, and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold.

[0064] For other implementations of the second aspect, please refer to the description of the implementation of the first aspect and will not be repeated here.

[0065] In a third aspect, the present application provides a decompression method, which is applied to an electronic device, and the method includes: obtaining first indication information in first application data, the first indication information is used to indicate a first compression algorithm, and the first application data is data compressed by the first compression algorithm for the second application data; determining the first compression algorithm based on the first indication information; the first compression algorithm is determined based on a first selection criterion, the size of the second application data and the compression speed of the second application data, wherein, when the access frequency of the second application data is greater than or equal to the first frequency threshold, the first selection criterion is related to the compression time, and when the access frequency of the second application data is less than the second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold; obtaining a first decompression algorithm corresponding to the first compression algorithm; and using the first decompression algorithm to decompress the first application data to obtain the second application data.

[0066] The implementation method of the third aspect can refer to the description of the implementation method of the first aspect and will not be repeated here.

[0067] In a fourth aspect, the present application provides a communication system comprising a first device and a second device, wherein the first device is used to execute the compression method provided by the first aspect, the second aspect, and any one of the implementations of the first aspect and the second aspect, and the second device is used to execute the decompression method provided by the third aspect.

[0068] In a possible implementation, the first device is configured to send the compressed application data to the second device, so that the second device decompresses the compressed application data.

[0069] In a fifth aspect, the present application provides an electronic device, comprising a processing module and a compression module, wherein the processing module is used to identify that the category of the first application data of the electronic device is a first category; the processing module is used to determine a first selection criterion based on the first category; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to the compression time, and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold; the processing module is used to determine a first compression algorithm based on the first selection criterion, the size of the first application data and the compression speed of the first application data; the compression module is used to compress the first application data using the first compression algorithm.

[0070] The implementation method of the fifth aspect can refer to the description of the implementation method of the first aspect and will not be repeated here.

[0071] In the sixth aspect, the present application provides an electronic device, including a transceiver, a processor and a memory; the above-mentioned memory is used to store a computer program, and the above-mentioned processor calls the above-mentioned computer program, so that the above-mentioned electronic device executes the compression method provided by the first aspect, the second aspect and any one of the implementation methods of the first aspect and the second aspect, and can also be used for the above-mentioned electronic device to execute the decompression method provided by the third aspect.

[0072] In the seventh aspect, the present application provides a computer storage medium, which stores a computer program. When the computer program is executed by a processor, it is used to execute the compression method provided by the first aspect, the second aspect, and any one of the implementation methods of the first aspect and the second aspect, and can also be used to execute the decompression method provided by the third aspect.

[0073] In the eighth aspect, the present application provides a computer program product. When the computer program product runs on a device, the device executes the compression method provided by the first aspect, the second aspect, and any one of the implementation methods of the first aspect and the second aspect. It can also be used for the above-mentioned electronic device to execute the decompression method provided by the third aspect.

[0074] In a ninth aspect, the present application provides an electronic device, the electronic device including a method or apparatus for executing any aspect or implementation of the present application. The electronic device is, for example, a chip.

[0075] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single implementation. On the contrary, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution or beneficial effect is included in at least one implementation. Therefore, the description of a technical feature, technical solution or beneficial effect in this application does not necessarily refer to the same implementation. Furthermore, the technical features, technical solutions and beneficial effects described in this application can also be combined in any appropriate manner. Those skilled in the art will understand that this application can be implemented without one or more specific technical features, technical solutions or beneficial effects of a specific implementation. In other implementations, additional technical features and beneficial effects can also be identified in specific implementations that do not embody all implementations. BRIEF DESCRIPTION OF THE DRAWINGS

[0076] The following is an introduction to the drawings used in this application.

[0077] FIG1 is a schematic diagram of the architecture of a communication system provided in an embodiment of the present application;

[0078] FIG2 is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application;

[0079] FIG3 is a schematic diagram of the architecture of an electronic device provided in an embodiment of the present application;

[0080] Figures 4 and 5 are schematic diagrams of some user interfaces provided in embodiments of the present application;

[0081] FIG6 is a schematic flow chart of a compression method provided in an embodiment of the present application;

[0082] FIG7 is a schematic diagram of a flow chart of a pretreatment process provided in an embodiment of the present application;

[0083] FIG8 is a schematic diagram of a pretreatment process provided in an embodiment of the present application;

[0084] FIG9 is a schematic diagram of a flow chart of another pretreatment process provided in an embodiment of the present application;

[0085] FIG10 is a schematic diagram of application data provided by an embodiment of the present application;

[0086] FIG11 is a flow chart of another compression method provided in an embodiment of the present application;

[0087] FIG12 is a schematic structural diagram of an electronic device provided in an embodiment of the present application;

[0088] FIG13 is a schematic diagram of the hardware structure of another electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0089] The technical solutions in the embodiments of the present application will be described below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " represents or, for example, A / B can represent A or B; "and / or" in the text is merely a description of the association relationship between associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" refers to two or more than two.

[0090] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.

[0091] With the frequent use of electronic devices such as mobile terminals in our daily lives, the applications (apps) and the data within them continue to accumulate and increase, resulting in a decrease in the available storage space on the devices. When storage space is insufficient, users may encounter many problems when using their devices, such as device lags, inability to run various applications smoothly, and even the inability to activate or use certain functions properly, reducing device efficiency and affecting the user experience.

[0092] Currently, the field of compression technology is focusing on lossless compression. The core concept of lossless compression is to preserve the integrity of the original data during compression and decompression, ensuring that the decompressed data is completely identical to the original data without any information loss. Lossless compression primarily achieves compression by eliminating redundant information in the data, rather than discarding some data. Lossless compression is widely used in fields requiring high data fidelity, such as medical imaging, audio compression, video compression, and scientific research data storage. With technological advances, traditional lossless compression technology is gradually shifting towards lossless compression based on artificial intelligence (AI). AI-based lossless compression technology uses machine learning methods such as deep learning and neural networks to discover and compress redundant / duplicate information in the data, enabling lossless compression to more efficiently compress data while also maintaining data integrity. However, lossless compression technology also faces challenges, the most significant of which is balancing the benefits (i.e., compression rate) with the time required (i.e., compression time). Since compression algorithms with high compression rates often require more computing resources and time to process and analyze the data, in most cases, the greater the space saved, the longer the computational time required. Industry technicians are committed to providing users with a better experience while meeting compression requirements, but this problem has not yet been effectively solved.

[0093] For example, a preset relationship between data access characteristics and compression algorithms is established. Based on the access characteristics of the data to be compressed, a corresponding compression algorithm is determined and used to compress the data. However, this preset approach lacks dynamism and only takes into account the data access characteristics. Consequently, the compression rate and / or compression time may not meet actual needs. For another example, multiple compression algorithms are preset. For each piece of data to be compressed, each of these multiple compression algorithms is used to pre-compress a portion of the data. The pre-compression results of each compression algorithm are evaluated using various pre-set metrics, such as compression time, resource consumption, and compression ratio. Finally, based on the evaluation results, the compression algorithm used to compress the current data is determined. Pre-compression and the evaluation of all preset compression algorithms are required for each compression, resulting in high time costs and processing pressure.

[0094] This application takes into account the problem of insufficient storage space in the above-mentioned electronic device and the challenges faced by the above-mentioned lossless compression technology, and proposes a compression method, which is applied to an electronic device, which can be installed with an application. For application data (which can be called first application data) in any application of the electronic device, the electronic device can identify the category of the first application data, for example, category 1 or category 2, wherein the data in category 1 is data that the electronic device evaluates to require low compression time consumption, and the data in category 2 is data that the electronic device evaluates to require high compression benefits. For example, the electronic device can classify data according to the frequency of use / access frequency of the data. The data in category 1 can be data with a high frequency of use / access frequency (which can be called hot data), and the data in category 2 can be data with a low frequency of use / access frequency (which can be called cold data). When the category of the first application data is category 1, the electronic device can determine the compression algorithm based on selection criterion 1 (preferentially selecting a compression algorithm with a short compression time) and data compression cost (DCC), so that when compressed by the compression algorithm, the compression speed can be as fast as possible under a limited compression rate (for example, the compression rate may be poor). When the category of the first application data is category 2, the electronic device can determine the compression algorithm based on selection criterion 2 (preferentially selecting a compression algorithm with a high compression rate) and weighted compression delay, so that when compressed by the compression algorithm, the best possible compression rate can be obtained within a limited compression time (for example, the compression time may be longer).

[0095] In this application, for different categories of application data, electronic devices can use different parameters and selection criteria to determine the compression algorithm. It can also be understood that different compression processing methods are used for different categories of application data to form a dedicated compression strategy. When formulating a dedicated compression strategy, this application comprehensively considers the access frequency of application data, relevant parameters of application data (such as the above-mentioned DCC, compression rate, weighted compression delay), data type of application data (which can characterize the content characteristics of the data itself) (when the data type is different, the values ​​of the above-mentioned relevant parameters may be different) and compression algorithm effect, so that the determined compression algorithm can well meet the different requirements of different categories of data, which not only reduces the storage pressure of electronic devices, but also takes into account the benefits and time consumption of the compression algorithm for the different requirements of different categories of data in actual scenarios, and provides users with a better user experience while meeting compression requirements.

[0096] The following introduces some technical terms involved in the embodiments of this application.

[0097] Application data refers to data generated by an APP. When users use various APPs on electronic devices, the APPs generate a large amount of application data. Application data includes, for example, executable files used to support APP operation, files set by the APP, user data in the APP, and cached files of the APP. The characteristics of different application data in the same APP (such as usage frequency / access frequency, modification frequency, and data type) may be different. The electronic device can classify application data based on at least one characteristic. For example, in a social application, data such as user personal information, icons of basic functions, updates posted by friends within the past month, and chat records within the past month are accessed more frequently and can be considered hot data. Data such as updates posted by friends three months ago and chat records from three months ago are accessed less frequently and can be considered cold data. Application data can include data of various data types, for example, at least one of the following: text data (such as data in formats such as txt, doc, ppt, and xlsx), image data (such as data in formats such as jpg and png), video data (such as data in formats such as mp4 and flv), audio data (such as data in formats such as mps3 and wma), compressed packages (such as data in formats such as rar and zip), and executable files (such as data in formats such as dex and so). A data type in this application can be a data format. For example, data in txt format and data in doc format belong to different data types. A data type in this application can also be a collection of multiple data formats. For example, text data in txt, doc, ppt, xlsx and other formats belong to the same data type.

[0098] A dex file, standing for Dalvik Executable file, can be an app's executable file and contain information about the app's executable components, such as Java classes, methods, and resources. An app's application data can include one or more dex files. The structure / format of a dex file is a special structure / format used by the Dalvik virtual machine. It consists of a header, an index area, and a data area. A specific example is shown in Figure 8 below. The header summarizes the layout of the entire dex file, including the size and offset of each element in the index area. The index area can include identifiers and offsets for data in the data area. The index area can contain multiple lists / sections, each of which can be used to describe different contents in the dex file. For example, the index area can include multiple lists, such as a string identifier list (string_ids) and a type identifier list (type_ids). The string_ids section describes the strings in the dex file, while the type_ids section describes the data types (such as array types and primitive types) in the dex file. Although the data in different dex files are different, the formats are the same. For example, the names and formats of multiple lists included in the index areas of different dex files are the same. For example, the index areas in any two dex files include string_ids, which are used to describe the strings in the current dex file (located in the data area), but the strings in the data areas of the two dex files can be different.

[0099] so file, the full name is shared object (so) file, also known as a dynamic link library, is a compiled program function library that can be used by APP. The functions in the dynamic link library are not part of the APP itself, but are loaded on demand according to the needs of the APP (only loaded when the APP is running). A dynamic link library can be called by at least one APP, and it can be said that the dynamic link library corresponds to this at least one APP. Optionally, the dynamic link library can be shared and used among multiple APPs, and different dynamic link libraries can be used / called by the same or different APPs. For example, dynamic link library 1 is used by APP1 and APP2, and dynamic link library 2 is used by APP2 and APP3. The dynamic link library of the electronic device can be stored in a dynamic link library warehouse, that is, the dynamic link library warehouse is a collection of dynamic link libraries. Electronic devices can use a hash table (which can be called a dynamic link library hash table) to record relevant information about the so file: the name of the dynamic link library, the number of apps that can call the current dynamic link library (which can be called the number of references), the file pointer (used to indicate the storage area of ​​the current dynamic link library in the dynamic link library warehouse), and the app pointer (used to indicate the storage area of ​​the app hash table, which is used to store information about apps that can call the current dynamic link library). An example of a dynamic link library warehouse and a dynamic link library hash table can be seen in Figure 10 below. In the same electronic device, so files with the same name have the same function and content, and the apps that can call the so file are also the same, while so files with different names have different functions and contents.

[0100] Compression ratio (expressed as Ratio c ), that is, the compressed data size (can be expressed as Size c ) and the original data size (which can be expressed as Size o ), the expression is as follows:

[0101] It can be understood that when the size of the original data is fixed, the smaller the compressed data size, the lower the compression rate, that is, the better the compression effect (the more space saved after compression). For the sake of convenience, this application can also refer to a small compression rate as a good compression rate and a large compression rate as a poor compression rate.

[0102] Compression speed (expressed as Speed c ), that is, the original data size (i.e. Size o ) and compression time (expressed as Time c ), the expression is as follows:

[0103] Decompression speed (expressed as Speed c), that is, the original data size (ie Size o ) and decompression time (expressed as Time d ), the expression is as follows:

[0104] DCC is the time required to save space per unit of data size. DCC can be calculated based on the original data size, compression speed, decompression speed, and the compressed product (i.e., the compressed data size). The expression is as follows:

[0105] According to the above expression, DCC is the ratio of compression and decompression time to space saving, and compression and decompression time is compression time. c (Right now ) and decompression time Time d (Right now ) and the space saved is the compressed data size Size o and the original data size c difference.

[0106] It can be understood that when the original data size is fixed, the smaller the DCC, the less time it takes to represent the compression, and accordingly, the better the compression effect. For ease of understanding, this application may also refer to a small DCC as a good DCC and a large DCC as a poor DCC.

[0107] The weighted compression delay (expressed as CompressDelay) is the sum of the compression times of files of various data types (expressed as Files). The expression is as follows:

[0108] Where n is greater than or equal to 1 and less than or equal to the number of files, and n is a positive integer. The original data size of the file of the nth data type, The compression speed of the file of the nth data type. n The ratio of files of the nth data type to files of the above multiple data types can be referred to as the data type ratio. For example, Files includes two data types of files: a 20-megabyte (MB) txt file and a 10MB so file. The P of the txt file is n is 20 / (20+10)=2 / 3, so the P of the file n =10 / (20+10)=1 / 3. n is the compression ratio of the file of the nth data type, K n Greater than 0 and less than or equal to 1, K nIf it is 1, the files of the nth data type will be compressed. n Less than 1 represents the portion of the file with the nth data type (proportion is K n ) will be compressed.

[0109] It is understandable that the same compression algorithm has different compression / decompression effects on data of different data types. For example, the above-mentioned compression speed / decompression speed, compression time / decompression time, and compression ratio are all different. Accordingly, DCC and weighted compression delay are also different.

[0110] Some data types respond poorly to most compression algorithms, i.e., they take a long time to compress and / or have a slow compression speed (e.g., poor DCC), and have a poor compression ratio. Such data types can be referred to as difficult-to-compress data. Other data types respond well to most compression algorithms, i.e., they take a short time to compress and / or have a fast compression speed (e.g., good DCC), and have a good compression ratio. Such data types can be referred to as easily-compressed data. For example, difficult-to-compress data is data whose compression ratio per unit time is less than or equal to a first compression threshold, and easily-compressed data is data whose compression ratio per unit time is greater than a second compression threshold, where the first compression threshold is less than or equal to the second compression threshold.

[0111] An application compression strategy (ACS) is a compression strategy for applications and application data that combines multiple general and specialized lossless compression algorithms with a time-space balancing strategy.

[0112] FIG1 exemplarily shows a schematic diagram of the architecture of a communication system 10 .

[0113] As shown in FIG1 , a communication system 10 may include an electronic device 100 and a server 200. The electronic device 100 and the server 200 may communicate via a wired link and / or a wireless link. Wired links include, for example, high definition multimedia interface (HDMI), universal serial bus (USB), coaxial cable, optical fiber, etc., and wireless methods include, for example, Bluetooth, wireless fidelity (Wi-Fi), sidelink, near field communication (NFC), ultra wide band (UWB), infrared, etc.

[0114] The electronic device 100 can be a mobile phone, a tablet computer, a handheld computer, a desktop computer, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), as well as smart home devices such as smart TVs and smart screens, wearable devices such as smart bracelets, smart watches, and smart glasses, extended reality (XR) devices such as augmented reality (AR), virtual reality (VR), and mixed reality (MR), in-vehicle devices, or smart city devices. The embodiments of the present application do not impose any special restrictions on the specific type of electronic device.

[0115] The server 200 may include at least one server, for example, a server cluster consisting of multiple servers, wherein any one of the servers may be a hardware server or a cloud server.

[0116] In one embodiment, the electronic device 100 can compress the application data in the electronic device 100 according to the compression method provided in the embodiment of the present application, and send the compressed application data to the server 200. The server 200 can decompress the application data sent by the electronic device 100 according to the decompression method provided in the embodiment of the present application, and use the decompressed application data. In other words, the electronic device 100 is used to compress the application data, and the server 200 is used to decompress the application data.

[0117] In one embodiment, the electronic device 100 can send application data to the server 200. The server 200 can compress the application data sent by the electronic device 100 according to the compression method provided in the embodiment of the present application, and send the compressed application data to the electronic device 100. The electronic device 100 can decompress the application data sent by the server 200 according to the decompression method provided in the embodiment of the present application, and use the decompressed application data. In other words, the server 200 is used to compress the application data, and the electronic device 100 is used to decompress the application data.

[0118] It can be understood that the form and quantity of the electronic device 100 and the server 200 shown in Figure 1 are only for illustration and are not limited to this embodiment of the present application.

[0119] The electronic device and server provided in the embodiments of the present application may also be referred to as communication devices or equipment.

[0120] Next, the electronic device in this application is introduced as an example.

[0121] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic 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.

[0122] FIG2 exemplarily shows a schematic diagram of the hardware structure of an electronic device 100 .

[0123] As shown in FIG2 , the electronic device 100 may include a processor 110 , a memory 120 , a display screen 130 , an audio module 140 , an antenna 1 , an antenna 2 , a mobile communication module 150 , a wireless communication module 160 , a sensor module 170 , and the like.

[0124] 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 video codec, a digital signal processor (DSP), a baseband processor and / or a neural-network processing unit (NPU), etc. Among them, different processing units can be independent devices or integrated into one or more processors. The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals based on instruction opcodes and timing signals to complete the control of instruction fetching and execution.

[0125] Processor 110 may also include a memory for storing instructions and data. In one embodiment, 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 retrieve it from the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0126] The memory 120 can be used to store computer-executable program code, which includes instructions. The memory 120 may include a program storage area and a data storage area. The program storage area may store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.). The memory 120 may include volatile memory, such as random access memory (RAM), etc. The memory 120 may also include non-volatile memory, such as read-only memory (ROM), flash memory, solid state disk (SSD), secure digital memory card (SD), etc. The memory 120 may also include a combination of the above-mentioned types of memory. The processor 110 may execute various functional applications and data processing of the electronic device 100 by running instructions stored in the memory 120 and / or instructions stored in a memory provided in the processor 110.

[0127] In one embodiment, the electronic device 100 may further include an external memory interface, which may be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface to implement data storage. For example, files such as music and videos may be stored on the external memory card.

[0128] Electronic device 100 can implement display functions using a GPU, display screen 130, and an application processor. A GPU is a microprocessor for image processing that connects display screen 130 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.

[0129] The display screen 130 is used to display images, videos, and the like. The display screen 130 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 one embodiment, the electronic device 100 may include one or N display screens 130, where N is a positive integer greater than one.

[0130] The audio module 140 can be used to convert digital audio information into analog audio signal output, and also to convert analog audio input into digital audio signals. The audio module 140 can also be used to encode and decode audio signals. In one embodiment, the audio module 140 can be provided in the processor 110, or some functional modules of the audio module 140 can be provided in the processor 110.

[0131] The electronic device 100 can implement audio functions, such as audio playback and recording, through the audio module 140, an audio device (not shown), and an application processor. The audio device is, for example, a speaker or a microphone. The speaker is used to convert audio electrical signals into sound signals, and the electronic device 100 can play music or implement hands-free calls through the speaker. The microphone is used to convert sound signals into electrical signals, and the electronic device 100 can collect the user's sound signals through the microphone to implement functions such as calls or recording.

[0132] The wireless communication function of the electronic 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.

[0133] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic 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.

[0134] The mobile communication module 150 can provide wireless communication solutions for the electronic device 100, including second generation (2G), third generation (3G), fourth generation (4G), fifth generation (5G), and sixth generation (6G). The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), and the like. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, filter and amplify the received electromagnetic waves, and transmit them to the modem processor for demodulation. The mobile communication module 150 can also amplify the signals modulated by the modem processor and convert them into electromagnetic waves for radiation via the antenna 1. In one embodiment, at least some of the functional modules of the mobile communication module 150 can be located in the processor 110. In another embodiment, at least some of the functional modules of the mobile communication module 150 and at least some of the modules of the processor 110 can be located in the same device.

[0135] 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-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 a sound signal through an audio device or displays an image or video through the display screen 130. In one embodiment, the modem processor may be an independent device. In another embodiment, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0136] 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 electronic 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.

[0137] In one embodiment, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with a network and other devices through wireless communication technology. The 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. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0138] The sensor module 170 may include at least one sensor, such as a pressure sensor and / or a touch sensor, an acceleration sensor, a gyroscope sensor, a distance sensor, a fingerprint sensor, and the like. Among them, the pressure sensor is used to sense the pressure signal and can convert the pressure signal into an electrical signal. The pressure sensor and / or the touch sensor can be set on the display screen 130. When a touch operation is applied to the display screen 130, the electronic device 100 can detect the touch operation (for example, including position and intensity) according to the touch sensor and / or the pressure sensor, and the touch operation can be transmitted to the application processor to determine the type of touch event. Optionally, a visual output related to the touch operation can be provided through the display screen 130.

[0139] FIG3 exemplarily shows a schematic diagram of the architecture of an electronic device 100 .

[0140] As shown in FIG3 , the electronic device 100 may include a user space, an operating system kernel, and device hardware.

[0141] The user space is a part of the operating system that can be used to run applications, such as audio applications, housekeeper applications, and compression applications. The compression application in this application can be a system application of the electronic device 100 or a third-party application. The compression application in this application can be an independent application or a functional module integrated into other applications. The application in this application can also be replaced by other software such as applets and atomic services.

[0142] The operating system kernel is the kernel / core part of the operating system / software system of the electronic device 100, responsible for managing hardware resources, providing system services and drivers, and supporting the operation of applications. The software system of the electronic device 100 can be an Android system, a Harmony system, or other software systems. The operating system kernel can include a compression file system, which is a module that compresses and decompresses data at the file system level. Optionally, the compression file system is for application data. In one embodiment, the software system of the electronic device 100 is an Android system, and the compression file system can be an Android compression file system (ACFS), that is, a file system with data compression and decompression functions designed based on the Android kernel, the Android open source project, and ACS. Without limitation, the Android system / Android kernel / Android open source project can also be replaced by other software systems / kernels of other software systems / open source projects of other software systems, and the compression file system can be a compression file system of other software systems. The compression file system can include a compression module and a decompression module. The compression module is a module responsible for performing data compression operations in the compression file system, and can include the implementation of the compression algorithm and related compression parameter configurations. The decompression module is a software component or module responsible for performing data decompression operations in a compression file system, and may include the implementation of a decompression algorithm and related decompression parameter configurations.

[0143] In the present application, an electronic device can compress and / or decompress application data through a compression application in user space and a compression file system in the operating system kernel. For example, when the electronic device receives a user operation for the compression application, or when the compression application determines on its own that compression is required (for example, the compression application has preset periodic compression rules), the electronic device can access the application data of the electronic device by triggering a compression module in the compression file system, and then formulate a dedicated compression strategy for the application data, and finally execute the compression process.

[0144] In the present application, for different categories of application data, the compression module can use different parameters and methods to determine different compression algorithms, and use the determined compression algorithms to compress the application data. In one embodiment, the compression module can include an access statistics module and a classification compression module, wherein the access statistics module can be used to collect and count the application data accessed by the application during operation, thereby determining which application data is frequently accessed (i.e., determining hot data) and which application data is rarely accessed (i.e., determining cold data). For the hot data and cold data obtained by the access statistics module, the classification compression module can use different parameters and methods to determine different compression algorithms, so that when hot data is compressed, the compression time can be as short as possible under a limited compression rate, and when cold data is compressed, the compression rate can be as good as possible under a limited compression time, that is, the best compression effect is achieved for different categories of application data. Not limited to the above embodiment, the compression module classifies the application data by itself. In another embodiment, the application data can also be classified by other modules, and the compression module can receive the classified application data sent by other modules. In some examples, the access statistics module is a module independent of the compression module.

[0145] Device hardware refers to the physical components or parts of electronic device 100. Device hardware may include memory, such as an SSD or SD card, which can be used to store raw and / or compressed application data. Without limitation, device hardware may also include a processor, an external storage interface, a display, a sensor module, a communication module, and the like. For specific examples, see the description of FIG. 2 above.

[0146] The following describes the application scenarios involved in the embodiments of the present application and user interface examples in these scenarios.

[0147] FIG4 exemplarily shows a user interface diagram of a lossless compression application scenario.

[0148] As shown in (A) of Figure 4, the electronic device 100 can display a user interface 410 of a housekeeper application. The housekeeper application can be a system application of the electronic device 100 or a third-party application. The user interface 410 may include a title "Clean and Speed ​​Up", a card 411 indicating storage space, a card 412 for file compression, a card 413 for application compression, and multiple cards 414 for file cleaning. Card 411 may include the proportion of storage space used in the electronic device 100 to the total storage space (for example, 82%) and related instructions. Card 412 may include the number and size of files that can be compressed in the electronic device 100, and a control 412A for triggering lossless compression of files in the electronic device 100. Card 413 may include the number of apps that can be compressed in the electronic device 100 and the amount of compressed data, as well as a control 413A for triggering lossless compression of apps in the electronic device 100. Multiple cards 414 include, for example, a card for cleaning up junk files, a card for cleaning up the contents of the gallery application, a card for cleaning up online videos, and the like. In one embodiment, the electronic device 100 can display a user interface applying lossless compression in response to a user operation (e.g., a touch operation, such as a click operation) acting on the control 413A. For a specific example, see the user interface 420 shown in (B) of Figure 4.

[0149] As shown in (B) of Figure 4, the user interface 420 may include an explanation 421 of applying lossless compression, compression information 422, and an application list 423. The explanation 421 is "Through a new compression technology, the installed applications are losslessly compressed to release storage space without affecting the operation and use of the applications". The compression information 422 may include the function name "one-click compression", the function description "compress the data of all applications", and the function control of "one-click compression", which is used to trigger: using the compression method provided in the embodiment of the present application to losslessly compress the application data of all applications in the electronic device 100. The list 423 may include options for multiple applications installed on the electronic device 100 (such as music, email, gallery, browser, video, etc.). The browser options are used as an example for explanation, and the options for other applications are similar. The browser options may include a browser icon 423A, the browser name 423B, a "one-click compression" control 423C, and a "view more" control 423D. Among them, control 423C is used to trigger: using the compression method provided in the embodiment of the present application to losslessly compress the application data of the browser, and control 423D is used to trigger viewing the information of the application data of the browser. List 423 can be used to display more application options in response to a user operation (the user operation is, for example, a sliding operation, and the sliding operation is, for example, sliding from bottom to top). In one embodiment, the electronic device 100 can display the compression information of the application data of the browser in response to a user operation (such as a touch operation, and the touch operation is, for example, a click operation) acting on the control 423D. For a specific example, see the user interface 430 shown in (C) of Figure 4. Optionally, before the electronic device 100 displays the user interface 430 shown in (C) of Figure 4, it can receive a user operation (such as a touch operation, and the touch operation is, for example, a click operation) acting on the "one-key compression" function control in the compression information 422. In response to the user operation, the compression method provided in the embodiment of the present application is used to compress the application data of all applications of the electronic device 100. Alternatively, before the electronic device 100 displays the user interface 430 shown in (C) of Figure 4, it can receive a user operation (such as a touch operation, such as a click operation) acting on the control 423C, and in response to the user operation, use the compression method provided in the embodiment of the present application to compress the application data of the browser of the electronic device 100.

[0150] As shown in FIG4(C), user interface 430 may include a title (i.e., "Browser"), a description 431 of lossless compression, a list 432 of "frequently accessed" application data, and a list 433 of "infrequently accessed" application data, indicating that the current interface is used to display browser compression information. Description 431 reads, "Using new compression technology, different compression methods are used for frequently accessed and infrequently accessed application data within the application. For example, infrequently accessed application data has a higher compression rate." List 432 is used to display information about multiple frequently accessed hot data within the browser. List 433 is used to display information about multiple less frequently accessed cold data within the browser. Information about any application data in lists 432 and 433 includes, for example, the name of the application data (which may be referred to as the file name), the size of the application data before compression (which may be referred to as the original size), and the size of the application data after compression (which may be referred to as the compressed size). The compressed size shown is the size of the data after the most recent compression, indicating that user interface 430 is used to display information about the browser's application data after the most recent compression. For example, list 432 includes information 432A for image 1: name "aaa.jpg," original size "15.8 MB," and compressed size "13.5 MB." Therefore, the compression ratio (i.e., the ratio of compressed size to original size) for image 1 is approximately 0.85. List 433 includes information 433A for image 2: name "fff.png," original size "14.7 MB," and compressed size "8.5 MB." Therefore, the compression ratio for image 2 is approximately 0.57. It can be seen that the compression ratio for hot data image 1 is greater than that for cold data image 2.

[0151] In one embodiment, after the embodiment shown in FIG4 , the access frequency of some application data in the browser may change, for example, from hot data to cold data, or from cold data to hot data. For example, the access frequency of application data changes after the electronic device 100 has been used for half a month. In this case, when the electronic device 100 compresses the application data of the browser in response to the user operation (which can be understood as a new compression), the compression algorithm used to compress the application data after the above-mentioned change in access frequency is different from the compression algorithm used to compress the application data before the change in access frequency (which can be understood as the old compression). Therefore, for the same application data, the compressed size after the above-mentioned new compression is different from the previous compressed size (i.e., the compressed size after the above-mentioned old compression).

[0152] Exemplarily, after the implementation shown in FIG4 , the access frequency of picture 1 and picture 2 in the browser changes. In this case, after the electronic device 100 re-compresses the application data of the browser, an example of the compression information of the application data of the browser displayed can be seen in the user interface 510 shown in FIG5 . The user interface 510 is similar to the user interface 430 shown in FIG4 (C), with the difference that, in the user interface 430, the information 432A of picture 1 is displayed in the list 432 of hot data, and the information 433A of picture 2 is displayed in the list 433 of cold data, while in the user interface 510, the information 433B of picture 1 is displayed in the list 433 of cold data, and the information 432B of picture 2 is displayed in the list 432 of hot data. In other words, picture 1 changes from hot data to cold data, and picture 2 changes from cold data to hot data. In user interface 510, the compressed size in information 433B of Picture 1 is "9.3 MB" (smaller than the compressed size of "13.5 MB" of Picture 1 in user interface 430), and therefore the corresponding compression ratio is approximately 0.59 (smaller than the compression ratio of 0.85 of Picture 1 in user interface 430). In user interface 510, the compressed size in information 432B of Picture 2 is "12.6 MB" (larger than the compressed size of "8.5 MB" of Picture 2 in user interface 430), and therefore the corresponding compression ratio is approximately 0.86 (larger than the compression ratio of 0.57 of Picture 1 in user interface 430).

[0153] Not limited to the above embodiment, in another embodiment, when the electronic device 100 displays the compression information of application data, it can also directly display the category of the application. For example, in the user interface 430 shown in FIG4 (C) and the user interface 510 shown in FIG5 , the information of any one of the application data in the list 432 and the list 433 can include the category of the application, that is, whether it is hot data or cold data. In another embodiment, when the electronic device 100 displays the compression information of application data, it can also display the historical compression size of the application data. For example, in the user interface 510 shown in FIG5 , the information 432B of picture 2 can include the historical compression size, that is, the compressed size of picture 2 in the user interface 430 shown in FIG4 (C) is "8.5MB", and the information 433B of picture 1 can include the historical compression size, that is, the compressed size of picture 1 in the user interface 430 shown in FIG4 (C) is "13.5MB".

[0154] The above embodiment is described using the example of user-triggered compression of application data. In another embodiment, the electronic device 100 can also scan the application / application data that needs to be compressed by itself, and use the compression method provided in this application to compress the scanned application data / scanned application data.

[0155] Not limited to the above implementation, in another implementation, the user may also select part of the application data in the application to perform lossless compression.

[0156] The compression method involved in this application is described based on the above embodiments. This method can be applied to the electronic device 100 or server 200 shown in Figure 1. This method can be applied to the electronic device 100 shown in Figure 2. This method can be applied to the electronic device 100 shown in Figure 3. The following describes the method using an electronic device as an example.

[0157] Please refer to Figure 6, which is a flow chart of a compression method provided by an embodiment of the present application. The process may include but is not limited to the following steps:

[0158] S101: The electronic device determines a first application of data to be compressed.

[0159] In one embodiment, the electronic device may determine the first application from multiple installed applications according to a preset rule. The parameters involved in the preset rule may include, but are not limited to, the amount of application data, the frequency of use, the type of application, etc. For example, an application whose amount of application data is greater than or equal to a preset threshold is determined as the first application. For another example, all installed applications are determined as the first application. In another embodiment, when the electronic device displays multiple options (indicating multiple installed applications respectively), it may receive a first user operation acting on a first option (indicating a first application) and determine the first application based on the first user operation. For example, as shown in FIG4 , the electronic device may determine the browser of the compressed electronic device based on the received user operation acting on the control 423C in the user interface 420.

[0160] S102: The electronic device classifies application data of the first application and obtains application data of category 1 and application data of category 2.

[0161] In one embodiment, the electronic device may evaluate the compression requirements of different application data based on the usage / application scenarios of the different application data in the first application, thereby classifying the application data. Category 1 application data is application data that the electronic device assesses as requiring low compression time, and Category 2 application data is application data that the electronic device assesses as requiring a good compression ratio (i.e., a low compression ratio).

[0162] In one embodiment, the above-mentioned usage condition / application scenario may be the frequency of application access to application data. In some examples, the electronic device may classify the application data of the first application based on the frequency of the first application accessing the application data. If the access frequency of application data in category 1 is greater than or equal to a first frequency threshold, and the access frequency of application data in category 2 is less than a second frequency threshold, and the first frequency threshold is greater than or equal to the second frequency threshold, it can be understood that the first application data in the first category is hot data, and the second application data in the second category is cold data.

[0163] Without limitation, in another embodiment, the above-mentioned usage conditions / application scenarios may also include the frequency of application data modification by the application, the data type of the application data, the function of the application data in the application, and labels set by the user for the application data. In some examples, the electronic device may preset Label 1 and Label 2, and the user may operate the electronic device to set labels for different application data of the first application. Application data that the user believes requires less time-consuming compression may be set to Label 1, and application data that the user believes requires a better compression rate may be set to Label 2. The electronic device may determine that application data with Label 1 is application data of Category 1, and that application data with Label 2 is application data of Category 2.

[0164] S103: The electronic device determines compression algorithm 1 based on selection criterion 1 (related to compression time) corresponding to category 1, and determines compression algorithm 2 based on selection criterion 2 (related to compression rate) corresponding to category 2.

[0165] In one embodiment, the electronic device may use different methods (including selection criteria) and parameters to determine the compression algorithms used for different categories of application data: Compression algorithm 1 is used to compress category 1 application data, and compression algorithm 2 is used to compress category 2 application data.

[0166] In one embodiment, application data of category 1 may include application data of multiple data types, and compression algorithm 1 may include multiple compression algorithms, each of which is used to compress application data of multiple data types in the application data of category 1. In one embodiment, application data of category 2 may include application data of multiple data types, and compression algorithm 2 may include multiple compression algorithms, each of which is used to compress application data of multiple data types in the application data of category 2.

[0167] In one embodiment, the electronic device may determine the selection criteria for the compression algorithm based on the different compression requirements of different categories of application data. That is, for different categories of application data, the electronic device may use different selection criteria for the compression algorithm. For example, for the compression requirement of category 1 application data (i.e., low compression time), the electronic device may determine the selection criteria 1 related to compression time so that the compression algorithm determined based on the selection criteria 1 can meet the compression requirement of category 1 application data; for the compression requirement of category 2 application data (i.e., good compression ratio), the electronic device may determine the selection criteria 2 related to compression ratio so that the compression algorithm determined based on the selection criteria 2 can meet the compression requirement of category 2 application data.

[0168] In one embodiment, the electronic device may be preset with an algorithm experience library, which may be used to store a plurality of compression algorithms and the relevant parameters of each compression algorithm. The relevant parameters of the compression algorithm may be empirical values ​​obtained through multiple uses / training. The relevant parameters of any compression algorithm may be calculated by the electronic device itself, or may be obtained by the electronic device from the cloud. The relevant parameters of the compression algorithm may include but are not limited to at least one of the following: DCC (the DCC corresponding to different data types may be different), compression speed (the compression speed corresponding to different data types may be different), decompression speed (the decompression speed corresponding to different data types may be different), and compression rate (the compression rate corresponding to different data types may be different). The electronic device may determine compression algorithm 1 and compression algorithm 2 from the plurality of algorithms in the algorithm experience library based on the relevant parameters of the compression algorithm in the algorithm experience library. An example of the algorithm experience library can be seen in Table 1 below.

[0169] Table 1

[0170] The algorithm experience library may include compression algorithm 3, compression algorithm 4, and related parameters of compression algorithm 3 and compression algorithm 4. The related parameters of compression algorithm 3 include DCC311, compression speed 312, and compression ratio 313 corresponding to data type 1, and DCC321, compression speed 322, and compression ratio 323 corresponding to data type 2. The related parameters of compression algorithm 4 include DCC411, compression speed 412, and compression ratio 413 corresponding to data type 1, and DCC421, compression speed 422, and compression ratio 423 corresponding to data type 2.

[0171] In one embodiment, for application data of category 1, the electronic device may determine compression algorithm 1 from multiple compression algorithms in the algorithm experience library based on the data type of the application data and the DCC in the algorithm experience library. Optionally, for each data type of application data in category 1, the electronic device may search the algorithm experience library for the DCC corresponding to the data type (i.e., the DCC corresponding to the data type in the relevant parameters of the multiple compression algorithms), filter out the smallest DCC from the found DCCs, and finally determine the compression algorithm corresponding to the smallest DCC as the compression algorithm used to compress the application data of the data type (belonging to the first application data).

[0172] In some examples, application data of category 1 includes application data of data type 1 and application data of data type 2. For application data of data type 1, the electronic device can determine from the algorithm experience library shown in Table 1 above: DCC311 corresponding to data type 1 in the relevant parameters of compression algorithm 3, and DCC411 corresponding to data type 1 in the relevant parameters of compression algorithm 4, and determine the smaller DCC (assuming DCC311) from DCC311 and DCC411, and determine compression algorithm 3 corresponding to DCC311 as the compression algorithm for compressing application data of data type 2. Similarly, for application data of data type 2, the electronic device can determine from the algorithm experience library shown in Table 1 above: DCC321 corresponding to data type 2 in the relevant parameters of compression algorithm 3, and DCC421 corresponding to data type 2 in the relevant parameters of compression algorithm 4, and determine the smaller DCC (assuming DCC421) from DCC321 and DCC421, and determine compression algorithm 4 corresponding to DCC421 as the compression algorithm for compressing application data of data type 2.

[0173] In one embodiment, for application data of category 2, the electronic device can determine compression algorithm 2 from multiple compression algorithms in the algorithm experience library based on the data type of the application data, the weighted compression delay and the compression rate in the algorithm experience library. Among them, the weighted compression delay of application data of category 2 is the total compression time calculated based on the weighted calculation of the data type ratio. The expression has been shown in the description of the weighted compression delay. The difference is that the Files in the above expression are application data of category 2. Based on the expression of the weighted compression delay CompressDelay, it can be obtained that for the same Files, the main parameter for calculating CompressDelay is the compression speed Speed. c It is understandable that the compression speed corresponding to different compression algorithms is Speed cDifferent, so the obtained CompressDelay is also different. Therefore, any CompressDelay can correspond to a set of compression algorithms. The compression speed corresponding to this set of compression algorithms is the compression speed used to calculate the current CompressDelay. Optionally, the electronic device presets the maximum compression time T for category 2 application data. max , the electronic device can obtain a weighted compression delay CompressDelay that is less than or equal to the preset maximum compression time T max A plurality of compression algorithms are selected, and a group of compression algorithms with a better compression ratio (ie, a lower compression ratio) is selected from the plurality of compression algorithms. The group of compression algorithms is compression algorithm 2.

[0174] In some examples, application data of category 2 includes application data 1 of data type 1 and application data 2 of data type 2. For application data 1 of data type 1, the electronic device can determine from the algorithm experience library shown in Table 1 above: the compression speed 312 and compression ratio 313 corresponding to data type 1 in the relevant parameters of compression algorithm 3, and the compression speed 412 and compression ratio 413 corresponding to data type 1 in the relevant parameters of compression algorithm 4. For application data 2 of data type 2, the electronic device can determine from the algorithm experience library shown in Table 1 above: the compression speed 322 and compression ratio 323 corresponding to data type 2 in the relevant parameters of compression algorithm 3, and the compression speed 422 and compression ratio 423 corresponding to data type 2 in the relevant parameters of compression algorithm 4. Then, the electronic device can calculate the weighted compression delay CompressDelay′ of the application data of category 2 based on the compression speed obtained above (taking application data 1 as easy-to-compress data and application data 2 as difficult-to-compress data as an example for explanation), and the specific expression is as follows:

[0175] Wherein, Size1 is the data size of application data 1 of data type 1, and Size2 is the data size of application data 2 of data type 2. Speed1 is the compression speed corresponding to data type 1, which may be compression speed 312 or compression speed 412 described above. Speed2 is the compression speed corresponding to data type 2, which may be compression speed 322 or compression speed 422 described above. P1 is the ratio of application data 1 to application data of category 2, P2 is the ratio of application data 2 to application data of category 2, and K2 is the ratio of compressed application data in application data 2 to application data 2. P1, P2, and K2 are all greater than 0 and less than or equal to 1, and P1 + P2 = 1.

[0176] It can be understood that the expression of CompressDelay′ does not show K1 (i.e., 1), which indicates that all application data 1 that is easily compressible data will be compressed. K2 is greater than 0 and less than or equal to 1, which indicates that part or all of the application data in application data 2 that is difficult to compress will be compressed, that is, the application data of K2 in application data 2 will be compressed. In one embodiment, P2 is related to K2. For example, when P2 is less than a preset ratio threshold, K2 is 1, and when P2 is greater than the preset ratio threshold, K2 is less than 1. In other words, when the proportion of difficult-to-compress data is small, all the difficult-to-compress data can be compressed. When the proportion of difficult-to-compress data is large, only part of the difficult-to-compress data can be compressed, so as to better balance the compression benefit and compression time.

[0177] Speed1 is the compression speed corresponding to the compression algorithm used to compress application data 1 (referred to as candidate algorithm 1). When candidate algorithm 1 is different, Speed1 is different. For example, when candidate algorithm 1 is compression algorithm 3, Speed1 is a compression speed of 312; when candidate algorithm 1 is compression algorithm 4, Speed1 is a compression speed of 412. Similarly, Speed2 is the compression speed corresponding to the compression algorithm used to compress application data 2 (referred to as candidate algorithm 2). When candidate algorithm 2 is different, Speed2 is different. For example, when compression algorithm 1 is compression algorithm 3, Speed2 is a compression speed of 322; when compression algorithm 4 is compression algorithm 4, Speed2 is a compression speed of 422. Therefore, different candidate algorithms 1 and 2 (referred to as different groups of candidate algorithms) will calculate different CompressDelay′ for application data of category 2.

[0178] The electronic device has a preset maximum compression time T for category 2 application data. max , electronic devices can first filter out those that satisfy CompressDelay′≤T max Multiple groups of candidate algorithms can be selected. The electronic device can then select a group of candidate algorithms with better compression rates from these multiple groups of candidate algorithms. For example, the relevant parameters of candidate algorithm 1 have a better compression rate for data type 1, and the relevant parameters of candidate algorithm 2 have a better compression rate for data type 2. In the resulting group of candidate algorithms, candidate algorithm 1 is the compression algorithm for compressing application data 1 of data type 1, and candidate algorithm 2 is the compression algorithm for compressing application data 2 of data type 2.

[0179] In some examples, the compression ratio is preferably the lowest compression ratio. In other examples, the compression ratio is preferably in the first H positions (H is a positive integer) when arranged from small to large. In other examples, the compression ratio is preferably greater than or equal to a preset compression ratio threshold. In other examples, the compression ratio can be determined by combining CompressDelay′ and the compression ratio. For example, assuming there are two groups of candidate algorithms, one of which has a smaller compression ratio but a larger CompressDelay′ (still less than T max ), another group of candidate algorithms has a higher compression ratio but a smaller CompressDelay′. In this case, the latter can be selected, that is, the candidate algorithm with a smaller compression ratio and a correspondingly smaller CompressDelay′ can be selected. This can be understood as selecting a compression algorithm based on the standard of balancing compression time and compression ratio.

[0180] S104: The electronic device compresses the application data of category 1 using compression algorithm 1, and compresses the application data of category 2 using compression algorithm 2.

[0181] In one embodiment, the application data of category 1 includes application data of multiple data types, and compression algorithm 1 includes multiple compression algorithms corresponding to the multiple data types. The electronic device uses compression algorithm 1 to compress the application data of category 1, including: the electronic device can use each compression algorithm in compression algorithm 1 to compress the application data of the corresponding data type in the application data of category 1. In one embodiment, the application data of category 2 includes application data of multiple data types, and compression algorithm 2 includes multiple compression algorithms corresponding to the multiple data types. The electronic device uses compression algorithm 2 to compress the application data of category 2, including: the electronic device can use each compression algorithm in compression algorithm 2 to compress the application data of the corresponding data type in the application data of category 2.

[0182] In one embodiment, before S104, the electronic device may determine the parameters of compression algorithm 1 based on the hardware performance of the electronic device and selection criterion 1, and determine the parameters of compression algorithm 2 based on the hardware performance of the electronic device and selection criterion 2. In some examples, for the same compression algorithm, the compression speed may be different when compressing the same file on devices with different hardware performance. The electronic device may determine the parameters of the compression algorithm that best suits the current system environment based on its own hardware performance (e.g., processor performance). In some examples, for the same compression algorithm, when the parameters are different, the compression speed may be different at the same compression rate, and / or the compression rate may be different at the same compression speed. The electronic device may determine the parameters of the compression algorithm based on the selection criteria corresponding to each category (e.g., preferring low time consumption or high returns) so as to further meet the compression requirements of the current category of application data when using the compression algorithm. In this way, the compression speed can be improved while ensuring the compression rate, thereby achieving optimization of data compression.

[0183] In one embodiment, the application data of the first application includes multiple dex files. Before S104, the electronic device may preprocess the multiple dex files first, and then compress the preprocessed files. In some examples, the preprocessing method may be to split and reorganize according to the structure. The electronic device may obtain multiple index files, and any one of the multiple index files may be called index file 1, and index file 1 includes the content of the segmented block named 1 in the above multiple dex files. For example, any two dex files in the multiple dex files are dex file 1 and dex file 2, and the names of the multiple segments in dex file 1 are respectively the same as the names of the multiple segments in dex file 2, and index file 1 includes the content of segmented block 1 in dex file 1 and the content of segmented block 2 in dex file 2, and the names of segmented block 1 and segmented block 2 are the same, both named 1. Any segmented block in the dex file may be the header of the dex file, any list in the index area, or the data area. Optionally, the electronic device may delete the multiple dex files of the first application and only retain the multiple index files obtained by preprocessing. It can be understood that the above-mentioned multiple index files are respectively content collections of the segments with different names in the multiple dex files. Based on the structural characteristics of the dex file, such a preprocessing method can allow the segments with the same name (the "function" is also the same) to be stored together, and the segments with different names to be stored separately, thereby improving the analysis and processing efficiency of the dex file. In S104, the electronic device can compress the preprocessed file, that is, compress the multiple index files obtained above, which can be understood as compressing the index files that are better processed, so as to achieve better compression rate and shorter compression time. For a specific description of the preprocessing process of the dex file, please refer to Figure 7 below.

[0184] In one embodiment, the application data of the first application includes at least one .so file, that is, the electronic device includes at least one .so file that can be called by the first application (it can also be said that the electronic device includes at least one .so file corresponding to the first application). Before S104, the electronic device can first pre-process the at least one .so file and then compress the pre-processed .so file. In some examples, the pre-processing method can be to remove duplicates by name. Any of the at least one .so file can be referred to as .so file 1. The electronic device can query whether there is a .so file with the same name as .so file 1. If there is a .so file 2 with the same name as .so file 1, it can delete .so file 1 or .so file 2, that is, delete duplicate and redundant .so files. After such pre-processing, there are no multiple .so files with the same name corresponding to the first application in the dynamic link library repository. Based on the specific application scenarios and functions of the .so files, such pre-processing methods can avoid the waste of storage resources caused by .so files with duplicate names (with the same content and functions) and optimize the storage and management of .so files. In S104, the electronic device can compress the pre-processed .so file to avoid the waste of processing and storage resources caused by compressing duplicate .so files, thereby achieving a better compression rate and shorter compression time. For a detailed description of the preprocessing process of the so file, please refer to Figure 9 below.

[0185] In the above method, the electronic device can evaluate the actual compression requirements of different application data in the first application, and classify the different categories of application data with different compression requirements, and then use different selection criteria and different methods to determine the compression algorithms of different categories of application data, so that the determined compression algorithm can meet the compression requirements of the current category of application data. The embodiment of the present application does not simply preset corresponding compression algorithms for different categories of application data, but classifies the application data according to actual conditions (such as real-time access frequency), and determines the compression algorithms used for different categories of application data according to actual conditions (such as data type / data type ratio, data size, compression speed) and using different methods. It can be understood as adjusting the compression strategy in real time, so as to achieve both the benefits and time consumption of compression for different categories of application data, and can well meet actual needs. The embodiment of the present application does not pre-compress each application data and evaluate the pre-compression results according to the set indicators, but presets an algorithm experience library, and directly selects the compression algorithm according to the parameters in the algorithm experience library, reducing time cost and processing cost, and having higher device availability. The compression method provided by the present application can effectively meet the various needs of users for data compression, that is, it provides users with an efficient, convenient and flexible compression solution.

[0186] Moreover, the electronic device can execute S101 on its own without user triggering, which can be understood as providing a function of automatically and transparently compressing application data. The user does not need to worry about the compression of application data. The system can automatically manage and optimize the storage space of the electronic device for the user, which is more intelligent and improves the user experience.

[0187] Please refer to Figure 7, which is a flowchart of a dex file preprocessing process provided by an embodiment of the present application. The process may include but is not limited to the following steps:

[0188] S201: The electronic device traverses the dex file of the first application to obtain an application identification (Identity document, ID) (AppID), a dex identification (dexID), and a split block identification (splitID).

[0189] In one embodiment, the electronic device may traverse the dex files in the program package of the first application (e.g., an Android application package (APK)). The traversal process includes traversing the components of each dex file (e.g., a header, an index area, and a data area). The traversal process may obtain: the AppID of the first application, the identifier of each dex file in the first application (i.e., a dexID), and the identifier of each split block in the dex file (i.e., a splitID). In some examples, any split block may be a header of the dex file, any list in the index area of ​​the dex file, or the data area of ​​the dex file.

[0190] S202: The electronic device obtains the storage location of each segmentation block in each dex file according to the application identifier, the dex identifier, and the segmentation block identifier.

[0191] In one embodiment, the electronic device can obtain the storage path of each dex file and the storage location of each split block in each dex file based on the AppID, dexID, and splitID obtained in S101. In some examples, the electronic device can use a read file pointer to obtain a file operation pointer of the dex storage path, and then obtain the file pointer offset and range of each split block in the corresponding dex file based on the information in the dex file header, that is, obtain the storage location of each split block.

[0192] S203: The electronic device reads the content of each segmented block according to the storage location of each segmented block, and stores the read content into a corresponding index file (segmented blocks with the same name correspond to the same index file) to obtain multiple index files.

[0193] In one embodiment, the electronic device can read the content of the current segmented block (for example, obtain a binary stream) based on the file pointer offset and range of each segmented block in the dex file to which it belongs. The electronic device can also obtain the name of the current segmented block. The electronic device can store the read content of the current segmented block in the index file corresponding to the name of the segmented block. It can be understood that the preprocessing process of multiple dex files of the first application may include: storing the contents of the segments with the same name (the same function) in different dex files in the same index file, and storing the contents of the segments with different names (different functions) in different index files. Therefore, multiple index files are obtained by preprocessing multiple dex files of the first application.

[0194] In one embodiment, the split blocks of each dex file may include: the header of the current dex file (1 split block), each list in the index area of ​​the current dex file (each list is 1 split block), and the data area of ​​the current dex file (1 split block). An example of the preprocessing process in this case can be seen in Figure 8 below. Figure 8 takes the preprocessing of two dex files (classesa.dex and classesb.dex) as an example for explanation.

[0195] As shown in Figure 8, classesa.dex and classesb.dex both include a header, an index area, and a data area. The index area includes a string identifier list (string_ids) (describing the strings in the corresponding dex file), a type identifier list (type_ids) (used to describe the data types in the corresponding dex file), a prototype identifier list (proto_ids) (used to describe the method prototypes in the corresponding dex file), a field identifier list (field_ids) (used to describe the fields referenced by the corresponding dex file), a method identifier list (method_ids) (used to describe the methods in the corresponding dex file), and a class identifier list (class_ids) (used to describe the classes in the corresponding dex file). It can be understood that the index area can also include more or fewer lists, which is not limited in this application. The dex file can also include more content, which is not limited in this application.

[0196] As shown in Figure 8, the electronic device can store the headers of the two dex files in the same index file (index, the suffix can be abbreviated as idx) (the current index file can be called header.idx). The electronic device can store the lists with the same name in the index areas of the two dex files in the same index file, specifically including: storing the string_ids in the index areas of the two dex files in the same index file (which can be called string.idx), storing the type_ids in the index areas of the two dex files in the same index file (which can be called type.idx), storing the proto_ids in the index areas of the two dex files in the same index file (which can be called proto.idx), storing the field_ids in the index areas of the two dex files in the same index file (which can be called field.idx), storing the method_ids in the index areas of the two dex files in the same index file (which can be called method.idx), and storing the class_ids in the index areas of the two dex files in the same index file (which can be called class.idx). The electronic device may store the data areas of the two dex files in the same index file (which may be called data.idx).

[0197] It can be understood that the multiple index files obtained by preprocessing multiple dex files are used to store data of different "functions" (such as different types) in these multiple dex files. The electronic device can compress the multiple index files obtained by preprocessing instead of directly compressing multiple dex files. This preprocessing method can significantly improve the efficiency of dex file processing and analysis, thereby achieving better compression rate and shorter compression time, and optimizing the use of storage space.

[0198] The above implementation manner is described by taking the example of preprocessing the multiple dex files of the first application after determining the first application to be compressed. In another implementation manner, the dex files of multiple applications of the electronic device can also be preprocessed together before determining the first application. For example, in S201 of Figure 7, the electronic device will traverse the installed applications, and the traversal process can obtain: AppIDs of multiple applications, dexIDs of multiple dex files in each application, and splitIDs of multiple split blocks in each dex file. In S203 of Figure 7, the electronic device will process the multiple dex files of each application to obtain multiple index files corresponding to each application. In another implementation manner, the electronic device can also perform a dex file preprocessing process on part of the application data in an application, which is not limited in the embodiment of the present application.

[0199] Please refer to Figure 9, which is a flowchart of a preprocessing process of an .so file provided in an embodiment of the present application. The process may include but is not limited to the following steps:

[0200] S301: The electronic device traverses the so file of the first application to obtain an application identifier (AppID) and a so identifier (soID).

[0201] In one embodiment, the electronic device may traverse the so files in the program package (eg, APK) of the first application and obtain: the AppID of the first application and an identifier (ie, soID) of each so file corresponding to the first application.

[0202] S302: The electronic device obtains information (including name) of each so file according to the application identifier and the so identifier.

[0203] S303: For each so file, the electronic device searches the dynamic link library hash table to see whether there is a so file with the same name as the so file.

[0204] In one embodiment, the dynamic link library hash table may include the name of the so file, the number of references (i.e., the number of APPs that can call the current so file), a file pointer (used to indicate the storage location of the current so file) and an APP pointer (used to indicate the APP hash table corresponding to the current so file, and the APP hash table includes information about the APP that can call the current so file). For a specific example, see Figure 10.

[0205] As shown in Figure 10, the dynamic link library hash table may include relevant information of the so file named "so_1" (which may be simply referred to as the so_1 file) and relevant information of the so file named "so_2" (which may be simply referred to as the so_2 file). In the dynamic link library hash table, the relevant information of the so_1 file includes: name (so_1), number of references (2), file pointer 1, and APP pointer 1. The relevant information of the so_2 file includes: name (so_2), number of references (3), file pointer 2, and APP pointer 2. The dynamic link library warehouse includes the so_1 file and the so_2 file. File pointer 1 indicates the storage location of the so_1 file in the dynamic link library warehouse, and file pointer 2 indicates the storage location of the so_2 file in the dynamic link library warehouse. APP pointer 1 indicates the APP hash table 1 corresponding to the so_1 file. APP hash table 1 includes the identifiers of two applications that can call the so_1 file: APP11 and APP12. APP pointer 2 indicates APP hash table 2 corresponding to the so_2 file. APP hash table 2 includes identifiers of three applications that can call the so_2 file: APP21, APP22, and APP23.

[0206] In one embodiment, for each so file corresponding to the first application, the electronic device can query in the dynamic link library hash table whether there is a so file with the same name as the so file (with the same function and content). It can be understood that the default dynamic link library hash table and the dynamic link library warehouse do not record the information of the so file corresponding to the first application. When there is a so file with the same name (assuming it is name 2), the electronic device can search for the so file with name 1 in the dynamic link library warehouse, that is, execute S304. When there is no so file with the same name, the relevant information of the so file with name 2 can be added to the dynamic link library hash table, that is, execute S306.

[0207] S304: The electronic device searches for the so file with name 2 in the dynamic link library warehouse.

[0208] In one embodiment, when there is a so file with the same name (name 2) in the dynamic link library hash table, the electronic device can obtain a file pointer of the so file with name 2, and query whether there is a so file with name 2 in the dynamic link library warehouse based on the file pointer. When there is a so file with name 2 in the dynamic link library warehouse, the electronic device can determine that there are currently redundant so files with name 2, that is, the electronic device includes multiple so files with name 2: the so file with name 2 corresponding to the first application and the so file with name 2 in the dynamic link library warehouse. The electronic device can delete the redundant so files with name 2, that is, execute S305.

[0209] In one embodiment, when there is a so file with name 2 in the dynamic link library warehouse, the electronic device can increase the number of references of the so file with name 2 in the dynamic link library hash table by 1, and add information of the first application in the APP hash table corresponding to the so file with name 2.

[0210] S305: The electronic device deletes the redundant so file with the name 2.

[0211] In one embodiment, when there is an extra so file named 2, the electronic device can delete the so file named 2 corresponding to the first application and only retain the so file named 2 in the dynamic link library warehouse. In one embodiment, when the dynamic link library warehouse stores multiple so files named 2, the electronic device can only retain one and delete the other files.

[0212] S306: The electronic device adds relevant information of the so file with name 2 to the dynamic link library hash table.

[0213] In one embodiment, when there is no so file with the same name (name 2) in the dynamic link library hash table, the electronic device can add a table entry of the so file with name 2 to the dynamic link library hash table. The table entry of the so file with name 2 includes: name 2, number of references (i.e. 1), file pointer 3 (indicating the storage location of the so file with name 2 in the dynamic link library warehouse), and APP pointer 3 (indicating the APP hash table corresponding to the so file with name 2 created above). In addition, the electronic device can store the so file with name 2 in the dynamic link library warehouse, and create an APP hash table (including information of the first application) corresponding to the so file with name 2.

[0214] Not limited to the above embodiment, in another embodiment, in S304, if the electronic device does not search for the so file with name 2 in the dynamic link library warehouse, S306 may be executed.

[0215] After the implementation shown in Figure 9, the electronic device can obtain the pre-processed dynamic link library warehouse, dynamic link library hash table, and APP hash table. The electronic device can compress these files, that is, compress the files after "deduplicated so files", so as to achieve better compression rate and shorter compression time, and optimize the use of storage space.

[0216] The above implementation method is described by taking the example of preprocessing multiple so files of the first application after determining the first application to be compressed. In another implementation method, preprocessing can also be performed before determining the first application. For example, the preprocessing process shown in Figure 9 is executed after each application is installed. The present application does not limit the timing of preprocessing. In another implementation method, the electronic device can also perform the so file preprocessing process on part of the application data in an application. The embodiment of the present application does not limit this.

[0217] Please refer to Figure 11, which is a flowchart of another compression method provided by an embodiment of the present application. The process may include but is not limited to the following steps:

[0218] S401: The electronic device identifies that the category of first application data is the first category.

[0219] In one embodiment, the first application data may be uncompressed application data in a first application of the electronic device, for example, application data that has not been compressed by an algorithm in an algorithm experience library of the electronic device.

[0220] In another embodiment, the first application data may be compressed application data in the first application of the electronic device. Optionally, it may be compressed by an algorithm in the algorithm experience library of the electronic device. Optionally, it may be compressed by other algorithms. For example, the downloaded installation package of the first application includes compressed application data.

[0221] In another embodiment, the first application data is all application data of the first application of the electronic device, and the first application data can be understood as the entire first application.

[0222] In one embodiment, the electronic device can identify the category of the first application data based on the access frequency of the first application data. In some examples, when the access frequency of the first application data is greater than or equal to the first frequency threshold, the first category of the identified first application data is hot data, and when the access frequency of the first application data is less than the second frequency threshold, the first category of the identified first application data is cold data. The access frequency of the above-mentioned first application data can be the frequency of the electronic device accessing the first application data, or it can be the frequency of the electronic device accessing the first application, such as the case where the first application data is all application data of the first application. Not limited to this, the category of the first application data can also be identified in other ways. For the relevant description of S401, please refer to the description of S102 in Figure 6, wherein Category 1 in Figure 6 is hot data and Category 2 is cold data.

[0223] S402: The electronic device determines whether the following conditions are met: the identification of the category of the first application data is the first identification, or whether the identification of the category of the first application data is changed.

[0224] S402 is an optional step. In one embodiment, the electronic device may not execute S402 and directly execute S403 after executing S401.

[0225] In one embodiment, the electronic device can determine whether the identification of S401 meets condition 1 or condition 2, where condition 1 is that the identification of the category of the first application data described in S401 is the first identification, and condition 2 is that S401 identifies that the category of the first application data has changed, that is, the first category identified by S401 is different from the category of the first application data identified previously (such as the most recent time).

[0226] In one embodiment, when condition 1 is met, it can be considered that the compression method of the embodiment of the present application is triggered for the first application data for the first time, that is, the compression method of the embodiment of the present application has not been performed on the first application data before. When condition 2 is met, it can be considered that the category of the first application data has changed, for example, from cold data to hot data, or from hot data to cold data. When condition 1 or condition 2 is met, the electronic device can obtain the compression algorithm of the first application data and use the obtained compression algorithm to compress the first application data, for example, executing S403-S408.

[0227] In one embodiment, when condition 1 and condition 2 are not met, it can be considered that the compression method of the embodiment of the present application has been executed on the first application data before, and the category of the first application data has not changed. In this case, if the electronic device does not detect an event for triggering access to the first application data, the electronic device may not decompress and compress the first application data, which can be understood as keeping the compression state of the first application data unchanged. Without limitation to this, in another embodiment, if the electronic device detects an event for triggering access to the first application data, it can decompress the first application data to access the decompressed first application data.

[0228] S403: The electronic device determines a first selection criterion according to the first category.

[0229] In one embodiment, when the first category is hot data, the electronic device may determine that the first selection criterion is related to compression time, for example, to preferentially select a compression algorithm with a short compression time. When the first category is cold data, the electronic device may determine that the first selection criterion is related to compression rate, for example, to preferentially select a compression algorithm with a low compression rate.

[0230] S404: The electronic device determines a first compression algorithm according to a first selection criterion, a data size of the first application data, and a compression speed of the first application data.

[0231] In one embodiment, the electronic device may be pre-installed with an algorithm experience library. The algorithm experience library can be used to store multiple compression algorithms and related parameters of each compression algorithm. The related parameters may include, but are not limited to: compression speed (the compression speed corresponding to different data types may be different), decompression speed (the decompression speed corresponding to different data types may be different), DCC (the DCC corresponding to different data types may be different), and compression ratio (the compression ratio corresponding to different data types may be different). For a description of the algorithm experience library, please refer to the description of the algorithm experience library in S103 of Figure 6.

[0232] In one embodiment, the electronic device can determine the first compression algorithm based on the first parameter. The first parameter is related to the first ratio. Optionally, the first parameter is calculated based on the first ratio. The first ratio is the ratio of the data size of the first application data to the compression speed of the first application data. The compression speed of the first application data here is the compression speed corresponding to the data type of the first application data. Different compression algorithms correspond to different compression speeds of the first application data. The data size of the first application data here is the data size of the first application data before compression. The first parameter is related to the first selection criterion. When the first selection criterion is related to the compression time, the first parameter is DCC; when the first selection criterion is related to the compression rate, the first parameter is the weighted compression delay of the first application data.

[0233] In one embodiment, the electronic device may determine a second parameter (including the aforementioned first parameter) based on a first selection criterion, and determine a first compression algorithm based on the second parameter. When the first selection criterion is related to compression time, the second parameter is the first parameter, i.e., DCC; when the first selection criterion is related to compression rate, the second parameter includes a weighted compression delay of the first application data (i.e., the first parameter) and a compression rate of the first application data. Here, the compression rate of the first application data is the compression rate corresponding to the data type of the first application data, and different compression algorithms correspond to different compression rates of the first application data.

[0234] In one embodiment, for the first application data of the hot data, the electronic device can determine the first compression algorithm based on the DCC (i.e., the first parameter), for example, determining the first compression algorithm with the smallest DCC from multiple compression algorithms in the algorithm experience library. Combined with the above DCC formula, DCC is related to the compression time. DCC is the time required to save space under the condition of unit data size. DCC is the ratio of the first time length to the first data amount, wherein the first time length includes the first compression time length Time c and the first decompression time d The first compression duration is the size of the first application data before compression. o and compression speed c The first decompression time is the data size of the first application data before compression. o and decompression speed d The first data size is the data size of the first application data before compression. o and the compressed data size of the first application data c In some examples, the first application data includes data of a first data type, and the DCC used as the first parameter may specifically be the DCC corresponding to the first data type. For related explanations, see the description of category 1 application data (i.e., hot data) in S103 of FIG6 , as well as the description of how to determine compression algorithm 1.

[0235] In another embodiment, for the first application data of cold data, the electronic device may determine the first compression algorithm based on the weighted compression delay (i.e., the first parameter) and the compression ratio of the first application data. Optionally, the first application data includes the third application data, and the compression ratio here includes the compression ratio corresponding to the data type of the third application data. The weighted compression delay of the first application data here is related to the second compression duration and the first coefficient of the third application data, wherein the second compression duration is the ratio of the data size of the third application data before compression to the compression speed of the third application data, and the first coefficient is the proportion of the third application data to the first application data. In some examples, the first application data includes data of the second data type, and the compression ratio here can be specifically the compression ratio corresponding to the second data type, and the second compression duration here can be specifically: the ratio of the data size of the third application data before compression to the compression speed corresponding to the second data type. In some examples, based on the above-mentioned formula of weighted compression delay CompDelay, the original data size of the third application data is The compression speed corresponding to the data type of the third application data is: The second compression duration is The first coefficient is P n .

[0236] In some examples, the first application data includes fourth application data and fifth application data, the compression ratio of the fourth application data per unit time is less than or equal to a first compression threshold, the compression ratio of the fifth application data per unit time is greater than a second compression threshold, the first compression threshold is less than or equal to the second compression threshold, and the weighted compression delay of the first application data includes a first value and a second value, the first value is related to the fourth compression duration and the second coefficient of the fourth application data, the second value is related to the fifth compression duration and the third coefficient of the fifth application data, the fourth compression duration is the ratio of the data size of the fourth application data to the compression speed of the fourth application data (i.e., the compression speed corresponding to the data type of the fourth application data), the second coefficient is the ratio of the fourth application data to the first application data, the fifth compression duration is the ratio of the data size of the fifth application data to the compression speed of the fifth application data (i.e., the compression speed corresponding to the data type of the fifth application data), and the third coefficient is the ratio of the fifth application data to the first application data. Optionally, the second value is also related to the fourth coefficient, which is the ratio of the compressed application data in the fifth application data to the fifth application data. Optionally, the third coefficient is related to the fourth coefficient. When the third coefficient is less than a preset coefficient threshold, the fourth coefficient is 1. When the third coefficient is greater than or equal to the preset coefficient threshold, the fourth coefficient is less than 1. The expression of the weighted compression delay of the first application data can be referred to the expression of CompressDelay′ in S103 of Figure 6, wherein the fourth application data is application data 1 of data type 1, the fifth application data is application data 2 of data type 2, and the fourth compression duration of the fourth application data is The second coefficient is P1, and the fifth compression duration of the fifth application data is The third coefficient is P2, and the fourth coefficient is K2.

[0237] In some examples, for the first application data of cold data, the electronic device can determine a compression algorithm that meets the first condition from multiple compression algorithms in the algorithm experience library based on the weighted compression delay and compression rate of the first application data. The first condition includes: when the compression rates are arranged in order from small to large, the compression rate corresponding to the first compression algorithm is ranked in the first N digits (N is a positive integer), and the weighted compression delay of the first application data is less than or equal to the third compression duration, and the third compression duration is the maximum compression duration of the first application data preset by the electronic device. For related explanations, please refer to the description of category 2 application data (i.e., cold data) in S103 of Figure 6, and the description of how to determine compression algorithm 2.

[0238] In one embodiment, the electronic device may determine the first compression algorithm based on the first selection criterion, the size of the first application data, the compression speed of the first application data, and the compression algorithm historically used for the first application data. In some examples, the method shown in FIG11 is executed cyclically. Assuming that the method shown in FIG11 is currently executed for the Nth time, the compression algorithm historically used for the first application data may include: the first compression algorithm determined at least once in the previous (N-1) executions of the method shown in FIG11, for example, the first compression algorithm determined for the (N-1)th execution of the method shown in FIG11.

[0239] S405: The electronic device determines whether the first application data has been compressed.

[0240] In one embodiment, the electronic device may determine whether the first application data has been compressed using a compression algorithm in an algorithm experience library. If the determination result is yes, the electronic device may execute S406-S407; if the determination result is no, the electronic device may execute S408.

[0241] S406: The electronic device decompresses the first application data.

[0242] In one embodiment, when the first application data is compressed data (assuming it has been compressed by compression algorithm 5), the electronic device can read the indication information in the first application data (the indication information indicates compression algorithm 5, for example, the indication information is stored in the header of the first application data), and the electronic device can determine compression algorithm 5 based on the indication information. Then, the electronic device can obtain the decompression algorithm corresponding to compression algorithm 5 based on the above correspondence, and use the decompression algorithm to decompress the first application data.

[0243] S407: The electronic device compresses the decompressed first application data using a first compression algorithm.

[0244] S408: The electronic device compresses the first application data using a first compression algorithm.

[0245] The description of S407 and S408 may refer to the description of S104 in FIG. 6 , wherein the first application data is application data of category 1 (ie, hot data) or application data of category 2 (ie, cold data).

[0246] The order of S405 and any of S401 to S404 is not limited.

[0247] In one embodiment, after S404, before the electronic device compresses the first application data / decompressed first application data (i.e., S407 or S708), the electronic device can determine the parameters of the first compression algorithm based on the hardware performance of the electronic device and the first selection criterion. For specific examples, please refer to the description of determining the parameters of compression algorithm 1 and compression algorithm 2 in Figure 6.

[0248] In one embodiment, the first application data is a plurality of dex files in the first application of the electronic device, and any two dex files among the plurality of dex files are the first dex file and the second dex file, and the names of the plurality of segments in the first dex file are respectively the same as the names of the plurality of segments in the second dex file. Before the electronic device compresses the first application data / decompressed first application data, the electronic device can preprocess the plurality of dex files. Specifically, the electronic device can obtain a plurality of index files based on the first application data, and any one of the plurality of index files is the first index file. The first index file includes the content of the first segment in the first dex file and the content of the second segment in the second dex file, and the names of the first segment and the second segment are the same. Accordingly, when the electronic device compresses the first application data / decompressed first application data, it can compress the plurality of index files obtained above. For specific instructions, please refer to the instructions for preprocessing of the dex files in FIG6 and the process in FIG7.

[0249] In one embodiment, the first application data includes at least one so file, and any one of the at least one so file can be called by at least one application of the electronic device, and the contents of the so files with the same name in the electronic device are also the same. Before the electronic device compresses the first application data / decompressed first application data, the electronic device can perform a preprocessing process on multiple so files. Specifically, the electronic device can query in the electronic device whether there is a so file with the same name as the first so file, and the first so file is any one of the at least one so file; when there is a so file with the same name as the first so file, the first so file is deleted. Accordingly, when the electronic device compresses the first application data / decompressed first application data, it will not compress duplicate so files. For specific instructions, please refer to the instructions for preprocessing of so files in Figure 6 and the process of Figure 9.

[0250] The present application provides another compression method for electronic devices. In one embodiment, the compression method may be performed after the process shown in FIG11. The compression method may include, but is not limited to:

[0251] The electronic device receives a first user operation, where the first user operation is, for example, a user operation on a control 423D in the user interface 420 shown in FIG4(B);

[0252] In response to a first user operation, the electronic device displays a first interface, which includes a first name, a first data size, and a second data size of the first application data. The first data size is the data size of the first application data before compression, and the second data size is the data size of the first application data after compression. The second data size is related to the access frequency of the first application data; wherein, when the access frequency of the first application data is the first frequency, the second data size is a first value, and when the access frequency of the first application data is the second frequency, the second data size is a second value, the first frequency is greater than or equal to the first frequency threshold (therefore, the first application data of the first frequency is hot data), the second frequency is less than the second frequency threshold (therefore, the first application data of the second frequency is cold data), the first frequency threshold is greater than or equal to the second frequency threshold, and the first value is greater than the second value. Optionally, the access frequency of the first application data in state 1 is the first frequency, and the access frequency of the first application data in state 2 is the second frequency. State 1 is before state 2, or state 2 is before state 1.

[0253] Optionally, the first interface further includes indication information of the first application data, where the indication information is used to indicate the access frequency of the first application data.

[0254] Optionally, the first interface further includes a third data size of the first application data, the second data size being the compressed data size of the first application data in the first state, and the third data size being the compressed data size of the first application data in the second state. The first application data in the first state and the first application data in the second state have different access frequencies, the first state being the state of the first application data when the first interface is displayed, and the second state being the state of the first application data before the first state. In other words, the third data size is the historically compressed data size of the first application data.

[0255] For example, the first interface is the user interface 430 shown in (C) of Figure 4, the first application data is picture 1 named "aaa.jpg", the first name is "aaa.jpg", the first data size is 15.8MB, the second data size is 13.5MB, and the indication information of the first application data is "frequently visited".

[0256] The present application provides a decompression method for electronic devices. In one embodiment, the decompression method may be performed after the process shown in FIG11. The decompression method may include, but is not limited to:

[0257] The electronic device may obtain first indication information in the second application data, where the first indication information is used to indicate a first compression algorithm, and the second application data is data compressed by the first compression algorithm using the first application data;

[0258] The electronic device may determine the first compression algorithm according to the first indication information;

[0259] The electronic device may obtain a first decompression algorithm corresponding to the first compression algorithm;

[0260] The second application data is decompressed using a first decompression algorithm to obtain the first application data.

[0261] In one embodiment, the electronic device may store a correspondence between compression algorithms and decompression algorithms. The step of obtaining the first decompression algorithm corresponding to the first compression algorithm includes: obtaining the first decompression algorithm corresponding to the first compression algorithm according to the correspondence.

[0262] Please refer to Figure 12, which is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may include a processing module 1010 and a compression module 1020. The description of each module is as follows:

[0263] The processing module 1010 is configured to identify that the category of first application data of the electronic device is a first category;

[0264] Processing module 1010 is configured to determine a first selection criterion based on the first category; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to the compression time; and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold;

[0265] The processing module 1010 is configured to determine a first compression algorithm based on a first selection criterion, a size of the first application data, and a compression speed of the first application data;

[0266] The compression module 1020 is configured to compress the first application data using a first compression algorithm.

[0267] In one possible implementation, the compression module 1020 is configured to compress the first application data using a first compression algorithm when the first application data is uncompressed data. The compression module 1020 is configured to decompress the first application data and compress the decompressed first application data using the first compression algorithm when the first application data is compressed data.

[0268] In one possible implementation, the processing module 1010 is configured to identify that the category of the first application data in the first state is the first category. The processing module 1010 is further configured to, after the compression module 1020 compresses the first application data using the first compression algorithm, perform the following: identifying that the category of the first application data in the second state is the second category; when the first category and the second category are different, determining a second selection criterion based on the second category, the access frequencies of the first application data in the first state and the first application data in the second state are different; and determining a second compression algorithm based on the second selection criterion, the size of the first application data, and the compression speed of the first application data. The compression module 1020 is further configured to, after the processing module 1010 determines the second compression algorithm based on the second selection criterion, the size of the first application data, and the compression speed of the first application data, compress the first application data in the second state using the second compression algorithm.

[0269] In one possible implementation, the electronic device 100 may further include a decompression module. The compression module 1020 is configured to compress the first application data in the first state using a first compression algorithm to obtain second application data. The decompression module is configured to decompress the second application data using the first decompression algorithm to obtain the first application data in the second state, where the first decompression algorithm corresponds to the first compression algorithm. The compression module 1020 is configured to compress the first application data in the second state using the second compression algorithm.

[0270] In one possible implementation, the electronic device 100 may further include a decompression module. The decompression module is configured to, after the processing module 1010 identifies that the category of the first application data in the second state is the second category, decompress the first application data in the first state using a first decompression algorithm when the first category and the second category are the same, where the first decompression algorithm corresponds to the first compression algorithm.

[0271] In one possible implementation, the processing module 1010 is used to determine a first compression algorithm based on a first parameter, where the first parameter is related to a first selection criterion, and the first parameter is related to a first ratio, where the first ratio is a ratio of a size of the first application data to a compression speed of the first application data.

[0272] In one possible implementation, the access frequency of the first application data is greater than or equal to a first frequency threshold, and the first selection criterion is related to compression time. Processing module 1010 is configured to determine a first compression algorithm based on a data compression cost (DCC); the DCC is related to compression time, and the DCC is a ratio of a first duration to a first data volume. The first duration includes a first compression duration and a first decompression duration. The first compression duration is a ratio of the data size of the first application data before compression to a compression speed. The first decompression duration is a ratio of the data size of the first application data before compression to a decompression speed. The first data volume is a difference between the data size of the first application data before compression and the data size of the first application data after compression.

[0273] In a possible implementation, the first compression algorithm is a compression algorithm having the smallest corresponding DCC among multiple preset compression algorithms.

[0274] In one possible implementation, the first application data includes data of a first data type. The electronic device 100 is preset with multiple compression algorithms and corresponding DCCs. Any one of the multiple compression algorithms corresponds to multiple DCCs, and the multiple DCCs correspond to different data types. The processing module 1010 is configured to determine a first compression algorithm based on the DCC corresponding to the first data type.

[0275] In one possible implementation, the access frequency of the first application data is less than the second frequency threshold, and the first selection criterion is related to the compression ratio. Processing module 1010 is configured to determine a first compression algorithm based on a weighted compression delay and a compression ratio of the first application data; the compression ratio is a ratio of the size of the compressed data to the size of the data before compression, the weighted compression delay of the first application data is related to a second compression duration and a first coefficient of the third application data, the first application data includes the third application data, the second compression duration is a ratio of the size of the third application data before compression to the compression speed of the third application data, and the first coefficient is a ratio of the third application data to the first application data.

[0276] In one possible implementation, the first compression algorithm is a compression algorithm that satisfies a first condition among a plurality of preset compression algorithms. The first condition includes: when the compression rates are arranged in ascending order, the compression rate corresponding to the first compression algorithm is arranged in the top N positions, and the weighted compression delay of the first application data is less than or equal to a third compression duration, where N is a positive integer and the third compression duration is the preset maximum compression duration of the first application data.

[0277] In one possible implementation, the first application data includes fourth application data and fifth application data, the compression rate of the fourth application data per unit time is less than or equal to the first compression threshold, the compression rate of the fifth application data per unit time is greater than the second compression threshold, the first compression threshold is less than or equal to the second compression threshold, and the weighted compression delay of the first application data includes a first value and a second value, the first value is related to the fourth compression duration and the second coefficient of the fourth application data, the second value is related to the fifth compression duration and the third coefficient of the fifth application data, the fourth compression duration is the ratio of the data size of the fourth application data to the compression speed of the fourth application data, the second coefficient is the proportion of the fourth application data to the first application data, the fifth compression duration is the ratio of the data size of the fifth application data to the compression speed of the fifth application data, and the third coefficient is the proportion of the fifth application data to the first application data.

[0278] In one possible implementation, the second value is also related to a fourth coefficient, where the fourth coefficient is the proportion of compressed application data in the fifth application data, and the third coefficient is related to the fourth coefficient, where when the third coefficient is less than a preset coefficient threshold, the fourth coefficient is 1, and when the third coefficient is greater than or equal to the preset coefficient threshold, the fourth coefficient is less than 1.

[0279] In one possible implementation, the first application data includes data of a second data type, and the electronic device 100 is pre-configured with multiple compression algorithms, corresponding compression ratios, and corresponding compression speeds. Any of the multiple compression algorithms corresponds to multiple compression ratios and multiple compression speeds, the multiple compression ratios correspond to different data types, and the multiple compression speeds correspond to different data types. The processing module 1010 is configured to determine the first compression algorithm based on a weighted compression delay of the first application data and the compression ratio corresponding to the second data type; the second compression duration is the ratio of the data size of the third application data before compression to the compression speed corresponding to the second data type.

[0280] In a possible implementation, the processing module 1010 is configured to determine a first compression algorithm according to a first selection criterion, a size of the first application data, a compression speed of the first application data, and a compression algorithm historically used for the first application data.

[0281] In a possible implementation, the processing module 1010 is further configured to determine parameters of the first compression algorithm according to hardware performance of the electronic device and a first selection criterion before the compression module 1020 uses the first compression algorithm to compress the first application data.

[0282] In one possible implementation, the first application data is a plurality of virtual machine executable dex files in the first application of the electronic device 100, any two dex files among the plurality of dex files are a first dex file and a second dex file, and the names of the plurality of segments in the first dex file are respectively the same as the names of the plurality of segments in the second dex file. The processing module 1010 is further used to obtain a plurality of index files according to the first application data before the compression module 1020 uses the first compression algorithm to compress the first application data, any one of the plurality of index files is a first index file, the first index file includes the content of the first segment in the first dex file and the content of the second segment in the second dex file, and the names of the first segment and the second segment are the same. The compression module 1020 is used to compress the plurality of index files using the first compression algorithm.

[0283] In one possible implementation, the first application data includes at least one shared object .so file, any one of the at least one .so file can be called by at least one application of the electronic device, and the contents of .so files with the same name in the electronic device are also the same. The processing module 1010 is further configured to, before the compression module 1020 compresses the first application data using the first compression algorithm, query whether there is an .so file with the same name as the first .so file in the electronic device, where the first .so file is any one of the at least one .so file; and if there is an .so file with the same name as the first .so file, delete the first .so file.

[0284] In one possible implementation, the electronic device 100 further includes a display module. The display module is configured to display a first interface in response to a first user operation, wherein the first interface includes a first name, a first data size, and a second data size of the first application data, wherein the first data size is the data size of the first application data before compression, and the second data size is the data size of the first application data after compression, and the second data size is related to an access frequency of the first application data; wherein, when the access frequency of the first application data is a first frequency, the second data size is a first value, and when the access frequency of the first application data is a second frequency, the second data size is a second value, the first frequency is greater than or equal to a first frequency threshold, the second frequency is less than a second frequency threshold, the first frequency threshold is greater than or equal to the second frequency threshold, and the first value is greater than the second value.

[0285] In a possible implementation, the first interface further includes first indication information, where the first indication information indicates an access frequency of the first application data.

[0286] In one possible implementation, the first interface also includes a third data size of the first application data, the second data size is the data size of the first application data in the first state after compression, and the third data size is the data size of the first application data in the second state after compression. The access frequencies of the first application data in the first state and the first application data in the second state are different. The first state is the state of the first application data when the first interface is displayed, and the second state is the state of the first application data before the first state.

[0287] It can be understood that the implementation and beneficial effects of each module can correspond to the methods shown in Figures 6, 7, 9, and 11, and the corresponding description of the above-mentioned decompression method.

[0288] Please refer to Figure 13, which is a schematic diagram of the hardware structure of another electronic device 100 provided in an embodiment of the present application. The electronic device 100 may include a processor 1001, a memory 1002, and a transceiver 1003. In one embodiment, the processor 1001, the memory 1002, and the transceiver 1003 may be interconnected via a bus.

[0289] Memory 1002 includes, but is not limited to, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or compact disc read-only memory (CD-ROM). Memory 1002 is used for storing computer programs and data. Transceiver 1003 is used to receive and transmit data.

[0290] The processor 1001 may be one or more central processing units (CPUs). When the processor 1001 is a CPU, the CPU may be a single-core CPU or a multi-core CPU.

[0291] The processor 1001 may be configured to read the computer program or instructions stored in the memory 1002 and perform the following operations:

[0292] Identifying the category of the first application data of the electronic device as the first category;

[0293] Determining a first selection criterion based on the first category; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to the compression time; and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold;

[0294] determining a first compression algorithm based on a first selection criterion, a size of the first application data, and a compression speed of the first application data;

[0295] The first application data is compressed using a first compression algorithm.

[0296] In one possible implementation, the processor 1001 is configured to compress the first application data using a first compression algorithm when the first application data is uncompressed data; decompress the first application data when the first application data is compressed data, and compress the decompressed first application data using the first compression algorithm.

[0297] In one possible implementation, processor 1001 is configured to identify that the category of first application data in a first state is the first category. Processor 1001 is further configured to, after compressing the first application data using the first compression algorithm, perform the following steps: identifying that the category of the first application data in a second state is the second category; when the first category and the second category are different, determining a second selection criterion based on the second category, where the access frequencies of the first application data in the first state and the first application data in the second state are different; determining a second compression algorithm based on the second selection criterion, a size of the first application data, and a compression speed of the first application data; and compressing the first application data in the second state using the second compression algorithm.

[0298] In one possible implementation, processor 1001 is configured to compress first application data in a first state using a first compression algorithm to obtain second application data. Processor 1001 is configured to decompress the second application data using a first decompression algorithm to obtain the first application data in a second state, where the first decompression algorithm corresponds to the first compression algorithm; and to compress the first application data in the second state using the second compression algorithm.

[0299] In one possible implementation, the processor 1001 is further used to, after identifying that the category of the first application data in the second state is the second category, decompress the first application data in the first state using a first decompression algorithm when the first category and the second category are the same, and the first decompression algorithm corresponds to the first compression algorithm.

[0300] In one possible implementation, the processor 1001 is used to determine a first compression algorithm based on a first parameter, where the first parameter is related to a first selection criterion, and the first parameter is related to a first ratio, where the first ratio is a ratio of a size of the first application data to a compression speed of the first application data.

[0301] In one possible implementation, the access frequency of the first application data is greater than or equal to a first frequency threshold, and the first selection criterion is related to compression time. Processor 1001 is configured to determine a first compression algorithm based on a data compression cost (DCC); the DCC is related to compression time, and the DCC is a ratio of a first duration to a first data volume. The first duration includes a first compression duration and a first decompression duration. The first compression duration is a ratio of a data size of the first application data before compression to a compression speed. The first decompression duration is a ratio of a data size of the first application data before compression to a decompression speed. The first data volume is a difference between a data size of the first application data before compression and a data size of the first application data after compression.

[0302] In a possible implementation, the first compression algorithm is a compression algorithm having the smallest corresponding DCC among multiple preset compression algorithms.

[0303] In one possible implementation, the first application data includes data of a first data type. The electronic device 100 is preset with multiple compression algorithms and corresponding DCCs. Any one of the multiple compression algorithms corresponds to multiple DCCs, and the multiple DCCs correspond to different data types. The processor 1001 is configured to determine a first compression algorithm based on the DCC corresponding to the first data type.

[0304] In one possible implementation, the access frequency of the first application data is less than a second frequency threshold, and the first selection criterion is related to the compression ratio. Processor 1001 is configured to determine a first compression algorithm based on a weighted compression delay and a compression ratio of the first application data; the compression ratio is a ratio of the size of the compressed data to the size of the data before compression, the weighted compression delay of the first application data is related to a second compression duration and a first coefficient of the third application data, the first application data includes the third application data, the second compression duration is a ratio of the size of the third application data before compression to the compression speed of the third application data, and the first coefficient is a ratio of the third application data to the first application data.

[0305] In one possible implementation, the first compression algorithm is a compression algorithm that satisfies a first condition among a plurality of preset compression algorithms. The first condition includes: when the compression rates are arranged in ascending order, the compression rate corresponding to the first compression algorithm is arranged in the top N positions, and the weighted compression delay of the first application data is less than or equal to a third compression duration, where N is a positive integer and the third compression duration is the preset maximum compression duration of the first application data.

[0306] In one possible implementation, the first application data includes fourth application data and fifth application data, the compression rate of the fourth application data per unit time is less than or equal to the first compression threshold, the compression rate of the fifth application data per unit time is greater than the second compression threshold, the first compression threshold is less than or equal to the second compression threshold, and the weighted compression delay of the first application data includes a first value and a second value, the first value is related to the fourth compression duration and the second coefficient of the fourth application data, the second value is related to the fifth compression duration and the third coefficient of the fifth application data, the fourth compression duration is the ratio of the data size of the fourth application data to the compression speed of the fourth application data, the second coefficient is the proportion of the fourth application data to the first application data, the fifth compression duration is the ratio of the data size of the fifth application data to the compression speed of the fifth application data, and the third coefficient is the proportion of the fifth application data to the first application data.

[0307] In one possible implementation, the second value is also related to a fourth coefficient, where the fourth coefficient is the proportion of compressed application data in the fifth application data, and the third coefficient is related to the fourth coefficient, where when the third coefficient is less than a preset coefficient threshold, the fourth coefficient is 1, and when the third coefficient is greater than or equal to the preset coefficient threshold, the fourth coefficient is less than 1.

[0308] In one possible implementation, the first application data includes data of a second data type, and the electronic device 100 is pre-configured with multiple compression algorithms, corresponding compression ratios, and corresponding compression speeds. Any of the multiple compression algorithms corresponds to multiple compression ratios and multiple compression speeds, the multiple compression ratios correspond to different data types, and the multiple compression speeds correspond to different data types. The processor 1001 is configured to determine the first compression algorithm based on a weighted compression delay of the first application data and the compression ratio corresponding to the second data type; the second compression duration is a ratio of the pre-compression data size of the third application data to the compression speed corresponding to the second data type.

[0309] In one possible implementation, the processor 1001 is configured to determine a first compression algorithm according to a first selection criterion, a size of the first application data, a compression speed of the first application data, and a compression algorithm historically used for the first application data.

[0310] In a possible implementation, the processor 1001 is further configured to determine parameters of the first compression algorithm according to hardware performance of the electronic device and a first selection criterion before compressing the first application data using the first compression algorithm.

[0311] In one possible implementation, the first application data is a plurality of virtual machine executable dex files in a first application of the electronic device 100, any two of the plurality of dex files are a first dex file and a second dex file, and the names of the plurality of segments in the first dex file are respectively the same as the names of the plurality of segments in the second dex file. The processor 1001 is further configured to obtain a plurality of index files based on the first application data before compressing the first application data using a first compression algorithm, wherein any one of the plurality of index files is a first index file, and the first index file includes the contents of a first segment in the first dex file and the contents of a second segment in the second dex file, and the names of the first segment and the second segment are the same. The processor 1001 is configured to compress the plurality of index files using a first compression algorithm.

[0312] In one possible implementation, the first application data includes at least one shared object SO file, any one of the at least one SO file can be called by at least one application of the electronic device, and SO files with the same name in the electronic device also have the same content. The processor 1001 is further configured to, before compressing the first application data using the first compression algorithm, query whether there is an SO file with the same name as the first SO file in the electronic device 100, where the first SO file is any one of the at least one SO file; and if there is an SO file with the same name as the first SO file, delete the first SO file.

[0313] In one possible implementation, the electronic device 100 further includes a display screen. The display screen is configured to display a first interface in response to a first user operation, wherein the first interface includes a first name, a first data size, and a second data size of the first application data, wherein the first data size is the data size of the first application data before compression, and the second data size is the data size of the first application data after compression, and the second data size is related to an access frequency of the first application data; wherein, when the access frequency of the first application data is a first frequency, the second data size is a first value, and when the access frequency of the first application data is a second frequency, the second data size is a second value, the first frequency is greater than or equal to a first frequency threshold, the second frequency is less than a second frequency threshold, the first frequency threshold is greater than or equal to the second frequency threshold, and the first value is greater than the second value.

[0314] In a possible implementation, the first interface further includes first indication information, where the first indication information indicates an access frequency of the first application data.

[0315] In one possible implementation, the first interface also includes a third data size of the first application data, the second data size is the data size of the first application data in the first state after compression, and the third data size is the data size of the first application data in the second state after compression. The access frequencies of the first application data in the first state and the first application data in the second state are different. The first state is the state of the first application data when the first interface is displayed, and the second state is the state of the first application data before the first state.

[0316] It can be understood that the implementation and beneficial effects of each operation can correspond to the methods shown in Figures 6, 7, 9, and 11, and the corresponding description of the above-mentioned decompression method.

[0317] The present application also provides a communication system comprising a first device and a second device. The first device is configured to execute the compression method provided in the present application, and the second device is configured to execute the decompression method provided in the present application. In one embodiment, the first device can send compressed application data to the second device, and the second device can decompress the received application data. Exemplarily, the communication system is the communication system 10 shown in FIG1 .

[0318] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program or instruction. When the computer program or instruction runs on a processor, it implements the method shown in Figures 6, 7, 9, and 11, and the above-mentioned decompression method.

[0319] An embodiment of the present application also provides a computer program product, which includes a computer program or instructions. When the computer program or instructions are run on a processor, it implements the method shown in Figures 6, 7, 9, and 11, the above-mentioned decompression method.

[0320] An embodiment of the present application also provides a chip device, which includes at least one processor, and the at least one processor is used to call a computer program or instruction stored in a memory so that the processor executes the method shown in Figures 6, 7, 9, and 11, the above-mentioned decompression method.

[0321] The methods provided in the various embodiments of the present application may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, they may 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 program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, a network device, a user device, or other programmable device. The computer instructions may 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 may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, or a magnetic tape), an optical medium (e.g., a digital video disc (DWD), or a semiconductor medium (e.g., a solid state drive (SSD)). As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit the same. Although the present application has been described in detail with reference to the above embodiments, a person skilled in the art should understand that the technical solutions described in the above embodiments may be modified, or some of the technical features thereof may be replaced by equivalents. However, such modifications or replacements do not deviate the essence of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

[0322] In the various embodiments of the present application, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced by each other. The technical features in different embodiments can be combined to form new embodiments according to their inherent logical relationships.

[0323] In the description of this application, words such as "first", "second", "S101", or "S102" are only used to distinguish the description and facilitate the context. Different sequence numbers themselves do not have specific technical meanings and cannot be understood as indicating or implying relative importance, nor can they be understood as indicating or implying the order of execution of operations. The execution order of each process should be determined by its function and internal logic.

[0324] In this application, the terms "comprise" or "have" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process / method comprising a series of steps, or a system / product / apparatus comprising a series of units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes / methods / products / apparatus.

Claims

1. A compression method, characterized in that: Applied to electronic equipment, the method comprises Identify the category of the first application data of the electronic device as a first category; Determine a first selection criterion according to the first category; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to compression time, and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold; determining a first compression algorithm according to the first selection criterion, the size of the first application data, and the compression speed of the first application data; The first application data is compressed using the first compression algorithm.

2. The method according to claim 1, characterized in that The compressing the first application data using the first compression algorithm includes: When the first application data is uncompressed data, compressing the first application data using the first compression algorithm; When the first application data is compressed data, the first application data is decompressed, and the decompressed first application data is compressed using the first compression algorithm.

3. The method according to claim 1 or 2, characterized in that The identifying that the category of the first application data of the electronic device is the first category includes: identifying a category of the first application data in a first state as the first category; After compressing the first application data using the first compression algorithm, the method further includes: identifying that the category of the first application data in the second state is a second category; when the first category and the second category are different, determining a second selection criterion according to the second category, and the access frequencies of the first application data in the first state and the first application data in the second state are different; determining a second compression algorithm according to the second selection criterion, the size of the first application data, and the compression speed of the first application data; The first application data in the second state is compressed using the second compression algorithm.

4. The method according to claim 3, characterized in that The compressing the first application data using the first compression algorithm includes: compressing the first application data in the first state using the first compression algorithm to obtain second application data; The compressing the first application data in the second state using the second compression algorithm includes: decompressing the second application data using a first decompression algorithm to obtain the first application data in the second state, wherein the first decompression algorithm corresponds to the first compression algorithm; The first application data in the second state is compressed using the second compression algorithm.

5. The method according to claim 3 or 4, characterized in that The method further comprises: After identifying that the category of the first application data in the second state is the second category, when the first category and the second category are the same, the first application data in the first state is decompressed using a first decompression algorithm, and the first decompression algorithm corresponds to the first compression algorithm.

6. The method according to any one of claims 1 to 5, characterized in that: The determining the first compression algorithm according to the first selection criterion, the size of the first application data and the compression speed of the first application data includes: The first compression algorithm is determined according to a first parameter, the first parameter is related to the first selection criterion, the first parameter is related to a first ratio, and the first ratio is a ratio of a size of the first application data to a compression speed of the first application data.

7. The method according to any one of claims 1 to 6, characterized in that: The access frequency of the first application data is greater than or equal to the first frequency threshold, and the first selection criterion is related to compression time; The determining the first compression algorithm according to the first selection criterion, the size of the first application data and the compression speed of the first application data includes: Determining the first compression algorithm according to the data compression cost DCC; The DCC is related to the compression time. The DCC is the ratio of a first duration to a first data volume. The first duration includes a first compression duration and a first decompression duration. The first compression duration is the ratio of a data size of the first application data before compression to a compression speed. The first decompression duration is the ratio of a data size of the first application data before compression to a decompression speed. The first data volume is the difference between a data size of the first application data before compression and a data size of the first application data after compression.

8. The method according to claim 7, characterized in that The first compression algorithm is a compression algorithm with the smallest corresponding DCC among multiple preset compression algorithms.

9. The method according to claim 7 or 8, characterized in that The first application data includes data of a first data type, the electronic device is preset with multiple compression algorithms and corresponding DCCs, any one of the multiple compression algorithms corresponds to multiple DCCs, and the multiple DCCs correspond to different data types respectively; The determining the first compression algorithm according to the first selection criterion, the size of the first application data and the compression speed of the first application data includes: The first compression algorithm is determined according to the DCC corresponding to the first data type.

10. The method according to any one of claims 1 to 6, characterized in that: The access frequency of the first application data is less than the second frequency threshold, and the first selection criterion is related to the compression rate; and determining the first compression algorithm according to the first selection criterion, the size of the first application data, and the compression speed of the first application data includes: The first compression algorithm is determined based on the weighted compression delay and compression rate of the first application data; the compression rate is the ratio of the data size after compression to the data size before compression, the weighted compression delay of the first application data is related to the second compression duration and the first coefficient of the third application data, the first application data includes the third application data, the second compression duration is the ratio of the data size of the third application data before compression to the compression speed of the third application data, and the first coefficient is the proportion of the third application data to the first application data.

11. The method according to claim 10, characterized in that The first compression algorithm is a compression algorithm that satisfies a first condition among a plurality of preset compression algorithms, wherein the first condition includes: when the compression rates are arranged in ascending order, the compression rate corresponding to the first compression algorithm is arranged in the first N positions, and the weighted compression delay of the first application data is less than or equal to a third compression duration, wherein N is a positive integer, and the third compression duration is a preset maximum compression duration of the first application data.

12. The method according to claim 10 or 11, characterized in that The first application data includes fourth application data and fifth application data, the compression rate of the fourth application data per unit time is less than or equal to a first compression threshold, the compression rate of the fifth application data per unit time is greater than a second compression threshold, the first compression threshold is less than or equal to the second compression threshold, the weighted compression delay of the first application data includes a first value and a second value, the first value is related to a fourth compression duration and a second coefficient of the fourth application data, the second value is related to a fifth compression duration and a third coefficient of the fifth application data, the fourth compression duration is the ratio of the data size of the fourth application data to the compression speed of the fourth application data, the second coefficient is the proportion of the fourth application data to the first application data, the fifth compression duration is the ratio of the data size of the fifth application data to the compression speed of the fifth application data, and the third coefficient is the proportion of the fifth application data to the first application data.

13. The method according to claim 12, characterized in that The second value is also related to the fourth coefficient, which is the proportion of compressed application data in the fifth application data. The third coefficient is related to the fourth coefficient, wherein when the third coefficient is less than a preset coefficient threshold, the fourth coefficient is 1, and when the third coefficient is greater than or equal to the preset coefficient threshold, the fourth coefficient is less than 1.

14. The method according to any one of claims 10 to 13, characterized in that: The first application data includes data of a second data type, the electronic device is preset with multiple compression algorithms, corresponding compression rates, and corresponding compression speeds, any one of the multiple compression algorithms corresponds to multiple compression rates and multiple compression speeds, the multiple compression rates correspond to different data types, and the multiple compression speeds correspond to different data types; The determining the first compression algorithm according to the first selection criterion, the size of the first application data and the compression speed of the first application data includes: determining the first compression algorithm according to the weighted compression delay of the first application data and the compression rate corresponding to the second data type; The second compression duration is a ratio of a data size of the third application data before compression to a compression speed corresponding to the second data type.

15. The method according to any one of claims 1 to 14, characterized in that: The determining the first compression algorithm according to the first selection criterion, the size of the first application data, and the compression speed includes: The first compression algorithm is determined according to the first selection criterion, the size of the first application data, the compression speed of the first application data, and the compression algorithm historically used by the first application data.

16. The method according to any one of claims 1 to 15, characterized in that: Before compressing the first application data using the first compression algorithm, the method further includes: Parameters of the first compression algorithm are determined according to the hardware performance of the electronic device and the first selection criterion.

17. The method according to any one of claims 1 to 16, characterized in that: The first application data is a plurality of virtual machine executable dex files in the first application of the electronic device, any two dex files among the plurality of dex files are a first dex file and a second dex file, and the names of the plurality of partition blocks in the first dex file are respectively the same as the names of the plurality of partition blocks in the second dex file; Before compressing the first application data using the first compression algorithm, the method further includes: Acquire multiple index files according to the first application data, wherein any one of the multiple index files is a first index file, and the first index file includes content of a first segmentation block in the first dex file and content of a second segmentation block in the second dex file, and the first segmentation block and the second segmentation block have the same name; The compressing the first application data using the first compression algorithm includes: The plurality of index files are compressed using the first compression algorithm.

18. The method according to any one of claims 1 to 17, characterized in that: The first application data includes at least one shared object so file, any one of the at least one so file can be called by at least one application of the electronic device, and the so files with the same name in the electronic device also have the same content; Before compressing the first application data using the first compression algorithm, the method further includes: Querying whether there is an SO file with the same name as the first SO file in the electronic device, where the first SO file is any one of the at least one SO file; When there is an so file with the same name as the first so file, delete the first so file.

19. A compression method, characterized in that: Applied to electronic equipment, the method comprises: receiving a first user operation; In response to the first user operation, a first interface is displayed, wherein the first interface includes a first name, a first data size, and a second data size of the first application data, wherein the first data size is the data size of the first application data before compression, and the second data size is the data size of the first application data after compression, and the second data size is related to an access frequency of the first application data; wherein, when the access frequency of the first application data is a first frequency, the second data size is a first value, and when the access frequency of the first application data is a second frequency, the second data size is a second value, the first frequency is greater than or equal to a first frequency threshold, the second frequency is less than a second frequency threshold, the first frequency threshold is greater than or equal to the second frequency threshold, and the first value is greater than the second value.

20. The method of claim 19, wherein: The first interface also includes first indication information, where the first indication information indicates the access frequency of the first application data.

21. The method according to claim 19 or 20, characterized in that The first interface also includes a third data size of the first application data, the second data size is the data size of the first application data in the first state after compression, the third data size is the data size of the first application data in the second state after compression, the access frequencies of the first application data in the first state and the first application data in the second state are different, the first state is the state of the first application data when the first interface is displayed, and the second state is the state of the first application data before the first state.

22. The method according to any one of claims 19 to 21, characterized in that: The second data size is the data size of the first application data after being compressed by a first compression algorithm, and the first compression algorithm is determined based on a first selection criterion, the size of the first application data and the compression speed of the first application data; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to the compression time, and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold.

23. A decompression method, characterized in that: Applied to electronic equipment, the method comprises: Acquire first indication information in the first application data, where the first indication information is used to indicate a first compression algorithm, and the first application data is data obtained by compressing the second application data using the first compression algorithm; determining the first compression algorithm according to the first indication information; the first compression algorithm is determined according to a first selection criterion, a size of the second application data, and a compression speed of the second application data, wherein when the access frequency of the second application data is greater than or equal to a first frequency threshold, the first selection criterion is related to the compression time, and when the access frequency of the second application data is less than a second frequency threshold, the first selection criterion is related to the compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold; Obtaining a first decompression algorithm corresponding to the first compression algorithm; The first application data is decompressed using the first decompression algorithm to obtain the second application data.

24. A communication system, characterized in that: It comprises a first device and a second device, wherein the first device is used to execute the compression method described in any one of claims 1 to 22, and the second device is used to execute the decompression method described in claim 23.

25. An electronic device, characterized in that: It includes a processing module and a compression module, wherein: The processing module is used to identify that the category of the first application data of the electronic device is the first category; The processing module is configured to determine a first selection criterion according to the first category; wherein, when the access frequency of the first application data is greater than or equal to a first frequency threshold, the first selection criterion is related to a compression time, and when the access frequency of the first application data is less than a second frequency threshold, the first selection criterion is related to a compression rate, and the first frequency threshold is greater than or equal to the second frequency threshold; The processing module is used to determine a first compression algorithm according to the first selection criterion, the size of the first application data and the compression speed of the first application data; The compression module is used to compress the first application data using the first compression algorithm.

26. An electronic device, characterized in that: The method comprises a transceiver, a processor and a memory, wherein the memory is used to store a computer program, and the processor calls the computer program to execute the method according to any one of claims 1 to 23.

27. A computer storage medium, characterized in that The computer storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 23 is implemented.

Citation Information

Patent Citations

  • Data processing method and device

    CN115905136A

  • Self-adaptive compression method and compression device, computer equipment and storage medium

    CN115905168A

  • Information management system

    US20050210054A1