Code updating method and device of application program, electronic device, and storage medium

By comparing the initial source code and historical running data of the application and deleting unused data, the issues of application size and stability were resolved, and memory optimization and fast startup were achieved.

CN115543401BActive Publication Date: 2026-02-03CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211247585.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-12
Publication Date
2026-02-03
Estimated Expiration
2042-10-12

AI Technical Summary

Technical Problem

Outdated and useless data exists in existing applications, causing them to grow in size, consume more memory, increase cold start time, and affect operational stability.

Method used

By obtaining the initial source code and historical running data of the application, storing them in different storage spaces, comparing the data differences, deleting unused data, and obtaining the target source code.

Benefits of technology

It reduces the size of the application, shortens the cold start time, improves operational stability, and reduces memory usage and network resource waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115543401B_ABST
    Figure CN115543401B_ABST
Patent Text Reader

Abstract

The application provides a code updating method and device of an application program, an electronic device and a storage medium, and belongs to the technical field of computers. The initial source code of the application program and original data to be called by the initial source code are acquired, historical running data of the application program in a running state is acquired, the historical running data is stored to a first storage space, when the application program is switched from the running state to a preset state, the historical running data is read from the first storage space and stored to a second storage space, the uploading state of the historical running data is acquired, if the uploading state indicates that the historical running data is not uploaded to a data processing terminal within a preset time, the historical running data is read from the second storage space, the historical running data is uploaded to the data processing terminal, the original data and the historical running data are compared to obtain target data, and the target data is deleted from the initial source code to obtain target source code, so that the memory space occupied by the application program can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method and apparatus for updating application code, an electronic device, and a storage medium. Background Technology

[0002] In related technologies, applications contain a lot of outdated and useless data. This data is kept in the application, which will cause the application size to continue to increase, resulting in the application occupying more memory space. On the other hand, it will increase the application's cold start time and cause the application to lag during operation, resulting in low application stability. Summary of the Invention

[0003] The main objective of this application is to provide a method, apparatus, electronic device, and storage medium for updating application code, which aims to optimize the application installation package, reduce the memory space occupied by the application, shorten the cold start time of the application, and improve the stability of the application operation.

[0004] To achieve the above objectives, a first aspect of this application provides a method for updating application code, the method comprising:

[0005] Obtain the initial source code of the application;

[0006] Obtain the original data to be called from the initial source code;

[0007] Obtain historical running data of the application while it is running, and store the historical running data in the first storage space;

[0008] When the application switches from the running state to a preset state, it reads the historical running data from the first storage space and stores the historical running data in the second storage space; wherein, the preset state includes a program stopped running state or a background state;

[0009] Obtain the upload status of the historical running data;

[0010] If the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time, then the historical running data is read from the second storage space and uploaded to the data processing terminal.

[0011] The original data to be invoked and the historical running data uploaded to the data processing terminal are compared to obtain the target data; wherein the target data is data that the application has not invoked.

[0012] The target data is removed from the initial source code to obtain the target source code.

[0013] In some embodiments, obtaining the original data to be called from the initial source code includes:

[0014] The initial source code is scanned according to a preset script file to obtain the original image data and original class data of the application.

[0015] The original image data is packaged to obtain the first image information;

[0016] The original data is uploaded based on a preset interface to obtain the first type of information;

[0017] The original data is obtained based on the first image information and the first type of information.

[0018] In some embodiments, the process of uploading the original class data based on a preset interface to obtain the first type of information includes:

[0019] If the data upload field of the original class data is "not uploaded" and the original class data is in the preset data upload list, then the interface is called to upload the original class data to obtain the first class information.

[0020] In some embodiments, the historical running data includes second image information and second type of information. Obtaining the historical running data of the application in its running state includes:

[0021] When the application is running, it calls a preset image acquisition method to obtain a preset image, and obtains the second image information based on the image name and image acquisition time of the preset image;

[0022] When the application is running, a preset class execution method is called to execute the preset class and initialize the preset class, thereby obtaining the class name and class usage time of the preset class, and obtaining the second type of information based on the class name and the class usage time;

[0023] The historical operation data is obtained based on the second image information and the second type of information.

[0024] In some embodiments, after obtaining the upload status of the historical running data, the process includes:

[0025] If the upload status indicates that the historical operation data has been uploaded to the data processing terminal within a preset time, then the historical operation data stored in the second storage space is marked according to a preset marking method.

[0026] In some embodiments, the step of comparing the original data to be invoked with the historical running data uploaded to the data processing terminal to obtain the target data includes:

