use of android.os.BatteryManager in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DarkThemeSlice method isAvailable.
@VisibleForTesting
boolean isAvailable(Context context) {
// checking dark theme mode.
if (isDarkThemeMode(context)) {
return false;
}
// checking the current battery level
final BatteryManager batteryManager = context.getSystemService(BatteryManager.class);
final int level = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
Log.d(TAG, "battery level=" + level);
return level <= BATTERY_LEVEL_THRESHOLD;
}
use of android.os.BatteryManager in project android_packages_apps_Settings by omnirom.
the class DarkThemeSlice method isAvailable.
@VisibleForTesting
boolean isAvailable(Context context) {
// check if dark theme mode is enabled or if dark theme scheduling is on.
if (Utils.isNightMode(context) || isNightModeScheduled()) {
return false;
}
// checking the current battery level
final BatteryManager batteryManager = context.getSystemService(BatteryManager.class);
final int level = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
Log.d(TAG, "battery level = " + level);
return level <= BATTERY_LEVEL_THRESHOLD;
}
use of android.os.BatteryManager in project Taskbar by farmerbb.
the class TaskbarController method getBatteryDrawable.
@TargetApi(Build.VERSION_CODES.M)
private Drawable getBatteryDrawable() {
BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
int batLevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
if (batLevel == Integer.MIN_VALUE)
return null;
IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent batteryStatus = context.registerReceiver(null, ifilter);
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
boolean isCharging = status == BatteryManager.BATTERY_STATUS_CHARGING || status == BatteryManager.BATTERY_STATUS_FULL;
String batDrawable;
if (batLevel < 10 && !isCharging)
batDrawable = "alert";
else if (batLevel < 25)
batDrawable = "20";
else if (batLevel < 40)
batDrawable = "30";
else if (batLevel < 55)
batDrawable = "50";
else if (batLevel < 70)
batDrawable = "60";
else if (batLevel < 85)
batDrawable = "80";
else if (batLevel < 95)
batDrawable = "90";
else
batDrawable = "full";
String charging;
if (isCharging)
charging = "charging_";
else
charging = "";
String batRes = "tb_battery_" + charging + batDrawable;
int id = getResourceIdFor(batRes);
return getDrawableForSysTray(id);
}
Aggregations