A method and device for generating an application installation package

Replace the network component interface through the byte control framework and generate application installation packages, solving the problem of difficult and insufficient maintenance of mobile terminal network performance monitoring and maintenance, and realizing non-invasive, lightweight and flexible monitoring functions.

CN112346774BActive Publication Date: 2025-04-15BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201910720776.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-08-06
Publication Date
2025-04-15
Estimated Expiration
2039-08-06

AI Technical Summary

Technical Problem

In the prior art, mobile terminal network performance monitoring has problems such as difficult maintenance and insufficient lightweight, especially in terms of code implantation and third-party SDK use.

Method used

The byte control framework is adopted to replace the network component interface in the class file through the customized interface in the network monitoring toolkit, thereby generating an application installation package to achieve intrusive network performance monitoring.

Benefits of technology

It reduces maintenance difficulty, reduces overhead for hosts, realizes platform-based output and flexible customization requirements, and avoids the risk of commercial privacy data leakage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112346774B_ABST
    Figure CN112346774B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for generating an application installation package, and relates to the field of computer technology. A specific implementation of the method includes: generating a target file based on a mobile application development framework; wherein the target file includes a source file, a software package, resources, configuration files, and a network monitoring toolkit that the project depends on; compiling the target file into a binary class file; using a byte manipulation framework, replacing the network component interface in the class file with a customized interface in the network monitoring toolkit, thereby generating an application installation package. This implementation can solve the technical problems of high maintenance difficulty and insufficient lightness.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for generating an application installation package. Background Art

[0002] Network performance optimization is crucial to the user experience of applications. For example, if a page loads for more than 3 seconds, 57% of users will leave. Before optimizing the network, you must first effectively monitor the network performance of mobile terminals. Currently, there are roughly the following ways to monitor the network performance of mobile terminals:

[0003] 1) Network component developers manually implant codes to obtain performance parameters such as network request duration, network anomalies, success rate statistics, etc., and then report the data to the cloud service for data aggregation to achieve the purpose of monitoring;

[0004] 2) Mobile applications implement network performance monitoring by accessing third-party paid SDKs (Software Development Kits);

[0005] 3) Mobile applications use AOP (Aspect Oriented Programming) to monitor network performance, achieving the goal of non-intrusive monitoring.

[0006] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0007] Regarding the first method: First, network monitoring developers need to understand the native code of network requests of each application, which involves many thorny issues such as code learning costs and code access rights; second, due to the rapid iteration of business codes, the codes manually implanted by developers may be optimized or tampered with, which requires a large maintenance cost; third, after the mobile monitoring method is developed and improved, it is difficult to output it as a platform product, which is not conducive to platform promotion.

[0008] Regarding the second method: First, as a commercial product, the third-party paid SDK is equivalent to a technical black box for the access party, and it is impossible to develop customized needs for network monitoring; second, the third-party paid SDK will bring economic costs to the application. For technology companies with independent research and development capabilities, they prefer self-developed performance monitoring platforms; third, using a third-party paid SDK is equivalent to reporting data to a third-party monitoring platform, which will involve the leakage of commercial privacy data.

[0009] For the third method: Since some mature AOP frameworks are used, the functions cannot be tailored, which results in additional overhead for the host, such as an increase in the number of methods or the size of the installation package. Currently, the main open source APM frameworks are Argus and Matrix. These open source frameworks mainly use AOP to monitor network performance, and technically achieve non-intrusive performance monitoring. However, Argus uses the AspectJ (an AOP implemented in the form of annotations at compile time) framework to monitor network status. The problem with using the AspectJ framework is that it brings a large number of methods to the host or increases the size of the installation package; and the Matrix framework lacks support for general mobile network monitoring. Summary of the invention

[0010] In view of this, an embodiment of the present invention provides a method and device for generating an application installation package to solve the technical problems of difficult maintenance and insufficient lightness.

[0011] To achieve the above object, according to one aspect of an embodiment of the present invention, a method for generating an application installation package is provided, comprising:

[0012] Generate target files based on the mobile application development framework; wherein the target files include source files, software packages, resources, configuration files and network monitoring toolkits that the project depends on;