[0027] The first image information and the second image information uploaded to the data processing terminal are compared to obtain the target image data.

[0028] The first type of information and the second type of information uploaded to the data processing terminal are compared to obtain the target type of data.

[0029] In some embodiments, the historical operation data includes first historical operation data and second historical operation data, and uploading the read historical operation data to the data processing terminal includes:

[0030] Compare the data differences between the first historical operation data and the second historical operation data;

[0031] If the first historical running data and the second historical running data are the same, then delete the second historical running data;

[0032] The first historical running data is uploaded to the data processing terminal.

[0033] To achieve the above objectives, a second aspect of this application provides an application code update apparatus, the apparatus comprising:

[0034] The first acquisition module is used to acquire the initial source code of the application;

[0035] The second acquisition module is used to acquire the original data to be called from the initial source code;

[0036] The third acquisition module is used to acquire historical running data of the application in its running state and store the historical running data in the first storage space.

[0037] A storage module is configured to read the historical running data from the first storage space and store the historical running data in the second storage space when the application switches from the running state to a preset state; wherein, the preset state includes a program stopped running state or a background state;

[0038] The fourth acquisition module is used to acquire the upload status of the historical running data;

[0039] An upload module is used to read the historical running data from the second storage space and upload the read historical running data to the data processing terminal if the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time.

[0040] The data comparison module is used to compare the original data to be called with the historical running data uploaded to the data processing terminal to obtain target data; wherein the target data is data that the application has not called.

[0041] The deletion module is used to delete the target data from the initial source code to obtain the target source code.

[0042] To achieve the above objectives, a third aspect of this application provides an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.

[0043] To achieve the above objectives, a fourth aspect of the present application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.

[0044] The application code update method, device, electronic device, and computer-readable storage medium proposed in this application obtain the initial source code of the application, the original data to be called in the initial source code, and the historical running data of the application in its running state. The historical running data is stored in a first storage space. To avoid the historical running data occupying the first storage space, when the application switches from the running state to a preset state, the historical running data is read from the first storage space and stored in a second storage space. To reduce network resource waste, the upload status of the historical running data is obtained. If the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time, the historical running data is read from the second storage space. The system then uploads the retrieved historical running data to the data processing terminal, avoiding the waste of network resources caused by frequent uploading of historical running data. It compares the original data to be called with the historical running data uploaded to the data processing terminal to obtain the target data. This comparison reveals data that the application has not yet called. The target data is then removed from the initial source code to obtain the target source code. By removing uncalled data from the initial source code, the application size is reduced, thus reducing the memory space occupied by the application. The cold start time of the application is also shortened. Furthermore, the stability of the application is improved by reducing stuttering during operation. Attached Figure Description

[0045] Figure 1This is a flowchart of the application code update method provided in the embodiments of this application;

[0046] Figure 2 yes Figure 1 The flowchart of step S120 in the middle;

[0047] Figure 3 yes Figure 1 The flowchart of step S130 in the process;

[0048] Figure 4 yes Figure 1 The flowchart of step S160 in the process;

[0049] Figure 5 yes Figure 1 The flowchart of step S170 in the process;

[0050] Figure 6 This is a schematic diagram of the structure of the application code update device provided in the embodiments of this application;

[0051] Figure 7 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0053] It should be noted that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, and the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.

[0055] First, let's analyze some of the terms used in this application:

[0056] Source code: refers to the original code, which is an uncompiled text file written according to programming rules. This text file contains a series of computer language instructions.

[0057] An interface is a class or function in an application that is responsible for transmitting or receiving data between different modules and processing that data.

[0058] In related technologies, applications contain a lot of outdated and useless data. This data is kept in the application, which will cause the application size to continue to increase, resulting in the application occupying more memory space. On the other hand, it will increase the application's cold start time and cause the application to lag during operation, resulting in low application stability.

[0059] Based on this, embodiments of this application provide a method for updating application code, an apparatus for updating application code, an electronic device, and a computer-readable storage medium, which aim to optimize application installation packages, reduce the memory space occupied by applications, shorten the cold start time of applications, and improve the stability of application operation.

[0060] The application code update method, apparatus, electronic device, and storage medium provided in this application embodiment are specifically described through the following embodiments. First, the application code update method in this application embodiment is described.

[0061] The application code update method provided in this application relates to the field of computer technology. The application code update method provided in this application can be applied to a terminal, a server, or software running on either a terminal or a server. In some embodiments, the terminal can be a smartphone, tablet, laptop, desktop computer, etc.; the server can be configured as an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the application code update method, but is not limited to the above forms.

