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

Commit c4b0d098 authored by Jeff Brown's avatar Jeff Brown Committed by Android (Google) Code Review
Browse files

Merge "Fix an NPE and possible unsynchronized call of Locked method." into jb-dev

parents 12da2c5e ee172414
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
@@ -87,26 +87,29 @@ final class InputMonitor implements InputManagerService.Callbacks {
    public long notifyANR(InputApplicationHandle inputApplicationHandle,
            InputWindowHandle inputWindowHandle) {
        AppWindowToken appWindowToken = null;
        if (inputWindowHandle != null) {
        synchronized (mService.mWindowMap) {
                WindowState windowState = (WindowState) inputWindowHandle.windowState;
            WindowState windowState = null;
            if (inputWindowHandle != null) {
                windowState = (WindowState) inputWindowHandle.windowState;
                if (windowState != null) {
                    Slog.i(WindowManagerService.TAG, "Input event dispatching timed out sending to "
                            + windowState.mAttrs.getTitle());
                    appWindowToken = windowState.mAppToken;
                    mService.saveANRStateLocked(appWindowToken, windowState);
                }
                }
            }
        
            if (appWindowToken == null && inputApplicationHandle != null) {
                appWindowToken = (AppWindowToken)inputApplicationHandle.appWindowToken;
            if (appWindowToken != null) {
                Slog.i(WindowManagerService.TAG,
                        "Input event dispatching timed out sending to application "
                                + appWindowToken.stringName);
                mService.saveANRStateLocked(appWindowToken, null);
            }

            if (windowState != null) {
                Slog.i(WindowManagerService.TAG, "Input event dispatching timed out "
                        + "sending to " + windowState.mAttrs.getTitle());
            } else if (appWindowToken != null) {
                Slog.i(WindowManagerService.TAG, "Input event dispatching timed out "
                        + "sending to application " + appWindowToken.stringName);
            } else {
                Slog.i(WindowManagerService.TAG, "Input event dispatching timed out.");
            }

            mService.saveANRStateLocked(appWindowToken, windowState);
        }

        if (appWindowToken != null && appWindowToken.appToken != null) {
+4 −2
Original line number Diff line number Diff line
@@ -9860,14 +9860,16 @@ public class WindowManagerService extends IWindowManager.Stub
     * the time an ANR occurred before anything else in the system changes
     * in response.
     *
     * @param appWindowToken The application that ANR'd, never null.
     * @param appWindowToken The application that ANR'd, may be null.
     * @param windowState The window that ANR'd, may be null.
     */
    public void saveANRStateLocked(AppWindowToken appWindowToken, WindowState windowState) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        pw.println("  ANR time: " + DateFormat.getInstance().format(new Date()));
        if (appWindowToken != null) {
            pw.println("  Application at fault: " + appWindowToken.stringName);
        }
        if (windowState != null) {
            pw.println("  Window at fault: " + windowState.mAttrs.getTitle());
        }