Skip to content

Commit

Permalink
Merge pull request #39 from mysteriumnetwork/300-wait-for-tunnel-perm…
Browse files Browse the repository at this point in the history
…issions

android/ios Wait for tunnel permissions
  • Loading branch information
tadaskay authored Feb 12, 2024
2 parents 127e03c + 6197026 commit ee9dca0
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions darwin/Classes/WireguardDartPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public class WireguardDartPlugin: NSObject, FlutterPlugin {
mgr.isEnabled = true

try await mgr.saveToPreferences()
try await mgr.loadFromPreferences()

return mgr
}
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down

0 comments on commit ee9dca0

Please sign in to comment.