[0062] This application can be used in a wide variety of general-purpose or special-purpose computer system environments or configurations. Examples include: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, and distributed computing environments including any of the above systems or devices. This application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform specific tasks or implement specific abstract data types. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0063] It should be noted that in all specific embodiments of this application, when processing data related to user identity or characteristics, such as user information, user behavior data, user historical data, and user location information, user permission or consent is obtained first. Furthermore, the collection, use, and processing of this data comply with relevant laws, regulations, and standards of the relevant countries and regions. In addition, when embodiments of this application require access to sensitive personal information of users, separate permission or consent from the user is obtained through pop-ups or redirects to confirmation pages. Only after obtaining the user's separate permission or consent is the necessary user-related data for the proper functioning of the embodiments of this application obtained.

[0064] Figure 1 This is an optional flowchart of the application code update method provided in the embodiments of this application. Figure 1 The method may include, but is not limited to, steps S110 to S180.

[0065] Step S110: Obtain the initial source code of the application;

[0066] Step S120: Obtain the original data to be called from the initial source code;

[0067] Step S130: Obtain historical running data of the application in its running state and store the historical running data in the first storage space;

[0068] Step S140: When the application switches from the running state to the preset state, historical running data is read from the first storage space and stored in the second storage space; wherein, the preset state includes the program stopping running state or entering the background state;

[0069] Step S150: Obtain the upload status of historical running data;

[0070] Step S160: If the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time, then read the historical running data from the second storage space and upload the read historical running data to the data processing terminal.

[0071] Step S170: Compare the original data to be called with the historical running data uploaded to the data processing terminal to obtain the target data; wherein the target data is the data that the application has not called.

[0072] Step S180: Delete the target data from the initial source code to obtain the target source code.

[0073] Steps S110 to S180 as illustrated in this embodiment involve obtaining the initial source code of the application, obtaining the original data to be called from the initial source code, obtaining the historical running data of the application in its running state, and storing the historical running data in the first storage space. To avoid the historical running data occupying the first storage space and affecting the running speed of other applications, when the application switches from the running state to a preset state, the historical running data is read from the first storage space and stored in the second storage space. To reduce network resource waste, the upload status of the historical running data is obtained. If the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time, the historical running data is read from the second storage space and uploaded to the data processing terminal, thus avoiding... The waste of network resources caused by frequent uploading of historical running data is addressed by comparing the original data to be called with the historical running data uploaded to the data processing terminal to obtain the target data. This comparison reveals data that the application has not yet called, which is then removed from the initial source code to obtain the target source code. By removing this unused data, the application installation package can be optimized. This reduces the application's size and memory usage, shortens cold start time, and improves operational stability by enabling faster and more responsive responses to user requests and reducing stuttering during operation. Ultimately, this enhances user experience and application stability.

[0074] In step S110 of some embodiments, the initial source code of the application is obtained according to a preset decompilation tool, or the initial source code of the application is obtained from the application's project.

[0075] Please see Figure 2In some embodiments, step S120 may include, but is not limited to, steps S210 to S240:

[0076] Step S210: Scan the initial source code according to the preset script file to obtain the original image data and original class data of the application.

[0077] Step S220: Package the original image data to obtain the first image information;

[0078] Step S230: Upload the original class data based on the preset interface to obtain the first type of information;

[0079] Step S240: Obtain the raw data based on the first image information and the first type of information.

[0080] In step S210 of some embodiments, the script file is executed to scan the initial source code of the application to obtain all the original image data and original class data to be called by the application. The original image data is all the image information to be called by the initial source code, including the application version number, image name, image size, etc. The original class data is all the class data to be called by the initial source code, including the application version number, class name, etc.

[0081] In step S220 of some embodiments, the original image data is saved as a JSON file, the JSON file is packaged, and the interface is called to upload the JSON file to the data processing terminal to obtain the first image information, wherein the first image information is all the image information that has been uploaded to the data processing terminal.