[0013] Compile the target file into a binary class file;

[0014] A byte manipulation framework is used to replace the network component interface in the class file with the customized interface in the network monitoring toolkit, thereby generating an application installation package.

[0015] Optionally, a byte manipulation framework is used to replace the network component interface in the class file with a customized interface in the network monitoring toolkit, including:

[0016] Parsing the class file to generate a tree-type bytecode structure;

[0017] The tree-type bytecode structure is traversed, and during the traversal process, the bytecode of the network component interface in the class file is replaced with the bytecode of the customized interface in the network monitoring toolkit.

[0018] Optionally, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit includes:

[0019] Through the cooperation of the ClassReader class, the ClassWriter class, the ClassVisitor class and the MethodVisitor class, the bytecode of the network component interface in the class file is replaced by the bytecode of the customized interface in the network monitoring toolkit.

[0020] Optionally, before generating the target file based on the mobile application development framework, the method further includes:

[0021] Enumerate the network component interfaces corresponding to each network component;

[0022] Generate corresponding customized interfaces according to the interfaces of various network components, thereby generating a network monitoring toolkit;

[0023] Integrate the network monitoring toolkit into the mobile application development framework.

[0024] Optionally, the network monitoring toolkit is used to collect network monitoring parameters of the mobile terminal and report the network monitoring parameters regularly or in real time;

[0025] The network monitoring parameters include at least one of the following:

[0026] Request method, request exception type, request initiation time, request uniform resource locator, upstream traffic, downstream traffic, remaining packet time, first packet time, request duration, handshake time with the server, domain name query time, and Http return code.

[0027] In addition, according to another aspect of an embodiment of the present invention, a device for generating an application installation package is provided, including:

[0028] A generation module, used to generate target files based on a mobile application development framework; wherein the target files include source files, software packages, resources, configuration files and network monitoring toolkits that the project depends on;

[0029] A compiling module, used for compiling the target file into a binary class file;

[0030] The replacement module is used to adopt a byte manipulation framework to replace the network component interface in the class file with the customized interface in the network monitoring toolkit, thereby generating an application installation package.

[0031] Optionally, the replacement module is used to:

[0032] Parsing the class file to generate a tree-type bytecode structure;

[0033] The tree-type bytecode structure is traversed, and during the traversal process, the bytecode of the network component interface in the class file is replaced with the bytecode of the customized interface in the network monitoring toolkit.

[0034] Optionally, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit includes:

[0035] Through the cooperation of the ClassReader class, the ClassWriter class, the ClassVisitor class and the MethodVisitor class, the bytecode of the network component interface in the class file is replaced by the bytecode of the customized interface in the network monitoring toolkit.

[0036] Optionally, an integrated module is also included for:

[0037] Before generating a target file based on a mobile application development framework, enumerate network component interfaces corresponding to each network component;

[0038] Generate corresponding customized interfaces according to the interfaces of various network components, thereby generating a network monitoring toolkit;

[0039] Integrate the network monitoring toolkit into the mobile application development framework.

[0040] Optionally, the network monitoring toolkit is used to collect network monitoring parameters of the mobile terminal and report the network monitoring parameters regularly or in real time;

[0041] The network monitoring parameters include at least one of the following:

[0042] Request method, request exception type, request initiation time, request uniform resource locator, upstream traffic, downstream traffic, remaining packet time, first packet time, request duration, handshake time with the server, domain name query time, and Http return code.

[0043] According to another aspect of an embodiment of the present invention, there is further provided an electronic device, including:

[0044] one or more processors;

[0045] a storage device for storing one or more programs,

[0046] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.

[0047] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in any one of the above embodiments is implemented.

