use of com.android.settings.fuelgauge.batterytip.tips.BatteryTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryTipLoader method loadInBackground.
@Override
public List<BatteryTip> loadInBackground() {
if (USE_FAKE_DATA) {
return getFakeData();
}
final List<BatteryTip> tips = new ArrayList<>();
final BatteryTipPolicy policy = new BatteryTipPolicy(getContext());
final BatteryInfo batteryInfo = mBatteryUtils.getBatteryInfo(mBatteryStatsHelper, TAG);
final Context context = getContext();
tips.add(new LowBatteryDetector(context, policy, batteryInfo).detect());
tips.add(new HighUsageDetector(context, policy, mBatteryStatsHelper, batteryInfo.discharging).detect());
tips.add(new SmartBatteryDetector(policy, context.getContentResolver()).detect());
tips.add(new EarlyWarningDetector(policy, context).detect());
tips.add(new SummaryDetector(policy, batteryInfo.averageTimeToDischarge).detect());
tips.add(new RestrictAppDetector(context, policy).detect());
Collections.sort(tips);
return tips;
}
use of com.android.settings.fuelgauge.batterytip.tips.BatteryTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryTipLoader method getFakeData.
private List<BatteryTip> getFakeData() {
final List<BatteryTip> tips = new ArrayList<>();
tips.add(new SummaryTip(BatteryTip.StateType.NEW, EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW, false, /* powerSaveModeOn */
"Fake data"));
return tips;
}
use of com.android.settings.fuelgauge.batterytip.tips.BatteryTip in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryTipPreferenceController method updateBatteryTips.
public void updateBatteryTips(List<BatteryTip> batteryTips) {
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));
}
}
for (int i = 0, size = batteryTips.size(); i < size; i++) {
final BatteryTip batteryTip = mBatteryTips.get(i);
batteryTip.sanityCheck(mContext);
if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
batteryTip.updatePreference(mCardPreference);
mBatteryTipMap.put(mCardPreference.getKey(), batteryTip);
batteryTip.log(mContext, mMetricsFeatureProvider);
mNeedUpdate = batteryTip.needUpdate();
break;
}
}
}
use of com.android.settings.fuelgauge.batterytip.tips.BatteryTip in project android_packages_apps_Settings by omnirom.
the class BatteryFixSlice method refreshBatteryTips.
@WorkerThread
@VisibleForTesting
static List<BatteryTip> refreshBatteryTips(Context context) {
final BatteryUsageStatsLoader statsLoader = new BatteryUsageStatsLoader(context, /* includeBatteryHistory */
false);
final BatteryUsageStats batteryUsageStats = statsLoader.loadInBackground();
final BatteryTipLoader loader = new BatteryTipLoader(context, batteryUsageStats);
final List<BatteryTip> batteryTips = loader.loadInBackground();
for (BatteryTip batteryTip : batteryTips) {
if (batteryTip.getState() != BatteryTip.StateType.INVISIBLE) {
context.getSharedPreferences(PREFS, MODE_PRIVATE).edit().putInt(KEY_CURRENT_TIPS_TYPE, batteryTip.getType()).putInt(KEY_CURRENT_TIPS_STATE, batteryTip.getState()).apply();
break;
}
}
return batteryTips;
}
use of com.android.settings.fuelgauge.batterytip.tips.BatteryTip in project android_packages_apps_Settings by omnirom.
the class BatteryTipLoader method getFakeData.
private List<BatteryTip> getFakeData() {
final List<BatteryTip> tips = new ArrayList<>();
tips.add(new SummaryTip(BatteryTip.StateType.NEW, EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN));
tips.add(new LowBatteryTip(BatteryTip.StateType.NEW, false));
return tips;
}
Aggregations