Resource encapsulation method, resource loading method and electronic device

By binding and encapsulating the target resource identifier with the resource package, the problem of being unable to extract some data resources during data encapsulation and packaging is solved, enabling convenient file resource reuse and development flexibility.

CN116319754BActive Publication Date: 2026-08-04CHENGDU CELIS TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHENGDU CELIS TECH CO LTD
Filing Date
2023-03-17
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

In existing technologies, it is impossible to extract and utilize some data resources from the overall resource package during data encapsulation and packaging, resulting in significant limitations in business development.

Method used

By determining the target resource identifier and binding it to the resource package, a packaged file resource is generated, which includes data resources and resource identifiers, and supports matching and loading of the target resource identifier.

Benefits of technology

It enables convenient extraction of target data resources from resource packages, supports the reuse of file resources in business development, and improves development flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116319754B_ABST
    Figure CN116319754B_ABST
Patent Text Reader

Abstract

The application provides a resource packaging method, a resource loading method and an electronic device. A target resource identifier and a resource package are bound and packaged to obtain a packaged file resource. Since the target resource identifier is a resource identifier of a data resource to be loaded in the resource package, and the resource package includes the data resource and the resource identifier of each data resource, other terminal devices can match the data resource corresponding to the target resource identifier from the resource package according to the target resource identifier after obtaining the packaged file resource, and then directly use the data resource corresponding to the target resource identifier, which is more convenient for file resource reuse in service development.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of resource encapsulation and loading technology, and in particular to a resource encapsulation method, a resource loading method, and an electronic device. Background Technology

[0002] Currently, data transmission via networks has become an important means of information delivery. Relying on network-based data transmission, the sending end can encapsulate and package data before sending it to the appropriate receiving end. The receiving end can then perform corresponding operations on the encapsulated and packaged data sent by the sending end according to its own needs, such as storage, downloading, decapsulation, and loading. This type of data transmission has been widely used in application services across various scenarios.

[0003] However, currently, when packaging and packaging data, all business-related data resources are typically packaged into a single resource package, which is a whole. When only a portion of the data resources within this resource package needs to be utilized, it is impossible to extract the data resources from the entire resource package, which significantly limits business development. Summary of the Invention

[0004] The purpose of this application is to provide a resource encapsulation method, a resource loading method, and an electronic device to solve the above-mentioned technical problems.

[0005] On the one hand, a resource encapsulation method is provided, the method comprising:

[0006] Determine the resource package to be packaged and the target resource identifier; the resource package includes data resources and resource identifiers for each data resource, and the target resource identifier is the resource identifier of the data resource to be loaded in the resource package;

[0007] The target resource identifier and the resource package are bound and encapsulated to obtain the encapsulated file resource.

[0008] In one embodiment, the resource package includes multiple data resources; determining the resource package to be packaged includes:

[0009] Obtain multiple data resources to be compiled and the resource identifier of each of the data resources to be compiled;

[0010] The data resources to be compiled and their resource identifiers are processed for compilation, and a resource package to be packaged is obtained based on the compilation results.

[0011] In one embodiment, the step of compiling each of the data resources to be compiled and the resource identifiers of each of the data resources to be compiled, and obtaining a resource package to be packaged based on the compilation result, includes:

[0012] The compilation process is performed on each of the data resources to be compiled and its resource identifier to obtain the corresponding compilation artifacts.

[0013] The compiled output is encrypted to obtain the resource package to be packaged.

[0014] In one embodiment, the step of encrypting the compiled output to obtain the resource package to be packaged includes:

[0015] The compiled product is encrypted using a symmetric encryption algorithm to obtain the resource package to be packaged.

[0016] In one embodiment, the step of binding and encapsulating the target resource identifier and the resource package to obtain the encapsulated file resource includes:

[0017] Identify the file identifier;

[0018] The file identifier, the target resource identifier, and the resource package are bound and encapsulated to obtain the encapsulated file resource.

[0019] In one embodiment, binding and encapsulating the file identifier, the target resource identifier, and the resource package to obtain the encapsulated file resource includes:

[0020] Determine the data length information of the resource package;