[0048] An embodiment of the above invention has the following advantages or beneficial effects: because the byte manipulation framework is adopted, the network component interface in the class file is replaced with the customized interface in the network monitoring toolkit to generate the technical means of the application installation package, so the technical problems of difficult maintenance and insufficient lightness in the prior art are overcome. The embodiment of the present invention uses ASM to implement the AOP idea to monitor the network performance of mobile applications, which has the following beneficial effects: 1) non-intrusive code implantation technology is adopted to avoid the labor cost caused by manual code implantation and the problem of coupling business and monitoring logic caused by intrusive code; 2) platform output can be realized, and different applications can easily access the network performance monitoring function; 3) a relatively lightweight AOP solution and ASM are adopted to implement non-intrusive code implantation, and the additional overhead introduced to the host after the user accesses is minimal; 4) avoid the use of third-party paid SDK for monitoring, developers can flexibly customize requirements, and can be deployed on private platforms to avoid the risk of commercial privacy data leakage; 5) it can cover the existing mobile terminal network components, perform refined performance monitoring of the mobile network, and facilitate users to fully monitor the network performance of online users' mobile terminals.

[0049] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0051] Figure 1 is a schematic diagram of the main process of a method for generating an application installation package according to an embodiment of the present invention;

[0052] Figure 2 is a schematic diagram of network monitoring parameters according to an embodiment of the present invention;

[0053] FIG3 is a schematic diagram of several methods of customizing an interface according to an embodiment of the present invention;

[0054] Figure 4 is a schematic diagram of 10 items in a Java class file according to an embodiment of the present invention;

[0055] Figure 5 is a schematic diagram of the main process of a method for generating an application installation package according to a reference embodiment of the present invention;

[0056] Figure 6This is a comparison chart of AOP underlying technologies;

[0057] Figure 7 is a schematic diagram of main modules of a device for generating an application installation package according to an embodiment of the present invention;

[0058] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0059] Fig. 9 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0060] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0061] Figure 1 is a schematic diagram of the main process of the method for generating an application installation package according to an embodiment of the present invention. As an embodiment of the present invention, Figure 1 As shown, the method for generating the application installation package may include:

[0062] Step 101: Generate a target file based on a mobile application development framework.

[0063] In this step, the target file can be generated based on the mobile application development framework, and the target file includes source files, project-dependent software packages (jar packages), resources (such as pictures, audio, etc.), configuration files (for application page layout, etc.) and network monitoring toolkits.

[0064] Generally speaking, the mobile application development framework includes the native network component layer, the network interface layer and the business development layer. Native network component layer: Native network components refer to native components provided by the mobile terminal system or independent network components provided by third-party open source. Developers can select different components to initiate network requests. For example, the current Android system application provides three major network components: HttpURLConnection component, Okhttp component and HttpClient component. Network interface layer: The main task of the network interface layer is to encapsulate the interface of the native components. Developers can use the corresponding network components to initiate network requests by calling the interface. Business development layer: The business development layer belongs to the top layer of the application. This layer uses the interface provided by the network interface layer to implement specific business. Business developers do not need to understand the underlying implementation and can focus on business development.

[0065] It should be noted that the mobile application development framework also integrates a network monitoring toolkit, so that the generated target file contains a network monitoring toolkit (i.e., SDK, which is generally a collection of development tools used by software engineers to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc.). The network monitoring toolkit is used to collect network monitoring parameters of mobile terminals and report the network monitoring parameters regularly or in real time. Figure 2 As shown, the network monitoring parameters include at least one of the following: request mode, request exception type, request initiation time, request uniform resource locator (URL), upstream traffic, downstream traffic, remaining packet time, first packet time, request time, handshake time with the server (TCP handshake time and / or SSL handshake time), domain name (DNS) query time, Http return code. The function of the network monitoring toolkit is to collect network monitoring parameters of the mobile terminal and report the collected network monitoring parameters to the cloud service. The reporting method can be issued by the cloud service. Reporting strategy, using timed reporting or real-time reporting.

