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

Commit 6d9cf535 authored by Dhavalkumar Chaudhary's avatar Dhavalkumar Chaudhary Committed by Android (Google) Code Review
Browse files

Merge "Add duration limit to battery stats checkin format" into main

parents ac7fd0c0 eb831e34
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -7787,7 +7787,7 @@ public abstract class BatteryStats {
    // This is called from BatteryStatsService.
    @SuppressWarnings("unused")
    public void dumpCheckin(Context context, PrintWriter pw, List<ApplicationInfo> apps, int flags,
            long histStart, BatteryStatsDumpHelper dumpHelper) {
            long histStart, BatteryStatsDumpHelper dumpHelper, long monotonicCheckinStartTime) {
        synchronized (this) {
            prepareForDumpLocked();

@@ -7797,7 +7797,7 @@ public abstract class BatteryStats {
        }

        if ((flags & (DUMP_INCLUDE_HISTORY | DUMP_HISTORY_ONLY)) != 0) {
            dumpHistory(pw, flags, histStart, true, 0);
            dumpHistory(pw, flags, histStart, true, monotonicCheckinStartTime);
        }

        if ((flags & DUMP_HISTORY_ONLY) != 0) {
+5 −0
Original line number Diff line number Diff line
@@ -66,4 +66,9 @@
    It only affects the `dumpsys batterystats -a` command -->
    <integer name="config_batteryHistoryDumpWindowSize">86400000</integer>

    <!-- Time span of battery history dump, in milliseconds, default value is 0 milliseconds.
    It only affects the `dumpsys batterystats -c` command, The checkin Format -->
    <integer name="config_batteryHistoryDumpCheckinWindowSize">0</integer>


</resources>
+1 −0
Original line number Diff line number Diff line
@@ -5466,6 +5466,7 @@
  <java-symbol type="integer" name="config_accumulatedBatteryUsageStatsSpanSize" />
  <java-symbol type="integer" name="config_batteryHistoryStorageSize" />
  <java-symbol type="integer" name="config_batteryHistoryDumpWindowSize" />
  <java-symbol type="integer" name="config_batteryHistoryDumpCheckinWindowSize" />

  <!--Dynamic Tokens-->
  <java-symbol name="system_accent1_0_light" type="color"/>
+21 −6
Original line number Diff line number Diff line
@@ -3134,6 +3134,18 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                } else if ("-c".equals(arg)) {
                    useCheckinFormat = true;
                    flags |= BatteryStats.DUMP_INCLUDE_HISTORY;
                    if (Flags.checkinHistoryStartTime()) {
                        long checkinDurationLimit = mContext.getResources().getInteger(
                                com.android.internal.R.integer
                                .config_batteryHistoryDumpCheckinWindowSize);
                        if (checkinDurationLimit > 0) {
                            monotonicClockStartTime =
                                mMonotonicClock.monotonicTime() - checkinDurationLimit;
                            if (monotonicClockStartTime < 0) {
                                monotonicClockStartTime = 0;
                            }
                        }
                    }
                } else if ("--proto".equals(arg)) {
                    toProto = true;
                } else if ("--charged".equals(arg)) {
@@ -3238,12 +3250,14 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                    return;
                } else if ("-a".equals(arg)) {
                    flags |= BatteryStats.DUMP_VERBOSE;
                    monotonicClockStartTime =
                        mMonotonicClock.monotonicTime() - mContext.getResources().getInteger(
                    long durationLimit = mContext.getResources().getInteger(
                            com.android.internal.R.integer.config_batteryHistoryDumpWindowSize);
                    if (durationLimit > 0) {
                        monotonicClockStartTime = mMonotonicClock.monotonicTime() - durationLimit;
                        if (monotonicClockStartTime < 0) {
                            monotonicClockStartTime = 0;
                        }
                    }
                } else if ("-v".equals(arg)) {
                    flags |= BatteryStats.DUMP_VERBOSE;
                } else if ("--sync".equals(arg)) {
@@ -3364,7 +3378,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                                checkinStats.readSummaryFromParcel(in);
                                in.recycle();
                                checkinStats.dumpCheckin(mContext, pw, apps, flags,
                                        historyStart, mDumpHelper);
                                        historyStart, mDumpHelper, monotonicClockStartTime);
                                mStats.mCheckinFile.delete();
                                return;
                            }
@@ -3377,7 +3391,8 @@ public final class BatteryStatsService extends IBatteryStats.Stub
            }
            if (DBG) Slog.d(TAG, "begin dumpCheckin from UID " + Binder.getCallingUid());
            awaitCompletion();
            mStats.dumpCheckin(mContext, pw, apps, flags, historyStart, mDumpHelper);
            mStats.dumpCheckin(mContext, pw, apps, flags, historyStart, mDumpHelper,
                    monotonicClockStartTime);
            if (writeData) {
                mStats.writeAsyncLocked();
            }
+8 −0
Original line number Diff line number Diff line
@@ -38,3 +38,11 @@ flag {
    bug: "364350206"
    is_fixed_read_only: true
}

flag {
     namespace: "backstage_power"
     name: "checkin_history_start_time"
     description: "Add duration limit to battery stats check in (csv) format"
     bug: "403599628"
     is_fixed_read_only: true
}