A method and apparatus for generating a software installation package
By retaining the target resource index information and deleting other resource index information, and by adding files using both uncompressed and compressed methods, the problem of large installation package data size was solved, achieving a reduction in installation package size and normal resource loading without compressing file limitations.
Patent Information
- Application Number
- CN202210741607.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-28
- Publication Date
- 2026-01-23
- Estimated Expiration
- 2042-06-28
AI Technical Summary
In existing technologies, files in the installation package are not allowed to be compressed, resulting in large data volumes and affecting download efficiency. How can the size of the installation package be reduced without allowing compression?
By retaining the resource index information of the target resource, deleting other resource index information, and adding the target resource index file and resources to the installation package in an uncompressed manner, while adding the original resource index file and resources to the installation package in a compressed manner.
While disallowing file compression, this reduces the installation package size while ensuring all resources load correctly, thus improving download efficiency.
Smart Images

Figure CN115113885B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and more specifically, to a method and apparatus for generating a software installation package. Background Technology
[0002] As individual applications become increasingly diversified, the size of their installation packages also grows. To reduce package size, installation packages are typically compressed before release. However, in some cases, file compression is not permitted, resulting in a large package size that not only consumes significant storage space but also impacts download efficiency. Therefore, finding a way to reduce the size of installation packages while disallowing file compression is a pressing issue. Summary of the Invention
[0003] This disclosure provides at least one method and apparatus for generating a software installation package.
[0004] In a first aspect, embodiments of this disclosure provide a method for generating a software installation package, comprising:
[0005] Obtain the original resource index file contained in the installation package to be released for the target application; the original resource index file contains resource index information corresponding to each resource;
[0006] Based on the first resource index information corresponding to the target resource that is reserved in the preset, the second resource index information corresponding to other resources in the original resource index file other than the target resource is determined, and the second resource index information is deleted to obtain the target resource index file;
[0007] The target resource index file and the target resources are added to the installation package to be released in an uncompressed manner, while the original resource index file and each resource are added in a compressed manner, to obtain the target installation package for release.
[0008] In an optional implementation, before determining the second resource index information corresponding to other resources besides the target resource in the original resource index file based on the first resource index information corresponding to the preset reserved target resource, the method further includes:
[0009] Obtain the first resource identifier information contained in the application manifest file of the installation package to be released;
[0010] The first resource identifier information and the custom second resource identifier information are used as the first resource index information corresponding to the preset reserved target resource.
[0011] In an optional implementation, the step of using the first resource identifier information and the customized second resource identifier information as the first resource index information corresponding to the preset reserved target resource includes:
[0012] If the first resource identifier information corresponds to an Extensible Markup Language (XML) file, then read each third resource identifier information in the XML file, and use the third resource identifier information and the custom second resource identifier information as the first resource index information corresponding to the preset reserved target resource; or
[0013] If the first resource identifier information corresponds to a sub-resource with inheritance attributes, the first resource identifier information, the fourth resource identifier information inherited by the sub-resource, and the custom second resource identifier information are used as the first resource index information corresponding to the preset reserved target resource.
[0014] In an optional implementation, after deleting the second resource index information, the method further includes:
[0015] If the resource index information corresponding to each resource under the target resource type all belong to the deleted second resource index information, then the format of the resource name string corresponding to the target resource type is modified to indicate that the second resource index information corresponding to the target resource type has been deleted.
[0016] In an optional implementation, after determining the second resource index information corresponding to resources other than the target resource in the original resource index file, the method further includes:
[0017] Delete the configuration information corresponding to the other resources; the configuration information includes at least one of metadata and offset information.
[0018] In one optional implementation, the other resources are resources with type function structures under multiple resource types; the configuration information includes offset information;
[0019] The step of deleting the second resource index information to obtain the target resource index file includes:
[0020] For each of the type function structures under the target resource type, the length of the offset array corresponding to the type function structure is modified based on the last valid offset in the offset array corresponding to that type function structure; and,
[0021] Based on the length of the modified offset array corresponding to each type function structure under the target resource type, the length of the configuration array corresponding to the target resource type is determined; the length of the configuration array is the maximum value among the lengths of each modified offset array.
[0022] Based on the length of the offset array corresponding to the type function structure and the length of the configuration array, a target resource index file is generated.
[0023] In one optional implementation, adding the original resource index file and each resource to the installation package to be released in a compressed manner includes:
[0024] The original resource index file and each resource are added to the resource package of the installation package to be released in a compressed manner;
[0025] The resource package is added in an uncompressed manner to the target resource directory pre-created in the installation package to be released.
[0026] In one optional implementation, the method further includes:
[0027] During the process of installing the target application using the target installation package in the target operating system, the original resource directory in the target installation package is replaced by the pre-created target resource directory, so that the target operating system can obtain the resource package corresponding to the target resource directory; the original resource directory corresponds to the target resource index file and the target resource.
[0028] In one optional implementation, replacing the original resource directory in the target installation package with the pre-created target resource directory includes:
[0029] During the process of installing the target application using the target installation package on the target operating system, it is determined whether an application context relationship that has already been built exists.
[0030] If it exists, the pre-created target resource directory is used to replace the original resource directory that already exists in the resource directory manager, so that the target operating system can obtain the resource package corresponding to the target resource directory;
[0031] If it does not exist, the original resource directory that already exists in the resource directory dictionary in the resource manager is replaced with the target resource directory, so that after the application context relationship is built, the target operating system can find the target resource directory from the resource directory dictionary and obtain the resource package corresponding to the target resource directory.
[0032] Secondly, embodiments of this disclosure also provide a software installation package generation apparatus, comprising:
[0033] The first acquisition module is used to acquire the original resource index file contained in the installation package to be released corresponding to the target application; the original resource index file contains resource index information corresponding to each resource;
[0034] The first determining module is used to determine the second resource index information corresponding to other resources in the original resource index file besides the target resource based on the first resource index information corresponding to the target resource that is reserved in a preset manner, and delete the second resource index information to obtain the target resource index file;
[0035] An addition module is used to add the target resource index file and the target resources in an uncompressed manner, and the original resource index file and each resource in a compressed manner, to the installation package to be released, to obtain the target installation package for release.
[0036] Thirdly, embodiments of this disclosure also provide a computer device, including: a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the computer device is running, the processor communicates with the memory via the bus, and when the machine-readable instructions are executed by the processor, the steps of the first aspect above, or any possible implementation of the first aspect, are performed.
[0037] Fourthly, embodiments of this disclosure also provide a computer-readable storage medium storing a computer program that, when executed by a processor, performs the steps of the first aspect or any possible implementation of the first aspect.
[0038] The software installation package generation method provided in this disclosure can obtain a target installation package containing preset reserved target resources, target resource index files corresponding to the target resources, original resources, and original resource index files corresponding to the original resources. The preset reserved target resources and target resource index files corresponding to the target resources are added to the installation package in an uncompressed manner, which satisfies the requirement that the resource.arsc file cannot be compressed. The original resources and original resource index files corresponding to the original resources are added to the installation package in a compressed manner, which not only ensures that all resources of the target application can be loaded normally, but also allows for compression, reducing the size of the installation package. In other words, the above process achieves the reduction of the installation package size while disallowing the compression of files within the installation package.
[0039] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0040] To more clearly illustrate the technical solutions of the embodiments of this disclosure, the accompanying drawings used in the embodiments will be briefly described below. These drawings are incorporated in and constitute a part of this specification. They illustrate embodiments conforming to this disclosure and, together with the specification, serve to explain the technical solutions of this disclosure. It should be understood that the following drawings only show some embodiments of this disclosure and should not be considered as limiting the scope. Those skilled in the art can obtain other related drawings based on these drawings without creative effort.
[0041] Figure 1 A flowchart illustrating a method for generating a software installation package according to an embodiment of this disclosure is shown;
[0042] Figure 2 A schematic diagram of a software installation package generation apparatus provided in an embodiment of the present disclosure is shown;
[0043] Figure 3 A schematic diagram of a computer device provided in an embodiment of this disclosure is shown. Detailed Implementation
[0044] To make the objectives, technical solutions, and advantages of the embodiments of this disclosure clearer, the technical solutions of the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this disclosure, and not all of them. The components of the embodiments of this disclosure described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this disclosure provided in the accompanying drawings is not intended to limit the scope of the claimed disclosure, but merely represents selected embodiments of this disclosure. All other embodiments obtained by those skilled in the art based on the embodiments of this disclosure without inventive effort are within the scope of protection of this disclosure.
[0045] In practice, there are certain restrictions that prohibit the compression of files within installation packages. For example, the resources.arsc file in the installation package of applications installed on the Android operating system cannot be compressed. This prevents application developers from reducing the installation size by compressing this file. Consequently, the installation package not only occupies a large amount of data space but also affects the transmission efficiency of the installation package during the download process. Therefore, how to reduce the size of the installation package under the restriction of not allowing the compression of files within the installation package is an urgent problem to be solved.
[0046] Based on this, this disclosure provides a method, apparatus, computer device, and storage medium for generating a software installation package. The method for generating a software installation package provided by this disclosure can obtain a target installation package containing preset reserved target resources, target resource index files corresponding to the target resources, original resources, and original resource index files corresponding to the original resources. The preset reserved target resources and target resource index files corresponding to the target resources are added to the installation package in an uncompressed manner, which satisfies the requirement that the resource.arsc file cannot be compressed. The original resources and original resource index files corresponding to the original resources are added to the installation package in a compressed manner, which not only ensures that all resources of the target application can be loaded normally, but also allows for compression, reducing the size of the installation package. In other words, the above process achieves the reduction of the installation package size while disallowing the compression of files within the installation package.
[0047] The deficiencies of the above solutions and the proposed solutions are the result of the inventor's practice and careful research. Therefore, the discovery process of the above problems and the solutions proposed in this disclosure below should be considered as the inventor's contribution to this disclosure.
[0048] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0049] To facilitate understanding of this embodiment, a method for generating a software installation package disclosed in this disclosure will first be described in detail. The execution subject of the method for generating a software installation package provided in this disclosure is generally a computer device with certain computing power.
[0050] First, it should be noted that the software installation package generation method provided in this disclosure is mainly applied to the generation process of installation packages for applications that can be installed on a target operating system (such as Android operating system).
[0051] The following describes the method for generating a software installation package provided in this embodiment, taking a server as the execution subject as an example.
[0052] See Figure 1 The diagram shows a flowchart of a method for generating a software installation package according to an embodiment of this disclosure. The method includes steps S101 to S103, wherein:
[0053] S101: Obtain the original resource index file contained in the installation package to be released corresponding to the target application; the original resource index file contains resource index information corresponding to each resource.
[0054] In this embodiment of the disclosure, the installation package to be released corresponding to the target application may refer to the installation package of the application installed on the target operating system (e.g., Android operating system), such as the Android package (APK).
[0055] The target application's corresponding installation package may contain a raw resource index file. Using the resource index information contained in the raw resource index file, the corresponding resources can be located. Here, the raw resource index file can refer to the resource.arsc file in the APK. Alternatively, the raw resource index file can contain a complete resource index file; here, the resource.arsc file can refer to the complete resource.arsc file.
[0056] S102: Based on the first resource index information corresponding to the target resource that is reserved in the preset, determine the second resource index information corresponding to other resources in the original resource index file other than the target resource, and delete the second resource index information to obtain the target resource index file.
[0057] Here, the pre-reserved target resources refer to the resources that the target operating system needs to access during the installation of the target application. By pre-reserving target resources, the target operating system can access the necessary resources required for the installation of the target application, thus avoiding errors during the installation process.
[0058] After deleting the second resource index information, the resulting target resource index file contains only the first resource index information corresponding to the target resource. For a complete resource.arsc file, deleting the second resource index information yields a trimmed resource.arsc file.
[0059] S103: Add the target resource index file and the target resources in an uncompressed manner, and the original resource index file and each resource in a compressed manner, to the installation package to be released, to obtain the target installation package for release.
[0060] Here, the target resource index file and target resources are added to the installation package in an uncompressed manner. This satisfies the requirement that the resource.arsc file cannot be compressed. Furthermore, since the target resource index file and target resources are necessary resources for the target operating system to install the target application, the installation process can proceed normally. In addition, adding the original resource index file and individual resources to the installation package in a compressed manner reduces the package size while ensuring that all resources of the target application are loaded correctly, guaranteeing that the installed target application can be used normally.
[0061] Through the above implementation process, a target installation package containing the preset reserved target resources, target resource index file, original resource index file, and each resource can be obtained. The obtained target installation package can not only meet the requirement that the resource.arsc file cannot be compressed, but also reduce the size of the installation package, and ensure that all resources of the target application can be loaded normally.
[0062] The above S101 to S103 will be described in detail below with reference to specific embodiments.
[0063] Regarding S102 above, in one embodiment, before determining the second resource index information corresponding to other resources besides the target resource in the original resource index file based on the first resource index information corresponding to the preset reserved target resource, the preset reserved target resource can be obtained by following these steps:
[0064] (1) It can obtain the first resource identifier information contained in the application manifest file in the installation package to be released.
[0065] Here, the application manifest file can refer to the AndroidManifest.xml file in the APK. By reading the AndroidManifest.xml file in the APK, the first resource identifier information contained in the file can be obtained.
[0066] (2) The first resource identifier information and the custom second resource identifier information are used as the first resource index information corresponding to the target resource that is reserved in the preset.
[0067] Customized second resource identifier information can be second resource identifier information corresponding to resources that are reserved by the user.
[0068] The resources corresponding to the first resource identifier and the resources corresponding to the second resource identifier are the target resources that are pre-reserved. The first resource identifier and the second resource identifier are the first resource index information corresponding to the target resources.
[0069] In practice, the first resource identifier information may also contain other resource identifier information. In this case, the other resource identifier information can be used as the first resource index information.
[0070] Here, the first resource identifier information and the second resource identifier information can be added to the resource identifier queue for temporary storage. Then, each piece of first resource identifier information in the resource identifier queue is traversed to determine whether each piece of first resource identifier information contains other resource identifier information.
[0071] In one implementation, for each first resource identifier, if the first resource identifier corresponds to an Extensible Markup Language (XML) file, then each third resource identifier in the XML file is read, and the third resource identifier and the custom second resource identifier are used as the first resource index information corresponding to the preset reserved target resource.
[0072] If the first resource identifier information corresponds to a sub-resource with inherited attributes, the first resource identifier information, the fourth resource identifier information inherited by the sub-resource, and the custom second resource identifier information are used as the first resource index information corresponding to the target resource that is reserved in the preset.
[0073] Here, the fourth resource identifier information inherited by the sub-resource can be the parent resource identifier information of the first resource identifier information.
[0074] If the first resource identifier information corresponds to data of a numerical type, no operation is required.
[0075] Based on the above, the first resource index information corresponding to all preset reserved target resources can be obtained.
[0076] Regarding S102 above, after deleting the second resource index information, the method further includes the following steps:
[0077] If the resource index information corresponding to each resource under the target resource type belongs to the deleted second resource index information, then the format of the resource name string corresponding to the target resource type is modified to indicate that the second resource index information corresponding to the target resource type has been deleted.
[0078] Here, if the resource index information corresponding to each resource under the target resource type all belongs to the deleted second resource index information, it means that after deleting the second resource index information, there are no resources under this target resource type. Here, the format of the resource name string corresponding to the target resource type can be modified to "?<resource type ID>". <resource type ID> represents the identifier information of this resource type. The modified resource name string indicates that there are no resources under this resource type.
[0079] Since the second resource index information has been deleted, other information about the resource corresponding to the second resource index information can also be deleted. In one implementation, configuration information corresponding to resources other than the target resource can be deleted. For example, the configuration information may include at least one of metadata and offset information.
[0080] Wherein, the resources other than the target resource are resources with type function structures under multiple resource types; when the configuration information includes offset information, in one implementation, the process of deleting the second resource index information to obtain the target resource index file may include the following steps:
[0081] (1) For each type function structure of the target resource type, the length of the offset array corresponding to the type function structure can be modified based on the last valid offset in the offset array corresponding to the type function structure.
[0082] Since the deletion involves deleting resources of type function structures and their corresponding offset information, for each type function structure under the target resource type, the offset array for each type function structure is obtained. Then, the last valid offset is found, and the resource quantity and length of the offset array for each type function structure are modified. Specifically, the resource quantity for each type function structure can be modified to the index value of the remaining resources plus 1, and the length of the offset array for each type function structure can be modified to the index value of the last valid offset plus 1.
[0083] (2) Based on the length of the modified offset array corresponding to each type function structure under the target resource type, determine the length of the configuration array corresponding to the target resource type; the length of the configuration array is the maximum value among the lengths of each modified offset array.
[0084] Here, the length of the configuration array (config array) in the TypeSpec structure under the target resource type can be modified to the maximum value among the lengths of each modified offset array.
[0085] Furthermore, the number of resources in the TypeSpec structure corresponding to the target resource type can be determined based on the modified resource quantity corresponding to each type function structure under the target resource type; the number of resources in the TypeSpec structure is the maximum value among the modified resource quantities corresponding to each type function structure.
[0086] (3) Generate the target resource index file based on the length of the offset array corresponding to the type function structure and the length of the configuration array.
[0087] Here, when generating the target resource index file, it is also possible to generate it based on the number of resources corresponding to the type function structure and the number of resources in the TypeSpec structure.
[0088] Regarding S103 above, in one embodiment, the process of adding the original resource index file and each resource to the installation package to be released in a compressed manner may include the following steps:
[0089] (1) Add the original resource index file and each resource to the resource package of the installation package to be released in a compressed manner.
[0090] Here, the original resource index file can be compressed into the resource package using a lossless compression method called DEFLATE, and each resource can also be added to the resource package using this lossless compression method.
[0091] (2) Add the resource package to the preset directory of the installation package to be released in an uncompressed manner.
[0092] Here, the resource package can be placed in the APK's assets directory in an uncompressed format, such as STORE. The assets directory can be a user-defined directory, or in other implementations, it can be placed in other directories.
[0093] In a specific implementation, during the process of adding the target resource index file and target resources to the installation package to be released in an uncompressed manner, the target resource index file can be added to the initial directory of the APK in an uncompressed manner, such as STORE, specifically the root directory of the APK. The target resources can also be added to the res file in the root directory in this uncompressed manner.
[0094] During the execution of step S103 above, the target resource index file and target resources are saved uncompressed to the res folder in the APK root directory. Thus, during the subsequent installation of the target application, the installation process in the target operating system can detect the uncompressed target resource index file and target resources when verifying the res folder, allowing the installation process to execute normally. By adding the original resource index file and each resource to the APK's assets directory in compressed form, and adding the assets directory to the installation process in the target operating system, the installation process can find the complete resources (i.e., the original resource index file and each resource) stored in the assets directory during the actual installation of the target application, instead of continuing to search for resources in the res folder in the APK root directory.
[0095] The target installation package obtained by the above method can significantly reduce the size of the installation package. For example, the original resource index file in an installation package is 3.8M in size, and the compressed original resource index file is approximately 700k in size. If the installation package obtained using the original resource index file is under the constraint that compression is not allowed, the data volume increases by approximately 3.1M compared to the installation package obtained using the compressed original resource index file. If the software installation package generation method provided in this disclosure is used, the resulting installation package contains approximately 700k of compressed original resource index file, approximately 500k of trimmed target resource index file, and approximately 400k of target resources, which increases the data volume by approximately 1M compared to the installation package obtained using the compressed original resource index file. Therefore, it can be seen that the software installation package generation method provided in this disclosure can significantly reduce the size of the installation package.
[0096] After obtaining the target installation package, in order to ensure that the installation process in the target operating system can flow normally to the node for searching for resources from the preset directory used to store the original resource index file and each resource, the method for generating the software installation package provided in this disclosure embodiment can modify the resource search directory. Specifically, during the process of installing the target application using the target installation package in the target operating system, the original resource directory in the target installation package can be replaced by a pre-created target resource directory. In this way, the installation process in the target operating system no longer searches for resources based on the resource directory used to search for resources from the original resource directory of the APK (the original resource directory corresponds to the target resource index file and the target resources), but instead searches for the corresponding resource package based on the pre-created target resource directory.
[0097] In practical implementation, when installing the target application, at least one page can already be created. Therefore, an application context relationship, i.e., an application context such as ApplicationContext, can exist for at least one page that has already been built. Thus, the practical implementation may include the following steps:
[0098] (1) During the process of installing the target application using the target installation package in the target operating system, it is determined whether there is an application context relationship that has been built.
[0099] Here, the application context can be automatically created by the target operating system when the page is loaded.
[0100] (2) If it exists, the original resource directory that already exists in the resource directory manager is replaced by the pre-created target resource directory so that the target operating system can obtain the resource package corresponding to the target resource directory.
[0101] Here, the existing resource directories in the resource target manager, such as mApkAssets in Resources' AssetManager, are automatically created by the target operating system during the installation of the target application. Pre-created target resource directories refer to directories pre-created for the original resource files and individual resources. For example, ApkAssets can be built based on file descriptor information, file offsets, and resource package length information. Since the resource packages are added to the default directories of the installation package to be released, replacing the existing original resource directories in the resource target manager with pre-created target resource directories allows the target operating system to quickly locate the resource packages corresponding to the target resource directory—that is, the original resource index files and individual resources—based on the file descriptor information, file offsets, and resource package lengths within the target resource directory.
[0102] (3) If it does not exist, the target resource directory is used to replace the original resource directory that already exists in the resource directory dictionary in the resource manager, so that after the application context relationship is constructed, the target operating system can find the target resource directory from the resource directory dictionary and obtain the resource package corresponding to the target resource directory.
[0103] If it does not exist, it means that the target operating system has not created the application context relationship. In this case, the target resource directory, such as ApkAssets, can be used to replace the original resource directory that already exists in the resource directory dictionary in the resource manager, such as ApkAssets in ResourceManager's mCachedApkAssets. This way, after the application context relationship is built, the target operating system can find the target resource directory from the resource directory dictionary and obtain the resource package corresponding to the target resource directory.
[0104] Those skilled in the art will understand that, in the above-described method of the specific implementation, the order in which each step is written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0105] Based on the same inventive concept, this disclosure also provides a software installation package generation device corresponding to the software installation package generation method. Since the principle of the device in this disclosure for solving the problem is similar to the software installation package generation method described above in this disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be described again.
[0106] Reference Figure 2The diagram shown is an architectural schematic of a data device provided in an embodiment of this disclosure. The device includes: a first acquisition module 201, a first determination module 202, and an addition module 203; wherein,
[0107] The first acquisition module 201 is used to acquire the original resource index file contained in the installation package to be released corresponding to the target application; the original resource index file contains resource index information corresponding to each resource;
[0108] The first determining module 202 is used to determine the second resource index information corresponding to other resources in the original resource index file besides the target resource based on the first resource index information corresponding to the target resource that is reserved in a preset manner, and delete the second resource index information to obtain the target resource index file;
[0109] Adding module 203 is used to add the target resource index file and the target resources in an uncompressed manner, and the original resource index file and each resource in a compressed manner, to the installation package to be released, to obtain the target installation package for release.
[0110] In an optional implementation, before determining the second resource index information corresponding to other resources besides the target resource in the original resource index file based on the first resource index information corresponding to the preset reserved target resource, the apparatus further includes:
[0111] The second acquisition module is used to acquire the first resource identification information contained in the application manifest file in the installation package to be released;
[0112] The second determining module is used to use the first resource identification information and the custom second resource identification information as the first resource index information corresponding to the preset reserved target resource.
[0113] In one optional implementation, the second determining module is specifically used for:
[0114] If the first resource identifier information corresponds to an Extensible Markup Language (XML) file, then read each third resource identifier information in the XML file, and use the third resource identifier information and the custom second resource identifier information as the first resource index information corresponding to the preset reserved target resource; or
[0115] If the first resource identifier information corresponds to a sub-resource with inheritance attributes, the first resource identifier information, the fourth resource identifier information inherited by the sub-resource, and the custom second resource identifier information are used as the first resource index information corresponding to the preset reserved target resource.
[0116] In an optional implementation, after deleting the second resource index information, the apparatus further includes:
[0117] The first modification module is used to modify the format of the resource name string corresponding to the target resource type if the resource index information corresponding to each resource under the target resource type belongs to the deleted second resource index information, so as to indicate that the second resource index information corresponding to the target resource type is deleted.
[0118] In an optional implementation, after determining the second resource index information corresponding to resources other than the target resource in the original resource index file, the apparatus further includes:
[0119] The deletion module is used to delete the configuration information corresponding to the other resources; the configuration information includes at least one of metadata and offset information.
[0120] In one optional implementation, the other resources are resources with type function structures under multiple resource types; the configuration information includes offset information;
[0121] The device further includes:
[0122] The second modification module is used to modify the length of the offset array corresponding to the type function structure for each type function structure under the target resource type, based on the last valid offset in the offset array corresponding to the type function structure; and
[0123] The third determining module is used to determine the length of the configuration array corresponding to the target resource type based on the length of the modified offset array corresponding to each type function structure under the target resource type; the length of the configuration array is the maximum value among the lengths of each modified offset array;
[0124] The generation module is used to generate a target resource index file based on the length of the offset array corresponding to the type function structure and the length of the configuration array.
[0125] In one alternative implementation, a module is added, specifically for:
[0126] The original resource index file and each resource are added to the resource package of the installation package to be released in a compressed manner;
[0127] The resource package is added in an uncompressed manner to the target resource directory pre-created in the installation package to be released.
[0128] In one optional embodiment, the apparatus further includes:
[0129] The replacement module is used to replace the original resource directory in the target installation package with the pre-created target resource directory during the installation of the target application using the target installation package in the target operating system, so that the target operating system can obtain the resource package corresponding to the target resource directory; the original resource directory corresponds to the target resource index file and the target resource.
[0130] In one optional implementation, the replacement module is specifically used for:
[0131] During the process of installing the target application using the target installation package on the target operating system, it is determined whether an application context relationship that has already been built exists.
[0132] If it exists, the pre-created target resource directory is used to replace the original resource directory that already exists in the resource directory manager, so that the target operating system can obtain the resource package corresponding to the target resource directory;
[0133] If it does not exist, the original resource directory that already exists in the resource directory dictionary in the resource manager is replaced with the target resource directory, so that after the application context relationship is built, the target operating system can find the target resource directory from the resource directory dictionary and obtain the resource package corresponding to the target resource directory.
[0134] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0135] Based on the same technical concept, this disclosure also provides a computer device. (See also...) Figure 3 The diagram shows the structure of a computer device 300 provided in this embodiment, including a processor 301, a memory 302, and a bus 303. The memory 302 stores execution instructions and includes a main memory 3021 and an external memory 3022. The main memory 3021, also called internal memory, is used to temporarily store computational data in the processor 301 and data exchanged with external memory such as a hard disk. The processor 301 exchanges data with the external memory 3022 through the main memory 3021. When the computer device 300 is running, the processor 301 and the memory 302 communicate through the bus 303, causing the processor 301 to execute the following instructions:
[0136] Obtain the original resource index file contained in the installation package to be released for the target application; the original resource index file contains resource index information corresponding to each resource;
[0137] Based on the first resource index information corresponding to the target resource that is reserved in the preset, the second resource index information corresponding to other resources in the original resource index file other than the target resource is determined, and the second resource index information is deleted to obtain the target resource index file;
[0138] The target resource index file and the target resources are added to the installation package to be released in an uncompressed manner, while the original resource index file and each resource are added in a compressed manner, to obtain the target installation package for release.
[0139] This disclosure also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the software installation package generation method described in the above method embodiments. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0140] This disclosure also provides a computer program product, which carries program code. The instructions included in the program code can be used to execute the steps of the software installation package generation method described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0141] The aforementioned computer program product can be implemented through hardware, software, or a combination thereof. In one optional embodiment, the computer program product is specifically embodied in a computer storage medium; in another optional embodiment, the computer program product is specifically embodied in a software product, such as a software development kit (SDK), etc.
[0142] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division; in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection may be through some communication interfaces; the indirect coupling or communication connection of devices or units may be electrical, mechanical, or other forms.
[0143] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0144] In addition, the functional units in the various embodiments of this disclosure can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0145] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a processor-executable, non-volatile, computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0146] Finally, it should be noted that the above-described embodiments are merely specific implementations of this disclosure, used to illustrate the technical solutions of this disclosure, and not to limit it. The protection scope of this disclosure is not limited thereto. Although this disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this disclosure. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this disclosure, and should all be covered within the protection scope of this disclosure. Therefore, the protection scope of this disclosure should be determined by the protection scope of the claims.
Claims
1. A method for generating a software installation package, characterized in that, include: Obtain the original resource index file contained in the installation package to be released for the target application; The original resource index file contains resource index information corresponding to each resource; Based on the first resource index information corresponding to the target resource that is reserved in the preset, the second resource index information corresponding to other resources in the original resource index file other than the target resource is determined, and the second resource index information is deleted to obtain the target resource index file; The target resource index file and the target resources are added to the installation package to be released in an uncompressed manner, while the original resource index file and each resource are added in a compressed manner, to obtain the target installation package for release; During the process of installing the target application using the target installation package on the target operating system, it is determined whether an application context relationship that has already been built exists. If it exists, the original resource directory that already exists in the resource directory manager is replaced by the target resource directory that was pre-created in the target installation package, so that the target operating system can obtain the resource package corresponding to the target resource directory, and the original resource directory corresponds to the target resource index file and the target resource; If it does not exist, the target resource directory is used to replace the original resource directory that already exists in the resource directory dictionary in the resource manager, so that after the application context relationship is built, the target operating system can find the target resource directory from the resource directory dictionary and obtain the resource package corresponding to the target resource directory; the resource package corresponding to the target resource directory includes the original resource index file and the various resources.
2. The method according to claim 1, characterized in that, Before determining the second resource index information corresponding to other resources besides the target resource in the original resource index file based on the first resource index information corresponding to the preset reserved target resource, the method further includes: Obtain the first resource identifier information contained in the application manifest file of the installation package to be released; The first resource identifier information and the custom second resource identifier information are used as the first resource index information corresponding to the preset reserved target resource.
3. The method according to claim 2, characterized in that, The step of using the first resource identifier information and the custom second resource identifier information as the first resource index information corresponding to the preset reserved target resource includes: If the first resource identifier information corresponds to an Extensible Markup Language (XML) file, then read each third resource identifier information in the XML file, and use the third resource identifier information and the custom second resource identifier information as the first resource index information corresponding to the preset reserved target resource; or If the first resource identifier information corresponds to a sub-resource with inheritance attributes, the first resource identifier information, the fourth resource identifier information inherited by the sub-resource, and the custom second resource identifier information are used as the first resource index information corresponding to the preset reserved target resource.
4. The method according to claim 1, characterized in that, After deleting the second resource index information, the method further includes: If the resource index information corresponding to each resource under the target resource type all belong to the deleted second resource index information, then the format of the resource name string corresponding to the target resource type is modified to indicate that the second resource index information corresponding to the target resource type has been deleted.
5. The method according to claim 1, characterized in that, After determining the second resource index information corresponding to resources other than the target resource in the original resource index file, the method further includes: Delete the configuration information corresponding to the other resources; the configuration information includes at least one of metadata and offset information.
6. The method according to claim 5, characterized in that, The other resources are resources with type function structures under multiple resource types; the configuration information includes offset information. The step of deleting the second resource index information to obtain the target resource index file includes: For each of the type function structures under the target resource type, the length of the offset array corresponding to the type function structure is modified based on the last valid offset in the offset array corresponding to that type function structure; and, Based on the length of the modified offset array corresponding to each type function structure under the target resource type, the length of the configuration array corresponding to the target resource type is determined; the length of the configuration array is the maximum value among the lengths of each modified offset array. Based on the length of the offset array corresponding to the type function structure and the length of the configuration array, a target resource index file is generated.
7. The method according to claim 1, characterized in that, The step of adding the original resource index file and each resource to the installation package to be released in a compressed manner includes: The original resource index file and each resource are added to the resource package of the installation package to be released in a compressed manner; The resource package is added in an uncompressed manner to the target resource directory pre-created in the installation package to be released.
8. The method according to claim 7, characterized in that, The method further includes: During the process of installing the target application using the target installation package in the target operating system, the original resource directory in the target installation package is replaced by the pre-created target resource directory, so that the target operating system can obtain the resource package corresponding to the target resource directory; the original resource directory corresponds to the target resource index file and the target resource.
9. A software installation package generation apparatus, characterized in that, include: The first acquisition module is used to acquire the original resource index file contained in the installation package to be released corresponding to the target application; The original resource index file contains resource index information corresponding to each resource; The first determining module is used to determine the second resource index information corresponding to other resources in the original resource index file besides the target resource based on the first resource index information corresponding to the target resource that is reserved in a preset manner, and delete the second resource index information to obtain the target resource index file; An adding module is used to add the target resource index file and the target resources in an uncompressed manner, and the original resource index file and each resource in a compressed manner, to the installation package to be released, so as to obtain a target installation package for release; The replacement module is used to determine whether an application context relationship has been built during the process of installing the target application using the target installation package in the target operating system; if it exists, the original resource directory that already exists in the resource directory manager is replaced with the target resource directory that was pre-created in the target installation package, so that the target operating system can obtain the resource package corresponding to the target resource directory, and the original resource directory corresponds to the target resource index file and the target resource; If it does not exist, the target resource directory is used to replace the original resource directory that already exists in the resource directory dictionary in the resource manager, so that after the application context relationship is built, the target operating system can find the target resource directory from the resource directory dictionary and obtain the resource package corresponding to the target resource directory; the resource package corresponding to the target resource directory includes the original resource index file and the various resources.
10. A computer device, characterized in that, include: The computer device includes a processor, a memory, and a bus, wherein the memory stores machine-readable instructions executable by the processor, and the processor communicates with the memory via the bus when the computer device is running, and the machine-readable instructions, when executed by the processor, perform the steps of the method for generating a software installation package as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the method for generating a software installation package as described in any one of claims 1 to 8.
Citation Information
Patent Citations
APK file compression method and system based on Android system
CN105138333A
Method and device for constructing application program resource package and terminal equipment
CN112835610A