[0066] Optionally, before step 101, the method further includes: enumerating the network component interfaces corresponding to each network component; generating corresponding customized interfaces according to each network component interface, thereby generating a network monitoring toolkit; integrating the network monitoring toolkit into the mobile application development framework. To implement AOP through network interfaces, it is first necessary to enumerate all possible calling interfaces (such as A, B, C, etc.) commonly used by mobile terminals for network component requests. This step can be understood as finding a network monitoring aspect. Secondly, a corresponding customized interface (such as A', B', C', etc.) is provided for each interface.

[0067] For example, in Android mobile applications, the commonly used network components for sending Http network requests are: Okhttp component, HttpClient component and HttpURLConnection component. Among them, the commonly used interfaces of these three network components generally include the following: Okhttp component - enqueue, newCall and execute; HttpClient component - execute; HttpURLConnection component - getContent, openConnection and openStream.

[0068] Customization and transformation are performed on the network component interfaces corresponding to the enumerated network components, and corresponding customized interfaces are generated respectively, so as to provide alternative customized interfaces for these network component interfaces respectively, so as to prepare for interface replacement in step 103.

[0069] A Java interface is a set of method declarations and a collection of method features. Optionally, there are several ways to customize an interface: Figure 3a As shown, add time tags before and after the method to count the time consumed by the method; Figure 3b As shown, relevant parameters are obtained before the method or after the function; Figure 3c It should be noted that the methods of customizing interfaces are not limited to the above three methods, and different methods can be used to generate customized interfaces according to different network monitoring parameters to be collected by the network monitoring toolkit, and the embodiment of the present invention does not limit this.

[0070] Step 102, compile the target file into a binary class file.

[0071] In this step, Javac (java compiler) can be used to compile the target file generated in step 101 into a binary class file, that is, to compile the source file, the software package, resources, configuration files and network monitoring toolkit that the project depends on into a binary class file (a file with the extension ".class"). Each legal Java class file has a precise definition, and it is this precise definition that enables the Java virtual machine to correctly read and interpret all Java class files.

[0072] Java class files are 8-bit binary streams. Data items are stored in order in the class file, with no gaps between adjacent items. This makes the class file compact and reduces storage space. Java class files contain many items of different sizes. Since the structure of each item is strictly specified, the class file can be parsed smoothly from beginning to end. Figure 4 As shown, a Java class file can be roughly divided into 10 items:

[0073] Magic: This item stores the magic number and version information of a Java class file. The first 4 bytes of a Java class file are called its magic number. Every correct Java class file starts with 0xCAFEBABE, which ensures that the Java virtual machine can easily distinguish Java files from non-Java files.

[0074] Version: This item stores the version information of the Java class file, which is of great significance to a Java file. As Java technology continues to develop, the format of class files is also constantly changing. The version information of the class file lets the virtual machine know how to read and process the class file.

[0075] Constant Pool: This item stores constants such as various text strings, class names, method names and interface names, final variables, and reference information to external classes in the class. The virtual machine must maintain a constant pool for each loaded class. The constant pool stores symbolic references to all types, fields, and methods used by the corresponding type, so it plays a core role in Java dynamic linking. The size of the constant pool accounts for about 60% of the entire class size on average.

[0076] Access_flag: This item indicates whether the file defines a class or an interface, and also specifies the access flag of the class or interface, such as public, private, abstract, and other information.

[0077] This Class: Pointer to a string constant representing the fully qualified name of the class.

[0078] Super Class: Pointer to a string constant representing the fully qualified name of the super class.

[0079] Interfaces: A pointer array that stores pointers to string constants of all interface names implemented by this class or its parent class. The constants pointed to by the above three items, especially the first two, generally need to be modified when we use ASM to derive a new class from an existing class: change the class name to the subclass name; change the parent class to the name of the class before derivation; if necessary, add new implementation interfaces.

[0080] Fields: This item provides a detailed description of the fields declared in the class or interface. It should be noted that the fields list only lists the fields in this class or interface, and does not include fields inherited from superclasses and parent interfaces.

[0081] Methods: This item provides a detailed description of the methods declared in the class or interface, such as the method name, parameters, and return value type. It should be noted that the Methods list only stores the methods in this class or interface, and does not include methods inherited from superclasses and parent interfaces.

[0082] Class attributes: This item stores basic information about the attributes defined by the class or interface in the file.

[0083] Step 103, using a byte manipulation framework, replacing the network component interface in the class file with the customized interface in the network monitoring toolkit, thereby generating an application installation package.

[0084] Specifically, ASM can be used to transform the binary class file in step 102, and the network component interface in the class file can be replaced with the customized interface in the network monitoring toolkit. The transformed class file is the application installation package. Generally speaking, the network component interfaces in the source files and the software packages that the project depends on are mainly replaced.

[0085] ASM is a Java bytecode manipulation framework that can be used to dynamically generate classes or enhance the functionality of existing classes. ASM can directly generate binary class files, and can also dynamically change class behavior before the class is loaded into the Java virtual machine. Java classes are stored in .class files with strict format definitions. These class files have enough metadata to parse all elements in the class: class name, methods, attributes, and Java bytecodes (instructions). After ASM reads information from the class file, it can change class behavior, analyze class information, and even generate new classes according to user requirements. Therefore, the embodiment of the present invention transforms the network interface layer of the application based on the ASM bytecode editing technology and the idea of ​​AOP (Aspect Oriented Programming), replacing the corresponding network component interface with a customized interface, thereby realizing a non-intrusive, low-overhead monitoring function.

[0086] Optionally, step 103 may specifically include: parsing the class file to generate a tree bytecode structure; traversing the tree bytecode structure, and during the traversal process, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit.

[0087] ASM uses a tree data structure to represent complex bytecode structures, and uses the Push model to traverse the tree bytecode structure and modify the bytecode during the traversal process. The so-called Push model is similar to the simple Visitor design pattern. Because the bytecode structure to be processed is fixed, there is no need to abstract a Visitor interface, but only to provide a Visitor interface.

[0088] Optionally, the bytecode of the network component interface in the class file is replaced by the bytecode of the customized interface in the network monitoring toolkit, including: through the cooperation of ClassReader class, ClassWriter class, ClassVisitor class and MethodVisitor class, the bytecode of the network component interface in the class file is replaced by the bytecode of the customized interface in the network monitoring toolkit.

[0089] ClassReader class: bytecode reading and analysis engine. It uses an event reading mechanism similar to SAX. Whenever an event occurs, it calls the registered ClassVisitor, AnnotationVisitor, FieldVisitor, and MethodVisitor to do the corresponding processing.

[0090] ClassVisitor class: defines the events that will be triggered when reading Class bytecode, such as class header parsing completion, annotation parsing, field parsing, method parsing, etc.

[0091] ClassWriter class: It implements the ClassVisitor interface and is used to splice bytecodes.

[0092] MethodVisitor class: defines events triggered when parsing a method, such as annotations, properties, codes, etc. on the method.

[0093] Therefore, calling the above four key classes can realize interface replacement and obtain the modified class file.

[0094] The main function of the custom interface in the network monitoring toolkit is to collect network data, such as Figure 2As shown, the basic parameters of the network request can be collected, and then the data can be summarized and reported to the cloud service to realize the monitoring function. The implementation method of the customized interface is to keep the original network interface call logic unchanged, and add the network request data collection logic, such as response time, upstream and downstream traffic, etc. Therefore, the embodiment of the present invention uses ASM to implement the AOP concept to monitor the network performance of mobile applications. The implantation of the monitoring function realizes the development of a non-intrusive method, which greatly reduces the user access cost; at the same time, the use of ASM to edit the bytecode can reduce the number of methods on the host and the increment of the installation package size, which is more advantageous than other implementation methods (such as the AspectJ framework).

[0095] According to the various embodiments described above, it can be seen that the present invention adopts a byte manipulation framework to replace the network component interface in the class file with a custom interface in the network monitoring toolkit to generate an application installation package, thereby solving the technical problems of difficult maintenance and insufficient lightness in the prior art. The embodiment of the present invention uses ASM to implement the use of AOP ideas to monitor the network performance of mobile applications, which has the following beneficial effects: 1) Adopting non-intrusive code implantation technology to avoid the labor cost caused by manual code implantation and the problem of coupling business and monitoring logic caused by intrusive code; 2) Platform output can be achieved, and different applications can easily access the network performance monitoring function; 3) Adopting a relatively lightweight AOP solution and ASM to implement non-intrusive code implantation, the additional overhead introduced to the host after the user accesses is minimal; 4) Avoiding the use of third-party paid SDK for monitoring, developers can flexibly customize requirements, and can be deployed on private platforms to avoid the risk of commercial privacy data leakage; 5) It can cover the existing mobile terminal network components, perform refined performance monitoring of the mobile network, and facilitate users to fully monitor the network performance of online user mobile terminals.

