Patch file generation method and system and storage medium

By comparing the header file information of the Dex file, a differential patch file is generated in class units, which solves the problem of excessive binary changes caused by small file changes in the existing technology, and forms a regular patch file for easy viewing and testing.

CN118535217APending Publication Date: 2024-08-23BYD CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311208301.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-15
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

When the existing technology generates a Dex file difference file, small file changes lead to a large number of binary changes, resulting in a larger difference file, and the file is inconvenient to view and test.

Method used

By obtaining the header file information of the target code file and the original code file, comparing the old and new class information, obtaining the difference information, and generating a patch file, ensure that the patch file is stored in class units to avoid irregular binary codes.

Benefits of technology

The size of the difference file is reduced, and the patch file formed is regular and easy to view and test, making it easy to run in the Android virtual machine.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535217A
    Figure CN118535217A
Patent Text Reader

Abstract

The invention discloses a patch file generation method and system and a storage medium, and the method comprises the steps: obtaining header file information of a target code file and header file information of an original code file, obtaining class information of the target code file as new class information, and obtaining class information of the original code file as original class information; and obtaining difference information between the new class information and the original class information according to the new class information and the original class information, and obtaining the patch file based on the difference information. According to the method, the problem that the generated patch file is too large is avoided, and the patch file is convenient to test and view on the virtual machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of software, and in particular to a method, system and storage medium for generating a patch file. Background Art

[0002] At present, the Dalvik Executable (Dex) file is the executable file format of the Android virtual machine. This type of file is used to save a series of class definitions and their associated auxiliary data, and is a binary file with a certain regular format.

[0003] In the related art, the solution for generating a difference file between two Dex files is mainly to generate it by comparing the binary codes of the files. By comparing the binary codes of the old and new Dex files, the different binary codes are stored in the new file, that is, a difference Dex file is generated. The difference file generated by this technology is mainly that after the Android device receives the difference file, the old Dex file and the difference file are merged into a new Dex file, so that the old Android program can be upgraded to a new code program. However, in the related art, a small change in the file will cause a large number of binary changes, and ultimately a larger difference file will be generated. Summary of the invention

[0004] The present application is proposed to solve the above-mentioned problem. According to one aspect of the present application, a method for generating a patch file is provided, the method comprising: obtaining header file information of a target code file and a source code file respectively; obtaining class information of the target code file as new class information according to the header file information of the target code file, and obtaining class information of the source code file as original class information according to the header file information of the source code file; obtaining difference information between the new class information and the original class information, and obtaining a patch file based on the difference information.

[0005] Exemplarily, the difference information includes a newly added class information set, and / or a changed class information set; the step of obtaining the difference information between the new class information and the original class information includes: obtaining a class description newly added to the target code file compared to the source code file based on the new class information and the original class information; and / or obtaining a class description of the same name between the target code file and the source code file based on the new class information and the original class information; obtaining a newly added class information set based on the newly added class description; and / or obtaining a class information set of the same name based on the class description of the same name, and determining all changed class information of the target code file in the class information set of the same name compared to the source code file to obtain a changed class information set.

[0006] Exemplarily, the method of determining all the changed class information of the target code file in the same-name class information set compared with the original code file to obtain the changed class information set includes: for a class in the same-name class information set, performing the following operations: comparing whether the class in the target code file has changed relative to the class in the original code file, and when there is a change, determining the class information corresponding to the class as the changed class information; performing the operations on other classes in the same-name class information set to obtain all the changed class information, and the set of all the changed class information is the changed class information set.

[0007] Exemplarily, the comparison of whether the class in the target code file has changed relative to the class in the source code file includes at least one of the following: comparing whether the access identifier of the class in the target code file has changed relative to the access identifier of the class in the source code file; comparing whether the parent class description of the class in the target code file has changed relative to the parent class description of the class in the source code file; comparing whether the interface parameters of the class in the target code file have changed relative to the interface parameters of the class in the source code file, the interface parameters including the number of interfaces and / or interface names; comparing whether the source file name of the class in the target code file has changed relative to the source file name of the class in the source code file; comparing whether the annotation of the class in the target code file has changed relative to the annotation of the class in the source code file; comparing whether the field of the class in the target code file has changed relative to the field of the class in the source code file; comparing whether the method of the class in the target code file has changed relative to the method of the class in the source code file; comparing whether the static variables of the class in the target code file have changed relative to the static variables of the class in the source code file.

