optimized the way of testing adb port

This commit is contained in:
Gliese129
2023-08-29 20:35:16 +09:00
parent 9f0a732ff9
commit c7da8167bd
2 changed files with 10 additions and 8 deletions

View File

@@ -1140,8 +1140,10 @@ namespace MaaWpfGui.Main
return false;
}
string[] address_ = address.Split(':');
string host = address_[0];
// normal -> [host]:[port]
// LDPlayer -> emulator-[port]
string[] address_ = address.Contains(":") ? address.Split(':') : address.Split('-');
string host = address_[0].Equals("emulator") ? "127.0.0.1" : address_[0];
int port = int.Parse(address_[1]);
using (var client = new TcpClient())

View File

@@ -2543,6 +2543,12 @@ namespace MaaWpfGui.ViewModels.UI
/// <returns>path</returns>
public static string GetBluestacksConfig()
{
var conf = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigPath, string.Empty);
if (!string.IsNullOrEmpty(conf))
{
return conf;
}
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(BluestacksNxtRegistryKey))
{
if (key != null)
@@ -2555,12 +2561,6 @@ namespace MaaWpfGui.ViewModels.UI
}
}
var conf = ConfigurationHelper.GetValue(ConfigurationKeys.BluestacksConfigPath, string.Empty);
if (!string.IsNullOrEmpty(conf))
{
return conf;
}
return null;
}