[0082] In step S230 of some embodiments, an interface is called to upload the original class data to the data processing terminal to obtain first-class information, wherein the first-class information is all class data uploaded to the data processing terminal. If the data upload field of the original class data is "not uploaded" and the original class data is in a preset data upload list, then the interface is called to upload the original class data to obtain the first-class information. Specifically, if the data upload field of the original class data of the current version of the application is "not uploaded" and the original class data of the current version of the application is in the data upload list, then the interface is called to upload the original class data to obtain the first-class information. It can be understood that whether the original class data has been uploaded can be determined by setting the identifier of the data upload field. For example, when the identifier of the data upload field is 1, it is determined that the original class data has been uploaded to the data processing terminal, and when the identifier of the data upload field is 0, it is determined that the original class data has not been uploaded to the data processing terminal. You can determine whether the original class data is in the data upload list by setting a configuration switch. If the configuration switch is on, the original class data is in the data upload list. If the configuration switch is off, the original class data is not in the data upload list.

[0083] In step S240 of some embodiments, the first image information and the first type of information are used as raw data, wherein the raw data is the full amount of data to be called in the initial source code of the application in the data processing terminal.

[0084] Steps S210 to S240, by uploading the full data of the application to be called to the data processing terminal, enable the data processing terminal to process the initial source code based on the full data, resulting in a smaller application and achieving the goal of application slimming. Simultaneously, uploading the full data to the data processing terminal instead of processing it locally on the application's local machine reduces the consumption of local computing and storage resources, improving the application's running efficiency on the local machine.

[0085] Please see Figure 3 In some embodiments, the historical running data includes second image information and second type of information, and step S130 may include, but is not limited to, steps S310 to S330:

[0086] Step S310: When the application is running, a preset image acquisition method is called to acquire a preset image, and the second image information is obtained based on the image name and image acquisition time of the preset image.

[0087] Step S320: When the application is in the running state, the preset class execution method is called to execute the preset class and initialize the preset class to obtain the class name and class usage time of the preset class. The second type of information is obtained based on the class name and class usage time.

[0088] Step S330: Obtain historical operation data based on the second image information and the second type of information.

[0089] In step S310 of some embodiments, the application's source code is currently analyzed using static analysis to obtain the usage of images and classes. Static analysis is a technique that scans and analyzes the application's source code using analysis tools without requiring the application to run. Classes declared but not referenced in the source code are considered unused classes, and images whose names are not referenced in the source code are considered unused images. A reference refers to a class or image being used elsewhere in the source code besides its declaration. However, static analysis cannot obtain the usage of images and classes without business function entry points. Images and classes without business function entry points may have references to their names or classes in the code. Since the business function entry point is removed, these images and classes will not be used during application runtime. If static analysis is used to scan the code, unused images and classes will be incorrectly identified as being used.

[0090] This application embodiment obtains a preset image by calling an image acquisition method while the application is running, thus obtaining the usage information of the preset image and accurately determining the image usage status within the application. When an image lacks a business function entry point, the method for acquiring the image during application runtime is not called, so no information about the image being used is obtained. However, if a static analysis method is used to scan the application source code, the image name will appear in the source code, thus revealing that the image has been used. Compared to the static analysis method, this application embodiment can more accurately determine the image usage status within the application.

[0091] Specifically, when the application is running, it calls the image acquisition method to obtain a preset image. The application version number, the image name of the preset image, and the image acquisition time of the preset image are used as the second image information. The image acquisition time is the usage time of the image, that is, the time when the image acquisition method is called to obtain the preset image. The second image information is the image data that the application has already called, that is, the image data has been used and there is a reference relationship between them.

[0092] In step S320 of some embodiments, this application embodiment obtains usage information of preset classes by calling class execution methods when the application is running, thereby accurately determining the usage status of functional classes in the application. When a functional class has no business function entry point, the method for executing that functional class is not called during application runtime, so no information about the functional class being used is obtained. However, if a static analysis method is used to scan the application source code, information about the functional class being used will be obtained because the class name appears in other parts of the source code besides the declaration. Compared to the static analysis method, this application embodiment can accurately determine the usage status of classes in the application.

[0093] Specifically, when the application is running, it calls the preset class execution method to execute the preset class and initialize the preset class, obtains the class name and the class usage time of the preset class, and obtains the second type of information based on the class name and the class usage time. The class usage time is the time when the preset class is executed, and the second type of information is the class data that the application has called, that is, the class data has been used and there is a reference relationship.

[0094] When a preset class is initialized, a flag in the preset class object is initialized. This flag indicates whether the preset class is used. If the flag has been initialized, it means that the preset class has been used. If the flag has not been initialized, it means that the preset class has not been used.

[0095] In step S330 of some embodiments, the image data and class data that the application has called are used as historical running data, and the historical running data is stored in the first storage space, wherein the first storage space is the memory of the terminal where the application is located.

