summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kunal Malhotra <malhk@google.com> 2023-04-27 22:50:16 +0000
committer Kunal Malhotra <malhk@google.com> 2023-04-29 00:03:28 +0000
commite47669b08c5a21d4c710bdee61ed3ec78757244f (patch)
treefcd6e566a647df85db4eab18b8e1d6cca3fd5f23
parent9cb6c27097f2c3c6ea4450c948ac89c3769902a5 (diff)
Updating logging for possible edge cases of incorrectly updated arrays
Test: manual testing on phone Bug: 278153526 Change-Id: Ie0b10dc3f52d9e5a4dadafc05ce374fd4b79d095
-rw-r--r--services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java b/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java
index 8f84b08ff6a6..79d3e968c07e 100644
--- a/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java
+++ b/services/core/java/com/android/server/am/ForegroundServiceTypeLoggerModule.java
@@ -33,7 +33,7 @@ import android.app.ForegroundServiceDelegationOptions;
import android.content.ComponentName;
import android.content.pm.ServiceInfo;
import android.util.ArrayMap;
-import android.util.Log;
+import android.util.Slog;
import android.util.SparseArray;
import com.android.internal.annotations.VisibleForTesting;
@@ -191,13 +191,20 @@ public class ForegroundServiceTypeLoggerModule {
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);
+ Slog.wtfStack(TAG, "FGS stop call being logged with no start call for UID for UID "
+ + uid
+ + " in package " + record.packageName);
return;
}
final ArrayList<Integer> apisFound = new ArrayList<>();
final ArrayList<Long> timestampsFound = new ArrayList<>();
for (int i = 0, size = apiTypes.size(); i < size; i++) {
- int apiType = apiTypes.get(i);
+ final int apiType = apiTypes.get(i);
+ if (!uidState.mOpenWithFgsCount.contains(apiType)) {
+ Slog.wtfStack(TAG, "Logger should be tracking FGS types correctly for UID " + uid
+ + " in package " + record.packageName);
+ continue;
+ }
// retrieve the eligible closed call
// we only want to log if this is the only
// open in flight call. If there are other calls,
@@ -214,7 +221,8 @@ public class ForegroundServiceTypeLoggerModule {
final ArrayMap<ComponentName, ServiceRecord> runningFgsOfType =
uidState.mRunningFgs.get(apiType);
if (runningFgsOfType == null) {
- Log.w(TAG, "Could not find appropriate running FGS for FGS stop");
+ Slog.w(TAG, "Could not find appropriate running FGS for FGS stop for UID " + uid
+ + " in package " + record.packageName);
continue;
}
@@ -321,7 +329,7 @@ public class ForegroundServiceTypeLoggerModule {
// it's not related to any FGS
UidState uidState = mUids.get(uid);
if (uidState == null) {
- Log.w(TAG, "API event end called before start!");
+ Slog.w(TAG, "API event end called before start!");
return -1;
}
if (uidState.mOpenWithFgsCount.contains(apiType)) {