[0021] The file identifier, the data length information, the target resource identifier, and the resource package are bound and encapsulated to obtain the encapsulated file resource.

[0022] On the other hand, a resource loading method is provided, including:

[0023] Upon receiving a resource loading instruction, the encapsulated file resource obtained according to any of the above resource encapsulation methods is decapsulated to obtain the target resource identifier and the resource package.

[0024] Based on the target resource identifier, the data resource corresponding to the target resource identifier is determined from the resource package and loaded.

[0025] In one embodiment, when the resource package is an encrypted resource package, the step of determining and loading the data resource corresponding to the target resource identifier from the resource package based on the target resource identifier includes:

[0026] The resource package is decrypted;

[0027] Based on the target resource identifier, the data resource corresponding to the target resource identifier is determined from the decrypted resource package and loaded.

[0028] In one embodiment, when the file resource includes a file identifier and data length information, the decryption process of the resource package includes:

[0029] When the file identifier matches the preset file identifier, data content of the corresponding length is read from the resource package according to the data length information;

[0030] The data content is then decrypted.

[0031] On the other hand, this application also provides an electronic device, including a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement any of the methods described above.

[0032] The resource encapsulation method, resource loading method, and electronic device provided in this application can bind and encapsulate a target resource identifier with a resource package to obtain an encapsulated file resource. Since the target resource identifier is the resource identifier of the data resource to be loaded in the resource package, and the resource package contains data resources and resource identifiers of each data resource, other terminal devices can match the data resource corresponding to the target resource identifier from the resource package after obtaining the encapsulated file resource, and then directly utilize the data resource corresponding to the target resource identifier, which is more convenient for file resource reuse in business development. Attached Figure Description

[0033] Figure 1 A flowchart illustrating the resource encapsulation method provided in Embodiment 1 of this application;

[0034] Figure 2 This is a flowchart illustrating the process of determining the resource package to be packaged, as provided in Embodiment 1 of this application.

[0035] Figure 3 A flowchart illustrating the resource loading method provided in Embodiment 1 of this application;

[0036] Figure 4 This is a flowchart illustrating the resource encapsulation method provided in Embodiment 2 of this application;

[0037] Figure 5 This is a schematic diagram of the data encapsulation format of the file resources provided in Embodiment 2 of this application;

[0038] Figure 6This is a flowchart illustrating the resource loading method provided in Embodiment 2 of this application;

[0039] Figure 7 This is a schematic diagram of the structure of the electronic device provided in Embodiment 3 of this application. Detailed Implementation

[0040] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0041] Example 1:

[0042] This application provides a resource encapsulation method. Please refer to [link to relevant documentation]. Figure 1 As shown, it includes the following steps:

[0043] S11: Determine the resource package to be packaged and the target resource identifier; the resource package includes data resources and resource identifiers of each data resource, and the target resource identifier is the resource identifier of the data resource to be loaded in the resource package.

[0044] S12: Bind and encapsulate the target resource identifier and resource package to obtain the encapsulated file resource.

[0045] The specific process of the above steps will be explained in detail below.

[0046] The resource package in this embodiment can be encapsulated from a single data resource, or it can be encapsulated from multiple data resources and their respective resource identifiers. That is, the resource package contains a correspondence between data resources and resource identifiers, allowing the corresponding data resource to be matched and utilized based on the required resource identifier.

[0047] In this application embodiment, the target resource identifier can be selected by the developer according to their needs. For example, for data resources in the resource package that need to be used multiple times independently, or for data resources in the resource package that need to be transmitted to other terminals for independent use, the data resource can be used as the data resource to be loaded, and the resource identifier corresponding to the data resource can be used as the target resource identifier. It should be noted that "utilization" here can refer to "resource loading," that is, the resource identifier of the data resource in the resource package that needs to be loaded later can be directly used as the target resource identifier.

[0048] For step S11 above, please refer to Figure 2 As shown, when the resource package includes multiple data resources, the following sub-steps may be included:

[0049] S111: Obtain multiple data resources to be compiled and the resource identifier of each data resource to be compiled.

[0050] S112: Perform compilation processing on each data resource to be compiled and its resource identifier, and obtain the resource package to be packaged based on the compilation processing results.