[0008] Exemplarily, the annotations of the class include: annotation information of the class, annotation information of the class method, annotation information of the class field, and annotation information of the class parameter; when at least one of the annotation information of the class, the annotation information of the class method, the annotation information of the class field, and the annotation information of the class parameter is different, it is determined that the annotation of the class in the target code file has changed relative to the annotation of the class in the source code file.

[0009] Exemplarily, the fields of the class include static fields and instance fields; when at least one of the number of the static fields, the number of the instance fields, and the definition content of the fields of the class are different, it is determined that the fields of the class in the target code file have changed relative to the fields of the class in the source code file; wherein the definition content of the fields of the class includes a field access identifier, a class to which the field belongs, a field type, and a field name.

[0010] Exemplarily, the methods of the class include direct methods and virtual methods; when at least one of the number of the direct methods, the number of the virtual methods, the definition content of the methods of the class, and the code implementation of the methods of the class are different, it is determined that the methods of the class in the target code file have changed relative to the methods of the class in the source code file; wherein the definition content of the methods of the class includes the method access identifier, the class to which the method belongs, the method return value, the method parameter list, and the method declaration description information; when the running instruction information of the methods of the class are consistent, it is confirmed that the code implementation of the methods of the class is the same, wherein the running instruction information of the methods of the class includes: the number of registers, the number of parameters, the number of registers used when calling other methods, the number of instructions, the number of definable variables, the instruction content, and the debugging information.

[0011] Exemplarily, obtaining the class information of the target code file as new class information based on the header file information of the target code file includes: parsing the header file information of the target code file to obtain a first number and a first offset of the classes of the target code, and obtaining the first number of class information of the target code file as new class information based on the first offset; obtaining the class information of the source code file as original class information based on the header file information of the source code file includes: parsing the header file information of the source code file to obtain a second number and a second offset of the classes of the source code file, and obtaining the second number of class information of the source code file as original class information based on the second offset.

[0012] Exemplarily, before obtaining the respective header file information of the target code file and the source code file, the patch file generation method further includes: obtaining the information digest algorithm value of the target code file as the first information digest algorithm value, and obtaining the information digest algorithm value of the source code file as the second information digest algorithm value; when the first information digest algorithm value is different from the second information digest algorithm value, obtaining the respective header file information of the target code file and the source code file for generating the patch file.

[0013] Exemplarily, obtaining a patch file based on the difference information includes: writing the difference information as difference content into a new code file to obtain a patch file, wherein the target code file, the original code file, and the patch file have the same file format.

[0014] According to another aspect of the present application, a patch file generation system is provided, the system comprising a memory and a processor, the memory storing a computer program, and when the computer program is executed by the processor, the processor executes the above-mentioned patch file generation method.

[0015] According to another aspect of the present application, a storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the above-mentioned method for generating a patch file.

[0016] The patch file generation method in the present application obtains the respective new class information and original class information according to the header file information of the target code file and the original code file, and then obtains the difference information between the new class information and the original class information by comparison, and then obtains the patch file according to the difference information. When the method is compared, the entire class is used as the comparison basis. When the new and old class information change, the entire class information is put into the collection, rather than a patch file composed of all the difference information, so it is not easy to have a large file; at the same time, the final patch file is not an irregular binary code, which is convenient for viewing and testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] By describing the embodiments of the present application in more detail in conjunction with the accompanying drawings, the above and other purposes, features and advantages of the present application will become more apparent. The accompanying drawings are used to provide a further understanding of the embodiments of the present application and constitute a part of the specification. Together with the embodiments of the present application, they are used to explain the present application and do not constitute a limitation of the present application. In the accompanying drawings, the same reference numerals generally represent the same components or steps.

