Make input dispatcher only ANR for foreground windows.

Redesigned the input dispatcher's ANR timeout mechanism so it is much
closer to Froyo's policy.  ANR is only ever signalled if the dispatcher
is waiting on a window to finish processing its previous event(s) and
there is new pending input.

In the old code, we tracked the dispatch timeout separately for each
input channel.  This was somewhat complicated and also resulted in the
situation where applications could ANR long after the user had pushed
them into the background.

Change-Id: I666ecada0952d4b95f1d67b9f733842b745c7f4b
This commit is contained in:
Jeff Brown
2010-09-15 15:18:56 -07:00
parent 3fd5fa4ca9
commit 519e024d1e
6 changed files with 387 additions and 660 deletions

View File

@@ -24,18 +24,13 @@ import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.os.Environment;
import android.os.LocalPowerManager;
import android.os.PowerManager;
import android.os.SystemProperties;
import android.util.Slog;
import android.util.Xml;
import android.view.InputChannel;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.Surface;
import android.view.WindowManagerPolicy;
import java.io.BufferedReader;
import java.io.File;
@@ -83,7 +78,6 @@ public class InputManager {
private static native void nativeSetInputWindows(InputWindow[] windows);
private static native void nativeSetInputDispatchMode(boolean enabled, boolean frozen);
private static native void nativeSetFocusedApplication(InputApplication application);
private static native void nativePreemptInputDispatch();
private static native InputDevice nativeGetInputDevice(int deviceId);
private static native int[] nativeGetInputDeviceIds();
private static native String nativeDump();
@@ -331,10 +325,6 @@ public class InputManager {
nativeSetFocusedApplication(application);
}
public void preemptInputDispatch() {
nativePreemptInputDispatch();
}
public void setInputDispatchMode(boolean enabled, boolean frozen) {
nativeSetInputDispatchMode(enabled, frozen);
}
@@ -395,20 +385,10 @@ public class InputManager {
public void notifyInputChannelBroken(InputChannel inputChannel) {
mWindowManagerService.mInputMonitor.notifyInputChannelBroken(inputChannel);
}
@SuppressWarnings("unused")
public long notifyInputChannelANR(InputChannel inputChannel) {
return mWindowManagerService.mInputMonitor.notifyInputChannelANR(inputChannel);
}
@SuppressWarnings("unused")
public void notifyInputChannelRecoveredFromANR(InputChannel inputChannel) {
mWindowManagerService.mInputMonitor.notifyInputChannelRecoveredFromANR(inputChannel);
}
@SuppressWarnings("unused")
public long notifyANR(Object token) {
return mWindowManagerService.mInputMonitor.notifyANR(token);
public long notifyANR(Object token, InputChannel inputChannel) {
return mWindowManagerService.mInputMonitor.notifyANR(token, inputChannel);
}
@SuppressWarnings("unused")