Search in sources :

Example 1 with BatteryTipLoader

use of com.android.settings.fuelgauge.batterytip.BatteryTipLoader in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class BatteryFixSlice method refreshBatteryTips.

@WorkerThread
private static List<BatteryTip> refreshBatteryTips(Context context) {
    final BatteryStatsHelperLoader statsLoader = new BatteryStatsHelperLoader(context);
    final BatteryStatsHelper statsHelper = statsLoader.loadInBackground();
    final BatteryTipLoader loader = new BatteryTipLoader(context, statsHelper);
    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) BatteryStatsHelperLoader(com.android.settings.fuelgauge.BatteryStatsHelperLoader) BatteryStatsHelper(com.android.internal.os.BatteryStatsHelper) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip) WorkerThread(androidx.annotation.WorkerThread)

Example 2 with BatteryTipLoader

use of com.android.settings.fuelgauge.batterytip.BatteryTipLoader 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

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