[0018] Figure 1 A flowchart of a patch file generation method in an embodiment of the present application is shown.

[0019] Figure 2 A schematic diagram of the header file format in an embodiment of the present application is shown.

[0020] Figure 3 A flowchart of a patch file generation method in an embodiment of the present application is shown.

[0021] Figure 4 A structural block diagram of a patch file generation system in an embodiment of the present application is shown.

[0022] Figure 5A structural block diagram of a patch file generation system processor in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solutions and advantages of the present application more obvious, the example embodiments according to the present application will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application, and it should be understood that the present application is not limited to the example embodiments described herein. Based on the embodiments of the present application described in the present application, all other embodiments obtained by those skilled in the art without creative work should fall within the scope of protection of the present application.

[0024] like Figure 1 As shown, the embodiment of the present application provides a method for generating a patch file, the method comprising the following steps:

[0025] S110, obtaining header file information of the target code file and the source code file.

[0026] S120. Obtain class information of the target code file as new class information according to header file information of the target code file, and obtain class information of the original code file as original class information according to header file information of the original code file.

[0027] S130: Obtain difference information between the new class information and the original class information, and obtain a patch file based on the difference information.

[0028] The patch file generation method in the present application obtains the respective new class information and original class information according to the header file information of the target code file and the original code file, and then obtains the difference information between the new class information and the original class information by comparison, and then obtains the patch file according to the difference information. When performing the comparison, the method uses the entire class as the comparison benchmark. When the new and old class information change, the entire class information is put into the collection, rather than a patch file composed of all the difference information, so that it is not easy to have a large file; at the same time, the final patch file is not an irregular binary code, which is convenient for viewing and testing.

[0029] Exemplarily, before obtaining the header file information of the target code file and the source code file, this method also needs to verify the Md5 value (that is, the message digest algorithm value) of the target code file and the source code file. The message digest algorithm is a widely used cryptographic hash function used to ensure the integrity and consistency of information transmission. The specific process is:

[0030] The information digest algorithm value of the target code file is obtained as the first information digest algorithm value, and the information digest algorithm value of the original code file is obtained as the second information digest algorithm value; when the first information digest algorithm value is different from the second information digest algorithm value, the header file information of the target code file and the original code file is obtained for generating a patch file. Similarly, if the first information digest algorithm value of the target code file and the second information digest algorithm value of the original code file are the same, their information is consistent, and there is no need to generate different difference code files, which can save computing power and improve efficiency.

[0031] like Figure 2 As shown, in step S110, the header file information of the target code file and the source code file is obtained. The header file is part of the Dex file. In the Dex file, in addition to the header file, it also includes index information such as string index, type index, method prototype index, field index, method index, call site index, etc., and also includes class definition area, method handle list, data area and other information.

[0032] In step S120, the class information of the target code file is obtained as the new class information according to the header file information of the target code file, and the class information of the original code file is obtained as the original class information according to the header file information of the original code file. Specifically, after obtaining the Dex header file information, the binary data of the Dex file is loaded, and according to the prescribed format definition of the Dex header file information, the content of the Dex header file can be parsed, and then the number of classes and the offset can be found in the header file area. The offset contains the location information of the class, and then the index position of all classes can be obtained according to the offset, and the required class information can be obtained according to the index position. It should be noted that the class of the Dex file is a user-defined reference data type, also known as a class type, and each class contains a data description and a set of functions for operating data or passing messages. The result obtained by comparing the class information can be used to represent the difference between the new code file and the old code file.

[0033] Exemplarily, for a target code file, class information of the target code file is obtained as new class information based on header file information of the target code file, including: parsing the header file information of the target code file to obtain a first number and a first offset of classes of the target code, and obtaining the first number of class information of the target code file as new class information based on the first offset.

