feat: 调整蓝叠hyperv端口号识别逻辑

This commit is contained in:
MistEO
2023-05-18 00:10:01 +08:00
parent 96789fba84
commit 3808fd5e22
2 changed files with 15 additions and 10 deletions

View File

@@ -1125,7 +1125,6 @@ namespace MaaWpfGui.Main
return false;
}
bool hyperV = Instances.SettingsViewModel.TryToSetBlueStacksHyperVAddress();
if (!Instances.SettingsViewModel.AutoDetectConnection
&& connected
&& connectedAdb == Instances.SettingsViewModel.AdbPath
@@ -1134,10 +1133,17 @@ namespace MaaWpfGui.Main
return true;
}
if (!hyperV && Instances.SettingsViewModel.AutoDetectConnection &&
!Instances.SettingsViewModel.DetectAdbConfig(ref error))
if (Instances.SettingsViewModel.AutoDetectConnection)
{
return false;
string bsHvAddress = Instances.SettingsViewModel.TryToSetBlueStacksHyperVAddress();
if (bsHvAddress != null)
{
Instances.SettingsViewModel.ConnectAddress = bsHvAddress;
}
else if (!Instances.SettingsViewModel.DetectAdbConfig(ref error))
{
return false;
}
}
bool ret = AsstConnect(_handle, Instances.SettingsViewModel.AdbPath, Instances.SettingsViewModel.ConnectAddress, Instances.SettingsViewModel.ConnectConfig);

View File

@@ -2251,17 +2251,17 @@ namespace MaaWpfGui.ViewModels.UI
/// Tries to set Bluestack Hyper V address.
/// </summary>
/// <returns>success</returns>
public bool TryToSetBlueStacksHyperVAddress()
public string TryToSetBlueStacksHyperVAddress()
{
if (string.IsNullOrEmpty(_bluestacksConfig))
{
return false;
return null;
}
if (!File.Exists(_bluestacksConfig))
{
ConfigurationHelper.SetValue(ConfigurationKeys.BluestacksConfigError, "File not exists");
return false;
return null;
}
var all_lines = File.ReadAllLines(_bluestacksConfig);
@@ -2284,12 +2284,11 @@ namespace MaaWpfGui.ViewModels.UI
if (line.StartsWith(_bluestacksKeyWord))
{
var sp = line.Split('"');
ConnectAddress = "127.0.0.1:" + sp[1];
break;
return "127.0.0.1:" + sp[1];
}
}
return true;
return null;
}
public bool IsAdbTouchMode()