8

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?

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
  • 2
    no 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 Answers1

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