Compare commits

..

3 Commits

Author SHA1 Message Date
chen08209
891977408e Fix android vpn issues
Some checks failed
build / build (macos-13, macos) (push) Has been cancelled
build / build (ubuntu-latest, android) (push) Has been cancelled
build / build (ubuntu-latest, linux) (push) Has been cancelled
build / build (windows-latest, windows) (push) Has been cancelled
build / upload-release (push) Has been cancelled
2024-07-15 16:19:58 +08:00
chen08209
5292f34e8d Fix android vpn issues 2024-07-15 16:18:51 +08:00
chen08209
1c54db6bf3 Rollback partial modification 2024-07-15 16:14:19 +08:00
5 changed files with 22 additions and 19 deletions

View File

@@ -44,7 +44,7 @@ object GlobalState {
fun initServiceEngine(context: Context) {
if (serviceEngine != null) return
lock.withLock {
if (serviceEngine != null) return
destroyServiceEngine()
serviceEngine = FlutterEngine(context)
serviceEngine?.plugins?.add(ProxyPlugin())
serviceEngine?.plugins?.add(AppPlugin())

View File

@@ -174,16 +174,19 @@ class FlClashVpnService : VpnService() {
inner class LocalBinder : Binder() {
fun getService(): FlClashVpnService = this@FlClashVpnService
override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean {
CoroutineScope(Dispatchers.Main).launch {
GlobalState.getCurrentTitlePlugin()?.handleStop()
}
try {
return super.onTransact(code, data, reply, flags)
} catch (e: RemoteException) {
throw e
}
}
// override fun onTransact(code: Int, data: Parcel, reply: Parcel?, flags: Int): Boolean {
// try {
// val isSuccess = super.onTransact(code, data, reply, flags)
// if (!isSuccess) {
// CoroutineScope(Dispatchers.Main).launch {
// GlobalState.getCurrentTitlePlugin()?.handleStop()
// }
// }
// return isSuccess
// } catch (e: RemoteException) {
// throw e
// }
// }
}
@@ -192,7 +195,6 @@ class FlClashVpnService : VpnService() {
}
override fun onUnbind(intent: Intent?): Boolean {
GlobalState.getCurrentTitlePlugin()?.handleStop()
return super.onUnbind(intent)
}

View File

@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';
import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/plugins/app.dart';
@@ -67,7 +66,6 @@ Future<void> vpnService() async {
clashCore.setFdMap(fd.id);
},
onProcess: (Process process) async {
print(process);
var packageName = await app?.resolverProcess(process);
clashCore.setProcessMap(
ProcessMapItem(
@@ -112,14 +110,13 @@ Future<void> vpnService() async {
onStop: () async {
await app?.tip(appLocalizations.stopVpn);
await globalState.stopSystemProxy();
exit(0);
},
),
);
globalState.updateTraffic();
globalState.updateFunctionLists = [
() {
() {
globalState.updateTraffic();
}
];
@@ -137,7 +134,8 @@ class ServiceMessageHandler with ServiceMessageListener {
required Function(Process process) onProcess,
required Function(String runTime) onStarted,
required Function(String groupName) onLoaded,
}) : _onProtect = onProtect,
})
: _onProtect = onProtect,
_onProcess = onProcess,
_onStarted = onStarted,
_onLoaded = onLoaded;
@@ -163,10 +161,11 @@ class ServiceMessageHandler with ServiceMessageListener {
}
}
@immutable
class TileListenerWithVpn with TileListener {
final Function() _onStop;
TileListenerWithVpn({
const TileListenerWithVpn({
required Function() onStop,
}) : _onStop = onStop;

View File

@@ -8,6 +8,7 @@ import 'package:fl_clash/common/common.dart';
import 'package:fl_clash/enum/enum.dart';
import 'package:fl_clash/models/models.dart';
import 'package:fl_clash/state.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:proxy/proxy_platform_interface.dart';
@@ -80,6 +81,7 @@ class Proxy extends ProxyPlatform {
bool get isStart => startTime != null && startTime!.isBeforeNow;
onStarted(int? fd) {
debugPrint("onStarted ==> $fd");
if (fd == null) return;
if (receiver != null) {
receiver!.close();

View File

@@ -1,7 +1,7 @@
name: fl_clash
description: A multi-platform proxy client based on ClashMeta, simple and easy to use, open-source and ad-free.
publish_to: 'none'
version: 0.8.39+202407151
version: 0.8.40+202407152
environment:
sdk: '>=3.1.0 <4.0.0'