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

Commit c8979c3b authored by Winson Chung's avatar Winson Chung
Browse files

Fix NPE when handling unresponsive embedded windows

- The input target may not be a window state, but we still need to
  report the ANR for the process

Bug: 433055104
Flag: EXEMPT bugfix
Test: Introduce an excessive  artificial embedded window input handling
      delay and ensure ANRs are still fired
Change-Id: Ie68e71a6d12f8cf90f5bc8f13c4d98bc97a4bf1c
parent 4cb14e51
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -182,12 +182,19 @@ class AnrController {
            }
            windowState = target.getWindowState();
            pid = target.getPid();
            if (windowState != null) {
                // Blame the activity if the input token belongs to the window. If the target is
                // embedded, then we will blame the pid instead.
                activity = (windowState.mInputChannelToken == inputToken)
                        ? windowState.mActivityRecord : null;
            Slog.i(TAG_WM, "ANR in " + target + ". Reason:" + timeoutRecord.mReason);
                aboveSystem = isWindowAboveSystem(windowState);
            } else {
                // Embedded windows without a host window state are assumed to be above 
                // system layers
                activity = null;
                aboveSystem = true;
            }
            Slog.i(TAG_WM, "ANR in " + target + ". Reason:" + timeoutRecord.mReason);
        }
        if (activity != null) {
            activity.inputDispatchingTimedOut(timeoutRecord, pid);