[0096] Steps S310 to S330 above obtain preset images by calling the image acquisition method while the application is running, thus acquiring usage information of the preset images. Compared to static analysis methods, this approach can more accurately determine the usage of images within the application. Similarly, while the application is running, a preset class is executed by calling the class execution method to obtain usage information of the preset class. Compared to static analysis methods, this approach can more accurately determine the usage of classes within the application.

[0097] In step S140 of some embodiments, when the application switches from a running state to a stopped running state or enters a background state, historical running data is read from the memory of the terminal where the application is located, and the historical running data is stored in a second storage space, wherein the second storage space is the database of the terminal where the application is located.

[0098] In step S150 of some embodiments, the upload status of historical running data is obtained. The upload status is used to characterize whether the historical running data has been uploaded to the data processing terminal within a preset time, including an uploaded status and an unuploaded status.

[0099] In step S160 of some embodiments, if the upload status indicates that historical running data has not been uploaded to the data processing terminal within a preset time, then the historical running data is read from the second storage space and uploaded to the data processing terminal, updating the upload status of the historical running data to the uploaded status. If the upload status indicates that historical running data has been uploaded to the data processing terminal within a preset time, i.e., the upload status is uploaded, then the historical running data stored in the second storage space is marked according to a preset marking method, for example, the data upload field of the historical running data stored in the second storage space is marked as true or 1, and the historical running data is not uploaded.

[0100] Specifically, a pre-set first time interval is obtained, and the previous image upload time of the second image information is added to the first time interval to calculate the first time. If the current time is greater than the first time, the second image information is uploaded to the data processing terminal. Similarly, a pre-set second time interval is obtained, and the previous class upload time of the second type of information is added to the second time interval to calculate the second time. If the current time is greater than the second time, the second type of information is uploaded to the data processing terminal. Here, the first time is the current image upload time, and the second time is the current class upload time. It should be noted that the first time interval and the second time interval can be the same or different. For example, the first time interval can be three days, one week, one month, etc., and the second time interval can also be three days, one week, one month, etc.

[0101] Please see Figure 4 In some embodiments, the historical running data includes first historical running data and second historical running data, and step S160 may also include, but is not limited to, step S410 or step S430:

[0102] Step S410: Compare the data differences between the first historical running data and the second historical running data;

[0103] Step S420: If the first historical running data and the second historical running data are the same, then delete the second historical running data;

[0104] Step S430: Upload the first historical running data to the data processing terminal.

[0105] In step S410 of some embodiments, since the historical running data includes first historical running data and second historical running data, a data difference comparison is performed between the first historical running data and the second historical running data to deduplicate the historical running data uploaded by the terminal where the application resides to the data processing terminal, thereby reducing the waste of network resources caused by uploading duplicate data. Specifically, a data difference comparison is performed between the second image information in the first historical running data and the second image information in the second historical running data, or a data difference comparison is performed between the second type of information in the first historical running data and the second type of information in the second historical running data.

[0106] In step S420 of some embodiments, if the second image information in the first historical running data is the same as the second image information in the second historical running data, then the second image information in the second historical running data is deleted. If the second type information in the first historical running data is the same as the second type information in the second historical running data, then the second type information in the second historical running data is deleted. Here, "the second image information in the first historical running data is the same as the second image information in the second historical running data" means that the version number and image name of the first historical running data are the same as the version number and image name of the second historical running data. "The second type information in the first historical running data is the same as the second type information in the second historical running data" means that the version number and class name of the first historical running data are the same as the version number and class name of the second historical running data.

[0107] Specifically, the application version number and image name are used as identifiers. If the version number, image name, and image acquisition time in the first historical running data are the same as those in the second historical running data, then the second image information in the second historical running data is deleted. If the version number and image name in the first historical running data are the same as those in the second historical running data, and the image acquisition time in the first historical running data is greater than, i.e., later than, the image acquisition time in the second historical running data, then the second image information in the second historical running data is deleted.

[0108] Using the application's version number and class name as identifiers, if the version number, class name, and class usage time in the first historical running data are all the same as those in the second historical running data, then the second type of information in the second historical running data is deleted; if the version number and class name in the first historical running data are the same as those in the second historical running data, and the class usage time in the first historical running data is greater than, i.e. later than, the class usage time in the second historical running data, then the second type of information in the second historical running data is deleted.

[0109] If the second image information in the first historical running data is different from the second image information in the second historical running data, that is, the application version number in the first historical running data is different from the application version number in the second historical running data, or the image name in the first historical running data is different from the image name in the second historical running data, then data deduplication will not be performed on the second image information in the first historical running data and the second image information in the second historical running data.

