diff options
| author | 2021-03-08 11:22:09 -0800 | |
|---|---|---|
| committer | 2021-03-08 11:36:56 -0800 | |
| commit | 739cd529e6ba4d6fb280d680debcbb25c12b44ce (patch) | |
| tree | baec8300f12213314ccf7a3207a814f2ffb86f78 | |
| parent | 397e520f7944b321e010c17efbc132a0ddf634a6 (diff) | |
Dump FgsStartTempAllowList in dumpsys activity processes
Bug: 182185371
Test: manual test with dumpsys activity processes
Change-Id: I538c4a8c4cd5a793bc42fd558105002997af59e7
| -rw-r--r-- | services/core/java/com/android/server/am/ActivityManagerService.java | 2 | ||||
| -rw-r--r-- | services/core/java/com/android/server/am/FgsStartTempAllowList.java | 28 |
2 files changed, 30 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 9e5d7e4c3325..0905f167057e 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -9238,6 +9238,8 @@ public class ActivityManagerService extends IActivityManager.Stub pw.print(ptw.callingUid); } } + pw.println(" mFgsStartTempAllowList:"); + mFgsStartTempAllowList.dump(pw); } if (mDebugApp != null || mOrigDebugApp != null || mDebugTransient || mOrigWaitForDebugger) { diff --git a/services/core/java/com/android/server/am/FgsStartTempAllowList.java b/services/core/java/com/android/server/am/FgsStartTempAllowList.java index 1f897b5928ce..a844c2aa4f05 100644 --- a/services/core/java/com/android/server/am/FgsStartTempAllowList.java +++ b/services/core/java/com/android/server/am/FgsStartTempAllowList.java @@ -19,10 +19,15 @@ package com.android.server.am; import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM; import android.annotation.Nullable; +import android.os.PowerWhitelistManager; import android.os.PowerWhitelistManager.ReasonCode; import android.os.SystemClock; +import android.os.UserHandle; import android.util.Slog; import android.util.SparseArray; +import android.util.TimeUtils; + +import java.io.PrintWriter; /** * List of uids that are temporarily allowed to start FGS from background. @@ -113,4 +118,27 @@ final class FgsStartTempAllowList { void remove(int uid) { mTempAllowListFgs.delete(uid); } + + void dump(PrintWriter pw) { + final long currentTimeNow = System.currentTimeMillis(); + final long elapsedRealtimeNow = SystemClock.elapsedRealtime(); + for (int i = 0; i < mTempAllowListFgs.size(); i++) { + final int uid = mTempAllowListFgs.keyAt(i); + final TempFgsAllowListEntry entry = mTempAllowListFgs.valueAt(i); + pw.println( + " " + UserHandle.formatUid(uid) + ": " + + " callingUid=" + UserHandle.formatUid(entry.mCallingUid) + + " reasonCode=" + PowerWhitelistManager.reasonCodeToString(entry.mReasonCode) + + " reason=" + entry.mReason); + pw.print(" duration=" + entry.mDuration + + "ms expiration="); + + // Convert entry.mExpirationTime, which is an elapsed time since boot, + // to a time since epoch (i.e. System.currentTimeMillis()-based time.) + final long expirationInCurrentTime = + currentTimeNow - elapsedRealtimeNow + entry.mExpirationTime; + TimeUtils.dumpTimeWithDelta(pw, expirationInCurrentTime, currentTimeNow); + pw.println(); + } + } } |