diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java
index 896c9de94..6cf91a5f6 100644
--- a/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java
+++ b/src/frontends/android/app/src/main/java/org/strongswan/android/ui/VpnProfileControlActivity.java
@@ -23,6 +23,7 @@ import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.ServiceConnection;
+import android.content.SharedPreferences;
import android.net.Uri;
import android.net.VpnService;
import android.os.Build;
@@ -41,6 +42,7 @@ import org.strongswan.android.data.VpnProfileDataSource;
import org.strongswan.android.data.VpnType.VpnTypeFeature;
import org.strongswan.android.logic.VpnStateService;
import org.strongswan.android.logic.VpnStateService.State;
+import org.strongswan.android.utils.Constants;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AlertDialog;
@@ -49,6 +51,7 @@ import androidx.appcompat.app.AppCompatDialogFragment;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
+import androidx.preference.PreferenceManager;
public class VpnProfileControlActivity extends AppCompatActivity
{
@@ -198,7 +201,9 @@ public class VpnProfileControlActivity extends AppCompatActivity
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M)
{
PowerManager pm = (PowerManager)this.getSystemService(Context.POWER_SERVICE);
- if (!pm.isIgnoringBatteryOptimizations(this.getPackageName()))
+ SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
+ if (!pm.isIgnoringBatteryOptimizations(this.getPackageName()) &&
+ !pref.getBoolean(Constants.PREF_IGNORE_POWER_WHITELIST, false))
{
PowerWhitelistRequired whitelist = new PowerWhitelistRequired();
mWaitingForResult = true;
diff --git a/src/frontends/android/app/src/main/java/org/strongswan/android/utils/Constants.java b/src/frontends/android/app/src/main/java/org/strongswan/android/utils/Constants.java
index 52234933b..71b6e0fce 100644
--- a/src/frontends/android/app/src/main/java/org/strongswan/android/utils/Constants.java
+++ b/src/frontends/android/app/src/main/java/org/strongswan/android/utils/Constants.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2016-2018 Tobias Brunner
+ * Copyright (C) 2016-2020 Tobias Brunner
* HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
@@ -58,4 +58,9 @@ public final class Constants
* Preference key to store the most recently used VPN profile
*/
public static final String PREF_MRU_VPN_PROFILE = "pref_mru_vpn_profile";
+
+ /**
+ * Preference key to store whether the user permanently dismissed our warning to add the app to the power whitelist
+ */
+ public static final String PREF_IGNORE_POWER_WHITELIST = "pref_ignore_power_whitelist";
}
diff --git a/src/frontends/android/app/src/main/res/values-de/strings.xml b/src/frontends/android/app/src/main/res/values-de/strings.xml
index 76652bc63..aaef5a6b9 100644
--- a/src/frontends/android/app/src/main/res/values-de/strings.xml
+++ b/src/frontends/android/app/src/main/res/values-de/strings.xml
@@ -1,6 +1,6 @@
Log
diff --git a/src/frontends/android/app/src/main/res/values-pl/strings.xml b/src/frontends/android/app/src/main/res/values-pl/strings.xml
index 2e1df077e..16ae3fc7d 100644
--- a/src/frontends/android/app/src/main/res/values-pl/strings.xml
+++ b/src/frontends/android/app/src/main/res/values-pl/strings.xml
@@ -36,6 +36,8 @@
Settings
Default VPN profile
Connect to most recently used profile
+ Ignore battery optimizations
+ Don\'t show a warning if the app is not on the device\'s power whitelist
Log
diff --git a/src/frontends/android/app/src/main/res/values-ru/strings.xml b/src/frontends/android/app/src/main/res/values-ru/strings.xml
index 23fa95d38..426084f22 100644
--- a/src/frontends/android/app/src/main/res/values-ru/strings.xml
+++ b/src/frontends/android/app/src/main/res/values-ru/strings.xml
@@ -33,6 +33,8 @@
Settings
Default VPN profile
Connect to most recently used profile
+ Ignore battery optimizations
+ Don\'t show a warning if the app is not on the device\'s power whitelist
Журнал
diff --git a/src/frontends/android/app/src/main/res/values-ua/strings.xml b/src/frontends/android/app/src/main/res/values-ua/strings.xml
index b4937364e..7f414e524 100644
--- a/src/frontends/android/app/src/main/res/values-ua/strings.xml
+++ b/src/frontends/android/app/src/main/res/values-ua/strings.xml
@@ -34,6 +34,8 @@
Settings
Default VPN profile
Connect to most recently used profile
+ Ignore battery optimizations
+ Don\'t show a warning if the app is not on the device\'s power whitelist
Журнал
diff --git a/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml b/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
index c1dbefb66..75a3bef33 100644
--- a/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
+++ b/src/frontends/android/app/src/main/res/values-zh-rCN/strings.xml
@@ -33,6 +33,8 @@
Settings
Default VPN profile
Connect to most recently used profile
+ Ignore battery optimizations
+ Don\'t show a warning if the app is not on the device\'s power whitelist
日志
diff --git a/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml b/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
index 13e75a43b..28e4e5ae1 100644
--- a/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
+++ b/src/frontends/android/app/src/main/res/values-zh-rTW/strings.xml
@@ -33,6 +33,8 @@
Settings
Default VPN profile
Connect to most recently used profile
+ Ignore battery optimizations
+ Don\'t show a warning if the app is not on the device\'s power whitelist
日誌
diff --git a/src/frontends/android/app/src/main/res/values/strings.xml b/src/frontends/android/app/src/main/res/values/strings.xml
index fb74d3f83..b72aad9c6 100644
--- a/src/frontends/android/app/src/main/res/values/strings.xml
+++ b/src/frontends/android/app/src/main/res/values/strings.xml
@@ -36,6 +36,8 @@
Settings
Default VPN profile
Connect to most recently used profile
+ Ignore battery optimizations
+ Don\'t show a warning if the app is not on the device\'s power whitelist
Log
diff --git a/src/frontends/android/app/src/main/res/xml/settings.xml b/src/frontends/android/app/src/main/res/xml/settings.xml
index 908a888d5..3eb7343e1 100644
--- a/src/frontends/android/app/src/main/res/xml/settings.xml
+++ b/src/frontends/android/app/src/main/res/xml/settings.xml
@@ -1,6 +1,6 @@