OSDN Git Service

Fix counting problems in StopwatchTimer.
authorBookatz <bookatz@google.com>
Thu, 6 Apr 2017 18:59:13 +0000 (11:59 -0700)
committerBookatz <bookatz@google.com>
Fri, 7 Apr 2017 18:12:54 +0000 (11:12 -0700)
commitceebafe41a127c18213ca39ddf692ae1cbfb100e
tree3f251ef9724d02515e996f7e6341edcbf18fca9d
parent67ee79e84fa14975721ab9500aabf593c05dbcfe
Fix counting problems in StopwatchTimer.

Changed StopwatchTimer so that its count only increases if the timer is
started when its time base is running. Previously, if the time base was
off, the timer was started, the time base was turned on, and then the
timer was stopped, the count would be increased; now, it will not
(because the time base was off when the timer started). Moreover, this
likely fixes the count==-1 bug that previously could occur, since the
count will no longer be decremented if the timer is stopped after a reset.

Fixes: 36730213
Bug: 30099724
Test: runtest -x
frameworks/base/core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java

Change-Id: Iad195e431618629ce432074e0c1bd217f9818cb1
core/java/com/android/internal/os/BatteryStatsImpl.java
core/tests/coretests/src/com/android/internal/os/BatteryStatsBackgroundStatsTest.java
core/tests/coretests/src/com/android/internal/os/BatteryStatsSensorTest.java
core/tests/coretests/src/com/android/internal/os/BatteryStatsStopwatchTimerTest.java [new file with mode: 0644]
core/tests/coretests/src/com/android/internal/os/BatteryStatsTests.java