Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 739cd529 authored by Makoto Onuki's avatar Makoto Onuki
Browse files

Dump FgsStartTempAllowList in dumpsys activity processes

Bug: 182185371
Test: manual test with dumpsys activity processes
Change-Id: I538c4a8c4cd5a793bc42fd558105002997af59e7
parent 397e520f
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -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) {
+28 −0
Original line number Diff line number Diff line
@@ -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();
        }
    }
}