Avoiding potential NPE when dumping to proto.
Inspired by http://aosp/736453.
Bug: 113087610
Test: Android builds
Change-Id: I9f0dae9cd5a839947c7ed150980eb30b928beef7
diff --git a/core/java/android/os/Looper.java b/core/java/android/os/Looper.java
index f17e0f0..684a8ee 100644
--- a/core/java/android/os/Looper.java
+++ b/core/java/android/os/Looper.java
@@ -386,7 +386,9 @@
final long looperToken = proto.start(fieldId);
proto.write(LooperProto.THREAD_NAME, mThread.getName());
proto.write(LooperProto.THREAD_ID, mThread.getId());
- mQueue.writeToProto(proto, LooperProto.QUEUE);
+ if (mQueue != null) {
+ mQueue.writeToProto(proto, LooperProto.QUEUE);
+ }
proto.end(looperToken);
}