Merge "Avoid background getTotalTimeLocked misreporting" into oc-dev

am: 6029bce3b4

Change-Id: Ib8292cc59afe1933bad8d48907ad47c46bb73e87
This commit is contained in:
Adam Bookatz
2017-06-08 05:59:56 +00:00
committed by android-build-merger

View File

@@ -201,7 +201,7 @@ public abstract class BatteryStats implements Parcelable {
* New in version 22: * New in version 22:
* - BLE scan result background count, BLE unoptimized scan time * - BLE scan result background count, BLE unoptimized scan time
*/ */
static final String CHECKIN_VERSION = "22"; static final String CHECKIN_VERSION = "23";
/** /**
* Old version, we hit 9 and ran out of room, need to remove. * Old version, we hit 9 and ran out of room, need to remove.
@@ -3054,6 +3054,7 @@ public abstract class BatteryStats implements Parcelable {
boolean wifiOnly) { boolean wifiOnly) {
final long rawUptime = SystemClock.uptimeMillis() * 1000; final long rawUptime = SystemClock.uptimeMillis() * 1000;
final long rawRealtime = SystemClock.elapsedRealtime() * 1000; final long rawRealtime = SystemClock.elapsedRealtime() * 1000;
final long rawRealtimeMs = (rawRealtime + 500) / 1000;
final long batteryUptime = getBatteryUptime(rawUptime); final long batteryUptime = getBatteryUptime(rawUptime);
final long whichBatteryUptime = computeBatteryUptime(rawUptime, which); final long whichBatteryUptime = computeBatteryUptime(rawUptime, which);
final long whichBatteryRealtime = computeBatteryRealtime(rawRealtime, which); final long whichBatteryRealtime = computeBatteryRealtime(rawRealtime, which);
@@ -3440,7 +3441,6 @@ public abstract class BatteryStats implements Parcelable {
final int count = bleTimer.getCountLocked(which); final int count = bleTimer.getCountLocked(which);
final Timer bleTimerBg = u.getBluetoothScanBackgroundTimer(); final Timer bleTimerBg = u.getBluetoothScanBackgroundTimer();
final int countBg = bleTimerBg != null ? bleTimerBg.getCountLocked(which) : 0; final int countBg = bleTimerBg != null ? bleTimerBg.getCountLocked(which) : 0;
final long rawRealtimeMs = (rawRealtime + 500) / 1000;
// 'actualTime' are unpooled and always since reset (regardless of 'which') // 'actualTime' are unpooled and always since reset (regardless of 'which')
final long actualTime = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTime = bleTimer.getTotalDurationMsLocked(rawRealtimeMs);
final long actualTimeBg = bleTimerBg != null ? final long actualTimeBg = bleTimerBg != null ?
@@ -3489,11 +3489,11 @@ public abstract class BatteryStats implements Parcelable {
if (u.getAggregatedPartialWakelockTimer() != null) { if (u.getAggregatedPartialWakelockTimer() != null) {
final Timer timer = u.getAggregatedPartialWakelockTimer(); final Timer timer = u.getAggregatedPartialWakelockTimer();
// Convert from microseconds to milliseconds with rounding // Times are since reset (regardless of 'which')
final long totTimeMs = (timer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000; final long totTimeMs = timer.getTotalDurationMsLocked(rawRealtimeMs);
final Timer bgTimer = timer.getSubTimer(); final Timer bgTimer = timer.getSubTimer();
final long bgTimeMs = bgTimer != null ? final long bgTimeMs = bgTimer != null ?
(bgTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : 0; bgTimer.getTotalDurationMsLocked(rawRealtimeMs) : 0;
dumpLine(pw, uid, category, AGGREGATED_WAKELOCK_DATA, totTimeMs, bgTimeMs); dumpLine(pw, uid, category, AGGREGATED_WAKELOCK_DATA, totTimeMs, bgTimeMs);
} }
@@ -3530,7 +3530,7 @@ public abstract class BatteryStats implements Parcelable {
final int count = timer.getCountLocked(which); final int count = timer.getCountLocked(which);
final Timer bgTimer = timer.getSubTimer(); final Timer bgTimer = timer.getSubTimer();
final long bgTime = bgTimer != null ? final long bgTime = bgTimer != null ?
(bgTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : -1; bgTimer.getTotalDurationMsLocked(rawRealtimeMs) : -1;
final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1; final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1;
if (totalTime != 0) { if (totalTime != 0) {
dumpLine(pw, uid, category, SYNC_DATA, "\"" + syncs.keyAt(isy) + "\"", dumpLine(pw, uid, category, SYNC_DATA, "\"" + syncs.keyAt(isy) + "\"",
@@ -3546,7 +3546,7 @@ public abstract class BatteryStats implements Parcelable {
final int count = timer.getCountLocked(which); final int count = timer.getCountLocked(which);
final Timer bgTimer = timer.getSubTimer(); final Timer bgTimer = timer.getSubTimer();
final long bgTime = bgTimer != null ? final long bgTime = bgTimer != null ?
(bgTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : -1; bgTimer.getTotalDurationMsLocked(rawRealtimeMs) : -1;
final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1; final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1;
if (totalTime != 0) { if (totalTime != 0) {
dumpLine(pw, uid, category, JOB_DATA, "\"" + jobs.keyAt(ij) + "\"", dumpLine(pw, uid, category, JOB_DATA, "\"" + jobs.keyAt(ij) + "\"",
@@ -3577,7 +3577,6 @@ public abstract class BatteryStats implements Parcelable {
final int count = timer.getCountLocked(which); final int count = timer.getCountLocked(which);
final Timer bgTimer = se.getSensorBackgroundTime(); final Timer bgTimer = se.getSensorBackgroundTime();
final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : 0; final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : 0;
final long rawRealtimeMs = (rawRealtime + 500) / 1000;
// 'actualTime' are unpooled and always since reset (regardless of 'which') // 'actualTime' are unpooled and always since reset (regardless of 'which')
final long actualTime = timer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTime = timer.getTotalDurationMsLocked(rawRealtimeMs);
final long bgActualTime = bgTimer != null ? final long bgActualTime = bgTimer != null ?
@@ -3718,6 +3717,7 @@ public abstract class BatteryStats implements Parcelable {
int reqUid, boolean wifiOnly) { int reqUid, boolean wifiOnly) {
final long rawUptime = SystemClock.uptimeMillis() * 1000; final long rawUptime = SystemClock.uptimeMillis() * 1000;
final long rawRealtime = SystemClock.elapsedRealtime() * 1000; final long rawRealtime = SystemClock.elapsedRealtime() * 1000;
final long rawRealtimeMs = (rawRealtime + 500) / 1000;
final long batteryUptime = getBatteryUptime(rawUptime); final long batteryUptime = getBatteryUptime(rawUptime);
final long whichBatteryUptime = computeBatteryUptime(rawUptime, which); final long whichBatteryUptime = computeBatteryUptime(rawUptime, which);
@@ -4658,7 +4658,6 @@ public abstract class BatteryStats implements Parcelable {
final int count = bleTimer.getCountLocked(which); final int count = bleTimer.getCountLocked(which);
final Timer bleTimerBg = u.getBluetoothScanBackgroundTimer(); final Timer bleTimerBg = u.getBluetoothScanBackgroundTimer();
final int countBg = bleTimerBg != null ? bleTimerBg.getCountLocked(which) : 0; final int countBg = bleTimerBg != null ? bleTimerBg.getCountLocked(which) : 0;
final long rawRealtimeMs = (rawRealtime + 500) / 1000;
// 'actualTime' are unpooled and always since reset (regardless of 'which') // 'actualTime' are unpooled and always since reset (regardless of 'which')
final long actualTimeMs = bleTimer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTimeMs = bleTimer.getTotalDurationMsLocked(rawRealtimeMs);
final long actualTimeMsBg = bleTimerBg != null ? final long actualTimeMsBg = bleTimerBg != null ?
@@ -4826,10 +4825,10 @@ public abstract class BatteryStats implements Parcelable {
final Timer aggTimer = u.getAggregatedPartialWakelockTimer(); final Timer aggTimer = u.getAggregatedPartialWakelockTimer();
// Convert from microseconds to milliseconds with rounding // Convert from microseconds to milliseconds with rounding
actualTotalPartialWakelock = actualTotalPartialWakelock =
(aggTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000; aggTimer.getTotalDurationMsLocked(rawRealtimeMs);
final Timer bgAggTimer = aggTimer.getSubTimer(); final Timer bgAggTimer = aggTimer.getSubTimer();
actualBgPartialWakelock = bgAggTimer != null ? actualBgPartialWakelock = bgAggTimer != null ?
(bgAggTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : 0; bgAggTimer.getTotalDurationMsLocked(rawRealtimeMs) : 0;
} }
if (actualTotalPartialWakelock != 0 || actualBgPartialWakelock != 0 || if (actualTotalPartialWakelock != 0 || actualBgPartialWakelock != 0 ||
@@ -4897,7 +4896,7 @@ public abstract class BatteryStats implements Parcelable {
final int count = timer.getCountLocked(which); final int count = timer.getCountLocked(which);
final Timer bgTimer = timer.getSubTimer(); final Timer bgTimer = timer.getSubTimer();
final long bgTime = bgTimer != null ? final long bgTime = bgTimer != null ?
(bgTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : -1; bgTimer.getTotalDurationMsLocked(rawRealtimeMs) : -1;
final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1; final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1;
sb.setLength(0); sb.setLength(0);
sb.append(prefix); sb.append(prefix);
@@ -4931,7 +4930,7 @@ public abstract class BatteryStats implements Parcelable {
final int count = timer.getCountLocked(which); final int count = timer.getCountLocked(which);
final Timer bgTimer = timer.getSubTimer(); final Timer bgTimer = timer.getSubTimer();
final long bgTime = bgTimer != null ? final long bgTime = bgTimer != null ?
(bgTimer.getTotalTimeLocked(rawRealtime, which) + 500) / 1000 : -1; bgTimer.getTotalDurationMsLocked(rawRealtimeMs) : -1;
final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1; final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : -1;
sb.setLength(0); sb.setLength(0);
sb.append(prefix); sb.append(prefix);
@@ -4990,7 +4989,6 @@ public abstract class BatteryStats implements Parcelable {
final int count = timer.getCountLocked(which); final int count = timer.getCountLocked(which);
final Timer bgTimer = se.getSensorBackgroundTime(); final Timer bgTimer = se.getSensorBackgroundTime();
final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : 0; final int bgCount = bgTimer != null ? bgTimer.getCountLocked(which) : 0;
final long rawRealtimeMs = (rawRealtime + 500) / 1000;
// 'actualTime' are unpooled and always since reset (regardless of 'which') // 'actualTime' are unpooled and always since reset (regardless of 'which')
final long actualTime = timer.getTotalDurationMsLocked(rawRealtimeMs); final long actualTime = timer.getTotalDurationMsLocked(rawRealtimeMs);
final long bgActualTime = bgTimer != null ? final long bgActualTime = bgTimer != null ?