Function updating method and device, and storage medium
By performing static analysis and functional testing before feature updates, we ensure that the app has received and covered the functional code, thus resolving the issue of feature update failures and improving the development efficiency of the app.
Patent Information
- Application Number
- CN202210344373.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2042-03-31
AI Technical Summary
In existing feature update methods, the app on the online device may fail to receive the features sent by the backend server or the feature code may not be overwritten, resulting in feature update failure and affecting the development and construction of the app's capabilities.
Before updating a feature, static analysis and feature detection are performed by obtaining the feature identifier of the feature to be updated to determine whether the code location of the feature to be updated exists in the App. After the App is running, it is determined whether the feature code has been overwritten, and the update is decided based on the matching results.
It reduced online issues caused by feature updates and improved the efficiency of app development and construction.
Smart Images

Figure CN116932019B_ABST
Abstract
Description
Technical Field
[0001] This application relates to computer software technology, and more particularly to a function update method, apparatus and storage medium. Background Technology
[0002] With the rapid development of the internet and the continuous improvement of people's living standards, more and more terminal device applications (Apps) are being developed to meet people's growing needs. The development and construction of many capabilities within Apps require controlling the target audience and gradually expanding the business. One reason is to test users' acceptance of new products and capabilities; another is to quickly control the impact of problems and prevent them from escalating into major issues.
[0003] Therefore, when the app is running, the backend server needs to distribute certain functions (such as some function switches, some parameters required by functions) to the corresponding batch or all online devices of the app to update the app functions.
[0004] However, there are some potential risks in updating existing features. For example, after the backend server distributes certain features to the App on a designated online device, the App on the online device may not successfully receive the distributed features, or the code for the corresponding features may not be overwritten when the App on the online device is running, which may cause the feature update to fail and cause problems in the development and construction of the capabilities of the App on the online device. Summary of the Invention
[0005] To address the problems existing in the prior art, this application provides a function update method, apparatus, and storage medium.
[0006] In a first aspect, embodiments of this application provide a function update method, including:
[0007] Get the feature identifier of the feature to be updated;
[0008] Before the App corresponding to the function to be updated runs, determine whether the code location of the function to be updated is obtained in the App based on the function identifier of the function to be updated;
[0009] If the code location of the function to be updated is obtained in the App, then after the App runs, the identifier of the function running in the App and its code location are obtained;
[0010] Based on the function identifier of the function to be updated, the code location of the function to be updated, and the identifier and code location of the function running in the App, a function matching is performed, and based on the function matching result, it is determined whether to update the function to be updated.
[0011] In one possible implementation, determining whether the code location of the function to be updated is obtained in the App based on the function identifier of the function to be updated includes:
[0012] Obtain the installation package corresponding to the App, and determine the mapping relationship between the strings in the installation package and the code positions where the strings are located based on the installation package, wherein the strings include the strings corresponding to the function identifiers of each function in the installation package;
[0013] Based on the mapping relationship and the function identifier of the function to be updated, determine whether the code location of the function to be updated is obtained in the App.
[0014] In one possible implementation, determining the mapping relationship between strings in the installation package and the code locations of those strings, based on the installation package, includes:
[0015] The loading instructions in the installation package are parsed to obtain the virtual addresses of all segments and all sections in the installation package;
[0016] Based on the virtual addresses of all segments and sections in the installation package, and the preset string size, determine the mapping relationship between the strings in the installation package and the code locations where the strings are located.
[0017] In one possible implementation, determining whether the code location of the function to be updated is obtained in the App based on the mapping relationship and the function identifier of the function to be updated includes:
[0018] Based on the installation package, obtain the string representing the target address in the mapping relationship from the code segment instructions of the installation package;
[0019] In the target address, find the string corresponding to the function identifier of the function to be updated in the string in the mapping relationship;
[0020] If the string corresponding to the function identifier of the function to be updated is found in the string of the mapping relationship at the target address, then the code location of the function to be updated in the App is determined.
[0021] In one possible implementation, obtaining the identifier and code location of the function running in the App after the App runs includes:
[0022] The App is configured with function detection logic, which is used to obtain the identifier of the corresponding function and its code location when the corresponding function is triggered.
[0023] After the App runs, based on the function detection logic, the identifier of the function running in the App and its code location are obtained.
[0024] In one possible implementation, the function detection logic is further configured to obtain the function value of the corresponding function when the corresponding function is triggered;
[0025] After obtaining the identifier and code location of the function running in the App, the process further includes:
[0026] Based on the aforementioned function detection logic, the function values of the functions running in the App are obtained;
[0027] The status of the functions running in the App is determined based on the function values of the functions running in the App.
[0028] The running status of the function to be updated is determined based on the function identifier of the function to be updated, as well as the identifier and status of the functions running in the App.
[0029] In one possible implementation, the function matching based on the function identifier of the function to be updated, the code location of the function to be updated, and the identifier and code location of the function running in the App includes:
[0030] Among the identifiers of the functions running in the App, identify the target identifier that is the same as the function identifier of the function to be updated;
[0031] Based on the target identifier, the code location of the target function is obtained from the code location of the function running in the App;
[0032] Function matching is performed based on the code location of the function to be updated and the code location of the target function.
[0033] In one possible implementation, determining whether to update the function to be updated based on the function matching result includes:
[0034] If the function matching result meets the preset function conditions, then it is determined to update the function to be updated, wherein the preset function conditions include that the matching offset value between the code position of the function to be updated and the code position of the target function is less than a preset threshold.
[0035] Secondly, embodiments of this application provide a function update device, including:
[0036] The function acquisition module is used to acquire the function identifier of the function to be updated.
[0037] The static analysis module is used to determine, based on the function identifier of the function to be updated, whether the code location of the function to be updated is obtained in the App before the App corresponding to the function to be updated runs.
[0038] The analysis module is used to obtain the identifier and code location of the function to be updated in the App after the App is run if the code location of the function to be updated is found in the App.
[0039] The feature update module is used to perform feature matching based on the feature identifier of the feature to be updated, the code location of the feature to be updated, and the identifier and code location of the features running in the App, and determine whether to update the feature to be updated based on the feature matching result.
[0040] In one possible implementation, the static analysis module is specifically used for:
[0041] Obtain the installation package corresponding to the App, and determine the mapping relationship between the strings in the installation package and the code positions where the strings are located based on the installation package, wherein the strings include the strings corresponding to the function identifiers of each function in the installation package;
[0042] Based on the mapping relationship and the function identifier of the function to be updated, determine whether the code location of the function to be updated is obtained in the App.
[0043] In one possible implementation, the static analysis module is specifically used for:
[0044] The loading instructions in the installation package are parsed to obtain the virtual addresses of all segments and all sections in the installation package;
[0045] Based on the virtual addresses of all segments and sections in the installation package, and the preset string size, determine the mapping relationship between the strings in the installation package and the code locations where the strings are located.
[0046] In one possible implementation, the static analysis module is specifically used for:
[0047] Based on the installation package, obtain the string representing the target address in the mapping relationship from the code segment instructions of the installation package;
[0048] In the target address, find the string corresponding to the function identifier of the function to be updated in the string in the mapping relationship;
[0049] If the string corresponding to the function identifier of the function to be updated is found in the string of the mapping relationship at the target address, then the code location of the function to be updated in the App is determined.
[0050] In one possible implementation, the runtime analysis module is specifically used for:
[0051] The App is configured with function detection logic, which is used to obtain the identifier of the corresponding function and its code location when the corresponding function is triggered.
[0052] After the App runs, based on the function detection logic, the identifier of the function running in the App and its code location are obtained.
[0053] In one possible implementation, the function detection logic is further configured to obtain the function value of the corresponding function when the corresponding function is triggered;
[0054] The operation analysis module is also used for:
[0055] Based on the aforementioned function detection logic, the function values of the functions running in the App are obtained;
[0056] The status of the functions running in the App is determined based on the function values of the functions running in the App.
[0057] The running status of the function to be updated is determined based on the function identifier of the function to be updated, as well as the identifier and status of the functions running in the App.
[0058] In one possible implementation, the function update module is specifically used for:
[0059] Among the identifiers of the functions running in the App, identify the target identifier that is the same as the function identifier of the function to be updated;
[0060] Based on the target identifier, the code location of the target function is obtained from the code location of the function running in the App;
[0061] Function matching is performed based on the code location of the function to be updated and the code location of the target function.
[0062] In one possible implementation, the function update module is specifically used for:
[0063] If the function matching result meets the preset function conditions, then it is determined to update the function to be updated, wherein the preset function conditions include that the matching offset value between the code position of the function to be updated and the code position of the target function is less than a preset threshold.
[0064] Thirdly, embodiments of this application provide a terminal device, including:
[0065] processor;
[0066] Memory; and
[0067] Computer programs;
[0068] The computer program is stored in the memory and is configured to be executed by the processor, the computer program including instructions for performing the method as described in the first aspect.
[0069] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that causes a server to perform the method described in the first aspect.
[0070] Fifthly, embodiments of this application provide a computer program product, including computer instructions, which are executed by a processor according to the method described in the first aspect.
[0071] The function update method, apparatus, and storage medium provided in this application embodiment determine whether the code location of the function to be updated is obtained in the App based on the function identifier of the function to be updated. If it is obtained, it means that the App has the function to be updated (e.g., the function issued by the backend server has been successfully obtained). Then, after the App runs, the identifier and code location of the function running in the App are further obtained. Based on the function identifier and code location of the function to be updated, and the identifier and code location of the function running in the App, function matching is performed. That is, after the App runs, it is determined whether the code of the corresponding function has been overwritten, thereby determining whether to update the function to be updated. In other words, this application embodiment performs function detection before updating the function to the online device, reducing online problems caused by function update and accelerating the development and construction of the capabilities of the App application on the online device. Attached Figure Description
[0072] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0073] Figure 1 This is a schematic diagram of the functional update system architecture provided in the embodiments of this application;
[0074] Figure 2 A flowchart illustrating a function update method provided in an embodiment of this application;
[0075] Figure 3 This is a schematic diagram illustrating the acquisition of relevant data after an App runs, provided in an embodiment of this application.
[0076] Figure 4 A flowchart illustrating another function update method provided in an embodiment of this application;
[0077] Figure 5 A schematic diagram of static analysis before an App runs, provided as an embodiment of this application;
[0078] Figure 6 This is a schematic diagram of the structure of a function update device provided in an embodiment of this application;
[0079] Figure 7 This is a schematic diagram of the basic hardware architecture of a terminal device provided in an embodiment of this application. Detailed Implementation
[0080] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0081] The terms “first,” “second,” “third,” and “fourth,” etc. (if present), in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0082] In recent years, due to the rapid development of internet businesses, the development and construction of many capabilities in app applications have required controlling the target audience as businesses gradually expand. Therefore, various feature update platforms have been established to handle the ever-increasing demand for feature updates.
[0083] Feature updates primarily address scenarios where the backend server needs to distribute certain features (such as feature switches or required parameters) to a batch or all online devices' apps, which are then processed by specific code logic. For example, business A pre-defines entry points and code logic for some activity features in its app code. As the app is updated and iterated, this code logic gradually extends to the online user base. However, since these features are disabled by default, the backend server needs to distribute feature switches during the activity period to enable these features in the app.
[0084] However, the above-mentioned feature updates have some potential risks. For example, after the backend server distributes certain features to the App on a designated online device, the App on the online device may not successfully receive the distributed features, or the code for the corresponding features may not be overwritten when the App on the online device is running, which may cause the feature update to fail and cause problems in the development and construction of the capabilities of the App on the online device.
[0085] Therefore, this application proposes a function update method, which performs function detection before updating functions to online devices. For example, it verifies whether the corresponding App has received the new function on one or more devices, and determines whether the code of the corresponding function has been overwritten after the App runs. This determines whether to update the above function, reduces online problems caused by function updates, and accelerates the development and construction of the capabilities of App applications on online devices.
[0086] Optionally, the function update method provided in this application embodiment can be applied to, for example, Figure 1 The shown function update system. In Figure 1 In this system architecture, the function update can include a server 101 and a terminal device 102. The terminal device is an offline terminal device. Multiple apps can be installed on the terminal device to provide different services to users, and the terminal device and the server can communicate via a network. This network can include various connection types, such as wired or wireless communication links or fiber optic cables, etc.
[0087] In the specific implementation process, if the code of an App on the online device pre-defines the entry point and code logic for some activity functions, the server 101 needs to issue a function switch to enable the activity function in the App. Before sending the function switch to the online device, the server 101 can first detect the function enabled by the function switch. For example, the server 101 can issue the function enabled by the function switch to the terminal device 102. Before the terminal device 102 runs the App after the function is issued to it, it verifies whether the App has received the function. If received, the terminal device 102 can further determine whether the code for the function has been overwritten after the App runs, and then determine whether to update the function (e.g., after the App runs, it determines whether the code for the function has been overwritten and decides to update the function).
[0088] Based on the detection results, such as the update result of the above function determined by the terminal device 102, the server 101 determines whether to send the above function switch to the online device. If the terminal device 102 determines to update the above function, the server 101 sends the above function switch to the online device. The online device successfully opens the function in the corresponding App according to the above function switch sent by the server 101, thereby reducing online problems caused by function update and accelerating the development and construction of the App application capabilities of the online device.
[0089] It should be noted that the system architecture and business scenarios described in the embodiments of this application are for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and do not constitute a limitation on the technical solutions provided in the embodiments of this application. As those skilled in the art will know, with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0090] The technical solutions of this application are described below using several embodiments as examples. The same or similar concepts or processes may not be repeated in some embodiments.
[0091] Figure 2 This is a flowchart illustrating a function update method provided in an embodiment of this application. The execution entity of this embodiment can be... Figure 1The specific execution entity of the terminal device in the application can be determined according to the actual application scenario, and this application embodiment does not impose any special restrictions on this. Figure 2 As shown, the function update method provided in this application embodiment may include the following steps:
[0092] S201: Obtain the function identifier of the function to be updated.
[0093] The aforementioned functions to be updated can be determined based on the actual situation, for example... Figure 1 The function switch in the embodiment enables the function. The function identifier may include the function name, number, and other information that identifies the function to be updated.
[0094] Here, the backend server can send the identifier of the function that needs to be updated to the terminal device, and then the terminal device can determine the function identifier of the function to be updated based on the identifier of the function that needs to be updated by the server.
[0095] Furthermore, the aforementioned functions to be updated can be built-in, static, or dynamic functions within the corresponding apps of the aforementioned terminal devices, and the specifics can be determined based on the actual situation. For example, Figure 1 For example, if an app on a mid-line device has pre-defined entry points and code logic for some activity functions, and the server needs to issue a function switch to enable the activity function in the app, the above-mentioned function to be updated is the activity function enabled by the above-mentioned function switch, and the above-mentioned function to be updated is the dynamic function in the app corresponding to the above-mentioned terminal device.
[0096] S202: Before the App corresponding to the above-mentioned function to be updated runs, determine whether the code location of the above-mentioned function to be updated is obtained in the above-mentioned App based on the function identifier of the above-mentioned function to be updated.
[0097] Here, static analysis is performed on the aforementioned terminal device. That is, before the App corresponding to the function to be updated runs, the installation package corresponding to the App is obtained, the installation package is analyzed, and the code location of the function to be updated is found.
[0098] In the static analysis phase, the terminal device can obtain the code location of a specific string through the installation package corresponding to the App. Then, the function identifier of the function to be updated is input into the static analysis as a specific string to determine whether the code location of the function to be updated can be obtained.
[0099] S203: If the code location of the function to be updated is obtained in the above App, then after the above App is run, the identifier of the function running in the above App and its code location are obtained.
[0100] In this embodiment of the application, if static analysis reveals the code location of the function to be updated within the aforementioned App, it indicates that the App contains the function to be updated. For example, using... Figure 1 Taking the server sending the aforementioned function switch to the terminal device as an example, if static analysis reveals the code location of the function switch in the corresponding app on the terminal device, it indicates that the terminal device has successfully received the function sent by the server. The terminal device can then further determine, after the corresponding app runs, whether the code for the function switch has been overwritten.
[0101] For example, the aforementioned terminal device can set up function detection logic in the corresponding App. This function detection logic is used to obtain the identifier of the corresponding function and its code location when the corresponding function is triggered. In this way, after the App runs, the terminal device can obtain the identifier of the function running in the App and its code location based on the function detection logic.
[0102] Taking the example of an iOS (a mobile operating system) installation package corresponding to the aforementioned app, the aforementioned terminal device can utilize the hook capability in iOS to set up function detection logic in the corresponding app, that is, to embed hooks in the methods for obtaining function items. For example, such as... Figure 3 As shown, after the aforementioned App starts and runs normally, the terminal device, based on the aforementioned function detection logic, obtains the identifiers and code locations of the functions running in the App. Specifically, after the App starts and runs normally, the terminal device hooks the method for obtaining function items within the App, triggers the function item acquisition method, and thus obtains the identifiers and code locations of the functions running in the App. The terminal device will obtain the identifiers and code locations of all running functions in the App by triggering the function item acquisition method multiple times.
[0103] In addition, the above function detection logic can also be used to obtain the function value of the corresponding function when the corresponding function is triggered.
[0104] The aforementioned terminal device can obtain the function value of the function running in the corresponding App based on the aforementioned function detection logic, and then determine the status of the function running in the aforementioned App based on the function value, and determine the running status of the function to be updated based on the function identifier of the function to be updated, as well as the identifier and status of the function running in the aforementioned App.
[0105] The aforementioned terminal device can preset the correspondence between function values and operating states for multiple functions, for example, using... Figure 1Taking the function switch described above as an example, the terminal device can set the function value of the function to be turned on to be 1 or 0, where 1 represents on and 0 represents off. In this way, after obtaining the function value of the function running in the corresponding App, the terminal device can determine the status of the function running in the App based on the function value and the aforementioned correspondence. Therefore, based on the function identifier of the function to be updated, and the identifier and status of the function running in the App, the operating status of the function to be updated can be determined. Thus, relevant personnel can judge whether the function to be updated meets expectations based on this operating status. For example... Figure 1 The server issues a function switch to enable the activity function in the App. If the terminal device determines that the function is enabled, relevant personnel can judge that the function meets expectations based on the enabled status.
[0106] S204: Based on the function identifier of the function to be updated, the code location of the function to be updated, and the identifier and code location of the function running in the App, perform function matching, and determine whether to update the function to be updated based on the function matching result.
[0107] For example, the terminal device can determine a target identifier that is the same as the function identifier of the function to be updated from the identifier of the function running in the corresponding App. Then, based on the target identifier, it can obtain the code position of the target function from the code position of the function running in the App. Based on the code position of the function to be updated and the code position of the target function, it can perform function matching, for example, by comparing the code position of the function to be updated with the code position of the target function to determine the position offset value.
[0108] Here, after performing the aforementioned function matching, the terminal device can determine whether to update the function to be updated based on the function matching result. Specifically, the terminal device can employ fuzzy matching logic, for example, determining whether the function matching result meets preset function conditions. These preset function conditions include that the matching offset between the code location of the function to be updated and the code location of the target function is less than a preset threshold. If the function matching result meets the preset function conditions, the terminal device determines to update the function to be updated. Here, the matching offset can be understood as the position offset value.
[0109] In this embodiment, the terminal device obtains the code location of the function to be updated during static analysis, while the corresponding App obtains the code location of the running function through function detection logic during runtime. The two code locations are not entirely consistent. To perform subsequent function matching, based on the matching result, the terminal device considers the matching offset value between the two. When the offset value is less than a preset threshold, a match is determined, i.e., a fuzzy match is found. This indicates that the code for the corresponding function is overwritten after the App runs, thus determining to update the function to be updated.
[0110] In this embodiment, before the App corresponding to the function to be updated runs, the code location of the function to be updated is determined in the App based on the function identifier of the function to be updated. If it is obtained, it means that the App has the function to be updated (e.g., the function issued by the backend server has been successfully obtained). Then, after the App runs, the identifier and code location of the function running in the App are further obtained. Based on the function identifier and code location of the function to be updated, and the identifier and code location of the function running in the App, function matching is performed. That is, after the App runs, it is determined whether the code of the corresponding function has been overwritten, thereby determining whether to update the function to be updated. In other words, this embodiment performs function testing before updating the function to the online device, reducing online problems caused by function updates and accelerating the development and construction of the capabilities of the App application on the online device.
[0111] Furthermore, during the static analysis phase—that is, before the App runs—the aforementioned terminal device determines whether the code location of the function to be updated is found in the corresponding App based on the function identifier of the function to be updated. It then considers obtaining the installation package corresponding to the App. Based on the installation package, it determines the mapping relationship between strings in the installation package and the code locations of those strings. These strings include the strings corresponding to the function identifiers of each function in the installation package. Then, based on this mapping relationship and the function identifier of the function to be updated, it determines whether the code location of the function to be updated is found in the App. If found, it further determines whether the code of the corresponding function has been overwritten after the App runs, thereby determining whether to update the function to be updated, thus resolving the problem of function update failures in existing function updates. Figure 4 This is a flowchart illustrating another function update method proposed in an embodiment of this application. Figure 4 As shown, the method includes:
[0112] S401: Get the function identifier of the function to be updated.
[0113] Step S401 is implemented in the same way as step S201 above, and will not be described again here.
[0114] S402: Before the App corresponding to the above-mentioned function to be updated runs, obtain the installation package corresponding to the App, and determine the mapping relationship between the strings in the installation package and the code positions where the strings are located based on the installation package. The above-mentioned strings include the strings corresponding to the function identifiers of each function in the above-mentioned installation package.
[0115] The aforementioned terminal device performs static analysis, parses the loading instructions in the aforementioned installation package, obtains the virtual addresses of all segments and sections in the aforementioned installation package, and then determines the mapping relationship between the strings in the aforementioned installation package and the code positions where the strings are located based on the virtual addresses and the preset string size.
[0116] For example, such as Figure 5 As shown, taking the aforementioned installation package as an iOS installation package as an example, the terminal device performs static analysis, loads the machO file, parses the loading instructions of the machO file to obtain the virtual addresses of all segments and sections, and then determines the mapping relationship between strings in the installation package and the code locations where those strings are located based on these virtual addresses and a preset string size. Here, when determining this mapping relationship, the terminal device also considers the strings in the data segment of the machO file, and determines the mapping relationship based on the strings in the data segment, the aforementioned virtual addresses, and the preset string size.
[0117] S403: Based on the above mapping relationship and the function identifier of the function to be updated, determine whether the code location of the function to be updated is obtained in the above App.
[0118] In this embodiment, after determining the mapping relationship, the terminal device can obtain the string representing the target address in the code segment instruction of the installation package within the mapping relationship, and then search for the string corresponding to the function identifier of the function to be updated within the string representing the target address in the mapping relationship. If the string corresponding to the function identifier of the function to be updated is found within the string representing the target address in the mapping relationship, the terminal device can determine that the code location of the function to be updated is obtained in the App, that is, the code location containing the string corresponding to the function identifier of the function to be updated can be found in the mapping relationship.
[0119] Here, we'll still use the above installation package as an example for iOS installation. Figure 5As shown, after determining the mapping relationship between strings in the installation package and the code locations of those strings, the terminal device can sequentially scan the text code segment instructions to obtain the string whose target address is located within the mapping relationship. For example, the terminal device can first determine if the code segment instruction is an ADRP instruction. If it is, it obtains the starting address from the code segment instruction and determines if that starting address is within the string in the mapping relationship. If it is not an ADRP instruction, the terminal device can re-execute the sequential scanning step of the text code segment instructions. If the starting address is within the mapping relationship, the terminal device can further determine if the next instruction is an Add instruction. Additionally, if the starting address is not within the string in the mapping relationship, the terminal device can re-execute the sequential scanning step of the text code segment instructions.
[0120] If the next instruction is an Add instruction, the terminal device can obtain the target address from the next instruction and determine whether the target address is in the above mapping relationship. Here, if the next instruction is not an Add instruction, the terminal device can re-execute the above steps of sequentially scanning the text code segment instructions. If the target address is in the string in the above mapping relationship, the terminal device can record the hit and continue scanning the text code segment instructions until the end of the text segment to obtain all strings in the text code segment instructions whose target addresses are in the above mapping relationship.
[0121] Furthermore, the aforementioned terminal device can search for the string corresponding to the function identifier of the function to be updated in all strings within the aforementioned mapping relationship at the aforementioned target address. If found, based on the aforementioned mapping relationship, the code location of the function to be updated can be obtained, indicating that the App contains the function to be updated. For example... Figure 1 The code of an app on the online device has some pre-set entry points and code logic for some activity functions. The server needs to send a function switch to enable the activity function in the app. After static analysis, the terminal device can obtain the code location of the function switch in the corresponding app, which means that the terminal device has successfully received the function switch sent by the server in the corresponding app.
[0122] S404: If the code location of the function to be updated is obtained in the above App, then after the above App is run, the identifier of the function running in the above App and its code location will be obtained.
[0123] S405: Based on the function identifier of the function to be updated, the code location of the function to be updated, and the identifier and code location of the function running in the App, perform function matching, and determine whether to update the function to be updated based on the function matching result.
[0124] The implementation of steps S404-S405 is the same as that of steps S203-S204 above, and will not be repeated here.
[0125] In the static analysis phase of this application embodiment, the installation package corresponding to the aforementioned App is obtained. Then, based on the installation package, the mapping relationship between the strings in the installation package and the code locations of the strings is determined. The aforementioned strings include the strings corresponding to the function identifiers of each function in the installation package. Then, based on the aforementioned mapping relationship and the function identifiers of the function to be updated, it is determined whether the code location of the function to be updated is obtained in the aforementioned App. If it is obtained, it means that the App has the function to be updated (for example, the function issued by the backend server has been successfully obtained). Then, after the aforementioned App runs, it is further determined whether the code of the corresponding function has been overwritten, thereby determining whether to update the function to be updated. That is, function detection is performed before updating the function to the online device, which solves the problem of function update failure in the existing function update and accelerates the development and construction of the capabilities of the App application on the online device.
[0126] Corresponding to the function update method in the above embodiments, Figure 6 This is a schematic diagram of the structure of a function update device provided in an embodiment of this application. For ease of explanation, only the parts relevant to the embodiments of this application are shown. Figure 6 This is a schematic diagram of a function update device provided in an embodiment of this application. The function update device 60 includes: a function acquisition module 601, a static analysis module 602, a runtime analysis module 603, and a function update module 604. The function update device can be the terminal device itself, or a chip or integrated circuit that implements the functions of the terminal device. It should be noted that the division into the function acquisition module, static analysis module, runtime analysis module, and function update module is only a logical functional division; physically, they can be integrated or independent.
[0127] Among them, the function acquisition module 601 is used to acquire the function identifier of the function to be updated.
[0128] The static analysis module 602 is used to determine, based on the function identifier of the function to be updated, whether the code location of the function to be updated is obtained in the App before the App corresponding to the function to be updated runs.
[0129] The analysis module 603 is used to obtain the identifier and code location of the function to be updated in the App after the App is run, if the code location of the function to be updated is obtained in the App.
[0130] The function update module 604 is used to perform function matching based on the function identifier of the function to be updated, the code location of the function to be updated, and the identifier and code location of the function running in the App, and determine whether to update the function to be updated based on the function matching result.
[0131] In one possible implementation, the static analysis module 602 is specifically used for:
[0132] Obtain the installation package corresponding to the App, and determine the mapping relationship between the strings in the installation package and the code positions where the strings are located based on the installation package, wherein the strings include the strings corresponding to the function identifiers of each function in the installation package;
[0133] Based on the mapping relationship and the function identifier of the function to be updated, determine whether the code location of the function to be updated is obtained in the App.
[0134] In one possible implementation, the static analysis module 602 is specifically used for:
[0135] The loading instructions in the installation package are parsed to obtain the virtual addresses of all segments and all sections in the installation package;
[0136] Based on the virtual addresses of all segments and sections in the installation package, and the preset string size, determine the mapping relationship between the strings in the installation package and the code locations where the strings are located.
[0137] In one possible implementation, the static analysis module 602 is specifically used for:
[0138] Based on the installation package, obtain the string representing the target address in the mapping relationship from the code segment instructions of the installation package;
[0139] In the target address, find the string corresponding to the function identifier of the function to be updated in the string in the mapping relationship;
[0140] If the string corresponding to the function identifier of the function to be updated is found in the string of the mapping relationship at the target address, then the code location of the function to be updated in the App is determined.
[0141] In one possible implementation, the runtime analysis module 603 is specifically used for:
[0142] The App is configured with function detection logic, which is used to obtain the identifier of the corresponding function and its code location when the corresponding function is triggered.
[0143] After the App runs, based on the function detection logic, the identifier of the function running in the App and its code location are obtained.
[0144] In one possible implementation, the function detection logic is further configured to obtain the function value of the corresponding function when the corresponding function is triggered.
[0145] The operation analysis module 603 is also used for:
[0146] Based on the aforementioned function detection logic, the function values of the functions running in the App are obtained;
[0147] The status of the functions running in the App is determined based on the function values of the functions running in the App.
[0148] The running status of the function to be updated is determined based on the function identifier of the function to be updated, as well as the identifier and status of the functions running in the App.
[0149] In one possible implementation, the function update module 604 is specifically used for:
[0150] Among the identifiers of the functions running in the App, identify the target identifier that is the same as the function identifier of the function to be updated;
[0151] Based on the target identifier, the code location of the target function is obtained from the code location of the function running in the App;
[0152] Function matching is performed based on the code location of the function to be updated and the code location of the target function.
[0153] In one possible implementation, the function update module 604 is specifically used for:
[0154] If the function matching result meets the preset function conditions, then it is determined to update the function to be updated, wherein the preset function conditions include that the matching offset value between the code position of the function to be updated and the code position of the target function is less than a preset threshold.
[0155] The apparatus provided in this application embodiment can be used to execute the technical solutions of the above method embodiments. Its implementation principle and technical effect are similar, and will not be repeated here.
[0156] Optionally, Figure 7A schematic diagram of a possible basic hardware architecture of the terminal device described in this application is provided.
[0157] See Figure 7 The terminal device 700 includes at least one processor 701 and a communication interface 703. Optionally, it may also include a memory 702 and a bus 704.
[0158] In the terminal device 700, the number of processors 701 can be one or more. Figure 7 Only one processor 701 is illustrated. Optionally, processor 701 can be a central processing unit (CPU), a graphics processing unit (GPU), or a digital signal processor (DSP). If terminal device 700 has multiple processors 701, the types of the multiple processors 701 can be different or the same. Optionally, the multiple processors 701 of terminal device 700 can also be integrated into a multi-core processor.
[0159] The memory 702 stores computer instructions and data; the memory 702 may store computer instructions and data required to implement the above-described function update method provided in this application, for example, the memory 702 stores instructions for implementing the steps of the above-described function update method. The memory 702 may be any one or any combination of the following storage media: non-volatile memory (e.g., read-only memory (ROM), solid-state drive (SSD), hard disk drive (HDD), optical disk), volatile memory.
[0160] The communication interface 703 can provide information input / output for the at least one processor. It may also include any one or any combination of the following devices: a network interface (e.g., an Ethernet interface), a wireless network card, or other devices with network access capabilities.
[0161] Optionally, the communication interface 703 can also be used for data communication between the terminal device 700 and other computing devices or terminal devices.
[0162] Further optional, Figure 7 Bus 704 is represented by a thick line. Bus 704 connects processor 701 to memory 702 and communication interface 703. In this way, through bus 704, processor 701 can access memory 702 and can also use communication interface 703 to exchange data with other computing devices or terminal devices.
[0163] In this application, the terminal device 700 executes computer instructions in the memory 702, causing the terminal device 700 to implement the above-mentioned function update method provided in this application, or causing the terminal device 700 to deploy the above-mentioned function update device.
[0164] From the perspective of logical functional division, for example, such as Figure 7 As shown, the memory 702 may include a function acquisition module 601, a static analysis module 602, a runtime analysis module 603, and a function update module 604. The inclusion here refers only to the fact that when the instructions stored in the memory are executed, they can respectively implement the functions of the function acquisition module, the static analysis module, the runtime analysis module, and the function update module, and is not limited to the physical structure.
[0165] In addition, the aforementioned terminal devices can, besides being like the ones described above... Figure 7 Besides being implemented through software, it can also be implemented as a hardware module or as a circuit unit through hardware.
[0166] This application provides a computer-readable storage medium, wherein the computer program product includes computer instructions that instruct a computing device to perform the above-described function update method provided in this application.
[0167] This application provides a computer program product including computer instructions, which are executed by a processor according to the method described in the first aspect.
[0168] This application provides a chip including at least one processor and a communication interface, wherein the communication interface provides information input and / or output to the at least one processor. Furthermore, the chip may also include at least one memory for storing computer instructions. The at least one processor is used to invoke and execute the computer instructions to perform the functional update method provided in this application.
[0169] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0170] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0171] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
Claims
1. A function update method characterized by comprising: include: Get the feature identifier of the feature to be updated; Before the application corresponding to the function to be updated runs, the installation package corresponding to the application is obtained. Based on the installation package, the mapping relationship between the strings in the installation package and the code positions of the strings is determined. The strings include the strings corresponding to the function identifiers of each function in the installation package. Based on the mapping relationship and the function identifier of the function to be updated, determine whether the code location of the function to be updated is obtained in the application; If the code location of the function to be updated is obtained in the application, then after the application runs, the identifier of the function running in the application and its code location are obtained; Among the identifiers of the functions running in the application, identify the target identifier that is the same as the function identifier of the function to be updated; Based on the target identifier, the code location of the target function is obtained from the code location of the function running in the application; Based on the code location of the function to be updated and the code location of the target function, a function matching is performed, and based on the function matching result, it is determined whether to update the function to be updated.
2. The method of claim 1, wherein, The step of determining the mapping relationship between strings in the installation package and the code positions of those strings, based on the installation package, includes: The loading instructions in the installation package are parsed to obtain the virtual addresses of all segments and all sections in the installation package; Based on the virtual addresses of all segments and sections in the installation package, and the preset string size, determine the mapping relationship between the strings in the installation package and the code locations where the strings are located.
3. The method of claim 1, wherein, The step of determining whether the code location of the function to be updated is obtained in the application based on the mapping relationship and the function identifier of the function to be updated includes: Based on the installation package, obtain the string representing the target address in the mapping relationship from the code segment instructions of the installation package; In the target address, find the string corresponding to the function identifier of the function to be updated in the string in the mapping relationship; If the string corresponding to the function identifier of the function to be updated is found in the string of the mapping relationship at the target address, then the code location of the function to be updated is determined in the application.
4. The method according to any one of claims 1 to 3, characterized in that, After the application runs, obtaining the identifier and code location of the function running in the application includes: The application is configured with function detection logic, which is used to obtain the identifier of the corresponding function and its code location when the corresponding function is triggered. After the application runs, the identifier of the function running in the application and its code location are obtained based on the function detection logic.
5. The method of claim 4, wherein, The function detection logic is also used to obtain the function value of the corresponding function when the corresponding function is triggered; After obtaining the identifier and code location of the function running in the application, the process further includes: Based on the function detection logic, the function values of the functions running in the application are obtained; The state of the function running in the application is determined based on the function value of the function running in the application. The running status of the function to be updated is determined based on the function identifier of the function to be updated, and the identifier and status of the function running in the application.
6. The method of claim 1, wherein, The step of determining whether to update the function to be updated based on the function matching result includes: If the function matching result meets the preset function conditions, then it is determined to update the function to be updated, wherein the preset function conditions include that the matching offset value between the code position of the function to be updated and the code position of the target function is less than a preset threshold.
7. A function updating apparatus characterized by comprising: include: The function acquisition module is used to acquire the function identifier of the function to be updated. The static analysis module is used to obtain the installation package corresponding to the application before the application corresponding to the function to be updated runs, and determine the mapping relationship between the strings in the installation package and the code positions where the strings are located based on the installation package. The strings include the strings corresponding to the function identifiers of each function in the installation package. Based on the mapping relationship and the function identifier of the function to be updated, determine whether the code location of the function to be updated is obtained in the application; The analysis module is used to obtain the identifier and code location of the function to be updated in the application after the application is run, if the code location of the function to be updated is found in the application. The function update module is used to determine, from the identifiers of functions running in the application, a target identifier that is the same as the function identifier of the function to be updated; Based on the target identifier, the code location of the target function is obtained from the code location of the function running in the application; Based on the code location of the function to be updated and the code location of the target function, a function matching is performed, and based on the function matching result, it is determined whether to update the function to be updated.
8. The apparatus of claim 7, wherein, The static analysis module is specifically used for: The loading instructions in the installation package are parsed to obtain the virtual addresses of all segments and all sections in the installation package; Based on the virtual addresses of all segments and sections in the installation package, and the preset string size, determine the mapping relationship between the strings in the installation package and the code locations where the strings are located.
9. The apparatus according to claim 7, characterized in that, The static analysis module is specifically used for: Based on the installation package, obtain the string representing the target address in the mapping relationship from the code segment instructions of the installation package; In the target address, find the string corresponding to the function identifier of the function to be updated in the string in the mapping relationship; If the string corresponding to the function identifier of the function to be updated is found in the string of the mapping relationship at the target address, then the code location of the function to be updated is determined in the application.
10. The apparatus according to any one of claims 7 to 9, characterized in that, The operation analysis module is specifically used for: The application is configured with function detection logic, which is used to obtain the identifier of the corresponding function and its code location when the corresponding function is triggered. After the application runs, the identifier of the function running in the application and its code location are obtained based on the function detection logic.
11. The apparatus according to claim 10, characterized in that, The function detection logic is also used to obtain the function value of the corresponding function when the corresponding function is triggered; The operation analysis module is also used for: Based on the function detection logic, the function values of the functions running in the application are obtained; The state of the function running in the application is determined based on the function value of the function running in the application. The running status of the function to be updated is determined based on the function identifier of the function to be updated, and the identifier and status of the function running in the application.
12. The apparatus according to claim 7, characterized in that, The function update module is specifically used for: If the function matching result meets the preset function conditions, then it is determined to update the function to be updated, wherein the preset function conditions include that the matching offset value between the code position of the function to be updated and the code position of the target function is less than a preset threshold.
13. A terminal device, characterized in that, include: processor; Memory; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor, the computer program including instructions for performing the method as described in any one of claims 1-6.
14. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that causes the server to perform the method according to any one of claims 1-6.
15. A computer program product, characterized in that, Includes computer instructions, which are executed by a processor according to any one of claims 1-6.
Citation Information
Patent Citations
Application program updating test method and device, terminal equipment and storage medium
CN108509212A
Kernel-based detection of target application functionality using virtual address mapping
CN109643343A
Application processing method, device and equipment and readable storage medium
CN113076248A
