A method for determining a stubbing process based on a file type and a related device
By using a file-type-based instrumentation process, target sub-functions of third-party applications are selectively instrumented and interpreted, solving the problem of existing technologies failing to fully monitor and optimize third-party applications, thus improving user experience and operational efficiency.
Patent Information
- Application Number
- CN202410042952.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-10
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-01-10
AI Technical Summary
In existing technologies, the operation of third-party applications is not fully understood by electronic devices, making it difficult to optimize them in a targeted manner, resulting in a poor user experience. Furthermore, compiler instrumentation processes often have missing instrumentation instances, making it difficult to improve the operating efficiency of third-party applications.
The instrumentation process is determined based on the file type. Different traversal processes are selected based on the file type of the running file. The target sub-function is instrumented, its execution interface is adjusted, and the target sub-function is interpreted and executed by the interpreter. The instrumentation information is stored in the asynchronous message queue.
It enables detailed monitoring and targeted optimization of the operation of third-party applications, improving user experience and operational efficiency, avoiding unnecessary optimization of the entire application, and reducing the compiler burden.
Smart Images

Figure CN119271533B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] Embodiments of the present application relate to the technical field of terminals, and in particular, to a method for determining a plug-in process based on file types and related apparatuses. BACKGROUND
[0002] With the development of the Internet, in order to facilitate life and entertainment, users download and use more and more third-party applications in the application market of electronic devices. However, for users, various related functions or associated application contents in the third-party applications can be quickly opened or can be quickly displayed in response to user operations, which can bring better user experience to users.
[0003] Since the current third-party applications do not involve related running operations of the operating system in the electronic device during running, the related running events such as when the various related functions in the third-party applications start running and when they end running are unknown to the operating system of the electronic device. Therefore, in order to avoid the situation that the application content (such as pictures, text, voice or controls, etc.) loading time is too long or the related function loading speed is slow during the running of the third-party application, in the prior art, the compiler in the virtual machine is usually used to plug in and process the key functions in the third-party application. Due to the complex running principle of the compiler, the design of the plug-in function based on the compiler is difficult, and the phenomenon of "missing plug-in" is easy to occur, so that the electronic device cannot completely and in detail master the running situation of the third-party application, thereby making it difficult for the electronic device to achieve good optimization effect for the third-party application and the user experience is poor.
[0004] Therefore, how to comprehensively screen out the key functions in the third-party application and plug in and process them to achieve the purpose of efficiently optimizing the third-party application and improving the user experience is a problem to be solved. SUMMARY
[0005] The present application provides a method for determining a plug-in process based on file types and related apparatuses, wherein in the method for determining a plug-in process based on file types, the corresponding traversal process can be adopted based on the file type of the running file of the application file of the third-party application after being compiled and optimized to achieve the purpose of comprehensively screening the target sub-function and plugging in and processing it, and the execution interface of the target sub-function is adjusted, which is helpful for the electronic device to monitor the running situation of the third-party application, so as to be able to optimize the key events of the third-party application in a targeted manner and improve the user's use experience.
[0006] In a first aspect, an embodiment of the present application provides a method for determining a hooking process based on a file type, which can include: obtaining file information of a running file corresponding to a third-party application, the running file being an application file corresponding to the third-party application that is currently compiled and executed or interpreted in an ART (Android Runtime), the file information including a file name of the running file, and the running file including at least one sub-function; determining a file type of the running file based on the file name in the running file, the file type including a first file type and a second file type; performing hooking processing on a target sub-function in the running file based on a traversal process corresponding to the file type of the running file, and continuing to interpret and execute the target sub-function through a first interpreter, the target sub-function being a sub-function having a key function tag.
[0007] In the prior art, the electronic device cannot optimize the third-party application in a targeted manner due to the lack of a hooking point, and the user experience is poor. In the embodiment of the present application, when the ART compiles or interprets and executes the running file of the third-party application, different traversal processes can be selected based on the compilation optimization attribute of the running file to perform hooking processing on the target sub-function in the running file, which helps to locate the key event in the running process of the third-party application by the electronic device, and then the third-party application can be optimized in a targeted manner based on the obtained key event of the third-party application, avoiding optimization of the entire third-party application, improving the accuracy of optimization, and improving the user experience.
[0008] In a possible implementation manner, the first traversal process can include traversing a type of an execution interface of each sub-function in the running file, and the first traversal process is a traversal process corresponding to the first file type; and the second traversal process can include traversing a type of compilation identification information of each sub-function in the running file, and the second traversal process is a traversal process corresponding to the second file type.
[0009] In the embodiment of the present application, the ART can take different traversal processes for the sub-functions in the running file based on different file types of the running file. Specifically, the first traversal process can first determine the type of the execution interface of the sub-function, and then determine whether the sub-function is the target sub-function; and the second traversal process can first determine whether the compilation identification information of the sub-function is empty, and then determine whether the sub-function with non-empty compilation identification information is the target sub-function. The embodiment of the present application helps to more comprehensively locate the key function in the sub-function in the third-party application by taking different traversal processes, helps to subsequently perform hooking processing on the target sub-function, and thus helps the electronic device to master the detailed running situation of the third-party application, facilitates the electronic device to subsequently optimize the third-party application in a targeted manner, and improves the running performance of the third-party application and the user experience.
[0010] In a possible implementation manner, the execution interface can include a compiled execution interface and an interpreted execution interface, and the interpreted execution interface can include a first interpreted execution interface and a second interpreted execution interface; in a case where the file type of the running file is the first file type, the running file is the image file data; the method can further include: traversing the execution interface of each sub-function in the running file; if the execution interface of the first sub-function is the compiled execution interface, and the first sub-function is the target sub-function, adjusting the execution interface of the first sub-function to the first interpreted execution interface, and executing the first sub-function by using the first interpreter; if the execution interface of the second sub-function is the second interpreted execution interface, and the second sub-function is the target sub-function, adjusting the execution interface of the second sub-function to the first interpreted execution interface, and executing the second sub-function by using the first interpreter.
[0011] In the embodiment of the present application, the first file type can represent the file suffix name of the running file. For example, when the running file is a file compiled and optimized by speed-profile, the suffix name of the running file is ".art", and thus the running file can be considered as the first file type. Since the ".art" file is an image file, one or more hot functions are stored in the image file. Therefore, in a case where the file type of the running file is the first file type, the ART needs to traverse the execution interface of each hot function in the running file, and determine whether each hot function has a key function tag, and then perform the instrumenting processing on the target sub-function having the key function tag, and adjust the execution interface of the target sub-function. By transferring the target sub-function to the first interpreter for interpreted execution, the running burden of the compiler and the second interpreter can be reduced, so as to further improve the performance of the electronic device. Moreover, the design principle of instrumenting processing by using the interpreter is simpler than that of instrumenting processing by using the interpreter, so that the target sub-function can be more comprehensively captured and interpreted, and the situation that the key events are missed from the instrumenting processing can be avoided, and the electronic device can more comprehensively master the running situation of the third-party application.
[0012] In a possible implementation manner, the ART can include a compiler and an interpreter, and the interpreter can include a first interpreter and a second interpreter; in a case where the file type of the running file is the first file type, the method can further include: if the execution interface of the third sub-function is the compiled execution interface, and the third sub-function is not the target sub-function, executing the machine code corresponding to the third sub-function; and if the execution interface of the fourth sub-function is the second interpreted execution interface, and the fourth sub-function is not the target sub-function, executing the fourth sub-function by using the second interpreter.
[0013] In the embodiments of the present application, the ART does not change the execution interface of the sub-functions other than the target sub-function. Specifically, if the execution interface of a sub-function is a compiled execution interface, and the sub-function is not the target sub-function, it means that the sub-function has been subjected to the compiled optimization processing, and thus the machine code corresponding to the sub-function can be directly executed. If the execution interface of a sub-function is the second interpretation execution, and the sub-function is not the target sub-function, the second interpreter continues to interpret and execute the sub-function, which helps to ensure the running efficiency of the third-party application and the user experience.
[0014] In a possible implementation manner, in the case that the file type of the running file is the second file type, the method can further include: obtaining the compiled identification information corresponding to each sub-function in the running file; if the compiled identification information of the fifth sub-function is empty, and the fifth sub-function is not the target sub-function, adjusting the execution interface of the fifth sub-function to the second interpretation execution interface, and interpreting and executing the fifth sub-function through the second interpreter; if the compiled identification information of the sixth sub-function is empty, and the sixth sub-function is the target sub-function, adjusting the execution interface of the sixth sub-function to the first interpretation execution interface, and interpreting and executing the sixth sub-function through the first interpreter; if the compiled identification information of the seventh sub-function is not empty, and the seventh sub-function is the target sub-function, adjusting the execution interface of the seventh sub-function to the first interpretation execution interface, and interpreting and executing the sixth sub-function through the first interpreter; if the compiled identification information of the eighth sub-function is not empty, and the eighth sub-function is not the target sub-function, executing the machine code corresponding to the eighth sub-function.
[0015] In the embodiments of the present application, the second file type can represent the file suffix name of the running file. For example, when the running file is an AOT-compiled optimized file and the suffix name of the running file is ".odex", the running file can be considered as the second file type. In the case where the file type of the running file is the second file type, the method of the present application can set the execution interface for each sub-function by judging whether the compilation identification information corresponding to each sub-function in the running file is empty. Specifically, when the compilation identification information of a sub-function is empty, it can be considered that the sub-function has not been subjected to compilation optimization processing, and the execution interface of the sub-function can be set as the second interpretation execution interface, and the second interpreter continues to interpret and execute the sub-function. If the compilation identification information of a sub-function is not empty, it can be considered that the sub-function has been subjected to compilation optimization processing. In the case where the sub-function is a target sub-function, the execution interface of the sub-function can be set as the first interpretation execution interface, and the first interpreter continues to interpret and execute the sub-function. If the compilation identification information of a sub-function is not empty, it can be considered that the sub-function has been subjected to compilation optimization processing. In the case where the sub-function is not a target sub-function, it can be understood that the sub-function has been subjected to compilation optimization processing, and therefore the machine code corresponding to the sub-function can be directly executed, which helps to ensure the running efficiency of the third-party application and the user experience.
[0016] In a possible implementation manner, after the target sub-function in the running file is subjected to the Hook processing, the above method can further include: obtaining the Hook information corresponding to the target sub-function; reflecting the Hook information into the message queue, and continuing to interpret and execute the target sub-function by the first interpreter.
[0017] In the embodiments of the present application, the message queue storing the Hook information is an asynchronous message queue, that is, after the Hook information is reflected into the message queue, it will not be processed at the first time, but in order to ensure the normal running of the third-party application, after the Hook information is saved into the message queue, the target sub-function can be continued to be interpreted and executed by the interpreter, and the Hook information can be processed asynchronously. This manner not only greatly weakens the influence of the Hook processing on the third-party application, but also ensures the running efficiency of the third-party application and the user experience.
[0018] In a possible implementation, the third-party application includes at least one application file, one application file includes at least one sub-function, and before the file information of the running file corresponding to the third-party application is acquired, the method can further include: in response to the third-party application being in a running state, traversing function information of each sub-function corresponding to each application file of the third-party application, the function information including a function name corresponding to the function; based on the function information and the pre-acquired configuration file, determining whether there is a function name of a key function in the configuration file that is the same as a function name of a ninth sub-function in the third-party application, the configuration file including one or more function names corresponding to one or more key functions respectively; and in a case where it is determined that there is a function name of a key function in the configuration file that is the same as the function name of the ninth sub-function in the third-party application, setting a key function label for the ninth sub-function.
[0019] In the embodiments of the present application, the ART can traverse each sub-function in each application file corresponding to the third-party application when the third-party application is initially started, and determine, based on function information of each sub-function and a pre-acquired configuration file, whether there is a function name of a key function in the configuration file that is the same as a function name of a ninth sub-function in the third-party application, where if there is a function name of a key function in the configuration file that is the same as the function name of the ninth sub-function in the third-party application, the ninth sub-function can be considered as a function corresponding to a key event. Further, the ART sets a key function label for the eighth function, so that the ART does not need to repeatedly determine key functions in the sub-function in the running file during the running of the third-party application, which helps to reduce the running burden of the electronic device and improve the efficiency of subsequent plug-in processing of the target sub-function in the running file by the ART based on the interpreter.
[0020] In a second aspect, the embodiments of the present application provide a system for determining a plug-in process based on a compiled optimization function, which can include a plug-in module and a first interpreter. The plug-in module can be configured to acquire file information of a running file corresponding to a third-party application, the running file being an application file corresponding to the third-party application that is currently compiled and executed or interpreted in the runtime virtual machine ART, the file information including a file name of the running file, and the running file including at least one sub-function; determine a file type of the running file based on the file name in the running file, the file type including a first file type and a second file type; and perform plug-in Hook processing on a target sub-function in the running file based on a traversal process corresponding to the file type of the running file, the target sub-function being a sub-function with a key function label. The first interpreter can be configured to continue to interpret and execute the target sub-function.
[0021] In a possible implementation, the first traversal process can include traversing types of execution interfaces corresponding to each sub-function in the running file, and the first traversal process is a traversal process corresponding to the first file type; and the second traversal process can include traversing types of compilation identification information corresponding to each sub-function in the running file, and the second traversal process is a traversal process corresponding to the second file type.
[0022] In a possible implementation, the execution interface can include a compiled execution interface and an interpreted execution interface, and the interpreted execution interface can include a first interpreted execution interface and a second interpreted execution interface; in a case where the file type of the running file is the first file type, the running file is mirror file data; and the system can further include a management module; the patching module can be further configured to traverse the execution interfaces of each sub-function in the running file; and the management module can be further configured to: in a case where the execution interface of a first sub-function is the compiled execution interface and the first sub-function is the target sub-function, adjust the execution interface of the first sub-function to the first interpreted execution interface; and in a case where the execution interface of a second sub-function is the second interpreted execution interface and the second sub-function is the target sub-function, adjust the execution interface of the second sub-function to the first interpreted execution interface; and the first interpreter can be further configured to: interpretively execute the first sub-function; and interpretively execute the second sub-function.
[0023] In a possible implementation, the ART can include a compiler and an interpreter, and the interpreter can include the first interpreter and the second interpreter; in a case where the file type of the running file is the first file type, the patching module can be configured to: in a case where the execution interface of a third sub-function is the compiled execution interface and the third sub-function is not the target function, execute machine code corresponding to the third sub-function; and the second interpreter can be configured to: in a case where the execution interface of a fourth sub-function is the second interpreted execution interface and the fourth sub-function is not the target sub-function, interpretively execute the fourth sub-function.
[0024] In a possible implementation, in the case that the file type of the running file is the second file type, the above-mentioned patching module can be further configured to: obtain the compilation identification information corresponding to each sub-function in the running file; in the case that the compilation identification information of the fifth sub-function is empty and the fifth sub-function is not the target sub-function, adjust the execution interface of the fifth sub-function to the second interpretation execution interface; in the case that the compilation identification information of the sixth sub-function is empty and the sixth sub-function is the target sub-function, adjust the execution interface of the sixth sub-function to the first interpretation execution interface; in the case that the compilation identification information of the seventh sub-function is not empty and the seventh sub-function is the target sub-function, adjust the execution interface of the seventh sub-function to the first interpretation execution interface; in the case that the compilation identification information of the eighth sub-function is not empty and the eighth sub-function is not the target sub-function, execute the machine code corresponding to the eighth sub-function; the above-mentioned second interpreter can be further configured to interpret and execute the fifth sub-function; and the above-mentioned first interpreter can be further configured to interpret and execute the sixth sub-function and / or the seventh sub-function.
[0025] In a possible implementation, after the target sub-function in the running file is processed by the patching Hook, in the case that the file type of the running file is the second file type, the above-mentioned patching module can be further configured to: obtain the patching information corresponding to the target sub-function, and reflect the patching information to the message queue; and the above-mentioned first interpreter can be further configured to: after the patching information is reflected to the message queue, continue to interpret and execute the target sub-function.
[0026] In a possible implementation, the third-party application includes at least one application file, and one application file includes at least one sub-function, and before obtaining the file information of the running file corresponding to the third-party application, the above-mentioned patching module can be further configured to: in response to the third-party application being in a running state, traverse the function information of each sub-function corresponding to each application file of the third-party application, the function information including a function name corresponding to the function; based on the function information and a configuration file obtained in advance, determine whether there is a function name of a key function in the configuration file that is the same as a function name of a ninth sub-function in the third-party application, the configuration file including one or more function names corresponding to the key functions respectively; and in the case that it is determined that there is a function name of a key function in the configuration file that is the same as a function name of a ninth sub-function in the third-party application, set a key function label for the ninth sub-function.
[0027] In a third aspect, an electronic device is provided, which includes one or more processors and one or more memories; wherein the one or more memories are coupled to the one or more processors, and are configured to store computer program codes; and the computer program codes include computer instructions, which when executed by the one or more processors, cause the electronic device to perform the interpreter-based instrumentation method according to the first aspect or any possible implementation of the first aspect.
[0028] In a fourth aspect, a computer readable storage medium is provided, which includes computer instructions, which when executed on an electronic device, cause the communication apparatus to perform the interpreter-based instrumentation method according to the first aspect or any possible implementation of the first aspect.
[0029] In a fifth aspect, a computer program product is provided, which when executed on a computer, cause the computer to perform the interpreter-based instrumentation method according to the first aspect or any possible implementation of the first aspect.
[0030] It can be understood that the system provided by the second aspect, the electronic device provided by the third aspect, the computer readable storage medium provided by the fourth aspect, and the computer program product provided by the fifth aspect are all used to execute the method provided by the embodiments of the present application. Therefore, the beneficial effects that can be achieved thereby can refer to the beneficial effects in the corresponding method, which will not be described here. BRIEF DESCRIPTION OF DRAWINGS
[0031] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background art, the drawings needed to be used in the embodiments of the present application or the background art will be described below.
[0032] Figures 1-4 is a user interface schematic diagram of a group of electronic devices provided by the embodiments of the present application.
[0033] Figure 5 is a running schematic diagram of a third-party application provided by the embodiments of the present application.
[0034] Figure 6 is a hardware structure schematic diagram of an electronic device provided by the embodiments of the present application.
[0035] Figure 7 is a software structure block diagram of an electronic device provided by the embodiments of the present application.
[0036] Figure 8 is another software structure block diagram of an electronic device provided by the embodiments of the present application.
[0037] Figure 9is a third-party application execution mode schematic diagram provided by an embodiment of the present application.
[0038] Figure 10 is a file type based method of determining a flowchart of a method of inserting a peg provided by an embodiment of the present application.
[0039] Figure 11 is a flowchart of an adjusted sub-function execution interface corresponding to a first traversal process provided by an embodiment of the present application.
[0040] Figure 12 is a flowchart of an adjusted sub-function execution interface corresponding to a first traversal process provided by another embodiment of the present application.
[0041] Figure 13 is a flowchart of an adjusted sub-function execution interface corresponding to a second traversal process provided by an embodiment of the present application.
[0042] Figure 14 is a flowchart of an adjusted sub-function execution interface corresponding to a second traversal process provided by another embodiment of the present application.
[0043] Figure 15 is a schematic diagram of optimizing the performance of a third-party application through a method of inserting a peg provided by an embodiment of the present application. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present application will be described clearly and exhaustively below with reference to the drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text only means a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which means that there are three cases of A alone, A and B together, and B alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0045] The term "user interface (UI)" in the following embodiments of the present application is a medium interface for interaction and information exchange between an application program or an operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface of an application program is source code written in a specific computer language such as Java, extensible markup language (XML), etc. The interface source code is parsed, rendered and finally presented as content recognizable by the user, such as pictures, texts, buttons and other controls on the electronic device. A control (also called a widget) is a basic element of a user interface, and typical controls include a toolbar, a menu bar, a text box, a button, a scroll bar, a picture and text. The properties and content of a control in an interface are defined by tags or nodes, such as XML tags or nodes <textview> 、 <imgview> 、 <videoview>The nodes define the controls contained in the interface. One node corresponds to one control or attribute in the interface, and the node is rendered into the content visible to the user after being parsed and rendered. In addition, many applications, such as hybrid applications, usually also contain web pages in the interface. The web page, also known as a page, can be understood as a special control embedded in the interface of the application. The web page is source code written in a specific computer language, such as hyper text markup language (HTML), cascading style sheets (CSS), JavaScript (JS), and the like. The web page source code can be loaded and displayed into content recognizable by the user by a browser or a web page display component similar to the function of the browser. The specific content contained in the web page is also defined by tags or nodes in the web page source code, such as HTML 、 、 <video> 、 <canvas>to define the elements and attributes of a web page.
[0046] A common form of user interface is a graphic user interface (GUI), which refers to a user interface that displays in a graphical manner. It can be an icon, a window, a control, etc. interface element displayed in the display screen of an electronic device, wherein the control can include an icon, a button, a menu, a tab, a text box, a dialog box, a status bar, a navigation bar, a Widget, and the like visible interface element.
[0047] In addition, embodiments for using such electronic devices, user interfaces for such electronic devices, and electronic devices are also introduced below. In some embodiments, the electronic device can be a portable electronic device that also contains other functions such as message management, message receiving and pushing functions, such as a mobile phone, a tablet computer, a wearable electronic device (e.g., a smart watch) with wireless communication functions, and the like. Exemplary embodiments of the portable electronic device include, but are not limited to, a mobile phone with Android operating system, iOS operating system, Windows operating system, or other operating systems. The portable electronic device described above can also be other portable electronic devices, such as a laptop computer (Laptop) with a touch-sensitive surface or a touch panel. It should also be understood that in other embodiments, the electronic device described above can not be a portable electronic device, but a desktop computer, an in-vehicle computer, etc. with a touch-sensitive surface or a touch panel. It can be understood that the embodiments of the present application are introduced by taking a smart phone as an example, but are not limited to a smart phone, and can also be other smart devices with communication functions, such as a smart watch, a smart bracelet, and the like. It can be understood that the embodiments of the present application are introduced by taking a smart phone as an example, but are not limited to a smart phone, and can also be other smart devices with communication functions, such as a smart watch, a smart bracelet, and the like.
[0048] In order to facilitate understanding of the embodiments of the present application, the technical problems to be solved by the embodiments of the present application are analyzed in detail below.
[0049] With the development of the Internet, in order to facilitate life and entertainment, users download and use more and more third-party software in the application market of the electronic device. However, for users, various related functions or associated application programs in the third-party application can be quickly opened or can quickly respond to user operations, which can bring better user experience to users.
[0050] Please refer to the accompanying drawings Figure 1 to the accompanying drawings Figure 4 , Figures 1-4 is a schematic diagram of a user interface of a group of electronic devices provided by the embodiments of the present application.
[0051] The electronic device can display a user interface as shown in Figure 1 , which is a user interface as shown in Figure 1 The illustrated user interface can include one or more third-party applications (such as third-party 101), and the user can click (or other user operation) the third-party 101. In the case of a short application loading time, the electronic device can quickly respond to the user's click operation and display a user interface as shown in Figure 2 The illustrated user interface is the application display interface of the third-party application, as shown in Figure 2 The illustrated user interface is the application display interface of the third-party application, as shown in Figure 2 The third-party application is a shopping application. When the user clicks on an application 1022 in the third-party application in the application display interface, the third-party application will load the corresponding application content for display in the electronic device, as shown in Figure 3 The illustrated user interface.
[0052] Currently, the third-party application will be affected by the related configuration of the electronic device, or the network speed, or other related factors. Before displaying the user interface as shown in Figure 3 The illustrated user interface is the application display interface of the third-party application, as shown in Figure 4 The illustrated user interface is the application display interface of the third-party application, as shown in Figure 4 The illustrated user interface is the application display interface of the third-party application, as shown in Figure 4 The illustrated user interface is the application display interface of the third-party application, as shown in Figure 3 The illustrated user interface is the application display interface of the third-party application, as shown in
[0053] The longer the display time of the user interface as shown in Figure 4 The longer the display time of the user interface as shown in Figure 4 The longer the display time of the user interface as shown in
[0054] However, the third-party application does not involve the related running events of the operating system in the electronic device. Please refer to the attached Figure 5 , Figure 5 is a schematic diagram of the running of a third-party application provided by an embodiment of the present application. As shown in Figure 5 When the third-party application is running, it is often a collection of multiple functions, and there is no explicit system event to define it. It can also be understood that the content loading process of the third-party application mainly executes the third-party application content, which is a black box for the operating system of the electronic device and cannot be modified, that is, the operating system of the electronic device cannot obtain the related running nodes (such as the running start node and the running end node of a certain application content) in the running process of the third-party application. There is no stub point when the third-party application is running, and the electronic device cannot optimize or improve the running of the third-party application based on the stub point.
[0055] In the prior art, one prior art solution is to perform runtime optimization for the entire third-party application, for example, as shown in the above Figure 5 In the prior art, the working frequency of the corresponding processing core is higher than the initial working frequency of the corresponding processing core during the entire third-party application runtime, that is, the prior art performs application runtime optimization by increasing the working frequency of the processing core during the entire third-party application runtime. That is, in the prior art, the working frequency of the processing core during the entire third-party application runtime is higher than the working frequency of the processing core during the initial third-party application runtime. The loading time of the third-party application can be shortened, and the user experience can be improved. However, the optimization operation of this solution (i.e., increasing the working frequency of the processing core during the entire third-party application runtime) is often limited by the power consumption of the processing core or the overall temperature control of the electronic device.
[0056] Please refer to Table 1 below, which is a table of third-party application loading time in different electronic devices in the prior art provided in an embodiment of the present application.
[0057] Table 1
[0058]
[0059] As shown in Table 1 above, the loading time of the third-party application A and the third-party application B is reduced after overall optimization. However, since this solution is an overall optimization of the third-party application, that is, the high working frequency of the processing core is maintained during the third-party application runtime. Therefore, although this solution can shorten the loading time of the third-party application, since it adjusts the frequency (i.e., adjusts the working frequency of the processing core) during the third-party application runtime, the shell temperature of the electronic device will rise significantly. Therefore, in order to control the temperature of the electronic device, the working frequency of the processing core cannot be modified significantly, and thus the loading time of the third-party application cannot be significantly shortened.
[0060] Another prior art solution is to consider the click operation of the user in the third-party application interface as the time point at which the application content of the third-party application starts to load, and to start frequency adjustment optimization based on this. The frequency adjustment time of this solution is significantly shorter than the overall optimization of the third-party application, so the time for adjusting the frequency of the processing core is shortened, and the working frequency after adjustment is higher, thereby shortening the loading time of the third-party application, under the condition that the shell temperature limit point of the electronic device does not change.
[0061] However, the scheme has a problem that the trigger point of the user click operation cannot completely correspond to the time point at which the application content of the third-party application starts to be loaded due to different objects clicked by the user. Moreover, the scheme does not have a clear end point of running, and therefore, even if there is a substitute start point of running, the end point of running after the application content is loaded cannot be obtained. Moreover, different click operations all need the electronic device to determine whether it is a start point of running, and the uncertainty may cause the scheme to be abused, and the lack of an end point may cause the scheme to have an expanded range of influence, and some operation efficiency improvement becomes low.
[0062] Therefore, the embodiments of the present application provide a method for determining a plug-in process based on a file type and a related device, which can determine a corresponding traversal process based on the file type of a running file of a third-party application to achieve the purpose of plug-in processing of a target sub-function, and adjust the execution interface of the target sub-function, which helps the electronic device to accurately determine the nodes of each event in the running of the third-party application through the plug-in information after plug-in, and then can optimize the third-party application in a targeted manner, such as shortening the loading time of a certain application content in the third-party application and improving the user experience.
[0063] For example, the embodiments of the present application can determine a corresponding traversal process based on the file type of a running file of a third-party application to achieve the purpose of plug-in processing of a target sub-function. The target sub-function is a function with a key function identifier, and the target sub-function represents a function corresponding to a key event in the running file. Further, the embodiments of the present application adjust the execution interface of the target sub-function to a first interpretation execution interface, and the target sub-function is interpreted and executed by a first interpreter (such as a Switch interpreter). Further, the plug-in information of the target sub-function after plug-in processing is reflected to a message queue to be processed. It can be seen that the embodiments of the present application can perform plug-in processing on the target sub-function in the running file to be executed in the third-party application based on the interpreter, obtain corresponding plug-in information, realize the positioning of the key event point in the running process of the third-party application, and then can optimize the third application in a targeted manner based on the obtained key event of the third-party application, avoid optimizing the entire third-party application, improve the accuracy of optimization, and increase the user experience. For example, as described above Figure 5 As shown, the working frequency of the processing core is raised at the critical function 1, and the working frequency of the processing core is lowered at the critical function 2 to be consistent with that before the raising, so that the working frequency of the processing core during the time period between the critical function 1 and the critical function 2 is higher than the working frequency of the processing core corresponding to the third-party application initially, and also higher than the working frequency of the processing core corresponding to the entire third-party application in the prior art during the running of the third-party application, so that the loading time of the application content in the third-party application can be greatly shortened, and the user experience is improved. In addition, the message queue storing the plug-in information is an asynchronous message queue, that is, after the plug-in information is reflected to the message queue, it will not be processed at the first time, but in order to ensure the normal running of the third-party application, after the plug-in information is saved to the message queue, the above-mentioned running function can be continuously interpreted and executed by the interpreter, and the plug-in information can be processed asynchronously, which greatly weakens the influence of the plug-in processing on the third-party application, and ensures the running efficiency and user experience of the third-party application.
[0064] The embodiments of the present application can be implemented to optimize the performance of the third-party application. The specific implementation of the method will be described in detail in the following related embodiments, and the embodiments of the present application will not be described here.
[0065] It should be understood that the above-mentioned user interface is only an example of the loading application interface of the third-party application, and should not be limited to the embodiments of the present application.
[0066] First, the following exemplary electronic device 100 is taken as an example to introduce the above-mentioned Figures 1-4 electronic device.
[0067] Please refer to the attached Figure 6 , Figure 6 is a hardware structure schematic diagram of an electronic device provided by the embodiments of the present application.
[0068] The embodiments will be described in detail below taking the electronic device 100 as an example. It should be understood that the electronic device 100 can have more or fewer components than those shown in Figure 6 , can combine two or more components, or can have a different component configuration. Figure 6 The various components shown in may be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.
[0069] The electronic device 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0070] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units can be independent devices or integrated in one or more processors.
[0071] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to instruction operation codes and timing signals, and complete the control of fetching and executing instructions.
[0072] The memory in the processor 110 can also be provided for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory can save instructions or data that the processor 110 has just used or repeatedly uses. If the processor 110 needs to use the instructions or data again, it can be directly called from the memory. This avoids repeated access and reduces the waiting time of the processor 110, thus improving the efficiency of the system.
[0073] In some embodiments, the processor 110 can include one or more interfaces. The interfaces can include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0074] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 can include multiple sets of I2C buses. The processor 110 can be coupled to the touch sensor 180K, the charger, the flash, the camera 193, etc. through different I2C bus interfaces, respectively. For example, the processor 110 can be coupled to the touch sensor 180K through an I2C interface, so that the processor 110 and the touch sensor 180K communicate through the I2C bus interface, realizing the touch function of the electronic device 100.
[0075] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple sets of I2S buses. The processor 110 can be coupled to the audio module 170 through the I2S bus, realizing the communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can deliver audio signals to the wireless communication module 160 through the I2S interface, realizing the function of answering the phone through the Bluetooth headset.
[0076] The PCM interface can also be used for audio communication, sampling, quantizing and encoding analog signals. In some embodiments, the audio module 170 can be coupled with the wireless communication module 160 through a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 through the PCM interface, enabling the function of answering a phone call through a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0077] The UART interface is a universal serial bus for asynchronous communication. The bus can be a bidirectional communication bus. It converts data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is usually used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 through the UART interface, enabling Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 through the UART interface, enabling the function of playing music through a Bluetooth headset.
[0078] The MIPI interface can be used to connect the processor 110 and peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes the camera serial interface (CSI), the display serial interface (DSI), etc. In some embodiments, the processor 110 and the camera 193 communicate through the CSI interface, enabling the camera function of the electronic device 100. The processor 110 and the display screen 194 communicate through the DSI interface, enabling the display function of the electronic device 100.
[0079] The GPIO interface can be configured through software. The GPIO interface can be configured as a control signal or as a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 and the camera 193, the display screen 194, the wireless communication module 160, the audio module 170, the sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0080] The SIM card interface can be used to communicate with the SIM card interface 195, enabling the function of transmitting data to the SIM card or reading data in the SIM card.
[0081] The USB interface 130 is an interface conforming to the USB standard specification, and can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device 100, and can also be used to transmit data between the electronic device 100 and a peripheral device. It can also be used to connect a headset to play audio through the headset. The interface can also be used to connect other electronic devices, such as AR devices, etc.
[0082] It can be understood that the interface connection relationship between the modules shown in the embodiments of the present application is only illustrative and does not constitute a structural limitation of the electronic device 100. In some other embodiments of the present application, the electronic device 100 can also use different interface connection methods or a combination of multiple interface connection methods.
[0083] The charging management module 140 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger.
[0084] The power management module 141 is used to connect the battery 142 and the charging management module 140 to the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160, etc.
[0085] The wireless communication function of the electronic device 100 can be realized through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor, and the baseband processor, etc.
[0086] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0087] The mobile communication module 150 can provide a solution for wireless communication including 2G / 3G / 4G / 5G, etc. applied to the electronic device 100. The mobile communication module 150 can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform filtering, amplification, etc. on the received electromagnetic waves, and transfer the same to the modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor, and radiate the same as electromagnetic waves through the antenna 1. In some embodiments, at least part of the functional modules of the mobile communication module 150 can be disposed in the processor 110. In some embodiments, at least part of the functional modules of the mobile communication module 150 can be disposed in the same device as at least part of the modules of the processor 110.
[0088] The modem processor can include a modulator and a demodulator. The modulator is configured to modulate a low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is configured to demodulate a received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. The low-frequency baseband signal processed by the baseband processor is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the microphone 170B, etc.), or displays an image or a video through the display screen 194. In some embodiments, the modem processor can be a separate device. In other embodiments, the modem processor can be independent of the processor 110, and disposed in the same device as the mobile communication module 150 or other functional modules.
[0089] The wireless communication module 160 can provide a solution for wireless communication including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. applied to the electronic device 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives an electromagnetic wave via the antenna 2, frequency-modulates and filters the electromagnetic wave signal, and transmits the processed signal to the processor 110. The wireless communication module 160 can also receive a signal to be transmitted from the processor 110, frequency-modulate it, amplify it, and radiate it as an electromagnetic wave via the antenna 2.
[0090] In some embodiments, the antenna 1 and the mobile communication module 150 of the electronic device 100 are coupled, and the antenna 2 and the wireless communication module 160 are coupled, so that the electronic device 100 can communicate with a network and other devices through wireless communication technology. The wireless communication technology can include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. The GNSS can include a global positioning system (GPS), a global navigation satellite system (GLONASS), a beidu navigation satellite system (BDS), a quasi-zenith satellite system (QZSS), and / or a satellite based augmentation systems (SBAS).
[0091] The electronic device 100 implements a display function through a GPU, a display screen 194, and an application processor, etc. The GPU is a microprocessor for image processing, which is connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs, which execute program instructions to generate or change display information.
[0092] The display screen 194 is configured to display images, text, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light emitting diode (QLED), etc. In some embodiments, the electronic device 100 can include one or N display screens 194, where N is a positive integer greater than 1.
[0093] The electronic device 100 can implement the photographing function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.
[0094] The ISP is configured to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, the light is transmitted to the camera photosensitive element through the lens, the light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to the ISP for processing to convert it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise and brightness of the image. The ISP can also optimize the exposure, color temperature, etc. of the shooting scene. In some embodiments, the ISP can be arranged in the camera 193.
[0095] The camera 193 is configured to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then transmits the electrical signal to the ISP to convert it into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV, etc. format. In some embodiments, the electronic device 100 can include one or N cameras 193, where N is a positive integer greater than 1. In other embodiments, the electronic device 100 can also not include the camera 193.
[0096] The digital signal processor is used to process digital signals, in addition to being able to process digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.
[0097] The video codec is used to compress or decompress digital video. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple encoding formats, such as: moving picture experts group (MPEG) 1, MPEG 2, MPEG 3, MPEG 4, etc.
[0098] The NPU is a neural-network (NN) calculation processor, which can quickly process input information by drawing on the structure of a biological neural network, such as drawing on the transmission mode between human brain neurons, and can also constantly self-learn. Through the NPU, the electronic device 100 can realize intelligent cognition applications such as image recognition, face recognition, voice recognition, text understanding, etc.
[0099] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to realize data storage functions. For example, music, video, etc. Files are saved in the external memory card.
[0100] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various function applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application required by a function (such as a face recognition function, a fingerprint recognition function, a mobile payment function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as face information template data, fingerprint information template, etc.). In addition, the internal memory 121 can include a high-speed random access memory, and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), etc.
[0101] The electronic device 100 can realize audio functions through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the earphone interface 170D, and the application processor, etc. For example, music playing, recording, etc.
[0102] The audio module 170 is configured to convert digital audio information into an analog audio signal output, and to convert an analog audio input into a digital audio signal. The audio module 170 can also be configured to encode and decode audio signals. In some embodiments, the audio module 170 can be disposed in the processor 110, or some of the functions of the audio module 170 can be disposed in the processor 110.
[0103] The speaker 170A, also referred to as a "loudspeaker", is configured to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0104] The receiver 170B, also referred to as a "earpiece", is configured to convert an audio electrical signal into a sound signal. When the electronic device 100 receives a call or a voice message, the user can listen to the voice by holding the receiver 170B close to the ear.
[0105] The microphone 170C, also referred to as a "microphone", "transducer", is configured to convert a sound signal into an electrical signal. When making a call or sending a voice message, the user can speak into the microphone 170C by holding the mouth close to the microphone 170C, and input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, in addition to collecting sound signals, noise reduction functions can also be achieved. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C, in addition to collecting sound signals, noise reduction, and can also identify the source of the sound, and achieve directional recording functions, etc.
[0106] The earphone interface 170D is configured to connect a wired earphone. The earphone interface 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0107] The pressure sensor 180A is configured to sense a pressure signal and convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be disposed on the display screen 194. The pressure sensor 180A can be of various types, such as a resistive pressure sensor, an inductive pressure sensor, a capacitive pressure sensor, etc. The capacitive pressure sensor can include at least two parallel plates of conductive material. When a force is applied to the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure according to the change in capacitance. When a touch operation is applied to the display screen 194, the electronic device 100 detects the intensity of the touch operation according to the pressure sensor 180A. The electronic device 100 can also calculate the position of the touch according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations applied to the same touch position but with different touch operation intensities can correspond to different operation instructions. For example, when a touch operation with a touch operation intensity less than a first pressure threshold is applied to a short message application icon, an instruction to view short messages is executed. When a touch operation with a touch operation intensity greater than or equal to the first pressure threshold is applied to the short message application icon, an instruction to create a new short message is executed.
[0108] The gyroscope sensor 180B can be configured to determine the motion attitude of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyroscope sensor 180B. The gyroscope sensor 180B can be used for anti-shake photography. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of shaking of the electronic device 100, calculates the distance that the lens module needs to compensate according to the angle, and lets the lens offset the shaking of the electronic device 100 by reverse movement to achieve anti-shake. The gyroscope sensor 180B can also be used for navigation and motion sensing game scenarios.
[0109] The barometric pressure sensor 180C is configured to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude, assists positioning and navigation by using the air pressure value measured by the barometric pressure sensor 180C.
[0110] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can detect the opening and closing of a flip cover by using the magnetic sensor 180D. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Further, according to the detected opening and closing state of the cover or the flip cover, the electronic device 100 can set a feature such as automatic unlocking of the flip cover.
[0111] The acceleration sensor 180E can detect the magnitude of acceleration of the electronic device 100 in various directions (generally three axes). When the electronic device 100 is stationary, the acceleration sensor 180E can detect the magnitude and direction of gravity. The acceleration sensor 180E can also be used to identify the attitude of the electronic device, and can be applied to landscape / portrait screen switching and pedometer applications.
[0112] Distance sensor 180F is configured to measure distance. Electronic device 100 can measure distance by infrared or laser. In some embodiments, electronic device 100 can utilize distance sensor 180F to measure distance for fast focusing when taking a picture.
[0113] Proximity light sensor 180G can include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode can be an infrared light emitting diode. Electronic device 100 emits infrared light outwardly through the light emitting diode. Electronic device 100 detects infrared reflected light from nearby objects using the photodiode. When sufficient reflected light is detected, electronic device 100 can determine that there is an object near electronic device 100. When insufficient reflected light is detected, electronic device 100 can determine that there is no object near electronic device 100. Electronic device 100 can utilize proximity light sensor 180G to detect that a user is holding electronic device 100 close to the ear for a phone call, so as to automatically turn off the screen to save power. Proximity light sensor 180G can also be used for automatic unlocking and locking of the screen in a holster mode or a pocket mode.
[0114] Ambient light sensor 180L is configured to sense ambient light brightness. Electronic device 100 can adaptively adjust the brightness of display 194 according to the sensed ambient light brightness. Ambient light sensor 180L can also be used to automatically adjust white balance when taking a picture. Ambient light sensor 180L can also cooperate with proximity light sensor 180G to detect whether electronic device 100 is in a pocket to prevent accidental touch.
[0115] Fingerprint sensor 180H is configured to collect a fingerprint. Electronic device 100 can utilize the collected fingerprint characteristics to implement fingerprint unlocking, access application lock, fingerprint picture taking, fingerprint call answering, and the like.
[0116] Temperature sensor 180J is configured to detect temperature. In some embodiments, electronic device 100 utilizes the temperature detected by temperature sensor 180J to implement temperature handling strategies. For example, when the temperature reported by temperature sensor 180J exceeds a threshold, electronic device 100 implements performance reduction of a processor located near temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, electronic device 100 heats battery 142 to avoid abnormal shutdown of electronic device 100 caused by low temperature. In other embodiments, when the temperature is lower than yet another threshold, electronic device 100 implements voltage boosting of the output voltage of battery 142 to avoid abnormal shutdown caused by low temperature.
[0117] Touch sensor 180K, also called "touch panel". Touch sensor 180K can be disposed on display screen 194, and touch screen, also called "touch panel", is composed of touch sensor 180K and display screen 194. Touch sensor 180K is used to detect touch operation applied on or near it. Touch sensor 180K can transmit detected touch operation to application processor to determine touch event type. Visual output related to touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K can also be disposed on the surface of electronic device 100, which is different from the position of display screen 194.
[0118] Keys 190 include power on key, volume key, etc. Keys 190 can be mechanical keys. They can also be touch keys. Electronic device 100 can receive key input and generate key signal input related to user settings and function control of electronic device 100.
[0119] Motor 191 can generate vibration prompt. Motor 191 can be used for incoming call vibration prompt, and also can be used for touch vibration feedback. For example, touch operation applied on different applications (such as taking pictures, playing audio, etc.) can correspond to different vibration feedback effects. Touch operation applied on different regions of display screen 194 can also correspond to different vibration feedback effects of motor 191. Different application scenarios (such as time reminder, receiving information, alarm, game, etc.) can also correspond to different vibration feedback effects. Touch vibration feedback effect can also support customization.
[0120] Indicator 192 can be an indicator light, which can be used to indicate charging state, power change, and also can be used to synthesize request, missed call, notification, etc.
[0121] SIM card interface 195 is used to connect SIM card. SIM card can be inserted into or pulled out of SIM card interface 195 to realize contact and separation with electronic device 100. Electronic device 100 can support one or N SIM card interfaces, N is a positive integer greater than 1. SIM card interface 195 can support Nano SIM card, Micro SIM card, SIM card, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. SIM card interface 195 can also be compatible with different types of SIM cards. SIM card interface 195 can also be compatible with external storage cards. Electronic device 100 interacts with network through SIM card to realize functions such as call and data communication.
[0122] Please refer to the accompanying drawings Figure 7 , Figure 7 is a software structure block diagram of an electronic device provided by an embodiment of the present application.
[0123] As Figure 7 As shown, the software structure diagram can be applicable to the above-mentioned Figure 6 In the hardware architecture of the electronic device 100 as shown, the layered architecture can divide the software in the electronic device 100 into several layers, each layer having a clear role and division of labor. The layers communicate with each other through a software interface. In some other embodiments, the Android system is divided into four layers, from top to bottom, the application layer, the application framework layer (which can also be referred to as the application management layer in the embodiments of the present application), the Android runtime and the system library, and the kernel layer.
[0124] The application layer can include a series of application packages.
[0125] As shown, the application layer can include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, running health, and the like. Figure 7
[0126] The application framework layer provides the application layer with application programming interfaces (APIs) and programming frameworks for the applications in the application layer. The application framework layer includes some pre-defined functions.
[0127] In some embodiments, the application framework layer can obtain a configuration file including one or more key functions and the corresponding instrumentation information of the one or more key functions, and based on the configuration file, the application framework layer can be used to instrument the application when calling the functions.
[0128] As shown, the application framework layer can include a display manager, a sensor manager, a cross-device connection manager, an event manager, an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, and the like. Figure 7 The display manager is used for display management of the system, and is responsible for management of all display-related transactions, including creation, destruction, direction switching, size and state changes, and the like. Generally, there will be only one default display module, i.e., the main display module, on a single device.
[0129] The sensor manager is responsible for state management of the sensors, and manages applications to monitor sensor events, and reports the events to the applications in real time.
[0130] The cross-device connection manager is used to establish a communication connection with other devices.
[0131]
[0132] The event manager is used for the event management service of the system, and is responsible for receiving events uploaded by the underlying and distributing to windows, and completes the reception and distribution of events.
[0133] The task manager is used for the management of the task (Activity) component, including start management, life cycle management, task direction management, etc.
[0134] The window manager is used for managing the window program. The window manager can acquire the size of the display screen, judge whether there is a status bar, lock the screen, and intercept the screen, etc. The window manager is also used for being responsible for the window display management, including the management of the window display mode, display size, display coordinate position, display level, etc.
[0135] The specific execution process of the above various embodiments can be referred to the related content of the man-machine dialogue method in the following.
[0136] The content provider is used to store and acquire data, and makes the data accessible by the application program. The data can include video, image, audio, dialed and answered telephone, browsing history and bookmark, telephone book, etc.
[0137] The view system includes visual controls, such as a control for displaying text, a control for displaying pictures, etc. The view system can be used to build an application program. The display interface can be composed of one or more views. For example, a display interface including a short message notification icon can include a view for displaying text and a view for displaying pictures.
[0138] The resource manager provides various resources for the application program, such as localized strings, icons, pictures, layout files, video files, etc.
[0139] The notification manager makes the application program can display notification information in the status bar, and can be used to convey the message of the notification type, which can automatically disappear after a short stay without user interaction. For example, the notification manager is used to inform the completion of downloading, message reminder, etc. The notification manager can also be a notification in the form of a chart or a scroll bar text appearing in the top status bar of the system, such as the notification of the application program running in the background, and can also be a notification in the form of a dialogue window appearing on the screen. For example, prompting text information in the status bar, issuing a prompt sound, vibrating the electronic device, and flickering the indicator light, etc.
[0140] The Android runtime includes the core library and the virtual machine. The Android runtime is responsible for the scheduling and management of the Android system.
[0141] The core library includes two parts: one part is the function function required to be called by the java language, and the other part is the core library of the Android.
[0142] Both the application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0143] The system library (also known as the data management layer) can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), and event data, etc.
[0144] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0145] The media library supports playback and recording of various common audio and video formats, as well as still image files. It supports multiple audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0146] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0147] A 2D graphics engine is a graphics engine for 2D drawing.
[0148] The kernel layer is the layer between hardware and software. The kernel layer contains at least the display driver, camera driver, audio driver, and sensor driver.
[0149] In one illustrated embodiment, please refer to the appendix. Figure 8 , Figure 8 This is a software structure block diagram of another electronic device provided in an embodiment of this application.
[0150] It should be noted that, as Figure 8 The software structure shown is based on the above. Figure 7 The software structure shown is illustrated in one embodiment applicable to this application.
[0151] like Figure 8 As shown, in the embodiment of the present application, the application layer can further include a third-party application, etc., which can be obtained from various application stores; the application framework layer can further include a management module, which can include a third-party application program for process creation, and a related function module for optimizing the measurement information of the third-party application and system optimization; the system library can include a plug-in module for pre-acquiring a configuration file corresponding to the third-party application program, a compiler, and an interpreter; in addition to the display driver, the camera driver, the audio driver, and the sensor driver, the kernel layer can further include a function module for kernel part system optimization, which is used for optimizing the kernel part. The present application embodiment does not make specific limitations on each function module, and the specific description of each function module can be referred to the following related description.
[0152] Specifically, the compiler is used to convert source code written in one programming language into another computer code, which is usually in the form of binary and is called object code. The purpose of this conversion process is usually to generate an executable program, which is then executed by computer hardware. For example, the compiler can compile the entire source code of the third-party application into machine code, so that the hardware of the electronic device can directly execute the compiled machine code.
[0153] The interpreter is used to directly execute the code written in a programming language or a script language, and does not pre-compile the source code into machine code. For example, an interpreter usually executes program code in the following ways: the interpreter reads the source code of the third-party application line by line, i.e., analyzes the source code line by line (for example, the java file corresponding to the third-party application), and directly executes it; or, translates the source code into relatively more efficient intermediate code, and then executes it immediately; or, executes the code pre-compiled and saved by the compiler inside the interpreter. It can be understood that the interpreter can be regarded as a black box, and the source code is input, and the result is returned in real time.
[0154] For example, in the embodiment of the present application, the interpreter can be used to reflect the plug-in information into the message queue, and then continue to interpret and execute the target sub-function.
[0155] For another example, in the case where it is determined that the execution interface of the sub-function in the running file of the third-party application is an interpretation execution interface, and the sub-function is not a target sub-function (i.e., a key function), the running function is continuously interpreted and executed. The interpreter can interpret and execute the function corresponding to the third-party application, and interpret and execute the hook function after the plug-in processing of the function corresponding to the third-party application. The present application embodiment does not make specific limitations thereon.
[0156] The instrumented module can instrument a key function to be interpreted and executed in the third-party application based on the configuration file to obtain instrumented information corresponding to the key function, and reflect the instrumented information to a message queue of the management module, so that the management module can perform system optimization or test information processing on the third-party application based on the instrumented information.
[0157] In the embodiments of the present application, the instrumented module can be used to obtain file information of a running file corresponding to the third-party application, the running file being a file corresponding to the third-party application that is currently compiled and executed or interpreted and executed in the runtime virtual machine ART, the file information can include a file name of the running file, and the running file can include at least one sub-function; based on the file name in the running file, determine the file type of the running file, the file type can include a first file type and a second file type; in the case where the file type of the running file is the first file type, instrument and hook the target sub-function in the running file based on a first traversal process, the first traversal process being related to an execution interface corresponding to each sub-function in the running file, the target sub-function being a sub-function with a key function label; in the case where the file type of the running file is the second file type, instrument and hook the target sub-function in the running file based on a second traversal process, the second traversal process being related to compilation identification information corresponding to each sub-function in the running file.
[0158] The hook refers to intercepting an original function that is originally called in an original target application program through a hook program, modifying the entry address of the original function to the entry address of the hook function, so as to realize the function of calling the hook function before executing the call to the original function, thereby realizing the modification or expansion of the function corresponding to the target application program. During the running of the program, the operations of inserting the hook program, removing the hook program, and changing the hook program can be referred to as dynamic hooking. Dynamic hooking can be realized by using a dynamic hook mechanism, and the function of the target application program can be modified and expanded flexibly.
[0159] The third-party application to be or being executed in the Java function is inserted by the insertion module, that is, the Hook (that is, the insertion processing) of the key function is performed, the corresponding insertion information is obtained, and the positioning of the key event of the third-party application can be indicated based on the insertion information, and then the performance of the third-party application can be optimized and the user experience can be improved. For example: the insertion processing is performed when the third-party application calls the function at the running starting point and the function at the running ending point, so that the operating system of the electronic device is positioned to the running starting point and the running ending point of the third-party application, and then the loading time of the third-party application and other related measurement information can be determined based on the corresponding insertion information of the running starting point and the running ending point, or the working frequency of the processing core at the running starting point (such as: increasing) and the working frequency of the processing core at the running ending point (such as: decreasing) can also be adjusted, so that the working frequency of the processing core is relatively high in the time period between the running starting point and the running ending point of the third-party application; the working frequency of the processing core is relatively low in the remaining time period. For example, compared with the overall adjustment of the working frequency of the processing core of the third-party application during the running process, the working frequency of the processing core in the special time period (the time period between the running starting point and the running ending point) of the third-party application can be higher in the embodiment of the application, so that the loading time of the third-party application can be greatly reduced, and the temperature limitation of the electronic device when adjusting the frequency can be avoided, and the user experience is greatly improved.
[0160] The management module can be used to adjust the execution interface corresponding to the target sub-function to the first interpretation execution interface, and can also perform system optimization or measurement information processing on the third-party application corresponding to the insertion information based on the configuration file and the insertion information in the message queue.
[0161] The specific embodiments of the above modules can be referred to the related embodiments below, and the embodiments of the application will not be described here.
[0162] In addition, please refer to the accompanying Figure 9 , Figure 9 is a third-party application execution mode schematic diagram provided by the embodiment of the application, as Figure 9 shown, the Android Runtime code (that is, the source code file of the third-party application) running state of the third-party application is generally divided into three categories, which are interpretation execution (which can be understood as executing the source code of the application program through the interpreter to obtain the code execution result), AOT execution and JIT execution.
[0163] Among them, the interpretation execution means that the compiler does not intervene, and the interpreter executes a sentence of the bytecode corresponding to the third-party application every time, which translates the bytecode into machine code and executes it, realizing the running of the third-party application. The bytecode at this time can be called cold code.
[0164] AOT execution refers to pre-compiling program code of a third-party application into machine code by a compiler, and ART runtime directly executes in the manner of machine code, so as to realize running of the third-party application.
[0165] Without AOT execution, JIT execution refers to that a virtual machine compiles hot code into machine code by a compiler at runtime (ART runtime), and then executes in the manner of machine code after compilation, so as to realize running of the third-party application.
[0166] It can be understood that the AOT execution and the JIT execution can be collectively referred to as compiled execution. In the embodiments of the present application, compared with the compiler which only translates source code into machine code as a whole, the interpreter reads source code line by line, interprets, and then executes immediately.
[0167] In addition, in the embodiments of the present application, the interpreter can include an Nterp interpreter and a Switch structure-based interpreter. The Nterp interpreter is mainly to introduce a handler table for instruction mapping, and to realize fast switching between instructions by handwritten assembly. It is the main interpreter currently applied in electronic devices, is frequently used, has good performance, and can interpret most of the source code in electronic devices. The Switch structure-based interpreter has stronger compatibility. In the case where the Nterp interpreter does not support, the Switch structure-based interpreter can be used for interpretation and execution, which can improve the success rate of application program execution. Generally, the interpretation and execution are performed only in a debugging environment, method tracking, instruction does not support, or in the case of abnormal bytecode (for example, failed structured-locking verification).
[0168] To this end, in the embodiments of the present application, mainly based on the file type of the running file of the third-party application, a corresponding traversal process is adopted to achieve the purpose of inserting and processing the target sub-function, and the execution interface of the target sub-function is adjusted, which helps to shunt the functions that need to be executed by the compiler and the interpreter, ensures the efficiency of inserting and processing the target sub-function of the electronic device, and also helps to ensure the normal running of the third-party application and the user experience. Further, by obtaining the insertion information corresponding to the target sub-function, the key event points in the running process of the third-party application are located based on the insertion information, so as to realize Hook of the key function, and then the third application can be optimized based on the obtained key events of the third-party application, for example, the loading time of the third-party application is shortened.
[0169] Exemplarily, when the interpreter interprets and executes the third-party application, the target sub-function containing the key function identifier can be processed by adopting a corresponding traversal process based on the file type of the running file of the third-party application, and the execution interface of the target sub-function is adjusted to the first interpretation execution interface, and the target sub-function is continuously interpreted and executed by the first interpreter (which can be regarded as a Switch interpreter); after the insertion is completed, the insertion information can be reflected to the message queue to be processed. In addition, based on the insertion information corresponding to the key function (for example, the insertion information includes the breakpoint information, the call address information of the key function, the function name of the key function and other related information) and the related configuration file, the corresponding hook function can be called at the above-mentioned breakpoint by the Hook method, so as to realize the system optimization processing such as adjusting the processing core working frequency or the acquisition of the measurement information of the third-party application. The specific implementation manner can be correspondingly referred to the related description of the embodiments below, and the embodiments of the present application do not make a detailed description here.
[0170] Next, based on the software structure shown in the above Figure 8 , the overall flow of the method for determining the insertion process based on the file type is exemplarily introduced.
[0171] First of all, it should be pointed out that the user involved in the embodiments of the present application and the following related embodiments is the user of the electronic device, and in some other embodiments, the user can also be the associate of the electronic device, and the embodiments of the present application do not make a specific limitation.
[0172] Secondly, based on the software structure shown in the above Figure 8 , the technical problems proposed in the present application are analyzed and solved in combination with the method for determining the insertion process based on the file type provided in the present application.
[0173] Please refer to Figure 10 , Figure 10 is a flowchart of a method for determining an insertion process based on a file type provided by the embodiments of the present application.
[0174] The method for determining the insertion process based on the file type can be applied to the software architecture described in the above Figure 8 , wherein the insertion module can be used to support and execute the method flow steps S201, S202 and part of S203 shown in the above Figure 10 , and the interpreter can be used to support and execute part of the step S203 of the method flow shown in the above Figure 10 . The specific related description of each step is as follows:
[0175] Step S201: obtaining the file information of the running file corresponding to the third-party application.
[0176] The running file is an application file corresponding to a third-party application currently compiled and executed or interpreted by the runtime virtual machine ART. The file information can include a file name of the running file, and the running file can include at least one sub-function. The running file can be understood as a file to be executed or called by the ART. For example, a file in which a call entry address information of a sub-function located at the top of a stack in the running file is obtained but the sub-function has not been called can be referred to as a running file. For another example, after all sub-functions in a current file are called, a file to which a sub-function to be called next belongs can also be referred to as a running file. It should be noted that the ART can execute the running file in a manner of one of compilation and interpretation.
[0177] Optionally, the third-party application can be a third-party application downloaded by a target user from an application store or other available channels. The embodiments of the present application do not make specific limitations thereon. When the ART executes the source code of the third-party application, function information of a sub-function in a running file corresponding to the third-party application can also be obtained, and the function information of the sub-function can be sent to the patching module. In addition, when the patching module determines whether a function in a running file is a target function and sets a key function label for the target function when the third-party application is initially run, the function information also needs to be obtained. The initial running of the third-party application can be understood as the first running of the third-party application after the third-party application is downloaded to the electronic device. The initial running of the third-party application can also be understood as the following scenario: after a target user uses the third-party application and closes the background of the third-party application, the target user starts the third-party application again on the electronic device.
[0178] In a method for implementing the embodiments, the third-party application includes at least one application file, and one application file includes at least one sub-function. Before obtaining file information of a running file corresponding to the third-party application, the above method can further include the following steps: in response to the third-party application being in a running state, traversing function information of each sub-function corresponding to each application file of the third-party application, the function information including a function name corresponding to the function; based on the function information and a configuration file obtained in advance, determining whether there is a function name of a key function in the configuration file that is the same as a function name of a ninth sub-function in the third-party application; and in a case where it is determined that there is a function name of a key function in the configuration file that is the same as the function name of the ninth sub-function in the third-party application, setting a key function label for the ninth sub-function.
[0179] The function information of the function corresponding to the third-party application can include a function name of the function corresponding to the third-party application and an entry address of calling the function, and the like.
[0180] Specifically, based on the function information of the third-party application corresponding function and the pre-acquired configuration file, the plug-in module can determine whether any sub-function corresponding to the third-party application is a key function, and the configuration file can include one or more function names corresponding to one or more key functions. Wherein, the configuration file can be used to identify whether there is a key function in the sub-function corresponding to the third-party application, and the configuration file can be a related configuration file pre-acquired by the plug-in module from the management module, and the application embodiment does not make specific limitation to the acquisition method of the configuration file.
[0181] For example, the configuration file includes the following information: the function name A1 of the key function 1, and the function name A2 of the key function 2. Wherein, when determining whether the function 1 and the function 2 corresponding to the third-party application are key functions, it is learned that the function name of the function 1 is A1, and it can be confirmed that the function 1 in the third-party application is a key function and is the key function 1 in the configuration file. If the function name of the function 2 is B2, then the function 2 is not a key function.
[0182] In addition, the configuration file can correspond to one or more third-party applications, and the configuration file can include one or more function names corresponding to one or more key functions, wherein the key function can be understood as a function called when a key event occurs in the third-party application, and the plug-in module can locate the called key function for plug-in, and then locate and determine the key event about to occur in the third-party application, and obtain the corresponding plug-in information. Wherein, the key event can be pre-set, for example, the key event can include events such as application content start loading event, application content end loading event, application content jump loading event, and the like, and the application embodiment does not make specific limitation. The configuration file containing one or more function names of the key function can determine whether the target function in the function corresponding to the third-party application is a key function, so as to locate the key event of the third-party application, thereby facilitating targeted optimization of the third-party application and improving user experience. In addition, the configuration file can be pre-stored in the management module, and the application embodiment does not make specific limitation.
[0183] It can be seen that, by determining whether the target function in the function corresponding to the third-party application is a key function based on the function name when the third-party application is initially run or started, the application embodiment can greatly improve the plug-in efficiency of the key function (i.e. the target sub-function), thereby reducing the influence of plug-in processing on the running of the third-party application.
[0184] Step S202: determining the file type of the running file based on the file name in the running file.
[0185] Wherein, the file type can include a first file type and a second file type.
[0186] Exemplarily, the first file type and the second file type can both represent a file suffix of a running file. When the running file is a file optimized by speed-profile compilation, the suffix of the running file is ".art", and thus the running file can be considered as the first file type. When the running file is a file optimized by AOT compilation, the suffix of the running file is ".odex", and thus the running file can be considered as the second file type.
[0187] It should be noted that the ART can have compilation options: verify, quicken, speed, and speed-profile. The verify compilation method only performs code verification on a dex file to check the legality of each part of a function. The quicken compilation method optimizes some dex instructions on the basis of the verify compilation method to improve the performance of an interpreter. The speed compilation method performs AOT compilation on all functions on the basis of the verify compilation method. The speed-profile compilation method performs AOT compilation on functions (such as hot functions) listed in a configuration file on the basis of the verify compilation method.
[0188] Further, based on the above-mentioned compilation methods, files with suffixes.dex,.odex, and.art can be generated. The third-party application has a plurality of class files generated after all java source codes are compiled. The class files can generate one or more.dex files after being compiled by DX / D8, and the.dex file is compiled and executed by a virtual machine. The.odex file can be generated after the.dex file is verified and optimized. The.dex file under the ART contains the complete content of the AOT-compiled code and dex. After Android 8.0, the dex content in the.odex file is moved to the.vdex file. The.art file is generated by the ART according to the configuration file at the same time as the.odex file is generated. The.art file is mainly used to improve the speed of loading the hot functions in the.odex file during the runtime of the third-party application. The.art file contains class information and the index of the hot functions in the.odex file. The ART loads the already-compiled code in the.odex file according to the.art file when running the third-party application. It should be noted that only the third-party application that has performed the speed-profile compilation method can generate the.art file. Understandably, the.art file is a mirror file containing the hot functions in the.odex file.
[0189] Step S203: based on the traversal flow corresponding to the file type of the running file, the target sub-function in the running file is subjected to the Hook processing, and the first interpreter is used to continue to interpret and execute the target sub-function.
[0190] The target sub-function is a sub-function with a key function label.
[0191] In an implementation example, the first traversal flow can include traversing the types of execution interfaces corresponding to each sub-function in the running file, and the first traversal flow is a traversal flow corresponding to the first file type; and the second traversal flow can include traversing the types of compilation identification information corresponding to each sub-function in the running file, and the second traversal flow is a traversal flow corresponding to the second file type.
[0192] In an implementation example, the execution interface can include a compiled execution interface and an interpreted execution interface, and the interpreted execution interface can include a first interpreted execution interface and a second interpreted execution interface; in a case where the file type of the running file is the first file type, the running file is image file data; and the method can further include: traversing the execution interfaces of each sub-function in the running file; if the execution interface of the first sub-function is the compiled execution interface, and the first sub-function is the target sub-function, adjusting the execution interface of the first sub-function to the first interpreted execution interface, and interpreting and executing the first sub-function by using the first interpreter; and if the execution interface of the second sub-function is the second interpreted execution interface, and the second sub-function is the target sub-function, adjusting the execution interface of the second sub-function to the first interpreted execution interface, and interpreting and executing the second sub-function by using the first interpreter.
[0193] In an implementation example, the ART can include a compiler and an interpreter, and the interpreter can include a first interpreter and a second interpreter; in a case where the file type of the running file is the first file type, the method can further include: if the execution interface of the third sub-function is the compiled execution interface, and the third sub-function is not the target sub-function, executing the machine code corresponding to the third sub-function; and if the execution interface of the fourth sub-function is the second interpreted execution interface, and the fourth sub-function is not the target sub-function, interpreting and executing the fourth sub-function by using the second interpreter.
[0194] For example, Figure 11 , Figure 11 is a flow diagram of adjusting a sub-function execution interface corresponding to a first traversal flow provided by an embodiment of the present application. As shown in Figure 11 As shown, when the ART executes each sub-function in the running file, the interpretation execution method needs to be set, which can be understood as setting the execution interface of the interpretation execution. Before judging whether each sub-function is the target sub-function (i.e., the sub-function with the key function label) before executing each sub-function, it is necessary to determine whether the execution interface corresponding to the currently traversed sub-function is the interpretation execution interface. Further, in the case where the execution interface corresponding to the currently traversed sub-function is not the interpretation execution interface (which can be understood as the execution interface corresponding to the sub-function being the compilation execution interface), it is judged whether the sub-function is the target sub-function. If the execution interface corresponding to the currently traversed sub-function is the interpretation execution interface, it is necessary to judge whether the execution interface corresponding to the sub-function is the second interpretation execution interface (which can be understood as the execution interface corresponding to the Nterp interpreter). Further, in the case where the execution interface corresponding to the currently traversed sub-function is the interpretation execution interface and is the second interpretation execution interface, it is judged whether the sub-function is the target sub-function. Further, for the sub-function determined to be the target sub-function, the execution interface corresponding to the sub-function can be adjusted to the first interpretation execution interface (i.e., adjusted to the interpretation execution interface corresponding to the Switch interpreter, and the sub-function is interpreted and executed by the Switch interpreter). After adjusting the execution interface of the target sub-function, the target sub-function can be handled by the debugger to obtain the debugging information corresponding to the target sub-function. If the currently judged sub-function is not the target sub-function (i.e., the sub-function does not have the key function label), the sub-function is executed by the compiler or interpreter corresponding to the original execution interface of the sub-function. For example, if the ART currently traverses the sub-function 1 in the running file (the original execution interface is the compilation execution interface, and does not contain the key function label), it can be determined that the sub-function 1 is not the target sub-function, and the sub-function 1 can be compiled and executed by the compiler (such as the AOT compiler). If the ART currently traverses the sub-function 2 in the running file (the original execution interface is the second interpretation execution interface, and does not contain the key function label), it can be determined that the sub-function 2 is not the target sub-function, and the sub-function 2 can be interpreted and executed by the second interpreter (i.e., the Nterp interpreter). It can be understood that if the sub-function currently traversed by the ART in the running file is not the target sub-function, i.e., the sub-function is not the trigger point of the key event of the third-party application when the sub-function is called, the electronic device does not need to handle the sub-function by the debugger, and does not need to adjust the execution mode of the sub-function. By executing the sub-function by the compiler or interpreter corresponding to the original execution interface of the sub-function, it is helpful to ensure the normal operation of the third-party application.
[0195] Please refer to Table 2 below, which is a table of an executor and its corresponding execution interface provided by an embodiment of the present application.
[0196] Table 2
[0197] < / canvas> < / video> Executor Execute interface AOT compiler quick_code Nterp interpreter interpreter::ExecuteNterpImpl Switch interpreter art_quick_to_interpreter_bridge … …
[0198] As shown in Table 2, different executors correspond to different execution interfaces. After determining that the currently traversed sub-function in the running file is the target sub-function, the execution interface corresponding to the target sub-function can be adjusted to the interpretation execution interface art_quick_to_interpreter_bridge corresponding to the Switch interpreter, so as to continue to interpret and execute the target sub-function through the Switch interpreter.
[0199] It should be noted that the executors and the execution interfaces corresponding thereto shown in Table 2 are only one implementation manner shown by the embodiments of the present application, and the embodiments of the present application do not make a specific limitation thereto.
[0200] It can be understood that, referring to Figure 12 , Figure 12 is another flow diagram of adjusting the execution interface of the sub-function corresponding to the first traversal flow provided by the embodiments of the present application. As Figure 12 As shown, when the ART executes the running file corresponding to the third-party application, the plug-in module can be used to: obtain the file information of the running file corresponding to the third-party application; determine the file type of the running file based on the file name in the running file; in the case where the file type of the running file is the first file type, traverse the execution interface of each sub-function in the running file; if the execution interface of the first sub-function is a compiled execution interface, and the first sub-function is the target sub-function, the execution interface of the first sub-function is adjusted to the first interpretation execution interface, and the first interpreter continues to interpret and execute the first sub-function. Further, the plug-in module can be used to: if the execution interface of the second sub-function is the second interpretation execution interface, and the second sub-function is the target sub-function, and the execution interface of the second sub-function is adjusted to the first interpretation execution interface, and the first interpreter continues to interpret and execute the second sub-function. Further, the plug-in module can be used to: in the case where the execution interface of the third sub-function is a compiled execution interface, and the third sub-function is not the target sub-function, execute the machine code corresponding to the third sub-function. Further, the second interpreter can be used to: in the case where the execution interface of the fourth sub-function is the second interpretation execution interface, and the fourth sub-function is not the target sub-function, interpret and execute the fourth sub-function through the second interpreter. Further, the plug-in module can also be used to: plug-in Hook processing on the target sub-function in the running file, obtain the plug-in information corresponding to the target sub-function; reflect the plug-in information to the message queue, and continue to interpret and execute the target sub-function through the first interpreter. Further, the management module can be used to: obtain the plug-in information of the target sub-function from the message queue; based on the configuration file and the plug-in information, determine the hook function corresponding to the target sub-function, and execute the hook function corresponding to the running function.
[0201] It should be noted that the number of the first sub-function, the second sub-function, the third sub-function and the fourth sub-function is greater than or equal to 0, and the number of the first sub-function, the second sub-function, the third sub-function and the fourth sub-function can be the same or different, which is not limited in the present application.
[0202] It should be noted that, in order to avoid the influence on the running efficiency of the third-party application when calling the hook function based on the plug-in information, the message queue is an asynchronous message queue, that is, after the plug-in information is reflected to the message queue, it will not be processed at the first time, but in order to ensure the normal running of the third-party application, after the plug-in information is saved to the message queue, the target sub-function in the running file can be continued to be interpreted and executed by the first interpreter (i.e. Switch interpreter), the plug-in information can be processed asynchronously, which greatly weakens the influence of plug-in processing on the third-party application, and ensures the performance efficiency and user experience of the running of the third-party application.
[0203] It should be further explained that the reflection of the target sub-function corresponding to the plug-in information to the message queue refers to the decompilation of the target sub-function corresponding to the plug-in information and saving it to the message queue, and the embodiments of the present application do not make specific limitations.
[0204] In a method of implementing, in the case that the file type of the running file is the second file type, the method can further include: obtaining the compiled identification information corresponding to each sub-function in the running file; if the compiled identification information of the fifth sub-function is empty and the fifth sub-function is not the target sub-function, adjusting the execution interface of the fifth sub-function to the second interpretation execution interface, and executing the fifth sub-function through the second interpreter; if the compiled identification information of the sixth sub-function is empty and the sixth sub-function is the target sub-function, adjusting the execution interface of the sixth sub-function to the first interpretation execution interface, and executing the sixth sub-function through the first interpreter; in the case that the compiled identification information of the seventh sub-function is non-empty and the seventh sub-function is the target sub-function, adjusting the execution interface of the seventh sub-function to the first interpretation execution interface; if the compiled identification information of the eighth sub-function is non-empty and the eighth sub-function is not the target sub-function, executing the machine code corresponding to the eighth sub-function.
[0205] Exemplarily, please refer to Figure 13 , Figure 13 is a flowchart of adjusting the execution interface of the sub-function corresponding to the second traversal process provided by the embodiments of the present application. As Figure 13 As shown, when the ART executes each sub-function in the running file, it is necessary to determine whether the compilation identification information corresponding to each sub-function is empty. If the compilation identification information of the fifth sub-function is empty, it indicates that the fifth sub-function has not been compiled by the compiler (such as the AOT compiler), and it is further necessary to determine whether the fifth sub-function is the target sub-function. If the fifth sub-function is not the target sub-function, the execution interface of the fifth sub-function can be set as the second interpretation execution interface (i.e., the execution interface corresponding to the Nterp interpreter, which can be interpreted and executed by the Nterp interpreter in the future). If the compilation identification information of the sixth sub-function is empty, it indicates that the sixth sub-function has not been compiled and optimized by the compiler (such as the AOT compiler). Further, if the sixth sub-function is the target sub-function, the execution interface of the sixth sub-function can be set as the first interpretation execution interface (i.e., the execution interface corresponding to the Switch interpreter, which can be interpreted and executed by the Switch interpreter in the future). If the compilation identification information of the seventh sub-function is not empty, it indicates that the seventh sub-function has been compiled and optimized by the compiler (such as the AOT compiler). Further, if the seventh sub-function is the target sub-function, the execution interface of the seventh sub-function can be set as the first interpretation execution interface (i.e., the execution interface corresponding to the Switch interpreter, which can be interpreted and executed by the Switch interpreter in the future). If the compilation identification information of the eighth sub-function is not empty, it indicates that the eighth sub-function has been compiled and optimized by the compiler (such as the AOT compiler). Further, if the eighth sub-function is not the target sub-function, the machine code corresponding to the eighth sub-function can be directly executed.
[0206] It can be understood that, referring to Figure 14 , Figure 14 is another flow diagram of adjusting the execution interface of a sub-function corresponding to the second traversal process provided by the embodiments of the present application. As shown in Figure 14 As shown, when the ART executes the running file corresponding to the third-party application, the instrumentation module can be configured to: obtain file information of the running file corresponding to the third-party application; determine the file type of the running file based on the file name in the running file; and obtain the compilation identification information corresponding to each sub-function in the running file in the case where the file type of the running file is the second file type. Further, the above-mentioned instrumentation module can also be configured to: in the case where the compilation identification information of the fifth sub-function is empty and the fifth sub-function is not the target sub-function, adjust the execution interface of the fifth sub-function to the second interpreted execution interface; in the case where the compilation identification information of the sixth sub-function is empty and the sixth sub-function is the target sub-function, adjust the execution interface of the sixth sub-function to the first interpreted execution interface; in the case where the compilation identification information of the seventh sub-function is non-empty and the seventh sub-function is the target sub-function, adjust the execution interface of the seventh sub-function to the first interpreted execution interface; and in the case where the compilation identification information of the eighth sub-function is non-empty and the eighth sub-function is not the target sub-function, execute the machine code corresponding to the eighth sub-function. Still further, the above-mentioned second interpreter can also be configured to interpret and execute the above-mentioned fifth sub-function. Still further, the above-mentioned first interpreter can also be configured to interpret and execute the above-mentioned sixth sub-function and / or the above-mentioned seventh sub-function. Still further, the instrumentation module can also be configured to: instrument and hook the target sub-function in the running file, obtain the instrumentation information corresponding to the target sub-function; reflect the instrumentation information to the message queue, and continue to interpret and execute the target sub-function through the first interpreter. Still further, the management module can be configured to: obtain the instrumentation information from the message queue; and execute the hook function corresponding to the running function based on the configuration file and the instrumentation information.
[0207] It should be noted that the number of the above-mentioned fifth sub-function, sixth sub-function, seventh sub-function and eighth sub-function is greater than or equal to 0, and the number of the fifth sub-function, sixth sub-function, seventh sub-function and eighth sub-function can be the same or different, which is not limited in the present application.
[0208] In one method of implementation, the interpreter can include an Nterp interpreter and a Switch interpreter, the first interpreter is the Switch interpreter, the second interpreter is the Nterp interpreter, the first interpreted execution interface is the interpreted execution interface corresponding to the Switch interpreter, and the second interpreted execution interface is the interpreted execution interface corresponding to the Nterp interpreter.
[0209] The interpreter includes an Nterp interpreter and a Switch interpreter. Since the proportion of functions executed by AOT after installation of most third-party applications is small, the remaining majority of code is still executed by interpretation, and therefore, the plugging processing is directly performed in the Nterp interpreter, which has a large impact. In order to reduce the above impact, the plugging Hook method can be degraded to the Switch interpretation method.
[0210] In a method for implementing, after the target sub-function in the running file is plugged and Hooked, the method can further include: obtaining the plugging information corresponding to the target sub-function; reflecting the plugging information to the message queue, and continuing to interpret and execute the target sub-function by the first interpreter.
[0211] Specifically, in the case where it is determined that the running function is a critical function, the plugging module can plug and Hook the target sub-function, and obtain the plugging information corresponding to the target sub-function. The plugging information can be used to indicate that the target position of the target sub-function is plugged with the corresponding Hook function, and the plugging information can include one or more of the following: the plugging point or plugging position of the target sub-function, the call address information of the target sub-function, the call address information of the Hook function corresponding to the target sub-function, the function name of the target sub-function, and other related plugging information. By plugging and Hooking the target sub-function, one or more plugging information of the third-party application in the application program or application content loading process can be determined, and the application program or application content loading of the third-party application can be optimized or measurement information obtained through the one or more plugging information. In addition, the Hook function can be understood as a function that is different from the third-party application and is interpreted and executed by the first interpreter after the target sub-function is plugged.
[0212] It should be noted that, in order to avoid the impact on the running efficiency of the third-party application when the Hook function is called based on the plugging information, the message queue is an asynchronous message queue, that is, after the plugging information is reflected to the message queue, it is not processed at the first time, but in order to ensure the normal running of the third-party application, after the plugging information is saved to the message queue, the target sub-function in the running file can be continued to be interpreted and executed by the first interpreter (i.e., the Switch interpreter), the plugging information can be processed asynchronously, which greatly reduces the impact of the plugging processing on the third-party application, and ensures the performance efficiency and user experience of the running of the third-party application.
[0213] It should be further noted that the reflection of the plugging information corresponding to the target sub-function to the message queue means that the plugging information corresponding to the target sub-function is decompiled and saved to the message queue, and the embodiments of the present application do not make specific limitations thereon.
[0214] In a method of illustrating implementation, the management module can obtain the hooking information corresponding to the target sub-function from the message queue.
[0215] Specifically, the management module can obtain the hooking information corresponding to the target sub-function from the message queue at any time. Based on the hooking information and the configuration file, the corresponding third-party application is processed. As described above Figure 12 and / or Figure 13 As shown, the management module can obtain the hooking information corresponding to the target sub-function from the message queue.
[0216] In a method of illustrating implementation, the management module can execute the hooking function corresponding to the target sub-function based on the configuration file and the hooking information corresponding to the target sub-function.
[0217] Specifically, the hooking function corresponding to the target sub-function is executed based on the configuration file and the hooking information corresponding to the target sub-function. In addition, the configuration file further includes one or more hooking functions corresponding to the key function, and each key function can correspond to one or more hooking functions. For example, the key function called at the starting point of the third-party application can correspond to a hooking function for adjusting the working frequency of the core, and can also correspond to a hooking function for recording the current time point. The hooking function can be used to optimize the third-party application or obtain measurement information, so as to improve the user experience. Therefore, the number and type of hooking functions corresponding to each key function are not specifically limited in the embodiments of the present application.
[0218] In addition, in other embodiments, the configuration file can further include function information of each hooking function, and the function information of each hooking function can include function name, function call address and other related information of the corresponding hooking function, which is not specifically limited in the embodiments of the present application. As described above Figure 12 and / or Figure 13 As shown, the management module can also determine the hooking function corresponding to the target sub-function based on the configuration file and the hooking information corresponding to the target sub-function, so that the first interpreter (i.e. Switch interpreter) can interpret and execute the hooking function corresponding to the target sub-function, so as to optimize the third-party application or obtain measurement information.
[0219] In other embodiments, the hooking function can also be executed or called by other execution modes, for example, by a compiler, as described above Figure 9 AOT execution and JIT execution; or by a related processing unit in the management module, which is not described in detail in the embodiments of the present application.
[0220] For example, please refer to the attached Figure 15 , Figure 15 This is a schematic diagram illustrating how instrumentation can be used to optimize the performance of a third-party application, as provided in an embodiment of this application.
[0221] like Figure 15 As shown, when a third-party application runs after a user operation, the starting point can be considered the starting stub, and the ending point can be considered the ending stub. When the third-party application calls a sub-function in the running file at the starting point and at the ending point, these can be identified as key function 1 and key function 2, respectively. Further instrumentation is then performed on key functions 1 and 2 to obtain their respective instrumentation information, which is then placed in the message queue. Simultaneously, the electronic device can normally call the running file to load normal application content. Based on the configuration file, hook function 1 (which increases the processing core's operating frequency) and hook function 2 (which decreases the processing core's operating frequency) can be determined for key function 1. Correspondingly, the electronic device can also determine the corresponding hook functions based on the instrumentation information for key functions 1 and 2 in the message queue. The electronic device can call hook function 1 at the starting point and hook function 2 at the ending point, specifically increasing the operating frequency of the four processing cores (e.g., at the starting point, the end point, and the end point, respectively). Figure 13 The four processing cores (processing core 1, processing core 2, processing core 3, and processing core 4) are shown to operate at higher frequencies, and their operating frequencies are lowered at the end of the execution process. This results in a higher operating frequency for the four processing cores during the time period between the start and end of the third-party application's execution, and a lower operating frequency during the remaining time periods. Therefore, compared to generally increasing the operating frequency of the processing cores during the third-party application's execution, the operating frequency of the processing cores in this embodiment can be higher, thereby significantly reducing the loading time of the third-party application while adhering to the temperature limitations of electronic devices, greatly improving the user experience.
[0222] In the embodiments of the present application, when the ART executes the running file of the third-party application, different traversal processes can be determined based on the file type of the running file, and then the target sub-function is plugged and the execution interface of the target sub-function is adjusted based on the different traversal processes, which helps to ensure that the key functions existing in the third-party application are comprehensively screened out, and the target sub-function (or key function) is interpreted and executed based on a separate interpreter (i.e., the first interpreter), which helps to ensure the normal operation of the third-party application, reduces the influence of the plugging processing on the running of the third-party application, and protects the user's use experience. Among them, the target sub-function in the third-party application is plugged based on the first interpreter to obtain corresponding plugging information, which can realize the positioning of the key event point in the running process of the third-party application, and then the third application can be optimized based on the obtained key events of the third-party application, avoiding optimizing the entire third-party application, improving the accuracy of optimization, and increasing the user experience. Moreover, the message queue storing the plugging information is an asynchronous message queue, that is, after the plugging information is reflected to the message queue, it will not be processed at the first time, but in order to ensure the normal operation of the third-party application, after the plugging information is saved to the message queue, the running function can be continuously interpreted and executed by the interpreter, and the plugging information can be processed asynchronously, which greatly weakens the influence of the plugging processing on the third-party application, and ensures the running efficiency and user experience of the third-party application.
[0223] The embodiments of the present application also provide an electronic device, which comprises one or more processors and one or more memories; wherein the one or more memories are coupled with the one or more processors, and the one or more memories are used to store computer program codes, the computer program codes comprising computer instructions, when the one or more processors execute the computer instructions, causing the electronic device to perform the method described in the above embodiments.
[0224] The embodiments of the present application also provide a computer program product comprising instructions, when the computer program product is run on an electronic device, causing the electronic device to perform the method described in the above embodiments.
[0225] The embodiments of the present application also provide a computer readable storage medium comprising instructions, when the instructions are run on an electronic device, causing the electronic device to perform the method described in the above embodiments.
[0226] It can be understood that the embodiments of the present application can be combined arbitrarily to achieve different technical effects.
[0227] In the above embodiments, all or part of the processes can be implemented by software, hardware, firmware, or any combination thereof. When implemented by software, all or part of the processes can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes described in the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that includes one or more available media sets. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk), etc.
[0228] Those of ordinary skill in the art can understand that all or part of the processes in the above embodiments can be implemented by a computer program to instruct the relevant hardware, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The storage medium includes ROM or random access memory (RAM), magnetic disk or optical disk, and various media that can store program codes.
[0229] In summary, the above only describes the embodiments of the technical solutions of the present application, and is not used to limit the protection scope of the present application. Any modifications, equivalent replacements, improvements, etc. made according to the disclosure of the present application shall be included in the protection scope of the present application.< / videoview> < / imgview> < / textview>
Claims
1. A method for determining instrumentation procedures based on file type, characterized in that, The method comprises: obtaining file information of a running file corresponding to a third-party application, the running file being an application file corresponding to the third-party application that is currently compiled and executed or interpreted in an ART (Android Runtime), and the file information comprising a file name of the running file, the running file comprising at least one sub-function; determining a file type of the running file based on the file name in the running file, the file type comprising a first file type and a second file type; based on a traversal process corresponding to the file type of the running file, performing a Hook process on a target sub-function in the running file, and continuing to interpret and execute the target sub-function through a first interpreter, the target sub-function being a sub-function having a key function label, and the traversal process comprising a first traversal process, the first traversal process comprising traversing types of execution interfaces corresponding to each sub-function in the running file, the first traversal process being a traversal process corresponding to the first file type, and the execution interface comprising a compiled execution interface; in a case where the file type of the running file is the first file type, the method further comprises: if an execution interface of a third sub-function is the compiled execution interface and the third sub-function is not a target sub-function, executing machine code corresponding to the third sub-function.
2. The method of claim 1, wherein, The traversal process further comprises a second traversal process, the second traversal process comprising traversing types of compilation identification information corresponding to each sub-function in the running file, the second traversal process being a traversal process corresponding to the second file type.
3. The method of claim 2, wherein, The execution interface further comprises an interpreted execution interface, the interpreted execution interface comprising a first interpreted execution interface and a second interpreted execution interface; in a case where the file type of the running file is the first file type, the running file is mirror file data; the method further comprises: traversing execution interfaces of each sub-function in the running file; if an execution interface of a first sub-function is the compiled execution interface and the first sub-function is a target sub-function, adjusting the execution interface of the first sub-function to the first interpreted execution interface, and interpreting and executing the first sub-function through the first interpreter; if an execution interface of a second sub-function is the second interpreted execution interface and the second sub-function is a target sub-function, adjusting the execution interface of the second sub-function to the first interpreted execution interface, and interpreting and executing the second sub-function through the first interpreter.
4. The method of claim 3, wherein, The ART comprises a compiler and an interpreter, the interpreter comprising the first interpreter and a second interpreter; in a case where the file type of the running file is the first file type, the method further comprises: if an execution interface of a fourth sub-function is the second interpreted execution interface and the fourth sub-function is not a target sub-function, interpreting and executing the fourth sub-function through the second interpreter.
5. The method according to claim 3 or 4, characterized in that, in a case where the file type of the running file is the second file type, the method further comprises: obtaining compilation identification information corresponding to each sub-function in the running file; If the compiling identification information of the fifth sub-function is empty and the fifth sub-function is not the target sub-function, the execution interface of the fifth sub-function is adjusted to the second interpretation execution interface, and the fifth sub-function is interpreted and executed by the second interpreter; If the compiling identification information of the sixth sub-function is empty and the sixth sub-function is the target sub-function, the execution interface of the sixth sub-function is adjusted to the first interpretation execution interface, and the sixth sub-function is interpreted and executed by the first interpreter; If the compiling identification information of the seventh sub-function is not empty and the seventh sub-function is the target sub-function, the execution interface of the seventh sub-function is adjusted to the first interpretation execution interface, and the seventh sub-function is interpreted and executed by the first interpreter; If the compiling identification information of the eighth sub-function is not empty and the eighth sub-function is not the target sub-function, the machine code corresponding to the eighth sub-function is executed.
6. The method according to any one of claims 1 to 5, characterized in that, After the target sub-function in the running file is processed by the method of hooking, the method further comprises: Obtaining the hooking information corresponding to the target sub-function; Reflecting the hooking information into the message queue, and continuing to interpret and execute the target sub-function by the first interpreter.
7. The method according to any one of claims 1 to 6, characterized in that, The third-party application comprises at least one application file, and one application file comprises at least one sub-function; before obtaining the file information of the running file corresponding to the third-party application, the method further comprises: In response to the third-party application being in a running state, traversing the function information of each sub-function corresponding to each application file of the third-party application, the function information comprising the function name corresponding to the function; Based on the function information and the pre-obtained configuration file, it is determined whether there is a function name of a key function in the configuration file that is the same as the function name of the ninth sub-function in the third-party application, the configuration file comprising one or more function names corresponding to the key function respectively; In a case where it is determined that there is a function name of a key function in the configuration file that is the same as the function name of the ninth sub-function in the third-party application, the ninth sub-function is set with the key function label.
8. A system for determining a instrumentation flow based on a compiled optimization function, the system comprising: The system comprises a hooking module and a first interpreter; The hooking module is configured to: Obtain the file information of the running file corresponding to the third-party application, the running file being the application file corresponding to the third-party application that is currently compiled and executed or interpreted and executed in the runtime virtual machine ART, the file information comprising the file name of the running file, and the running file comprising at least one sub-function; Based on the file name in the running file, determine the file type of the running file, the file type comprising a first file type and a second file type; The target sub-function in the running file is subjected to the Hook processing based on a corresponding traversal process of a file type of the running file, the target sub-function is a sub-function with a key function label, and the traversal process includes a first traversal process, the first traversal process includes traversing a type of an execution interface corresponding to each sub-function in the running file, the first traversal process is a traversal process corresponding to the first file type, and the execution interface includes a compilation execution interface and an interpretation execution interface. The first interpreter is configured to continue to interpret and execute the target sub-function after the Hook processing of the target sub-function in the running file by the Hook processing module. The Hook processing module is further configured to execute machine code corresponding to a third sub-function in a case where an execution interface of the third sub-function is the compilation execution interface and the third sub-function is not the target sub-function.
9. An electronic device, comprising: The electronic device includes one or more processors and one or more memories; wherein the one or more memories are coupled with the one or more processors, the one or more memories are configured to store computer program codes, the computer program codes include computer instructions, and when the one or more processors execute the computer instructions, the electronic device is caused to perform the method in any one of claims 1-7.
10. A computer-readable storage medium comprising instructions, characterized in that, When the instructions run on the electronic device, the electronic device is caused to perform the method in any one of claims 1-7.
Citation Information
Patent Citations
Instrumentation method and system based on interpreter and related electronic equipment
CN116467221A