Update database clear & job refresh mechanism for time zone change intent

- Clear database and reset periodic job
- Take a snapshot of current battery usage stats

Bug: 336423923
Test: atest SettingsRoboTests:com.android.settings.fuelgauge.batteryusage
Change-Id: I4aade9db950b508e2190605371f246904f131da3
This commit is contained in:
mxyyiyi
2024-05-08 17:34:22 +08:00
parent 798340fafd
commit d3ce90347b
5 changed files with 51 additions and 0 deletions

View File

@@ -173,6 +173,20 @@ public final class BootBroadcastReceiverTest {
assertThat(mShadowAlarmManager.peekNextScheduledAlarm()).isNull();
}
@Test
public void onReceive_withTimeZoneChangedIntent_clearAllDataAndRefreshesJob()
throws InterruptedException {
BatteryTestUtils.insertDataToBatteryStateTable(
mContext, Clock.systemUTC().millis(), "com.android.systemui");
assertThat(mDao.getAllAfter(0).size()).isEqualTo(1);
mReceiver.onReceive(mContext, new Intent(Intent.ACTION_TIMEZONE_CHANGED));
TimeUnit.MILLISECONDS.sleep(100);
assertThat(mDao.getAllAfter(0)).isEmpty();
assertThat(mShadowAlarmManager.peekNextScheduledAlarm()).isNotNull();
}
@Test
public void invokeJobRecheck_broadcastsIntent() {
BootBroadcastReceiver.invokeJobRecheck(mContext);