[0051] In this embodiment, the data resource to be compiled can be any format, such as SVG format. In an optional implementation, the compiled data resource and resource identifier can be directly encapsulated, that is, the compilation product can be directly encapsulated to obtain the resource package in step S11. At this time, the resource package consists of the compiled data resource and resource identifier.

[0052] In practical applications, after obtaining the file resource, it may need to be uploaded to other terminals for application, such as for loading. Therefore, in another optional implementation, to prevent the resource package in the file resource from being modified during transmission, the compilation output can be encrypted; that is, the resource package in the file resource is an encrypted resource package. Specifically, in this embodiment, a symmetric encryption algorithm can be used to encrypt the compilation output to obtain the resource package to be packaged. For example, the RSA encryption algorithm can be used for encryption.

[0053] In this embodiment, the encapsulated file resource includes at least a target resource identifier and a resource package. It is understood that, to facilitate subsequent file type identification, the file resource may also include a file identifier; that is, step S12 may include the following sub-steps:

[0054] Identify the file identifier;

[0055] The file identifier, target resource identifier, and resource package are bound and encapsulated to obtain the encapsulated file resource.

[0056] Specifically, developers can set corresponding file identifiers based on the type of file resource. For example, the header identifier of the encapsulated file resource can be the file identifier, which is used to indicate the type of file resource.

[0057] In some embodiments, in order to facilitate the accurate parsing of the resource package from the encapsulated file resources, the data length information of the resource package can be determined. This data length information can represent the actual data length of the resource package. Then, the file identifier, data length information, target resource identifier and resource package are bound and encapsulated to obtain the encapsulated file resources.

[0058] It should be noted that the data length information here can be used to indicate the total data length of the resource package.

[0059] This application also provides a resource loading method. Please refer to [link to relevant documentation]. Figure 3 As shown, it includes the following steps:

[0060] S31: Upon receiving a resource loading instruction, the file resource to be unsealed is unsealed to obtain the target resource identifier and resource package.

[0061] S32: Based on the target resource identifier, determine the data resource corresponding to the target resource identifier from the resource package and load it.

[0062] The file resource to be unsealed in step S31 can be a packaged file resource obtained through the above-described resource encapsulation method.

[0063] Step S32 may include the following sub-steps:

[0064] Decrypt the resource package;

[0065] The data resource corresponding to the target resource identifier is determined from the decrypted resource package based on the target resource identifier and then loaded.

[0066] For example, in some embodiments, in addition to the target resource identifier and resource package mentioned above, the file resource may also include a file identifier and data length information. In this case, decrypting the resource package includes:

[0067] When the file identifier matches the preset file identifier, read the corresponding length of data content from the resource package according to the data length information;

[0068] The data content is decrypted.

[0069] It should be noted that the resource loading method provided in this application embodiment essentially includes the reverse process of the above-described resource encapsulation method, so the content described in the above-described resource encapsulation method can be referred to, and the specific steps will not be repeated here.

[0070] The resource encapsulation method and resource loading method provided in this application can bind and encapsulate the target resource identifier of the data resource to be loaded with a resource package to obtain the encapsulated file resource. Since the resource package contains data resources and resource identifiers of each data resource, other terminals can load the data resource corresponding to the target resource identifier from the resource package after obtaining the encapsulated file resource, which is more convenient for file resource reuse in business development.

[0071] Example 2:

[0072] Currently, SVG format images and animations are widely used in Android-based cockpit operating systems. Although they are all SVG format, different third-party frameworks have significantly different support for SVG decoding capabilities. Among them, the SVG decoding module built into the Android resource system has the best decoding capabilities and compatibility. However, the SVG resources of this module must be statically defined in the business APK package and cannot be dynamically loaded, which brings considerable limitations to business development.

[0073] To address this issue, this application provides a more specific resource encapsulation method. Please refer to [link to relevant documentation]. Figure 4 As shown, it includes:

[0074] S41: Obtain multiple data resources to be compiled and the resource identifier of each data resource to be compiled.

