Skip to content

Commit

Permalink
Fix flashback caused by process
Browse files Browse the repository at this point in the history
  • Loading branch information
chen08209 committed Jun 17, 2024
1 parent d6c22d4 commit 4ba2f72
Show file tree
Hide file tree
Showing 19 changed files with 316 additions and 459 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand All @@ -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()
}

Expand All @@ -126,6 +132,7 @@ class ProxyPlugin : FlutterPlugin, MethodChannel.MethodCallHandler, ActivityAwar
flClashVpnService?.stop()
unbindService()
GlobalState.runState.value = RunState.STOP;
GlobalState.runTime = null;
}

@SuppressLint("ForegroundServiceType")
Expand Down
10 changes: 4 additions & 6 deletions core/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ type Delay struct {
}

type Process struct {
Id int64 `json:"id"`
Metadata constant.Metadata `json:"metadata"`
Id int64 `json:"id"`
Metadata *constant.Metadata `json:"metadata"`
}

type ProcessMapItem struct {
Id int64 `json:"id"`
Value *string `json:"value"`
Id int64 `json:"id"`
Value string `json:"value"`
}

type Now struct {
Expand Down Expand Up @@ -396,8 +396,6 @@ func applyConfig(isPatch bool) {
if isPatch {
patchConfig(cfg.General)
} else {
runtime.GC()
executor.Shutdown()
hub.UltraApplyConfig(cfg, true)
}
}
16 changes: 12 additions & 4 deletions core/dart-bridge/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,26 @@ const (
Now MessageType = "now"
Process MessageType = "process"
Request MessageType = "request"
Run MessageType = "run"
)

type Message struct {
Type MessageType `json:"type"`
Data interface{} `json:"data"`
}

func (message *Message) Json() string {
data, _ := json.Marshal(message)
return string(data)
func (message *Message) Json() (string, error) {
data, err := json.Marshal(message)
return string(data), err
}

func SendMessage(message Message) {
SendToPort(*Port, message.Json())
if Port == nil {
return
}
s, err := message.Json()
if err != nil {
return
}
SendToPort(*Port, s)
}
42 changes: 0 additions & 42 deletions core/platform/limit.go

This file was deleted.

171 changes: 0 additions & 171 deletions core/platform/procfs.go

This file was deleted.

Loading

0 comments on commit 4ba2f72

Please sign in to comment.