Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 80b80e7b authored by Wale Ogunwale's avatar Wale Ogunwale Committed by android-build-merger
Browse files

Merge "Correctly blame ANR on process using another process token" into oc-dev am: 921daeed

am: 860732e4

Change-Id: Ic249da944216aae8a6582b9d5d4648c4d9ea83b4
parents c7022287 860732e4
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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;
        }
    }

    private ActivityRecord getWaitingHistoryRecordLocked() {
+2 −2
Original line number Diff line number Diff line
@@ -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
+5 −1
Original line number Diff line number Diff line
@@ -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);
}
+3 −2
Original line number Diff line number Diff line
@@ -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];
        }