Loading core/java/android/os/BatteryStats.java +3 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.os; import static android.app.ActivityManager.PROCESS_STATE_BOUND_TOP; import static android.os.BatteryStatsManager.NUM_WIFI_STATES; import static android.os.BatteryStatsManager.NUM_WIFI_SUPPL_STATES; Loading Loading @@ -903,9 +902,9 @@ public abstract class BatteryStats implements Parcelable { * is not attributed to any non-critical process states. */ public static final int[] CRITICAL_PROC_STATES = { PROCESS_STATE_TOP, PROCESS_STATE_BOUND_TOP, PROCESS_STATE_FOREGROUND_SERVICE, PROCESS_STATE_FOREGROUND Uid.PROCESS_STATE_TOP, Uid.PROCESS_STATE_FOREGROUND_SERVICE, Uid.PROCESS_STATE_FOREGROUND }; public abstract long getProcessStateTime(int state, long elapsedRealtimeUs, int which); Loading core/tests/coretests/src/com/android/internal/os/BstatsCpuTimesValidationTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -584,7 +584,7 @@ public class BstatsCpuTimesValidationTest { actualCpuTimeMs += cpuTimesMs[i]; } assertApproximateValue("Incorrect total cpu time, " + msgCpuTimes, 2 * WORK_DURATION_MS, actualCpuTimeMs); WORK_DURATION_MS, actualCpuTimeMs); batteryOffScreenOn(); } finally { Loading Loading @@ -656,8 +656,14 @@ public class BstatsCpuTimesValidationTest { } } private void assertApproximateValue(String errorPrefix, long expectedValue, long actualValue) { assertValueRange(errorPrefix, actualValue, expectedValue * 0.5, expectedValue * 1.5); private void assertApproximateValue(String errorPrefix, long expectedValueMs, long actualValueMs) { // Allow the actual value to be 1 second smaller than the expected. // Also allow it to be up to 5 seconds larger, to accommodate the arbitrary // latency introduced by BatteryExternalStatsWorker.scheduleReadProcStateCpuTimes assertValueRange(errorPrefix, actualValueMs, expectedValueMs - 1000, expectedValueMs + 5000); } private void assertValueRange(String errorPrefix, Loading Loading
core/java/android/os/BatteryStats.java +3 −4 Original line number Diff line number Diff line Loading @@ -16,7 +16,6 @@ package android.os; import static android.app.ActivityManager.PROCESS_STATE_BOUND_TOP; import static android.os.BatteryStatsManager.NUM_WIFI_STATES; import static android.os.BatteryStatsManager.NUM_WIFI_SUPPL_STATES; Loading Loading @@ -903,9 +902,9 @@ public abstract class BatteryStats implements Parcelable { * is not attributed to any non-critical process states. */ public static final int[] CRITICAL_PROC_STATES = { PROCESS_STATE_TOP, PROCESS_STATE_BOUND_TOP, PROCESS_STATE_FOREGROUND_SERVICE, PROCESS_STATE_FOREGROUND Uid.PROCESS_STATE_TOP, Uid.PROCESS_STATE_FOREGROUND_SERVICE, Uid.PROCESS_STATE_FOREGROUND }; public abstract long getProcessStateTime(int state, long elapsedRealtimeUs, int which); Loading
core/tests/coretests/src/com/android/internal/os/BstatsCpuTimesValidationTest.java +9 −3 Original line number Diff line number Diff line Loading @@ -584,7 +584,7 @@ public class BstatsCpuTimesValidationTest { actualCpuTimeMs += cpuTimesMs[i]; } assertApproximateValue("Incorrect total cpu time, " + msgCpuTimes, 2 * WORK_DURATION_MS, actualCpuTimeMs); WORK_DURATION_MS, actualCpuTimeMs); batteryOffScreenOn(); } finally { Loading Loading @@ -656,8 +656,14 @@ public class BstatsCpuTimesValidationTest { } } private void assertApproximateValue(String errorPrefix, long expectedValue, long actualValue) { assertValueRange(errorPrefix, actualValue, expectedValue * 0.5, expectedValue * 1.5); private void assertApproximateValue(String errorPrefix, long expectedValueMs, long actualValueMs) { // Allow the actual value to be 1 second smaller than the expected. // Also allow it to be up to 5 seconds larger, to accommodate the arbitrary // latency introduced by BatteryExternalStatsWorker.scheduleReadProcStateCpuTimes assertValueRange(errorPrefix, actualValueMs, expectedValueMs - 1000, expectedValueMs + 5000); } private void assertValueRange(String errorPrefix, Loading