Methods for generating Android application packages, methods for launching and running applications, and device configurations.
By splitting and generating additional CPP code files, the problem of low download efficiency caused by excessively large Android application package sizes was solved, achieving both size reduction and efficiency improvement.
Patent Information
- Application Number
- CN202210663451.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-13
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2042-06-13
AI Technical Summary
As Android application packages become more feature-rich, their size also increases, leading to slow download efficiency.
By obtaining the source code files of the target application, the runtime functions are extracted and additional CPP code files are generated. Combined with the remaining source code files and download logic, a reassembled Android application package is generated.
It reduces the size of Android application packages, lowers download time, and improves download and installation efficiency.
Smart Images

Figure CN117270938B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a method for generating a reconstructed Android application package, a method for launching and running the application, and an apparatus. Background Technology
[0002] With the widespread use of mobile devices, more and more applications are installed on them. Users can download Android application packages through their mobile devices. For example, users can download Android application packages from application download platforms and install them to use the installed applications.
[0003] Currently, the functionality offered by applications is increasing, and the more features an application provides, the larger the size of the Android application package becomes. When the size of the Android application package increases, it affects the download time, resulting in lower download efficiency. Summary of the Invention
[0004] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product for generating recombined Android application packages that can reduce the size of Android application packages, in order to address the above-mentioned technical problems.
[0005] Firstly, this application provides a method for generating a recombined Android application package, the method comprising:
[0006] Obtain the source code files of the target application;
[0007] Determine the runtime type functions that the target application needs to call at runtime in the source code file;
[0008] The runtime type function is extracted from the source code file to obtain the remaining source code file after extraction, and an additional CPP code file is generated based on the extracted runtime type function.
[0009] The logic for generating the additional CPP file; the download logic is used to instruct the target application to download the additional CPP file at runtime;
[0010] Based on the remaining source code files after splitting and the download logic, a reconstructed Android application package of the target application is generated.
[0011] In one embodiment, obtaining the source code file of the target application includes:
[0012] When an application package reassembly instruction is received, the instruction is parsed to obtain at least one of the target application identifier, application package storage path, and file storage path.
[0013] The target application is identified by the target application identifier;
[0014] The application package of the target application is obtained through the application package storage path, and the source code file of the target application is obtained through the file storage path.
[0015] In one embodiment, the target application identifier is obtained by selecting from multiple candidate application identifiers in the reconfiguration page displayed on the terminal; the size of the candidate application package corresponding to the candidate application identifier is greater than or equal to a preset size threshold; the application package storage path is configured in the reconfiguration page; and the file storage path is configured in the reconfiguration page.
[0016] In one embodiment, the step of splitting the runtime type function from the source code file to obtain the remaining source code file after splitting includes:
[0017] Create an empty function corresponding to the function of the specified execution type;
[0018] The source code file is updated based on the empty function to obtain the remaining source code file after splitting.
[0019] In one embodiment, the source code file includes a source array file; the source array file includes a source function array; the source function array includes multiple source function pointers; updating the source code file based on the empty function to obtain the remaining source code file after splitting includes:
[0020] Determine the target source function pointers in the source function array that point to the function of the execution type;
[0021] Change the target source function pointer from pointing to a runtime function to pointing to an empty function to obtain an updated source function array, and obtain an updated source array file based on the updated source function array;
[0022] Based on the updated source array file and the function pointed to by the updated source function pointer in the updated source array file, the remaining source code file after splitting is obtained.
[0023] In one embodiment, the step of changing the target source function pointer from pointing to a runtime function to pointing to an empty function to obtain an updated source function array includes:
[0024] For each target source function pointer, the empty function corresponding to the current running type function pointed to by the current target source function pointer is determined according to the first correspondence between the running type function and the empty function;
[0025] Change the value of the current target source function pointer to the function identifier of the empty function corresponding to the current running type function.
[0026] In one embodiment, the Android application package includes a source SO file; the identifier of the source SO file is consistent with the identifier of the target SO file; replacing the source SO file in the Android application package with the target SO file to obtain a reconstructed Android application package includes:
[0027] Based on the identifier of the target SO file, the source SO file in the Android application package is determined;
[0028] Replace the source SO file in the Android application package with the target SO file to obtain a reconstructed Android application package.
[0029] Secondly, this application also provides an apparatus for generating a recombined Android application package, the apparatus comprising:
[0030] The application acquisition module is used to acquire the source code files of the target application.
[0031] The splitting module is used to determine the runtime type functions that the target application needs to call at runtime in the source code file; split the runtime type functions from the source code file to obtain the remaining source code file after splitting; and generate additional CPP code files based on the split runtime type functions.
[0032] A reassembly module is used to generate download logic for the additional CPP file; the download logic is used to instruct the target application to download the additional CPP file at runtime; based on the remaining source code files after splitting and the download logic, a reassembled Android application package of the target application is generated.
[0033] In one embodiment, the splitting module is further configured to determine the startup page to be displayed when the target application starts; determine the jump page to which the target application jumps through the startup page according to the page jump logic between the pages displayed by the target application; and use the function to be called to display the jump page as the runtime type function required by the target application at runtime.
[0034] In one embodiment, the splitting module is further configured to attach a CPP code file to create an empty function corresponding to the run type function; and update the source code file based on the empty function to obtain the remaining source code file after splitting.
[0035] In one embodiment, the splitting module is further configured to create an initial function array; the initial function array includes multiple running function pointers; each running function pointer is respectively pointed to a corresponding running type function to obtain a running function array, and a running array file is generated based on the running function array; an additional CPP code file is generated based on the running array file and the running type function.
[0036] In one embodiment, the splitting module is further configured to create a runtime external declaration corresponding to the current runtime function pointer for each runtime function pointer in the runtime function array; generate a runtime array file based on the runtime function array and the runtime external declaration; the runtime external declaration is used to declare that the runtime type function pointed to by the runtime function pointer is located outside the runtime array file.
[0037] In one embodiment, the source array file includes a source function array; the source function array includes multiple source function pointers; the splitting module is further configured to determine the target source function pointer in the source function array that points to a runtime function; change the target source function pointer from pointing to a runtime function to pointing to an empty function to obtain an updated source function array, and obtain an updated source array file based on the updated source function array; and obtain the remaining source code file after splitting based on the updated source array file and the functions pointed to by the updated source function pointers in the updated source function array.
[0038] In one embodiment, the splitting module is further configured to, for each target source function pointer, determine the empty function corresponding to the current running type function pointed to by the current target source function pointer according to the correspondence between the running type function and the empty function; and change the value of the current target source function pointer to the function identifier of the empty function corresponding to the current running type function.
[0039] In one embodiment, the splitting module is further configured to generate additional CPP code files based on the run type function; determine the startup type function required to start the target application in the source code file based on the run type function, and generate the remaining source code files after splitting through the startup type function.
[0040] In one embodiment, the source code file includes a source array file; the splitting module is further configured to copy the source array file to obtain a copied array file; the copied array file includes a copied function array; the copied function array includes copied function pointers; deletes copied function pointers from the copied function pointers except those pointing to runtime type functions to obtain a remaining copied function array after deletion; the copied array file including the remaining copied function array after deletion is used as a runtime array file, and an additional CPP code file is generated based on the runtime array file and the runtime type functions.
[0041] In one embodiment, the reorganization module is further configured to compile the remaining source code files after the split to obtain a target SO file; and to reorganize the application package using the target SO file to obtain a reorganized application package.
[0042] In one embodiment, the reassembly module is further configured to obtain the Android application package of the target application; the Android application package includes a source SO file generated based on the source code file; the remaining source code file and download logic after the split are compiled to obtain a target SO file; the target SO file replaces the source SO file in the Android application package to obtain a reassembled Android application package.
[0043] In one embodiment, the Android application package includes a source SO file; the identifier of the source SO file is consistent with the identifier of the target SO file; the reassembly module is further configured to determine the source SO file in the application package based on the identifier of the target SO file; and replace the source SO file in the application package with the target SO file to obtain a reassembled application package.
[0044] In one embodiment, the application package reassembly device is further configured to, when launching a target application obtained by installing and reassembling an Android application package, acquire a target SO file stored locally and generated based on the remaining source code files after splitting; launch the target application using the target SO file; when running the target application, acquire an additional SO file generated based on additional CPP code files; update the target SO file using the additional SO file to obtain an updated SO file, and run the target application using the updated SO file.
[0045] In one embodiment, the updated SO file is obtained by updating the target SO file based on the function mapping file and through the additional SO file; the target SO file includes an updated source function array; the updated source function array includes updated source function pointers; the additional SO file includes a running function array; the running function array includes running function pointers; the application package reassembly device is further configured to determine the updated source function pointer corresponding to each running function pointer in the running function array, thereby obtaining the correspondence between the running function pointers and the updated source function pointers; and generate a function mapping file based on the correspondence between the running function pointers and the updated source function pointers.
[0046] In one embodiment, the device for generating the recombined Android application package is further configured to, for each running function pointer in the running function array, determine the empty function corresponding to the current running function pointer based on the correspondence between running type functions and empty functions; determine the target update source function pointer in the updated source function array; the target update source function pointer is an update source function pointer pointing to the empty function corresponding to the current running function pointer; and use the target update source function pointer as the function pointer corresponding to the current running function pointer.
[0047] Thirdly, this application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in any of the methods for generating a reconstructed Android application package provided in the embodiments of this application.
[0048] Fourthly, this application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in any of the methods for generating a reconstructed Android application package provided in the embodiments of this application.
[0049] Fifthly, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the methods for generating a reconstructed Android application package provided in the embodiments of this application.
[0050] The aforementioned method, apparatus, computer device, storage medium, and computer program product for generating a reconstructed Android application package, by obtaining the target application's source code file, can determine the runtime type function within the source code file. By determining the runtime type function, the source code file can be split using the runtime type function to obtain the additional CPP code file required to run the target application and the remaining split source code file required to start the target application. By obtaining the remaining split source code file, a reconstructed Android application package can be generated based on the download logic of the remaining split source code file and the additional CPP file. Since the remaining split source code file is obtained by splitting the source code file, the size of the remaining split source code file will be smaller than the size of the source code file, and the size of the reconstructed Android application package generated from the remaining split source code file will be smaller than the size of the Android application package generated from the source code file, thereby reducing the size of the Android application package. By reducing the size of the reconstructed Android application package, the download time of the reconstructed Android application package can be reduced, thereby improving the download efficiency of the Android application package. Furthermore, when the size of the Android application package is reduced, the time required to install the Android application package can also be reduced, thereby improving the installation efficiency of the Android application package.
[0051] A method, apparatus, computer device, computer-readable storage medium, and computer program product for starting and running an application.
[0052] In a first aspect, this application provides a method for starting and running an application, the method comprising:
[0053] When the target application obtained by installing and reassembling the Android application package is launched, the target SO file stored locally during the installation of the target application is obtained; wherein, the target SO file is generated based on the remaining source code files after splitting.
[0054] The target application is launched using the target SO file;
[0055] When the target application is run, an additional SO file generated based on the additional CPP code file is obtained;
[0056] The target SO file is updated by the attached SO file to obtain an updated dynamic link library, and the target application is run through the updated dynamic link library.
[0057] In one embodiment, when launching the target application obtained by installing and reassembling the Android application package, obtaining the target SO file stored locally during the installation of the target application includes:
[0058] In response to a launch command for the target application, initialize the application process;
[0059] The application process, and based on the preset identifier of the target SO file, obtains the target SO file stored locally during the installation of the target application.
[0060] In one embodiment, the target SO file includes an updated array of source functions; launching the target application via the target SO file includes:
[0061] Call the updated source function pointer in the updated source function array, and determine the startup type function pointed to by the called updated source function pointer;
[0062] The target application is started by calling the startup type function pointed to by the update source function pointer.
[0063] Secondly, this application also provides an application startup and operation device, the device comprising:
[0064] The link library acquisition module is used to acquire the target SO file stored locally during the installation of the target application when the target application obtained by installing and reassembling the application package is launched; wherein, the target SO file is generated based on the remaining source code files after splitting.
[0065] A startup module is used to launch the target application via the target SO file.
[0066] The runtime module is used to obtain an additional SO file generated based on the additional CPP code file when the target application is run; update the target SO file with the additional SO file to obtain an updated SO file; and run the target application with the updated SO file.
[0067] In one embodiment, the running module is further configured to, in response to a running instruction for the target application, determine whether an additional SO file exists locally; when no additional SO file exists locally, generate a download instruction according to the download logic of the additional SO file; send the download instruction; and the sent download instruction is used to trigger the server to return the additional SO file.
[0068] In one embodiment, the target SO file includes an updated source function array; the startup function includes updated source function pointers; the attached SO file includes a running function array; the running function array includes running function pointers; the running module is further configured to obtain a preset function mapping file, and determine the correspondence between the updated source function pointers and the running function pointers based on the function mapping file; determine the function pointers to be updated in the updated source function array based on the correspondence between the updated source function pointers and the running function pointers; update the function pointers to be updated using the running function pointers in the attached SO file to obtain an updated SO file.
[0069] In one embodiment, the running module is further configured to, for each running function pointer in the attached SO file, determine the update source function pointer corresponding to the current running function pointer based on the correspondence between the update source function pointer and the running function pointer, and use the determined update source function pointer as the target function pointer; determine the current running type function pointed to by the current running function pointer; and change the target function pointer from pointing to an empty function to pointing to the current running type function.
[0070] In one embodiment, the running module is further configured to change the value of the target function pointer corresponding to the current running function pointer to the value of the current running function pointer.
[0071] Thirdly, this application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps in the startup and running method of any application provided in the embodiments of this application.
[0072] Fourthly, this application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in the startup and running method of any application provided in the embodiments of this application.
[0073] Fifthly, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps in the startup and running method of any application provided in the embodiments of this application.
[0074] The aforementioned application startup and execution methods, apparatuses, computer devices, storage media, and computer program products, when starting the target application, obtain a target SO file generated based on the remaining source code files after splitting, and can start the target application based on the startup type function in the target SO file. When running the target application, obtain an additional SO file based on the additional CPP code files, and update the target SO file based on the execution type function in the additional SO file to obtain an updated SO file including the execution type function. The target application can then be run based on the updated SO file including the execution type function, thus realizing the startup and execution of the target application. Attached Figure Description
[0075] Figure 1 This is an application environment diagram of a method for generating a recombined Android application package in one embodiment;
[0076] Figure 2 This is a flowchart illustrating a method for generating a recombined Android application package in one embodiment;
[0077] Figure 3 This is a schematic diagram of a reconfiguration page in one embodiment;
[0078] Figure 4 This is a schematic diagram of reorganizing the configuration page in another embodiment;
[0079] Figure 5 This is a schematic diagram of a code file in one embodiment;
[0080] Figure 6 This is a schematic diagram of an array file in one embodiment;
[0081] Figure 7 This is a schematic diagram of an Android application package in one embodiment;
[0082] Figure 8 This is a schematic diagram illustrating the correspondence between updating the source function pointer and the running function pointer in one embodiment;
[0083] Figure 9 This is a flowchart illustrating the startup and execution method used in one embodiment;
[0084] Figure 10 This is a schematic diagram illustrating the update of the source function pointer in one embodiment;
[0085] Figure 11 This is a flowchart illustrating a method for generating a recombined Android application package in a specific embodiment.
[0086] Figure 12 This is a flowchart illustrating the startup and execution method used in a specific embodiment.
[0087] Figure 13 This is a flowchart illustrating the startup and execution method of a target application in one embodiment;
[0088] Figure 14 This is a schematic diagram illustrating the process of reassembling, launching, and running a target application in one embodiment;
[0089] Figure 15 This is a structural block diagram of a device for generating a recombined Android application package in one embodiment;
[0090] Figure 16 This is a structural block diagram of the startup and operation device used in one embodiment;
[0091] Figure 17 This is an internal structural diagram of a computer device in one embodiment;
[0092] Figure 18 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0093] 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.
[0094] The method for generating a recombined Android application package provided in this application embodiment can be applied to, for example, Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated on server 104 or placed on the cloud or other servers. Both terminal 102 and server 104 can be used independently to execute the method for generating a reconstructed Android application package provided in this embodiment. Terminal 102 and server 104 can also work together to execute the method for generating a reconstructed Android application package provided in this embodiment. Taking the example of terminal 102 and server 104 working together to execute the method for generating a reconstructed Android application package provided in this embodiment, the user can trigger terminal 102 to generate an application package reconstructing instruction and trigger terminal 102 to send the generated application package reconstructing instruction to server 104. When server 104 receives the application package reconstructing instruction, it determines the target application pointed to by the application package reconstructing instruction, obtains the application package and source code file of the target application, and reconstructs the application package using the source code file to obtain the reconstructed application package.
[0095] The terminal 102 can be, but is not limited to, various desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle systems. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. The server 104 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0096] In one embodiment, such as Figure 2 As shown, a method for generating a reassembled Android application package is provided. The method is illustrated using a computer device as an example, where the computer device is... Figure 1 The terminal or server in the process. The method for generating a reassembled Android application package includes the following steps:
[0097] S202, Obtain the source code file of the target application.
[0098] Source code files, also known as source program files, are uncompiled text files written according to specific programming language specifications. Android application packages can be generated from source code files. An Android application package refers to the application's installation package file; for example, in the Android system, an Android application package can be an APK (Android Package) file.
[0099] Specifically, when it is necessary to reassemble the application package of a target application, the computer device can obtain the source code files of the target application. The computer device can then execute these source code files to implement all the functionalities provided by the target application. The source code files include source array files and external files. The external files contain the specific implementation process of functions; for example, they contain the source code of functions, which includes all the code that implements the function's functionality. The source array files may contain the entry points of functions in the external files, allowing the computer device to access and execute these functions.
[0100] In one embodiment, the computer device may also obtain the original Android application package of the target application.
[0101] In one embodiment, the Android application package can be a compressed file, which includes at least dynamic link libraries, a signature file, resource files, and a resource index table. The resource index table records information about all application resource directories.
[0102] In one embodiment, the computer device may include an application package library. The computer device can determine the size of each Android application package in the application package library and filter out Android application packages whose size is greater than or equal to a preset size threshold. The application corresponding to the Android application package whose size is greater than or equal to the preset size threshold is selected as the target application. By determining the Android application packages whose size is greater than or equal to the preset size threshold, these Android application packages can be recombined to obtain a recombined Android application package with a smaller size, thereby reducing the download time of the Android application package.
[0103] In one embodiment, the computer device stores a mapping between application identifiers and Android application packages, as well as a mapping between application identifiers and source code files. When a target application is determined, the computer device can determine the target application identifier of the target application, and obtain the Android application package corresponding to the target application identifier based on the mapping between application identifiers and Android application packages, thereby obtaining the Android application package of the target application. The computer device can also obtain the source code file corresponding to the target application identifier based on the mapping between application identifiers and source code files, that is, obtain the source code file corresponding to the Android application package of the target application.
[0104] In one embodiment, when an application package reassembly instruction is received, the application package reassembly instruction is parsed to obtain at least one of a target application identifier, an application package storage path, and a file storage path; the target application is determined by the target application identifier; the Android application package of the target application is obtained by the application package storage path, and the source code file of the target application is obtained by the file storage path.
[0105] Specifically, when it is necessary to reassemble the application package, that is, when it is necessary to generate a reassembled application package, the user can trigger the terminal to generate an application package reassembly instruction and trigger the terminal to send the application package reassembly instruction to the server. When the server receives the application package reassembly instruction, the server can parse the application package reassembly instruction to obtain at least one of the following: target application identifier, application package storage path, and file storage path. Further, the server pre-stores multiple Android application packages and multiple source code files. When the target application identifier is obtained, the server can use the application corresponding to the target application identifier as the target application, obtain the Android application package of the target application according to the application storage path, and obtain the source code file of the target application according to the file storage path.
[0106] In one embodiment, the server uses the Android application package stored in the application storage path as the Android application package of the target application, and uses the source code file stored in the file storage path as the source code file of the target application. The application storage path can be a storage path in memory, and similarly, the file storage path can also be a storage path in memory.
[0107] In one implementation, the application package reassembly instruction may only carry the application package storage path and the file storage path, so that the server can obtain the Android application package of the target application according to the application package storage path and obtain the source code file of the target application according to the file storage path.
[0108] In the above embodiments, since the application package reassembly instruction carries the target application identifier, application package storage path and file storage path, the target application can be accurately determined based on the target application identifier, the Android application package of the target application can be accurately obtained based on the application package storage path, and the source code file of the target application can be accurately obtained based on the file storage path.
[0109] In one embodiment, the target application identifier is obtained by selecting from multiple candidate application identifiers in the reconfiguration page displayed on the terminal; the size of the candidate application package corresponding to the candidate application identifier is greater than or equal to a preset size threshold; the application package storage path is configured in the reconfiguration page; and the file storage path is configured in the reconfiguration page.
[0110] Specifically, users can generate application package reassembly commands through a reassembly configuration page displayed on the terminal. The reassembly configuration page can display multiple candidate application identifiers, allowing users to select the target application identifier. Furthermore, users can also configure the application package storage path corresponding to the target application identifier, as well as the file storage path corresponding to the target application identifier, through the reassembly configuration page. The terminal then generates the application package reassembly command based on the target application identifier, the application package storage path, and the file storage path.
[0111] In one embodiment, the server may store multiple Android application packages. The server determines the size of each Android application package and generates a correspondence between application package identifiers and application package sizes based on the determined sizes. This correspondence is then sent to the terminal. The terminal can determine application package identifiers whose sizes are greater than or equal to a preset size threshold based on this correspondence. These candidate application package identifiers are then displayed on the reconfiguration page. By displaying only candidate application package identifiers with sizes greater than or equal to the preset size threshold, instead of displaying all application package identifiers, the number of application package identifiers displayed on the reconfiguration page is reduced, making it easier for users to quickly identify the target application package identifier from the reduced number. Furthermore, by displaying only candidate application package identifiers with sizes greater than or equal to the preset size threshold, subsequent reconfiguration of excessively large Android application packages can be performed without reconfiguring excessively small ones, thus reducing the probability of reconfiguring unnecessary application packages.
[0112] In one implementation, reference Figure 3 , Figure 3 The diagram illustrates a reconfiguration page in one embodiment. The reconfiguration page may display product type options 301 and function type options 302. Users can trigger the display of corresponding candidate application identifiers 303 through these options. For example, when a user selects business type 2 and product type 1, the terminal can obtain multiple candidate application identifiers corresponding to business type 2 and product type 1, and display these multiple candidate application identifiers. The reconfiguration page may also display an application description 304 and an application manager 305, allowing users to select the target application identifier from multiple candidate application identifiers by combining the application description 304 and the application manager.
[0113] When the user selects the target application identifier, the reconfiguration page can be displayed as follows: Figure 4 As shown. Reference Figure 4 The reconfiguration page can display an application package storage path input box 401 and a file storage path input box 402 corresponding to the target application identifier. The user can then enter the application package storage path in the application package storage path input box and the file storage path in the file storage path input box. Furthermore, the reconfiguration page can also display a confirmation control 403. When the user clicks the confirmation control, the terminal can generate an application package reconfiguration command based on the target application identifier, application package storage path, and file storage path. Figure 4 This shows a diagram of another reconfiguration page.
[0114] In the above embodiments, by displaying the reorganization configuration page, users can freely select the Android application package to be reorganized and configure it, thereby greatly improving the flexibility of application package reorganization.
[0115] S304 determines the runtime type functions required by the target application in the source code file.
[0116] Specifically, when it's necessary to reassemble the Android application package of a target application—that is, when it's necessary to generate a reassembled Android application package—the computer device can iterate through the functions in the source code files to determine the runtime type functions that the target application needs to call at runtime. Runtime type functions are those functions that the application needs to call during runtime, ensuring the application runs correctly after startup. For example, if the target application displays page A upon startup, and users can navigate to pages B and C from page A, the computer device will use the functions required to display page B and page C as runtime type functions.
[0117] In one embodiment, a user can trigger a terminal to display source code files through a code editing application and view the displayed source code files to determine the execution type functions in the source code files.
[0118] In one embodiment, when a user obtains a runtime type function in a source code file through code walkthrough analysis, the user can mark the runtime type function so that the terminal can determine the runtime type function in the source code file based on the user's mark.
[0119] In one embodiment, the computer device can determine the business functions provided by the target application and identify the first business function that the target application can immediately provide upon startup. For example, if the target application is a game application and the game lobby is displayed immediately upon startup, the display of the game lobby can be considered the first business function provided by the game application. Once the first business function is determined, the computer device can determine the remaining business functions in the target application besides the first business function. For example, in the above example, when entering the game arena through the game lobby, the display of the game arena can be considered the remaining business functions provided by the game application. In this case, the computer device will use the functions that implement the remaining business functions as the runtime type functions.
[0120] In one embodiment, determining the runtime type functions required by the target application in the source code file includes: determining the startup page to be displayed when the target application starts; determining the jump page to which the target application jumps through the startup page based on the page jump logic between the pages displayed by the target application; and taking the functions to be called to display the jump page as the runtime type functions required by the target application.
[0121] Specifically, the computer device can determine the page to be displayed when the target application starts, and use this page as the startup page. When determining the startup page, the computer device can obtain the page navigation logic between the pages displayed by the target application, and determine the jump pages that can be navigated to through the startup page based on the page navigation logic. The jump pages that can be navigated to through the startup page can include pages that are directly navigated to and pages that are indirectly navigated to. For example, when the target application can provide pages A, B, and C, and page A can be used to navigate to page B, and page B to page C, then page A can be called the startup page. Since page A can be used to directly navigate to page B, page B is called a jump page. Since page A can be used to navigate to page B, and page B to page C, page A can be used to indirectly navigate to page C, and page C is also called a jump page. Furthermore, when determining the jump pages, the computer device can use the functions called to display the jump pages in the source code file as the runtime type functions required by the target application.
[0122] In one embodiment, the computer device can determine the launch page and redirect pages based on the services provided by the target application. The computer device will use the page required to display when implementing the homepage service function as the launch page, and the page required to display when implementing non-first service functions as the redirect pages. For example, in the above example, when it is determined that displaying the game lobby is the first service function provided by the target application, the computer device can use the page displaying the game lobby as the launch page. When entering the game arena through the game lobby, the computer device can use the page displaying the game arena as the redirect page. It is easy to understand that since implementing the homepage service function may require displaying a series of pages, the number of launch pages can be multiple.
[0123] In one embodiment, the computer device may determine all pages that the target application can display, as well as the launch page, and treat all pages except the launch page as jump pages, and treat the functions required to implement the jump pages as run type functions.
[0124] In one embodiment, the startup page and the page navigation logic between pages can be pre-set in the computer device, so that the computer device can determine the running type function through the pre-set information.
[0125] In one embodiment, the computer device can determine the execution type function by performing a code walkthrough on the source code file. For example, the source code file may include an HTML (HyperText Markup Language) file. The computer device can locate the HTML file corresponding to the preset launch page name. The computer device can traverse the code in the HTML file corresponding to the launch page to identify the page redirection code within that HTML file, and use the page redirection code to determine the redirect page to which the launch page will redirect, and then obtain the HTML file corresponding to the redirect page. Once the HTML file corresponding to the redirect page is obtained, the computer device can traverse the code in that HTML file to determine the function to be called when displaying the redirect page, and use the identified function as the execution type function.
[0126] In the above embodiments, the execution type function can be determined based on the page jump logic between each page, thereby improving the efficiency of determining the execution type function.
[0127] S206: Extract the runtime type functions from the source code file to obtain the remaining source code file after extraction, and generate additional CPP code files based on the extracted runtime type functions.
[0128] Specifically, since the source code file can implement all the functions provided by the target application, it includes startup type functions and runtime type functions. Startup type functions are the functions called when the application starts; they are used to launch the target application. Once the runtime type functions are determined, the computer device can extract them from the source code file, resulting in the remaining source code file and additional CPP code files. The additional CPP code files are the files required for application runtime; they provide the functions called during application startup, i.e., they provide the runtime type functions. CPP code files are code files written in the target language, such as source code files written in C++. The remaining source code file after extraction includes the startup type functions; therefore, the remaining source code file is the file required for application startup, providing the functions called during application startup, i.e., it provides the startup type functions.
[0129] In one implementation, the computer device can create an initial supplementary CPP code file and migrate the runtime type functions from the source code file to the created supplementary CPP code file, resulting in a supplementary CPP code file that includes the runtime type functions. When migrating the runtime type functions from the source code file to the created supplementary CPP code file, the source code file that does not contain the runtime type functions can be used as the remaining source code file after splitting.
[0130] S208, the logic for generating the additional CPP code file for download; the download logic is used to instruct the target application to download the additional CPP code file at runtime.
[0131] Specifically, when generating the additional CPP code file, the computer device can also generate download logic for the additional CPP code file. This allows the terminal to download the additional CPP code file when it runs the target application. For example, the computer device can generate the download logic based on the storage path of the additional CPP code file. This storage path can be a preset path or dynamically generated based on storage space usage.
[0132] S208, based on the remaining source code files and download logic after splitting, obtains the reassembled Android application package of the target application.
[0133] Specifically, once the remaining source code files after splitting are obtained, the computer device can use these files and the download logic to generate a reconstructed Android application package. For example, the computer device can package and compile the remaining source code files and the download logic to obtain a reconstructed Android application package.
[0134] In one embodiment, a reconstructed Android application package of the target application is generated based on the remaining source code files and download logic after splitting, including: obtaining the Android application package of the target application; the Android application package includes a source SO file generated based on the source code files; compiling the remaining source code files and download logic after splitting to obtain a target SO file; and replacing the source SO file in the Android application package with the target SO file to obtain the reconstructed Android application package.
[0135] Specifically, when it's necessary to reassemble an Android application package to obtain a reassembled Android application package, the computer device can compile the remaining source code files and download logic after splitting, obtaining a target SO file. This target SO file then replaces the source SO file in the Android application package, resulting in the reassembled Android application package. For example, the target application's Android application package includes a source SO file obtained by packaging and compiling the source code files. When the remaining source code files and download logic after splitting are obtained, the computer device can compile them to obtain a target SO file. This target SO file then replaces the source SO file in the application package, resulting in the reassembled application package. Here, compilation refers to the process of using a compiler to convert source code written in a source language into a target program. An SO file is a program function library under Linux, that is, compiled code and data that can be used by other programs.
[0136] In one implementation, the computer device can first package the remaining source code files after splitting into DLL files, and then package the DLL files into SO files. A DLL file is a library file, an executable file that allows programs to share code and other resources necessary to perform specific tasks. An SO file is a dynamic link library, a compiled file that includes compiled code and data that can be used by other programs.
[0137] In one embodiment, the Android application package can be a compressed file, such as a zip (a compressed file format). The computer device can decompress the Android application package to obtain the decompressed Android application package. The decompressed Android application package includes a source SO file. The computer device replaces the source SO file with the target SO file to obtain an uncompressed recombined Android application package. Further, the computer device recompresses the uncompressed recombined Android application package to obtain a recombined Android application package.
[0138] In one embodiment, when the reconstructed Android application package is obtained, the computer device can upload the reconstructed Android application package to the application download platform, so that the user can download the reconstructed Android application package from the application download platform and install the downloaded reconstructed Android application package.
[0139] Since the remaining source code files after splitting are derived from the split source code files, their file sizes will be smaller than the original source code files. Consequently, the target SO file generated from these remaining source code files will be smaller than the source SO file generated from the original source code files. Therefore, by replacing the source SO file in the application package with the target SO file, the size of the reassembled Android application package can be smaller than the original Android application package, thus achieving the goal of reducing the Android application package size. Reducing the size of the Android application package can reduce the upload time required to upload it to the application download platform. Furthermore, since application download platforms stipulate that the size of the Android application package cannot exceed a preset size threshold, reducing the size of the Android application package can also ensure successful upload, thereby increasing the success rate of uploading the Android application package to the application download platform.
[0140] In one embodiment, since the remaining source code files after splitting include startup type functions, which are functions called when the application starts, the remaining source code files can be used to start the application. When the source SO file is replaced with the target SO file generated based on the remaining source code files to obtain a reconstructed Android application package, the terminal can install the reconstructed Android application package and start the target application through the target SO file in the reconstructed Android application package after successful installation. Since the additional CPP code file includes runtime type functions, which are functions called when the application runs, the additional CPP code file can be used to run the application. Therefore, the terminal can combine the reconstructed Android application package and the additional CPP code file to run the target application. For example, the reconstructed Android application package may also include authentication certificates and other information, and the terminal can run the target application based on the authentication certificate and the additional SO file generated by the additional CPP code file. Since the reassembled Android application package can be used to install and launch the target application, while the original Android application package can be used to install, launch, and run the target application, the size of the reassembled Android application package will be smaller than that of the original Android application package, even with fewer functions provided, thus achieving the goal of reducing the size of the Android application package.
[0141] In the above-described method for reassembling application packages, by obtaining the target application's source code file, the runtime type function within the source code file can be determined. By determining the runtime type function, the source code file can be split using this function, yielding the additional CPP code files required to run the target application and the remaining source code files required to launch the target application. By obtaining the remaining source code files, a reassembled Android application package can be generated based on the download logic of the remaining source code files and the additional CPP files. Since the remaining source code files are obtained by splitting the source code file, their size will be smaller than the original source code file, and the size of the reassembled Android application package generated from the remaining source code files will be smaller than the size of the Android application package generated from the original source code file. By reducing the size of the reassembled Android application package, the download time can be reduced, thereby improving the download efficiency of the Android application package. Furthermore, when the size of the Android application package is reduced, the time required to install the Android application package can also be reduced, thereby improving the installation efficiency of the Android application package.
[0142] Furthermore, reducing the size of the Android application package decreases the installation time, thereby improving installation efficiency. This embodiment is completely transparent to business developers, who can complete the source code splitting without writing additional code. Moreover, when the target application is a game, this embodiment does not intrude on the game engine, allowing it to maintain its original working logic and thus improving game stability.
[0143] In one embodiment, splitting the runtime type function from the source code file to obtain the remaining source code file after splitting includes: creating an empty function corresponding to the runtime type function; updating the source code file based on the empty function to obtain the remaining source code file after splitting.
[0144] Specifically, when the runtime type function is obtained, the computer device can generate corresponding additional CPP code files based on the runtime type function. For example, the file structure of the additional CPP code file can be consistent with the file structure of the source code file, so the computer device can refer to the components of the source code file and generate the additional CPP code file through the runtime type function. Furthermore, the computer device can also create empty functions corresponding to each runtime type function and update the runtime type functions in the source code file to empty functions, obtaining the remaining source code file after splitting. Here, an empty function refers to a function that is only defined without writing local variables and specific function body statements.
[0145] In one embodiment, the computer device may refer to the components of the source code file and generate an additional CPP code file by running a type function. For ease of description, the external files included in the unsplit source code file will be referred to as source external files, the external files included in the additional CPP code file will be referred to as runtime external files, and the external files included in the remaining split source code file will be referred to as startup external files. Further, refer to... Figure 5 When the source code file includes source array files and source external files, the corresponding generated additional CPP code files can also include runtime array files and runtime external files. The source external files contain runtime type functions and startup type functions, while the source array files can contain the entry addresses of the functions in the source external files, allowing the computer to access the functions in the source external files through the source array files. Similarly, the runtime external files can contain runtime type functions, and the runtime array files can contain the entry addresses of the runtime type functions, allowing the runtime array files to serve as the entry points for the runtime type functions. By dividing the code into array files and external files, the coupling between code segments can be reduced.
[0146] In one embodiment, the computer device can directly use the source external file containing the execution type function as the execution external file. It is readily understood that since the remaining source code file after splitting is obtained by updating the source code file, when the source code file includes both the source array file and the source external file, reference... Figure 5 The remaining source code files after splitting also include the updated source array file and the startup external file. The startup external file may contain startup type functions, and the updated source array file may contain the entry addresses of the startup type functions, allowing the computer device to enter the startup type functions through the updated source array file. The computer device can directly use the source external file containing the startup type functions as the startup external file. Figure 5 A schematic diagram of a code file in one embodiment is shown.
[0147] In the above embodiments, by obtaining the runtime type function, an additional CPP code file can be generated based on the runtime type function, and the target application can then be run based on the additional CPP code file. Furthermore, since the remaining source code file after splitting can be obtained simply by updating the source code file based on the created empty function, the generation process of the remaining source code file after splitting is simplified compared to regenerating a new one, thereby improving the generation efficiency of the remaining source code file after splitting.
[0148] In one embodiment, generating an additional CPP code file based on the split runtime type function includes: creating an initial function array; the initial function array includes multiple runtime function pointers; pointing each runtime function pointer to the corresponding runtime type function to obtain a runtime function array, and generating a runtime array file based on the runtime function array; and generating an additional CPP code file based on the runtime array file and the runtime type function.
[0149] Specifically, the additional CPP code file to be generated may include a runtime array file and a runtime external file. The runtime array file may include an array of runtime functions. When a runtime function array needs to be generated, the computer device may create an initial function array, which may include multiple runtime function pointers. These pointers describe the location of data in memory; pointers are generally pointer variables that store the starting address of the object they point to. Further, when generating the initial function array, the computer device may point the runtime function pointers in the initial function array to runtime type functions, thus transforming the initial function array into a runtime function array when a runtime function pointer points to a runtime type function. Once the runtime function array is obtained, the computer device can generate a runtime array file from it, and then generate an additional CPP code file based on the runtime array file and runtime type functions, for example, based on the runtime array file and a runtime external file storing runtime type functions.
[0150] In one embodiment, the source code file may also include a source array file and a source external file. The source array file includes a source function array, which contains source function pointers that point to functions in the source external file. Since the source external file may contain startup type functions and runtime type functions, the source function pointers may point to either a runtime type function or a startup type function. When launching and running a target application based on an unreassembled Android application package, when the target application needs to be launched, the computer device can call a startup type function in the source external file through one of the source function pointers in the source function array; when the target application needs to be run, the computer device can call a runtime type function in the source external file through another source function pointer in the source function array.
[0151] In the above embodiments, since the attached CPP code file includes a pointer to a runtime function and the runtime function itself, the runtime function can be invoked by calling the pointer, thereby enabling the target application to run. Furthermore, by pointing the runtime function pointer to the runtime function and invoking the runtime function through the pointer, the coupling of the code can be reduced.
[0152] In one embodiment, there is a one-to-one correspondence between the running function pointer and the running type function; the function identifier of the running type function is determined, and the value of the running function pointer is set to the corresponding function identifier of the running type function to obtain the running function array.
[0153] Specifically, the computer device can determine the number of runtime functions and create an initial function array based on that number. The initial function array contains the same number of runtime function pointers as the number of runtime functions, allowing each runtime function pointer to point to a specific runtime function. When a runtime function pointer needs to point to a runtime function, the computer device can determine the function identifier of the runtime function and use that identifier as the value of the runtime function pointer. The function identifier uniquely identifies a runtime function; for example, it could be the address of the runtime function.
[0154] In one embodiment, since the number of function pointers is the same as the number of function types, the function types can be sorted to obtain a sequence of function types. The computer device then points the function pointers to the corresponding function types according to the order of the function pointers in the function array and the order of the function types in the sequence of function types. For example, the computer device points the function pointers to function types with the same order.
[0155] In one embodiment, when a function is defined in a program, its source code is converted into executable code and a memory space is allocated during compilation. This memory space has a starting address, also known as the function address. The function name represents the function address. When a function is called, its address is obtained through the function name, and the function code is executed. Therefore, the function address can specifically be the function name, and assigning the function name of the runtime function to the runtime function pointer allows the function pointer to point to the corresponding function. Furthermore, since the source function pointer in the source code file can point to a runtime function, the value of the source function pointer can be the function name of the runtime function. Therefore, the computer device can determine the value of the runtime function pointer based on the value of the source function pointer. For example, refer to... Figure 6 When a user identifies a runtime function in a source code file through code review, the user can input the function name of the runtime function into the computer device. The computer device can then determine the source function pointers in the source function array that point to the runtime function based on the input function name. When it is necessary to generate a runtime function array, the computer device can use the values of the source function pointers in the source function array as the values of the runtime function pointers in the runtime function array to obtain the runtime function array. Figure 6A schematic diagram of an array file is shown in one embodiment.
[0156] In the above embodiments, simply setting the value of the running function pointer to a function of the running type function is sufficient to make the running function pointer point to the running type function.
[0157] In one embodiment, generating a runtime array file based on a runtime function array includes: for each runtime function pointer in the runtime function array, creating a runtime external declaration corresponding to the current runtime function pointer; generating a runtime array file based on the runtime function array and the runtime external declaration; the runtime external declaration is used to declare that the runtime type function pointed to by the runtime function pointer is located outside the runtime array file; and generating an additional CPP code file based on the runtime array file and the runtime type function declared by the runtime external declaration.
[0158] Specifically, when generating the runtime function array, for each runtime function pointer in the array, a runtime external declaration corresponding to the current runtime function pointer is created, and a runtime array file is generated using the runtime external declarations and the runtime function array. The runtime external declarations declare that the runtime type functions pointed to by the runtime function pointers are located outside the runtime array file. By declaring runtime type functions, they can be used across files. Furthermore, when generating the runtime array file, the computer device can generate an additional CPP code file based on the runtime array file and the runtime type functions declared in the runtime external declarations.
[0159] In this embodiment, by generating an external declaration of the runtime, the declared runtime type function can be used across files, thereby improving the calling flexibility of the runtime type function.
[0160] In one embodiment, the source code file includes a source array file; the source array file includes a source function array; the source function array includes multiple source function pointers; updating the source code file based on empty functions to obtain the remaining source code file after splitting includes: determining the target source function pointer in the source function array that points to a function of execution type; changing the target source function pointer from pointing to a function of execution type to pointing to an empty function to obtain an updated source function array, and obtaining an updated source array file based on the updated source function array; obtaining the remaining source code file after splitting based on the updated source array file and the function pointed to by the updated source function pointer in the updated source function array.
[0161] Specifically, when creating an empty function corresponding to a runtime type function and needing to generate the remaining source code file after splitting, the computer device can determine the target source function pointer in the source function array that points to the runtime type function, and change the target source function pointer from pointing to the runtime type function to pointing to the empty function, thus obtaining an updated source function array. That is, the computer device updates the function identifiers of the runtime type functions in the source function array using the function identifiers of the empty functions, obtaining an updated source function array, and uses the source array file containing the updated source function array as the updated source array file. Therefore, the computer device can obtain the remaining source code file after splitting using the updated source array file and the empty function.
[0162] In the above embodiments, since the remaining source code files after splitting include an updated source array file for entering the startup type function and a startup type function for starting the target application, the generated remaining source code files after splitting can be used to start the target application normally.
[0163] In one embodiment, the target source function pointer in the source function array that points to a function of execution type is determined; the target source function pointer is changed from pointing to a function of execution type to pointing to an empty function to obtain the updated source function array, and the updated source array file is obtained based on the updated source function array.
[0164] Specifically, the source function array includes multiple source function pointers, which can point to either startup type functions or runtime type functions. When the runtime type function required by the target application in the source code file is determined, the computer device can determine the target source function pointer in the source function array that points to the runtime type function. For example, when the runtime type function required by the target application in the source code file is determined, the computer device can obtain the function name of the runtime type function, and thus the computer device uses the source function pointer whose value is the function name of the runtime type function as the target source function pointer. Further, the computer device changes the target source function pointer from pointing to a runtime type function to pointing to an empty function. When the target source function pointer is changed from pointing to a runtime type function to pointing to an empty function, the source function array is also changed to the updated source function array, and the source array file is also changed to the updated source array file. For example, see reference... Figure 6 When both source function pointer 2 and source function pointer 3 in the source function array point to a function of the running type, the computer device can set source function pointer 2 to point to an empty function to obtain updated source function pointer 2, and set source function pointer 3 to point to an empty function to obtain updated source function pointer 3.
[0165] In this embodiment, the updated source array file is obtained by updating the target source function pointer within the original source array file. Compared to regenerating a completely new updated source array file, this embodiment maintains the overall structure of the updated source array file, thereby reducing the probability of code errors due to structural changes and improving the success rate of generating the updated source array file. Furthermore, obtaining the updated source array file through simple pointer updates also improves the efficiency of generating the updated source array file.
[0166] In one embodiment, the target source function pointer is changed from pointing to a runtime type function to pointing to an empty function to obtain an updated source function array. This includes: for each target source function pointer, determining the empty function corresponding to the current runtime type function pointed to by the current target source function pointer according to the correspondence between runtime type functions and empty functions; and changing the value of the current target source function pointer to the function identifier of the empty function corresponding to the current runtime type function.
[0167] The function identifier of an empty function refers to the information that identifies an empty function. Specifically, the function identifier of an empty function can be the address of the empty function, or the name of the empty function.
[0168] Specifically, when a computer device creates an empty function corresponding to each runtime type function, it can determine the correspondence between the runtime type function and the empty function, thus obtaining the first correspondence. For example, when creating an empty function `method_2_cusmain` corresponding to the runtime type function `method_2`, it can be determined that `method_2` corresponds to `method_2_cusmain`. When it is necessary to point the target source function pointer in the source function array to an empty function, for each of the multiple target source function pointers, the computer device can determine the empty function corresponding to the current runtime type function pointed to by the current source function pointer, based on the correspondence between the runtime type function and the empty function. For example, when the current target source function pointer P[2] points to the running type function method_2, the empty function corresponding to the running type function method_2 can be determined as method_2_cusmain according to the correspondence between the running type function and the empty function. Thus, the computer device changes the value of the current target source function pointer from method_2 to method_2_cusmain, that is, changes P[2] = method_2 to P[2] = method_2_cusmain. In this way, the target source function pointer is changed from pointing to the running type function to pointing to the empty function.
[0169] In this embodiment, the target source function pointer can be changed from pointing to a runtime type function to pointing to an empty function simply by changing the value, thereby improving the efficiency of pointer modification.
[0170] In one embodiment, when the target source function pointer in the source function array is changed from pointing to a runtime function to pointing to an empty function, the source function array is updated, the source function pointers in the source function array are updated, and the source array file is updated. The computer device then obtains the remaining source code file after splitting using the updated source array file, the startup function pointed to by the updated source function pointer, and the empty function. Since the updated source function pointer in the updated source array file can point to either a startup function or an empty function, and since an empty function is a function without any implementation code, the file size of the remaining source code file after splitting is smaller than the file size of the source code file generated using the source array file, runtime function, and startup function. This reduces the size of the recombined application package generated based on the remaining source code file. Furthermore, since the updated source function pointer in the remaining source code file can point to a startup function, the target application can be started normally using the remaining source code file.
[0171] In one embodiment, the source array file may include a source function array and corresponding external declarations. The external declarations corresponding to the source function array declare that the functions pointed to by the source function pointers are located outside the source array file. That is, the external declarations corresponding to the source function array indicate that the runtime type functions and startup type functions are located in external source files outside the source array file. Therefore, when the source array file is changed to an updated source array file, the resulting updated source array file also includes the updated source function array and corresponding startup external declarations. The startup external declarations corresponding to the updated source function array declare that the startup type functions are located in files outside the updated source array file.
[0172] In one embodiment, generating an additional CPP code file based on the split runtime type function includes: copying the source array file to obtain a copied array file; the copied array file includes a copied function array; the copied function array includes copied function pointers; deleting copied function pointers from the copied function pointers except those pointing to runtime type functions to obtain a remaining copied function array after deletion; using the copied array file including the remaining copied function array after deletion as the runtime array file, and generating an additional CPP code file based on the runtime array file and the runtime type function.
[0173] Specifically, a computer device can copy a source array file to obtain a copied array file. The function array in the copied array file is called a copied function array; the function pointers in the copied function array are called copied function pointers. The computer device can delete all copied function pointers from the source function array except those pointing to runtime functions, retaining only the copied function pointers pointing to runtime functions, to obtain a runtime function array. Based on this runtime function array, a corresponding additional CPP code file can be generated.
[0174] In one embodiment, when the computer device deletes the copy function pointer pointing to the startup type function, it may also delete the external declaration of the startup type function in the copy array file.
[0175] In one embodiment, the computer device may also change the name of the copy function array and the name of the copy array file.
[0176] In the above embodiments, since the additional CPP code file can be obtained simply by modifying the copied array file, the generation efficiency of the additional CPP code file is also improved.
[0177] In one embodiment, the remaining source code files after splitting are compiled to obtain a target SO file; the Android application package is then reassembled using the target SO file to obtain a reassembled Android application package.
[0178] Specifically, when the remaining source code files after splitting are obtained, since these files contain code written in a source code language that cannot be recognized by the computer system, they need to be compiled to produce a file that the computer system can recognize. For example, the computer device compiles the remaining source code files to obtain compiled source code files, which are then used as the target SO file. Once the target SO file is obtained, the computer device can use it to reassemble the Android application package, resulting in a reassembled Android application package. For instance, the computer device can package the target SO file into an Android application package to obtain a reassembled Android application package.
[0179] In this embodiment, by compiling the remaining source code files after splitting, a file that can be recognized by the computer system can be obtained. Since the Android application package is reassembled using a target SO file that the computer system can recognize, the computer system can identify the reassembled Android application package, thereby obtaining a target application that can be installed and launched normally through the reassembled Android application package.
[0180] In one embodiment, the Android application package includes a source SO file; the identifier of the source SO file is consistent with the identifier of the target SO file; the Android application package is reassembled using the target SO file to obtain a reassembled Android application package, including determining the source SO file in the Android application package based on the identifier of the target SO file; and replacing the source SO file in the Android application package with the target SO file to obtain the reassembled Android application package.
[0181] Specifically, the identifier of the generated target SO file can be the same as the identifier of the source SO file generated based on the source code file. Therefore, when the target SO file is generated, the computer device can locate the source SO file from the Android application package of the target application based on the identifier of the target SO file and replace the source SO file with the target SO file. When the target SO file replaces the source SO file, the Android application package of the target application is changed to a reconstructed Android application package. The identifier of the dynamic link library can be the library name of the dynamic link library, so the library name of the target SO file can be the same as the library name of the source SO file. For example, both the library name of the target SO file and the library name of the source SO file can be MethodPointerTable.CPP.
[0182] In one embodiment, since the remaining source code files after splitting are obtained by updating the source code files, the file name of the remaining source code files after splitting can be the same as the file name of the source code files. Therefore, the identifier of the target SO file generated based on the remaining source code files after splitting can be the same as the identifier of the source SO file generated based on the source code files.
[0183] In one embodiment, reference Figure 7 When an Android application package includes files such as SO files, signature files, resource files, and resource index tables, the computer device can replace the source SO file in the target application's Android application package with the target SO file, thereby obtaining a reconstructed application package. Figure 7 A schematic diagram of an Android application package in one embodiment is shown.
[0184] In the above embodiments, since the identifier of the source SO file is consistent with the identifier of the target SO file, the source SO file in the Android application package can be quickly found based on the consistent identifier, thereby improving the reorganization efficiency of the Android application package based on the quickly found source SO file.
[0185] In one embodiment, the method further includes an application startup and execution step, which includes: when launching a target application obtained by installing and reassembling an Android application package, obtaining a target SO file stored locally and generated based on the remaining source code files after splitting; launching the target application using the target SO file; when running the target application, obtaining an additional SO file generated based on the additional CPP code files; updating the target SO file using the additional SO file to obtain an updated SO file, and running the target application using the updated SO file.
[0186] Specifically, when the server obtains the reconstructed Android application package, it can send the package to the terminal, allowing the terminal to decompress and install it to obtain the target application. During installation, the target SO file is stored locally. When the user is determined to launch the target application, the terminal can obtain the target SO file generated from the remaining source code files after splitting, and launch the application using the target SO file. An SO file is a special type of object file that can be loaded (linked) at runtime. Using SO files makes the executable file smaller, facilitates modularization and updates, and effectively improves memory usage efficiency. Simply put, the dynamic link library compiled from the remaining source code files after splitting is called the target SO file, and the dynamic link library compiled from the additional CPP code files is called the additional SO file.
[0187] Once the target application starts, the terminal can determine whether an additional SO file generated by attaching the CPP code file exists locally. If the additional SO file does not exist, it downloads the additional SO file from the server, updates the target SO file with the additional SO file to obtain an updated SO file, and runs the target application with the updated SO file.
[0188] In this embodiment, by prioritizing the sending of the reassembled Android application package required for installing and launching the target application to the terminal, the download and installation time of the target application can be reduced. By sending an additional SO file to the terminal after the target application starts, the terminal can ensure the target application runs normally using the additional SO file.
[0189] In one embodiment, the updated SO file is obtained by updating the target SO file based on the function mapping file and by attaching an SO file; the target SO file includes an updated source function array; the updated source function array includes updated source function pointers; the attached SO file includes a run function array; the run function array includes run function pointers; the step of generating the function mapping file includes: determining the updated source function pointer corresponding to each run function pointer in the run function array, obtaining the correspondence between the run function pointers and the updated source function pointers; and generating the function mapping file based on the correspondence between the run function pointers and the updated source function pointers.
[0190] Specifically, the reassembled Android application package may also include function mapping files. The terminal can update the target SO file using these function mapping files and by attaching an SO file. Function mapping files can be generated when splitting the source code files. When generating function mapping files, the computer device can obtain the remaining source code files and attached CPP code files after splitting, and determine the updated source function array in the remaining source code files and the run function array in the attached CPP code files. Further, the run function array may include run function pointers, and the updated source function array may include updated source function pointers. The computer device determines the updated source function pointer corresponding to each run function pointer in the run function array, obtaining the correspondence between run function pointers and updated source function pointers, and generates the function mapping file based on this correspondence. For example, the computer device may use the correspondence between run function pointers and updated source function pointers as the content of the function mapping file.
[0191] In one embodiment, when the correspondence between the running function pointer and the updated source function pointer is obtained, the computer device determines the first position information of the running function pointer in the running function array and the second position information of the corresponding updated source function pointer in the updated source function array. The computer device binds the first position information and the second position information to obtain a function mapping file. Specifically, the position information can be the order in which the function pointers are arranged in the function array. For example, when the running function pointer at the beginning of the running function array corresponds to the updated source function pointer at the second position in the updated source function array, the first position in the running function array can be bound to the second position in the updated source function array.
[0192] In one embodiment, when the function mapping file is obtained, the computer device can also compile the function mapping file and the remaining source code files after splitting together to obtain the target SO file, and then generate a recombined application package based on the target SO file.
[0193] In one embodiment, when the function mapping file and the remaining source code file after splitting are obtained, the computer device can compile the function mapping file and the remaining source code file after splitting respectively to obtain the compiled function mapping file and the target SO file, and reassemble the Android application package through the target SO file to obtain the reassembled Android application package, and then package the compiled function mapping file into the reassembled Android application package.
[0194] In the above embodiments, by determining the correspondence between the running function pointer and the updating source function pointer, the target application can be run based on this correspondence.
[0195] In one embodiment, determining the update source function pointer corresponding to each running function pointer in the running function array includes: for each running function pointer in the running function array, determining the empty function corresponding to the current running function pointer based on the correspondence between running type functions and empty functions; determining the target update source function pointer in the updated source function array; the target update source function pointer is the update source function pointer pointing to the empty function corresponding to the current running function pointer; and using the target update source function pointer as the function pointer corresponding to the current running function pointer.
[0196] Specifically, when generating the remaining source code files after splitting, the computer device creates an empty function corresponding to each runtime function type. Therefore, a correspondence between runtime function types and empty functions is established. Based on this correspondence, the computer device can determine the correspondence between runtime function pointers and update source function pointers. When determining the correspondence between runtime function pointers and update source function pointers, for each runtime function pointer in the runtime function array, the computer device determines the empty function corresponding to the current runtime function pointer based on the correspondence between runtime function types and empty functions. Since some update source function pointers in the updated source function array are set to point to empty functions when generating the remaining source code files after splitting, the computer device uses the empty function corresponding to the current runtime function pointer as the target update source function pointer and sets it as the function pointer corresponding to the current runtime function pointer.
[0197] In one embodiment, reference Figure 8The computer device can determine the empty function corresponding to each running function pointer in the running function array, and determine the empty function pointed to by each updated source function pointer in the updated source function array, and treat the running function pointers and updated source function pointers corresponding to the same empty function as a pair of corresponding function pointers. For example, when the running function pointer C[n] corresponds to the empty function n, and the updated source function pointer P[n] points to the empty function n, C[n] and P[n] can be treated as a pair of corresponding function pointers. Figure 8 A schematic diagram illustrating the correspondence between the running function pointer and the updating source function pointer in one embodiment is shown.
[0198] In one embodiment, when the correspondence between the running function pointer and the update source function pointer is determined, the computer device can record the correspondence between the running function pointer and the update source function pointer in a function mapping file, for example, record C[0] = P[1] in the function mapping file.
[0199] In the above embodiments, by using an empty function as a basis, the corresponding update source function pointer for each running function pointer can be quickly obtained, thereby improving the efficiency of determining the correspondence between the running function pointer and the update source function pointer.
[0200] In one embodiment, determining the update source function pointer corresponding to each running function pointer in the running function array includes: for each running function pointer in the running function array, performing similarity matching between the value of the current running function pointer and the value of the update source function pointer to obtain a similarity matching result; and taking the update source function pointer with a similarity greater than or equal to a preset similarity threshold as the function pointer corresponding to the current running function pointer.
[0201] Specifically, when an empty function is created, the name of the corresponding empty function can be obtained based on the name of the function of the running type, and the value of the corresponding update source function pointer can be obtained based on the name of the empty function. For example, when the name of the running type function is method_2, the name of the empty function corresponding to this running type function can be method_2_cusmain, and the value of the update source function pointer pointing to this empty function in the updated source function array can be method_2_cusmain. Furthermore, when it is necessary to determine the update source function pointer corresponding to the running function pointer, the value of the running function pointer and the value of the update source function pointer can be matched for similarity, and the correspondence between the running function pointer and the update source function pointer can be obtained based on the similarity matching result. Here, the value of the pointer refers to the value assigned to the pointer. For example, when pointer p[0] = method_1, method_1 is the value of pointer p[0].
[0202] In one embodiment, the computer device can determine the value corresponding to each updated source function pointer in the updated source function array, and for each running function pointer in the running function array, determine the value of the current running function pointer, and perform similarity matching between the value of the current running function pointer and the value of each updated source function pointer to obtain a matching result. Further, the computer device can obtain a preset similarity threshold, and take the updated source function pointers with similarity greater than or equal to the preset similarity threshold as the function pointers corresponding to the current running function pointer. For example, when the updated source function array is {p[0] = method_1, p[1] = method_2_cusmain}, and the current running function pointer is C[0] = method_2, the computer device can perform similarity matching between method_2 and method_1 and method_2_cusmain respectively, and based on the similarity matching result, obtain the updated source function pointer corresponding to the current running function pointer C[0] as p[1].
[0203] In the above embodiments, since only similarity matching is needed to determine the second correspondence, the efficiency of determining the correspondence between the running function pointer and the updated source function pointer is also improved.
[0204] In one embodiment, such as Figure 9 As shown, a method for starting and running an application is provided, which is applied to... Figure 1 Taking the terminal as an example, the method for starting and running the application includes the following steps:
[0205] S902, when launching the target application obtained by installing and reassembling the Android application package, obtain the target SO file stored locally during the installation process of the target application, wherein the target SO file is generated based on the remaining source code files after splitting.
[0206] Specifically, when a user wants to use the target application, the user can download the reconstructed Android application package of the target application through the terminal, trigger the terminal to install the downloaded reconstructed Android application package, and display the application icon of the target application after the reconstructed Android application package is installed. The user can launch the target application through the application icon. When the terminal confirms that the user clicks the application icon, the terminal can obtain the target SO file copied from the reconstructed Android application package to the local machine during the installation of the target application, and launch the target application through the target SO file.
[0207] In one embodiment, since the target SO file is packaged into the reassembled Android application package when it is generated, the terminal can launch the target application by using the target SO file in the reassembled Android application package when the target application needs to be determined.
[0208] In one embodiment, the terminal can obtain the target SO file through its storage path and launch the target application through the first dynamic library. The storage path of the target SO file can be pre-set within the reassembled Android application package.
[0209] In one embodiment, when a target application obtained by installing and reassembling an Android application package is launched, obtaining the target SO file generated from the remaining source code files after splitting in the reassembly Android application package includes: initializing the application process in response to a launch command for the target application; and obtaining the target SO file in the reassembly Android application package through the application process and according to a preset identifier of the target SO file.
[0210] Specifically, when a user clicks the application icon, the terminal can generate a launch command and, in response to this command, initialize the application process. Furthermore, the terminal can obtain the target SO file through the application process and based on a preset identifier for the target SO file. The identifier for the target SO file can specifically be the storage path of the target SO file.
[0211] In one embodiment, the name of the target SO file can be the same as the name of the source SO file. Therefore, when generating a reconstructed Android application package, only the source SO file in the application package needs to be replaced with the target SO file, without changing the rest of the application package. Furthermore, when using the reconstructed Android application package, the target SO file can be invoked based on a pre-set identifier of the source SO file. This identifier can specifically be a name.
[0212] In the above embodiments, by initializing the application process, the target SO file can be obtained through the application process, so that the target application can be launched based on the target SO file in the future.
[0213] S904, Start the target application via the target SO file.
[0214] Specifically, when the target SO file is obtained, the terminal can obtain the startup type function in the target SO file and initialize the startup type function to start the target application based on the initialized startup type function.
[0215] In one embodiment, the target SO file includes an updated array of source functions; launching the target application via the target SO file includes: calling an updated source function pointer in the updated array of source functions, and determining the launch type function pointed to by the called updated source function pointer; launching the target application via the launch type function pointed to by the called updated source function pointer.
[0216] Specifically, the reassembled Android application package can contain the calling code for startup type functions. When the target application needs to be launched, the terminal can run the calling code copied locally from the reassembled application package, and then call the updated source function pointers in the updated source function array based on the calling code. For example, if startup type functions 1 through 10 need to be called sequentially during the launch of the target application, the terminal can call the updated source function pointers in the updated source function array sequentially to achieve the sequential calling of startup type functions 1 through 10, and launch the target application through the sequentially called startup type functions.
[0217] In one embodiment, when the terminal calls the update source function pointer, since the value of the update source function pointer is the address of the startup type function, the terminal can find the startup type function based on the address of the startup type function and run the startup type function.
[0218] In the above embodiments, by calling the update source function pointer, the startup type function can be called based on the update source function pointer, thereby achieving the purpose of starting the target application through the startup type function.
[0219] S906: When running the target application, obtain the additional SO file generated based on the additional CPP code file.
[0220] Specifically, when the target application needs to be run after it has been launched, the terminal can determine whether an additional SO file exists locally and obtain it from the server. This server can be the background server of the target application, and the additional SO file refers to a dynamic link library obtained by compiling an additional CPP code file. In one embodiment, the terminal can obtain the additional SO file after confirming that the target application has successfully started, during the startup process of the target application, or when it determines that the user has triggered the command to run the target application.
[0221] In one embodiment, when the target application is run, obtaining an additional SO file generated based on the additional CPP code file includes: in response to the run command for the target application, determining whether an additional SO file exists locally; if no additional SO file exists, generating a download command according to the download logic of the attached SO file and sending the download command; the sent download command is used to trigger the server to return the additional SO file.
[0222] Specifically, after the terminal launches the target application, the user can trigger a running operation for the target application, and the terminal generates a running command based on the user's operation. For example, when the target application is a game application and it is launched, the terminal can display the game application loading page and display a "Enter Game" control when the game application is fully loaded. The user can enter the game by clicking the "Enter Game" control, and the terminal can generate a running command in response to the user's click operation. Further, in response to this running command, the terminal can determine whether an additional SO file exists locally. If the additional SO file does not exist locally, the terminal obtains the download logic for the additional SO file, that is, the download logic for the additional CPP code file, and generates a download command based on the download logic. The terminal sends this download command to the server to retrieve the additional SO file from the server. The terminal can then enter the game application and display the game application's homepage through the downloaded additional SO file. In one embodiment, when an additional SO file exists locally, the terminal can directly run the target application based on the additional SO file.
[0223] In the above embodiments, by obtaining the additional SO file from the server only when it does not exist locally, unnecessary acquisition processes can be reduced, thereby saving computer resources consumed in downloading the additional SO file from the server.
[0224] S908 updates the target SO file by attaching the SO file, obtains the updated dynamic link library, and runs the target application by updating the dynamic link library.
[0225] Specifically, when the additional SO file is obtained, the terminal can update the empty functions in the target SO file through the run type functions in the additional SO file, thereby obtaining the updated SO file, and then running the target application by updating the SO file.
[0226] In one embodiment, since there is a one-to-one correspondence between runtime functions and empty functions, when the attached SO file is obtained, for each of the multiple runtime functions, the terminal updates the corresponding empty function using the current runtime function. For example, the terminal replaces the corresponding empty function with the current runtime function and uses the function name of the current runtime function as the value of the update source function pointer pointing to the corresponding empty function.
[0227] In the above embodiments, when starting the target application, by obtaining the target SO file generated from the remaining source code files after splitting, the target application can be started based on the startup type function in the target SO file. When running the target application, by obtaining the additional SO file generated from the additional CPP code files, the target SO file can be updated based on the run type function in the additional SO file, resulting in an updated SO file including the run type function. The target application can then be run based on the updated SO file including the run type function, thus achieving the startup and running of the target application.
[0228] In one embodiment, the method further includes: playing a startup animation when the target application is launched via the target SO file; displaying the homepage when the playback duration of the startup animation reaches a preset duration; and generating a running instruction for the target application in response to a page navigation operation on the homepage.
[0229] Specifically, when a terminal launches a target application via a target SO file, it can play a preset launch animation. During the animation playback, it loads the files required to launch the target application and initializes the launch type function, then launches the application using the loaded files and initialized launch type function. When the launch animation's playback duration reaches the preset duration, the application is considered successfully launched. At this point, the terminal can display a launch page, such as a homepage with an option to enter the game. When a user wants to navigate to a jump page from the homepage—for example, to enter the game from the game's homepage—the user can click the "Enter Game" control on the homepage. The terminal then interprets the user's click as a page jump operation for the homepage and generates a run command in response.
[0230] In one embodiment, the terminal may display the startup page after the startup animation has finished playing.
[0231] In the above embodiments, by displaying the startup page for running the target application only after the startup animation has played for a preset duration, the probability of the homepage not being displayed properly due to insufficient loading time can be reduced, thereby improving the success rate of homepage display and thus improving the success rate of generating running instructions.
[0232] In one embodiment, the target SO file includes an updated source function array; the updated source function array includes updated source function pointers; the appended SO file includes a running function array; the running function array includes running function pointers; updating the target SO file using the appended SO file to obtain an updated SO file includes: obtaining a preset function mapping file, and determining the correspondence between updated source function pointers and running function pointers based on the function mapping file; determining the function pointers to be updated in the updated source function array based on the correspondence between updated source function pointers and running function pointers; updating the function pointers to be updated using the running function pointers in the appended SO file to obtain the updated SO file.
[0233] Specifically, when updating a target SO file via an attached SO file, the terminal can obtain a function mapping file. This function mapping file contains the correspondence between source function pointers and running function pointers. Further, the terminal can determine the function pointers in the updated source function array that need updating based on this correspondence, and then update these pointers using the running function pointers from the attached SO file. These function pointers can be all or some of the function pointers in the updated source function array. After updating the source function array, the target SO file becomes the updated SO file.
[0234] In one embodiment, the function pointer to be updated can be an update source function pointer that points to an empty function. The terminal can determine the update source function pointers pointing to empty functions in the updated source function array and use these pointers as the function pointers to be updated. The terminal can determine the update source function pointers pointing to empty functions in the updated source function array based on a function mapping file.
[0235] In this embodiment, by using the start pointer pointing to an empty function as the start pointer to be updated, the function pointer to be updated can be updated based on the running function pointer, so that the updated source function pointer can point to the running type function. Thus, by calling the updated source function pointer, the running type function can be called, and the target application can be run by calling the running type function.
[0236] In one embodiment, determining the function pointer to be updated in the updated source function array based on the correspondence between the update source function pointer and the running function pointer includes: for each running function pointer in the attached SO file, determining the update source function pointer corresponding to the current running function pointer based on the correspondence between the update source function pointer and the running function pointer, and using the determined update source function pointer as the function pointer to be updated; updating the function pointer to be updated using the running function pointer in the attached SO file includes: determining the current running type function pointed to by the current running function pointer; changing the function pointer to be updated from pointing to an empty function to pointing to the current running type function.
[0237] Specifically, when the correspondence between the update source function pointer and the running function pointer is obtained, for each running function pointer in the running function array, the terminal determines the update source function pointer corresponding to the current running function pointer based on the correspondence between the update source function pointer and the running function pointer, and uses the update source function pointer corresponding to the current running function pointer as the function pointer to be updated. For example, if the relationship between the update source function pointer and the running function pointer is that the update source function pointer P[1] corresponds to the running function pointer C[0], the terminal can use the running function pointer C[0] as the function pointer to be updated. Further, when the function pointer to be updated corresponding to the current running function pointer is determined, the terminal can determine the current running type function pointed to by the current running function pointer, and change the function pointer to be updated corresponding to the current running function pointer from pointing to an empty function to pointing to the current running type function. This process is repeated until all update source function pointers pointing to empty functions in the updated source function array are changed to point to the corresponding running type function.
[0238] For example, refer to Figure 10 When the update source function pointer 2 points to the empty function 1, and the empty function 1 corresponds to the runtime type function 1, the terminal can set the update source function pointer 2 to the runtime type function 1, and correspondingly set the update source function pointer n to the runtime type function n. Figure 10 A schematic diagram illustrating the updating of the source function pointer in one embodiment is shown.
[0239] In this embodiment, because the target SO file is directly replaced with the source SO file during the reassembly of the application package without altering the rest of the application package's content, the remaining unmodified code still calls the runtime functions through the source function array. Since the updated source function array is obtained by updating the source function pointers, its name is identical to the original array. This means that the remaining unmodified code in the application package actually calls the runtime functions through the updated source function array. However, some updated source function pointers in the updated source function array point to null functions. This causes calling these pointers to run null functions, leading to application failure. This embodiment, by changing the function pointers to be updated from pointing to null functions to pointing to runtime functions, enables the runtime functions to be called through the updated source function array, thus ensuring the normal operation of the target application.
[0240] In one embodiment, changing the function pointer to be updated from pointing to an empty function to pointing to a function of the currently running type includes: changing the value of the function pointer to be updated corresponding to the function pointer of the currently running function to the value of the function pointer of the currently running function.
[0241] Specifically, when updating the function pointer to be updated corresponding to the currently running function pointer, the terminal can directly assign the value of the currently running function pointer to the function pointer to be updated. For example, when the currently running function pointer P[0] = method_2 and the function pointer to be updated corresponding to the currently running function pointer P[0] is C[1], the terminal can change C[1] = method-2_cusmain to C[1] = method-2.
[0242] In one embodiment, reference Figure 11 , Figure 11 A specific method for generating a reassembled Android application package is provided, which includes:
[0243] S1102, when an application package reassembly instruction is received, the computer device parses the application package reassembly instruction to obtain at least one of the target application identifier, application package storage path, and file storage path.
[0244] S1104, the computer device identifies the target application through the target application identifier; obtains the Android application package of the target application through the application package storage path, and obtains the source code file of the target application through the file storage path.
[0245] S1106, the computer device determines the startup page to be displayed when the target application starts; based on the page jump logic between the pages displayed by the target application, it determines the jump page to which the startup page will jump; and the function to be called to display the jump page is used as the runtime type function required by the target application at runtime.
[0246] S1108, The computer device creates an initial function array; the initial function array includes multiple running function pointers; the function identifier of the running type function is determined, and the value of the running function pointer is set to the corresponding function identifier of the running type function, thus obtaining the running function array.
[0247] S1110, for each running function pointer in the running function array, the computer device creates a running external declaration corresponding to the current running function pointer; and generates a running array file based on the running function array and the running external declaration; the running external declaration is used to declare that the running type function pointed to by the running function pointer is located outside the running array file.
[0248] S1112, The computer device generates an additional CPP code file based on the runtime array file and the runtime type functions declared by the runtime external declaration.
[0249] S1114, the computer device determines the target source function pointers in the source function array that point to the runtime type function; for each target source function pointer, it determines the empty function corresponding to the current runtime type function pointed to by the current target source function pointer according to the correspondence between runtime type functions and empty functions.
[0250] S1116, the computer device changes the value of the current target source function pointer to the function identifier of the empty function corresponding to the currently running type function, obtains the updated source function array, and obtains the updated source array file based on the updated source function array.
[0251] S1118, the computer device obtains the remaining source code file after splitting through the updated source array file, startup type function, and empty function.
[0252] S1120, the computer device determines the update source function pointer corresponding to each running function pointer in the running function array, obtains the correspondence between the running function pointer and the update source function pointer, and generates a function mapping file based on the correspondence between the running function pointer and the update source function pointer; the function mapping file is used to run the target application.
[0253] S1122, The computer device compiles the remaining source code files after splitting to obtain the target SO file; based on the identifier of the target SO file, the source SO file in the Android application package is determined; the target SO file replaces the source SO file in the Android application package to obtain the reassembled Android application package.
[0254] S1124, When launching a target application obtained by installing and reassembling an Android application package, the computer device obtains a target SO file generated based on the remaining source code files after splitting; and launches the target application using the target SO file.
[0255] S1126, When the target application is run, the computer device obtains an additional SO file generated based on the additional CPP code file; the target SO file is updated using the additional SO file to obtain an updated SO file, and the target application is run using the updated SO file.
[0256] In the above method for generating a reconstructed Android application package, by obtaining the target application's Android application package and source code files, the runtime type function in the source code files can be determined. By determining the runtime type function, the source code files can be split using the runtime type function, obtaining the additional CPP code files required to run the target application and the remaining source code files required to launch the target application. By obtaining the remaining source code files, the application package can be reconstructed based on these remaining source code files, making the reconstructed Android application package usable for installing and launching the target application, and the reconstructed Android application package and additional CPP code files usable for running the target application. Since the remaining source code files are obtained by splitting the source code files, the size of the remaining source code files will be smaller than the size of the source code files, and the size of the reconstructed application package generated from the remaining source code files will be smaller than the size of the Android application package generated from the source code files. By reducing the size of the reconstructed Android application package, the download time of the reconstructed Android application package can be reduced, thereby improving the download efficiency of the Android application package.
[0257] In one embodiment, reference Figure 12 , Figure 12 A specific method for starting and running an application is provided, which includes:
[0258] S1202, when the target application obtained by installing and reassembling the Android application package is launched, the terminal responds to the launch command for the target application and initializes the application process; through the application process and according to the preset identifier of the target SO file, the target SO file in the reassembly Android application package is obtained.
[0259] S1204, the terminal calls the updated source function pointer in the updated source function array and determines the startup type function pointed to by the called updated source function pointer; the target application is started by the startup type function pointed to by the called updated source function pointer.
[0260] S1206, When running the target application, the terminal responds to the running command for the target application by determining whether an additional SO file exists locally; if no additional SO file exists locally, a download command is sent to the server; the sent download command is used to trigger the server to return the additional SO file.
[0261] S1208, the terminal obtains a preset function mapping file and determines the correspondence between the update source function pointer and the running function pointer based on the function mapping file.
[0262] S1210, for each running function pointer in the attached SO file, the terminal determines the update source function pointer corresponding to the current running function pointer based on the correspondence between the update source function pointer and the running function pointer, and uses the determined update source function pointer as the function pointer to be updated.
[0263] S1212, the terminal determines the currently running function type function pointed to by the currently running function pointer; changes the value of the function pointer to be updated corresponding to the currently running function pointer to the value of the currently running function pointer, obtains the updated SO file, and runs the target application through the updated SO file.
[0264] In the above embodiments, when starting the target application, by obtaining the target SO file generated from the remaining source code files after splitting, the target application can be started based on the startup type function in the target SO file. When running the target application, by obtaining the additional SO file based on the additional CPP code files, the target SO file can be updated based on the runtime type function in the additional SO file, resulting in an updated SO file including the runtime type function. The target application can then be run based on the updated SO file including the runtime type function, thus achieving the startup and running of the target application.
[0265] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0266] In one embodiment, reference Figure 13 When a target application needs to be launched, and the target application is a game application, S1301 the game engine loads the game SO file (the game SO file refers to the game engine's code library on the Android device, containing the source code written by the game developer), S1302 and executes the first function in the game SO file. S1303 the game engine starts the loop function, S1304 and finds the target SO file. S1305 the game engine loads the target SO file, S1306 and opens the target SO file, S1307 initializes the launch type function in the target SO file. S1308 the game engine executes the specific initialization process, S1309 and upon completion of initialization, checks if an additional SO file exists locally. S1310 if an additional SO file exists locally, the game engine opens the additional SO file. S1311 if no additional SO file exists, the game engine downloads the additional SO file, S1312 and updates the target SO file using the additional SO file. S1313, The game engine executes the registration of the code function table; S1314, The game engine executes the registration of the data table; S1315, The cached data is initialized; S1316, The game engine runs the target application using the registered code function table and the registered data table. Figure 13 A flowchart illustrating a method for starting and running a target application is provided.
[0267] This application also provides an application scenario in which the above-described method for generating a reconstructed Android application package and the method for launching and running the application are applied. Specifically, the application of the method for generating a reconstructed Android application package and the method for launching and running the application in this application scenario is as follows:
[0268] refer to Figure 14When developing a game application, users can create a default build process through the server, generating source code files and an Android application package. When reducing the size of the Android application package is needed, the server parses the source code files, obtaining the remaining source code files and additional CPP code files. The server then compiles the remaining source code files to obtain the target SO file, and compiles the additional CPP code files to obtain an additional SO file. Further, the server decompresses the application package, obtaining a decompressed application package containing the source SO file. The server then replaces the source SO file with the target SO file, resulting in a reassembled application package. The server compresses the reassembled application package, obtaining a compressed reassembled application package, and sends it to the terminal. The terminal can install and launch the target application using the received reassembled application package. When launching the target application, the terminal can download the additional SO file and map and replace the target SO file using the additional SO file, obtaining an updated target SO file. In other words, the terminal dynamically loads functions from the target SO file to run the target application. Figure 14 A schematic diagram of the process of reassembling, launching, and running the target application is shown in one embodiment.
[0269] Based on the same inventive concept, this application also provides an apparatus for generating a reconstructed Android application package to implement the above-described method for generating a reconstructed Android application package. The solution provided by this apparatus is similar to the solution described in the above method. Therefore, the specific limitations of one or more embodiments of the apparatus for generating a reconstructed Android application package provided below can be found in the limitations of the method for generating a reconstructed Android application package described above, and will not be repeated here.
[0270] In one embodiment, such as Figure 15 As shown, a device 1500 for generating recombined Android application packages is provided, comprising: an application acquisition module 1502, a splitting module 1504, and a recombining module 1506, wherein:
[0271] Application acquisition module 1502 is used to acquire the source code file of the target application;
[0272] The splitting module 1504 is used to determine the runtime type functions that the target application needs to call at runtime in the source code file; split the runtime type functions from the source code file to obtain the remaining source code file after splitting; and generate an additional CPP code file based on the split runtime type functions.
[0273] The reassembly module 1506 is used to generate download logic for the additional CPP file; the download logic is used to instruct the target application to download the additional CPP file at runtime; based on the remaining source code files after splitting and the download logic, a reassembled Android application package of the target application is generated.
[0274] In one embodiment, the application acquisition module 1502 is further configured to, when receiving an application package reassembly instruction, parse the application package reassembly instruction to obtain at least one of a target application identifier, an application package storage path, and a file storage path; determine the target application through the target application identifier; obtain the application package of the target application through the application package storage path; and obtain the source code file of the target application through the file storage path.
[0275] In one embodiment, the application package reassembly device 1500 is further configured to determine a target application identifier, which is obtained by selecting multiple candidate application identifiers in the reassembly configuration page displayed on the terminal; the size of the candidate application package corresponding to the candidate application identifier is greater than or equal to a preset size threshold; the application package storage path is configured in the reassembly configuration page; and the file storage path is configured in the reassembly configuration page.
[0276] In one embodiment, the splitting module 1504 is further configured to determine the startup page to be displayed when the target application starts; determine the jump page to which the target application jumps through the startup page according to the page jump logic between the pages displayed by the target application; and use the function to be called to display the jump page as the runtime type function required by the target application at runtime.
[0277] In one embodiment, the splitting module 1504 is further configured to generate an additional CPP code file based on the runtime type function; create an empty function corresponding to the runtime type function; and update the source code file based on the empty function to obtain the remaining source code file after splitting.
[0278] In one embodiment, the splitting module 1504 is further configured to create an initial function array; the initial function array includes multiple running function pointers; each running function pointer is pointed to a corresponding running type function to obtain a running function array, and a running array file is generated based on the running function array; an additional CPP code file is generated based on the running array file and the running type function.
[0279] In one embodiment, the running function pointer corresponds one-to-one with the running type function; the splitting module 1504 is also used to determine the function identifier of the running type function and set the value of the running function pointer to the corresponding function identifier of the running type function to obtain the running function array.
[0280] In one embodiment, the splitting module 1504 is further configured to create a runtime external declaration corresponding to the current runtime function pointer for each runtime function pointer in the runtime function array; generate a runtime array file based on the runtime function array and the runtime external declaration; the runtime external declaration is used to declare that the runtime type function pointed to by the runtime function pointer is located outside the runtime array file.
[0281] In one embodiment, the source array file includes a source function array; the source array file includes a source function array; the source function array includes multiple source function pointers; the splitting module 1504 is further configured to determine the target source function pointer in the source function array that points to a runtime type function; change the target source function pointer from pointing to a runtime type function to pointing to an empty function to obtain an updated source function array, and obtain an updated source array file based on the updated source function array; and obtain the remaining source code file after splitting based on the updated source array file and the function pointed to by the updated source function pointer in the updated source array file.
[0282] In one embodiment, the splitting module 1504 is further configured to, for each target source function pointer, determine the empty function corresponding to the current running type function pointed to by the current target source function pointer according to the correspondence between the running type function and the empty function; and change the value of the current target source function pointer to the function identifier of the empty function corresponding to the current running type function.
[0283] In one embodiment, the splitting module 1504 is further configured to generate additional CPP code files based on the runtime type function; determine the startup type function required to launch the target application in the source code file based on the runtime type function, and generate the remaining source code files after splitting through the startup type function.
[0284] In one embodiment, the source code file includes a source array file; the splitting module 504 is further configured to copy the source array file to obtain a copied array file; the copied array file includes a copied function array; the copied function array includes copied function pointers; the copied function pointers are deleted except for those pointing to runtime type functions, resulting in a remaining copied function array after deletion; the copied array file including the remaining copied function array after deletion is used as a runtime array file; and an additional CPP code file is generated based on the runtime array file and the runtime type functions.
[0285] In one embodiment, the reorganization module 1506 is further configured to compile the remaining source code files after splitting to obtain a target SO file; and to reorganize the application package using the target SO file to obtain a reorganized application package.
[0286] In one embodiment, the reassembly module 1506 is further configured to obtain the Android application package of the target application; the Android application package includes a source SO file generated based on the source code file; the remaining source code file and download logic after splitting are compiled to obtain the target SO file; the target SO file replaces the source SO file in the Android application package to obtain the reassembled Android application package.
[0287] In one embodiment, the Android application package includes a source SO file; the identifier of the source SO file is consistent with the identifier of the target SO file; the reassembly module 1506 is further configured to determine the source SO file in the application package based on the identifier of the target SO file; and replace the source SO file in the application package with the target SO file to obtain a reassembled application package.
[0288] In one embodiment, the Android application package reassembly generation apparatus 1500 is further configured to, when launching a target application obtained by installing the reassembly application package, obtain a target SO file generated from the reassembly application package based on the remaining source code files after splitting; launch the target application using the target SO file; when running the target application, obtain an additional SO file generated based on the additional CPP code files; update the target SO file using the additional SO file to obtain an updated SO file, and run the target application using the updated SO file.
[0289] In one embodiment, the updated SO file is obtained by updating the target SO file based on the function mapping file and by attaching an SO file; the target SO file includes an updated source function array; the updated source function array includes updated source function pointers; the attached SO file includes a run function array; the run function array includes run function pointers; the application package reassembly device 1500 is further configured to determine the updated source function pointer corresponding to each run function pointer in the run function array, thereby obtaining the correspondence between the run function pointers and the updated source function pointers; and generate a function mapping file based on the correspondence between the run function pointers and the updated source function pointers.
[0290] In one embodiment, the Android application package reassembly generation device 1500 is further configured to, for each running function pointer in the running function array, determine the empty function corresponding to the current running function pointer according to the first correspondence between running type functions and empty functions; determine the target updated source function pointer in the updated source function array; the target updated source function pointer is an updated source function pointer pointing to the empty function corresponding to the current running function pointer; and use the target updated source function pointer as the function pointer corresponding to the current running function pointer.
[0291] In one embodiment, the Android application package reassembly generation device 1500 is further configured to perform similarity matching between the value of the current running function pointer and the value of the updated source function pointer for each running function pointer in the running function array, and obtain a similarity matching result; and to use the updated source function pointer with a similarity greater than or equal to a preset similarity threshold as the function pointer corresponding to the current running function pointer.
[0292] In one embodiment, such as Figure 16 As shown, an application startup and execution device 1600 is provided, including: a link library acquisition module 1602, a splitting module 1604, and a reassembly module 1606, wherein:
[0293] The link library acquisition module 1602 is used to acquire the target SO file stored locally during the installation of the target application when the target application obtained by installing and reassembling the application package is launched; wherein the target SO file is generated based on the remaining source code files after splitting.
[0294] Startup module 1604 is used to start the target application from the target SO file;
[0295] The execution module 1606 is used to obtain an additional SO file generated based on the additional CPP code file when running the target application; update the target SO file with the additional SO file to obtain an updated SO file, and run the target application with the updated SO file.
[0296] In one embodiment, the link library acquisition module 1602 is further configured to initialize the application process in response to a startup command for the target application; and obtain the target SO file in the reassembled application package through the application process and according to the library identifier of the preset target SO file.
[0297] In one embodiment, the startup module 1604 is further configured to call the updated source function pointer in the updated source function array, and determine the startup type function pointed to by the called updated source function pointer; and start the target application through the startup type function pointed to by the called updated source function pointer.
[0298] In one embodiment, the running module 1606 is further configured to, in response to a running instruction for the target application, determine whether an additional SO file exists locally; when no additional SO file exists locally, generate a download instruction according to the download logic of the additional SO file; send the download instruction; the sent download instruction is used to trigger the server to return the additional SO file.
[0299] In one embodiment, the target SO file includes an updated array of source functions; the startup function includes updated source function pointers; the attached SO file includes an array of running functions; the running function array includes running function pointers; the running module 1606 is further configured to obtain a preset function mapping file, and determine the correspondence between the updated source function pointers and the running function pointers based on the function mapping file; determine the function pointers to be updated in the updated source function array based on the correspondence between the updated source function pointers and the running function pointers; and update the function pointers to be updated using the running function pointers in the attached SO file to obtain the updated link library.
[0300] In one embodiment, the running module 1606 is further configured to, for each running function pointer in the attached SO file, determine the update source function pointer corresponding to the current running function pointer based on the correspondence between the update source function pointer and the running function pointer, and use the determined update source function pointer as the function pointer to be updated; determine the current running type function pointed to by the current running function pointer; and change the function pointer to be updated from pointing to an empty function to pointing to the current running type function.
[0301] In one embodiment, the running module 1606 is further configured to change the value of the function pointer to be updated corresponding to the currently running function pointer to the value of the currently running function pointer.
[0302] The modules in the aforementioned device for generating and launching Android application packages can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0303] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 17As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores application package reassembly data. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements an application package reassembly method.
[0304] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 18 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a method for starting and running an application. The display unit of the computer device is used to form a visually visible image. It can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0305] Those skilled in the art will understand that Figures 17-18The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0306] In one embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above method embodiments.
[0307] In one embodiment, a computer-readable storage medium is provided storing a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0308] In one embodiment, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and executes the computer instructions, causing the computer device to perform the steps in the above method embodiments.
[0309] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0310] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0311] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0312] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for generating a recombined Android application package, characterized in that, The method includes: Obtain the source code files of the target application; Determine the runtime type functions that the target application needs to call at runtime in the source code file; the runtime type functions are the functions that the target application needs to call at runtime. The runtime type function is extracted from the source code file to obtain the remaining source code file after extraction, and an additional CPP code file is generated based on the extracted runtime type function. The download logic generates the additional CPP code file; the download logic is used to instruct the target application to download the additional SO file generated based on the additional CPP code file at runtime; Based on the remaining source code files after splitting and the download logic, a reconstructed Android application package of the target application is generated.
2. The method according to claim 1, characterized in that, The step of determining the runtime type functions required to be called by the target application at runtime in the source code file includes: Determine the launch page that the target application needs to display when it starts; Based on the page navigation logic between pages displayed by the target application, determine the navigation page to which the launch page will redirect; The functions required to be called to display the redirected page will be used as the runtime type functions required by the target application.
3. The method according to claim 1, characterized in that, The step of extracting the runtime type function from the source code file to obtain the remaining source code file after extraction includes: Create an empty function corresponding to the function of the specified execution type; The source code file is updated based on the empty function to obtain the remaining source code file after splitting.
4. The method according to claim 3, characterized in that, The source code file includes a source array file; the source array file includes a source function array; the source function array includes multiple source function pointers; updating the source code file based on the empty function to obtain the remaining source code file after splitting includes: Determine the target source function pointers in the source function array that point to the function of the execution type; Change the target source function pointer from pointing to a runtime function to pointing to an empty function to obtain an updated source function array, and obtain an updated source array file based on the updated source function array; Based on the updated source array file and the functions pointed to by the updated source function pointers in the updated source function array, the remaining source code file after splitting is obtained.
5. The method according to claim 1, characterized in that, The step of generating additional CPP code files based on the extracted runtime type functions includes: Create an initial function array; the initial function array includes multiple function pointers. Each of the running function pointers is then pointed to the corresponding running type function to obtain a running function array, and a running array file is generated based on the running function array; Based on the run array file and the run type function, generate an additional CPP code file.
6. The method according to claim 5, characterized in that, The step of generating a runtime array file based on the runtime function array includes: For each running function pointer in the array of running functions, a running external declaration corresponding to the current running function pointer is created; A runtime array file is generated based on the runtime function array and the runtime external declaration; the runtime external declaration is used to declare that the runtime type function pointed to by the runtime function pointer is located outside the runtime array file.
7. The method according to claim 1, characterized in that, The source code file includes a source array file; the step of generating additional CPP code files based on the split execution type functions includes: Copy the source array file to obtain a copied array file; the copied array file includes a copy function array; the copy function array includes copy function pointers; Delete all copy function pointers except those pointing to runtime type functions from the copied function array to obtain the remaining copied function array after deletion; The copied array file, which includes the array of copied functions remaining after deletion, is used as the run array file. Based on the run array file and the run type functions, an additional CPP code file is generated.
8. The method according to claim 1, characterized in that, The process of generating a reconstructed Android application package for the target application based on the remaining source code files after splitting and the download logic includes: Obtain the Android application package of the target application; the Android application package includes a source SO file generated based on the source code file; The remaining source code files and download logic after the split are compiled to obtain the target SO file; Replace the source SO file in the Android application package with the target SO file to obtain a reconstructed Android application package.
9. The method according to any one of claims 1 to 8, characterized in that, The method further includes: When the target application obtained by installing and reassembling the Android application package is launched, the target SO file stored locally and generated based on the remaining source code files after splitting is obtained. The target application is launched using the target SO file; When the target application is run, an additional SO file generated based on the additional CPP code file is obtained; The target SO file is updated by the additional SO file to obtain an updated SO file, and the target application is run using the updated SO file.
10. The method according to claim 9, characterized in that, The updated SO file is obtained by updating the target SO file based on the function mapping file and through the attached SO file; the target SO file includes an updated source function array; the updated source function array includes updated source function pointers; the attached SO file includes a run function array; the run function array includes run function pointers; the steps for generating the function mapping file include: Determine the update source function pointer corresponding to each running function pointer in the running function array to obtain the correspondence between running function pointers and update source function pointers; Based on the correspondence between the running function pointer and the update source function pointer, a function mapping file is generated.
11. The method according to claim 10, characterized in that, Determining the update source function pointer corresponding to each running function pointer in the running function array includes: For each running function pointer in the array of running functions, the empty function corresponding to the current running function pointer is determined according to the correspondence between running type functions and empty functions; Determine the target updated source function pointer in the updated source function array; the target updated source function pointer is an updated source function pointer that points to the empty function corresponding to the currently running function pointer; The target update source function pointer is used as the function pointer corresponding to the currently running function pointer.
12. A method for starting and running an application, characterized in that, The method further includes: When the target application obtained by installing and reassembling the Android application package is launched, the target SO file stored locally during the installation process is retrieved; wherein, the target SO file is generated based on the remaining source code files after splitting; the reassembly Android application package of the target application is generated based on the remaining source code files after splitting and the download logic; the remaining source code files after splitting are obtained by retrieving the source code files of the target application, determining the runtime type functions that the target application needs to call at runtime in the source code files, and extracting the runtime type functions from the source code files; the runtime type functions are the functions that the target application needs to call at runtime; The target application is launched using the target SO file; When the target application is run, an additional SO file generated based on the additional CPP code file is obtained based on the download logic; the additional CPP code file is generated based on the run type function extracted from the source code file; The target SO file is updated by the additional SO file to obtain an updated SO file, and the target application is run using the updated SO file.
13. The method according to claim 12, characterized in that, When the target application is run, obtaining the additional SO file generated based on the additional CPP code file according to the download logic includes: In response to the execution command for the target application, determine whether an additional SO file exists locally; When no additional SO file exists, a download instruction is generated based on the download logic of the additional SO file. Send a download command; the sent download command is used to trigger the server to return an additional SO file.
14. The method according to claim 12, characterized in that, The target SO file includes an updated array of source functions; the updated array of source functions includes updated source function pointers; the attached SO file includes an array of run functions; the run function array includes run function pointers; The step of updating the target SO file using the attached SO file to obtain an updated SO file includes: Obtain a preset function mapping file, and determine the correspondence between the update source function pointer and the running function pointer based on the function mapping file; Based on the correspondence between the updated source function pointer and the running function pointer, determine the function pointers to be updated in the updated source function array; The function pointer to be updated is updated by using the running function pointer in the attached SO file, thus obtaining the updated SO file.
15. The method according to claim 14, characterized in that, The step of determining the function pointers to be updated in the updated source function array based on the correspondence between the updated source function pointers and the running function pointers includes: For each running function pointer in the attached SO file, an update source function pointer corresponding to the current running function pointer is determined based on the correspondence between the update source function pointer and the running function pointer, and the determined update source function pointer is used as the function pointer to be updated. The step of updating the function pointer to be updated through the running function pointer in the attached SO file includes: Determine the function of the currently running type that the currently running function pointer points to; Change the function pointer to be updated from pointing to an empty function to pointing to a function of the currently running type.
16. An apparatus for generating a recombined Android application package, characterized in that, The device includes: The application acquisition module is used to acquire the source code files of the target application. A splitting module is used to determine the runtime type functions that the target application needs to call at runtime in the source code file; split the runtime type functions from the source code file to obtain the remaining source code file after splitting; and generate an additional CPP code file based on the split runtime type functions; the runtime type functions are the functions that the target application needs to call at runtime. The reassembly module generates download logic for the additional CPP code file; the download logic is used to instruct the target application to download the additional SO file generated based on the additional CPP code file at runtime; based on the remaining source code files after splitting and the download logic, a reassembled Android application package of the target application is generated.
17. The apparatus according to claim 16, characterized in that, The splitting module is also used to determine the startup page to be displayed when the target application starts; determine the jump page to which the target application jumps through the startup page according to the page jump logic between the pages displayed by the target application; and take the function to be called to display the jump page as the run type function to be called when the target application runs.
18. The apparatus according to claim 16, characterized in that, The splitting module is also used to create an empty function corresponding to the running type function; and to update the source code file based on the empty function to obtain the remaining source code file after splitting.
19. The apparatus according to claim 18, characterized in that, The source code file includes a source array file; the source array file includes a source function array; the source function array includes multiple source function pointers; the splitting module is further used to determine the target source function pointer in the source function array that points to a function of execution type; change the target source function pointer from pointing to a function of execution type to pointing to an empty function to obtain an updated source function array, and obtain an updated source array file based on the updated source function array; and obtain the remaining source code file after splitting based on the updated source array file and the function pointed to by the updated source function pointer in the updated source function array.
20. The apparatus according to claim 16, characterized in that, The splitting module is also used to create an initial function array; the initial function array includes multiple running function pointers; each running function pointer is pointed to a corresponding running type function to obtain a running function array, and a running array file is generated based on the running function array; Based on the run array file and the run type function, generate an additional CPP code file.
21. The apparatus according to claim 20, characterized in that, The splitting module is also used to create a runtime external declaration corresponding to the current runtime function pointer for each runtime function pointer in the runtime function array; and to generate a runtime array file based on the runtime function array and the runtime external declaration. The external declaration is used to declare that the runtime type function pointed to by the runtime function pointer is located outside the runtime array file.
22. The apparatus according to claim 16, characterized in that, The source code file includes a source array file; the splitting module is further used to copy the source array file to obtain a copied array file; the copied array file includes a copied function array; the copied function array includes copied function pointers; deletes copied function pointers from the copied function array except those pointing to runtime type functions to obtain a remaining copied function array after deletion; the copied array file including the remaining copied function array after deletion is used as a runtime array file, and an additional CPP code file is generated based on the runtime array file and the runtime type functions.
23. The apparatus according to claim 16, characterized in that, The reassembly module obtains the Android application package of the target application; the Android application package includes a source SO file generated based on the source code file; the remaining source code file and download logic after splitting are compiled to obtain the target SO file; the target SO file replaces the source SO file in the Android application package to obtain the reassembled Android application package.
24. The apparatus according to claim 16, characterized in that, The device for generating the reconstructed Android application package is further configured to: when launching a target application obtained by installing the reconstructed Android application package, obtain a target SO file stored locally and generated based on the remaining source code files after splitting; launch the target application using the target SO file; when running the target application, obtain an additional SO file generated based on the additional CPP code files; update the target SO file using the additional SO file to obtain an updated SO file, and run the target application using the updated SO file.
25. The apparatus according to claim 24, characterized in that, The updated SO file is obtained by updating the target SO file based on the function mapping file and through the attached SO file; the target SO file includes an updated source function array; the updated source function array includes updated source function pointers; the attached SO file includes a running function array; the running function array includes running function pointers; the application package reassembly device is further used to determine the updated source function pointer corresponding to each running function pointer in the running function array, thereby obtaining the correspondence between running function pointers and updated source function pointers; Based on the correspondence between the running function pointer and the update source function pointer, a function mapping file is generated.
26. The apparatus according to claim 25, characterized in that, The device for generating the recombined Android application package is also used to determine, for each running function pointer in the running function array, the empty function corresponding to the current running function pointer according to the correspondence between running type functions and empty functions; Determine the target update source function pointer in the updated source function array; The target update source function pointer is an update source function pointer that points to the empty function corresponding to the currently running function pointer; the target update source function pointer is used as the function pointer corresponding to the currently running function pointer.
27. An application startup and operation device, characterized in that, The device includes: The link library acquisition module is used to acquire the target SO file stored locally during the installation process of the target application when the target application obtained by installing and reassembling the Android application package is launched. The target SO file is generated based on the remaining source code files after splitting. The reassembly Android application package of the target application is generated based on the remaining source code files after splitting and the download logic. The remaining source code files are obtained by acquiring the source code files of the target application, determining the runtime type functions required by the target application at runtime, and extracting the runtime type functions from the source code files. The runtime type functions are the functions required by the target application at runtime. A startup module is used to launch the target application via the target SO file. The runtime module is used to obtain an additional SO file generated based on the additional CPP code file based on the download logic when the target application is run; update the target SO file with the additional SO file to obtain an updated SO file, and run the target application with the updated SO file; the additional CPP code file is generated based on the runtime type function extracted from the source code file.
28. The apparatus according to claim 27, characterized in that, The running module is also used to respond to the running command for the target application, determine whether there is an additional SO file locally; when there is no additional SO file, generate a download command according to the download logic of the additional SO file; send the download command; the sent download command is used to trigger the server to return the additional SO file.
29. The apparatus according to claim 27, characterized in that, The target SO file includes an updated source function array; the updated source function array includes updated source function pointers; the attached SO file includes a running function array; the running function array includes running function pointers; the running module is further configured to obtain a preset function mapping file, and determine the correspondence between the updated source function pointers and the running function pointers based on the function mapping file; determine the function pointers to be updated in the updated source function array based on the correspondence between the updated source function pointers and the running function pointers; update the function pointers to be updated using the running function pointers in the attached SO file to obtain the updated SO file.
30. The apparatus according to claim 29, characterized in that, The running module is also used to determine, for each running function pointer in the attached SO file, an update source function pointer corresponding to the current running function pointer based on the correspondence between the update source function pointer and the running function pointer, and to use the determined update source function pointer as the function pointer to be updated; Determine the function of the current running type that the currently running function pointer points to; change the function pointer to be updated from pointing to an empty function to pointing to the currently running type function.
31. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 15.
32. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 15.
33. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 15.
Citation Information
Patent Citations
So file loading method and device, storage medium and terminal equipment
CN110765394A
