Support phonetype control for Settings Battery database retention time

Bug: 404740486
Fix: 404740486
Test: atest
Flag: EXEMPT bug fix
Change-Id: Ifc9032e19a5b26e307d1426ea5c07de84e1613f4
This commit is contained in:
Zaiyue Xue
2025-03-19 17:49:16 +08:00
parent 339367886d
commit 08a3aa7f33
4 changed files with 20 additions and 4 deletions

View File

@@ -32,6 +32,7 @@ import androidx.test.core.app.ApplicationProvider;
import com.android.settings.fuelgauge.batteryusage.db.BatteryStateDao;
import com.android.settings.fuelgauge.batteryusage.db.BatteryStateDatabase;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.testutils.BatteryTestUtils;
import org.junit.After;
@@ -104,7 +105,9 @@ public final class PeriodicJobReceiverTest {
@Test
public void onReceive_containsExpiredData_clearsExpiredDataFromDatabase()
throws InterruptedException {
insertExpiredData(/* shiftDay= */ DatabaseUtils.DATA_RETENTION_INTERVAL_DAY);
int dataRetentionDays = FeatureFactory.getFeatureFactory()
.getPowerUsageFeatureProvider().getDataRetentionDays();
insertExpiredData(/* shiftDay= */ dataRetentionDays);
mReceiver.onReceive(mContext, JOB_UPDATE_INTENT);
@@ -115,7 +118,9 @@ public final class PeriodicJobReceiverTest {
@Test
public void onReceive_withoutExpiredData_notClearsExpiredDataFromDatabase()
throws InterruptedException {
insertExpiredData(/* shiftDay= */ DatabaseUtils.DATA_RETENTION_INTERVAL_DAY - 1);
int dataRetentionDays = FeatureFactory.getFeatureFactory()
.getPowerUsageFeatureProvider().getDataRetentionDays();
insertExpiredData(dataRetentionDays - 1);
mReceiver.onReceive(mContext, JOB_UPDATE_INTENT);