Bug fix for NPE if FGS stop log called before FGS start

Test: unit tests.
Bug: 277583461
Change-Id: I7f8beb3c962d92f4dd50148208251d558dbfee97
This commit is contained in:
Kunal Malhotra
2023-04-13 16:55:36 +00:00
parent 9c233f2638
commit 802bb5ca25

View File

@@ -190,6 +190,10 @@ public class ForegroundServiceTypeLoggerModule {
// and also clean up the start calls stack by UID
final ArrayList<Integer> apiTypes = convertFgsTypeToApiTypes(record.foregroundServiceType);
final UidState uidState = mUids.get(uid);
if (uidState == null) {
Log.e(TAG, "FGS stop call being logged with no start call for UID " + uid);
return;
}
final ArrayList<Integer> apisFound = new ArrayList<>();
final ArrayList<Long> timestampsFound = new ArrayList<>();
for (int i = 0, size = apiTypes.size(); i < size; i++) {