From 4964d990296d022988d28d3788eb114b86681191 Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Thu, 9 Sep 2021 12:05:38 -0700 Subject: [PATCH] Fix NPE in BootReceiver.addTombstoneToDropBox. If we have a native crash before the DropBoxManager starts, don't try to send the tombstone. Bug: http://b/199333694 Test: not obviously practical Change-Id: I542fb9641bb4d699ca79caf9faca93412c236a44 --- services/core/java/com/android/server/BootReceiver.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/BootReceiver.java b/services/core/java/com/android/server/BootReceiver.java index fdba098e6b80f..469f465d7c9a3 100644 --- a/services/core/java/com/android/server/BootReceiver.java +++ b/services/core/java/com/android/server/BootReceiver.java @@ -476,7 +476,11 @@ public class BootReceiver extends BroadcastReceiver { */ public static void addTombstoneToDropBox(Context ctx, File tombstone, boolean proto) { final DropBoxManager db = ctx.getSystemService(DropBoxManager.class); - final String bootReason = SystemProperties.get("ro.boot.bootreason", null); + if (db == null) { + Slog.e(TAG, "Can't log tombstone: DropBoxManager not available"); + return; + } + HashMap timestamps = readTimestamps(); try { if (proto) {