From d470e927ea0159c9676790760b1ede7a5463b41b Mon Sep 17 00:00:00 2001 From: Yi Kong Date: Wed, 24 Jul 2024 08:10:11 +0000 Subject: profcollect: Guard binder calls with null checks In case of profcollectd dies, mIProfcollect will become null. Guard all calls to mIProfcollect with null checks to prevent NPE. Change-Id: I0908bd2413f77a44a00e2692bb027ba580ecbec6 Test: presubmit Bug: 354339294 --- .../android/server/profcollect/ProfcollectForwardingService.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java index e6dac88f8a9e..dab397864613 100644 --- a/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java +++ b/services/profcollect/src/com/android/server/profcollect/ProfcollectForwardingService.java @@ -354,6 +354,9 @@ public final class ProfcollectForwardingService extends SystemService { private static void createAndUploadReport(ProfcollectForwardingService pfs) { BackgroundThread.get().getThreadHandler().post(() -> { + if (pfs.mIProfcollect == null) { + return; + } String reportName; try { reportName = pfs.mIProfcollect.report(pfs.mUsageSetting) + ".zip"; @@ -401,6 +404,9 @@ public final class ProfcollectForwardingService extends SystemService { final int traceDuration = 5000; final String traceTag = "camera"; BackgroundThread.get().getThreadHandler().post(() -> { + if (mIProfcollect == null) { + return; + } try { mIProfcollect.trace_process(traceTag, "android.hardware.camera.provider", traceDuration); -- cgit v1.2.3-59-g8ed1b