CN109614105A - A kind of Android application return stack state static simulation method of Starting mode sensitivity - Google Patents
A kind of Android application return stack state static simulation method of Starting mode sensitivity Download PDFInfo
- Publication number
- CN109614105A CN109614105A CN201811522157.5A CN201811522157A CN109614105A CN 109614105 A CN109614105 A CN 109614105A CN 201811522157 A CN201811522157 A CN 201811522157A CN 109614105 A CN109614105 A CN 109614105A
- Authority
- CN
- China
- Prior art keywords
- activity
- stack state
- starting
- return
- stack
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/43—Checking; Contextual analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Software Systems (AREA)
- Debugging And Monitoring (AREA)
- Stored Programmes (AREA)
Abstract
A kind of Android application return stack state static simulation method of Starting mode sensitivity.This method comprises: extracting part from Android application AndroidManifest.xml file returns to stack state relevant configuration, and the heap memory distributing point by constructing an object for each Activity class and the call back function calling sequence being rewritten according to the control stream each Activity object of tissue are that Android application construction assists principal function;By carrying out the target Activity class in direction analysis extraction Activity starting relationship to auxiliary principal function and returning to stack state relevant configuration, to construct the starting figure of Activity object;Start figure construction based on Activity and returns to stack state transition figure.A variety of upper layer applications, such as GUI model construction, GUI test, bug excavation, defects detection can be supported by returning to stack state transition figure, and avoid the illegal route problem caused by being currently up the insensitive Activity branch instruction analysis of mode.
Description
Technical field
The invention belongs to Android mobile application software Static Analysis Technology fields, and in particular to a kind of Starting mode is quick
The return stack static simulation method of sense.
Background technique
Android has become most popular operating system in mobile device.The type of Android application is abundant, quantity
It is huge, it is used widely in the various aspects of people's life.Activity is the most important component of Android application program
One of, it is responsible for providing a user interactive interface.The Activity example that android system generates software running process is with stack
Form group, which is woven in, to be returned in stack, so that user correctly returns to previous bed boundary (preceding layer Activity example).Return to stack top
Layer Activity example is current interface, interacts jumping between capable of triggering Activity, changes and returns to stack state.
The relationship that jumps between Activity constitutes the general frame of Android application, and a variety of upper layers can be supported by modeling to it
Research and application, such as: GUI model construction, GUI test, bug excavation, defects detection etc..Activity jump by
Activity starting and return action triggering, and the target Activity of return action needs to return to stack state by current
It determines.Therefore, it is most important to jump model for building Activity for the variation of accurate simulation return stack state.
Android CLP AD can control Activity by configuring attribute relevant to stack state is returned
Stack state variation is returned caused by starting.For the Activity starting, default configuration requires system creation one new
Activity example is simultaneously pressed into return stack.Particular arrangement then can generate certain effects to stack is returned, such as: if a starting
" launchMode " attribute of target Activity is set as " singleTask " in relationship, and its " taskAffinity " attribute
Value is identical as application packet name, then whether system can first look for returning and have existed in stack when starting target Activity
The example of target Activity, and if it exists, will then return to Activity example all destructions in stack more than the example, otherwise create
It builds the new example of a target Activity and is pressed into return stack.
Current Activity jumps static analysis and does not extract to the association attributes for influencing to return stack state, and assumes
All Activity are activated with default configuration.Clearly for having used the Android of particular arrangement to apply, current method
Its state change for returning to stack can not be correctly simulated, so that the target Activity of the positioning return action of mistake, generates illegal
Activity is jumped.The upper layer based on Activity branch instruction analysis is seriously affected comprising the illegal Activity the illegal route jumped
Using, such as: in the GUI test based on model, test case by Dynamic Execution, and is executed illegal in the form of path of motion
Path Shi Zehui leads to test crash since mistake executes illegal, influences testing efficiency and accuracy.
Inter-component communication in android system transmits information using intent object, to start target element.For
Determining target Activity simultaneously extracts attribute configuration relevant with return stack state, needs to parse by direction analysis
The field contents of intent object.Different from only one entrance of typical Java program, Android application program includes a large amount of returns
Letter of transfer number, user and system acting can all trigger corresponding readjustment, i.e. Android application program includes multiple entrances.Therefore, how
The event-driven complex control stream that Android program is effectively treated is directed to the challenge that analysis needs to overcome.
Summary of the invention
Object of the present invention is to solve, current Activity branch instruction analysis is unwise to Starting mode to be caused to return to stack state simulation
Incorrect problem, the Android application for providing a kind of Starting mode sensitivity return to stack state static simulation method.
Technical solution of the present invention
A kind of Android application return stack state static simulation method of Starting mode sensitivity, includes the following steps:
1st, the basic conception that the method is related to:
1) 1, Activity Starting mode are defined;
2) Activity starting figure (Activity launching graph, abbreviation ALG);
3) stack state transition figure (back stack transition graph, abbreviation BSTG) is returned;
2nd, the Android application of Starting mode sensitivity returns to the specific steps of stack state static simulation method:
Step 1, Android application pretreatment;
Step 2 generates Activity starting figure by the Activity branch instruction analysis of Starting mode sensitivity;
Step 3 generates return stack state transition figure based on Activity starting figure.
The method of the present invention the specific implementation process is as follows:
1st, the basic conception that the method for the present invention is related to;
The definition of 1.Activity Starting mode;
When android system starts Activity, the association attributes configuration for returning to stack state is influenced, is defined as
Activity Starting mode;The Android association attributes for influencing Starting mode are defined as returning to stack state association attributes.
The method summarizes 4 return stack state association attributes and 7 Starting mode;4 return stack states are related
Attribute is respectively: target Activity " launchMode " and " taskAffinity " in starting relationship, starts Activity
When Activity between the mark of Intent object that is transmitted of the API Calls that communicate, if having the calling of API finish ().
In one Activity starting relationship, its Starting mode is determined to the configuration of this four attributes.
7 kinds of Starting mode be respectively standard, singleTop, standard-clearTop,
SingleTop-clearTop, reorderToFront, singleTask and standard | finish.Effectively start mode and
Its influence to stack is returned, such as table 1, wherein Activity class cnStart c with Starting mode ltxIt is designated asIf current
Returning to stack state is < ac1,ac2,…,acx-1,acx,acx+1,…,acn>, wherein acxIndicate Activity class cxAn example,
ac1For stack bottom example, acnFor stack top example;a'cxIt is to be different from acxCxNew example.
Table 1 returns to stack variation with different Starting mode starting Activity bring.
2.Activity starting figure (Activity Launching Graph, abbreviation ALG) definition;
It is four-tuple that Activity, which starts figure: ALG=(LT, N, E, s).LT is the set of Starting mode;N is node collection
It closes, i.e. the set of Activity class;E is oriented line set, E={ < ns,nt,lt>|ns∈N,nt∈ N, lt ∈ LT }, wherein nsIt is
The initial point on side, ntIt is the terminal on side, lt is the element in Starting mode set LT, indicates source Activity class nsIn a manner of lt
Start target Activity class nt;S is the start node of ALG, for the Main Activity of Android application.
3. returning to stack state transition figure (Back Stack Transition Graph, BSTG) definition;
Returning to stack state transition figure is four-tuple: BSTG=(LT, BS, ST, bsinit).BS is to return to stack state set: BS
={ < c1,c2,…,ci,…,cn>|ci∈ N }, wherein c1For the type of the stack bottom Activity example of return stack, cnTo return to stack
Stack top example type.ST is the set of directed edge, indicates to return to stack state transition: ST=L ∪ F, and wherein L is Activity
Start triggered return stack state transition set, the return stack state transition set that F is triggered by return action.L=<
bss,bst,lt>|bss∈BS,bst∈ BS, lt ∈ LT }, wherein bssStack state, bs are returned for sourcetFor target Activity shape
State.bsinitFor start node, the return stack state which indicates only includes the example of a Main Activity.
2nd, specific step is as follows for the Android application return stack state static simulation method of Starting mode sensitivity:
4. step 1 pre-processes Android application;
Android application pretreatment includes two parts: first part is AndroidManifest.xml document analysis, from
The keynote message extracted in file includes: 1) Android application packet name;2) the Activity class name set ACT registered;3) each
The intent filter of Activity class;4) " taskAffinity " and " launchMode " attribute value of each Activity class;
Second part is to construct auxiliary main () for direction analysis, to support the sensitivity of Starting mode described in subsequent step 2
Activity branch instruction analysis.Auxiliary main () includes that the heap memory of an object of each Activity class distributes sentence,
And the call back function call statement of the foundation control stream tissue of each Activity object.
Different from traditional java applet only one program entry (main function), Android application program is event
Driving, is made of a large amount of call back functions.These call back functions include life cycle callback and non-life cycle callback.Non- Life Cycle
Phase readjustment includes system readjustment and GUI readjustment again.In order to carry out direction analysis, need to construct an auxiliary principal function for these times
Letter of transfer number is organized according to control stream.Fig. 1 illustrates the structure of auxiliary main ().For Activity life cycle callback
Function: onCreate () and onDestroy () indicates respectively the beginning and end of Activity life cycle;onStart()
With onStop () respectively Activity visually with it is not visible when call automatically;OnResume () and onPause () are then indicated
Can the operation cycle, user can operate Activity within this section of period, for example click button.The system that system voluntarily triggers is returned
Adjust (such as onLocationChanged ()) and the GUI readjustment (such as onClick ()) of user behavior triggering that can interact
It is called in period.When assisting principal function for Android application build, the call back function being rewritten only is considered.
5. step 2 generates Activity starting figure by the Activity branch instruction analysis of Starting mode sensitivity;
The Activity branch instruction analysis of Starting mode sensitivity includes the field sensitivity direction analysis rule of 10 object-orienteds
Start side create-rule with 8 Activity;10 direction analysis rules are directed to respectively: class instantiates sentence, Activity
Instantiation sentence, copy-statement, field reading statement, field write statement, method call sentence, the setting intent logo of class
Sentence, display intent analysis, implicit intent analysis and Activity start sentence;8 Activity start side create-rule
Be directed to respectively: invalid return stack state relevant configuration determines, singleTask starting side generates, singleTop-
ClearTop starting is generated when generating, standard-clearTop starting, reorderToFront starting side generates,
SingleTop starting is in generation, standard | it is generated when finish starts with standard starting side.
5.1 symbol definition
Symbol definition used in 2 ALG construction method of table
Table 2 lists the symbol definition that ALG construction method uses.First part is the abstract of java applet.C indicate class and
The set of interface, ACT indicate the set of all Activity classes.Each method body can be expressed as sentence s.Method body can be by
Object-instantiated, assignment, field are read, field is write, five kinds of atomic sentence compositions of method call.Object-instantiated means heap memory
Distribution.Second part defines the correlation technique used during direction analysis.Pt (r) indicates object pointed by pointer r
Set.FPt (r, f) provides object set pointed by the field f of pointer r.Part III provides used in determining Starting mode
Symbol.It is activated the launchMode of Activity class, taskAffinity, inter-component communication method transmitting when starting
The mark of intent object and the calling joint effect of finish () method return stack state, determine Starting mode.
The selectable value of launchMode attribute are as follows: " standard ", " singleTop ", " singleTask ",
"singleInstance".Invalid flag (IVFLAG) is classified as to the influence for returning to stack according to Intent mark, there is criterion
Will (VFLAG) and other (OFLAG).The selectable value of VFLAG are as follows: " FLAG_ACTIVITY_CLEAR_TOP ", " FLAG_
ACTIVITY_CLEAR_TOP ", " FLAG_ACTIVITY_REORDER_TO_FRONT ".The present invention is causing multiple to return to stacks
Interactive intent mark is known as invalid flag.Part IV gives ALG related symbol.It is constructed by direction analysis
Each node is the object of an Activity class in Activity starting figure.
The field sensitivity direction analysis rule of 5.2 object-orienteds
Direction analysis is carried out to auxiliary principal function, the node set N of the ALG and set E on side is empty when initial.[RULE-
1]-[RULE-6] corresponds to the rule of direction corresponding to five atomic sentences.[RULE-1] corresponds to class and instantiates sentence.
[RULE-2] is specifically in the instantiation of Activity class.The creation of each Activity object is the newly-increased section of ALG
Point.[RULE-3]-[RULE-5] respectively corresponds assignment, field is read, field write statement.[RULE-6] has corresponded to the calling language of method
Sentence.Each method m includes its method name, parameter thismAnd pm, return value rm.It is disassembled for m that direction analysis is carried out to method m
Method body smAnd auxiliary sentence x :=rmAnalysis.
Android system is new to start by inter-component communication API, such as startActivity (intent)
Activity.Intent object determines target Activity.Intent can be divided into two types, explicit and implicit.Explicitly
Intent has recorded specific target Activity type.Implicit intent have recorded target Activity need to be implemented it is dynamic
Make, only have execute the Motor ability activities be likely to be activated.The movement that Activity is able to carry out is infused
Volume is in the intent filter of AndroidMainfest.xml.Android platform provides APIs to help intent object
Record target Activity relevant information, such as setComponent (), setAction ().For explicit intent, target
Activity type is stored in field Intent.mCompont.mClass.For implicit intent, target Activity
The movement needed to be implemented is stored in field Intent.mAction.Attribute field, which is arranged, for intent to start
It is special that Activity achievees the effect that, for example " FLAG_ACTIVITY_CLEAR_TOP " label claim system first looks for returning
In stack with the example of target Activity same type, and if it exists, will then return to the example in stack more than the example and all destroy.
[RULE-7]-[RULE-10] is that inter-component communication correlative is directed toward rule.[RULE-7] to intent indicate into
Row analysis.Intent mark is integer type.Intent object oiValue of statistical indicant is stored in by call method addFlags ()
MFlags field;The new mark of addition can also be subjected to step-by-step or fortune with having mark by call method setFlags ()
It calculates and is stored in mFlags field.[RULE-8] and [RULE-9] respectively analyzes explicit and implicit intent.For
Intent object oiThe subsidiary field targetClassName of character string type is constructed to store target Activity class name.
FindTarget () method return in [RULE-9] is able to carry out ojThe target Activity of movement gathers.[RULE-10] point
Analysed all Activity starting correlation APIs, comprising: startActivity (), startActivityForResult (),
StartActivityIfNeeded () and menuItem.setIntent ().In this rule, this indicates one
Activity example;The intent object o that starting Activity is transmittedjField targetClasssName have recorded target
Activity class name ok;GetActObj () obtains its unique instance o in heap memory according to class namel;GetFlags () will
Intent object ojThe integer that is stored of field mFlags be converted into attribute set and merge and return;GetLM () and GetTA () points
Not Huo Qu target Activity object launchMode and taskAffinity;GetFIN () obtains just analyzed method m
Method body either with or without call finish (); Indicate oiUnder Starting mode relevant configuration config
Start ol。
5.3Activity starts side create-rule
[RULE-11]-[RULE-18], which gives, generates ALG starting according to starting relationship between Activity and configuration information
The rule on side.[RULE-11] corresponds to the judgement of invalid configuration, and wherein pkName is the packet name of current Android application.When
When taf and current packet name be not identical, if system is mounted with application identical with taf, it can start in the return stack of the application
Target Activity.Invalid configuration can cause multiple interactions for returning to stack, do not start for the Activity of invalid configuration and generate
Start side.[RULE-12]-[RULE-18] respectively correspond Starting mode be singleTask, singleTop-clearTop,
Standard-clearTop, reorderToFront, singleTop, standard | the effective edge of finish, standard
It generates, wherein method ConfigVali () determines whether configuration information is effective according to [RULE-11], if effectively, returning
true。
6. step 3 generates return stack state transition figure based on Activity starting figure;
It returns to stack state transition figure construction method and figure ALG=(LT, N, E, s), a return stack shape is started with Activity
The number k comprising same type Activity example is at best able in state as input, output returns to stack state transition figure BSTG=
(LT,BS,ST,bsinit), its step are as follows:
(1) set BS is set, and ST is sky, and node queue stateQueue to be processed is sky;
(2) construction is initial returns to stack state node bsinit, the example of only one s of original state;
(3) by bsinitSet BS is added, and by bsinitIt is pressed into node queue stateQueue to be processed, is then followed successively by
Each return stack state node in queue adds out side, that is, returns to stack state variation caused by Activity starting and return
Stack state variation is returned caused by movement;
(4) the head of the queue state node currentState in stateQueue is popped up;CurrentState stack top
The type of Activity example is cs;
(5) current Activity class c in traversal Activity starting ringsGo out side.Go out side for every, according to 1 mould of table
Quasi- csStart target Activity c in a manner of lttStack state newState is returned afterwardslaunching;
(6) if newStatelaunchingIn Activity repeat example number be no more than k, construction from
CurrentState to newStatelaunchingSide l, and ST is added in l.
(7) if newStatelaunchingIn Activity repeat example number be no more than k andThen by newStatelaunchingSimultaneously set BS is added in indentation stateQueue;
(8) it if having more than 1 example in currentState, simulates after the top currentState element is popped and returns
Stack state newStateback, construct from currentState to newStatebackSide f, and ST is added in f;If
newStatebackNot in BS set, then by newStatebackIt is pressed into stateQueue;
(9) if stateQueue is not sky, (4) step is jumped to.
The advantages and positive effects of the present invention:
The method of the present invention generates Activity starting figure by the Activity branch instruction analysis of Starting mode sensitivity first, so
It is generated afterwards based on Activity starting figure and returns to stack state transition figure.Activity starting figure illustrates that Android application is each
Starting relationship between Activity class, focuses on the extraction of Starting mode.Return stack state transition figure simulates Activity and opens
Stack state variation is returned caused by dynamic and return action, can directly indicate that user may in dynamic operation Android application
The return stack state of appearance.
The advantages and positive effects of the present invention are embodied in:
(1) Starting mode is extracted, and simulates 7 kinds to return caused by different Starting mode starting Activity
Return stack state variation.The insensitive Activity branch instruction analysis of Starting mode assumes whole Activity in a manner of standard
It is activated.Therefore for having used the Android of special Starting mode to apply, the insensitive Activity of Starting mode is jumped point
Analysis can not correctly simulate it and return to stack state variation, to generate illegal Activity Changes, influence the upper layer based on this
Using.The return stack state transition figure of Starting mode sensitivity then can support a variety of upper layer applications (such as GUI model construction,
GUI test, bug excavation, defects detection etc.) while avoid the illegal route, to reach good effect.For example, being based on GUI
In the Android test of model, illegal test case can be effectively avoided using BSTG, promotes testing efficiency, reduce artificial behaviour
Make.
(2) by returning to stack state transition figure, it can be found that Android applies a return stack shape in using process
Whether state can have multiple examples with Activity.In Android application, Activity starting ring is being performed a plurality of times
Afterwards, there may be the multiple examples of same type in return stack.Excessive same type Activity example can occupy a large amount of system resources, make
Caton is used at user, influences user experience.Returning to stack state transition figure can be provided with for Android CLP AD
Information is imitated, to help to adjust the Starting mode of Activity in Activity starting ring, reasonable management returns to stack, to be promoted soft
Part quality optimizes user experience.
[Detailed description of the invention]
Fig. 1 is the structure for assisting main ().
Fig. 2 is the partial code segment of Android application software ConnectBot.
Fig. 3 is the overall framework of the sensitive return stack state static simulation method of Starting mode.
The part Activity that Fig. 4 is Android application software ConnectBot starts figure.
The part that Fig. 5 is Android application software ConnectBot returns to stack state transition figure.
[specific embodiment]
It is realized now in conjunction with the method for the present invention and stack state is returned to the part of the Android application software ConnectBot of Fig. 1
Transition figure.The basic conception that the method for the invention is related to: Activity Starting mode, Activity starting figure and return stack
The particular content of status transition chart is detailed in Summary (omiting herein).The return stack state static simulation of Starting mode sensitivity
Method is general frame such as Fig. 3 that ConnectBot constructs BSTG.The specific implementation steps are as follows:
(1) intermediate code of generation is pre-processed by after Android installation kit decompiling first, from
It is extracted in AndroidManifest.xml file and applies packet name, Activity class set, Main Activity, each Activity
Part return stack state relevant configuration (launchMode and taskAffinity), each Activity can received action,
Then the direction analysis for the Android application program that building auxiliary main () drives behavior with support;(2) to auxiliary main
() carries out the direction analysis of object-oriented, and constructs Activity starting figure;(3) it is generated based on ALG and returns to stack state transition
Figure.1. pretreatment
Pretreatment first parses the AndroidMainfest.xml file of Fig. 2 code snippet: ConnectBot is answered
With the entitled org.connectbot (the 26th row) of packet;29-30 row determines that Main Activity is
HostListActivity;Code snippet includes the registration of 3 Activity classes, Activity class set ACT=altogether
{ HostListActivity, ConsoleActivity, SettingsActivity } (the 27th row, the 32nd row and the 37th row);
The launchMode attribute of HostListActivity and SettingsActivity is sky, therefore its launchMode is default
The launchMode attribute value of value standard, ConsoleActivity are singleTop (the 33rd row);Three Activity
TaskAffinity attribute value be sky, therefore using and application register identical default value " org.connectbot ";Only
There is ConsoleActivity to have registered the ability (the 35th row) of reception " action.View " movement, implicit intent can be sent out
" Intent.ACTION_VIEW " movement out is responded.
It is the auxiliary main () of ConnectBot building according to Fig. 1, structure is as follows:
1 void main(){
2 r1:=new HostListActivity ();
3 r2:=new ConsoleActivity ();
4 r3:=new SettingsActivity ();
5 …
6 INVOKECALLBACK(r1);
7 INVOKECALLBACK(r2);
8 INVOKECALLBACK(r3);
9 …}
Only comprising the call statement for the call back function being rewritten in auxiliary main ().
2. generating ALG
Direction analysis and the generation of object-oriented are carried out according to the rule of [RULE-1]-[RULE-18] to auxiliary main ()
Activity starting figure ALG=(LT, N, E, s).The 2-4 row of auxiliary main () is respectively the example of three Activity classes
Change, android system is that respective object distributes heap memory space.According to [RULE-2], N={ o2, o3, o4, that is, it is respectively
The object of HostListActivity, ConsoleActivity, SettingsActivity.
Fig. 2 code snippet the 8th, 21,11-12 row have invoked inter-component communication API respectively.According to [RULE-10], the generation
Chip segment altogether there are three starting relationship, if code line 8,21, the corresponding starting relationship of 11-12 be e1, e2, e3.These three startings
The details of relationship are as shown in table 3.E1 starts target Activity by implicit intent object, which provides
Target Activity needs received movements " Intent.ACTION_VIEW " (the 7th row of Fig. 2), locates according to [RULE-9] and in advance
Each Activity received can be acted after reason, can determine that the target Activity of e1 is ConsoleActivity.The mesh of e1
LaunchMode the and taskAffinity value for marking Activity is respectively " singleTop " and " org.connectbot ", is opened
There is no the calling of finish () when moving-target Activity, is not provided with intent mark, determines e1's according to [RULE-11]
Starting mode relevant configuration is effectively configuration, determines that the Starting mode of e1 is singleTop according to [RULE-16].E2 and e3 are equal
By explicit intent object start target Activity, respectively HostListActivity (the 19th row of Fig. 2) and
SettingsActivity (the 12nd row of Fig. 2).The launchMode of the target Activity of e2 and e3 is " standard ",
TaskAffinity is " org.connectbot " and is not accompanied by the calling of finish ().Received intent pairs of e2
As being provided with mark " FLAG_ACTIVITY_CLEAR_TOP " (the 20th row of Fig. 2), the not set mark of e3.It is true according to [RULE-11]
The Starting mode relevant configuration for determining e2, e3 is effectively configuration, determines that the Starting mode of e2, e3 are distinguished according to [RULE-16]
Standard-clearTop and standard.
Table 3 starts relationship details
After the Activity branch instruction analysis of Starting mode sensitivity, Activity starting figure ALG such as Fig. 4 institute generated
Show, n1、n2、n3Respectively indicate HostListActivity, ConsoleActivity, SettingsActivity tri-
Activity class, e1、e2、e3Respectively indicate three starting relationships.ALG=(LT, N, E, s), in which:
LT={ standard, standard-clearTop, singleTop };
N={ n1,n2,n3};
E={ e1,e2,e3};
S=n1。
3. generating BSTG
It is generated for Fig. 2 code snippet and returns to stack transition figure as shown in figure 5, the existing ALG based on Fig. 4 illustrates that BSTG was generated
Journey.
Start figure ALG=(LT, N, E, s) as input with Activity, k=2 is set, and output returns to stack state transition figure
BSTG=(LT, BS, ST, bsinit) the step of it is as follows:
1) BS={ } is set, ST={ }, the left side stateQueue=[], stateQueue is head of the queue, right side tail of the queue;
2) starting stack state bs is initialized with Main Activityinit=<n1>;
3) by bsinitIt is added and returns to stack state set BS={ bsinit, and it is pressed into node queue to be processed
StateQueue=[bsinit];
4) the head of the queue state node currentState=bs in stateQueue is popped upinit, bsinitStack top Activity
The type of example is n1, stateQueue=[] at this time;
5) n in ALG is traversed1Go out side.n1There are two to go out side e1And e3.For
A) currently returning to stack state is bsinit, n1 is simulated according to the 2nd row of table 1 and starts target in a manner of singleTop
Stack state newState is returned after Activity n2launching=< n1,n2>;
b)newStatelaunchingIn there is no a same type Activity example, construction from currentState to
newStatelaunchingSide l1, and be added into and return to stack state transition set ST={ l1};
c)newStatelaunchingIn do not have same type Activity example andThen by bs2
=newStatelaunchingSimultaneously set BS is added in indentation stateQueue, at this time BS={ bsinit,bs2, stateQueue=
[bs2]。
For
A) currently returning to stack state is bsinit, n1 is simulated according to the 1st row of table 1 and starts target in a manner of standard
Activity n3Stack state newState is returned afterwardslaunching=< n1,n3>;
b)newStatelaunchingIn there is no a same type Activity example, construction from currentState to
newStatelaunchingSide l2, and be added into and return to stack state transition set ST={ l1,l2}。
c)newStatelaunchingIn do not have same type Activity example andThen by bs3
=newStatelaunchingSimultaneously set BS is added in indentation stateQueue, at this time BS={ bsinit,bs2,bs3, stateQueue
=[bs2,bs3];
6) due to currently returning to stack state bsinitIn only one example, then no longer simulation return action caused by return
Stack state variation.
7) stateQueue is not empty, in pop-up stateQueue head of the queue state node currentState=at this time
bs2, bs2The type of stack top Activity example is n2, stateQueue=[bs at this time3];
8) n in ALG is traversed2Go out side.n2There is 1 to go out side e2.For
A) currently returning to stack state is bs2, n is simulated according to the 3rd row of table 12Start mesh in a manner of standard-clearTop
Mark Activity n1Stack state newState is returned afterwardslaunching=< n1>;
b)newStatelaunchingIn there is no a same type Activity example, construction from currentState to
newStatelaunchingSide l3, and be added into and return to stack state transition set ST={ l1,l2,l3};
C) due to newStatelaunching=bsinit∈ BS, so being not necessarily to bs2It is pressed into stateQueue.
9) due to currently returning to stack state bs2In have more than 1 Activity example, then simulate bs2After top element is popped
Return to stack state newStateback=bs1, construct from bs2To newStatebackSide f1, and it is added into ST, at this time ST=
{l1,l2,l3,f1, stateQueue=[bs3];
10) stateQueue is not empty, in pop-up stateQueue head of the queue state node currentState=at this time
bs3, bs3The type of stack top Activity example is n3, stateQueue=[] at this time;
11) n in ALG3Do not go out side.
12) due to currently returning to stack state bs3In have more than 1 Activity example, then simulate bs2Top element is popped
Stack state newState is returned afterwardsback=bs1, construct from bs3To newStatebackSide f2, and it is added into ST, at this time ST=
{l1,l2,l3,f1,f2, stateQueue=[];
13) BSTG construction terminates.
Being generated based on ALG and returning to the final output of stack state transition figure is BSTG=(LT, BS, ST, bsinit),
In:
LT={ standard, standard-clearTop, singleTop };
BS={ bsinit,bs2,bs3, bsinit=<n1>, bs2=< n1,n2>, bs3=< n1,n3>;
ST={ l1,l2,l3,f1,f2};
bsinit=< n1>。
Claims (6)
1. a kind of Android application of Starting mode sensitivity returns to stack state static simulation method, it is characterised in that including as follows
Step:
1st, the basic conception that the method is related to:
Define 1, Activity Starting mode;
Define 2, Activity starting figure;
It defines 3, return to stack state transition figure;
2nd, the method comprises the steps of:
Step 1 pre-processes Android application;
Step 2 generates Activity starting figure by the Activity branch instruction analysis of Starting mode sensitivity;
Step 3 generates return stack state transition figure based on Activity starting figure.
2. a kind of Android application of Starting mode sensitivity according to claim 1 returns to stack state static simulation method,
It is characterized in that, Activity Starting mode described in defining 1 refers to, when android system starts Activity, influence to return
The association attributes of stack state configure, and are defined as Activity Starting mode;Influence the Android association attributes quilt of Starting mode
It is defined as returning to stack state association attributes;The method summarizes 4 return stack state association attributes and 7 Starting mode;4
A launchMode for returning to taskAffinity, Activity class that stack state association attributes are Activity class respectively, it opens
The mark of the transmitted intent object of inter-component communication API Calls and start finish () after Activity when dynamic Activity
Whether it is called;7 Starting mode are standard, singleTop, standard-clearTop, singleTop- respectively
ClearTop, reorderToFront, singleTask and standard | finish.
3. a kind of Android application of Starting mode sensitivity according to claim 1 returns to stack state static simulation method,
It is characterized in that, the starting figure of Activity described in defining 2 (Activity launching graph, abbreviation ALG) is specifically fixed
Justice is as follows, and it is four-tuple that Activity, which starts figure: ALG=(LT, N, E, s);LT is the set of Starting mode;N is node set,
That is the set of Activity class;E is oriented line set, E={ < ns,nt,lt>|ns∈N,nt∈ N, lt ∈ LT }, wherein nsIt is side
Initial point, ntIt is the terminal on side, lt is the element in Starting mode set LT, indicates source Activity class nsIt is opened in a manner of lt
Moving-target Activity class nt;S is the start node of ALG, for the Main Activity of Android application;
Return stack state transition figure (back stack transition graph, abbreviation BSTG) described in defining 3 is specifically defined
As follows, returning to stack state transition figure is four-tuple: BSTG=(LT, BS, ST, bsinit);BS is to return to stack state set: BS=
{<c1,c2,…,ci,…,cn>|ci∈ N }, wherein c1For the type of the stack bottom Activity example of return stack, cnTo return to stack
The type of stack top example, N are node sets, i.e. the set of Activity class;ST is the set of directed edge, indicates to return to stack state
Transition: ST=L ∪ F, wherein L starts the return stack state transition set triggered by Activity, and F is triggered by return action
Return stack state transition set L={ <bss,bst,lt>|bss∈BS,bst∈ BS, lt ∈ LT }, wherein bssStack is returned for source
State, bstFor target Activity state;bsinitFor start node, the return stack state which indicates only includes one
The example of Main Activity.
4. a kind of Android application of Starting mode sensitivity according to claim 1 returns to stack state static simulation method,
It is characterized in that, the application pretreatment of Android described in step 1 includes two parts: first part is
AndroidManifest.xml document analysis, the keynote message extracted from file include: 1) Android application packet name;2) it infuses
The Activity class name set ACT of volume;3) the intent filter of each Activity class;4) each Activity class
" taskAffinity " and " launchMode " attribute value;Second part is to construct auxiliary main () for direction analysis, to prop up
Hold the Activity branch instruction analysis of the sensitivity of Starting mode described in step 2;The auxiliary main () includes each Activity class
An object heap memory distribution sentence and each Activity object foundation control stream tissue call back function call language
Sentence.
5. a kind of Android application of Starting mode sensitivity according to claim 1 returns to stack state static simulation method,
It is characterized in that, generating Activity by the Activity branch instruction analysis of Starting mode sensitivity described in step 2 starts figure
Method is, the Activity branch instruction analysis of Starting mode sensitivity include 10 object-orienteds field sensitivity direction analysis rule and
8 Activity start side create-rule;10 direction analysis rules are directed to respectively: class instantiates sentence, Activity class
Instantiation sentence, copy-statement, field reading statement, field write statement, method call sentence, setting intent indicate sentence,
Show that intent analysis, implicit intent analysis and Activity start sentence;8 Activity starting side create-rule difference
Be directed to: invalid return stack state relevant configuration determines, singleTask starting side generates, singleTop-clearTop is opened
Dynamic Bian Shengcheng, standard-clearTop starting is generated when generating, reorderToFront starting, singleTop starts side
Generate, standard | finish starting while and standard start while generate.
6. a kind of Android application of Starting mode sensitivity according to claim 3 returns to stack state static simulation method,
It is characterized in that, generating the method for returning to stack state transition figure based on Activity starting figure described in step 3 is, with
The number k comprising same type Activity example, which is at best able to, in Activity starting figure ALG, return stack state is used as input,
Output returns to stack state transition figure BSTG=(LT, BS, ST, bsinit);Firstly generate start node bsinit, which is added
In set BS, and by start node bsinitIt is pressed into node queue statequeue to be processed, is then followed successively by each of queue
It returns to stack state node and adds out side, that is, return caused by Activity starting and returned caused by stack state variation and return action
Return stack state variation;For currently returning to stack state currentstate, to return to the process that stack state adds out side are as follows: traversal
Activity starts current Activity class c in ringsGo out side, wherein csIt is the type of currentstate stack top example, for
Every goes out side, simulates csStart target Activity class c in a manner of lttStack state newState is returned afterwardslauningIf
newStatelauningIn Activity repeat example number be no more than k, construction from currentState to
newStatelaunchingSide l, and ST is added in l;If newStatelaunchingIn Activity repeat example number not
More than k andThen by newStatelaunchingSimultaneously set BS is added in indentation stateQueue;If
1 example is had more than in currentState, then simulates after the top currentstate element is popped and return to stack state
newStateback, construct from currentstate to newStatebackSide f, and ST is added in f, if newStatebackDo not exist
In BS set, then by newStatebackIt is pressed into statequeue.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811522157.5A CN109614105B (en) | 2018-12-13 | 2018-12-13 | Starting mode sensitive Android application return stack state static simulation method |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201811522157.5A CN109614105B (en) | 2018-12-13 | 2018-12-13 | Starting mode sensitive Android application return stack state static simulation method |
Publications (2)
Publication Number | Publication Date |
---|---|
CN109614105A true CN109614105A (en) | 2019-04-12 |
CN109614105B CN109614105B (en) | 2022-02-15 |
Family
ID=66009179
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201811522157.5A Active CN109614105B (en) | 2018-12-13 | 2018-12-13 | Starting mode sensitive Android application return stack state static simulation method |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN109614105B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112241296A (en) * | 2019-07-17 | 2021-01-19 | 北京密境和风科技有限公司 | Page switching method and device in application |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103970526A (en) * | 2013-11-21 | 2014-08-06 | 成都力淼科技有限公司 | Android based single-activity view switching technology |
US20160011904A1 (en) * | 2014-07-11 | 2016-01-14 | Accenture Global Services Limited | Intelligent application back stack management |
CN108089895A (en) * | 2017-12-19 | 2018-05-29 | 珠海市君天电子科技有限公司 | The register method of Activity, device, electronic equipment and storage medium in a kind of plug-in unit |
CN108958980A (en) * | 2018-07-23 | 2018-12-07 | Oppo(重庆)智能科技有限公司 | Prevent method, electronic device and the computer readable storage medium of Activity life cycle exception |
-
2018
- 2018-12-13 CN CN201811522157.5A patent/CN109614105B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103970526A (en) * | 2013-11-21 | 2014-08-06 | 成都力淼科技有限公司 | Android based single-activity view switching technology |
US20160011904A1 (en) * | 2014-07-11 | 2016-01-14 | Accenture Global Services Limited | Intelligent application back stack management |
CN108089895A (en) * | 2017-12-19 | 2018-05-29 | 珠海市君天电子科技有限公司 | The register method of Activity, device, electronic equipment and storage medium in a kind of plug-in unit |
CN108958980A (en) * | 2018-07-23 | 2018-12-07 | Oppo(重庆)智能科技有限公司 | Prevent method, electronic device and the computer readable storage medium of Activity life cycle exception |
Non-Patent Citations (3)
Title |
---|
NARIMAN MIRZAEI: "Reducing Combinatorics in GUI Testing of", 《IEEE 2016 IEEE/ACM 38TH IEEE INTERNATIONAL CONFERENCE ON SOFTWARE ENGINEERING》 * |
SHENGQIAN YANG: "Static Window Transition Graphs for Android", 《IEEE 2015 30TH IEEE/ACM INTERNATIONAL CONFERENCE ON AUTOMATED SOFTWARE ENGINEERING》 * |
张国强: "基于概率层次分析的缓冲区溢出检测工具评估", 《计算机应用与软件》 * |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112241296A (en) * | 2019-07-17 | 2021-01-19 | 北京密境和风科技有限公司 | Page switching method and device in application |
CN112241296B (en) * | 2019-07-17 | 2024-03-22 | 北京密境和风科技有限公司 | Page switching method and device in application |
Also Published As
Publication number | Publication date |
---|---|
CN109614105B (en) | 2022-02-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7207031B2 (en) | System and method for utilization of a command structure representation | |
US9274761B1 (en) | Dual programming interface | |
Engels et al. | Testing the consistency of dynamic UML diagrams | |
EP3296866B1 (en) | Method implemented by a computer that presents software-type applications based on design specifications | |
CN103885816A (en) | Simulation method of real-time embedded system | |
Selonen et al. | Transformations between UML diagrams | |
CN110427459A (en) | Visualized generation method, system and the platform of speech recognition network | |
CN109614105A (en) | A kind of Android application return stack state static simulation method of Starting mode sensitivity | |
CN106227667B (en) | A kind of method for generating test case of the mobile application of the IFML based on extension | |
Hunt | A Beginner's Guide to Scala, Object Orientation and Functional Programming | |
CN111708699A (en) | Intelligent integrated detection system for Android application program | |
CN115658046B (en) | Method and device for developing modularized UI (user interface) interaction component based on Web technology | |
CN104267954B (en) | The generation method and device of a kind of part included in user interface | |
Jin et al. | Describing the syntax and semantics of UML statecharts in a heterogeneous modelling environment | |
Spanoudakis et al. | Gaia agents implementation through models transformation | |
Sinnig | The complicity of patterns and model-based UI development | |
Cavarra et al. | A framework to simulate UML models: moving from a semi-formal to a formal environment | |
Mansour et al. | White Box Testing Of Web Applications | |
CN118151918B (en) | Trusted low-code development platform and code generation method based on UML model | |
CN113220277B (en) | Development method and device for embedded service | |
Trivedi | User interface implementation of environmental data integration system with React | |
Devi et al. | Design and Development of Android Application for Virtual Birthday Present | |
Mason | Moses Formalism Creation–Tutorial | |
Nymeyer | A grammatical specification of human-computer dialogue | |
CN117539443A (en) | Unified cutting method and system for real-time operation system of national product networking |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |