CN112328266B - Software interconnection interface-oriented application program reduction method and system - Google Patents

Software interconnection interface-oriented application program reduction method and system Download PDF

Info

Publication number
CN112328266B
CN112328266B CN202011233823.0A CN202011233823A CN112328266B CN 112328266 B CN112328266 B CN 112328266B CN 202011233823 A CN202011233823 A CN 202011233823A CN 112328266 B CN112328266 B CN 112328266B
Authority
CN
China
Prior art keywords
file
apk
application program
application
stack information
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202011233823.0A
Other languages
Chinese (zh)
Other versions
CN112328266A (en
Inventor
张颖
崔磊
蔡华谦
蔡斯博
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Intel Technology Co ltd
Original Assignee
Intel Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Intel Technology Co ltd filed Critical Intel Technology Co ltd
Priority to CN202011233823.0A priority Critical patent/CN112328266B/en
Publication of CN112328266A publication Critical patent/CN112328266A/en
Application granted granted Critical
Publication of CN112328266B publication Critical patent/CN112328266B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/61Installation

Abstract

The embodiment of the invention provides a method and a system for reducing an application program guided by a software interconnection interface, wherein the method comprises the following steps: acquiring stack information of an application program; analyzing the stack information of the application program to generate a first analysis result; analyzing the APK file of the application program to generate a second analysis result; determining a reduction set according to the first analysis result and the second analysis result; and according to the reduction set, reducing the APK file of the application program to generate a new APK file. According to the method and the system provided by the embodiment of the invention, the stack information analysis result called by the programming interface and the APK file analysis result are fully utilized to guarantee the correct operation of the programming interface, the accurate reduction of the Android application program guided by the software interconnection interface is realized, the resource occupation of the application program is effectively reduced, and the development efficiency of the application program is improved.

Description

Software interconnection interface-oriented application program reduction method and system
Technical Field
The invention relates to the technical field of information, in particular to a software interconnection interface-oriented application program reduction method and a software interconnection interface-oriented application program reduction system.
Background
An Application Programming Interface (API) is an Interface between a program provided by an operating system to a programmer and the operating system, and the Application program can access system resources and obtain system services during execution through the API. Correspondingly, the export and import of the data resources are realized between the application program software through the programming interface, and the interconnection between the software is realized.
At present, in order to ensure the correct operation of the generated Android programming interface, a complete Android application installation Package (APK) needs to be loaded, but the correct operation of the programming interface only needs to be supported by a small part of codes and resources in the APK actually, and the method of loading the whole APK wastes storage resources and computing resources of the mobile device.
Related technologies provide various Android application program reduction methods and tools, but an effective method for accurately reducing a software interconnection interface-oriented application program aiming at a support part of a programming interface is not provided, so that the application program still retains a large number of redundant functions, interactive logic and background tasks which are irrelevant to the operation of the programming interface, and resource waste and low application development efficiency are caused.
Disclosure of Invention
In view of the above, embodiments of the present invention provide a software interconnection interface-oriented application reduction method and a software interconnection interface-oriented application reduction system that overcome or at least partially solve the above problems.
In order to solve the above problem, an embodiment of the present invention provides a method for reducing an application program guided by a software interconnection interface, where the method is applied to an Android application program, and includes: acquiring stack information of an application program; analyzing the stack information of the application program to generate a first analysis result; analyzing the APK file of the application program to generate a second analysis result; determining a reduction set according to the first analysis result and the second analysis result; and according to the reduction set, reducing the APK file of the application program to generate a new APK file.
Optionally, acquiring stack information of the application program includes:
setting stack information record configuration, transmitting a configuration file to an Android terminal, and starting stack information records;
starting an application program to be reduced, sequentially calling each programming interface, and checking a return result;
after all the stack information is correctly called, stopping stack information recording and generating a recording file;
the contents recorded by the recording file comprise a method call stack, a call parameter type, a call parameter instance and a return value in an App starting process and a programming interface calling process.
Optionally, acquiring stack information of the application program includes:
the method comprises the steps of configuring and obtaining in stages, dividing Android program operation into a plurality of stages, and respectively capturing respective stack information of the plurality of stages to form a plurality of stack information recording files;
configuring and acquiring the sub-content, capturing the stack information for multiple times, capturing different contents in the stack information each time, and respectively generating a plurality of recording files of the stack information so as to reduce the size of each recording file of the stack information;
and classifying for configuration and acquisition, realizing continuous reduction of a capture set based on a configured code packet or class, and finally limiting the size of the record files of a plurality of stack information within an acceptable range.
Optionally, analyzing the stack information of the application program to generate a first analysis result, including:
analyzing a recording file of stack information, analyzing method, parameter and return value information in the file according to a self-defined grammar rule, and acquiring a content list appearing in the whole stacking process so as to generate a first analysis result, wherein the content list appearing in the stacking process comprises: a class list, a resource list, and a shared library list.
Optionally, analyzing the APK file of the application program to generate a second analysis result, including:
the method comprises the steps of utilizing a class and a method for analyzing and modifying a Dex file in a jar package of a Dex2jar tool, reading a Dex byte code file in an APK, obtaining a list of all classes in an application, reading/assets and/res folders in the APK, obtaining a list of all resource files in the application, and reading a list of all shared library files under/lib folder files in the APK;
and generating a second analysis result according to the list of the classes, the list of the resource files and the list of the shared library files.
Optionally, determining a reduction set according to the first analysis result and the second analysis result, including:
comparing the second analysis result with the first analysis result, solving a difference set of the second analysis result and the first analysis result, and removing a content list appearing in the stacking process from an APK content list to obtain a final reduction set, wherein the APK content list comprises: a list of all classes in the application, a list of all resource files in the application, a list of all shared library files in the APK/under the lib folder file.
Optionally, according to the reduction set, reducing the APK file of the application program includes:
deleting a resource file list and a shared library file list which appear in the reduction set from an APK file of an application program aiming at the resource and the shared library;
aiming at the classes, operating the Dex byte codes of the application programs, reading the content of the Dex file, deleting the classes appearing in the reduction set, and regenerating the Dex file;
obtaining the APK file after the reduction is completed according to the steps, repacking the APK file after the reduction is completed into an APK, applying a signature, and generating a new available APK file;
and generating a new reflection Dex file according to the new APK file and the original programming interface code so as to support the normal calling of the programming interface.
Optionally, the method further comprises:
installing a new APK file on the Android terminal, and importing a reflection Dex into the Android terminal;
based on a resource reflection mechanism and an efficient interoperation technology of a cloud-end fusion system, an application programming interface is generated through external monitoring and control by utilizing a resource reflection mechanism inside an information system;
sequentially calling each programming interface by using the interfaces to obtain calling results;
if the application program is started normally and the returned results of all the programming interfaces are correct, the application reduction is considered to be successful, and the method is ended;
if a problem occurs in the starting process, the reduction set is incorrect, missing classes or resources need to be positioned, a new APK file is regenerated, and the steps are executed again;
the method comprises the following steps of generating a new APK file again aiming at the condition that App is abnormally started or programming interface calling fails, and executing the following steps:
analyzing a programming interface calling result and an Android log, finding out missing classes and/or resources, removing the missing classes and/or resources from an reduction set to generate a new reduction set, and reducing the APK of an original application program according to the new reduction set to generate a new APK file.
Optionally, the method further comprises:
aiming at a newly added programming interface of an Android system, the method for reducingthe application program comprises the following steps:
adding codes, resources and shared libraries depended by the newly added programming interface based on the new APK file, and updating the application program;
acquiring and analyzing stack information of the updated calling process of the application program to the newly added programming interface, and acquiring a content list appearing in the newly added stack process;
deleting a content list appearing in the process of adding a stack from the reduction set to obtain a new reduction set;
and according to the new reduction set, reducing the APK file of the updated application program to generate an updated APK file capable of supporting the operation of the newly added programming interface.
The embodiment of the invention also provides a software interconnection interface oriented application program reduction system, which is applied to Android application programs and comprises the following steps:
the stack information acquisition module is used for acquiring stack information of the application program;
the stack information analysis module is used for analyzing the stack information of the application program and acquiring a first analysis result;
the APK analysis module is used for analyzing the APK file of the application program and acquiring a second analysis result;
a reduction set determination module, configured to determine a reduction set according to the first analysis result and the second analysis result;
and the APK reduction module is used for reducing the APK file of the application program according to the reduction set to generate a new APK file.
It can be seen from the foregoing technical solutions that, the embodiments of the present invention provide a software interconnection interface-oriented application reduction method and system, which analyze stack information and an APK file called by a programming interface respectively, and generate a reduction set by integrating analysis results, so as to ensure support for operation of the programming interface, implement accurate reduction of an Android application oriented to the software interconnection interface, and can effectively reduce resource occupation of the application and improve development efficiency of the Android application.
Drawings
FIG. 1 is a flowchart illustrating steps of a method for software interconnect interface oriented application reduction according to an embodiment of the present invention;
FIG. 2 is a statistical chart of the volume proportion of files in APK of a randomly selected part of Android applications;
FIG. 3 is a flowchart illustrating steps for analyzing stack information according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a Dex file structure according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating the steps of an APK reduction iteration test according to an embodiment of the present invention;
FIG. 6 is a flowchart illustrating a method for reducing programming interface oriented Android applications according to an embodiment of the present invention;
fig. 7 is a block diagram of a software interconnection interface oriented application reduction system according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The Android application program provides rich functions and services for users, and in order to construct a good application ecology, other functions related to the core function can be added into the Android application program so as to meet the requirements of different users. For example, the paying treasure has a series of related functions such as a balance treasure, sesame credit, flower and the like in addition to the paying function, and even comprises a series of flow guiding functions such as dripping trip, hungry taking out, and tianmao. However, for many users, the purpose of using one application is relatively single, and not all functions of the application are used, and at this time, the redundant functions become the chief culprits of occupying Android terminal resources, consuming the electric quantity of the Android terminal, and slowing down the speed of the Android terminal. The reduction of the redundant functions is performed, only the most core functions are reserved, and the method is one of important ideas for reducing the Android terminal application, is a 'white box' idea, needs to redevelop the application, is low in efficiency and high in cost, and needs the support of an original development document or a developer. On the other hand, the requirements of different users on the functions are different, and the method is not universal.
In order to realize the classic algorithm and function, Android application developers often import code packages to reduce unnecessary repeated development. The code package is typically imported in its entirety, however, only a portion, or even a small portion, of the code is used, creating redundancy. With the upgrade of the application version, some codes and resources are abandoned and not cleaned in time, and also remain in the installation package. On the other hand, different Android terminals have different hardware resources, and in order to adapt to the hardware resources, the application program must prepare multiple codes and resources in an installation package, which are also redundant for a single machine. Reducing the redundancy in the installation package is another important idea for reducing the Android terminal application.
The application reduction method reduces the size of the application, improves the starting and running speed of the application, but does not reduce the Android application for the purpose of correctly running a programming interface. In some specific scenes aiming at Android application program development, only the correct operation of a programming interface needs to be ensured, and considering that for most Android application programs, in the calling process of the programming interface, the used application classes, dependent resource files and shared library files only occupy a small part of the whole APK classes, resources and shared libraries, the invention considers how to reduce the APK of the application program package on the premise of ensuring that the programming interface can be correctly called and realizing specific software interconnection, so that only the classes, resources and shared libraries which the programming interface depends on are reserved and loaded, and the accurate reduction of the Android application program guided by the software interconnection interface is realized.
Example one
Fig. 1 is a flowchart illustrating steps of a method for software interconnection interface-oriented application reduction according to an embodiment of the present invention. Referring to fig. 1, the method specifically includes the following steps:
in step S31, stack information of the application program is acquired.
In this embodiment, stack information of a calling process and an App starting process of an application programming interface is recorded by using an internetware behavior reflection technology based on a computational reflection mechanism.
The internetware behavior reflection technology provides a model construction method and an instruction level control method when the internetware application behaviors are operated by establishing an internetware behavior reflection conceptual model, realizes the refletall of a prototype system, and can efficiently monitor and control the application behaviors.
In this embodiment, a two-part model of the Android application during running is constructed by using a monitoring function of an internetware behavior reflection technology on an application behavior, including a runtime stack model and a runtime stack model, so as to obtain stack information during the Android application running.
The runtime heap model mainly includes two major elements, namely an initial state of a heap area and activities which occur during runtime and affect heap area data, and reflects data flow in the code execution process, namely processes of creation, modification, recovery and the like of objects, and is a set of initial values of memory data and heap modification activities which occur within a period of time. In this embodiment, constructing the runtime stack model specifically includes the following steps:
first, a heap area initial state is generated. The initial state of the heap area refers to a snapshot of the heap area at a certain moment, and in order to ensure atomicity of the heap area state, that is, to ensure that the state of the heap area is not changed by other threads when the initial state of the heap area is generated, the framework freezes the data of the heap area first and then performs the snapshot.
Second, activities in the heap model are generated. There may be many activities in the heap model, and if any activity for changing heap area data is recorded, huge resource overhead is caused, and subsequent search application is not facilitated. Therefore, before generating the heap model, the framework provides a number of options to delineate the scope of monitoring and provides a timestamp-based heap state query algorithm for use.
The runtime stack model mainly comprises three elements of a control flow graph, runtime activities and relations among the activities, reflects control flows in the code execution process, namely processes of circulation, branching, method calling and the like, and is a set of activities of one or more control flows occurring in a period of time. In this embodiment, constructing the runtime stack model may include the following steps:
in the first step, a control flow graph is generated. A control flow graph is an abstract representation of the program source code, which is a collection of all possible activities of an application. Since Android applications confuse code when compiling byte code, it is difficult for developers to provide source code. In this case, the framework directly modifies an Android Runtime (Android Runtime, ART) to obtain the Dex bytecode of the application, which is used as a basis for the control flow graph, thereby avoiding mismatching between the control flow graph and the Runtime control flow.
And secondly, redistributing the execution of the control flow graph according to the requirement. Each thread of the Android program corresponds to an execution path of a control flow, the framework provides a behavior interpreter, and each thread distributes the control flow graph to the behavior interpreter of the thread as required to generate activities of the application in operation.
And thirdly, generating the dependency relationship between the control flows. At present, the Android application mostly adopts a multithreading structure, and complex dependency relationships exist among threads, so the dependencies are analyzed and added into a control flow to be integrated into a complete control flow.
Step S32, analyzing the stack information of the application program to generate a first analysis result.
According to the method, a plurality of Android applications are randomly selected, and the volume ratio of various files in a plurality of APKs is counted.
Referring to fig. 2, fig. 2 is a statistical diagram of the volume fraction of files in the APK of the randomly selected partial Android application. As shown in fig. 2, the main memory occupied by the APK file is a shared library, resource, and code (class).
Therefore, in this embodiment, reduction is mainly performed on the class, the resource and the shared library file, and in view of this, the analysis on the stack information is also mainly the analysis on the class, the resource and the shared library file, and then the step S32 may include:
analyzing a recording file of stack information, analyzing method, parameter and return value information in the file according to a self-defined grammar rule, and acquiring a content list appearing in the whole stacking process so as to generate a first analysis result, wherein the content list appearing in the stacking process comprises: a class list, a resource list, and a shared library list.
Fig. 3 is a flowchart illustrating steps for analyzing stack information according to an embodiment of the present invention. Referring to fig. 3, analyzing the stack information of the application program specifically includes the following steps:
first, reading stack information recording file. In the embodiment, only whether the class, the resource and the shared library are used is concerned, and the calling relationship among the methods is not concerned, so that the record is not structured into the calling relationship tree, and the record file is directly read and analyzed to form the method calling list.
And secondly, respectively extracting a class list, a resource list and a shared library list.
First, a class list is extracted. And extracting the method, the return value and the parameter of each item according to the method call list obtained in the first step, analyzing the fields and extracting the class in the fields.
Accordingly, inter-class dependencies are analyzed. And according to the class list, iteratively inquiring all ancestor classes and interface classes of each class from a Dex file in the APK, and adding the classes into the class list to avoid errors.
And secondly, extracting a resource list. Besides directly acquiring resources by a traditional method provided by Android, content, res, and the like, there can be a plurality of resource using methods, for example, setting resources on a certain View, and extracting by using any one or more of the following methods:
android.weight.ImageView.setImageResource(@DrawableRes intresId);
android.weight.TextView.setText(@StringRes intresId);
android.support.v7.app.AppCompatDelegate.setContentView(intresId)。
accordingly, the resource id is translated. For the native resources under the/assets directory, directly opening the native resources through an open method of an AssetManager, wherein the parameters are file names and are directly used; for resources under the/res directory, the Android compiler gives an id to the resources at compile time, and performs mapping by generating r.java and resources.arsc files. When a developer uses a resource, it typically uses its id, rather than its file name directly. Illustratively, a developer who wants to use a layout file of res/layout/activity _ main. xml will refer to the file by r.layout. Therefore, the method parameter obtained through the Resources class is only an integer id, not a file name. When the Android application is actually operated, the resource file is mapped by the id according to the compiled content of the resources. Therefore, this embodiment also needs to convert the acquired resource id into a corresponding file name.
In this embodiment, the Android application can be reversely compiled into the source code, and the modified Android application program can be repackaged, so that repeated work such as apk construction can be effectively supported. In this embodiment, an Apktool tool is used to decompile resources, obtain a corresponding relationship between a resource id and a resource name, compare the corresponding relationship with the parameters obtained in the previous step, and finally obtain an actually used resource name list.
And thirdly, extracting a shared library list. Like resources, shared libraries cannot be directly accessed through the stack model. And analyzing the parameters of the system.load and system.load library function loading shared library files to obtain a shared library list.
And thirdly, removing the duplicate. In the above stack information analysis process, the declaration, parameter, return value, and other information of each method are extracted, which are repeated. Therefore, before determining the reduction set, duplication removal must be performed to further reduce the volume of the stack information record file, thereby reducing the terminal resources occupied by the stack model construction process
And fourthly, generating a first analysis result according to the class list, the resource list and the shared library list after the duplication removal.
And step S33, analyzing the APK file of the application program to generate a second analysis result.
In this embodiment, according to a Dex file structure and an operation technique for a Dex byte code, a Dex byte code file in an APK is analyzed to obtain reducible and irrelevant classes therein, so as to analyze the APK file of the application program and generate a second analysis result, where the second analysis result includes:
the method comprises the steps of utilizing a class and a method for analyzing and modifying a Dex file in a jar package of a Dex2jar tool, reading a Dex byte code file in an APK, obtaining a list of all classes in an application, reading/assets and/res folders in the APK, obtaining a list of all resource files in the application, and reading a list of all shared library files under/lib folder files in the APK;
and generating a second analysis result according to the list of the classes, the list of the resource files and the list of the shared library files.
Referring to fig. 4, fig. 4 is a schematic diagram of a Dex file structure according to an embodiment of the present invention. As shown in fig. 4, the Dex file can be divided into three parts, i.e., a file header, an index area, and a data area.
The file header is the header of the Dex file, and records some basic information of the Dex file: magic word, checksum, signature, file size, file header size, endian. In addition, the Dex file header records the rough data distribution of the Dex file, that is, the size and offset of each section, for example, the offset of the string index area and the number of strings in the string list.
The index area indexes character strings, types, method declarations, fields and methods in the whole Dex, and the position and the size of each index in the Dex file are specified by a Dex header. Taking the method declaration index area as an example, it describes all method declarations in the Dex file, including: method name, return type, parameter list.
The data area records all classes, specific methods, instructions and other data in the Dex file, and is the most important part in the Dex file.
TABLE 1
Figure BDA0002766077450000111
Referring to table 1, table 1 is a code example table of a Dex file operated by Dex2jar according to an embodiment of the present invention. As shown in Table 1, the tool reads the content of the Dex file into DexFileNode through DexFileReader. The clzs field in the DexFileNode contains all the class information in the Dex file, and after the information is modified, the DexFileWriter can be used for writing back the Dex file again, namely the modification of the Dex file is completed.
And step S34, determining a reduction set according to the first analysis result and the second analysis result.
In one embodiment, the step S34 may include the following steps:
comparing the second analysis result with the first analysis result, solving a difference set of the second analysis result and the first analysis result, and removing a content list appearing in the stacking process from an APK content list to obtain a final reduction set, wherein the APK content list comprises: a list of all classes in the application, a list of all resource files in the application, a list of all shared library files in the APK/under the lib folder file.
According to the embodiment, the content list obtained in the APK analysis is used as the original reduction set, and the content list appearing in the stacking process is removed from the original reduction set, namely, the related content supporting the operation of the programming interface is removed from the original reduction set, so that the related content supporting the operation of the programming interface is not reduced, and the operation of the programming interface is further ensured.
And step S35, according to the reduction set, reducing the APK file of the application program to generate a new APK file.
According to the reduction set, the irrelevant classes, resources and shared libraries are deleted from the APK, and then the APK is repackaged and re-signed to form a new APK. Specifically, the step S35 may include:
deleting a resource file list and a shared library file list which appear in the reduction set from an APK file of an application program aiming at the resource and the shared library;
aiming at the classes, operating the Dex byte codes of the application programs, reading the content of the Dex file, deleting the classes appearing in the reduction set, and regenerating the Dex file;
obtaining the APK file after the reduction is completed according to the steps, repacking the APK file after the reduction is completed into an APK, applying a signature, and generating a new available APK file;
and generating a new reflection Dex file according to the new APK file and the original programming interface code so as to support the normal calling of the programming interface.
TABLE 2
Figure BDA0002766077450000121
Figure BDA0002766077450000131
Referring to table 2, table 2 is a reduction method table for different APK file directories according to the present invention. As shown in table 2, in this embodiment, the irrelevant resources in the res, assets, and lib directories are directly deleted, the Dex file is regenerated, the files other than the META-INF directory are directly copied, and the APK file is re-signed and packaged by regenerating the signature file in the META-INF directory, that is, the reduction of the APK is completed.
For different files or directories, different reduction operations are executed, specifically including:
first, for the assets directory. The directory is used to store native static files, and supports arbitrary file directory structures. The Android compiler does not generate resource IDs for the resource files, does not compile the resource IDs, and directly copies the resource IDs to the APK. Without the resource ID, these resources are opened directly by the AssetManager. During the APK reduction process, the unused resources in the assets directory are directly deleted.
Second, for lib directories. The directory is used for storing shared libraries on which the application depends and is written by C/C + +. Because the bottom layer architectures of various Android terminals are different and the shared libraries supported by the Android terminals are also different, so in order to support Android terminals with different structures, so files with a plurality of architectures are usually stored under a lib directory. In general, the android terminal can be divided into four architectures, namely arm, arm-v7a, x86 and mips, four subdirectories, namely armeabi, armeabi-v7a, x86 and mips, are established under the lib directory, and then a so file of the corresponding architecture is placed in each subdirectory. In fact, since android terminals of x86 and mips architectures are not common in the market, general applications will only support the arm and arm-v7a architectures. During the APK reduction process, shared libraries that are not used in the lib directory are directly deleted herein. For the Android terminal with a fixed architecture, subdirectories of other architectures under the lib directory can be deleted.
Third, for res directory. The directory is used for storing resource files. Unlike the assets directory, the resource file under the directory is compiled, and a resource ID is generated, and the developer directly accesses the corresponding resource using the resource ID. They are divided into several classes, and each class of resource file is placed under a corresponding subdirectory, including: an anim subdirectory for storing animation files, a color subdirectory for storing color values, a drawable subdirectory for storing image files, a layout subdirectory for storing layout files, values subdirectory for storing simple values, a raw subdirectory for storing files without compiling, an xml subdirectory for storing xml files and the like. The res directory also sometimes provides a variety of resource files that support different Android terminal models. In the APK reduction process, the resource file that is not used in the res directory is directly deleted, and although this causes the corresponding resource ID to be a null pointer, no error is generated because the resource file is not used.
Fourth, for the META-INF directory. The directory is used to store signature files for the APK, which can be used to ensure the integrity of the APK. The signature file is generated when the android SDK is packaged into the APK, and when the android terminal is installed and applied, the signature file is firstly checked to ensure that each file in the APK is not tampered, so that malicious attack and virus infection are prevented. The catalog comprises three files of MANIFEST.MF, CERT.SF and CERT.RSA.
Fifth, for android manifest. The file is a configuration file of the whole Android application, and each Activity, Service, Provider and Receiver in the code is recorded in detail, and the file also comprises information such as authority statement, package name and used SDK version. And the Android system knows the whole information of the APK according to the file and starts a corresponding component. Even if a part of components recorded in a file is deleted, an error does not occur as long as the components are not actually used. So, during the reduction of APK, no modification is made to the android manifest.
Sixthly, for classes. The file is an executable file of the Android Dalvik virtual machine, and executable codes of Android application programs are stored in the file. Dex files must be modified if there is a need to delete an unrelated class. Specifically, the Dex file is read by a Dex2jar tool, irrelevant classes in the file are deleted, and the Dex file is regenerated. Detailed implementations are described herein in the next section.
Seventh, resources. The file records the corresponding relation between the resource file in the res directory and the resource ID thereof, and when the resource is loaded, the position of the resource file is returned according to the resource ID. Although the resources in the partial res directory are deleted, which causes the partial corresponding relationship in the resources. Therefore, no modifications are made to the resources.
Eighth, for other files and directories. The files and the directories are customized by an Android application developer, and the Android SDK can directly copy the files and the directories into the APK, so that the files and the directories are not processed and are reserved.
In one implementation, in combination with the above embodiments, the present application provides a method for acquiring stack information of an application. Specifically, the step S31 may include:
setting stack information record configuration, transmitting a configuration file to an Android terminal, and starting stack information records;
starting an application program to be reduced, sequentially calling each programming interface, and checking a return result;
after all the stack information is correctly called, stopping stack information recording and generating a recording file;
the contents recorded by the recording file comprise a method call stack, a call parameter type, a call parameter instance and a return value in an App starting process and a programming interface calling process.
Referring to table 3, table 3 is a configuration information table of stack information records, and in the present embodiment, stack information of an application is obtained according to configuration items of configuration files set in table 1. The stack information record configuration is characterized in that an App package name and a process name which need to be subjected to stack information capture are set firstly, and specific contents which need to be captured are set, wherein the specific contents comprise a method, parameters, a return value, field read-write, abnormity and the like; finally, the concerned class or code packet is set, and the default is all application classes.
TABLE 3
Figure BDA0002766077450000151
Figure BDA0002766077450000161
Wherein the PackageName indicates the application that needs to build the stack model, and if configured only as an application package name, will only handle the main process of the application. Otherwise, the corresponding process name needs to be added after the package name, for example: com, ibox, computers, pushservice. Generally, when the sub-process cannot run correctly, the Android application reports a program error to a user, but the crash of the main process cannot be caused, and the calling of a programming interface cannot be influenced. Therefore, generally, only the stack information of the host process needs to be acquired and analyzed.
ApiNameList is a list of programming interface names, representing a plurality of programming interfaces; ApiArgsList is a parameter list, has the same length as ApiNameList, and corresponds to the parameters of each programming interface, wherein the parameter of each programming interface is a Json string.
StageDivided is a boolean variable that indicates whether phased trace acquisition needs to be turned on. After the stack model is started, the module calls a construction tool of the stack model twice to respectively form trace files of an App starting process and a programming interface calling process. This configuration is enabled when the trace file is too large to record. And for the phased trace acquisition with finer granularity, the trace acquisition is customized by a developer and is completed by manual operation.
Contentdigital is a boolean variable that indicates whether or not the trace acquisition of the sub-content needs to be started. After the starting, the module calls a construction tool of the stack model twice, obtains parameters of the method and the reading and writing conditions of the fields in the method respectively, and clears application data between two calls so as to avoid the problem caused by different starting processes of App twice. This configuration is enabled when the trace file is too large to record. If it and the staged device are started at the same time, the App startup process will perform internal content trace acquisition, while the programming interface call process will not. The reason is that the calling process of the programming interface is often simpler, the situation that the Android terminal resource is excessively occupied cannot be caused, and the trace does not need to be acquired by the content.
ClassList is a list of classes of interest, which can be of variable length, indicating the class of interest during the stack construction process. If the list is empty, then focus is on all application classes. The configuration is enabled in the process of acquiring the stack information related to the resources and the shared library, and can also be started when developers test a small part of classes.
Because the Android application program can generate a large amount of stack information during running, if the Android application program is not limited, all stack information is captured, the application is often jammed or even crashed during running, the process of capturing the stack information additionally occupies the CPU and memory resources of the Android terminal, and the resources required by the running of the App exceed the upper limit of the performance of the Android terminal. Even after a long waiting time, complete stack information can be obtained, the size of the stack information often reaches hundreds of M, even a plurality of G, and subsequent analysis is difficult to perform.
In view of the above, in combination with the above embodiments, the present application provides a method for acquiring stack information of an application. Specifically, the method may include:
firstly, configuring and acquiring the Android program in stages, dividing the Android program operation into a plurality of stages, respectively capturing respective stack information of the plurality of stages, and forming a plurality of record files of the stack information.
Specifically, App startup and programming interface call can be regarded as two processes, and stack information grabbing is performed on each process. Namely, the stack model building program is started, and after the App is opened, the stack model building program is immediately stopped to generate a record file. And then, the stack model building program is started again, each programming interface is called in sequence, the stack model building program is stopped, and another record file is generated. However, for apps that are large in size, slow in boot process, and many in boot load items, even if stack information is captured separately during boot, the process cannot be performed smoothly. At this time, the App starting process may be artificially divided into multiple stages, for example, one stage before the user interface pops up the starting animation, a second stage when the starting animation runs, and a third stage after the starting animation ends. In order to prevent insufficiency of the acquired stack information, each stage may be appropriately relaxed, and the subsequent stack information analysis module may perform deduplication.
Secondly, configuring and acquiring the content, capturing the stack information for multiple times, capturing different contents in the stack information each time, and respectively generating a plurality of recording files of the stack information so as to reduce the size of the recording file of each stack information.
Illustratively, the method, the parameter and the return value used in the program running process are only grabbed for the first time, and the method, the field modification information and the exception are grabbed for the second time.
Thirdly, the configuration and the acquisition are carried out in a classified mode, the continuous reduction of a capture set is realized based on a configured code packet or class, and finally the size of the record files of the stack information is limited within an acceptable range.
Illustratively, through preliminary stack information grabbing or manual analysis, it is determined that 10 classes are reserved, and then when stack information grabbing is performed next time, the classes can be configured to be not concerned, and the stack model does not record the calling process and the instance object related to the classes, so that the recording overhead is reduced. This approach may also be used, for example, if it is desired to determine whether a certain fraction of classes will be used. The configuration is modified to focus on only these classes, and stack model construction is performed, and because the focused classes are fewer, the stack model construction can be completed in less time, and the stack model construction and analysis process is accelerated. However, this method can only be used as an aid because of the large number of analogies involved in the overall process of App initiation and programming interface invocation.
According to the embodiment, the stack information is configured and captured in a grading, content-dividing and classifying manner, although the operation steps and the number of the record files are increased, the occupation of single Android terminal resources and the size of each record file are reduced, the calculation performance of the terminal is saved, and the smooth operation of stack information acquisition and subsequent analysis work can be better ensured.
With reference to the foregoing embodiment, in an implementation manner, after the APK file of the application program is reduced according to the reduction set, an iterative test may be performed on the Android application program to ensure that the application program functions normally, and the specific steps may include:
installing a new APK file on the Android terminal, and importing a reflection Dex into the Android terminal;
based on a resource reflection mechanism and an efficient interoperation technology of a cloud-end fusion system, an application programming interface is generated through external monitoring and control by utilizing a resource reflection mechanism inside an information system;
sequentially calling each programming interface by using the interfaces to obtain calling results;
if the application program is started normally and the returned results of all the programming interfaces are correct, the application reduction is considered to be successful, and the method is ended;
if a problem occurs in the starting process, the reduction set is incorrect, missing classes or resources need to be positioned, a new APK file is regenerated, and the steps are executed again;
the method comprises the following steps of generating a new APK file again aiming at the condition that App is abnormally started or programming interface calling fails, and executing the following steps:
analyzing a programming interface calling result and an Android log, finding out missing classes and/or resources, removing the missing classes and/or resources from an reduction set to generate a new reduction set, and reducing the APK of an original application program according to the new reduction set to generate a new APK file.
Fig. 5 is a flowchart illustrating steps of an APK reduction iteration test according to an embodiment of the present invention. Referring to fig. 5, in the embodiment, after the installation test is performed on the reduced APK, it is determined that the application program can normally run, if so, the reduction is ended, and if not, the reduction set is re-determined by analyzing the android log, and the APK is re-reduced.
The installation test is to install the reduced APK generated by the APK reduction module on the Android terminal, simultaneously place the reflection Dex corresponding to the APK into a designated folder of the Android terminal, and then start the Android terminal App. When the App is started, the interoperation system detects and loads a reflection type Dex of the App, and an interoperation interface is exposed outwards. And then, calling the interoperation interface to obtain a calling result.
The judgment result mainly judges whether the reduced APK can support the normal calling of the programming interface, and the judgment standards are three, namely whether the APK can be correctly installed, whether the programming interface can be normally called and whether the calling result of the programming interface is correct. Wherein, whether the APK can be correctly installed or not is mainly detected, and the accuracy of APK reduction, especially the validity of a re-signature is detected; whether a programming interface can be normally called or not is mainly detected whether class, resource and shared library are lost or not; and if the calling result of the programming interface is correct, mainly detecting the class, the resource and the shared library of another form to be missing. This type of miss does not directly result in a program crash, but rather appears as a result of program behavior errors. For example, for a programmatic interface accessing a local database, if the local database resources are missing, the programmatic interface can still call correctly, but it will return no data.
If the detection is correct, the Android application program reduction work is finished; if any detection item is wrong, error analysis is needed, missing codes and resources are found, and APK reduction is carried out again.
And analyzing the Android log, adjusting the reduction set to be executed when the test fails, mainly taking charge of analyzing the test result and the Android log, finding the missing class, resource or shared library, deleting the class, resource or shared library from the reduction set, and carrying out APK reduction again.
If the installation process of the APK fails, the re-signature of the APK is invalid due to a large probability, and the signature process needs to be checked; if the calling process of a certain programming interface fails, the return information of the interoperation interface needs to be analyzed first. If the DeadObject is wrong, the App is not correctly started or is killed, a global object cannot be provided for a programming interface calling process, and the Android log needs to be further analyzed to find out specific error information; if the error is the class missing error, the relevant class missing of the programming interface calling process is indicated, and the class needs to be deleted from the reduction set; in general, the programming interface calling process does not use the resources and the shared libraries, so that the error of missing the resources and the shared libraries can be avoided. Then, the Android log needs to be analyzed. In general, the missing class name or resource name can be directly found according to NoClassDefFoundError, ClassNotFoundDexception and FileNotFoundDexception of the Android log; if the calling result of a certain programming interface is incorrect, the common error is that the local database resource is deleted, so that the access to the local database is incorrect. At this point the corresponding database resource needs to be deleted from the reduction set.
For errors that cannot be located and analyzed by a program, a specific problem-specific analysis is required. To achieve automation, a dichotomy based error localization method is generally proposed herein for the worst case, i.e. without any error-prompting information. Before APK reduction, the reduction sets need to be sorted, and the step is to maintain the ordering of the reduction sets. Then, by utilizing a dichotomy, firstly, the reduction of the content of the first half of the reduction set is tried, and if an error exists, the error can be positioned in the first half of the reduction set; if there are no errors, the error may be located at about the second half of the reduced set. Bisection is continued until the missing key class or resource is found. During multiple iterations, a global dichotomy result may be shared. That is, if it is proved in the previous iteration that no error occurs when deleting the first n classes, when an error occurs in the next iteration, the location of the error is definitely not in the first n classes, so as to reduce repeated calculation. The method can also be used as an assistant for developers, and when the error range is reduced to a certain degree, the developers can directly determine the error position according to experience.
Fig. 6 is a flowchart illustrating steps of a method for reducing Android applications guided by a programming interface according to an embodiment of the present invention. Referring to fig. 6, in the embodiment, an Android application calls a programming interface, stack information generated in the running process of the programming interface is acquired and analyzed, an APK file is analyzed, a reduction set is determined according to the analysis results of the APK file and the APK file, so that the support of the APK on the running of the programming interface after reduction is ensured, an installation test is performed after each APK reduction, it is determined that the application can run normally, reduction is finished if the APK is reduced, and otherwise, the reduction set is determined again by analyzing an Android log, and the APK is reduced again.
With the above embodiments, the application further provides a method for reducingthe application program aiming at the newly added programming interface of the Android system. Specifically, the method may include the steps of:
aiming at a newly added programming interface of an Android system, the method for reducingthe application program comprises the following steps:
adding codes, resources and shared libraries depended by the newly added programming interface based on the new APK file, and updating the application program;
acquiring and analyzing stack information of the updated calling process of the application program to the newly added programming interface, and acquiring a content list appearing in the newly added stack process;
deleting a content list appearing in the process of adding a stack from the reduction set to obtain a new reduction set;
and according to the new reduction set, reducing the APK file of the updated application program to generate an updated APK file capable of supporting the operation of the newly added programming interface.
Through the embodiment, the original application does not need to be reduced again, and the reducibility of the application can be finished only by adding the code, the resource and the shared library which are depended by the newly added programming interface on the basis of the reducibility application. On the one hand, since APK has been reduced and the volume has been reduced, the time taken for its installation test is reduced. On the other hand, the calling process of the newly added programming interface is relatively simple, and related classes and resources are relatively few, so that the number of iteration rounds is not too large, even iteration is not needed, and the process of reducing the duplicate is efficiently simplified.
Based on the same inventive concept, the embodiment of the present invention provides a software interconnection interface oriented application reduction system 600. Fig. 7 is a block diagram of a software interconnection interface oriented application reduction system 600 according to an embodiment of the present invention. As shown in fig. 7, the system 600 includes:
a stack information obtaining module 601, configured to obtain stack information of an application;
a stack information analysis module 602, configured to analyze stack information of the application program and obtain a first analysis result;
the APK analysis module 603 is configured to analyze an APK file of the application program to obtain a second analysis result;
a reduction set determination module 604, configured to determine a reduction set according to the first analysis result and the second analysis result;
an APK reduction module 605, configured to perform reduction on the APK file of the application according to the reduction set, and generate a new APK file.
Optionally, the stack information obtaining module 601 includes:
the stack information configuration submodule is used for setting stack information record configuration, transmitting a configuration file to the Android terminal and starting stack information records;
the programming interface calls the traversal submodule and is used for starting the application program to be reduced, calling each programming interface in sequence and checking a return result;
and the recording submodule is used for terminating the stack information recording after all the stack information is correctly called, and generating a recording file.
The contents recorded by the recording file comprise a method call stack, a call parameter type, a call parameter instance and a return value in an App starting process and a programming interface calling process.
Optionally, the stack information obtaining module 601 further includes:
the grading submodule is used for grading configuration and acquisition, dividing the Android program operation into a plurality of stages, respectively capturing respective stack information of the plurality of stages, and forming a plurality of stack information recording files;
the content sub-module is used for configuring and acquiring content, capturing the stack information for multiple times, capturing different contents in the stack information each time, and respectively generating a plurality of record files of the stack information so as to reduce the size of the record file of each stack information;
and the classification submodule is used for classifying, configuring and obtaining, realizing continuous reduction of a capture set based on a configured code packet or class, and finally limiting the size of a record file of a plurality of stack information within an acceptable range.
Optionally, the stack information analysis module 602 includes:
the stack information analysis submodule is used for analyzing a recording file of stack information, analyzing method, parameter and return value information in the file according to a self-defined grammar rule, and acquiring a content list appearing in the whole stacking process so as to generate a first analysis result, wherein the content list appearing in the stacking process comprises: a class list, a resource list, and a shared library list.
Optionally, the APK analysis module 603 includes:
the content list extraction submodule is used for reading Dex byte code files in the APK, acquiring a list of all classes in the application, reading/assets and/res folders in the APK, acquiring a list of all resource files in the application and reading a list of all shared library files under/lib folder files in the APK by utilizing the class and the method for analyzing and modifying the Dex files in a jar package of a Dex2jar tool;
and the second analysis result generation sub-module is used for generating a second analysis result according to the list of the classes, the list of the resource files and the list of the shared library files.
Optionally, the reduction set determination module 604 comprises: a
The reduction set determining submodule is used for comparing the second analysis result with the first analysis result, solving a difference set of the second analysis result and the first analysis result, and removing a content list appearing in the stacking process from an APK content list to obtain a final reduction set, wherein the APK content list comprises: a list of all classes in the application, a list of all resource files in the application, a list of all shared library files in the APK/under the lib folder file.
Optionally, the APK reduction module 605 includes:
the resource and shared library processing submodule is used for deleting a resource file list and a shared library file list which appear in the reduction set from an APK file of an application program aiming at the resource and the shared library;
the Dex file processing submodule is used for operating Dex byte codes of an application program aiming at classes, reading the content of the Dex file, deleting the classes appearing in the reduction set and regenerating the Dex file;
the APK file generation submodule is used for obtaining the APK files after the reduction is finished according to the steps, repacking the APK files after the reduction is finished into APK, applying a signature and generating available new APK files;
and the reflection Dex file generation submodule is used for generating a new reflection Dex file according to the new APK file and the original programming interface code so as to support the normal calling of the programming interface.
Optionally, the system further comprises:
the installation and import submodule is used for installing a new APK file on the Android terminal and importing the reflection Dex into the Android terminal;
based on a resource reflection mechanism and an efficient interoperation technology of a cloud-end fusion system, an application programming interface is generated through external monitoring and control by utilizing a resource reflection mechanism inside an information system;
the calling result obtaining submodule is used for sequentially calling each programming interface by utilizing the interfaces to obtain calling results;
if the application program is started normally and the returned results of all the programming interfaces are correct, the application reduction is considered to be successful, and the method is ended;
if a problem occurs in the starting process, the reduction set is incorrect, missing classes or resources need to be positioned, a new APK file is regenerated, and the steps are executed again;
the APK file regeneration submodule is used for regenerating a new APK file aiming at the condition that App is abnormally started or programming interface calling fails, and executing the following steps:
analyzing a programming interface calling result and an Android log, finding out missing classes and/or resources, removing the missing classes and/or resources from an reduction set to generate a new reduction set, and reducing the APK of an original application program according to the new reduction set to generate a new APK file.
Optionally, the system further comprises:
newly-increased programming interface subtracts submodule piece again for to the newly-increased programming interface of Android system, subtract application again, include:
adding codes, resources and shared libraries depended by the newly added programming interface based on the new APK file, and updating the application program;
acquiring and analyzing stack information of the updated calling process of the application program to the newly added programming interface, and acquiring a content list appearing in the newly added stack process;
deleting a content list appearing in the process of adding a stack from the reduction set to obtain a new reduction set;
and according to the new reduction set, reducing the APK file of the updated application program to generate an updated APK file capable of supporting the operation of the newly added programming interface.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should be further noted that, in the present embodiment, relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method for reducing an application program guided by a software interconnection interface and the system for reducing an application program guided by a software interconnection interface provided by the present invention are described in detail above, in this embodiment, a specific example is applied to explain the principle and the implementation manner of the present invention, and the description of the above embodiment is only used to help understanding the method and the core idea of the present invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.

Claims (10)

1. A method for reducing an application program guided by a software interconnection interface is characterized by being applied to an Android application program and comprising the following steps:
acquiring stack information of an application program;
analyzing the stack information of the application program to generate a first analysis result;
analyzing the APK file of the application program to generate a second analysis result;
determining a reduction set according to the first analysis result and the second analysis result;
according to the reduction set, carrying out reduction on the APK file of the application program to generate a new APK file;
the acquiring stack information of the application program comprises:
recording stack information of a calling process and an App starting process of an application programming interface by adopting an internetware behavior reflection technology based on a computational reflection mechanism;
and constructing two part models of the Android application in operation by utilizing the monitoring function of the internetware behavior reflection technology on the application behaviors, wherein the two part models comprise an operation stack model and an operation stack model, so as to obtain stack information of the Android application in operation.
2. The method of claim 1, wherein obtaining stack information for an application comprises:
setting stack information record configuration, transmitting a configuration file to an Android terminal, and starting stack information records;
starting an application program to be reduced, sequentially calling each programming interface, and checking a return result;
after all the stack information is correctly called, stopping stack information recording and generating a recording file;
the contents recorded by the recording file comprise a method call stack, a call parameter type, a call parameter instance and a return value in an App starting process and a programming interface calling process.
3. The method of claim 1, wherein obtaining stack information for an application comprises:
the method comprises the steps of configuring and obtaining in stages, dividing Android program operation into a plurality of stages, and respectively capturing respective stack information of the plurality of stages to form a plurality of stack information recording files;
configuring and acquiring the sub-content, capturing the stack information for multiple times, capturing different contents in the stack information each time, and respectively generating a plurality of recording files of the stack information so as to reduce the size of each recording file of the stack information;
and classifying for configuration and acquisition, realizing continuous reduction of a capture set based on a configured code packet or class, and finally limiting the size of the record files of a plurality of stack information within an acceptable range.
4. The method of claim 1, wherein analyzing the stack information of the application to generate a first analysis result comprises:
analyzing a recording file of stack information, analyzing method, parameter and return value information in the file according to a self-defined grammar rule, and acquiring a content list appearing in the whole stacking process so as to generate a first analysis result, wherein the content list appearing in the stacking process comprises: a class list, a resource list, and a shared library list.
5. The method of claim 1, wherein analyzing the APK file of the application to generate a second analysis result comprises:
the method comprises the steps of utilizing a class and a method for analyzing and modifying a Dex file in a jar package of a Dex2jar tool, reading a Dex byte code file in an APK, obtaining a list of all classes in an application, reading/assets and/res folders in the APK, obtaining a list of all resource files in the application, and reading a list of all shared library files under/lib folder files in the APK;
and generating a second analysis result according to the list of the classes, the list of the resource files and the list of the shared library files.
6. The method of claim 1, wherein determining a reduction set from the first analysis result and the second analysis result comprises:
comparing the second analysis result with the first analysis result, solving a difference set of the second analysis result and the first analysis result, and removing a content list appearing in the stacking process from an APK content list to obtain a final reduction set, wherein the APK content list comprises: a list of all classes in the application, a list of all resource files in the application, a list of all shared library files in the APK/under the lib folder file.
7. The method of claim 1, wherein reducing the APK file of the application according to the reduction set comprises:
deleting a resource file list and a shared library file list which appear in the reduction set from an APK file of an application program aiming at the resource and the shared library;
aiming at the classes, operating the Dex byte codes of the application programs, reading the content of the Dex file, deleting the classes appearing in the reduction set, and regenerating the Dex file;
obtaining the APK file after the reduction is completed according to the steps, repacking the APK file after the reduction is completed into an APK, applying a signature, and generating a new available APK file;
and generating a new reflection Dex file according to the new APK file and the original programming interface code so as to support the normal calling of the programming interface.
8. The method of claim 1, further comprising:
installing a new APK file on the Android terminal, and importing a reflection Dex into the Android terminal;
based on a resource reflection mechanism and an efficient interoperation technology of a cloud-end fusion system, an application programming interface is generated through external monitoring and control by utilizing a resource reflection mechanism inside an information system;
sequentially calling each programming interface by using the interfaces to obtain calling results;
if the application program is started normally and the returned results of all the programming interfaces are correct, the application reduction is considered to be successful, and the method is ended;
if a problem occurs in the starting process, the reduction set is incorrect, missing classes or resources need to be positioned, a new APK file is regenerated, and the steps are executed again;
the method comprises the following steps of generating a new APK file again aiming at the condition that App is abnormally started or programming interface calling fails, and executing the following steps:
analyzing a programming interface calling result and an Android log, finding out missing classes and/or resources, removing the missing classes and/or resources from an reduction set to generate a new reduction set, and reducing the APK of an original application program according to the new reduction set to generate a new APK file.
9. The method of claim 1, further comprising:
aiming at a newly added programming interface of an Android system, the method for reducingthe application program comprises the following steps:
adding codes, resources and shared libraries depended by the newly added programming interface based on the new APK file, and updating the application program;
acquiring and analyzing stack information of the updated calling process of the application program to the newly added programming interface, and acquiring a content list appearing in the newly added stack process;
deleting a content list appearing in the process of adding a stack from the reduction set to obtain a new reduction set;
and according to the new reduction set, reducing the APK file of the updated application program to generate an updated APK file capable of supporting the operation of the newly added programming interface.
10. A software interconnection interface oriented application reduction system is applied to Android applications and comprises the following steps:
the stack information acquisition module is used for acquiring stack information of the application program;
the stack information analysis module is used for analyzing the stack information of the application program and acquiring a first analysis result;
the APK analysis module is used for analyzing the APK file of the application program and acquiring a second analysis result;
a reduction set determination module, configured to determine a reduction set according to the first analysis result and the second analysis result;
the APK reduction module is used for reducing the APK file of the application program according to the reduction set to generate a new APK file;
the acquiring stack information of the application program comprises:
recording stack information of a calling process and an App starting process of an application programming interface by adopting an internetware behavior reflection technology based on a computational reflection mechanism;
and constructing two part models of the Android application in operation by utilizing the monitoring function of the internetware behavior reflection technology on the application behaviors, wherein the two part models comprise an operation stack model and an operation stack model, so as to obtain stack information of the Android application in operation.
CN202011233823.0A 2020-11-06 2020-11-06 Software interconnection interface-oriented application program reduction method and system Active CN112328266B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011233823.0A CN112328266B (en) 2020-11-06 2020-11-06 Software interconnection interface-oriented application program reduction method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011233823.0A CN112328266B (en) 2020-11-06 2020-11-06 Software interconnection interface-oriented application program reduction method and system

Publications (2)

Publication Number Publication Date
CN112328266A CN112328266A (en) 2021-02-05
CN112328266B true CN112328266B (en) 2021-09-28

Family

ID=74316443

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011233823.0A Active CN112328266B (en) 2020-11-06 2020-11-06 Software interconnection interface-oriented application program reduction method and system

Country Status (1)

Country Link
CN (1) CN112328266B (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106155751A (en) * 2016-08-02 2016-11-23 传线网络科技(上海)有限公司 Application packing and issuing method and device
CN107180053A (en) * 2016-03-11 2017-09-19 中国移动通信集团河北有限公司 A kind of data warehouse optimization method and device
CN108920156A (en) * 2018-05-29 2018-11-30 Oppo广东移动通信有限公司 Application program prediction model method for building up, device, storage medium and terminal
CN109636600A (en) * 2018-11-26 2019-04-16 上海财经大学 A kind of investment combination method about subtracted using dimension
CN112099880A (en) * 2020-08-12 2020-12-18 北京大学 Method and system for reducing application program driven by scene

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7818722B2 (en) * 2006-06-09 2010-10-19 International Business Machines Corporation Computer implemented method and system for accurate, efficient and adaptive calling context profiling
US9239715B1 (en) * 2013-09-25 2016-01-19 Amazon Technologies, Inc. Cancel and rollback update stack requests
CN105740125B (en) * 2016-01-29 2018-03-30 四川秘无痕信息安全技术有限责任公司 Obtain Android application program launchings number and the method for time
WO2018046440A1 (en) * 2016-09-06 2018-03-15 Eidgenoessische Technische Hochschule Zurich (Ethz) Ray-tracing methods for realistic interactive ultrasound simulation
EP3379413A1 (en) * 2017-03-21 2018-09-26 Nokia Solutions and Networks Oy Optimization of a software image layer stack
CN109189469B (en) * 2018-06-22 2020-08-28 北京大学 Reflection-based android application micro-servitization method and system

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107180053A (en) * 2016-03-11 2017-09-19 中国移动通信集团河北有限公司 A kind of data warehouse optimization method and device
CN106155751A (en) * 2016-08-02 2016-11-23 传线网络科技(上海)有限公司 Application packing and issuing method and device
CN108920156A (en) * 2018-05-29 2018-11-30 Oppo广东移动通信有限公司 Application program prediction model method for building up, device, storage medium and terminal
CN109636600A (en) * 2018-11-26 2019-04-16 上海财经大学 A kind of investment combination method about subtracted using dimension
CN112099880A (en) * 2020-08-12 2020-12-18 北京大学 Method and system for reducing application program driven by scene

Also Published As

Publication number Publication date
CN112328266A (en) 2021-02-05

Similar Documents

Publication Publication Date Title
Ŝevčik et al. Relaxed-memory concurrency and verified compilation
CN106371940B (en) Method and device for solving program crash
Liu et al. Grail: Context-aware fixing of concurrency bugs
Sridharan et al. Thin slicing
Altekar et al. OPUS: Online Patches and Updates for Security.
Heelan et al. Gollum: Modular and greybox exploit generation for heap overflows in interpreters
Pina et al. Rubah: DSU for Java on a stock JVM
US11249758B2 (en) Conditional branch frame barrier
US9417931B2 (en) Unified metadata for external components
CN109117164B (en) Micro-service updating method and system based on difference analysis of key elements
WO2016179266A1 (en) Software dependency shading
CN112099880B (en) Method and system for reducing application program driven by scene
Bai et al. {DSAC}: Effective Static Analysis of {Sleep-in-Atomic-Context} Bugs in Kernel Modules
Spear et al. Solving the starting problem: device drivers as self-describing artifacts
Sun et al. {KSG}: Augmenting kernel fuzzing with system call specification generation
Novikov et al. Verification of operating system monolithic kernels without extensions
Nikolić et al. Reachability analysis of program variables
CN111352631A (en) Interface compatibility detection method and device
CN112328266B (en) Software interconnection interface-oriented application program reduction method and system
Dalsgaard et al. Private memory allocation analysis for safety-critical Java
Chen et al. Hopper: Interpretative fuzzing for libraries
CN116578282A (en) Code generation method, device, electronic equipment and medium
Bai et al. Effective detection of sleep-in-atomic-context bugs in the Linux kernel
Borodin et al. Deterministic static analysis
Ma et al. Efficient Scheduler Live Update for Linux Kernel with Modularization

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information

Address after: No. 826, building 12345, Phoenix legend, Hanbang, Jingyue Development Zone, Changchun City, Jilin Province

Applicant after: Changchun interui Software Co.,Ltd.

Address before: 100080 room 1608, 16 / F, Haidian new technology building, 65 North Fourth Ring Road West, Haidian District, Beijing

Applicant before: BEIJING INTERNETWARE Ltd.

Address after: No. 826, building 12345, Phoenix legend, Hanbang, Jingyue Development Zone, Changchun City, Jilin Province

Applicant after: Intel Technology Co.,Ltd.

Address before: No. 826, building 12345, Phoenix legend, Hanbang, Jingyue Development Zone, Changchun City, Jilin Province

Applicant before: Changchun interui Software Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant