Remove legacy useless BatteryTip cache mechanism
Remove the legacy BatteryTip list cache mechanism to avoid not using the new re-create BatteryTip list, but only update its state and invoke updatePreference(). We should use the new BatteryTip list to apply the new detected results. Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER="com.android.settings.fuelgauge.batterytip" Change-Id: I884f04927403ad4d97b459ff5477a1fe9df21553
This commit is contained in:
@@ -36,6 +36,7 @@ import com.android.settingslib.core.instrumentation.MetricsFeatureProvider;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Controller in charge of the battery tip group
|
||||
@@ -98,15 +99,7 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
||||
if (batteryTips == null) {
|
||||
return;
|
||||
}
|
||||
if (mBatteryTips == null) {
|
||||
mBatteryTips = batteryTips;
|
||||
} else {
|
||||
// mBatteryTips and batteryTips always have the same length and same sequence.
|
||||
for (int i = 0, size = batteryTips.size(); i < size; i++) {
|
||||
mBatteryTips.get(i).updateState(batteryTips.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
mBatteryTips = batteryTips;
|
||||
mCardPreference.setVisible(false);
|
||||
for (int i = 0, size = batteryTips.size(); i < size; i++) {
|
||||
final BatteryTip batteryTip = mBatteryTips.get(i);
|
||||
@@ -171,9 +164,9 @@ public class BatteryTipPreferenceController extends BasePreferenceController {
|
||||
if (mBatteryTips == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return mBatteryTips.stream().anyMatch(BatteryTip::isVisible)
|
||||
? mBatteryTips.stream().filter(BatteryTip::isVisible).findFirst().get() : null;
|
||||
Optional<BatteryTip> visibleBatteryTip =
|
||||
mBatteryTips.stream().filter(BatteryTip::isVisible).findFirst();
|
||||
return visibleBatteryTip.orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user