Search in sources :

Example 21 with BatteryStatsHelper

use of com.android.internal.os.BatteryStatsHelper in project android_packages_apps_Settings by SudaMod.

the class AnomalyLoader method loadInBackground.

@Override
public List<Anomaly> loadInBackground() {
    if (USE_FAKE_DATA) {
        return generateFakeData();
    }
    if (mBatteryStatsHelper == null) {
        mBatteryStatsHelper = new BatteryStatsHelper(getContext());
        mBatteryStatsHelper.create((Bundle) null);
        mBatteryStatsHelper.refreshStats(BatteryStats.STATS_SINCE_CHARGED, mUserManager.getUserProfiles());
    }
    return mAnomalyUtils.detectAnomalies(mBatteryStatsHelper, mPolicy, mPackageName);
}
Also used : BatteryStatsHelper(com.android.internal.os.BatteryStatsHelper)

Example 22 with BatteryStatsHelper

use of com.android.internal.os.BatteryStatsHelper in project android_packages_apps_Settings by DirtyUnicorns.

the class BatteryInfo method getBatteryInfo.

public static void getBatteryInfo(final Context context, final Callback callback, boolean shortString) {
    final long startTime = System.currentTimeMillis();
    BatteryStatsHelper statsHelper = new BatteryStatsHelper(context, true);
    statsHelper.create((Bundle) null);
    BatteryUtils.logRuntime(LOG_TAG, "time to make batteryStatsHelper", startTime);
    BatteryInfo.getBatteryInfo(context, callback, statsHelper, shortString);
}
Also used : BatteryStatsHelper(com.android.internal.os.BatteryStatsHelper)

Example 23 with BatteryStatsHelper

use of com.android.internal.os.BatteryStatsHelper in project platform_packages_apps_Settings by BlissRoms.

the class BatteryStatsHelperLoader method loadInBackground.

@Override
public BatteryStatsHelper loadInBackground() {
    Context context = getContext();
    final BatteryStatsHelper statsHelper = new BatteryStatsHelper(context, true);
    mBatteryUtils.initBatteryStatsHelper(statsHelper, null, /* bundle */
    mUserManager);
    return statsHelper;
}
Also used : Context(android.content.Context) BatteryStatsHelper(com.android.internal.os.BatteryStatsHelper)

Example 24 with BatteryStatsHelper

use of com.android.internal.os.BatteryStatsHelper in project android_packages_apps_Settings by SudaMod.

the class BatteryStatsHelperLoader method loadInBackground.

@Override
public BatteryStatsHelper loadInBackground() {
    Context context = getContext();
    final BatteryStatsHelper statsHelper = new BatteryStatsHelper(context, true);
    mBatteryUtils.initBatteryStatsHelper(statsHelper, null, /* bundle */
    mUserManager);
    return statsHelper;
}
Also used : Context(android.content.Context) BatteryStatsHelper(com.android.internal.os.BatteryStatsHelper)

Example 25 with BatteryStatsHelper

use of com.android.internal.os.BatteryStatsHelper in project android_packages_apps_Settings by SudaMod.

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)

Aggregations

BatteryStatsHelper (com.android.internal.os.BatteryStatsHelper)45 ArrayMap (android.util.ArrayMap)10 BatterySipper (com.android.internal.os.BatterySipper)10 HashMap (java.util.HashMap)10 Map (java.util.Map)10 Context (android.content.Context)7 ArrayList (java.util.ArrayList)5 Comparator (java.util.Comparator)5 Intent (android.content.Intent)3 IntentFilter (android.content.IntentFilter)3 BatteryStats (android.os.BatteryStats)3 WorkerThread (androidx.annotation.WorkerThread)3 BatteryStatsHelperLoader (com.android.settings.fuelgauge.BatteryStatsHelperLoader)3 BatteryTipLoader (com.android.settings.fuelgauge.batterytip.BatteryTipLoader)3 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)3 Estimate (com.android.settingslib.fuelgauge.Estimate)3 INetworkStatsService (android.net.INetworkStatsService)2 RemoteException (android.os.RemoteException)2 VisibleForTesting (androidx.annotation.VisibleForTesting)1 SettingsActivity (com.android.settings.SettingsActivity)1