]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
android: Don't default to marking VPN connections as metered
authorTobias Brunner <tobias@strongswan.org>
Tue, 1 Dec 2020 14:54:35 +0000 (15:54 +0100)
committerTobias Brunner <tobias@strongswan.org>
Tue, 1 Dec 2020 15:00:09 +0000 (16:00 +0100)
For apps targeting Android 10, where a method to change this was added, the
default changed so that all VPN connections are marked as metered.  This means
certain background operations (e.g. syncing data) are not performed anymore
even when connected to a WiFi.  By setting this to false, the metered state
of the VPN connection reflects that of the underlying networks.

src/frontends/android/app/src/main/java/org/strongswan/android/logic/CharonVpnService.java

index da6ea637412efdae740fd9b397f2a95bc227db11..5a37955d3fc0303ee077b17a4bea4279e3325b83 100644 (file)
@@ -822,6 +822,12 @@ public class CharonVpnService extends VpnService implements Runnable, VpnStateSe
                        PendingIntent pending = PendingIntent.getActivity(context, 0, intent,
                                                                                                                          PendingIntent.FLAG_UPDATE_CURRENT);
                        builder.setConfigureIntent(pending);
+
+                       /* mark all VPN connections as unmetered (default changed for Android 10) */
+                       if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q)
+                       {
+                               builder.setMetered(false);
+                       }
                        return builder;
                }