From c2c86d0b9ef9f81025434466b9660b27181f5491 Mon Sep 17 00:00:00 2001 From: Kunal Malhotra Date: Thu, 23 Feb 2023 00:56:44 +0000 Subject: [PATCH] Fixing possible NullPointerException Test: manul testing Change-Id: I448c3d31c69a7c1649bfe30e864ad053cd8987bb Bug: b/263304156 --- .../android/server/am/ForegroundServiceTypeLoggerModule.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java b/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java index c0cb7d9f69e35..993595b4870d9 100644 --- a/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java +++ b/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java @@ -316,6 +316,10 @@ public class ForegroundServiceTypeLoggerModule { // then we should care, otherwise we assume // it's not related to any FGS UidState uidState = mUids.get(uid); + if (uidState == null) { + Log.w(TAG, "API event end called before start!"); + return -1; + } if (uidState.mOpenWithFgsCount.contains(apiType)) { // are there any calls that started with an FGS? if (uidState.mOpenWithFgsCount.get(apiType) != 0) {