[0075] In step S41, the data resource to be compiled is an SVG format data resource. That is, in step S41, the standard Android SVG resource "SVG.xml" is obtained as the data resource to be compiled, as well as the resource identifier of "SVG.xml".

[0076] S42: Compile multiple data resources to be compiled and the resource identifiers of each data resource to obtain the compilation product.

[0077] In step S42, the compilation output resource.apk can be obtained by using the Android standard AAPT2 tool.

[0078] S43: Encrypt the compiled output to obtain the resource package.

[0079] In step S43, the compiled product resource.apk can be encrypted using the RSA symmetric encryption algorithm to obtain the resource package to be packaged.

[0080] S44: The target resource identifier, file identifier, data length information of the resource package, and the resource package are encapsulated to obtain the file resource.

[0081] In this embodiment, the file identifier, target resource identifier, data length information, and resource package can be concatenated and encapsulated to obtain the file resource. That is, the data format of the encapsulated file resource can be as follows: Figure 5 As shown.

[0082] The file resource comprises four parts from header to footer: header, resourceID, data length, and datatrack, representing the file identifier, target resource identifier, data length information, and resource package, respectively. It is understood that the file resource data format can also be other formats, and the order of header, resourceID, datalength, and datatrack is not limited to the order shown in the embodiments of this application.

[0083] In this embodiment of the application, the header of the file resource can be set to "XSVG".

[0084] Based on the resource encapsulation method provided in the embodiments of this application, the embodiments of this application also provide a resource loading method, please refer to [link to relevant documentation]. Figure 6 As shown, it includes:

[0085] S61: Receive resource loading instructions.

[0086] It is understandable that the resource loading instruction can contain the target resource identifier of the data resource to be loaded. Based on the target resource identifier, the file resource containing the target resource identifier can be identified from multiple encapsulated file resources, and that file resource can be used as the target file resource to be uncapsulated.

[0087] S62: Verify file identifier.

[0088] Step S62 refers to verifying the file identifier in the target file resource.

[0089] S63: After verification, read the corresponding length of data content from the data packet of the file resource according to the data length information and decrypt it.

[0090] If the verification fails, no further parsing is required, which saves processor resources.

[0091] S64: Use the target resource identifier to determine the corresponding data resource from the decrypted resource package and load it.

[0092] Specifically, after obtaining an XSVG format file resource from the internet or any other data source, you can unpack the file resource. When the file resource's data format is... Figure 5When the format is shown, the unpacking steps for file resources can be as follows: First, verify the file header (i.e., file identifier). If the first 4 bytes are "XSVG", the verification passes. Then, parse the last 8 bytes sequentially using big-endian byte order. If it is a long integer, record the information. Then, parse the last 8 bytes sequentially again, parsing it as a long value, which is used as the byte length for reading the resource package. Then, use this byte length to read all the data content in the resource package. Decrypt the read data content to obtain the standard Android resource package resource.apk. After obtaining the standard Android resource package resource.apk, use the Android standard dynamic apk loading mechanism to read and load the data resource corresponding to the target resource identifier.

[0093] The resource loading method provided in this application embodiment maintains high decoding efficiency and compatibility, and can also better realize file resource reuse and dynamic loading. It does not require statically defining the SVG resources to be loaded into the business APK. The corresponding data resources can be determined and loaded by the target resource identifier in the file resources.

[0094] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0095] Example 3:

[0096] This embodiment provides an electronic device; please refer to [link / reference]. Figure 7 As shown, the electronic device includes a processor 701 and a memory 702. The memory 702 stores a computer program. The processor 701 and the memory 702 communicate via a communication bus. The processor 701 executes the computer program to implement the steps of the method in the above embodiments, which will not be described again here. It is understood that... Figure 7 The structure shown is for illustrative purposes only; the electronic device may also include components that are more advanced than those shown. Figure 7 The more or fewer components shown, or having the same Figure 7 The different configurations shown are illustrated. It should be noted that the electronic devices in the embodiments of this application can be installed in a vehicle.

[0097] The processor 701 can be an integrated circuit chip with signal processing capabilities. The processor 701 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor.

[0098] The memory 702 may include, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable read-only memory (EPROM), electrically erasable read-only memory (EEPROM), etc.

