Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change Application Not Responding (ANR) Timeout in AOSP [closed]

How do I change the Application Not Responding (ANR) timeout in the AOSP source code? The default timeout is 5 seconds, but where is that set and how do I change it?

like image 897
Dhasneem Avatar asked Jul 12 '13 11:07

Dhasneem


People also ask

How we can avoid the ANR situation?

How to prevent an ANR? Stop doing heavy tasks on the main thread. Instead use worker threads such as IntentService, AsyncTask Handler, or another Thread simply.

What is an application not responding ANR error and how can you prevent them from occurring in an app?

When the UI thread of an Android app is blocked for too long, an "Application Not Responding" (ANR) error is triggered. If the app is in the foreground, the system displays a dialog to the user, as shown in figure 1. The ANR dialog gives the user the opportunity to force quit the app.

Which of the following will trigger an ANR application Not Responding dialog?

Android will display the ANR dialog for a particular application when it detects one of the following conditions: No response to an input event (such as key press or screen touch events) within 5 seconds. A BroadcastReceiver hasn't finished executing within 10 seconds.

What is ANR Responding time in Android?

Application Not Responding (ANR) errors are triggered when the UI thread of the application is not responding for more than 5 seconds. You can read more about ANRs and diagnosing ANRs in the Android documentation. Additionally, Crashlytics can help pinpoint specific problematic threads.


1 Answers

The ANR Timeout is defined in File InputDispatcher.cpp (frameworks\base\libs\ui) . Copying and pasting that piece of code below.

// Default input dispatching timeout if there is no focused application or paused window
// from which to determine an appropriate dispatching timeout.
const nsecs_t DEFAULT_INPUT_DISPATCHING_TIMEOUT = 5000 * 1000000LL; // 5 sec
like image 157
Nargis Avatar answered Oct 02 '22 21:10

Nargis