Specific embodiment
Below in conjunction with the accompanying drawings, embodiments of the invention are described.
The determination method of the responsive state of the application program that the embodiment of the present application is provided is applied to answering on mobile terminal
It is the scene for responding or being not responding to be determined with the responsive state of program, mobile terminal herein includes but is not limited to mobile phone
And panel computer etc., the operating system of the mobile terminal can be IOS systems;Above-mentioned application program can be in mobile terminal
Screen on have the application program of corresponding icon, e.g., " Alipay " etc., or the son application journey inside application program
Sequence, the subapplication has corresponding icon and/or word etc. on the displaying interface of application program, and e.g., " Alipay " is internal
Business, including " Yuebao " and " transferring accounts " etc..
The responsive state of above-mentioned application program is that response refers to the instruction that can receive user input, and can be referred to according to this
Order performs corresponding operation;And the responsive state of application program for be not responding to refer to the application program for a long time block it is motionless, and
Any response is made in the not instruction to user input, can be to be not responding to by the responsive state of application program in this description
Referred to as interim card.
The application provide application program responsive state determination method can be as shown in Figure 1 system perform, such as Fig. 1
Shown, the system can include:Main thread accessor 101 and main thread requestor 102.
Main thread accessor 101, for when monitoring that destination application starts, by the operating system of mobile terminal
Application programming interface (Application Programming Interface, API) function creation of offer is divided accordingly
Thread, the separated time journey is to access the thread that the response results of main thread are set up.Specifically, main thread accessor 101 is being created
After corresponding separated time journey, main thread can also be accessed to the transmission inquiry request of main thread requestor 102 by the separated time journey
Response results;And according to response results, determine the responsive state of main thread;Afterwards further according to the responsive state of main thread, really
The responsive state of the application program that sets the goal.Herein, the responsive state according to main thread determines the responsive state of destination application
Principle it is as follows:After destination application startup, operating system refers to the renewal of destination application and to user input
The response for making (also referred to as user operates) is completed by main thread, wherein, renewal includes the displaying interface color of application program
Renewal (it is e.g., red->It is blue) and according to operation result to showing the renewal at interface, when the responsive state of main thread is not for
During response, the problem that destination application can be caused to update and be not responding to user's operation, namely only in main thread
Responsive state for response when, the responsive state of destination application is just to respond.
Additionally, main thread accessor 101 can be also used for starting timer for above-mentioned separated time journey, so that property performance period ground
The response results of main thread are conducted interviews by separated time journey, namely when the timing time of the timer is reached, by separated time
Journey accesses the response results of main thread.
Furthermore, main thread accessor 101 can be also used for when it is determined that the responsive state of destination application is to be not responding to,
Output report information, so that developer is according to this report information, optimizes to destination application.
Main thread requestor 102, for the state that periodic queries main thread is presently in, and be presently according to it
State, determines the response results of main thread.Main thread requestor 102 specifically can be by call function:
CFRunLoopRunInMode inquires about the state that main thread is presently in, wherein, the state that main thread is presently in includes:wa
I t lock statuss, busy state and idle condition etc., wherein, busy state is also referred to as working condition, is presently in main thread
When state is working condition, it cannot respond to user input.Specifically, when the state that main thread is presently in is wai t lock shapes
When state or busy state, the response results of main thread are determined to be not responding to, and it is the free time to work as the state that main thread is presently in
During state, determine that the response results of main thread are response.
Alternatively, main thread requestor 102 (can be referred to as main thread state team in local maintenance memory cell
Row), afterwards when determining to arrive the response results of main thread every time, can be by response results storage to said memory cells.
In one example, memory cell can be as shown in table 1.
Table 1
Inquiry times |
Response results |
1 |
Response |
2 |
It is not responding to |
3 |
Response |
4 |
It is not responding to |
5 |
It is not responding to |
6 |
It is not responding to |
It should be noted that table 1 is a kind of example, the limitation to the application is not intended as, in actual applications, table 1
In response results can also be expressed as other information, it is e.g., idle or busy etc.;Additionally, table 1 may include other fields
Content, e.g., corresponding weighted value of response results etc..
Main thread requestor 102, is additionally operable to receive the inquiry request that main thread accessor 101 sends, and according to the inquiry
The response results of the acquisition main thread from the corresponding memory cell of main thread (e.g., table 1) are asked, the response results that will be obtained afterwards
Return to main thread requestor 102.
In 102 local maintenance memory cell of main thread requestor, main thread accessor 101 can be also used for according to master
The response results that thread pool device 102 is returned, when determining the responsive state of main thread for response, send out to main thread requestor 102
Flush instructions are sent, main thread requestor 102 empties the response results in memory cell after above-mentioned flush instructions are received.
Main thread requestor 102 restarts to preserve the response knot that subsequent query is arrived after the response results in emptying memory cell
Really.
In one example, after the response results in emptying memory cell, the subsequent query for restarting to preserve is arrived
Response results can be as shown in table 2.
Table 2
Inquiry times |
Response results |
7 |
Response |
8 |
It is not responding to |
9 |
Response |
It should be noted that above-mentioned is a kind of drawing for function to main thread accessor 101 and main thread requestor 102
Divide method, in actual applications, it is also possible to many according to this by main thread requestor 102 after multiple response results are got
Individual response results determine the responsive state of main thread, the response shape of the main thread that will be determined by main thread requestor 102 again afterwards
State returns to main thread accessor 101, and the application is not construed as limiting to this.
In this application, system that can be as shown in Figure 1 determines the responsive state of application program, but is performing the determination
Before process, following steps can periodically be performed by the main thread status inquiry device 102 in Fig. 1:
Step A:The state that inquiry main thread is presently in.
Main thread requestor 102 specifically can be by call function:CFRunLoopRunInMode come inquire about main thread work as
Preceding state in which, wherein, the state that main thread is presently in includes:Wait lock statuss, busy state and idle condition etc..
Step B:According to the state that main thread is presently in, the response results of main thread are determined.
When the state that main thread is presently in is wait lock statuss or busy state, the responsive state of main thread is determined
To be not responding to, and when the state that main thread is presently in is idle condition, determine that the responsive state of main thread is response.
It can thus be seen that the application can be that situation about being not responding to is supervised to various responsive states for causing main thread
Control, e.g., main thread is in wait lock statuss or busy state etc., it is possible thereby to solve in the prior art, can only monitor due to
Main thread causes the responsive state of main thread to be the limitation being not responding in wait lock statuss.
Step C:By response results storage to memory cell.
In one example, afterwards, memory cell can be such as the institute of table 1 for the process 6 times for performing step A- steps C in periodicity
Show.
Main thread status inquiry device 102 in by Fig. 1 periodically performs step A- steps C many times afterwards, it is possible to by
System shown in Fig. 1 determines the responsive state of application program, and its specific determination process can be with as shown in Fig. 2 the method be specific
May include steps of:
Step 210, when monitoring that destination application starts, creates corresponding separated time journey.
Destination application herein can be the application program for having corresponding icon on the screen of the mobile terminal, e.g.,
" Alipay " etc., or the subapplication inside application program, the subapplication is at the displaying interface of application program
On have corresponding icon and/or word etc., e.g., " Alipay " internal business, including " Yuebao " and " transferring accounts " etc..
The application programming interface that main thread accessor 101 can specifically be provided by the operating system of mobile terminal
(Application Programming Interface, API) corresponding separated time journey of function creation, the separated time journey is led to access
The thread that the response results of thread are set up.
Step 220, main thread accessor 101 obtains main thread by separated time journey from memory cell corresponding with main thread
Multiple response results.
Alternatively, main thread accessor 101 can start timing after corresponding separated time journey is created in separated time journey
Device, so as to when the timing time of the timer is reached, by this point of response results of thread accesses main thread, thus realizes
Acquisition of the periodicity of main thread accessor 101 to the response results of main thread.
Step 220 is specifically as follows:Main thread accessor 101 is sent out by the separated time journey for creating to main thread requestor 102
Send inquiry request;Main thread requestor 102 obtains multiple sound after inquiry request is received from the memory cell of main thread
Result is answered, multiple response results herein can inquire about n response results (e.g., the 4-6 in table 1 for obtaining continuous n times recently
It is secondary to inquire about corresponding 3 response results), wherein, n>=1, or can also be that whole response results (e.g., are looked into for 6 times in table 1
Whole response results that inquiry is obtained);Main thread requestor 102, can will be the plurality of after multiple response results are got
Response results return to main thread accessor 101.
Step 230, according to multiple response results, determines the responsive state of main thread.
Herein, the responsive state of main thread can be determined by main thread accessor 101 according to multiple response results, its tool
The determination process of body can be:It is the read-around ratio being not responding to that response results are obtained from multiple response results, if read-around ratio
More than predetermined threshold value, it is determined that the responsive state of main thread is to be not responding to;The responsive state for otherwise determining main thread is response.This
Place, predetermined threshold value can set based on experience value.
Such as previous example, the 4-6 times inquiry is obtained in multiple response results that main thread requestor 102 is returned are table 1
3 response results when, then above-mentioned read-around ratio (being referred to as weighted value) can be 3, and assume when predetermined threshold value be 2
When, because 3>2 (i.e. more than predetermined threshold value), so main thread accessor 101 can determine the responsive state of main thread not ring
Should;Otherwise, it is assumed that when predetermined threshold value is 3, because 3=3 (being no more than predetermined threshold value), thread accesses device 101 can be true
It is response to determine the responsive state of main thread.6 inquiries are right in multiple response results that main thread requestor 102 is returned are table 1
During the whole response results answered, the read-around ratio of acquisition is also 3;It is determined that after read-around ratio, determining the response of main thread
The process of state is same as above, does not repeat again herein.
Alternatively, when the responsive state of main thread can be determined in thread accessor 101 for response, can be looked into main thread
Ask device 102 and send flush instructions, main thread requestor 102 after the flush instructions are received, in can emptying memory cell
Multiple response results, can such as empty 6 response results in table 1;Afterwards when reaching in the cycle, above-mentioned steps are repeated
A- step C, to preserve the response results of newest inquiry in the memory unit, preserve the storage list of the response results of newest inquiry
Unit can be as shown in table 2.
Step 240, according to the responsive state of main thread, determines the responsive state of destination application.
Herein, the response of destination application can be determined by main thread accessor 101 according to the responsive state of main thread
State, its determination process can be:
When the responsive state of main thread is for response, determine that the responsive state of destination application is response;Work as main thread
Responsive state when being not responding to, to determine the responsive state of destination application to be not responding to.
Herein, because after destination application starts, operating system should to the renewal of destination application and target
The response operated to user with program is completed by main thread, wherein, renewal includes the displaying interface color of application program
Renewal (it is e.g., red->It is blue) and according to operation result to showing the renewal at interface, when the responsive state of main thread is not for
During response, the problem that destination application can be caused to update and be not responding to user's operation, namely only in main thread
Responsive state for response when, the responsive state of destination application is just to respond.Therefore, the application can be according to main thread
Responsive state, determines the responsive state of destination application.
Alternatively, when the responsive state of destination application is determined in main thread accessor 101 to be not responding to, it can be with
Output report information as follows:
Can be seen that this report information from above-mentioned report information includes:Device name (Device Name), equipment version
This number (Device Version), IOS system versions number (IOS Version), application version number (App Version),
Test bag version (Build Version), use internal memory (Used Memory), flying fox version (FlyFox Version), application
The running environment parameter informations such as the title (e.g., title at that time) and operation result (reason) of program, wherein, FlyFox refers to one
Plant client control plug-in unit.So as to developer can optimize according to this report information to destination application.
The determination method of the responsive state of the application program that the application is provided, by the multiple response knots for obtaining main thread
Really determine the responsive state of main thread, the responsive state according to main thread determines the responsive state of application program afterwards;
Namely the application can determine the responsive state of application program automatically according to the state of main thread, without to application program sheet
Body is modified, and such that it is able to reduce the workload of developer, and can improve the effect that the responsive state of application program determines
Rate.
With the determination method of the responsive state of above-mentioned application program accordingly, a kind of application that the embodiment of the present application is also provided
The determining device of the responsive state of program, as shown in figure 3, the device includes:
Creating unit 301, for when monitoring that destination application starts, creating corresponding separated time journey.
Acquiring unit 302, for the separated time journey that is created by creating unit 301 from memory cell corresponding with main thread
Obtain multiple response results of main thread.
Determining unit 303, for the multiple response results obtained according to acquiring unit 302, determines the response shape of main thread
State.
Alternatively, response results can include response and be not responding to;
Determining unit 303 specifically for:
It is the read-around ratio being not responding to that response results are obtained from multiple response results, if read-around ratio exceedes default threshold
Value, it is determined that the responsive state of main thread is to be not responding to;The responsive state for otherwise determining main thread is response.
Determining unit 303, is additionally operable to the responsive state according to main thread, determines the responsive state of destination application.
Determining unit 303 specifically for:
When the responsive state of main thread is for response, determine that the responsive state of destination application is response;
When the responsive state of main thread is to be not responding to, determine the responsive state of destination application to be not responding to.
Alternatively, the device can also include memory cell 304, for periodically performing following steps:
The state that inquiry main thread is presently in;
According to the state that main thread is presently in, the response results of main thread are determined;
By response results storage to memory cell.
Alternatively, the device can also include:Unit 305 is emptied, for being response when the responsive state for determining main thread
When, the multiple response results in memory cell 304 are emptied.
The function of each functional module of the embodiment of the present application device, can be by each step of above method embodiment come real
It is existing, therefore, the specific work process of the device that the application is provided is not repeated again herein.
The application provide application program determining device, creating unit 301 when monitor destination application start when,
Create corresponding separated time journey;Acquiring unit 302 obtains main thread by separated time journey from memory cell corresponding with main thread
Multiple response results;Determining unit 303 determines the response shape of main thread according to multiple response results.Thus, it is possible to reduce exploitation
The workload of personnel, and the efficiency that the responsive state of application program determines can be improved.
It should be noted that the determining device of the responsive state of the application program that the application is provided can be integrated in and apply journey
In the client control plug-in unit of sequence, e.g., when determining device is used to determine the responsive state of " Alipay ", then the determining device can
To be integrated in " FlyFox ", wherein, " FlyFox " is used to monitor produced problem when " Alipay " client is run, and provides
Instrument assists in problem during operation.
Those skilled in the art it will be appreciated that in said one or multiple example, work(described in the invention
Be able to can be realized with hardware, software, firmware or their any combination.When implemented in software, can be by these functions
Storage is transmitted in computer-readable medium or as one or more instructions on computer-readable medium or code.
Above-described specific embodiment, has been carried out further to the purpose of the present invention, technical scheme and beneficial effect
Describe in detail, should be understood that and the foregoing is only specific embodiment of the invention, be not intended to limit the present invention
Protection domain, it is all technical scheme basis on, any modification, equivalent substitution and improvements done etc. all should
It is included within protection scope of the present invention.