1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-28 02:37:16 +00:00

Added battery level to debug info

This commit is contained in:
M66B 2021-08-15 19:55:06 +02:00
parent fc8a553762
commit f6ab6ced81

View file

@ -42,6 +42,7 @@ import android.net.Network;
import android.net.NetworkCapabilities;
import android.net.NetworkInfo;
import android.os.BadParcelableException;
import android.os.BatteryManager;
import android.os.Build;
import android.os.Bundle;
import android.os.DeadObjectException;
@ -1760,7 +1761,9 @@ public class Log {
sb.append(String.format("Battery optimizations: %s\r\n",
ignoring == null ? null : Boolean.toString(!ignoring)));
sb.append(String.format("Charging: %b\r\n", Helper.isCharging(context)));
BatteryManager bm = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
int batlevel = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY);
sb.append(String.format("Charging: %b; level: %d\r\n", Helper.isCharging(context), batlevel));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
UsageStatsManager usm = (UsageStatsManager) context.getSystemService(Context.USAGE_STATS_SERVICE);