Log battery level

This commit is contained in:
M66B 2020-11-04 15:15:08 +01:00
parent 6f60234833
commit b89a3e9935
2 changed files with 12 additions and 1 deletions

View File

@ -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;

View File

@ -1479,7 +1479,8 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
new Exception(state.getUnrecoverable()));
// Sends store NOOP
EntityLog.log(this, account.name + " checking store");
EntityLog.log(this, account.name + " checking store" +
" battery=" + Helper.getBatteryLevel(this));
if (!iservice.getStore().isConnected())
throw new StoreClosedException(iservice.getStore(), "NOOP");