diff options
author | Arne Schwabe <arne@rfc2549.org> | 2018-07-23 13:10:58 +0200 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2018-07-23 13:23:40 +0200 |
commit | a733aad2ec8ed8cdb8b6d9d584c172488eacfa8f (patch) | |
tree | 9cce7040f0accbb4d3e562d7dfcc80bc54f86ad5 /main/src | |
parent | 367e7e4fd1246f8e15fd5e036e49ef971f44a8de (diff) |
Move app restriction initialisation to Application class
Diffstat (limited to 'main/src')
4 files changed, 22 insertions, 7 deletions
diff --git a/main/src/main/java/de/blinkt/openvpn/activities/BaseActivity.java b/main/src/main/java/de/blinkt/openvpn/activities/BaseActivity.java index 08f2787b..7258d8d6 100644 --- a/main/src/main/java/de/blinkt/openvpn/activities/BaseActivity.java +++ b/main/src/main/java/de/blinkt/openvpn/activities/BaseActivity.java @@ -34,10 +34,10 @@ public class BaseActivity extends Activity { @Override protected void onResume() { super.onResume(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - AppRestrictions.getInstance(this).checkRestrictions(this); - - } } + @Override + protected void onPause() { + super.onPause(); + } } diff --git a/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java b/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java index 311b600d..1b2fc1b3 100644 --- a/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java +++ b/main/src/main/java/de/blinkt/openvpn/api/AppRestrictions.java @@ -12,6 +12,7 @@ import android.os.Bundle; import android.os.Parcelable; import de.blinkt.openvpn.VpnProfile; import de.blinkt.openvpn.core.ConfigParser; +import de.blinkt.openvpn.core.Connection; import de.blinkt.openvpn.core.ProfileManager; import de.blinkt.openvpn.core.VpnStatus; @@ -30,6 +31,7 @@ public class AppRestrictions { static boolean alreadyChecked = false; private static AppRestrictions mInstance; private RestrictionsManager mRestrictionsMgr; + private BroadcastReceiver mRestrictionsReceiver; private AppRestrictions(Context c) { @@ -44,13 +46,17 @@ public class AppRestrictions { private void addChangesListener(Context c) { IntentFilter restrictionsFilter = new IntentFilter(Intent.ACTION_APPLICATION_RESTRICTIONS_CHANGED); - BroadcastReceiver restrictionsReceiver = new BroadcastReceiver() { + mRestrictionsReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { applyRestrictions(context); } }; - c.registerReceiver(restrictionsReceiver, restrictionsFilter); + c.registerReceiver(mRestrictionsReceiver, restrictionsFilter); + } + + private void removeChangesListener(Context c) { + c.unregisterReceiver(mRestrictionsReceiver); } private String hashConfig(String config) { @@ -179,4 +185,9 @@ public class AppRestrictions { addChangesListener(c); applyRestrictions(c); } + + public void pauseCheckRestrictions(Context c) + { + removeChangesListener(c); + } } diff --git a/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java b/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java index 3261d32b..181cca5f 100644 --- a/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java +++ b/main/src/main/java/de/blinkt/openvpn/core/ICSOpenVPNApplication.java @@ -22,6 +22,7 @@ import org.acra.annotation.ReportsCrashes; import android.os.StrictMode; import de.blinkt.openvpn.BuildConfig; import de.blinkt.openvpn.R; +import de.blinkt.openvpn.api.AppRestrictions; public class ICSOpenVPNApplication extends Application { private StatusListener mStatus; @@ -42,6 +43,9 @@ public class ICSOpenVPNApplication extends Application { if (BuildConfig.BUILD_TYPE.equals("debug")) enableStrictModes(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + AppRestrictions.getInstance(this).checkRestrictions(this); + } } private void enableStrictModes() { diff --git a/main/src/main/res/values/untranslatable.xml b/main/src/main/res/values/untranslatable.xml index d7113fa4..e71d79ab 100644 --- a/main/src/main/res/values/untranslatable.xml +++ b/main/src/main/res/values/untranslatable.xml @@ -64,7 +64,7 @@ 0E910C15–9A85-4DD9-AE0D-E6862392E638). Generate using uuidgen or similar tools </string> <string name="apprest_uuid">UUID</string> - <string name="apprest_ovpn_desc">Content of the OpenVPN configuration file</string> + <string name="apprest_ovpn_desc">Content of the OpenVPN configuration file. These files are usually have the extension .ovpn (sometimes also .conf) and are plain text multi line configuration files. If your MDM does not support multiline configuration entries, you can also use a base64 encoded string here. A text file can be converted to base64 using openssl base64 -A -in</string> <string name="apprest_ovpn">Config</string> <string name="apprest_name_desc">Name of the VPN profile</string> <string name="apprest_name">Name</string> |