From 5ec6004a9fafca9c289d32faccd4b34298e0bd9d Mon Sep 17 00:00:00 2001 From: John Maguire Date: Tue, 8 Nov 2022 08:08:07 -0700 Subject: [PATCH] Fix crash on Android 9 and below (#81) --- .../kotlin/net/defined/mobile_nebula/NebulaVpnService.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt b/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt index da64c14..75d48d2 100644 --- a/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt +++ b/android/app/src/main/kotlin/net/defined/mobile_nebula/NebulaVpnService.kt @@ -92,10 +92,13 @@ class NebulaVpnService : VpnService() { .addRoute(ipNet.network, ipNet.maskSize.toInt()) .setMtu(site!!.mtu) .setSession(TAG) - .setMetered(false) .allowFamily(OsConstants.AF_INET) .allowFamily(OsConstants.AF_INET6); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + builder.setMetered(false); + } + // Add our unsafe routes site!!.unsafeRoutes.forEach { unsafeRoute -> val ipNet = mobileNebula.MobileNebula.parseCIDR(unsafeRoute.route)