From 29b6591d0f84079037131857fe8941c296aa8ec7 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Fri, 9 Feb 2024 15:50:13 +0200 Subject: [PATCH 1/4] Fix android build --- android/build.gradle | 2 +- example/android/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 55a28fb..f59e96a 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -10,7 +10,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:7.1.3' + classpath 'com.android.tools.build:gradle:8.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/example/android/build.gradle b/example/android/build.gradle index c123f6b..5994dbe 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -6,7 +6,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.2.1' + classpath 'com.android.tools.build:gradle:8.2.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } From cdcf5993b8c198f9ea3a9d71381a1b2ce4cda2e9 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Mon, 12 Feb 2024 10:03:01 +0200 Subject: [PATCH 2/4] android: Fix permission status listener not working --- .../wireguard_dart/WireguardDartPlugin.kt | 43 +++++++++++-------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/android/src/main/kotlin/network/mysterium/wireguard_dart/WireguardDartPlugin.kt b/android/src/main/kotlin/network/mysterium/wireguard_dart/WireguardDartPlugin.kt index 7fa9b9a..67c158a 100644 --- a/android/src/main/kotlin/network/mysterium/wireguard_dart/WireguardDartPlugin.kt +++ b/android/src/main/kotlin/network/mysterium/wireguard_dart/WireguardDartPlugin.kt @@ -1,27 +1,30 @@ package network.mysterium.wireguard_dart -import io.flutter.embedding.engine.plugins.FlutterPlugin -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result -import io.flutter.embedding.engine.plugins.activity.ActivityAware -import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding -import io.flutter.plugin.common.PluginRegistry - import android.app.Activity -import io.flutter.embedding.android.FlutterActivity -import android.content.Intent import android.content.Context +import android.content.Intent import android.util.Log import com.beust.klaxon.Klaxon -import com.wireguard.android.backend.* +import com.wireguard.android.backend.Backend +import com.wireguard.android.backend.BackendException +import com.wireguard.android.backend.GoBackend +import com.wireguard.android.backend.Tunnel import com.wireguard.crypto.KeyPair +import io.flutter.embedding.android.FlutterActivity +import io.flutter.embedding.engine.plugins.FlutterPlugin +import io.flutter.embedding.engine.plugins.activity.ActivityAware +import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding import io.flutter.plugin.common.EventChannel -import kotlinx.coroutines.* - - +import io.flutter.plugin.common.MethodCall +import io.flutter.plugin.common.MethodChannel +import io.flutter.plugin.common.MethodChannel.MethodCallHandler +import io.flutter.plugin.common.MethodChannel.Result +import io.flutter.plugin.common.PluginRegistry +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.Job import kotlinx.coroutines.launch import java.io.ByteArrayInputStream @@ -54,13 +57,15 @@ class WireguardDartPlugin : FlutterPlugin, MethodCallHandler, ActivityAware, } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?): Boolean { - havePermission = - (requestCode == PERMISSIONS_REQUEST_CODE) && (resultCode == Activity.RESULT_OK) + if (requestCode == PERMISSIONS_REQUEST_CODE) { + havePermission = resultCode == Activity.RESULT_OK + } return havePermission } - override fun onAttachedToActivity(activityPluginBinding: ActivityPluginBinding) { - this.activity = activityPluginBinding.activity as FlutterActivity + override fun onAttachedToActivity(binding: ActivityPluginBinding) { + this.activity = binding.activity as FlutterActivity + binding.addActivityResultListener(this) } override fun onDetachedFromActivityForConfigChanges() { From e0dda5998c35fd0ec190de12c0c37e38f21987f2 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Mon, 12 Feb 2024 10:11:50 +0200 Subject: [PATCH 3/4] darwin: Fix first connect always failing https://forums.developer.apple.com/forums/thread/25928 --- darwin/Classes/WireguardDartPlugin.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/darwin/Classes/WireguardDartPlugin.swift b/darwin/Classes/WireguardDartPlugin.swift index ce43f34..906e205 100644 --- a/darwin/Classes/WireguardDartPlugin.swift +++ b/darwin/Classes/WireguardDartPlugin.swift @@ -140,6 +140,7 @@ public class WireguardDartPlugin: NSObject, FlutterPlugin { mgr.isEnabled = true try await mgr.saveToPreferences() + try await mgr.loadFromPreferences() return mgr } From 6197026d52644946d71c7b05d27f56b23ddb6892 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Mon, 12 Feb 2024 10:16:11 +0200 Subject: [PATCH 4/4] 0.6.1 changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8582cd3..d2259f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## [0.6.1](https://github.com/mysteriumnetwork/wireguard_dart/tree/0.6.0) (2024-02-12) + +- android/darwin: Fix first connect failing + +[Full Changelog](https://github.com/mysteriumnetwork/wireguard_dart/compare/0.6.0...0.6.1) + ## [0.6.0](https://github.com/mysteriumnetwork/wireguard_dart/tree/0.6.0) (2024-02-05) - android: Update API to match darwin implementation