[0034] For the original code file, the class information of the original code file is obtained as the original class information according to the header file information of the original code file, including: parsing the header file information of the original code file to obtain the second number and the second offset of the classes of the original code file, and obtaining the second number of class information of the original code file as the original class information according to the second offset.

[0035] For a class, its class information at least includes: class description, class access identifier, class parent class description, class interface, class source file name, class annotation, class fields and class methods.

[0036] Among them, class is a user-defined reference data type, also known as class type. Each class contains data description and a set of functions that operate data or pass messages. Class description refers to the attributes and methods of the class, which are used to describe the characteristics and behavior of the object. The access identifier of the class refers to the access information used to identify some classes or class interface hierarchies. The parent class description of the class refers to which class or interface a class inherits from. The interface of the class refers to the interface implemented by a class, that is, the methods and attributes that the class needs to implement. The source file name of the class refers to the file name where the class definition is located, usually consisting of the class name and the suffix name. The annotation of the class refers to the special mark added to the code, which can be read during compilation, class loading, and runtime, and the corresponding processing is performed. The field of the class refers to the variable defined in the class, which is used to store the state of the object. The method of the class is the function defined in the class, which is used to implement the behavior of the class. The static variable of the class refers to the variable belonging to the entire class. Static variables can be accessed directly through the class name or through the object.

[0037] Exemplarily, in the storage area of ​​the terminal memory, all class information parsed from the Dex file can be saved, including the class of the target code file and the class of the original code file. After the class description is obtained, the corresponding class information can be searched and obtained from the storage area.

[0038] Exemplarily, the difference information includes a newly added class information set, and / or a changed class information set. In step S130, the difference information between the new class information and the original class information is obtained, including: obtaining a class description newly added to the target code file compared to the original code file based on the new class information and the original class information; and / or obtaining a class description with the same name in the target code file and the original code file based on the new class information and the original class information.

[0039] A newly added class information set is obtained based on the newly added class description; and / or, a class information set with the same name is obtained based on the class description with the same name, and all changed class information of the target code file compared with the original code file in the class information set with the same name is determined to obtain a changed class information set.

[0040] In some embodiments, the difference information includes a newly added class information set and a changed class information set. In step S130, when obtaining the difference information, it is necessary to obtain the newly added class description to obtain the newly added class information set and also to obtain the class description of the same name to obtain the changed class information set.

[0041] In some embodiments, the difference information includes one of a newly added class information set and a changed class information set. In step S130, when obtaining the difference information, the newly added class information set is obtained by obtaining the newly added class description, or the changed class information set is obtained by obtaining the same class description.

[0042] According to the new class information and the original class information, the class description added to the target code file compared to the original code file can be obtained. Similarly, the class description of the target code file and the original code file with the same name can also be obtained. Exemplarily, the class description of the target code file is placed in the first set, and the class description of the original code file is placed in the second set, and then the intersection between the first set and the second set is obtained.

[0043] Among them, the class descriptions in the intersection can be identified as the class descriptions with the same name in the original code file and the target code file, and the class descriptions outside the intersection are the newly added class descriptions in the target code file compared to the original code file. When making a comparison, there may be a situation where there is no intersection between the first set and the second set or all of them are intersections. When there is no intersection, all class descriptions in the target code file are newly added class descriptions compared to the code file, and then the patch file is generated based on the newly added class descriptions. When the first set and the second set are all intersections, all class descriptions in the target code file are class descriptions with the same name, and then the patch file is generated based on the class descriptions with the same name.

[0044] Taking the example that the difference information includes a newly added class information set and a changed class information set, the newly added class information set is obtained based on the newly added class description, and the class information set with the same name is obtained based on the class description with the same name (taking the case where there is intersection and non-intersection between the first set and the second set mentioned above as an example), and all the changed class information in the target code file compared to the original code file in the class information set with the same name is determined to obtain the changed class information set.

[0045] Exemplarily, all the change class information of the target code file compared with the original code file in the same name class information set is determined to obtain the change class information set, including the following contents:

