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

Commit 85399be2 authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Dump FgsStartTempAllowList in dumpsys activity processes" into sc-dev

parents 50f0175f 739cd529
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -9236,6 +9236,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();
        }
    }
}