[0110] If the second type of information in the first historical running data is different from the second type of information in the second historical running data, that is, the version number of the application in the first historical running data is different from the version number of the application in the second historical running data, or the class name in the first historical running data is different from the class name in the second historical running data, then data deduplication will not be performed on the second type of information in the first historical running data and the second type of information in the second historical running data.

[0111] In step S430 of some embodiments, if the first historical running data and the second historical running data are the same, then the first historical running data is uploaded to the data processing terminal. If the first historical running data and the second historical running data are different, then both the first historical running data and the second historical running data are uploaded to the data processing terminal. Specifically, if the second image information of the first historical running data and the second image information of the second historical running data are the same, then the second image information of the first historical running data is uploaded to the data processing terminal; if the second image information of the first historical running data and the second image information of the second historical running data are different, then both the second image information of the first historical running data and the second image information of the second historical running data are uploaded to the data processing terminal. If the second type of information of the first historical running data and the second type of information of the second historical running data are the same, then the second type of information of the first historical running data is uploaded to the data processing terminal; if the second type of information of the first historical running data and the second type of information of the second historical running data are different, then both the second type of information of the first historical running data and the second type of information of the second historical running data are uploaded to the data processing terminal.

[0112] Steps S410 to S430 above compare the differences between the first historical running data and the second historical running data to deduplicate the historical running data, and then upload the deduplicated historical running data to the data processing terminal. Compared with uploading duplicate historical running data to the data processing terminal, this method can reduce the waste of network resources during data transmission.

[0113] Please see Figure 5 In some embodiments, step S170 may include, but is not limited to, step S510 or step S520:

[0114] Step S510: Compare the data differences between the first image information and the second image information uploaded to the data processing terminal to obtain the target image data;

[0115] Step S520: Compare the data differences between the first type of information and the second type of information uploaded to the data processing terminal to obtain the target type of data.

[0116] In step S510 of some embodiments, in order to obtain unused image data, the first image information and the second image information uploaded to the data processing terminal are compared for data difference, and the second image information is removed from the first image information to obtain the target image data. The first image information is the full image data, the second image information is the used image data, and the target image data is the unused image data.

[0117] In step S520 of some embodiments, in order to obtain unused class data, the first type of information and the second type of information uploaded to the data processing terminal are compared for data difference, and the second type of information is removed from the first type of information to obtain the target class data. The first type of information is the full class data, the second type of information is the used class data, and the target class data is the unused class data.

[0118] It should be noted that the target image data, target class data, first image information, second image information, first class information, and second class information can be visualized to facilitate querying the usage of images and classes.

[0119] Steps S510 to S520 above, by comparing the data differences between the first image information and the second image information, can obtain image data that is not used by the application. By comparing the data differences between the first type of information and the second type of information, can obtain class data that is not used by the application. By monitoring the image data and class data, the application can be optimized based on the monitoring data to promote the rapid development of the application.

[0120] In step S180 of some embodiments, in order to reduce the complexity of the application and make the application clearer and faster, unused image data and unused class data are deleted from the initial source code to obtain target source code. The target source code is the source code with unnecessary data removed. The target source code is compiled to obtain a new application.

[0121] In this embodiment, a packaging script scans all image information in the application, generates a JSON file from the image information, and sends the JSON file to the middleware platform. The JSON file contains all image data. Upon entering the homepage, the application client retrieves the middleware configuration switch information. If the switch information indicates the middleware configuration switch is on, image usage data and class usage data statistics are performed; if the switch information indicates the middleware configuration switch is off, the statistics function is disabled. During a single run of the application client, all local image retrieval methods are called back. During method calls, the image name and image usage time are recorded in memory. When the application stops running or runs in the background, the image name and image usage time are read from memory and stored in the client's database. After the application launches and enters the homepage, it automatically checks the time interval between the last image upload time and the current time. If the time interval is greater than a preset time threshold, it initiates the current upload and records the current image upload time. It then compresses the application version number, image name, and image usage time using a preset compression format to obtain used image data. The compression format can be gzip compression. The client calls the first interface to upload the used image data to the data processing terminal. The data processing terminal decompresses the data using gzip compression to obtain the used image data and deduplicates it based on the application version number and image name. Specifically, it updates the image usage time in the data processing terminal database based on the image usage time of the used image data. If the application version number and image name of an image in the data processing terminal database are the same as those of a used image, the image usage time of that image is updated based on the usage time of the used image. The deduplicated used image data is then uploaded to the middle platform. The middle platform analyzes the images based on the full image data and the used image data to determine the image usage status.