[0096] Figure 5 It is a schematic diagram of the main process of a method for generating an application installation package according to a reference embodiment of the present invention.

[0097] Step 501 , enumerate the network component interfaces corresponding to the various network components, and generate corresponding customized interfaces according to the various network component interfaces, thereby generating a network monitoring toolkit.

[0098] First, you need to enumerate all possible calling interfaces of commonly used network components in mobile terminals and then generate corresponding custom interfaces for each interface. For example, in Android mobile applications, the commonly used network components for sending Http network requests are: Okhttp component, HttpClient component and HttpURLConnection component. Among them, the commonly used interfaces of these three network components generally include the following: Okhttp component - enqueue, newCall and execute; HttpClient component - execute; HttpURLConnection component - getContent, openConnection and openStream.

[0099] The network monitoring toolkit is used to collect network monitoring parameters of mobile terminals and report the network monitoring parameters regularly or in real time. The main function of the customized interface in the network monitoring toolkit is the network data collection function, which can collect the basic parameters of network requests, and then summarize the data and report it to the cloud service to realize the monitoring function.

[0100] Step 502: Integrate the network monitoring toolkit into a mobile application development framework.

[0101] Step 503: Generate a target file based on the mobile application development framework.

[0102] Step 504: compile the target file into a binary class file.