[0046] For a class in the class information set with the same name, the following operation is performed: compare whether the class in the target code file has changed with the class in the source code file, and if there is a change, determine the class information corresponding to the class as the changed class information. Perform the above operation on other classes in the class information set with the same name to obtain all the changed class information, and the set of all the changed class information is the changed class information set.

[0047] When comparing whether the classes in the target code file have changed relative to the classes in the source code file, it is necessary to compare the following items. When at least one of the following (1)-(8) has changed, it can be confirmed that the classes in the target code file have changed compared to the classes in the source code file.

[0048] (1) Compare the access identifiers of the classes in the target code file with those in the source code file to see if there are any changes.

[0049] (2) Compare the parent class description of the class in the target code file with that in the source code file to see if there is any change.

[0050] (3) Compare the interface parameters of the class in the target code file with those of the class in the source code file to see if there are any changes, wherein the interface parameters include the number of interfaces and / or the interface name.

[0051] (4) Compare the source file name of the class in the target code file with the source file name of the class in the original code file to see if there is any change.

[0052] (5) Compare the annotations of the classes in the target code file with those in the source code file to see if there are any changes.

[0053] Exemplarily, the annotation of a class includes: annotation information of the class, annotation information of a method of the class, annotation information of a field of the class, and annotation information of a parameter of the class.

[0054] When at least one of the annotation information of the class, the annotation information of the class method, the annotation information of the class field, and the annotation information of the class parameter is different, it is determined that the annotation of the class in the target code file has changed relative to the annotation of the class in the source code file.

[0055] (6) Compare the fields of the class in the target code file with those in the source code file to see if there are any changes.

[0056] Exemplarily, the fields of a class include static fields and instance fields. When at least one of the number of static fields, the number of instance fields, and the definition content of the fields of a class is different, it is determined that the fields of the class in the target code file have changed relative to the fields of the class in the source code file. The definition content of the fields of a class includes a field access identifier, a class where the field is located, a field type, and a field name. When at least one of the field access identifier, the class where the field is located, the field type, and the field name in the field definition content changes, it can be confirmed that the definition content has changed.

[0057] (7) Compare the methods of the classes in the target code file with those in the source code file to see if there are any changes.

[0058] The class methods include direct methods and virtual methods. When at least one of the number of direct methods, the number of virtual methods, the definition content of the class methods, and the code implementation of the class methods is different, it is determined that the class methods in the target code file are changed relative to the class methods in the original code file.

[0059] The definition of the method of a class includes the method access identifier, the class where the method is located, the method return value, the method parameter list, and the method declaration description information. When at least one of the method access identifier, the class where the method is located, the method return value, the method parameter list, and the method declaration description information changes, it can be confirmed that the definition of the method of the class in the target code file has changed compared to the class in the source code file.

[0060] The code of a class method is implemented as the running instruction information of the class method, including: the number of registers, the number of parameters, the number of registers used when calling other methods, the number of instructions, the number of definable variables, the instruction content and debugging information.

[0061] (8) Compare the static variables of the class in the target code file with those of the class in the source code file to see if there are any changes.

[0062] In summary, when there is class information with the same name between the target code file and the source code file, the above comparison process is performed to confirm whether at least one of the class access identifier, parent class description, interface parameters (including the number of interfaces and interface names), source file name, annotation, field, method and static variable of the class in (1)-(8) above has changed. When a change occurs, all class information of the changed class is taken as the changed class information and the entire changed class information is incorporated into the changed class information set. In this way, after traversing all class information with the same name, a complete changed class information set can be obtained. Through the above process, a complete set of changed class information and a set of newly added class information are obtained, and then a patch file can be obtained based on the set of changed class information and the set of newly added class information (as mentioned above, the new class information of the target code file and the original class information of the source code file do not necessarily have both newly added class information and class information with the same name. Therefore, when there is only newly added class information between the new class information and the original class information, the patch file is obtained through the set of newly added class information; when there is only class information with the same name between the new class information and the original class information, the patch file is obtained by comparing the set of changed class information obtained based on the class information with the same name).