[0122] The client determines whether to upload all class data. If it has not uploaded all class data for this version of the application and the client is a whitelisted user who needs to upload all class data, then it uploads all class data to the middle platform. When the application stops running or runs in the background, it iterates through the class information of all clients, determines whether the class has been used, and writes the used classes (i.e., the used class data) to the local database. It also uses the application version number and class name as identifiers to deduplicate the used class data. If the time interval between the current class upload time and the previous class upload time is greater than a time threshold, then it uploads the deduplicated used class data to the middle platform. The middle platform analyzes the classes based on the all class data and the used class data to obtain the class usage status.

[0123] Specifically, it retrieves all images from the application's installation package, parses the image named A.app (where A can be the application's name), reads the __DATA field of the __objc_classlist section to obtain all uninitialized class objects, and obtains the metaclass object based on the class name of each object. The bits in the metaclass object point to the class_rw_t of the class object. The flags of class_rw_t contain a binary bit that records whether the class has been initialized. This binary bit is only initialized for classes that have been used.

[0124] It should be noted that multiple clients can simultaneously upload used image data and used class data. When used image data and used class data are uploaded to the data processing terminal, the data upload fields for both used image data and used class data in the client's database are marked as true. The middleware configuration switch can be used to set a whitelist of users allowed to upload the full amount of class data.

[0125] Please see Figure 6 This application also provides an application code update apparatus that can implement the above-described application code update method. The apparatus includes:

[0126] The first acquisition module 610 is used to acquire the initial source code of the application.

[0127] The second acquisition module 620 is used to acquire the original data to be called from the initial source code;

[0128] The third acquisition module 630 is used to acquire historical running data of the application in the running state and store the historical running data in the first storage space.

[0129] The storage module 640 is used to read historical running data from the first storage space and store the historical running data in the second storage space when the application switches from the running state to the preset state; wherein the preset state includes the program stopping running state or entering the background state;

[0130] The fourth acquisition module 650 is used to acquire the upload status of historical running data;

[0131] The upload module 660 is used to read historical running data from the second storage space and upload the read historical running data to the data processing terminal if the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time.

[0132] The data comparison module 670 is used to compare the original data to be called with the historical running data uploaded to the data processing terminal to obtain the target data; where the target data is the data that the application has not called.

[0133] Module 680 is used to remove the target data from the initial source code to obtain the target source code.

[0134] Please see Figure 7 , Figure 7 The hardware structure of an electronic device according to another embodiment is illustrated. The electronic device includes:

[0135] The processor 710 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application.

[0136] The memory 720 can be implemented as a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 720 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 720, and the processor 710 calls the code update method for the application programs in the embodiments of this application.

[0137] The input / output interface 730 is used to implement information input and output;

[0138] The communication interface 740 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0139] Bus 750 transmits information between various components of the device (e.g., processor 710, memory 720, input / output interface 730, and communication interface 740);

[0140] The processor 710, memory 720, input / output interface 730 and communication interface 740 are connected to each other within the device via bus 750.

[0141] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the code update method for the aforementioned application.

[0142] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.

[0143] The application code update method, application code update device, electronic device, and computer-readable storage medium provided in this application embodiment obtain the initial source code of the application, obtain the original data to be called in the initial source code, obtain the historical running data of the application in the running state, and store the historical running data in a first storage space. To avoid the historical running data occupying the first storage space and affecting the running speed of other applications, when the application switches from the running state to a preset state, the historical running data is read from the first storage space and stored in a second storage space. To reduce network resource waste, the upload status of the historical running data is obtained. If the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time, the historical running data is read from the second storage space and uploaded. The data is transmitted to the data processing terminal, avoiding the waste of network resources caused by frequently uploading historical running data. The original data to be called is compared with the historical running data uploaded to the data processing terminal to obtain the target data. Through data difference comparison, data that the application has not called can be found. The target data is then deleted from the initial source code to obtain the target source code. By deleting the data that the application has not called from the initial source code, the application installation package is optimized. In terms of application package size, the application size can be reduced, thereby reducing the memory space occupied by the application. In terms of cold start time, the application cold start time can be shortened. In terms of operational stability, the application can respond to user requests quickly and sensitively, reducing application lag during operation, and improving user experience and application stability to a certain extent.