[0103] Javac can be used to compile the target file generated in step 503 into a binary class file, that is, to compile the source file, the software package, resources, configuration files and network monitoring toolkit that the project depends on into a binary class file (ie, .class file).

[0104] Step 505: Using a byte manipulation framework, the network component interface in the class file is replaced with the customized interface in the network monitoring toolkit, thereby generating an application installation package.

[0105] ASM can be used to transform the binary class file in step 504, and the network component interface in the class file is replaced with the customized interface in the network monitoring toolkit. The transformed class file is the application installation package. Generally speaking, the network component interfaces in the source files and the software packages that the project depends on are mainly replaced. ASM uses a tree data structure to represent complex bytecode structures, and uses the Push model to traverse the tree bytecode structure, and modify the bytecode during the traversal process.

[0106] There are currently many ways to implement bytecode editing technology, such as Figure 6 As shown, according to the comparison of AOP underlying technologies, it can be seen that ASM is the best implementation solution in terms of functions, performance, interface-oriented programming and programming difficulty. The embodiment of the present invention adopts the more efficient ASM bytecode editing technology to implement non-intrusive code implantation. If other technologies are used, there will be the disadvantage of high implementation cost.

[0107] In addition, the specific implementation content of the method for generating an application installation package in a reference embodiment of the present invention has been described in detail in the method for generating an application installation package described above, so the repeated content will not be described here.

[0108] Figure 7 is a schematic diagram of main modules of a device for generating an application installation package according to an embodiment of the present invention, such as Figure 7 As shown, the device 700 for generating an application installation package includes a generating module 701, a compiling module 702 and a replacing module 703. The generating module 701 is used to generate a target file based on a mobile application development framework; wherein the target file includes a source file, a software package, resources, configuration files and a network monitoring toolkit that the project depends on; the compiling module 702 is used to compile the target file into a binary class file; the replacing module 703 is used to use a byte manipulation framework to replace the network component interface in the class file with the customized interface in the network monitoring toolkit, thereby generating an application installation package.

[0109] Optionally, the replacement module 703 is used to:

[0110] Parsing the class file to generate a tree-type bytecode structure;

[0111] The tree-type bytecode structure is traversed, and during the traversal process, the bytecode of the network component interface in the class file is replaced with the bytecode of the customized interface in the network monitoring toolkit.

[0112] Optionally, replacing the bytecode of the network component interface in the class file with the bytecode of the customized interface in the network monitoring toolkit includes:

[0113] Through the cooperation of the ClassReader class, the ClassWriter class, the ClassVisitor class and the MethodVisitor class, the bytecode of the network component interface in the class file is replaced by the bytecode of the customized interface in the network monitoring toolkit.

