summaryrefslogtreecommitdiff
path: root/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2020-12-29 00:54:08 +0100
committercyBerta <cyberta@riseup.net>2020-12-29 00:54:08 +0100
commit6b032b751324a30120cfaabe88940f95171df11f (patch)
treeb6b26b84358726a02e27558562e7e9ea70a7aaa0 /app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
parent16da1eeb5180cbb4a0d916785a08ccbcd3c1d74e (diff)
new year cleanup: restructure messy project
Diffstat (limited to 'app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java56
1 files changed, 0 insertions, 56 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java b/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
deleted file mode 100644
index 2efce9e4..00000000
--- a/app/src/main/java/se/leap/bitmaskclient/OnBootReceiver.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package se.leap.bitmaskclient;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-import android.content.SharedPreferences;
-import android.util.Log;
-
-import de.blinkt.openvpn.core.VpnStatus;
-import se.leap.bitmaskclient.utils.PreferenceHelper;
-
-import static android.content.Intent.ACTION_BOOT_COMPLETED;
-import static se.leap.bitmaskclient.Constants.APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE;
-import static se.leap.bitmaskclient.Constants.EIP_IS_ALWAYS_ON;
-import static se.leap.bitmaskclient.Constants.EIP_RESTART_ON_BOOT;
-import static se.leap.bitmaskclient.Constants.PROVIDER_VPN_CERTIFICATE;
-import static se.leap.bitmaskclient.Constants.SHARED_PREFERENCES;
-
-public class OnBootReceiver extends BroadcastReceiver {
-
- SharedPreferences preferences;
-
- // Debug: am broadcast -a android.intent.action.BOOT_COMPLETED
- @Override
- public void onReceive(Context context, Intent intent) {
- //Lint complains if we're not checking the intent action
- if (intent == null || !ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
- return;
- }
- 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 isAlwaysOnConfigured = VpnStatus.isAlwaysOn();
- Log.d("OpenVPN", "OpenVPN onBoot intent received. Provider configured? " + providerConfigured + " Start on boot? " + startOnBoot + " isAlwaysOn feature configured: " + isAlwaysOnConfigured);
- if (providerConfigured) {
- if (isAlwaysOnConfigured) {
- //exit because the app is already setting up the vpn
- return;
- }
- if (startOnBoot) {
- Log.d("OpenVpn", "start StartActivity!");
- Intent startActivityIntent = new Intent(context.getApplicationContext(), StartActivity.class);
- startActivityIntent.putExtra(EIP_RESTART_ON_BOOT, true);
- startActivityIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(startActivityIntent);
- }
- } else {
- if (isAlwaysOnConfigured) {
- Intent dashboardIntent = new Intent(context.getApplicationContext(), StartActivity.class);
- dashboardIntent.putExtra(APP_ACTION_CONFIGURE_ALWAYS_ON_PROFILE, true);
- dashboardIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- context.startActivity(dashboardIntent);
- }
- }
- }
-}