[0099] This embodiment also provides a computer-readable storage medium, such as a floppy disk, optical disk, hard disk, flash memory, USB flash drive, SD card, MMC card, etc., in which one or more programs implementing the above steps are stored. These one or more programs can be executed by one or more processors 301 to implement the steps of the method in the above embodiment, which will not be described again here.

[0100] It should be noted that the illustrations provided in this embodiment are only schematic representations of the basic concept of the present invention. Therefore, the drawings only show components relevant to the present invention and are not drawn according to the actual number, shape, and size of components in implementation. In actual implementation, the form, quantity, and proportion of each component can be arbitrarily changed, and the component layout may be more complex. The structures, proportions, sizes, etc., depicted in the accompanying drawings are only for illustrative purposes to aid those skilled in the art and are not intended to limit the implementation conditions of the present invention. Therefore, they have no substantial technical significance. Any modifications to the structure, changes in proportions, or adjustments to size, without affecting the effects and objectives of the present invention, should still fall within the scope of the technical content disclosed in the present invention. Furthermore, the terms such as "upper," "lower," "left," "right," "middle," and "one" used in this specification are only for clarity of description and are not intended to limit the scope of the present invention. Changes or adjustments to their relative relationships, without substantially altering the technical content, should also be considered within the scope of the present invention.

[0101] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0102] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A resource encapsulation method, characterized in that, include: Determine the resource package to be packaged and the target resource identifier; the resource package includes data resources and resource identifiers for each data resource, and the target resource identifier is the resource identifier of the data resource to be loaded in the resource package, used to load the data resource corresponding to the target resource identifier; Determine the file identifier; bind and encapsulate the file identifier, the target resource identifier, and the resource package to obtain the encapsulated file resource; wherein, the file identifier is used to determine whether it matches a preset file identifier.

2. The resource encapsulation method as described in claim 1, characterized in that, The resource package includes multiple data resources; determining the resource package to be packaged includes: Obtain multiple data resources to be compiled and the resource identifier of each of the data resources to be compiled; The data resources to be compiled and their resource identifiers are processed for compilation, and a resource package to be packaged is obtained based on the compilation results.

3. The resource encapsulation method as described in claim 2, characterized in that, The process of compiling each of the data resources to be compiled and their resource identifiers, and obtaining a resource package to be packaged based on the compilation result, includes: The compilation process is performed on each of the data resources to be compiled and its resource identifier to obtain the corresponding compilation artifacts. The compiled output is encrypted to obtain the resource package to be packaged.

4. The resource encapsulation method as described in claim 3, characterized in that, The step of encrypting the compiled output to obtain the resource package to be packaged includes: The compiled product is encrypted using a symmetric encryption algorithm to obtain the resource package to be packaged.

5. The resource encapsulation method according to any one of claims 1-4, characterized in that, The step of binding and encapsulating the file identifier, the target resource identifier, and the resource package to obtain the encapsulated file resource includes: Determine the data length information of the resource package; The file identifier, the data length information, the target resource identifier, and the resource package are bound and encapsulated to obtain the encapsulated file resource.

6. A resource loading method, characterized in that, include: Upon receiving a resource loading instruction, the encapsulated file resource obtained by the resource encapsulation method according to any one of claims 1-5 is decapsulated to obtain the target resource identifier and the resource package; Based on the target resource identifier, the data resource corresponding to the target resource identifier is determined from the resource package and loaded.

7. The resource loading method as described in claim 6, characterized in that, When the resource package is an encrypted resource package, the step of determining and loading the data resource corresponding to the target resource identifier from the resource package based on the target resource identifier includes: The resource package is decrypted; Based on the target resource identifier, the data resource corresponding to the target resource identifier is determined from the decrypted resource package and loaded.

8. The resource loading method as described in claim 7, characterized in that, When the file resource includes file identifier and data length information, the decryption process of the resource package includes: When the file identifier matches the preset file identifier, data content of the corresponding length is read from the resource package according to the data length information; The data content is then decrypted.

9. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program, and the processor executes the computer program to implement the method as described in any one of claims 1-8.