[0063] Exemplarily, the process of obtaining a patch file based on a newly added class information set and / or a changed class information set is as follows: using DexBuilder (Dex generator, a software tool for packaging class information into Dex) to write the newly added class information set and / or the changed class information set as difference content into a new code file to obtain a patch file. In this method, the target code file, the original code file, and the patch file have the same file format, all of which are Dex files. Such a patch file can be run in an Android virtual machine, which is convenient for testing or viewing.

[0064] like Figure 3 As shown, it is a flowchart of the patch file generation method in the embodiment of the present application. Figure 3 Let's explain this method again:

[0065] First, after obtaining the target code file and the original code file, check the Md5 values ​​of the two files. When the Md5 values ​​are not the same, proceed to the next step, otherwise the method ends.

[0066] After that, the number and offset of each class are obtained by parsing the information of the Dex header file of the target code file and the source code file, and the class information of all classes is obtained based on this. Then, the intersection of the first set and the second set is obtained by comparing the class descriptions in the respective class information. The content outside the intersection is the newly added class description, and the newly added class description set can be obtained based on the newly added class description. The content within the intersection is the class description of the same name.

[0067] Compare all classes corresponding to the class description with the same name, and find the class information that has changed as the changed class information by comparing the class access identifier, the parent class description, the interface parameters of the class (including the number of interfaces and interface names), the source file name of the class, the class annotation, the field of the class, the method of the class and the static variables of the class, and take all the changed class information as the changed class information set.

[0068] Finally, a new Dex file is constructed according to the changed class information set and the newly added class information set as a patch file. At this point, the method ends.

[0069] The patch file generation method in the present application obtains the respective new class information and original class information according to the header file information of the target code file and the original code file, and then obtains the newly added class description and the same-name class description by comparison, and then obtains the changed class information set by comparing the same-name class information, and then obtains the patch file by combining the newly added class information set obtained by the newly added class description. In this method, when comparing, the entire class is used as the comparison basis. When the new and old class information changes, the entire class information will be put into the set, rather than a patch file composed of all the difference information, and it is not easy to have a large file. At the same time, the patch file finally formed is not an irregular binary code, which is convenient for viewing and testing through a virtual machine. In addition, when the changed class information is obtained by comparing the same-name class information of the target code file and the original code file, the contents of the class information will be compared one by one. When a single content changes (such as the access identifier of the class), the different parts will not be put into the difference file one by one, but the entire class information will be put into the difference file. In this way, when there are many parts that have changed, computing power can be saved and a large difference file will not be formed.

[0070] like Figure 4 As shown, an embodiment of the present application also provides a patch file generation system 400, which includes a memory 410 and a processor 420. The memory 410 stores a computer program. When the computer program is executed by the processor 420, the processor 420 executes the patch file generation method described above.

[0071] An embodiment of the present application further provides a storage medium, on which a computer program is stored. When the computer program is executed by a processor, the processor executes the patch file generation method described above.

[0072] For example, Figure 5As shown, it is a structural block diagram of the processor in an embodiment of the present application, the Dex file old represents the original code file, and the Dex file new represents the target code file. The processor includes a Dex parsing module, a class information (class information) acquisition module, a class difference comparison module, and a Dex patch generation module. Among them, the Dex parsing module is used to obtain header file information according to the code file, and the class information acquisition module is used to obtain the class information of the target code file as new class information according to the header file information of the target code file, and obtain the class information of the original code file as original class information according to the header file information of the original code file. The class difference comparison module is used to obtain the newly added class description of the target code file compared to the original code file according to the new class information and the original class information, and, according to the new class information and the original class information, obtain the same-name class description of the target code file and the original code file. The class difference comparison module is also used to obtain a newly added class information set based on the newly added class description, and obtain a class information set of the same name based on the class description of the same name, and determine all the changed class information of the target code file compared to the original code file in the class information set of the same name, and obtain a changed class information set. Finally, the patch generation module will obtain a patch file based on the newly added class information set and the changed class information set. The difference part file is also a Dex format file.

[0073] The patch file generation system and storage medium in the present application implement the above-mentioned patch file generation method, obtain the respective new class information and original class information according to the header file information of the target code file and the original code file, and then obtain the newly added class description and the same-name class description by comparison, and then obtain the changed class information set by comparing the same-name class information, and then obtain the patch file by combining the newly added class information set obtained by the newly added class description. In this method, when comparing, the entire class is used as the comparison basis. When the new and old class information changes, the entire class information will be put into the set, rather than a patch file composed of all the difference information, and it is not easy to have a large file. At the same time, the patch file finally formed is not an irregular binary code, which is convenient for viewing and testing through a virtual machine. In addition, when the changed class information is obtained by comparing the same-name class information of the target code file and the original code file, the contents of the class information will be compared one by one. When a single content changes (such as the access identifier of the class), the different parts will not be put into the difference file one by one, but the entire class information will be put into the difference file. In this way, when there are many parts that have changed, computing power can be saved and a large difference file will not be formed.

[0074] Although example embodiments have been described herein with reference to the accompanying drawings, it should be understood that the above example embodiments are merely exemplary and are not intended to limit the scope of the present application to this. Those of ordinary skill in the art may make various changes and modifications therein without departing from the scope and spirit of the present application. All these changes and modifications are intended to be included within the scope of the present application as required by the appended claims.

[0075] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0076] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed.

[0077] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0078] Similarly, it should be understood that in order to streamline the present application and help understand one or more of the various inventive aspects, in the description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the method of the present application should not be interpreted as reflecting the following intention: the claimed application requires more features than the features clearly stated in each claim. More specifically, as reflected in the corresponding claims, the inventive point is that the corresponding technical problem can be solved with features less than all the features of a single disclosed embodiment. Therefore, the claims following the specific embodiment are hereby explicitly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present application.

[0079] It will be understood by those skilled in the art that, except for mutually exclusive features, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this specification may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature that provides the same, equivalent or similar purpose.

[0080] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present application and form different embodiments. For example, in the claims, any one of the claimed embodiments may be used in any combination.

[0081] The various component embodiments of the present application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) can be used in practice to implement some or all of the functions of some modules according to the embodiments of the present application. The present application can also be implemented as a vehicle-mounted system program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0082] It should be noted that the above embodiments illustrate the present application rather than limit the present application, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets should not be constructed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of multiple such elements. The present application may be implemented with the aid of hardware including several different elements and with the aid of appropriately programmed computers. In a unit claim listing several on-board systems, several of these on-board systems may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names.

[0083] The above is only a specific implementation method or description of a specific implementation method of the present application, and the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application shall be based on the protection scope of the claims.

Claims

1. A method for generating a patch file, characterized in that: The method comprises: Get the header file information of the target code file and the source code file; According to the header file information of the target code file, the class information of the target code file is obtained as new class information, and according to the header file information of the original code file, the class information of the original code file is obtained as original class information; Difference information between the new class information and the original class information is obtained, and a patch file is obtained based on the difference information.

2. The method for generating a patch file according to claim 1, characterized in that: The difference information includes a newly added information set and / or a changed information set; The obtaining of difference information between the new class information and the original class information includes: According to the new class information and the original class information, a class description newly added to the target code file compared to the original code file is obtained; and / or, according to the new class information and the original class information, a class description having the same name as the target code file and the original code file is obtained; A newly added class information set is obtained based on the newly added class description; and / or, a class information set with the same name is obtained based on the class description with the same name, and all the changed class information of the target code file compared with the original code file in the class information set with the same name is determined to obtain a changed class information set.

3. The method for generating a patch file according to claim 2, characterized in that: The step of determining all the change class information of the target code file compared with the original code file in the same-name class information set to obtain the change class information set includes: For a class in the same-name class information set, performing the following operations: comparing whether the class in the target code file is changed relative to the class in the source code file, and if there is a change, determining the class information corresponding to the class as the changed class information; The operation is performed on other classes in the class information set with the same name to obtain all changed class information, and the set of all changed class information is the changed class information set.

