mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-19 18:47:55 +08:00
feat: 新增在ADB重连失败断开连接时重启模拟器重试的选项
feat: 重连失败尝试启动模拟器重连前先关闭当前模拟器 fix: 修改开关默认为关闭,优化日志 fix: 优化文案
This commit is contained in:
@@ -376,7 +376,7 @@ std::optional<std::vector<uchar>> asst::Controller::call_command(const std::stri
|
||||
{ "cmd", cmd },
|
||||
} },
|
||||
};
|
||||
constexpr static int ReconnectTimes = 20;
|
||||
constexpr static int ReconnectTimes = 5;
|
||||
for (int i = 0; i < ReconnectTimes; ++i) {
|
||||
if (need_exit()) {
|
||||
break;
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace MeoAsstGui
|
||||
break;
|
||||
|
||||
case "Reconnecting":
|
||||
mainModel.AddLog(Localization.GetString("TryToReconnect"), LogColor.Error);
|
||||
mainModel.AddLog($"{Localization.GetString("TryToReconnect")}({Convert.ToUInt32(details["details"]["times"]) + 1})", LogColor.Error);
|
||||
break;
|
||||
|
||||
case "Reconnected":
|
||||
@@ -336,6 +336,20 @@ namespace MeoAsstGui
|
||||
connected = false;
|
||||
mainModel.AddLog(Localization.GetString("ReconnectFailed"), LogColor.Error);
|
||||
AsstStop();
|
||||
|
||||
var settingsModel = _container.Get<SettingsViewModel>();
|
||||
Execute.OnUIThread(async () =>
|
||||
{
|
||||
if (settingsModel.RetryOnDisconnected)
|
||||
{
|
||||
mainModel.AddLog(Localization.GetString("TryToStartEmulator"), LogColor.Error);
|
||||
mainModel.killEmulator();
|
||||
await Task.Delay(3000);
|
||||
mainModel.Stop();
|
||||
mainModel.LinkStart();
|
||||
}
|
||||
});
|
||||
|
||||
break;
|
||||
|
||||
case "ScreencapFailed":
|
||||
|
||||
@@ -150,6 +150,7 @@
|
||||
<system:String x:Key="ConnectionAddress">连接地址</system:String>
|
||||
<system:String x:Key="ConnectionAddressTip">第一次使用会自动填写,若遇到问题可尝试手动修改</system:String>
|
||||
<system:String x:Key="ConnectionPreset">连接配置</system:String>
|
||||
<system:String x:Key="RetryOnDisconnected">ADB重连失败时尝试重启模拟器后再次重连(后台使用定时任务挂机且设置任务完成自动关闭模拟器必须勾选该项)</system:String>
|
||||
<!-- 设置 -->
|
||||
|
||||
<!-- 一键长草 -->
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
@@ -91,5 +92,15 @@
|
||||
ItemsSource="{Binding ConnectConfigList}"
|
||||
SelectedValue="{Binding ConnectConfig}"
|
||||
SelectedValuePath="Value" />
|
||||
|
||||
<CheckBox
|
||||
Grid.Row="4"
|
||||
Grid.ColumnSpan="4"
|
||||
Margin="10,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
IsChecked="{Binding RetryOnDisconnected}"
|
||||
HorizontalAlignment="Left">
|
||||
<TextBlock TextWrapping="Wrap" Text="{DynamicResource RetryOnDisconnected}" />
|
||||
</CheckBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -1428,6 +1428,21 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
private bool _retryOnDisconnected = Convert.ToBoolean(ViewStatusStorage.Get("Connect.RetryOnDisconnected", bool.FalseString));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether to retry task after adb disconnected.
|
||||
/// </summary>
|
||||
public bool RetryOnDisconnected
|
||||
{
|
||||
get => _retryOnDisconnected;
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _retryOnDisconnected, value);
|
||||
ViewStatusStorage.Set("Connect.RetryOnDisconnected", value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, List<string>> _defaultAddress = new Dictionary<string, List<string>>
|
||||
{
|
||||
{ "General", new List<string> { string.Empty } },
|
||||
|
||||
Reference in New Issue
Block a user