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?
Asked
Active
Viewed 6,436 times
8

Victor Rendina
- 1,130
- 12
- 19

Dhasneem
- 4,037
- 4
- 33
- 47
-
From experience, that is device dependent. On some devices, that is 5 seconds, but on some it is higher. – gunar Jul 12 '13 at 11:21
-
@gunar can we change it in our source code? – Dhasneem Jul 12 '13 at 11:27
-
2no way!!!! you should investigate why that happens and remove the cause, not the effect. Here's a good thread: http://stackoverflow.com/questions/704311/android-how-do-i-investigate-an-anr?rq=1 – gunar Jul 12 '13 at 11:27
-
1@Dhasneem If you have the source for your device, then you can change it, compile and flash it. It won't help others if they encounter an ANR using your app though... – ataulm Jul 12 '13 at 11:28
1 Answers
14
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

Nargis
- 4,687
- 1
- 28
- 45
-
In my source code, there is no such file InputDispatcher.cpp. I want it for ICS source code – Dhasneem Jul 12 '13 at 11:29
-
check in this path frameworks / base / services / input / InputDispatcher.cpp – Nargis Jul 12 '13 at 11:32
-
Ya.. I can found out. And one more doubt. For all source code, it will be there or ll it change? – Dhasneem Jul 12 '13 at 11:37
-
-
Can't find where frameworks\base\libs\ui is stored... do you guys have any idea ? – clst Jun 01 '20 at 15:34