diff --git a/lib/hiddifycore/core_interface/core_interface_mobile.dart b/lib/hiddifycore/core_interface/core_interface_mobile.dart index b38d65a6..91e02da6 100644 --- a/lib/hiddifycore/core_interface/core_interface_mobile.dart +++ b/lib/hiddifycore/core_interface/core_interface_mobile.dart @@ -114,24 +114,29 @@ class CoreInterfaceMobile extends CoreInterface with InfraLogger { }); _isBgClientAvailable = true; - for (var i = 0; i < 200; i++) { + loggy.info("Waiting for starting core"); + for (var i = 0; i < 20; i++) { try { - final res = await _status.get(timeout: const Duration(milliseconds: 100)); + final res = await _status.get(timeout: const Duration(seconds: 1)); switch (res) { case CoreStarted(): break; case CoreStopped(): - if (res.alert != null) return res; + if (res.alert != null) { + return res; + } case CoreStopping(): // return res; case CoreStarting(): } + await Future.delayed(const Duration(milliseconds: 200)); } on TimeoutException { // just retry } } + loggy.info("Waiting for starting core finished"); if (!await waitUntilPort(portBack, true, null, maxTry: 10)) { await stopMethodChannel(); diff --git a/lib/singbox/model/core_status.dart b/lib/singbox/model/core_status.dart index 837956a0..a5deec2e 100644 --- a/lib/singbox/model/core_status.dart +++ b/lib/singbox/model/core_status.dart @@ -19,8 +19,12 @@ sealed class CoreStatus with _$CoreStatus { switch (event?["status"]) { case "Stopped": final alertstr = event?["alert"] as String?; - final alert = CoreAlert.values.firstOrNullWhere((e) => alertstr?.toLowerCase() == e.name.toLowerCase()); - final msgStr = event?["message"] as String?; + var msgStr = event?["message"] as String?; + var alert = CoreAlert.values.firstOrNullWhere((e) => alertstr?.toLowerCase() == e.name.toLowerCase()); + if ((alert == null) && (alertstr ?? "") != "") { + msgStr = ((msgStr ?? "") != "") ? "$alertstr: $msgStr" : alertstr; + alert = CoreAlert.unknown; + } return CoreStatus.stopped(alert: alert, message: msgStr); case "Starting": @@ -100,4 +104,5 @@ enum CoreAlert { startService, alreadyStarted, startFailed, + unknown, }