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
(cherry picked from commit 3c4231d6131ad1cc5d3765a814b7a0e5b8310998)
Merged-In: I936d51f0c205640eac94f80062ad66f55df9d0df
diff --git a/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java b/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java
index e2821cb..3c71c90 100644
--- a/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java
+++ b/tests/cts/net/src/android/net/cts/BatteryStatsManagerTest.java
@@ -155,6 +155,13 @@
         // 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,