Skip to content

Commit

Permalink
Rollback partial modification
Browse files Browse the repository at this point in the history
  • Loading branch information
chen08209 committed Jul 15, 2024
1 parent a4b5f4a commit 1c54db6
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
// }
// }
}


Expand Down
11 changes: 5 additions & 6 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:io';

import 'package:fl_clash/clash/clash.dart';
import 'package:fl_clash/plugins/app.dart';
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();
}
];
Expand All @@ -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;
Expand All @@ -163,10 +161,11 @@ class ServiceMessageHandler with ServiceMessageListener {
}
}

@immutable
class TileListenerWithVpn with TileListener {
final Function() _onStop;

TileListenerWithVpn({
const TileListenerWithVpn({
required Function() onStop,
}) : _onStop = onStop;

Expand Down
2 changes: 2 additions & 0 deletions lib/plugins/proxy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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'

Expand Down

0 comments on commit 1c54db6

Please sign in to comment.