use of com.android.internal.os.BatteryStatsHelper in project platform_packages_apps_Settings by BlissRoms.
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);
}
use of com.android.internal.os.BatteryStatsHelper in project platform_packages_apps_Settings by BlissRoms.
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);
}
use of com.android.internal.os.BatteryStatsHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.
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;
}
use of com.android.internal.os.BatteryStatsHelper in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryInfo method getBatteryInfo.
public static BatteryInfo getBatteryInfo(final Context context, final BatteryStatsHelper statsHelper, boolean shortString) {
final BatteryStats stats;
final long batteryStatsTime = System.currentTimeMillis();
if (statsHelper == null) {
final BatteryStatsHelper localStatsHelper = new BatteryStatsHelper(context, true);
localStatsHelper.create((Bundle) null);
stats = localStatsHelper.getStats();
} else {
stats = statsHelper.getStats();
}
BatteryUtils.logRuntime(LOG_TAG, "time for getStats", batteryStatsTime);
final long startTime = System.currentTimeMillis();
PowerUsageFeatureProvider provider = FeatureFactory.getFactory(context).getPowerUsageFeatureProvider(context);
final long elapsedRealtimeUs = PowerUtil.convertMsToUs(SystemClock.elapsedRealtime());
final Intent batteryBroadcast = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
// 0 means we are discharging, anything else means charging
final boolean discharging = batteryBroadcast.getIntExtra(BatteryManager.EXTRA_PLUGGED, -1) == 0;
if (discharging && provider != null && provider.isEnhancedBatteryPredictionEnabled(context)) {
Estimate estimate = provider.getEnhancedBatteryPrediction(context);
if (estimate != null) {
Estimate.storeCachedEstimate(context, estimate);
BatteryUtils.logRuntime(LOG_TAG, "time for enhanced BatteryInfo", startTime);
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats, estimate, elapsedRealtimeUs, shortString);
}
}
final long prediction = discharging ? stats.computeBatteryTimeRemaining(elapsedRealtimeUs) : 0;
final Estimate estimate = new Estimate(PowerUtil.convertUsToMs(prediction), false, /* isBasedOnUsage */
EstimateKt.AVERAGE_TIME_TO_DISCHARGE_UNKNOWN);
BatteryUtils.logRuntime(LOG_TAG, "time for regular BatteryInfo", startTime);
return BatteryInfo.getBatteryInfo(context, batteryBroadcast, stats, estimate, elapsedRealtimeUs, shortString);
}
use of com.android.internal.os.BatteryStatsHelper in project android_packages_apps_Settings by omnirom.
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);
}
Aggregations