From 8528dcc31f95c48264f6ca2ef1fb085be332e201 Mon Sep 17 00:00:00 2001 From: cyBerta Date: Mon, 25 Jan 2021 12:58:53 +0100 Subject: Android O+ devices: only launch VPN on boot if always-on is enabled. For pre Android O: evaluate last connection state in OnBootReceiver --- app/src/main/java/se/leap/bitmaskclient/base/OnBootReceiver.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/src/main/java/se/leap/bitmaskclient/base/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/base/OnBootReceiver.java index df1d3e5a..3b534a7d 100644 --- a/app/src/main/java/se/leap/bitmaskclient/base/OnBootReceiver.java +++ b/app/src/main/java/se/leap/bitmaskclient/base/OnBootReceiver.java @@ -4,6 +4,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.os.Build; import android.util.Log; import de.blinkt.openvpn.core.VpnStatus; @@ -27,7 +28,7 @@ public class OnBootReceiver extends BroadcastReceiver { } preferences = context.getSharedPreferences(SHARED_PREFERENCES, Context.MODE_PRIVATE); boolean providerConfigured = !preferences.getString(PROVIDER_VPN_CERTIFICATE, "").isEmpty(); - boolean startOnBoot = preferences.getBoolean(EIP_RESTART_ON_BOOT, false); + boolean startOnBoot = preferences.getBoolean(EIP_RESTART_ON_BOOT, false) && Build.VERSION.SDK_INT < Build.VERSION_CODES.O; boolean isAlwaysOnConfigured = VpnStatus.isAlwaysOn(); Log.d("OpenVPN", "OpenVPN onBoot intent received. Provider configured? " + providerConfigured + " Start on boot? " + startOnBoot + " isAlwaysOn feature configured: " + isAlwaysOnConfigured); if (providerConfigured) { -- cgit v1.2.3