diff options
author | cyberta <cyberta@riseup.net> | 2021-01-25 11:49:07 +0000 |
---|---|---|
committer | cyberta <cyberta@riseup.net> | 2021-01-25 11:49:07 +0000 |
commit | d2cfd37e8380f47cf450fff59867c87b6327a735 (patch) | |
tree | 93dee5b4dcd6fa85f9bf70c17920c21f46b6402c /app/src/main/java/de/blinkt/openvpn/VpnProfile.java | |
parent | 67f62a7d20dd079fb1f6392d6c953e2ee8ea29d3 (diff) | |
parent | bb6679c4c04e974ddb064b4cb5cee268b67b8ce1 (diff) |
Merge branch 'fix_always_on_reboot' into 'master'
Fix always on reboot
Closes #8994
See merge request leap/bitmask_android!119
Diffstat (limited to 'app/src/main/java/de/blinkt/openvpn/VpnProfile.java')
-rw-r--r-- | app/src/main/java/de/blinkt/openvpn/VpnProfile.java | 43 |
1 files changed, 8 insertions, 35 deletions
diff --git a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java index 41b5ddb5..f2da0838 100644 --- a/app/src/main/java/de/blinkt/openvpn/VpnProfile.java +++ b/app/src/main/java/de/blinkt/openvpn/VpnProfile.java @@ -15,12 +15,14 @@ import android.os.Build; import android.preference.PreferenceManager; import android.security.KeyChain; import android.security.KeyChainException; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; import android.text.TextUtils; import android.util.Base64; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import org.spongycastle.util.io.pem.PemObject; import org.spongycastle.util.io.pem.PemWriter; @@ -63,8 +65,7 @@ import de.blinkt.openvpn.core.VPNLaunchHelper; import de.blinkt.openvpn.core.VpnStatus; import de.blinkt.openvpn.core.X509Utils; import de.blinkt.openvpn.core.connection.Connection; -import de.blinkt.openvpn.core.connection.Obfs4Connection; -import de.blinkt.openvpn.core.connection.OpenvpnConnection; +import de.blinkt.openvpn.core.connection.ConnectionAdapter; import se.leap.bitmaskclient.BuildConfig; import se.leap.bitmaskclient.R; @@ -303,21 +304,6 @@ public class VpnProfile implements Serializable, Cloneable { @Deprecated public void upgradeProfile() { - if (mProfileVersion < 2) { - /* default to the behaviour the OS used */ - mAllowLocalLAN = Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT; - } - - if (mProfileVersion < 4) { - moveOptionsToConnection(); - mAllowedAppsVpnAreDisallowed = true; - } - if (mAllowedAppsVpn == null) - mAllowedAppsVpn = new HashSet<>(); - - if (mConnections == null) - mConnections = new Connection[0]; - if (mProfileVersion < 6) { if (TextUtils.isEmpty(mProfileCreator)) mUserEditable = true; @@ -332,20 +318,6 @@ public class VpnProfile implements Serializable, Cloneable { } - @Deprecated - private void moveOptionsToConnection() { - mConnections = new Connection[1]; - Connection conn = mUsePluggableTransports ? new Obfs4Connection() : new OpenvpnConnection(); - - conn.setServerName(mServerName); - conn.setServerPort(mServerPort); - conn.setUseUdp(mUseUdp); - conn.setCustomConfiguration(""); - - mConnections[0] = conn; - - } - public String getConfigFile(Context context, boolean configForOvpn3) { File cacheDir = context.getCacheDir(); @@ -1159,8 +1131,9 @@ public class VpnProfile implements Serializable, Cloneable { public static VpnProfile fromJson(String json) { try { - Gson gson = new Gson(); - return gson.fromJson(json, VpnProfile.class); + GsonBuilder builder = new GsonBuilder(); + builder.registerTypeAdapter(Connection.class, new ConnectionAdapter()); + return builder.create().fromJson(json, VpnProfile.class); } catch (Exception e) { e.printStackTrace(); } |