CN104484176B - A kind of Android system window object acquisition methods and device - Google Patents

A kind of Android system window object acquisition methods and device Download PDF

Info

Publication number
CN104484176B
CN104484176B CN201410784202.XA CN201410784202A CN104484176B CN 104484176 B CN104484176 B CN 104484176B CN 201410784202 A CN201410784202 A CN 201410784202A CN 104484176 B CN104484176 B CN 104484176B
Authority
CN
China
Prior art keywords
window
services
window object
function
module
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
CN201410784202.XA
Other languages
Chinese (zh)
Other versions
CN104484176A (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.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing 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 Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201410784202.XA priority Critical patent/CN104484176B/en
Publication of CN104484176A publication Critical patent/CN104484176A/en
Application granted granted Critical
Publication of CN104484176B publication Critical patent/CN104484176B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The invention discloses a kind of Android system window object acquisition methods and device, it is related to intelligent mobile terminal technical field.Methods described includes:Before the window object that window services are called obtains function, the calling to home window object acquisition function in the Android system is intercepted;The home window object acquisition function of the interception is replaced with into first window object acquisition function;When triggering window services to obtain window object, the window services are by calling the first window object acquisition function to obtain window object and returning to the process of specifying;The specified process extracts each subwindow object from the window object.The present invention solves the problems, such as to meet to obtain simultaneously window object speed soon and is applicable all android versions, and window object beneficial effect can be rapidly obtained in the case where taking into account various android versions by achieving.

Description

A kind of Android system window object acquisition methods and device
Technical field
The present invention relates to intelligent mobile terminal technical field, and in particular to a kind of Android system window object acquisition methods and Device.
Background technology
With the development of smart mobile phone, there is the system of a variety of support smart mobile phones.Such as android (Android) system System.Android is a kind of open source code operating system based on Linux, is mainly used for the mobile terminals such as mobile phone. Android platform is made up of operating system, middleware, user interface and application software.
With the increase of the occupation rate of market of android system, increasing developer is developed based on android system App (application, using), user is more convenient using android mobile phones.But per money app after exploitation, and Can not reach the standard grade at once because the app on real system in use, it is possible that some bug, such as each UI in app Interface (window object) be cannot respond to when user clicks on, and failure or logic error etc. are redirected when UI is redirected.Therefore for APP , it is necessary to first carry out UI tests typically after the completion of exploitation, after UI interface normal operations of all APP in Android system Just can formally it issue.And in UI test process, then APP window object is obtained using some instruments, is tested.
In traditional acquisition UI instrument, exist it is following several, pass through viewserver (window services) obtain window Object, this kind of scheme is adapted to all android versions, but speed is slow;Also one kind is to pass through Accessibility Service (miscellaneous function service) obtains window object, although the speed that this kind of mode obtains window object is fast, is only applicable On android4.1 versions, and its window object obtained is not comprehensive, for the subwindow object of parent window object It may lose;Also one kind is to obtain window object, but the test by uiAutomator (UI automated test tools) Instrument is only suitable on android4.2 versions.
In above-mentioned traditional method, it is unable to meet to obtain simultaneously window object speed soon and is applicable all Android versions.
The content of the invention
In view of the above problems, it is proposed that the present invention so as to provide one kind overcome above mentioned problem or at least in part solve on State a kind of Android system window object acquisition device of problem and a kind of corresponding Android system window object acquisition methods.
According to one aspect of the present invention, there is provided a kind of Android system window object acquisition methods of knowing clearly, including:
Before the window object that window services are called obtains function, intercept to home window object in the Android system Obtain the calling of function;
The home window object acquisition function of the interception is replaced with into first window object acquisition function;
When triggering window services to obtain window object, the window services are by calling the first window object to obtain Take function to obtain window object and return to the process of specifying;
The specified process extracts each subwindow object from the window object.
Preferably, before the window object called in window services obtains function, intercept in the Android system The calling of home window object acquisition function includes:
Whether monitoring starts to create window services;
Start to create window services if listened to, intercept the establishment to the window services, so as to intercept window clothes Business needs the loading of home window object acquisition function in the Android system that calls to it.
Preferably, the interception window object acquisition function is replaced with into first window object acquisition function includes:
After establishment to the window services is intercepted, home window object acquisition function that window services are needed to load Replace with first window object acquisition function;
The window services are created, and load the first window object acquisition function.
Preferably, in addition to:The initial process incubator of Android system is replaced with into specific first process incubator;It is logical Cross the first process incubator and monitor and whether start to create window services.
Preferably, it is described to include by the way that whether the first process incubator monitoring starts establishment window services:
Java virtual machines are created by the first process incubator;
Socket for audit window service is registered by the java virtual machines, by the socket monitor whether Start to create window services.
Preferably, it is described to include by the way that whether socket monitoring starts establishment window services:
Monitor the first message for whether being received in the socket and creating window services;If the socket receives Create the first message of window services, it is determined that start to create window services.
Preferably, the home window object acquisition function that window services are needed to load replaces with first window object Obtaining function includes:
The initial getfocuswindow functions that window services are needed to load, replace with the first getfocuswindow letters Number;The return sequential of the first getfocuswindow functions specifies process for return.
Preferably, the window services are included by calling the first window object acquisition function to obtain window object:
By the first getfocuswindow functions, the windowstata window objects at the top of window object storehouse are searched.
Preferably, in addition to:When window object at the top of window object storehouse changes, the window object is judged Whether obtain;
If the window object does not obtain, continue the window object returning to the process of specifying.
According to another aspect of the present invention, the invention also discloses a kind of Android system window object acquisition device, Including:
Blocking module, before the window object suitable for being called in window services obtains function, intercept to the Android system The calling of middle home window object acquisition function;
Function replacement module, obtained suitable for the home window object acquisition function of the interception is replaced with into first window object Take function;
Window object acquisition module, suitable for when triggering window services to obtain window object, the window services pass through Call the first window object acquisition function to obtain window object and return to the process of specifying;
Window acquisition module, each subwindow object is extracted from the window object suitable for the specified process.
Preferably, the blocking module includes:
Whether window services, which create, monitors module, be adapted for listening for starting to create window services;
First blocking module, if starting to create window services suitable for listening to, intercept the wound to the window services Build, the loading of home window object acquisition function in the Android system that calls is needed so as to intercepting window services to it.
Preferably, the function replacement module includes:
First function replacement module, suitable for after the establishment to the window services is intercepted, window services being needed to load Home window object acquisition function replace with first window object acquisition function;
Window services creation module, suitable for creating the window services, and load the first window object acquisition function.
Preferably, in addition to:
Process incubator replacement module, suitable for the initial process incubator of Android system is replaced with into specific first process Incubator;Monitored by the first process incubator and whether start to create window services.
Preferably, the window services create monitoring module and included:
Virtual machine creating module, suitable for creating java virtual machines by the first process incubator;
First window service-creation monitors module, suitable for being registered by the java virtual machines for audit window service Socket, monitored by the socket and whether start to create window services.
Preferably, the first window service-creation is monitored module and included:
Create message and monitor module, be adapted for listening for whether receiving in the socket and create the first of window services and disappear Breath;If the socket receives the first message for creating window services, it is determined that starts to create window services.
Preferably, the first function replacement module includes:
Second function replacement module, suitable for the initial getfocuswindow functions for needing to load by window services, replace For the first getfocuswindow functions;The return sequential of the first getfocuswindow functions specifies process for return.
Preferably, the window object acquisition module includes:
First window object acquisition module, suitable for by the first getfocuswindow functions, searching window object storehouse The windowstata window objects at top.
Preferably, in addition to:Window object judge module, become suitable for the window object at the top of window object storehouse During change, judge whether the window object has obtained;If the window object does not obtain, continue the window object Return to the process of specifying.
Can be by the window that is called in viewserver according to a kind of Android system window object acquisition methods of the present invention Before mouth object acquisition function, the calling to home window object acquisition function in the Android system is intercepted, is obtained Window object is no longer by view server transmission means, but the specified process directly inside return system, by specifying process The information of parent window and each subwindow can be obtained directly from the window object.This solves and can not met simultaneously The problem of obtaining window object speed soon and being applicable all android versions, achieves and is taking into account various android versions In the case of can be rapidly obtained window object beneficial effect.
Described above is only the general introduction of technical solution of the present invention, in order to better understand the technological means of the present invention, And can be practiced according to the content of specification, and in order to allow above and other objects of the present invention, feature and advantage can Become apparent, below especially exemplified by the embodiment of the present invention.
Brief description of the drawings
By reading the detailed description of hereafter preferred embodiment, it is various other the advantages of and benefit it is common for this area Technical staff will be clear understanding.Accompanying drawing is only used for showing the purpose of preferred embodiment, and is not considered as to the present invention Limitation.And in whole accompanying drawing, identical part is denoted by the same reference numerals.In the accompanying drawings:
Fig. 1 shows a kind of flow signal of Android system window object acquisition methods according to an embodiment of the invention Figure;
Fig. 2 shows a kind of flow signal of Android system window object acquisition methods according to an embodiment of the invention Figure;
Fig. 3 shows a kind of flow signal of Android system window object acquisition methods according to an embodiment of the invention Figure;
Fig. 4 shows a kind of structural representation of Android system window object acquisition device according to an embodiment of the invention Figure;
Fig. 5 shows a kind of structural representation of Android system window object acquisition device according to an embodiment of the invention Figure;And
Fig. 6 shows a kind of structural representation of Android system window object acquisition device according to an embodiment of the invention Figure.
Embodiment
The exemplary embodiment of the disclosure is more fully described below with reference to accompanying drawings.Although the disclosure is shown in accompanying drawing Exemplary embodiment, it being understood, however, that may be realized in various forms the disclosure without should be by embodiments set forth here Limited.On the contrary, these embodiments are provided to facilitate a more thoroughly understanding of the present invention, and can be by the scope of the present disclosure Completely it is communicated to those skilled in the art.
One of core concept of the present invention is:Before obtaining function by the window object called in viewserver, block The calling to home window object acquisition function in the Android system is cut, the window object obtained no longer passes through view Server transmission means, but the specified process directly inside return system, by specifying process can be directly from the window pair As the information of middle acquisition parent window and each subwindow.So that in the case of can meeting that acquisition window object is fireballing simultaneously Suitable for all android versions.
Embodiment one
Reference picture 1, it illustrates a kind of schematic flow sheet of Android system window object acquisition methods of the present invention, including:
Step 110, before the window object that window services are called obtains function, intercept to initial in the Android system Window object obtains the calling of function;
In traditional viewserver implementation procedures, it is necessary to adjust when going to obtain window object by viewserver Function is obtained with window object, has called the window object to obtain function in viewserver and has gone window management service After obtaining window object windostata in the window list storehouses that windows manager servive are maintained, it can return Viewserver, all data of window object are then got as described in viewserver by the transmission of outside socket again.
Wherein, Viewserver is a kind of service, it can be understood as a process.
And the embodiment of the present invention, then before viewserver calls the window object acquisition function, intercept to the peace The calling of home window object acquisition function in tall and erect system, subsequently into step 120.
In embodiments of the present invention, can be entered by the way that the initial process incubator of Android system is replaced with into specific first Journey incubator, then realized before the window object that window services are called obtains function, intercepted by the first process incubator To the calling of home window object acquisition function in the Android system.
Step 120, the home window object acquisition function of the interception is replaced with into first window object acquisition function;
The home window object acquisition function of interception is replaced with the window object of oneself and obtains letter by the embodiment of the present invention Number, i.e., foregoing first window object acquisition function;The window object of oneself obtains function and removes windows in the embodiment of the present invention Windowstata function and interface and initial window pair is obtained in the window list storehouses that manager servive are maintained Consistent as obtaining function, the object simply returned after windowstata is got is changed to the finger that the embodiment of the present invention is specified Determine process.
Step 130, when triggering window services to obtain window object, the window services are by calling first window Mouth object acquisition function obtains window object and returns to the process of specifying;
The first window object acquisition letter of oneself of the invention is replaced with the initial window object of interception is obtained into function After number, viewserver calling is continued executing with, then what it was called is the first window object acquisition function of the present invention, The first window object acquisition function gets the object returned after windowstata and is changed to the finger that the embodiment of the present invention is specified Determine process.
In embodiments of the present invention, when returning, the pipe pipelines between viewserver and specified process can be passed through The data are returned, outside socket transmission is required no, improves efficiency of transmission.
Step 140, the specified process extracts each subwindow object from the window object.
In the window list storehouses maintained due to windows manager servive, each windowstata objects are equal It is all window datas under a main window, such as the APP for a startup, the windowstata is with APP main window The information of main window is recorded, the subwindow information based on main window, then continues to record under the main window, that is, passes through one Windowstata can obtain the main window of any activation information and the letter of all subwindows that includes of the window of itself Breath.Therefore the embodiment of the present invention is specified after process gets the windowstata, you can therefrom obtain main window itself The information for all subwindows that information and the window include.
In embodiments of the present invention, it is getfocuswindow that the window object that viewserver is called, which obtains function, should Function is to obtain windowstata from the stack top of the windows manager servive window list storehouses maintained, stack top Windowstata represents a movable Activity, i.e. window object, and an APP for opening and showing can be understood as One movable APP, the APP all subwindows, fall within the movable Activity, then now obtain stack top Windowstata, that is, obtaining the data structure of all windows including the APP, then it is of the invention specify into Journey can obtain all window messages from windowstata this data structure by window class and set membership.
In embodiments of the present invention, occurs a movable Activity only in Android system, you can by above-mentioned Process obtains its corresponding window object, so as to obtain window message all in the window object.
The embodiment of the present invention is using the mechanism of viewserver reading window object, the window object acquisition called It is the first window object acquisition function for specifying process that function, which replaces with returning an object value, then proceedes to perform viewserver letter Number invoked procedure, it will call the first window object acquisition function of the present invention, so as to get window object, and return to this The specified process of invention.Said process, window object quickly can be returned into the process of specifying, realizing can meet to obtain simultaneously The advantages of being applied to all android versions in the case of taking window object fireballing.
Embodiment two
Reference picture 2, it illustrates a kind of schematic flow sheet of Android system window object acquisition methods of the present invention, including:
Step 210, monitor and whether start to create window services;
In embodiments of the present invention, can before viewserver is created i.e. proceed by interception, i.e., by pair Viewserver creates the interception of process, and the calling of function is obtained so as to intercept viewserver to window object.
So first, monitor and whether start to create viewserver in Android system.
Preferably, in addition to:
Sub-step A212, the initial process incubator of Android system is replaced with into specific first process incubator;Pass through Whether the first process incubator is monitored starts to create window services.
In the present invention, in order to realize create viewserver processes monitoring, it is necessary to initial first to Android system Process incubator be that zygote processes are replaced, replace with the first process incubator specified, i.e. the first zygote processes, Whether the first zygote processes can be monitored starts to create viewserver.
In android system, all program process and system service process SystemServer be all by Zygote processes breed (fork) come out, therefore, the present invention can be replaced with by the initial zygote processes of Android system First zygote processes, which are realized, monitors and intercepts process.
Certainly, it is necessary to restart android after replacing the initial zygote processes of Android system and being the first zygote processes System.The function of the first zygote processes after replacement also added in addition to the function including initial zygote processes Monitor and whether start to create the processing logic after window services and monitoring.
In embodiments of the present invention, the initial zygote processes of Android system are being replaced as the first of the present invention Zygote processes, initial zygoteInit classes can be replaced with to the amended zygoteInit classes of the present invention, after this changes In zygoteInit classes in addition to the function including zygote processes, also added monitoring whether start create window services with And the processing logic after monitoring.After loading, the first zygote processes can be such that Android system normally starts, can also Realize the interception function of the present invention.
Certainly, the root authority of system can be obtained in advance, is then replaced again for Android system, above-mentioned replacement process Change.
Preferably, it is described to include by the way that whether the first process incubator monitoring starts establishment window services:
Sub-step A213, java virtual machines are created by the first process incubator;
Sub-step A214, the socket for audit window service is registered by the java virtual machines, passes through the set Connect word and monitor and whether start to create window services.
In the normal boot process of Android system, substantially:Activation system->Init processes, which are read, to be started init.rc—>Init process creation zygote processes->Zygote process creation java virtual machines loading zygoteInit classes- >The socket monitored by virtual machine registration needs->ActivityManagerService is waited to be write to socket The establishment message of establishment process->Zygote processes correspond to process according to the establishment message establishing.
So the present invention the initial zygote processes of Android system are replaced with that the present invention specifies in abovementioned steps the After one zygote processes, after Android system is restarted, its init process can create the first zygote processes of the present invention, so After can the first zygote process creation java virtual machines, and then the socket for audit window service is registered, by described Whether socket is monitored starts to create window services.
Preferably, it is described to include by the way that whether socket monitoring starts establishment window services:
Sub-step A215, monitor the first message for whether being received in the socket and creating window services;It is if described Socket receives the first message for creating window services, it is determined that starts to create window services.
The socket of above-mentioned registration, it is to monitor the message received in socket in the embodiment of the present invention.In android When system needs establishment process, system needs to send the first message for creating viewserver to socket, then described in monitoring Whether the first message that creates window services is received in socket, you can judges whether system starts to create viewserver. If the socket receives the first message for creating window services, it is determined that starts to create window services.If the set Connect word and do not receive the first message for creating window services, then system does not create window services.
Step 220, start to create window services if listened to, the establishment to the window services is intercepted, so as to block Cutting window services needs the loading of home window object acquisition function in the Android system that calls to it;
So the embodiment of the present invention is then intercepted to viewserver wound after listening to and starting to create viewserver Build.Intercept the process interception viewserver of the establishment to viewserver in embodiments of the present invention needs to call to it The loading of function, for example intercept the loading that viewserver needs the window object that calls to obtain function to it.
Step 230, after establishment to the window services is intercepted, home window object that window services are needed to load Obtain function and replace with first window object acquisition function;
In embodiments of the present invention, it is the first of the present invention in the initial zygote processes of foregoing replacement Android system During zygote processes, during initial zygoteInit classes are replaced with into the amended zygoteInit classes of the present invention, In amended zygoteInit classes, the first window object acquisition function that the present invention needs can also be added, first window Process of the mouth object acquisition function before windowstata is got obtains letter with the original window object of Android system Number is consistent, and simply first window object acquisition function gets the return sequential after windowstata and is changed to directly return and refers to Determine process.
Step 240, the window services are created, and load the first window object acquisition function;
So obtained in the first window object that the initial window object acquisition function of Android system is replaced with to the present invention After taking function, then the process for creating the viewserver can be continued executing with, the function needed for it can be then loaded after creating, Function needed for it includes the first window object acquisition function.
Step 250, the window services are by calling the first window object acquisition function to obtain window object and returning Refer to determine process;
So now, when the viewserver calls the first window object acquisition function to remove windows After windowstata being got in the window list storehouses that manager servive are maintained, you can directly by described in Windowstata returns to the specified process of Android system by the pipe pipelines between viewserver and specified process, and this refers to It can be UI test processes to determine process.
Step 260, the specified process extracts each subwindow object from the window object.
Then the letter of main window that it is related to and wherein each subwindow can be obtained from the windowstata Breath.Content in the information of the window such as window, the control in each window, the various letters of subwindow etc. corresponding to each control Breath.
The embodiment of the present invention is created process to viewserver and entered using the mechanism of viewserver reading window object Row intercepts, and it is the first window for specifying process that the home window object acquisition function called after interception, which replaces with returning an object value, Object acquisition function, then proceed to create viewserver, this hair can be then called when viewserver obtains window object afterwards Bright first window object acquisition function, so as to obtain window object, and the specified process of the present invention is returned to, specified process passes through The window object, the information of parent window therein and all subwindows can be obtained.Said process, can be quickly by window pair As returning to the process of specifying, realizing can meet to be applied to all android in the case of acquisition window object is fireballing simultaneously The advantages of version.
Embodiment three
Reference picture 3, it illustrates a kind of schematic flow sheet of Android system window object acquisition methods of the present invention, including:
Step 310, the initial process incubator of Android system is replaced with into specific first process incubator;
The initial zygote processes of Android system are replaced with into the first preset zygote processes of the present invention;First The function of zygote processes also added whether monitoring starts to create window in addition to the function including initial zygote processes Processing logic after oral business and monitoring.After replacement, system, the init processes that activation system most starts can be restarted.
Step 320, java virtual machines are created by the first process incubator;
First zygote processes of the init process initiations embodiment of the present invention
Step 330, the socket for audit window service is registered by the java virtual machines, monitors the socket In whether receive create window services first message;If the socket, which receives, creates first disappearing for window services Breath, it is determined that start to create window services, into step 340;
If the socket is not received by the first message for creating window services, according to its common execution flow Perform.
Step 340, the establishment to the window services is intercepted, that calls is needed to it so as to intercept window services The loading of getfocuswindow functions;
Process is created i.e. in intercepting system to it before viewserver is created to intercept, so as to which window can be intercepted Service needs the loading of the getfocuswindow functions called to it.
In embodiments of the present invention, its purpose is to intercept viewserver to itself having in Android system The loading of initial getfocuswindow functions.
Step 350, after the establishment to the window services is intercepted, window services needs are loaded initial Getfocuswindow functions, replace with the first getfocuswindow functions;The first getfocuswindow functions Sequential is returned to return to the process of specifying;
The first getfocuswindow functions of the present invention and the initial getfocuswindow of itself in Android system Function has identical parameter setting, simply changes the returning an object value of the initial getfocuswindow functions of system for this The specified process of invention.
Step 360, the window services are created, and load the first getfocuswindow functions;
After it substituted for above-mentioned function, you can continue executing with process hatching process, the first zygote processes can continue Viewserver is created, the relevant parameter of the first getfocuswindow functions is loaded after establishment.
Step 370, window services are searched at the top of window object storehouse by the first getfocuswindow functions Windowstata window objects, and windowstata window objects are returned into the process of specifying;
After abovementioned steps, when window services perform and obtain window object, then described first can be called Getfocuswindow functions, from the storehouse of memory window object, the windowstata of stack top is obtained, then can be incited somebody to action Windowstata is passed by the pipe pipelines between viewserver and specified process and is returned to specified process.Certainly Pipe pipelines between viewserver and specified process can be structure in use.
Step 380, the specified process extracts each subwindow object from the window object.
Preferably, in addition to:
Step 382, when the window object at the top of window object storehouse changes, judge the window object whether Through obtaining;
Step 384, if the window object does not obtain, continue the window object returning to the process of specifying.
In embodiments of the present invention, because the first getfocuswindow functions are the windowstata of the stack top obtained, And the windowstata of stack top represents the window object for activating application in other words of current presentation, other are in the window on backstage Object then can be in the position of some under stack top.As long as the windowstata changes of stack top of the embodiment of the present invention, i.e. android The app changes of system current presentation, you can obtain the windowstata after the change.
So the present invention can constantly obtain the windowstata of stack top, and the windowstata to having obtained is carried out Record, when next time obtains windowstata, according to foregoing record, if the windowstata of stack top does not change, Without obtaining, if the windowstata of stack top changes, continue the window object returning to the process of specifying.
The embodiment of the present invention is created process to viewserver and entered using the mechanism of viewserver reading window object Row intercepts, and it is the first window for specifying process that the home window object acquisition function called after interception, which replaces with returning an object value, Object acquisition function, then proceed to create viewserver, this hair can be then called when viewserver obtains window object afterwards Bright first window object acquisition function, so as to obtain stack top window object, and the specified process of the present invention is returned to, specify process By the window object, the information of parent window therein and all subwindows can be obtained.Said process, can be quickly by window Mouth object returns to the process of specifying, and realizing can meet to be applied to own in the case of acquisition window object is fireballing simultaneously The advantages of android versions.
Example IV
Reference picture 4, it illustrates a kind of structural representation of Android system window object acquisition device of the present invention, including:
Blocking module 410, before the window object suitable for being called in window services obtains function, intercept to the Android system The calling of home window object acquisition function in system;
Function replacement module 420, suitable for the home window object acquisition function of the interception is replaced with into first window pair As obtaining function;
Window object acquisition module 430, suitable for when triggering window services to obtain window object, the window services are led to Cross and call the first window object acquisition function to obtain window object and the specified process of return.
Window acquisition module 440, each subwindow object is extracted from the window object suitable for the specified process.
Embodiment five
Reference picture 5, it illustrates a kind of structural representation of Android system window object acquisition device of the present invention, including:
Blocking module 510, including:
Whether window services, which create, monitors module 512, be adapted for listening for starting to create window services;
First blocking module 514, if starting to create window services suitable for listening to, intercept to the window services Create, the loading of home window object acquisition function in the Android system that calls is needed so as to intercepting window services to it;
Function replacement module 520, including:
First function replacement module 522, suitable for after the establishment to the window services is intercepted, window services being needed to add The home window object acquisition function of load replaces with first window object acquisition function;
Window services creation module 524, suitable for creating the window services, and load the first window object acquisition letter Number;
Window object acquisition module 530, suitable for when triggering window services to obtain window object, the window services are led to Cross and call the first window object acquisition function to obtain window object and the specified process of return.
Window acquisition module 540, each subwindow object is extracted from the window object suitable for the specified process.
Preferably, in addition to:
Process incubator replacement module, suitable for the initial process incubator of Android system is replaced with into specific first process Incubator;Monitored by the first process incubator and whether start to create window services.
Preferably, the window services create monitoring module and included:
Virtual machine creating module, suitable for creating java virtual machines by the first process incubator;
First window service-creation monitors module, suitable for being registered by the java virtual machines for audit window service Socket, monitored by the socket and whether start to create window services.
Preferably, the first window service-creation is monitored module and included:
Create message and monitor module, be adapted for listening for whether receiving in the socket and create the first of window services and disappear Breath;If the socket receives the first message for creating window services, it is determined that starts to create window services.
Embodiment six
Reference picture 6, it illustrates a kind of structural representation of Android system window object acquisition device of the present invention, including:
Process incubator replacement module 610, suitable for the initial process incubator of Android system is replaced with into specific first Process incubator;
Virtual machine creating module 620, suitable for creating java virtual machines by the first process incubator;
First window service-creation monitors module 630, is taken suitable for being registered by the java virtual machines for audit window The socket of business, monitor the first message for whether being received in the socket and creating window services;If the socket connects Receive the first message for creating window services, it is determined that start to create window services, into the second blocking module 640.
Second blocking module 640, intercepts the establishment to the window services, and it is needed to call so as to intercept window services Getfocuswindow functions loading;
Second function replacement module 650, suitable for the initial getfocuswindow functions for needing to load by window services, replace It is changed to the first getfocuswindow functions;The return sequential of the first getfocuswindow functions be return specify into Journey;
Window services creation module 660, suitable for creating the window services, and load the first getfocuswindow Function;
First window object acquisition module 670, suitable for window services by the first getfocuswindow functions, search window Windowstata window objects at the top of mouth object stack, and windowstata window objects are returned into the process of specifying;
Window acquisition module 680, each subwindow object is extracted from the window object suitable for the specified process.
Preferably, in addition to:
Window object judge module, when being changed suitable for the window object at the top of window object storehouse, described in judgement Whether window object has obtained;If the window object does not obtain, continue the window object returning to the process of specifying
Algorithm and display be not inherently related to any certain computer, virtual system or miscellaneous equipment provided herein. Various general-purpose systems can also be used together with teaching based on this.As described above, required by constructing this kind of system Structure be obvious.In addition, the present invention is not also directed to any certain programmed language.It should be understood that it can utilize various Programming language realizes the content of invention described herein, and the description done above to language-specific is to disclose this hair Bright preferred forms.
In the specification that this place provides, numerous specific details are set forth.It is to be appreciated, however, that the implementation of the present invention Example can be put into practice in the case of these no details.In some instances, known method, structure is not been shown in detail And technology, so as not to obscure the understanding of this description.
Similarly, it will be appreciated that in order to simplify the disclosure and help to understand one or more of each inventive aspect, Above in the description to the exemplary embodiment of the present invention, each feature of the invention is grouped together into single implementation sometimes In example, figure or descriptions thereof.However, the method for the disclosure should be construed to reflect following intention:I.e. required guarantor The application claims of shield features more more than the feature being expressly recited in each claim.It is more precisely, such as following Claims reflect as, inventive aspect is all features less than single embodiment disclosed above.Therefore, Thus the claims for following embodiment are expressly incorporated in the embodiment, wherein each claim is in itself Separate embodiments all as the present invention.
Those skilled in the art, which are appreciated that, to be carried out adaptively to the module in the equipment in embodiment Change and they are arranged in one or more equipment different from the embodiment.Can be the module or list in embodiment Member or component be combined into a module or unit or component, and can be divided into addition multiple submodule or subelement or Sub-component.In addition at least some in such feature and/or process or unit exclude each other, it can use any Combination is disclosed to all features disclosed in this specification (including adjoint claim, summary and accompanying drawing) and so to appoint Where all processes or unit of method or equipment are combined.Unless expressly stated otherwise, this specification (including adjoint power Profit requires, summary and accompanying drawing) disclosed in each feature can be by providing the alternative features of identical, equivalent or similar purpose come generation Replace.
In addition, it will be appreciated by those of skill in the art that although some embodiments described herein include other embodiments In included some features rather than further feature, but the combination of the feature of different embodiments means in of the invention Within the scope of and form different embodiments.For example, in the following claims, embodiment claimed is appointed One of meaning mode can use in any combination.
The all parts embodiment of the present invention can be realized with hardware, or to be run on one or more processor Software module realize, or realized with combinations thereof.It will be understood by those of skill in the art that it can use in practice Microprocessor or digital signal processor (DSP) set to realize that Android system window object according to embodiments of the present invention obtains The some or all functions of some or all parts in standby.The present invention is also implemented as described here for performing Method some or all equipment or program of device (for example, computer program and computer program product).This The program of the realization present invention of sample can store on a computer-readable medium, or can have one or more signal Form.Such signal can be downloaded from internet website and obtained, and either be provided or with any other on carrier signal Form provides.
It should be noted that the present invention will be described rather than limits the invention for above-described embodiment, and ability Field technique personnel can design alternative embodiment without departing from the scope of the appended claims.In the claims, Any reference symbol between bracket should not be configured to limitations on claims.Word "comprising" does not exclude the presence of not Element or step listed in the claims.Word "a" or "an" before element does not exclude the presence of multiple such Element.The present invention can be by means of including the hardware of some different elements and being come by means of properly programmed computer real It is existing.In if the unit claim of equipment for drying is listed, several in these devices can be by same hardware branch To embody.The use of word first, second, and third does not indicate that any order.These words can be explained and run after fame Claim.
The invention discloses A1, a kind of Android system window object acquisition methods, including:
Before the window object that window services are called obtains function, intercept to home window object in the Android system Obtain the calling of function;
The home window object acquisition function of the interception is replaced with into first window object acquisition function;
When triggering window services to obtain window object, the window services are by calling the first window object to obtain Take function to obtain window object and return to the process of specifying;
The specified process extracts each subwindow object from the window object.
A2, the method as described in A1, before the window object called in window services obtains function, intercept to described The calling of home window object acquisition function includes in Android system:
Whether monitoring starts to create window services;
Start to create window services if listened to, intercept the establishment to the window services, so as to intercept window clothes Business needs the loading of home window object acquisition function in the Android system that calls to it.
A3, the method as described in A2, the interception window object is obtained into function and replaces with first window object acquisition letter Number includes:
After establishment to the window services is intercepted, home window object acquisition function that window services are needed to load Replace with first window object acquisition function;
The window services are created, and load the first window object acquisition function.
A4, the method as described in A2, in addition to:
The initial process incubator of Android system is replaced with into specific first process incubator;Pass through first process Whether incubator is monitored starts to create window services.
Whether A5, the method as described in A4, described monitored by the first process incubator start to create window services Including:
Java virtual machines are created by the first process incubator;
Socket for audit window service is registered by the java virtual machines, by the socket monitor whether Start to create window services.
A6, the method as described in A5, it is described to include by the way that whether socket monitoring starts establishment window services:
Monitor the first message for whether being received in the socket and creating window services;If the socket receives Create the first message of window services, it is determined that start to create window services.
A7, the method as described in A3, the home window object acquisition function that window services are needed to load replace with First window object acquisition function includes:
The initial getfocuswindow functions that window services are needed to load, replace with the first getfocuswindow letters Number;The return sequential of the first getfocuswindow functions specifies process for return.
A8, the method as described in A7, the window services are by calling the first window object acquisition function to obtain window Mouth object includes:
By the first getfocuswindow functions, the windowstata window objects at the top of window object storehouse are searched.
A9, the method as described in A8, in addition to:
When window object at the top of window object storehouse changes, judge whether the window object has obtained;
If the window object does not obtain, continue the window object returning to the process of specifying.
The invention also discloses B10, a kind of Android system window object acquisition device, including:
Blocking module, before the window object suitable for being called in window services obtains function, intercept to the Android system The calling of middle home window object acquisition function;
Function replacement module, obtained suitable for the home window object acquisition function of the interception is replaced with into first window object Take function;
Window object acquisition module, suitable for when triggering window services to obtain window object, the window services pass through Call the first window object acquisition function to obtain window object and return to the process of specifying;
Window acquisition module, each subwindow object is extracted from the window object suitable for the specified process.
B11, the device as described in B10, the blocking module include:
Whether window services, which create, monitors module, be adapted for listening for starting to create window services;
First blocking module, if starting to create window services suitable for listening to, intercept the wound to the window services Build, the loading of home window object acquisition function in the Android system that calls is needed so as to intercepting window services to it.
B12, the device as described in B11, the function replacement module include:
First function replacement module, suitable for after the establishment to the window services is intercepted, window services being needed to load Home window object acquisition function replace with first window object acquisition function;
Window services creation module, suitable for creating the window services, and load the first window object acquisition function.
B13, the device as described in B11, in addition to:
Process incubator replacement module, suitable for the initial process incubator of Android system is replaced with into specific first process Incubator;Monitored by the first process incubator and whether start to create window services.
B14, the device as described in B13, the window services, which create monitoring module, to be included:
Virtual machine creating module, suitable for creating java virtual machines by the first process incubator;
First window service-creation monitors module, suitable for being registered by the java virtual machines for audit window service Socket, monitored by the socket and whether start to create window services.
B15, the device as described in B14, the first window service-creation, which monitors module, to be included:
Create message and monitor module, be adapted for listening for whether receiving in the socket and create the first of window services and disappear Breath;If the socket receives the first message for creating window services, it is determined that starts to create window services.
B16, the device as described in B12, the first function replacement module include:
Second function replacement module, suitable for the initial getfocuswindow functions for needing to load by window services, replace For the first getfocuswindow functions;The return sequential of the first getfocuswindow functions specifies process for return.
B17, the device as described in B16, the window object acquisition module include:
First window object acquisition module, suitable for by the first getfocuswindow functions, searching window object storehouse The windowstata window objects at top.
B18, the device as described in B17, in addition to:
Window object judge module, when being changed suitable for the window object at the top of window object storehouse, described in judgement Whether window object has obtained;If the window object does not obtain, continue the window object returning to the process of specifying.

Claims (18)

1. a kind of Android system window object acquisition methods, including:
Before the window object that window services are called obtains function, intercept to home window object acquisition in the Android system The calling of function;
The home window object acquisition function of the interception is replaced with into first window object acquisition function;
When triggering window services to obtain window object, the window services are by calling the first window object acquisition letter Number obtains window object and returns to the process of specifying;
The specified process extracts each subwindow object from the window object.
2. the method as described in claim 1, it is characterised in that it is described window services call window object obtain function it Before, intercept includes to the calling of home window object acquisition function in the Android system:
Whether monitoring starts to create window services;
Start to create window services if listened to, the establishment to the window services is intercepted, so as to intercept window services pair The loading of home window object acquisition function in the Android system that its needs calls.
3. method as claimed in claim 2, it is characterised in that the interception window object is obtained into function and replaces with the first window Mouth object acquisition function includes:
After the establishment to the window services is intercepted, the home window object acquisition function that window services need to load is replaced For first window object acquisition function;
The window services are created, and load the first window object acquisition function.
4. method as claimed in claim 2, it is characterised in that also include:
The initial process incubator of Android system is replaced with into specific first process incubator;Hatched by first process Whether device is monitored starts to create window services.
5. method as claimed in claim 4, it is characterised in that whether described monitored by the first process incubator starts Creating window services includes:
Java virtual machines are created by the first process incubator;
Socket for audit window service is registered by the java virtual machines, is monitored and whether started by the socket Create window services.
6. method as claimed in claim 5, it is characterised in that whether described monitored by the socket starts to create window Service includes:
Monitor the first message for whether being received in the socket and creating window services;If the socket receives establishment The first message of window services, it is determined that start to create window services.
7. method as claimed in claim 3, it is characterised in that the home window object for needing to load by window services obtains Taking function to replace with first window object acquisition function includes:
The initial getfocuswindow functions that window services are needed to load, replace with the first getfocuswindow functions; The return sequential of the first getfocuswindow functions specifies process for return;Wherein, getfocuswindow functions are The stack top of the window list storehouses maintained from window management service obtains a movable window object.
8. method as claimed in claim 7, it is characterised in that the window services are by calling the first window object to obtain Taking function to obtain window object includes:
By the first getfocuswindow functions, the windowstata window objects at the top of window object storehouse are searched.
9. method as claimed in claim 8, it is characterised in that also include:
When window object at the top of window object storehouse changes, judge whether the window object has obtained;
If the window object does not obtain, continue the window object returning to the process of specifying.
10. a kind of Android system window object acquisition device, including:
Blocking module, before the window object suitable for being called in window services obtains function, intercept to first in the Android system Beginning window object obtains the calling of function;
Function replacement module, suitable for the home window object acquisition function of the interception is replaced with into first window object acquisition letter Number;
Window object acquisition module, suitable for when triggering window services to obtain window object, the window services pass through calling The first window object acquisition function obtains window object and returns to the process of specifying;
Window acquisition module, each subwindow object is extracted from the window object suitable for the specified process.
11. device as claimed in claim 10, it is characterised in that the blocking module includes:
Whether window services, which create, monitors module, be adapted for listening for starting to create window services;
First blocking module, if starting to create window services suitable for listening to, the establishment to the window services is intercepted, from And intercepting window services needs the loading of home window object acquisition function in the Android system that calls to it.
12. device as claimed in claim 11, it is characterised in that the function replacement module includes:
First function replacement module, suitable for after the establishment to the window services is intercepted, window services needs being loaded first Beginning window object obtains function and replaces with first window object acquisition function;
Window services creation module, suitable for creating the window services, and load the first window object acquisition function.
13. device as claimed in claim 11, it is characterised in that also include:
Process incubator replacement module, hatch suitable for the initial process incubator of Android system is replaced with into specific first process Device;Monitored by the first process incubator and whether start to create window services.
14. device as claimed in claim 13, it is characterised in that the window services, which create monitoring module, to be included:
Virtual machine creating module, suitable for creating java virtual machines by the first process incubator;
First window service-creation monitors module, suitable for registering the socket for audit window service by the java virtual machines Word, monitored by the socket and whether start to create window services.
15. device as claimed in claim 14, it is characterised in that the first window service-creation, which monitors module, to be included:
Create message and monitor module, be adapted for listening for whether receiving the first message for creating window services in the socket;Such as Socket described in fruit receives the first message for creating window services, it is determined that starts to create window services.
16. device as claimed in claim 12, it is characterised in that the first function replacement module includes:
Second function replacement module, suitable for window services are needed into the initial getfocuswindow functions that load, replace with the One getfocuswindow functions;The return sequential of the first getfocuswindow functions specifies process for return;Wherein, Getfocuswindow functions are that the stack top of the window list storehouses maintained from window management service obtains a movable window Object.
17. device as claimed in claim 16, it is characterised in that the window object acquisition module includes:
First window object acquisition module, suitable for by the first getfocuswindow functions, searching at the top of window object storehouse Windowstata window objects.
18. device as claimed in claim 17, it is characterised in that also include:
Window object judge module, when being changed suitable for the window object at the top of window object storehouse, judge the window Whether object has obtained;If the window object does not obtain, continue the window object returning to the process of specifying.
CN201410784202.XA 2014-12-16 2014-12-16 A kind of Android system window object acquisition methods and device Active CN104484176B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201410784202.XA CN104484176B (en) 2014-12-16 2014-12-16 A kind of Android system window object acquisition methods and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201410784202.XA CN104484176B (en) 2014-12-16 2014-12-16 A kind of Android system window object acquisition methods and device

Publications (2)

Publication Number Publication Date
CN104484176A CN104484176A (en) 2015-04-01
CN104484176B true CN104484176B (en) 2018-01-19

Family

ID=52758720

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201410784202.XA Active CN104484176B (en) 2014-12-16 2014-12-16 A kind of Android system window object acquisition methods and device

Country Status (1)

Country Link
CN (1) CN104484176B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105468529B (en) * 2015-12-15 2018-07-24 北京奇虎科技有限公司 A kind of accurate traversal method of Android application UI controls and device
CN107402781B (en) * 2017-06-26 2020-10-27 珠海大横琴科技发展有限公司 Open screen page display management method, terminal and computer readable storage medium
CN108958849B (en) * 2018-06-28 2022-03-22 武汉斗鱼网络科技有限公司 Method, device, storage medium and mobile terminal for acquiring current Activity object
CN112860363A (en) * 2021-02-07 2021-05-28 麒麟软件有限公司 Linux system based Android application window state dynamic updating method

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102693394A (en) * 2012-06-07 2012-09-26 奇智软件(北京)有限公司 Method and device for intercepting calling for service of application program
CN102855138A (en) * 2012-07-20 2013-01-02 腾讯科技(深圳)有限公司 Application program interface (API) intercepting method and device and mobile terminal
CN104156662A (en) * 2014-08-28 2014-11-19 北京奇虎科技有限公司 Process monitoring method and device and intelligent terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6820256B2 (en) * 2000-12-13 2004-11-16 Microsoft Corporation System and method for whole-system program analysis
US7882496B2 (en) * 2004-06-01 2011-02-01 International Business Machines Corporation Method and system for metering execution of interpreted programs

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102693394A (en) * 2012-06-07 2012-09-26 奇智软件(北京)有限公司 Method and device for intercepting calling for service of application program
CN102855138A (en) * 2012-07-20 2013-01-02 腾讯科技(深圳)有限公司 Application program interface (API) intercepting method and device and mobile terminal
CN104156662A (en) * 2014-08-28 2014-11-19 北京奇虎科技有限公司 Process monitoring method and device and intelligent terminal

Also Published As

Publication number Publication date
CN104484176A (en) 2015-04-01

Similar Documents

Publication Publication Date Title
CN108108297B (en) Method and device for automatic testing
CN109302522B (en) Test method, test device, computer system, and computer medium
US10671381B2 (en) Continuous integration with reusable context aware jobs
US8209564B2 (en) Systems and methods for initiating software repairs in conjunction with software package updates
US8839201B2 (en) Capturing test data associated with error conditions in software item testing
US10067858B2 (en) Cloud-based software testing
CN106844136B (en) Method and system for collecting program crash information
US9292416B2 (en) Software development kit testing
US8839202B2 (en) Test environment managed within tests
US20110214112A1 (en) Systems and mehtods for generating predictive diagnostics via package update manager
US9684587B2 (en) Test creation with execution
US9116802B2 (en) Diagnostic notification via package update manager
CN104484223B (en) A kind of Android system application method for closing and device
US9069902B2 (en) Software test automation
CN110096424B (en) Test processing method and device, electronic equipment and storage medium
US8949794B2 (en) Binding a software item to a plain english control name
CN105468529A (en) Accurate traversal method and apparatus for UI controls of android application
CN110013672B (en) Method, device, apparatus and computer-readable storage medium for automated testing of machine-run games
CN104484176B (en) A kind of Android system window object acquisition methods and device
US20170132023A1 (en) Monitoring And Actuation Of View Controller Parameters To Reach Deep States Without Manual Developer Intervention
US10795793B1 (en) Method and system for simulating system failures using domain-specific language constructs
US9329979B2 (en) Derivation of generalized test cases
US20140109050A1 (en) Altering a test
US9292422B2 (en) Scheduled software item testing
CN107590064A (en) A kind of application upgrade method of testing, device and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20220729

Address after: Room 801, 8th floor, No. 104, floors 1-19, building 2, yard 6, Jiuxianqiao Road, Chaoyang District, Beijing 100015

Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Patentee before: Qizhi software (Beijing) Co.,Ltd.

TR01 Transfer of patent right