Application installation package generation method, device and electronic device
By only generating proxy methods based on the parent class methods called in each class, the problem of too large installation packages after insertion in existing hot repair techniques is solved, and the effect of reducing the size of the installation package and reducing storage space usage is achieved.
Patent Information
- Application Number
- CN201910767227.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-20
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2039-08-20
AI Technical Summary
When existing hot repair technology generates installation packages after insertion, the package size will be large, resulting in increased user download and storage space usage, and may not meet the release requirements of the installation package.
When installing package inserts for a baseline, only proxy methods are generated based on the parent class methods called in each class, rather than traversing all parent class methods, thereby reducing the target baseline installation package size after insertion.
Effectively reduce the size of the target baseline installation package after insertion, reduce the storage space occupied by users download, and avoid the risk that the installation package cannot be published.
Smart Images

Figure CN112416300B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device and electronic device for generating an application installation package. Background Art
[0002] After an application (Application, APP) is launched, there will be more or less some vulnerabilities (bugs). In order to ensure the safe operation of the APP, these bugs need to be fixed in a timely manner.
[0003] The traditional APP repair solution is for developers to fix bugs in the background and generate a new version of the APP installation package for users to download and reinstall the APP. This traditional APP repair method is costly and inefficient. For this reason, hot repair technology has emerged. This technology does not require users to reinstall the new version of the APP to run the APP with the fixed bug. The more mature hot repair technologies in the industry, such as Dexpatch and Tinker, require killing and restarting the application to take effect; Android's hot repair solution InstantRun can fix bugs without restarting the application. Its basic principle is to insert stubs for each class when generating the installation package. For each class, if there is a patch package for the class, the method logic in the patch package is executed, and if there is no patch package for the class, the original logic of the class is executed.
[0004] However, the installation package generated by the InstantRun solution after instrumentation will be very large. Summary of the invention
[0005] In view of this, the present invention provides a method, device and electronic device for generating an application installation package, which are used to reduce the size of the installation package in a hot repair solution.
[0006] In order to achieve the above objectives, in a first aspect, an embodiment of the present invention provides a method for generating an application installation package, comprising:
[0007] Traverse each class in the baseline installation package to be plugged, and for the current class traversed, traverse the parent class method called in the current class;
[0008] When the traversal result of the parent class method of the current class is not empty, a proxy method of the current class is generated according to the traversed parent class method, and the proxy method is used for being called by the patch class of the target class to call the parent class method when the current class needs to be repaired;
[0009] After traversing each class in the baseline installation package, repackaging is performed to generate a target baseline installation package.
[0010] As an optional implementation of the embodiment of the present invention, the generating of the proxy method of the current class according to the traversed parent class method includes:
[0011] Generate a hash code for each parent class method traversed;
[0012] A proxy method of the current class is generated according to the generated hash code, wherein the proxy method includes the following calling instructions: when the hash code of the incoming target parameter is the target hash code, a parent class method corresponding to the target hash code is called, and the target hash code is any one of the generated hash codes.
[0013] As an optional implementation of the embodiment of the present invention, generating a hash code for each parent class method traversed includes:
[0014] For each parent class method traversed, determine the method signature of the parent class method;
[0015] Generate a hash code of the parent class method according to the method signature.
[0016] As an optional implementation of the embodiment of the present invention, the traversing of the parent class method called in the current class includes:
[0017] Traverse the methods in the current class;
[0018] For each method traversed, traverse the instructions in the method;
[0019] When the traversed instruction is an instruction for calling a parent class method, the method is determined to be the parent class method called in the current class.
[0020] As an optional implementation of the embodiment of the present invention, the traversing the methods in the current class includes:
[0021] Traverse all methods in the current class except the initialization init method.
[0022] In a second aspect, an embodiment of the present invention provides a method for processing an application, including:
[0023] Get the baseline installation package to be processed uploaded by the user;
[0024] Traversing each class in the baseline installation package to determine the parent class method called in each class;
[0025] Performing an instrumentation process on the determined parent class method to generate a proxy method of the parent class method, wherein the proxy method is used for being called by the patch class of the class to call the parent class method;
[0026] Repackage the instrumented baseline installation package to generate a target baseline installation package.
[0027] In a third aspect, an embodiment of the present invention provides a device for generating an application installation package, comprising:
[0028] A traversal module is used to traverse each class in the baseline installation package to be plugged, and for the current class traversed, traverse the parent class method called in the current class;
[0029] A proxy method generation module, used for generating a proxy method of the current class according to the traversed parent class method when the traversal result of the parent class method of the current class is not empty, and the proxy method is used for being called by the patch class of the target class to call the parent class method of the current class when the current class needs to be repaired;
[0030] The installation package generation module is used to repackage and generate a target baseline installation package after traversing each class in the baseline installation package.
[0031] As an optional implementation of the embodiment of the present invention, the proxy method generation module is specifically used for:
[0032] Generate a hash code for each parent class method traversed;
[0033] A proxy method of the current class is generated according to the generated hash code, wherein the proxy method includes the following calling instructions: when the hash code of the incoming target parameter is the target hash code, a parent class method corresponding to the target hash code is called, and the target hash code is any one of the generated hash codes.
[0034] As an optional implementation of the embodiment of the present invention, the proxy method generation module is specifically used for:
[0035] For each parent class method traversed, determine the method signature of the parent class method;
[0036] Generate a hash code of the parent class method according to the method signature.
[0037] As an optional implementation of the embodiment of the present invention, the traversal module is specifically used for:
[0038] Traverse the methods in the current class;
[0039] For each method traversed, traverse the instructions in the method;
[0040] When the traversed instruction is an instruction for calling a parent class method, the method is determined to be the parent class method called in the current class.
[0041] As an optional implementation of the embodiment of the present invention, the traversal module is specifically used for:
[0042] Traverse all methods in the current class except the initialization init method.
[0043] In a fourth aspect, an embodiment of the present invention provides a device for processing an application, including:
[0044] An acquisition module is used to acquire the baseline installation package to be processed uploaded by the user;
[0045] A determination module, used to traverse each class in the baseline installation package and determine the parent class method called in each class;
[0046] A proxy method generation module, used for inserting the determined parent class method to generate a proxy method of the parent class method, wherein the proxy method is used for being called by the patch class of the class to call the parent class method;
[0047] The installation package generation module is used to repackage the baseline installation package after the instrumentation process to generate a target baseline installation package.
[0048] In a fifth aspect, an embodiment of the present invention provides an electronic device, comprising: a memory and a processor, the memory being used to store a computer program; the processor being used to execute the method described in the first aspect, the second aspect or any one of the embodiments of the first aspect when calling the computer program.
[0049] In a sixth aspect, an embodiment of the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method described in the first aspect, the second aspect, or any one of the embodiments of the first aspect is implemented.
[0050] The application installation package generation method, device and electronic device provided by the embodiments of the present invention can effectively reduce the size of the target baseline installation package finally generated after instrumentation by only instrumenting the class in the baseline installation package according to the parent class method called in the class to generate a proxy method for the class. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present invention;
[0052] Figure 2 A schematic diagram of a flow chart of a method for generating an application installation package provided by an embodiment of the present invention;
[0053] Figure 3 A schematic diagram of a flow chart of a method for traversing parent classes provided in an embodiment of the present invention;
[0054] Figure 4 A schematic diagram of a process flow of a method for generating an agent provided in an embodiment of the present invention;
[0055] Figure 5 A flowchart of a method for processing an application provided by an embodiment of the present invention;
[0056] Figure 6 A schematic diagram of the structure of an application installation package generating device provided by an embodiment of the present invention;
[0057] Figure 7 A schematic diagram of the structure of an application processing device provided by an embodiment of the present invention;
[0058] Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0059] Among the related hot fix technologies, InstantRun is a hot fix solution based on Java instrumentation developed by Google. Its basic principle is to instrument each class when generating the installation package. For each class, when there is a patch package for the class, the method logic in the patch package is executed, and when there is no patch package for the class, the original logic of the class is executed. Among them, when instrumenting a class, a proxy method will be generated for each class, which is used to enable the patch class of the class to access the parent class method of the class through the proxy method when repairing a class; among them, when generating the proxy method, all parent class methods of the class will be traversed, for example: for class A, its parent class is class B, and the parent class of class B is class C, then all methods of class B and class C are traversed; then the proxy method is generated according to all the traversed methods. The installation package generated by this method after instrumentation will be very large, so it will take up a large amount of storage space when the user downloads the installation package, and it may not meet the release requirements of the installation package, resulting in the inability to release the installation package.
[0060] In order to solve the above technical problems, an embodiment of the present invention provides an application installation package generation method, device and electronic device, which mainly reduces the size of the target baseline installation package generated after instrumentation by only instrumenting the class in the baseline installation package according to the parent class method called in the class when instrumenting the baseline installation package, and generating a proxy method for the class.
[0061] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present invention, such as Figure 1As shown, the electronic device 100 provided by the embodiment of the present invention can provide a development interface for developers to interact on the development interface to generate a target baseline installation package. When in use, the developer can write the code of the baseline installation package in the development interface, or import the code of the baseline installation package through the import function provided by the development interface (such as the "file" option in the figure); then the developer can write the plug-in code in the code of the baseline installation package for plug-in, or can also pre-write the plug-in code and encapsulate it, and directly call the encapsulated method in the code of the baseline installation package when plugging; finally, the developer can compile the plug-in code through the compilation function in the development interface to generate the target baseline installation package. Among them, the plug-in code is the plug-in code corresponding to the application installation package generation method provided by the embodiment of the present invention, such as the code shown in the figure: "Traverse each class in the baseline installation package to be plugged, for the traversed class, traverse the parent class method called in the class", and "When the traversal result of the parent class method of the class is not empty, generate the proxy method of the class according to the traversed parent class method". The figure is replaced by xxx for exemplary explanation.
[0062] In addition, the application installation package generation method provided in the embodiment of the present invention can be provided as a packaging service on a service platform for users to use; the service platform can be, for example, a Software as a Service (SaaS) platform, and the packaging service can be a paid service or a free service. In addition, the service platform can provide a packaging service switch function, through which the packaging service is provided to some users and closed to some users; the service platform can also provide users with a use switch function, when the packaging service is provided to a certain user, the user can choose to use the packaging service or not through the use switch function.
[0063] The following first explains some of the terms involved in the embodiments of the present invention to facilitate understanding of the technical solutions in the embodiments of the present invention:
[0064] Baseline installation package: the installation package of the baseline version, which is a version created by labeling the project version when a certain stage of development is completed; this version is a stable version and is the basis for the development of subsequent versions.
[0065] ASM: A Java bytecode manipulation framework that can read class files, modify existing classes in binary form, or dynamically generate classes.
[0066] Method signature: The main function is to distinguish between two methods, that is, to uniquely identify a method; it consists of the method name and the method parameter list (including parameter type and parameter order). It should be noted that the method signature provided by the Java Virtual Machine (JVM) actually consists of three parts: method name, parameter list and return value. The method signature described in this embodiment can be a method signature that does not include a return value or a method signature that includes a return value. The specific selection can be arbitrarily made according to needs.
[0067] Hash code: hashcode represents a characteristic of an object and can be obtained by calculating the object through a hash code algorithm.
[0068] Map: used to manage mappings and store key-value pairs; the key is unique and cannot be repeated.
[0069] The technical solution of the present invention is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0070] Figure 2 The flowchart of the method for generating an application installation package provided by the embodiment of the present invention is shown in FIG. 1 , and the execution subject of the method may be an application installation package generating device. Figure 2 As shown, the method provided in this embodiment may include the following steps:
[0071] S110, traversing each class in the baseline installation package to be plugged, and for the traversed current class, traversing out the parent class method called in the current class.
[0072] The baseline installation package may be a baseline installation package of any application, which may specifically be an Android installation package (Android Package, APK) or other types of installation packages, which are not particularly limited here.
[0073] In this embodiment, the baseline installation package can be plugged in through ASM. Specifically, all classes in the baseline installation package to be plugged can be traversed, and for the traversed class (herein referred to as the current class), the methods in the class are traversed to find out the parent class method called by the class, that is, to find out the parent class method called by each class. In the specific implementation, all classes can be traversed, and then each class can be traversed one by one to find the parent class method called by each class; or the parent class method called by the class can be searched while traversing the class.
[0074] When looking for a specific parent class method, you can use Figure 3 The method shown is implemented. Figure 3A flow chart of a method for traversing parent classes provided in an embodiment of the present invention is shown as follows: Figure 3 As shown, the method may include the following steps:
[0075] S111. Traverse the methods in the current class.
[0076] Specifically, for the current class traversed, the class bytecode can be traversed to read the methods in the class, and then it can be determined whether the traversed method is the parent class method called by the class.
[0077] Considering the initialization (init) method in the class, the package size added when generating the proxy method is very small and almost negligible. In this embodiment, when searching for the parent class method, only all methods except the initialization init method in the current class can be traversed. For the init method, the existing instrumentation method can be used for instrumentation, that is, the part related to the init method in the proxy method can be consistent with the corresponding part in the existing proxy method.
[0078] S112. For each method traversed, traverse the instructions in the method.
[0079] Specifically, a method includes a series of instructions. When determining whether the traversed method is a parent class method called by the class, each instruction in the method may be traversed to determine whether the method contains instructions for calling the parent class method.
[0080] In specific implementation, instruction traversal in a method may be completed by traversing the operation codes (opcodes) contained in the method.
[0081] S113. When the traversed instruction is an instruction for calling a parent class method, the method is determined to be the parent class method called in the current class.
[0082] Specifically, the instruction to call the parent class method is generally INVOKESPECIAL. Therefore, when the opcode is INVOKESPECIAL, it can be said that the traversed instruction is an instruction to call the parent class method, that is, the method contains an instruction to call the parent class method. At this time, it can be determined that the method is the parent class method called in the current class.
[0083] It should be noted that, in this embodiment, calling the parent class method can be any of the following two situations: first, the subclass calls the parent class method that has not been overridden; second, the parent class method called by the subclass is overridden in the subclass, but the method in the parent class is called when it is called.
[0084] In this embodiment, when searching for the parent class method, it can be as described above, when traversing to a certain method, traversing the instructions in the method, and determining whether the traversed instruction is an instruction to call the parent class method; or it can be that all methods are traversed first, and then for each method, all instructions are traversed, and then each instruction is determined whether it is an instruction to call the parent class method.
[0085] S120. When the traversal result of the parent class method of the current class is not empty, a proxy method of the current class is generated according to the traversed parent class method.
[0086] The proxy method is used for the patch class of the current class to call the parent class method called in the current class when the current class needs to be repaired. Its main content is a large switch case statement, in which the object of the switch is the characteristic value of the method. When the value is the same as the characteristic value of a parent class method, the parent class method is called.
[0087] Specifically, if the parent class method is not called in some classes, there is no need to generate the proxy method of the class when the class is instrumented. That is, when the traversal result of the parent class method of the current class is empty, the proxy method of the current class may not be generated; when the traversal result of the parent class method of the current class is not empty, the proxy method of the current class is generated.
[0088] In the specific implementation, after traversing the parent class methods, a certain algorithm can be used to generate the characteristic value of each parent class method, and the proxy method can be generated according to the characteristic value. In order to improve the processing efficiency, in this embodiment, the hash code technology can be used to generate the proxy method. The specific method can be found in Figure 4 . Figure 4 A schematic diagram of a process flow of a method for generating an agent provided by an embodiment of the present invention, such as Figure 4 As shown, the method may include the following steps:
[0089] S121. Generate a hash code for each parent class method traversed.
[0090] Specifically, a hashcode algorithm may be used to generate a hash code for each parent class method. To improve generation efficiency, in this embodiment, for each parent class method traversed, the method signature of the parent class method may be determined first, and then a hash code of the parent class method may be generated according to the method signature.
[0091] In the specific implementation, in order to improve the efficiency of generating proxy methods in the later stage, in this embodiment, the method signatures of each parent class method can be put into a map collection, where the key in the key-value pair in the map can be the method signature and the value can be the class where the method signature is located. Based on the mapping mechanism and automatic sorting function of the map container, there is no need to perform deduplication and sorting operations when generating proxy methods in the later stage, thereby improving the generation efficiency.
[0092] S122. Generate a proxy method of the current class according to the generated hash code.
[0093] Specifically, the current class can be modified through the class injection function of ASM, and a proxy method can be inserted into the class. Among them, the parameter passed in by the proxy method (referred to as the target parameter here) can be a method signature. The proxy method can generate a hash code based on the passed in method signature (string), and then determine whether the hash code is the target hash code. That is, the proxy method may include the following calling instructions: when the hash code of the passed in target parameter is the target hash code, call the parent class method corresponding to the target hash code, and the target hash code is any hash code among the generated hash codes. As mentioned earlier, the main content of the proxy method is the switch case statement. In this proxy method, the value of the switch case is the hash code. The following example illustrates the content of the proxy method:
[0094] For example, the parent class methods called by a class A determined in step S110 include: F1, F2 and F3, wherein the hashcode of the method signature of the parent class method F1 is 1000, the hashcode of the method signature of the parent class method F2 is 2000, and the hashcode of the method signature of the parent class method F3 is 3000. Then, in the proxy method of the class A, the hashcode of the target parameter can be switched, and the case statement can include the following case statements: case1000, calling F1; case2000, calling F2; case3000, calling F3.
[0095] Of course, the proxy method may also include other parameters and statements. When calling the parent class method, the parent class method may be called according to other parameters passed in. For each class, other plugging operations may also be included, which is not particularly limited in this embodiment.
[0096] This proxy method is mainly used for patch class calls. For example, after the user downloads and installs the baseline installation package after the stub, if a bug in class A of the application needs to be fixed, a patch class can be generated for class A and packaged in the patch package. After the user downloads the patch package, when the application detects the patch package during operation, it will run the patch class to repair class A. Among them, most of the methods in the patch class are copies of the methods in class A. Since the patch class has no parent class, when it is necessary to call the parent class method of class A, the proxy method in class A can be called, and the method signature string of the parent class method to be called can be passed in; the proxy method of class A can switch to the corresponding case statement based on the hashcode of the passed method signature string, and then call the parent class method.
[0097] S130: After traversing all classes in the baseline installation package, repackage to generate a target baseline installation package.
[0098] Specifically, after traversing each class in the baseline installation package and completing the instrumentation operation of each class, you can repackage and generate an instrumented baseline installation package (herein referred to as a target installation package), and then publish it to the application market for users to download and install the corresponding application.
[0099] If the application has a bug that needs to be fixed later, a patch package can be generated for users to download to fix the class where the bug occurs.
[0100] In this embodiment, when generating the baseline installation package after instrumentation, the proxy method is generated only according to the parent class method called in each class. Compared with the solution of generating the proxy method according to all the parent class methods of each class in the related art, the size of the baseline installation package can be greatly reduced. For example, according to the solution of generating the proxy method according to all the parent class methods of each class, the package size is increased by 30% after the original baseline installation package is instrumented; the solution provided in this embodiment only increases the package size by 5% after the original baseline installation package is instrumented, which effectively reduces the size of the baseline installation package. In this way, the storage space occupied can be reduced when the user downloads the installation package, and the situation that the installation package cannot be published due to failure to meet the publishing requirements of the installation package can be avoided.
[0101] The application installation package generation method provided in this embodiment, when instrumenting the baseline installation package, for each class in the baseline installation package, only the class is instrumented according to the parent class method called in the class, and the proxy method of the class is generated. This can effectively reduce the size of the target baseline installation package that is finally generated after instrumentation.
[0102] Based on the same inventive concept, an embodiment of the present invention provides a method for processing an application program. Figure 5 FIG. 1 is a flow chart of a method for processing an application provided in an embodiment of the present invention, which method can be applied to the above service platform. Figure 5 As shown, the method may include the following steps:
[0103] S210: Obtain a baseline installation package to be processed uploaded by a user.
[0104] Specifically, the service platform may provide a packaging service including an instrumentation function. When using the service, the user may upload a baseline installation package that needs instrumentation through an upload interface provided by the service platform.
[0105] S220: traverse each class in the baseline installation package to determine the parent class method called in each class.
[0106] S230: Perform instrumentation processing on the determined parent class method to generate a proxy method of the parent class method.
[0107] The proxy method is used for the patch class of the class in the baseline installation package to call the parent class method.
[0108] Specifically, after the service platform obtains the baseline installation package, it can call the pre-set instrumentation method to traverse each class in the baseline installation package and determine the parent class method that needs to be instrumented; then instrument the parent class method that needs to be instrumented to generate a proxy method for the parent class method.
[0109] The determination process of the parent class method can be found in Figure 2 For the description of step S110 in the embodiment shown, the generation process of the proxy method can be found in Figure 2 The relevant description of step S120 in the illustrated embodiment will not be repeated here.
[0110] In addition, when executing steps S220 and S230, you can traverse each class in the baseline installation package, determine the parent class method called in each class, and then generate a proxy method for the parent class method; or you can traverse each class in the baseline installation package, and when traversing to a certain class, determine the parent class method called in the class, and generate a proxy method for the parent class method.
[0111] S240: Repackage the baseline installation package after the instrumentation process to generate a target baseline installation package.
[0112] Specifically, after completing the instrumentation process of each class, the service platform can repackage and generate an instrumented baseline installation package (referred to herein as a target installation package) and provide it to the user.
[0113] The application processing method provided in this embodiment can provide users with a packaging service that includes an instrumentation function; and when instrumenting the baseline installation package, instrumentation operations are performed on each category according to the parent class method called in each category, and proxy methods for each category are generated, which can effectively reduce the size of the target baseline installation package that is finally generated after instrumentation.
[0114] Based on the same inventive concept, as an implementation of the above method, an embodiment of the present invention provides an application installation package generation device. The device embodiment corresponds to the above method embodiment. For ease of reading, this device embodiment will no longer repeat the details of the above method embodiment one by one, but it should be clear that the device in this embodiment can correspond to all the contents of the above method embodiment.
[0115] Figure 6 A schematic diagram of the structure of an application installation package generating device provided by an embodiment of the present invention, such as Figure 6 As shown, the device provided in this embodiment includes:
[0116] The traversal module 111 is used to traverse each class in the baseline installation package to be plugged, and for the current class traversed, traverse the parent class method called in the current class;
[0117] The proxy method generation module 112 is used to generate a proxy method of the current class according to the traversed parent class method when the parent class method traversal result of the current class is not empty, and the proxy method is used for the patch class of the target class to call the parent class method when the current class needs to be repaired;
[0118] The installation package generation module 113 is used to repackage and generate a target baseline installation package after traversing each class in the baseline installation package.
[0119] As an optional implementation of the embodiment of the present invention, the proxy method generation module 112 is specifically used for:
[0120] Generate a hash code for each parent class method traversed;
[0121] A proxy method of the current class is generated according to the generated hash code, wherein the proxy method includes the following calling instructions: when the hash code of the incoming target parameter is the target hash code, a parent class method corresponding to the target hash code is called, and the target hash code is any one of the generated hash codes.
[0122] As an optional implementation of the embodiment of the present invention, the proxy method generation module 112 is specifically used for:
[0123] For each parent class method traversed, determine the method signature of the parent class method;
[0124] Generate a hash code of the parent class method according to the method signature.
[0125] As an optional implementation of the embodiment of the present invention, the traversal module 111 is specifically used for:
[0126] Traverse the methods in the current class;
[0127] For each method traversed, traverse the instructions in the method;
[0128] When the traversed instruction is an instruction for calling a parent class method, the method is determined to be the parent class method called in the class.
[0129] As an optional implementation of the embodiment of the present invention, the traversal module 111 is specifically used for:
[0130] Traverse all methods in the current class except the initialization init method.
[0131] The application installation package generation device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0132] Based on the same inventive concept, as an implementation of the above method, an embodiment of the present invention provides a processing device for an application program. The device embodiment corresponds to the above method embodiment. For ease of reading, the device embodiment will no longer repeat the details of the above method embodiment one by one, but it should be clear that the device in this embodiment can correspond to all the contents of the above method embodiment.
[0133] Figure 7 A schematic diagram of the structure of a processing device for an application provided by an embodiment of the present invention is shown in FIG. Figure 7 As shown, the device provided in this embodiment includes:
[0134] The acquisition module 121 is used to acquire the baseline installation package to be processed uploaded by the user;
[0135] A determination module 122 is used to traverse each class in the baseline installation package and determine the parent class method called in each class;
[0136] The proxy method generation module 123 is used to perform an instrumentation process on the determined parent class method to generate a proxy method of the parent class method, and the proxy method is used to be called by the patch class of the class to call the parent class method;
[0137] The installation package generation module 124 is used to repackage the baseline installation package after the instrumentation process to generate a target baseline installation package.
[0138] The application processing device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0139] Based on the same inventive concept, an embodiment of the present invention further provides an electronic device. Figure 8 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention, such as Figure 8 As shown, the electronic device provided in this embodiment includes: a memory 210 and a processor 220, the memory 210 is used to store computer programs; the processor 220 is used to execute the method described in the above method embodiment when calling the computer program.
[0140] The application installation package generating device may be an electronic device with display and computing functions, such as a desktop computer or a laptop computer.
[0141] The application installation package generation device provided in this embodiment can execute the above method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0142] An embodiment of the present invention further provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method described in the above method embodiment is implemented.
[0143] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media that include computer-usable program code.
[0144] The processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0145] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0146] Computer readable media include permanent and non-permanent, removable and non-removable storage media. Storage media can be implemented by any method or technology to store information, and the information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0147] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating an application installation package, characterized in that: include: Traverse each class in the baseline installation package to be plugged, and for the current class traversed, traverse the parent class method called in the current class; When the traversal result of the parent class method of the current class is not empty, a proxy method of the current class is generated according to the traversed parent class method, and the proxy method is used for being called by the patch class of the target class to call the parent class method when the current class needs to be repaired; After traversing each class in the baseline installation package, repackaging is performed to generate a target baseline installation package; The step of generating the proxy method of the current class according to the traversed parent class method includes: Generate a hash code for each parent class method traversed; Generate a proxy method of the current class according to the generated hash code, wherein the proxy method includes the following calling instructions: when the hash code of the incoming target parameter is the target hash code, call the parent class method corresponding to the target hash code, and the target hash code is any hash code among the generated hash codes; The step of generating a hash code for each parent class method traversed includes: For each parent class method traversed, determine the method signature of the parent class method; Generate a hash code of the parent class method according to the method signature.
2. The method according to claim 1, characterized in that: The traversing of the parent class methods called in the current class includes: Traverse the methods in the current class; For each method traversed, traverse the instructions in the method; When the traversed instruction is an instruction for calling a parent class method, the method is determined to be the parent class method called in the current class.
3. The method according to claim 2, characterized in that The method of traversing the current class includes: Traverse all methods in the current class except the initialization init method.
4. A method for processing an application, characterized in that: include: Get the baseline installation package to be processed uploaded by the user; Traversing each class in the baseline installation package to determine the parent class method called in each class; Performing an instrumentation process on the determined parent class method, determining a method signature of the parent class method for each traversed parent class method, generating a hash code of the parent class method according to the method signature, and generating a proxy method of the parent class method according to the generated hash code, wherein the proxy method is used for being called by a patch class of the class to call the parent class method, and the proxy method includes the following calling instructions: when the hash code of the incoming target parameter is a target hash code, calling the parent class method corresponding to the target hash code, wherein the target hash code is any one of the generated hash codes; Repackage the instrumented baseline installation package to generate a target baseline installation package.
5. A device for generating an application installation package, characterized in that: include: A traversal module is used to traverse each class in the baseline installation package to be plugged, and for the current class traversed, traverse the parent class method called in the current class; A proxy method generation module, used for generating a proxy method of the current class according to the traversed parent class method when the result of traversal of the parent class method of the current class is not empty, and the proxy method is used for being called by the patch class of the target class to call the parent class method when the current class needs to be repaired; An installation package generation module, used to repackage and generate a target baseline installation package after traversing each class in the baseline installation package; The proxy method generation module is specifically used to: generate a hash code for each parent class method traversed; generate a proxy method of the current class according to the generated hash code, and the proxy method includes the following calling instructions: when the hash code of the incoming target parameter is the target hash code, call the parent class method corresponding to the target hash code, and the target hash code is any hash code among the generated hash codes; The proxy method generation module is specifically used to: determine the method signature of each parent class method traversed out; and generate a hash code of the parent class method according to the method signature.
6. A processing device for an application, characterized in that: include: An acquisition module is used to acquire the baseline installation package to be processed uploaded by the user; A determination module, used to traverse each class in the baseline installation package and determine the parent class method called in each class; A proxy method generation module is used to perform an instrumentation process on the determined parent class method, determine the method signature of the parent class method for each traversed parent class method, generate a hash code of the parent class method according to the method signature, and generate a proxy method of the parent class method according to the generated hash code, wherein the proxy method is used for being called by the patch class of the class to call the parent class method, and the proxy method includes the following calling instructions: when the hash code of the incoming target parameter is the target hash code, call the parent class method corresponding to the target hash code, and the target hash code is any hash code among the generated hash codes; The installation package generation module is used to repackage the baseline installation package after the instrumentation process to generate a target baseline installation package.
7. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program; and the processor is used to execute the method according to any one of claims 1 to 4 when calling the computer program.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
Citation Information
Patent Citations
Modularized JAVA application software online updating system and method
CN102141919A
Function calling method and device
CN105183571A