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

Commit 6cfd01d6 authored by riddle_hsu's avatar riddle_hsu Committed by Steve Kondik
Browse files

[ActivityManager] Fix NullPointerException when dumping ContentProviderRecord.

Sympton: If there is external access without handles, dumpsys will met exception as:
  * ContentProviderRecord{45ed0fc8 u0 com.android.providers.media/.MediaProvider}
...
    externals=
Exception occurred while dumping:
java.lang.NullPointerException
	at com.android.server.am.ContentProviderRecord.dump(ContentProviderRecord.java:171)

Root Cause: External handles may be empty but there is "no handle" count.

Solution: Check null and print with handle, no handle count.

Change-Id: I0ee497096113e5685d491a0d4346f57d398495e6
parent ea9fae12
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -168,13 +168,17 @@ final class ContentProviderRecord {
        if (full) {
            if (hasExternalProcessHandles()) {
                pw.print(prefix); pw.print("externals=");
                        pw.println(externalProcessTokenToHandle.size());
                        pw.print(externalProcessNoHandleCount);
                if (externalProcessTokenToHandle != null) {
                    pw.print(" handles="); pw.print(externalProcessTokenToHandle.size());
                }
                pw.println();
            }
        } else {
            if (connections.size() > 0 || externalProcessNoHandleCount > 0) {
                pw.print(prefix); pw.print(connections.size());
                        pw.print(" connections, "); pw.print(externalProcessNoHandleCount);
                        pw.println(" external handles");
                        pw.println(" externals");
            }
        }
        if (connections.size() > 0) {