[0114] Optionally, an integrated module is also included for:

[0115] Before generating a target file based on a mobile application development framework, enumerate network component interfaces corresponding to each network component;

[0116] Generate corresponding customized interfaces according to the interfaces of various network components, thereby generating a network monitoring toolkit;

[0117] Integrate the network monitoring toolkit into the mobile application development framework.

[0118] Optionally, the network monitoring toolkit is used to collect network monitoring parameters of the mobile terminal and report the network monitoring parameters regularly or in real time;

[0119] The network monitoring parameters include at least one of the following:

[0120] Request method, request exception type, request initiation time, request uniform resource locator, upstream traffic, downstream traffic, remaining packet time, first packet time, request duration, handshake time with the server, domain name query time, and Http return code.

[0121] According to the various embodiments described above, it can be seen that the present invention adopts a byte manipulation framework to replace the network component interface in the class file with a custom interface in the network monitoring toolkit to generate an application installation package, thereby solving the technical problems of difficult maintenance and insufficient lightness in the prior art. The embodiment of the present invention uses ASM to implement the use of AOP ideas to monitor the network performance of mobile applications, which has the following beneficial effects: 1) Adopting non-intrusive code implantation technology to avoid the labor cost caused by manual code implantation and the problem of coupling business and monitoring logic caused by intrusive code; 2) Platform output can be achieved, and different applications can easily access the network performance monitoring function; 3) Adopting a relatively lightweight AOP solution and ASM to implement non-intrusive code implantation, the additional overhead introduced to the host after the user accesses is minimal; 4) Avoiding the use of third-party paid SDK for monitoring, developers can flexibly customize requirements, and can be deployed on private platforms to avoid the risk of commercial privacy data leakage; 5) It can cover the existing mobile terminal network components, perform refined performance monitoring of the mobile network, and facilitate users to fully monitor the network performance of online user mobile terminals.

[0122] It should be noted that the specific implementation content of the device for generating the application installation package of the present invention has been described in detail in the method for generating the application installation package described above, so the repeated content will not be described here.

[0123] Figure 8 An exemplary system architecture 800 is shown to which the method for generating an application installation package or the apparatus for generating an application installation package according to the embodiments of the present invention can be applied.

[0124] like Figure 8As shown, system architecture 800 may include terminal devices 801, 802, 803, a network 804, and a server 805. Network 804 is used to provide a medium for communication links between terminal devices 801, 802, 803 and server 805. Network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0125] The user can use the terminal devices 801, 802, 803 to interact with the server 804 through the network 804 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 801, 802, 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).

[0126] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0127] The server 805 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 801, 802, and 803. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.

[0128] It should be noted that the method for generating an application installation package provided in the embodiment of the present invention is generally executed by the server 805, and accordingly, the device for generating the application installation package is generally set in the server 805. The method for generating an application installation package provided in the embodiment of the present invention can also be executed by the terminal devices 801, 802, and 803, and accordingly, the device for generating the application installation package can be set in the terminal devices 801, 802, and 803.

[0129] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0130] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0131] like Fig. 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0132] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0133] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.

[0134] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0135] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0136] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor, for example, it may be described as: a processor includes a generation module, a compilation module and a replacement module, wherein the names of these modules do not constitute a limitation on the modules themselves in some cases.

[0137] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: generating a target file based on a mobile application development framework; wherein the target file includes source files, software packages, resources, configuration files and network monitoring toolkits that the project depends on; compiling the target file into a binary class file; using a byte manipulation framework, replacing the network component interface in the class file with the customized interface in the network monitoring toolkit, thereby generating an application installation package.

