Fix cell stats did not increase due to rate limit in battery stats
Current test triggers batterystats to update mobile stats by switching default network and ConnectivityService will call reportMobileRadioPowerState to have batterystats update the mobile stats. But in current design, batterystats will rate-limit the update if it is due to modem power state change. So the modem stats might not be updated if it's rate-limited. The other reasons (plug/unplug, battery level change,etc) will be unaffected. Thus, dump battery stats in the test to trigger a full sync of data. Bug: 256087047 Test: CtsNetTestCases:BatteryStatsManagerTest Change-Id: I936d51f0c205640eac94f80062ad66f55df9d0df
This commit is contained in:
@@ -155,6 +155,13 @@ public class BatteryStatsManagerTest{
|
||||
// removing data activity tracking.
|
||||
mCtsNetUtils.ensureWifiConnected();
|
||||
|
||||
// There's rate limit to update mobile battery so if ConnectivityService calls
|
||||
// BatteryStatsManager.reportMobileRadioPowerState when default network changed,
|
||||
// the mobile stats might not be updated. But if the mobile update due to other
|
||||
// reasons (plug/unplug, battery level change, etc) will be unaffected. Thus here
|
||||
// dumps the battery stats to trigger a full sync of data.
|
||||
executeShellCommand("dumpsys batterystats");
|
||||
|
||||
// Check cellular battery stats are updated.
|
||||
runAsShell(UPDATE_DEVICE_STATS,
|
||||
() -> assertStatsEventually(mBsm::getCellularBatteryStats,
|
||||
|
||||
Reference in New Issue
Block a user