Fix flashback caused by process
This commit is contained in:
@@ -15,6 +15,7 @@ enum class RunState {
|
||||
class GlobalState {
|
||||
companion object {
|
||||
val runState: MutableLiveData<RunState> = MutableLiveData<RunState>(RunState.STOP)
|
||||
var runTime: Date? = null
|
||||
var flutterEngine: FlutterEngine? = null
|
||||
fun getCurrentTilePlugin(): TilePlugin? =
|
||||
flutterEngine?.plugins?.get(TilePlugin::class.java) as TilePlugin?
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.flutter.embedding.engine.plugins.activity.ActivityAware
|
||||
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
|
||||
import io.flutter.plugin.common.MethodCall
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
import java.util.Date
|
||||
|
||||
|
||||
class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAware {
|
||||
@@ -93,6 +94,10 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
}
|
||||
}
|
||||
|
||||
"GetRunTimeStamp" -> {
|
||||
result.success(GlobalState.runTime?.time)
|
||||
}
|
||||
|
||||
"startForeground" -> {
|
||||
title = call.argument<String>("title") as String
|
||||
content = call.argument<String>("content") as String
|
||||
@@ -118,6 +123,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
if (GlobalState.runState.value == RunState.START) return;
|
||||
flClashVpnService?.start(port, props)
|
||||
GlobalState.runState.value = RunState.START
|
||||
GlobalState.runTime = Date()
|
||||
startAfter()
|
||||
}
|
||||
|
||||
@@ -126,6 +132,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
|
||||
flClashVpnService?.stop()
|
||||
unbindService()
|
||||
GlobalState.runState.value = RunState.STOP;
|
||||
GlobalState.runTime = null;
|
||||
}
|
||||
|
||||
@SuppressLint("ForegroundServiceType")
|
||||
|
||||
Reference in New Issue
Block a user