[0138] According to the technical solution of the embodiment of the present invention, because the byte manipulation framework is adopted, the network component interface in the class file is replaced with the customized interface in the network monitoring toolkit to generate the technical means of the application installation package, so the technical problems of difficult maintenance and insufficient lightness in the prior art are overcome. The embodiment of the present invention uses ASM to implement the use of AOP ideas to monitor the network performance of mobile applications, which has the following beneficial effects: 1) Adopting non-intrusive code implantation technology to avoid the labor cost caused by manual code implantation and the problem of coupling business and monitoring logic caused by intrusive code; 2) Platform output can be realized, and different applications can easily access the network performance monitoring function; 3) Adopting a relatively lightweight AOP solution and ASM to implement non-intrusive code implantation, the additional overhead introduced to the host after the user accesses is minimal; 4) Avoiding the use of third-party paid SDK for monitoring, developers can flexibly customize requirements, and can be deployed on private platforms to avoid the risk of commercial privacy data leakage; 5) It can cover the existing mobile terminal network components, and perform refined performance monitoring of the mobile network, which is convenient for users to fully monitor the network performance of online users' mobile terminals.

[0139] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A method for generating an application installation package, characterized in that: include: Enumerate the network component interfaces corresponding to each network component; Generate corresponding customized interfaces according to the interfaces of various network components, thereby generating a network monitoring toolkit; integrating said network monitoring toolkit into a mobile application development framework; Generate target files based on the mobile application development framework; wherein the target files include source files, software packages, resources, configuration files and network monitoring toolkits that the project depends on; Compile the target file into a binary class file; A byte manipulation framework is used to replace the network component interface in the class file with the customized interface in the network monitoring toolkit, thereby generating an application installation package.

2. The method according to claim 1, characterized in that Using a byte manipulation framework, the network component interface in the class file is replaced with a custom interface in the network monitoring toolkit, including: Parsing the class file to generate a tree-type bytecode structure; The tree-type bytecode structure is traversed, and during the traversal process, the bytecode of the network component interface in the class file is replaced with the bytecode of the customized interface in the network monitoring toolkit.

3. The method according to claim 2, characterized in that Replacing the bytecode of the network component interface in the class file with the bytecode of the custom interface in the network monitoring toolkit includes: Through the cooperation of the ClassReader class, the ClassWriter class, the ClassVisitor class and the MethodVisitor class, the bytecode of the network component interface in the class file is replaced by the bytecode of the customized interface in the network monitoring toolkit.

4. The method according to claim 1, characterized in that: The network monitoring toolkit is used to collect network monitoring parameters of the mobile terminal and report the network monitoring parameters regularly or in real time; The network monitoring parameters include at least one of the following: Request method, request exception type, request initiation time, requested uniform resource locator, upstream traffic, downstream traffic, remaining packet time, first packet time, request duration, handshake time with the server, domain name query time, and Http return code.

5. A device for generating an application installation package, characterized in that: include: A generation module, used to generate target files based on a mobile application development framework; wherein the target files include source files, software packages, resources, configuration files and network monitoring toolkits that the project depends on; A compiling module, used for compiling the target file into a binary class file; A replacement module, used to replace the network component interface in the class file with the customized interface in the network monitoring toolkit using a byte manipulation framework, thereby generating an application installation package; The integration module is used to enumerate the network component interfaces corresponding to each network component before generating the target file based on the mobile application development framework; generate the corresponding customized interface according to each network component interface, thereby generating a network monitoring toolkit; and integrate the network monitoring toolkit into the mobile application development framework.

6. The device according to claim 5, characterized in that The replacement module is used for: Parsing the class file to generate a tree-type bytecode structure; The tree-type bytecode structure is traversed, and during the traversal process, the bytecode of the network component interface in the class file is replaced with the bytecode of the customized interface in the network monitoring toolkit.

7. The device according to claim 6, characterized in that Replacing the bytecode of the network component interface in the class file with the bytecode of the custom interface in the network monitoring toolkit includes: Through the cooperation of the ClassReader class, the ClassWriter class, the ClassVisitor class and the MethodVisitor class, the bytecode of the network component interface in the class file is replaced by the bytecode of the customized interface in the network monitoring toolkit.

8. The device according to claim 5, characterized in that The network monitoring toolkit is used to collect network monitoring parameters of the mobile terminal and report the network monitoring parameters regularly or in real time; The network monitoring parameters include at least one of the following: Request method, request exception type, request initiation time, requested uniform resource locator, upstream traffic, downstream traffic, remaining packet time, first packet time, request duration, handshake time with the server, domain name query time, and Http return code.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 4.

10. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • Monitoring method and device for computer application program

    CN107291587A