Search in sources :

Example 1 with BatteryUsageStatsLoader

use of com.android.settings.fuelgauge.BatteryUsageStatsLoader 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;
}
Also used : BatteryTipLoader(com.android.settings.fuelgauge.batterytip.BatteryTipLoader) BatteryUsageStats(android.os.BatteryUsageStats) BatteryUsageStatsLoader(com.android.settings.fuelgauge.BatteryUsageStatsLoader) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) VisibleForTesting(androidx.annotation.VisibleForTesting) WorkerThread(androidx.annotation.WorkerThread)

Aggregations

BatteryUsageStats (android.os.BatteryUsageStats)1 VisibleForTesting (androidx.annotation.VisibleForTesting)1 WorkerThread (androidx.annotation.WorkerThread)1 BatteryUsageStatsLoader (com.android.settings.fuelgauge.BatteryUsageStatsLoader)1 BatteryTipLoader (com.android.settings.fuelgauge.batterytip.BatteryTipLoader)1 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)1