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

Commit 7737ab44 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android (Google) Code Review
Browse files

Merge "Force write battery stats after a --history-since." into lmp-preview-dev

parents 38bd7b9c 16b0b56c
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -669,6 +669,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
        int flags = 0;
        boolean isCheckin = false;
        boolean noOutput = false;
        boolean writeData = false;
        long historyStart = -1;
        int reqUid = -1;
        if (args != null) {
@@ -687,6 +688,7 @@ public final class BatteryStatsService extends IBatteryStats.Stub
                        return;
                    }
                    historyStart = Long.parseLong(args[i]);
                    writeData = true;
                } else if ("-c".equals(arg)) {
                    isCheckin = true;
                    flags |= BatteryStats.DUMP_INCLUDE_HISTORY;
@@ -749,10 +751,16 @@ public final class BatteryStatsService extends IBatteryStats.Stub
            List<ApplicationInfo> apps = mContext.getPackageManager().getInstalledApplications(0);
            synchronized (mStats) {
                mStats.dumpCheckinLocked(mContext, pw, apps, flags, historyStart);
                if (writeData) {
                    mStats.writeAsyncLocked();
                }
            }
        } else {
            synchronized (mStats) {
                mStats.dumpLocked(mContext, pw, flags, reqUid, historyStart);
                if (writeData) {
                    mStats.writeAsyncLocked();
                }
            }
        }
    }