[0144] The embodiments described in 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 by the embodiments of this application. As those skilled in the art will know, with the evolution of technology and the emergence of new application scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.

[0145] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of this application, and may include more or fewer steps than shown, or combine certain steps, or different steps.

[0146] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0147] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0148] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific 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 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.

[0149] It should be understood that in this application, "at least one (item)" means one or more, and "more than" means two or more. "And / or" is used to describe the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0150] 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 the units described above 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.

[0151] The units described above 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.

[0152] 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 as a software functional unit.

[0153] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0154] The preferred embodiments of the present application have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present application. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and substance of the embodiments of the present application shall be within the scope of the claims of the present application.

Claims

1. A method for updating application code, characterized in that, The method includes: Obtain the initial source code of the application; Obtain the original data to be called from the initial source code; Obtain historical running data of the application while it is running, and store the historical running data in the first storage space; When the application switches from the running state to a preset state, it reads the historical running data from the first storage space and stores the historical running data in the second storage space; wherein, the preset state includes a program stopped running state or a background state; Obtain the upload status of the historical running data; If the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time, then the historical running data is read from the second storage space and uploaded to the data processing terminal. The original data to be invoked and the historical running data uploaded to the data processing terminal are compared to obtain the target data; wherein the target data is data that the application has not invoked. The target data is removed from the initial source code to obtain the target source code.

2. The application code update method according to claim 1, characterized in that, The process of obtaining the original data to be called from the initial source code includes: The initial source code is scanned according to a preset script file to obtain the original image data and original class data of the application. The original image data is packaged to obtain the first image information; The original data is uploaded based on a preset interface to obtain the first type of information; The original data is obtained based on the first image information and the first type of information.

3. The application code update method according to claim 2, characterized in that, The process of uploading the original class data based on a preset interface to obtain the first type of information includes: If the data upload field of the original class data is "not uploaded" and the original class data is in the preset data upload list, then the interface is called to upload the original class data to obtain the first class information.

4. The application code update method according to claim 2, characterized in that, The historical running data includes second image information and second type of information. Obtaining the historical running data of the application in its running state includes: When the application is running, it calls a preset image acquisition method to obtain a preset image, and obtains the second image information based on the image name and image acquisition time of the preset image; When the application is running, a preset class execution method is called to execute the preset class and initialize the preset class, thereby obtaining the class name and class usage time of the preset class, and obtaining the second type of information based on the class name and the class usage time; The historical operation data is obtained based on the second image information and the second type of information.

5. The application code update method according to claim 1, characterized in that, After obtaining the upload status of the historical running data, the process includes: If the upload status indicates that the historical operation data has been uploaded to the data processing terminal within a preset time, then the historical operation data stored in the second storage space is marked according to a preset marking method.

6. The application code update method according to claim 4, characterized in that, The step of comparing the original data to be retrieved with the historical running data uploaded to the data processing terminal to obtain the target data includes: The first image information and the second image information uploaded to the data processing terminal are compared to obtain the target image data. The first type of information and the second type of information uploaded to the data processing terminal are compared to obtain the target type of data.

7. The application code update method according to any one of claims 1 to 6, characterized in that, The historical operation data includes first historical operation data and second historical operation data. Uploading the read historical operation data to the data processing terminal includes: Compare the data differences between the first historical operation data and the second historical operation data; If the first historical running data and the second historical running data are the same, then delete the second historical running data; The first historical running data is uploaded to the data processing terminal.

8. An application code update device, characterized in that, The device includes: The first acquisition module is used to acquire the initial source code of the application; The second acquisition module is used to acquire the original data to be called from the initial source code; The third acquisition module is used to acquire historical running data of the application in its running state and store the historical running data in the first storage space. A storage module is configured to read the historical running data from the first storage space and store the historical running data in the second storage space when the application switches from the running state to a preset state; wherein, the preset state includes a program stopped running state or a background state; The fourth acquisition module is used to acquire the upload status of the historical running data; An upload module is used to read the historical running data from the second storage space and upload the read historical running data to the data processing terminal if the upload status indicates that the historical running data has not been uploaded to the data processing terminal within a preset time. The data comparison module is used to compare the original data to be called with the historical running data uploaded to the data processing terminal to obtain target data; wherein the target data is data that the application has not called. The deletion module is used to delete the target data from the initial source code to obtain the target source code.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the application code update method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the code update method for the application program as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for generating application updating package

    CN106919382A

  • Application program updating method and device in multi-tenant scene and electronic equipment

    CN112486547A