mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-07 09:33:39 +02:00
Log battery level
This commit is contained in:
@@ -424,6 +424,16 @@ public class Helper {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Integer getBatteryLevel(Context context) {
|
||||
try {
|
||||
BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
|
||||
return bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
|
||||
} catch (Throwable ex) {
|
||||
Log.e(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
static boolean isCharging(Context context) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user