Call detect anomaly in period job only when there is new battery usage data.

- Reduce the memory usage of call anomaly detection
 - Remove redundant condition for low battery banner

Bug: 300446490
Bug: 284893240
Fix: 300446490
Test: presubmit
Change-Id: I11c1b41a45e129bcec57b9d18c4affe0de7f1d38
Merged-In: I11c1b41a45e129bcec57b9d18c4affe0de7f1d38
This commit is contained in:
Zaiyue Xue
2023-09-19 15:05:08 +08:00
parent 821ed07099
commit 8371d08595
3 changed files with 14 additions and 17 deletions

View File

@@ -53,7 +53,6 @@ public class LowBatteryDetectorTest {
mPolicy = spy(new BatteryTipPolicy(RuntimeEnvironment.application));
mContext = RuntimeEnvironment.application;
ReflectionHelpers.setField(mPolicy, "lowBatteryEnabled", true);
ReflectionHelpers.setField(mPolicy, "lowBatteryHour", 3);
mBatteryInfo.discharging = true;
mLowBatteryDetector = new LowBatteryDetector(mContext, mPolicy, mBatteryInfo,
@@ -78,13 +77,9 @@ public class LowBatteryDetectorTest {
@Test
public void testDetect_lowBattery_tipNew() {
mBatteryInfo.batteryLevel = 3;
mBatteryInfo.batteryLevel = 20;
mBatteryInfo.remainingTimeUs = TimeUnit.DAYS.toMillis(1);
assertThat(mLowBatteryDetector.detect().getState()).isEqualTo(BatteryTip.StateType.NEW);
mBatteryInfo.batteryLevel = 50;
mBatteryInfo.remainingTimeUs = TimeUnit.MINUTES.toMillis(1);
assertThat(mLowBatteryDetector.detect().getState()).isEqualTo(BatteryTip.StateType.NEW);
}
@Test
@@ -104,9 +99,9 @@ public class LowBatteryDetectorTest {
}
@Test
public void testDetect_timeEstimationZero_tipInvisible() {
public void testDetect_lowTimeEstimation_tipInvisible() {
mBatteryInfo.batteryLevel = 50;
mBatteryInfo.remainingTimeUs = 0;
mBatteryInfo.remainingTimeUs = TimeUnit.MINUTES.toMillis(1);
assertThat(mLowBatteryDetector.detect().isVisible()).isFalse();
}