From 788b2a07eb3f73dc56d64b3418c0f2159dc5aea4 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 13 Oct 2018 07:15:47 +0000 Subject: [PATCH] Added debug info --- .../java/eu/faircode/email/FragmentAbout.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/FragmentAbout.java b/app/src/main/java/eu/faircode/email/FragmentAbout.java index 04a36a73..bc31bd88 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAbout.java +++ b/app/src/main/java/eu/faircode/email/FragmentAbout.java @@ -19,10 +19,13 @@ package eu.faircode.email; Copyright 2018 by Marcel Bokhorst (M66B) */ +import android.app.usage.UsageStatsManager; import android.content.Context; import android.content.Intent; +import android.net.ConnectivityManager; import android.os.Build; import android.os.Bundle; +import android.os.PowerManager; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -106,6 +109,24 @@ public class FragmentAbout extends FragmentEx { sb.append(String.format("Id: %s\r\n", Build.ID)); sb.append("\r\n"); + PowerManager pm = getContext().getSystemService(PowerManager.class); + boolean ignoring = pm.isIgnoringBatteryOptimizations(BuildConfig.APPLICATION_ID); + sb.append(String.format("Battery optimizations: %b\r\n", !ignoring)); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { + UsageStatsManager usm = getContext().getSystemService(UsageStatsManager.class); + int bucket = usm.getAppStandbyBucket(); + sb.append(String.format("Standby bucket: %d\r\n", bucket)); + } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + ConnectivityManager cm = getContext().getSystemService(ConnectivityManager.class); + boolean saving = (cm.getRestrictBackgroundStatus() == ConnectivityManager.RESTRICT_BACKGROUND_STATUS_ENABLED); + sb.append(String.format("Data saving: %b\r\n", saving)); + } + + sb.append("\r\n"); + String body = "
" + sb.toString().replaceAll("\\r?\\n", "
") + "
"; EntityMessage draft;