4. The method for generating a patch file according to claim 3, characterized in that: The comparing whether the class in the target code file has changed relative to the class in the source code file comprises at least one of the following: Comparing whether the access identifier of the class in the target code file is changed with the access identifier of the class in the source code file; Comparing whether the parent class description of the class in the target code file is changed with the parent class description of the class in the source code file; Comparing whether the interface parameters of the class in the target code file have changed with the interface parameters of the class in the source code file, the interface parameters including the number of interfaces and / or interface names; Compare whether the source file name of the class in the target code file is changed with the source file name of the class in the original code file; Comparing whether the annotation of the class in the target code file is changed with the annotation of the class in the source code file; Comparing whether the field of the class in the target code file has changed with the field of the class in the source code file; Comparing whether the method of the class in the target code file is changed with the method of the class in the source code file; Compare the static variables of the class in the target code file with those in the source code file to see whether there are any changes.

5. The method for generating a patch file according to claim 4, characterized in that: The annotations of the class include: annotation information of the class, annotation information of the method of the class, annotation information of the field of the class, and annotation information of the parameter of the class; When at least one of the annotation information of the class, the annotation information of the method of the class, the annotation information of the field of the class, and the annotation information of the parameter of the class is different, it is determined that the annotation of the class in the target code file has changed relative to the annotation of the class in the source code file.

6. The method for generating a patch file according to claim 4, characterized in that: The fields of the class include static fields and instance fields; When at least one of the number of the static fields, the number of the instance fields, and the definition content of the fields of the class is different, determining that the fields of the class in the target code file are changed relative to the fields of the class in the source code file; The definition content of the field of the class includes a field access identifier, a class where the field belongs, a field type, and a field name.

7. The method for generating a patch file according to claim 4, characterized in that: The methods of the class include direct methods and virtual methods; When at least one of the number of the direct methods, the number of the virtual methods, the definition content of the methods of the class, and the code implementation of the methods of the class is different, determining that the methods of the class in the target code file are changed relative to the methods of the class in the source code file; The method definition of the class includes method access identifier, method class, method return value, method parameter list and method declaration description information; When the running instruction information of the methods of the class are consistent, it is confirmed that the code implementation of the methods of the class is the same, wherein the running instruction information of the methods of the class includes: the number of registers, the number of parameters, the number of registers used when calling other methods, the number of instructions, the number of definable variables, the instruction content and the debugging information.

8. The method for generating a patch file according to claim 1, characterized in that: Obtaining class information of the target code file as new class information according to header file information of the target code file, including: parsing the header file information of the target code file to obtain a first number and a first offset of classes of the target code, and obtaining the first number of class information of the target code file as new class information according to the first offset; The method comprises: obtaining class information of the source code file as original class information according to header file information of the source code file, comprising: parsing the header file information of the source code file to obtain a second number and a second offset of classes of the source code file, and obtaining the second number of class information of the source code file as original class information according to the second offset.

9. The method for generating a patch file according to any one of claims 1 to 8, characterized in that: Before obtaining the header file information of the target code file and the source code file, the patch file generation method further includes: Obtaining the information digest algorithm value of the target code file as the first information digest algorithm value, and obtaining the information digest algorithm value of the source code file as the second information digest algorithm value; When the first information digest algorithm value is different from the second information digest algorithm value, header file information of each of the target code file and the original code file is obtained to generate a patch file.

10. The method for generating a patch file according to any one of claims 1 to 8, characterized in that: The obtaining of a patch file based on the difference information includes: The difference information is written into a new code file as difference content to obtain a patch file, wherein the target code file, the original code file and the patch file have the same file format.

11. A patch file generation system, characterized in that: The system includes a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method for generating a patch file according to any one of claims 1 to 10.

12. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by the processor, the processor executes the method for generating a patch file according to any one of claims 1 to 10.