Merge "Correctly blame ANR on process using another process token" into oc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
921daeed2f
@@ -1820,14 +1820,22 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyDispatchingTimedOut(String reason) {
|
||||
public boolean keyDispatchingTimedOut(String reason, int windowPid) {
|
||||
ActivityRecord anrActivity;
|
||||
ProcessRecord anrApp;
|
||||
boolean windowFromSameProcessAsActivity;
|
||||
synchronized (service) {
|
||||
anrActivity = getWaitingHistoryRecordLocked();
|
||||
anrApp = app;
|
||||
windowFromSameProcessAsActivity = app == null || app.pid == windowPid;
|
||||
}
|
||||
if (windowFromSameProcessAsActivity) {
|
||||
return service.inputDispatchingTimedOut(anrApp, anrActivity, this, false, reason);
|
||||
} else {
|
||||
// In this case another process added windows using this activity token. So, we call the
|
||||
// generic service input dispatch timed out method so that the right process is blamed.
|
||||
return service.inputDispatchingTimedOut(windowPid, false /* aboveSystem */, reason) < 0;
|
||||
}
|
||||
return service.inputDispatchingTimedOut(anrApp, anrActivity, this, false, reason);
|
||||
}
|
||||
|
||||
private ActivityRecord getWaitingHistoryRecordLocked() {
|
||||
|
||||
@@ -706,8 +706,8 @@ public class AppWindowContainerController
|
||||
}
|
||||
|
||||
/** Calls directly into activity manager so window manager lock shouldn't held. */
|
||||
boolean keyDispatchingTimedOut(String reason) {
|
||||
return mListener != null && mListener.keyDispatchingTimedOut(reason);
|
||||
boolean keyDispatchingTimedOut(String reason, int windowPid) {
|
||||
return mListener != null && mListener.keyDispatchingTimedOut(reason, windowPid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,10 @@ public interface AppWindowContainerListener extends WindowContainerListener {
|
||||
/**
|
||||
* Called when the key dispatching to a window associated with the app window container
|
||||
* timed-out.
|
||||
*
|
||||
* @param reason The reason for the key dispatching time out.
|
||||
* @param windowPid The pid of the window key dispatching timed out on.
|
||||
* @return True if input dispatching should be aborted.
|
||||
*/
|
||||
boolean keyDispatchingTimedOut(String reason);
|
||||
boolean keyDispatchingTimedOut(String reason, int windowPid);
|
||||
}
|
||||
|
||||
@@ -258,7 +258,8 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
||||
// Notify the activity manager about the timeout and let it decide whether
|
||||
// to abort dispatching or keep waiting.
|
||||
final AppWindowContainerController controller = appWindowToken.getController();
|
||||
final boolean abort = controller != null && controller.keyDispatchingTimedOut(reason);
|
||||
final boolean abort = controller != null
|
||||
&& controller.keyDispatchingTimedOut(reason, windowState.mSession.mPid);
|
||||
if (!abort) {
|
||||
// The activity manager declined to abort dispatching.
|
||||
// Wait a bit longer and timeout again later.
|
||||
@@ -281,7 +282,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks {
|
||||
return 0; // abort dispatching
|
||||
}
|
||||
|
||||
void addInputWindowHandle(final InputWindowHandle windowHandle) {
|
||||
private void addInputWindowHandle(final InputWindowHandle windowHandle) {
|
||||
if (mInputWindowHandles == null) {
|
||||
mInputWindowHandles = new InputWindowHandle[16];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user