From c296d6f4466e2616432660bb01465f3746e1bb65 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 11 Jan 2016 11:17:45 +0100 Subject: ask to be excluded from battery optimization --- src/main/java/eu/siacs/conversations/ui/XmppActivity.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/main/java/eu/siacs/conversations/ui/XmppActivity.java') diff --git a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java index a23f51ebd..36e82b2a7 100644 --- a/src/main/java/eu/siacs/conversations/ui/XmppActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/XmppActivity.java @@ -35,6 +35,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; +import android.os.PowerManager; import android.os.SystemClock; import android.preference.PreferenceManager; import android.text.InputType; @@ -91,6 +92,7 @@ public abstract class XmppActivity extends Activity { protected static final int REQUEST_ANNOUNCE_PGP = 0x0101; protected static final int REQUEST_INVITE_TO_CONVERSATION = 0x0102; protected static final int REQUEST_CHOOSE_PGP_ID = 0x0103; + protected static final int REQUEST_BATTERY_OP = 0x13849ff; public XmppConnectionService xmppConnectionService; public boolean xmppConnectionServiceBound = false; @@ -372,6 +374,15 @@ public abstract class XmppActivity extends Activity { } } + protected boolean showBatteryOptimizationWarning() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); + return !pm.isIgnoringBatteryOptimizations(getPackageName()); + } else { + return false; + } + } + protected boolean usingEnterKey() { return getPreferences().getBoolean("display_enter_key", false); } -- cgit v1.2.3