Skip to content

Commit

Permalink
Use latest native libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
ctrysbita committed Aug 23, 2020
1 parent 72c6c17 commit 8b434c5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.9.0
- Upgrade to StrongSwan 5.9.0.
- Add `prepared` for checking vpn preparation on android.

## 0.8.0
- Fix crash on launch caused by abiFilters. (#45)

Expand Down
8 changes: 4 additions & 4 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ group 'io.xdea.flutter_vpn'
version '1.0-SNAPSHOT'

buildscript {
ext.kotlin_version = '1.3.61'
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
classpath 'com.android.tools.build:gradle:4.0.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// For downloading prebuilt libs
classpath 'de.undercouch:gradle-download-task:3.4.3'
classpath 'de.undercouch:gradle-download-task:4.0.2'
}
}

apply plugin: 'de.undercouch.download'

// Download prebuilt native libs.
task downloadNaticeLib(type: Download) {
src 'https://github.com/X-dea/Flutter_VPN/releases/download/v0.6.0/strongswan_libs_v5.8.1.zip'
src 'https://github.com/X-dea/Flutter_VPN/releases/download/v0.9.0/strongswan_libs_v5.9.0.zip'
dest "$buildDir/native.zip"
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ class FlutterVpnPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {

override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) {
when (call.method) {
"hasPrepared" -> {
val intent = VpnService.prepare(activityBinding.activity.applicationContext)
result.success(intent == null)
}
"prepare" -> {
val intent = VpnService.prepare(activityBinding.activity.applicationContext)
if (intent != null) {
Expand All @@ -124,6 +120,10 @@ class FlutterVpnPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
result.success(true)
}
}
"prepared" -> {
val intent = VpnService.prepare(activityBinding.activity.applicationContext)
result.success(intent == null)
}
"connect" -> {
val intent = VpnService.prepare(activityBinding.activity.applicationContext)
if (intent != null) {
Expand Down
8 changes: 4 additions & 4 deletions lib/flutter_vpn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ class FlutterVpn {
/// Do nothing in iOS.
static Future<bool> prepare() async {
if (!Platform.isAndroid) return true;
return await _channel.invokeMethod('prepare');
return await _channel.invokeMethod<bool>('prepare');
}

static Future<bool> hasPrepared() async {
/// Check if vpn connection has been prepared. (Android only)
static Future<bool> get prepared async {
if (!Platform.isAndroid) return true;
final response = await _channel.invokeMethod('hasPrepared');
return response;
return await _channel.invokeMethod<bool>('prepared');
}

/// Disconnect and stop VPN service.
Expand Down

0 comments on commit 8b434c5

Please sign in to comment.