Migrate to IndentingPrintWriter.
Switch from using PrintWriter with manual indents to IndentingPrintWriter to simplify and standardize the dumping code. Bug: 79580230 Test: verify dump output looks correct Test: atest com.android.server.power.batterysaver.BatterySaverPolicyTest Test: atest com.android.server.power.batterysaver.BatterySaverStateMachineTest Test: atest com.android.server.power.batterysaver.BatterySavingStatsTest Test: atest CtsBatterySavingTestCases Change-Id: I3ec2e4df63739fce3bb850100874b087e65c20a7
This commit is contained in:
@@ -29,6 +29,7 @@ import android.os.PowerSaveState;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.KeyValueListParser;
|
||||
import android.util.Slog;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
@@ -1031,90 +1032,92 @@ public class BatterySaverPolicy extends ContentObserver {
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw) {
|
||||
final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
|
||||
|
||||
synchronized (mLock) {
|
||||
pw.println();
|
||||
mBatterySavingStats.dump(pw, "");
|
||||
ipw.println();
|
||||
mBatterySavingStats.dump(ipw);
|
||||
|
||||
pw.println();
|
||||
pw.println("Battery saver policy (*NOTE* they only apply when battery saver is ON):");
|
||||
pw.println(" Settings: " + Settings.Global.BATTERY_SAVER_CONSTANTS);
|
||||
pw.println(" value: " + mSettings);
|
||||
pw.println(" Settings: " + mDeviceSpecificSettingsSource);
|
||||
pw.println(" value: " + mDeviceSpecificSettings);
|
||||
ipw.println();
|
||||
ipw.println("Battery saver policy (*NOTE* they only apply when battery saver is ON):");
|
||||
ipw.increaseIndent();
|
||||
ipw.println("Settings: " + Settings.Global.BATTERY_SAVER_CONSTANTS);
|
||||
ipw.increaseIndent();
|
||||
ipw.println("value: " + mSettings);
|
||||
ipw.decreaseIndent();
|
||||
ipw.println("Settings: " + mDeviceSpecificSettingsSource);
|
||||
ipw.increaseIndent();
|
||||
ipw.println("value: " + mDeviceSpecificSettings);
|
||||
ipw.decreaseIndent();
|
||||
|
||||
pw.println(" Adaptive Settings: " + Settings.Global.BATTERY_SAVER_ADAPTIVE_CONSTANTS);
|
||||
pw.println(" value: " + mAdaptiveSettings);
|
||||
pw.println(" Adaptive Device Specific Settings: "
|
||||
ipw.println("Adaptive Settings: " + Settings.Global.BATTERY_SAVER_ADAPTIVE_CONSTANTS);
|
||||
ipw.increaseIndent();
|
||||
ipw.println("value: " + mAdaptiveSettings);
|
||||
ipw.decreaseIndent();
|
||||
ipw.println("Adaptive Device Specific Settings: "
|
||||
+ Settings.Global.BATTERY_SAVER_ADAPTIVE_DEVICE_SPECIFIC_CONSTANTS);
|
||||
pw.println(" value: " + mAdaptiveDeviceSpecificSettings);
|
||||
ipw.increaseIndent();
|
||||
ipw.println("value: " + mAdaptiveDeviceSpecificSettings);
|
||||
ipw.decreaseIndent();
|
||||
|
||||
pw.println(" mAccessibilityEnabled=" + mAccessibilityEnabled.get());
|
||||
pw.println(" mAutomotiveProjectionActive=" + mAutomotiveProjectionActive.get());
|
||||
pw.println(" mPolicyLevel=" + mPolicyLevel);
|
||||
ipw.println("mAccessibilityEnabled=" + mAccessibilityEnabled.get());
|
||||
ipw.println("mAutomotiveProjectionActive=" + mAutomotiveProjectionActive.get());
|
||||
ipw.println("mPolicyLevel=" + mPolicyLevel);
|
||||
|
||||
dumpPolicyLocked(pw, " ", "full", mFullPolicy);
|
||||
dumpPolicyLocked(pw, " ", "default adaptive", mDefaultAdaptivePolicy);
|
||||
dumpPolicyLocked(pw, " ", "current adaptive", mAdaptivePolicy);
|
||||
dumpPolicyLocked(pw, " ", "effective", mEffectivePolicyRaw);
|
||||
dumpPolicyLocked(ipw, "full", mFullPolicy);
|
||||
dumpPolicyLocked(ipw, "default adaptive", mDefaultAdaptivePolicy);
|
||||
dumpPolicyLocked(ipw, "current adaptive", mAdaptivePolicy);
|
||||
dumpPolicyLocked(ipw, "effective", mEffectivePolicyRaw);
|
||||
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
}
|
||||
|
||||
private void dumpPolicyLocked(PrintWriter pw, String indent, String label, Policy p) {
|
||||
private void dumpPolicyLocked(IndentingPrintWriter pw, String label, Policy p) {
|
||||
pw.println();
|
||||
pw.print(indent);
|
||||
pw.println("Policy '" + label + "'");
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_ADVERTISE_IS_ENABLED + "=" + p.advertiseIsEnabled);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_VIBRATION_DISABLED + "=" + p.disableVibration);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_ANIMATION_DISABLED + "=" + p.disableAnimation);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_FULLBACKUP_DEFERRED + "=" + p.deferFullBackup);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_KEYVALUE_DEFERRED + "=" + p.deferKeyValueBackup);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_ACTIVATE_FIREWALL_DISABLED + "=" + !p.enableFirewall);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_ACTIVATE_DATASAVER_DISABLED + "=" + !p.enableDataSaver);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_LAUNCH_BOOST_DISABLED + "=" + p.disableLaunchBoost);
|
||||
pw.println(
|
||||
" " + KEY_ADJUST_BRIGHTNESS_DISABLED + "=" + !p.enableAdjustBrightness);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_ADJUST_BRIGHTNESS_FACTOR + "=" + p.adjustBrightnessFactor);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_GPS_MODE + "=" + p.locationMode);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_FORCE_ALL_APPS_STANDBY + "=" + p.forceAllAppsStandby);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_FORCE_BACKGROUND_CHECK + "=" + p.forceBackgroundCheck);
|
||||
pw.println(
|
||||
" " + KEY_OPTIONAL_SENSORS_DISABLED + "=" + p.disableOptionalSensors);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_AOD_DISABLED + "=" + p.disableAod);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_SOUNDTRIGGER_DISABLED + "=" + p.disableSoundTrigger);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_QUICK_DOZE_ENABLED + "=" + p.enableQuickDoze);
|
||||
pw.print(indent);
|
||||
pw.println(" " + KEY_ENABLE_NIGHT_MODE + "=" + p.enableNightMode);
|
||||
pw.increaseIndent();
|
||||
pw.println(KEY_ADVERTISE_IS_ENABLED + "=" + p.advertiseIsEnabled);
|
||||
pw.println(KEY_VIBRATION_DISABLED + "=" + p.disableVibration);
|
||||
pw.println(KEY_ANIMATION_DISABLED + "=" + p.disableAnimation);
|
||||
pw.println(KEY_FULLBACKUP_DEFERRED + "=" + p.deferFullBackup);
|
||||
pw.println(KEY_KEYVALUE_DEFERRED + "=" + p.deferKeyValueBackup);
|
||||
pw.println(KEY_ACTIVATE_FIREWALL_DISABLED + "=" + !p.enableFirewall);
|
||||
pw.println(KEY_ACTIVATE_DATASAVER_DISABLED + "=" + !p.enableDataSaver);
|
||||
pw.println(KEY_LAUNCH_BOOST_DISABLED + "=" + p.disableLaunchBoost);
|
||||
pw.println(KEY_ADJUST_BRIGHTNESS_DISABLED + "=" + !p.enableAdjustBrightness);
|
||||
pw.println(KEY_ADJUST_BRIGHTNESS_FACTOR + "=" + p.adjustBrightnessFactor);
|
||||
pw.println(KEY_GPS_MODE + "=" + p.locationMode);
|
||||
pw.println(KEY_FORCE_ALL_APPS_STANDBY + "=" + p.forceAllAppsStandby);
|
||||
pw.println(KEY_FORCE_BACKGROUND_CHECK + "=" + p.forceBackgroundCheck);
|
||||
pw.println(KEY_OPTIONAL_SENSORS_DISABLED + "=" + p.disableOptionalSensors);
|
||||
pw.println(KEY_AOD_DISABLED + "=" + p.disableAod);
|
||||
pw.println(KEY_SOUNDTRIGGER_DISABLED + "=" + p.disableSoundTrigger);
|
||||
pw.println(KEY_QUICK_DOZE_ENABLED + "=" + p.enableQuickDoze);
|
||||
pw.println(KEY_ENABLE_NIGHT_MODE + "=" + p.enableNightMode);
|
||||
|
||||
pw.print(" Interactive File values:\n");
|
||||
dumpMap(pw, " ", p.filesForInteractive);
|
||||
pw.println("Interactive File values:");
|
||||
pw.increaseIndent();
|
||||
dumpMap(pw, p.filesForInteractive);
|
||||
pw.decreaseIndent();
|
||||
pw.println();
|
||||
|
||||
pw.print(" Noninteractive File values:\n");
|
||||
dumpMap(pw, " ", p.filesForNoninteractive);
|
||||
pw.println("Noninteractive File values:");
|
||||
pw.increaseIndent();
|
||||
dumpMap(pw, p.filesForNoninteractive);
|
||||
pw.decreaseIndent();
|
||||
|
||||
// Decrease from indent right after "Policy" line
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
|
||||
private void dumpMap(PrintWriter pw, String prefix, ArrayMap<String, String> map) {
|
||||
private void dumpMap(PrintWriter pw, ArrayMap<String, String> map) {
|
||||
if (map == null) {
|
||||
pw.println("N/A");
|
||||
return;
|
||||
}
|
||||
final int size = map.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
pw.print(prefix);
|
||||
pw.print(map.keyAt(i));
|
||||
pw.print(": '");
|
||||
pw.print(map.valueAt(i));
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.os.PowerManager;
|
||||
import android.os.SystemClock;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.Slog;
|
||||
import android.util.proto.ProtoOutputStream;
|
||||
|
||||
@@ -888,70 +889,75 @@ public class BatterySaverStateMachine {
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw) {
|
||||
final IndentingPrintWriter ipw = new IndentingPrintWriter(pw, " ");
|
||||
|
||||
ipw.println();
|
||||
ipw.println("Battery saver state machine:");
|
||||
ipw.increaseIndent();
|
||||
synchronized (mLock) {
|
||||
pw.println();
|
||||
pw.println("Battery saver state machine:");
|
||||
|
||||
pw.print(" Enabled=");
|
||||
pw.println(mBatterySaverController.isEnabled());
|
||||
pw.print(" full=");
|
||||
pw.println(mBatterySaverController.isFullEnabled());
|
||||
pw.print(" adaptive=");
|
||||
pw.print(mBatterySaverController.isAdaptiveEnabled());
|
||||
ipw.print("Enabled=");
|
||||
ipw.println(mBatterySaverController.isEnabled());
|
||||
ipw.increaseIndent();
|
||||
ipw.print("full=");
|
||||
ipw.println(mBatterySaverController.isFullEnabled());
|
||||
ipw.print("adaptive=");
|
||||
ipw.print(mBatterySaverController.isAdaptiveEnabled());
|
||||
if (mBatterySaverController.isAdaptiveEnabled()) {
|
||||
pw.print(" (advertise=");
|
||||
pw.print(
|
||||
ipw.print(" (advertise=");
|
||||
ipw.print(
|
||||
mBatterySaverController.getBatterySaverPolicy().shouldAdvertiseIsEnabled());
|
||||
pw.print(")");
|
||||
ipw.print(")");
|
||||
}
|
||||
pw.println();
|
||||
pw.print(" mState=");
|
||||
pw.println(mState);
|
||||
ipw.decreaseIndent();
|
||||
ipw.println();
|
||||
ipw.print("mState=");
|
||||
ipw.println(mState);
|
||||
|
||||
pw.print(" mLastChangedIntReason=");
|
||||
pw.println(mLastChangedIntReason);
|
||||
pw.print(" mLastChangedStrReason=");
|
||||
pw.println(mLastChangedStrReason);
|
||||
ipw.print("mLastChangedIntReason=");
|
||||
ipw.println(mLastChangedIntReason);
|
||||
ipw.print("mLastChangedStrReason=");
|
||||
ipw.println(mLastChangedStrReason);
|
||||
|
||||
pw.print(" mBootCompleted=");
|
||||
pw.println(mBootCompleted);
|
||||
pw.print(" mSettingsLoaded=");
|
||||
pw.println(mSettingsLoaded);
|
||||
pw.print(" mBatteryStatusSet=");
|
||||
pw.println(mBatteryStatusSet);
|
||||
ipw.print("mBootCompleted=");
|
||||
ipw.println(mBootCompleted);
|
||||
ipw.print("mSettingsLoaded=");
|
||||
ipw.println(mSettingsLoaded);
|
||||
ipw.print("mBatteryStatusSet=");
|
||||
ipw.println(mBatteryStatusSet);
|
||||
|
||||
pw.print(" mIsPowered=");
|
||||
pw.println(mIsPowered);
|
||||
pw.print(" mBatteryLevel=");
|
||||
pw.println(mBatteryLevel);
|
||||
pw.print(" mIsBatteryLevelLow=");
|
||||
pw.println(mIsBatteryLevelLow);
|
||||
ipw.print("mIsPowered=");
|
||||
ipw.println(mIsPowered);
|
||||
ipw.print("mBatteryLevel=");
|
||||
ipw.println(mBatteryLevel);
|
||||
ipw.print("mIsBatteryLevelLow=");
|
||||
ipw.println(mIsBatteryLevelLow);
|
||||
|
||||
pw.print(" mSettingAutomaticBatterySaver=");
|
||||
pw.println(mSettingAutomaticBatterySaver);
|
||||
pw.print(" mSettingBatterySaverEnabled=");
|
||||
pw.println(mSettingBatterySaverEnabled);
|
||||
pw.print(" mSettingBatterySaverEnabledSticky=");
|
||||
pw.println(mSettingBatterySaverEnabledSticky);
|
||||
pw.print(" mSettingBatterySaverStickyAutoDisableEnabled=");
|
||||
pw.println(mSettingBatterySaverStickyAutoDisableEnabled);
|
||||
pw.print(" mSettingBatterySaverStickyAutoDisableThreshold=");
|
||||
pw.println(mSettingBatterySaverStickyAutoDisableThreshold);
|
||||
pw.print(" mSettingBatterySaverTriggerThreshold=");
|
||||
pw.println(mSettingBatterySaverTriggerThreshold);
|
||||
pw.print(" mBatterySaverStickyBehaviourDisabled=");
|
||||
pw.println(mBatterySaverStickyBehaviourDisabled);
|
||||
ipw.print("mSettingAutomaticBatterySaver=");
|
||||
ipw.println(mSettingAutomaticBatterySaver);
|
||||
ipw.print("mSettingBatterySaverEnabled=");
|
||||
ipw.println(mSettingBatterySaverEnabled);
|
||||
ipw.print("mSettingBatterySaverEnabledSticky=");
|
||||
ipw.println(mSettingBatterySaverEnabledSticky);
|
||||
ipw.print("mSettingBatterySaverStickyAutoDisableEnabled=");
|
||||
ipw.println(mSettingBatterySaverStickyAutoDisableEnabled);
|
||||
ipw.print("mSettingBatterySaverStickyAutoDisableThreshold=");
|
||||
ipw.println(mSettingBatterySaverStickyAutoDisableThreshold);
|
||||
ipw.print("mSettingBatterySaverTriggerThreshold=");
|
||||
ipw.println(mSettingBatterySaverTriggerThreshold);
|
||||
ipw.print("mBatterySaverStickyBehaviourDisabled=");
|
||||
ipw.println(mBatterySaverStickyBehaviourDisabled);
|
||||
|
||||
pw.print(" mDynamicPowerSavingsDefaultDisableThreshold=");
|
||||
pw.println(mDynamicPowerSavingsDefaultDisableThreshold);
|
||||
pw.print(" mDynamicPowerSavingsDisableThreshold=");
|
||||
pw.println(mDynamicPowerSavingsDisableThreshold);
|
||||
pw.print(" mDynamicPowerSavingsEnableBatterySaver=");
|
||||
pw.println(mDynamicPowerSavingsEnableBatterySaver);
|
||||
ipw.print("mDynamicPowerSavingsDefaultDisableThreshold=");
|
||||
ipw.println(mDynamicPowerSavingsDefaultDisableThreshold);
|
||||
ipw.print("mDynamicPowerSavingsDisableThreshold=");
|
||||
ipw.println(mDynamicPowerSavingsDisableThreshold);
|
||||
ipw.print("mDynamicPowerSavingsEnableBatterySaver=");
|
||||
ipw.println(mDynamicPowerSavingsEnableBatterySaver);
|
||||
|
||||
pw.print(" mLastAdaptiveBatterySaverChangedExternallyElapsed=");
|
||||
pw.println(mLastAdaptiveBatterySaverChangedExternallyElapsed);
|
||||
ipw.print("mLastAdaptiveBatterySaverChangedExternallyElapsed=");
|
||||
ipw.println(mLastAdaptiveBatterySaverChangedExternallyElapsed);
|
||||
}
|
||||
ipw.decreaseIndent();
|
||||
}
|
||||
|
||||
public void dumpProto(ProtoOutputStream proto, long tag) {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.android.server.power.batterysaver;
|
||||
|
||||
import android.os.BatteryManagerInternal;
|
||||
import android.os.SystemClock;
|
||||
import android.util.IndentingPrintWriter;
|
||||
import android.util.Slog;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TimeUtils;
|
||||
@@ -26,7 +27,6 @@ import com.android.internal.annotations.VisibleForTesting;
|
||||
import com.android.server.EventLogTags;
|
||||
import com.android.server.LocalServices;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -391,18 +391,15 @@ public class BatterySavingStats {
|
||||
stat.endTime = 0;
|
||||
}
|
||||
|
||||
public void dump(PrintWriter pw, String indent) {
|
||||
public void dump(IndentingPrintWriter pw) {
|
||||
pw.println("Battery saving stats:");
|
||||
pw.increaseIndent();
|
||||
|
||||
synchronized (mLock) {
|
||||
pw.print(indent);
|
||||
pw.println("Battery saving stats:");
|
||||
|
||||
indent = indent + " ";
|
||||
|
||||
final long now = System.currentTimeMillis();
|
||||
final long nowElapsed = injectCurrentTime();
|
||||
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
|
||||
|
||||
pw.print(indent);
|
||||
pw.print("Battery Saver is currently: ");
|
||||
switch (BatterySaverState.fromIndex(mCurrentState)) {
|
||||
case BatterySaverState.OFF:
|
||||
@@ -416,9 +413,8 @@ public class BatterySavingStats {
|
||||
break;
|
||||
}
|
||||
|
||||
pw.increaseIndent();
|
||||
if (mLastBatterySaverEnabledTime > 0) {
|
||||
pw.print(indent);
|
||||
pw.print(" ");
|
||||
pw.print("Last ON time: ");
|
||||
pw.print(sdf.format(new Date(now - nowElapsed + mLastBatterySaverEnabledTime)));
|
||||
pw.print(" ");
|
||||
@@ -427,8 +423,6 @@ public class BatterySavingStats {
|
||||
}
|
||||
|
||||
if (mLastBatterySaverDisabledTime > 0) {
|
||||
pw.print(indent);
|
||||
pw.print(" ");
|
||||
pw.print("Last OFF time: ");
|
||||
pw.print(sdf.format(new Date(now - nowElapsed + mLastBatterySaverDisabledTime)));
|
||||
pw.print(" ");
|
||||
@@ -436,14 +430,10 @@ public class BatterySavingStats {
|
||||
pw.println();
|
||||
}
|
||||
|
||||
pw.print(indent);
|
||||
pw.print(" ");
|
||||
pw.print("Times full enabled: ");
|
||||
pw.println(mBatterySaverEnabledCount);
|
||||
|
||||
if (mLastAdaptiveBatterySaverEnabledTime > 0) {
|
||||
pw.print(indent);
|
||||
pw.print(" ");
|
||||
pw.print("Last ADAPTIVE ON time: ");
|
||||
pw.print(sdf.format(
|
||||
new Date(now - nowElapsed + mLastAdaptiveBatterySaverEnabledTime)));
|
||||
@@ -452,8 +442,6 @@ public class BatterySavingStats {
|
||||
pw.println();
|
||||
}
|
||||
if (mLastAdaptiveBatterySaverDisabledTime > 0) {
|
||||
pw.print(indent);
|
||||
pw.print(" ");
|
||||
pw.print("Last ADAPTIVE OFF time: ");
|
||||
pw.print(sdf.format(
|
||||
new Date(now - nowElapsed + mLastAdaptiveBatterySaverDisabledTime)));
|
||||
@@ -461,39 +449,36 @@ public class BatterySavingStats {
|
||||
TimeUtils.formatDuration(mLastAdaptiveBatterySaverDisabledTime, nowElapsed, pw);
|
||||
pw.println();
|
||||
}
|
||||
pw.print(indent);
|
||||
pw.print(" ");
|
||||
pw.print("Times adaptive enabled: ");
|
||||
pw.println(mAdaptiveBatterySaverEnabledCount);
|
||||
|
||||
pw.decreaseIndent();
|
||||
pw.println();
|
||||
|
||||
pw.print(indent);
|
||||
pw.println("Drain stats:");
|
||||
|
||||
pw.print(indent);
|
||||
pw.println(" Battery saver OFF ON");
|
||||
dumpLineLocked(pw, indent, InteractiveState.NON_INTERACTIVE, "NonIntr",
|
||||
dumpLineLocked(pw, InteractiveState.NON_INTERACTIVE, "NonIntr",
|
||||
DozeState.NOT_DOZING, "NonDoze");
|
||||
dumpLineLocked(pw, indent, InteractiveState.INTERACTIVE, " Intr",
|
||||
dumpLineLocked(pw, InteractiveState.INTERACTIVE, " Intr",
|
||||
DozeState.NOT_DOZING, " ");
|
||||
|
||||
dumpLineLocked(pw, indent, InteractiveState.NON_INTERACTIVE, "NonIntr",
|
||||
dumpLineLocked(pw, InteractiveState.NON_INTERACTIVE, "NonIntr",
|
||||
DozeState.DEEP, "Deep ");
|
||||
dumpLineLocked(pw, indent, InteractiveState.INTERACTIVE, " Intr",
|
||||
dumpLineLocked(pw, InteractiveState.INTERACTIVE, " Intr",
|
||||
DozeState.DEEP, " ");
|
||||
|
||||
dumpLineLocked(pw, indent, InteractiveState.NON_INTERACTIVE, "NonIntr",
|
||||
dumpLineLocked(pw, InteractiveState.NON_INTERACTIVE, "NonIntr",
|
||||
DozeState.LIGHT, "Light ");
|
||||
dumpLineLocked(pw, indent, InteractiveState.INTERACTIVE, " Intr",
|
||||
dumpLineLocked(pw, InteractiveState.INTERACTIVE, " Intr",
|
||||
DozeState.LIGHT, " ");
|
||||
}
|
||||
pw.decreaseIndent();
|
||||
}
|
||||
|
||||
private void dumpLineLocked(PrintWriter pw, String indent,
|
||||
private void dumpLineLocked(IndentingPrintWriter pw,
|
||||
int interactiveState, String interactiveLabel,
|
||||
int dozeState, String dozeLabel) {
|
||||
pw.print(indent);
|
||||
pw.print(dozeLabel);
|
||||
pw.print(" ");
|
||||
pw.print(interactiveLabel);
|
||||
|
||||
@@ -25,6 +25,7 @@ import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import android.metrics.LogMaker;
|
||||
import android.util.IndentingPrintWriter;
|
||||
|
||||
import androidx.test.filters.SmallTest;
|
||||
import androidx.test.runner.AndroidJUnit4;
|
||||
@@ -73,7 +74,7 @@ public class BatterySavingStatsTest {
|
||||
|
||||
void assertDumpable() {
|
||||
final ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
dump(new PrintWriter(out), ""); // Just make sure it won't crash.
|
||||
dump(new IndentingPrintWriter(new PrintWriter(out))); // Just make sure it won't crash.
|
||||
}
|
||||
|
||||
void advanceClock(int minutes) {
|
||||
|
||||
Reference in New Issue
Block a user