mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
fix.新增一个备选连接地址的逻辑,修复雷电等模拟器直接连不上的问题
https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/712 https://github.com/MaaAssistantArknights/MaaAssistantArknights/issues/688
This commit is contained in:
@@ -13,8 +13,7 @@
|
||||
"adbExtraSwipeDuration": 1000,
|
||||
"adbExtraSwipeDuration_Doc": "额外的滑动持续时间:adb有bug,同样的参数,偶尔会划得非常远。额外做一个短程滑动,把之前的停下来。若小于0,则关闭额外滑动功能",
|
||||
"penguinReport": {
|
||||
"Doc": "企鹅数据汇报:每次到结算界面,汇报掉落数据至企鹅数据 https://penguin-stats.cn/。true-开启,false-关闭,默认true",
|
||||
"enable": true,
|
||||
"Doc": "企鹅数据汇报: https://penguin-stats.cn/",
|
||||
"cmdFormat": "curl -H \"Content-Type: application/json\" -s -i -d \"[body]\" \"https://penguin-stats.cn/PenguinStats/api/v2/report\" [extra]",
|
||||
"cmdFormat_Doc": "命令格式,想打印详细信息可以尝试添加 -v -i"
|
||||
}
|
||||
@@ -24,7 +23,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"click": "[Adb] -s [Address] shell input tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell dumpsys window displays | grep init=",
|
||||
@@ -37,7 +36,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"click": "[Adb] -s [Address] shell input tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '",
|
||||
@@ -50,7 +49,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"click": "[Adb] -s [Address] shell input tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '",
|
||||
@@ -63,7 +62,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"click": "[Adb] -s [Address] shell input tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '",
|
||||
@@ -76,7 +75,7 @@
|
||||
"devices": "[Adb] devices",
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"click": "[Adb] -s [Address] shell input tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell dumpsys window displays | grep init= | awk ' { print $3 } '",
|
||||
@@ -103,7 +102,7 @@
|
||||
"addressRegex": "(.+)\tdevice",
|
||||
"connect": "[Adb] connect [Address]",
|
||||
"displayId": "[Adb] -s [Address] shell dumpsys display | grep mUniqueId=virtual:com.microsoft.windows.systemapp:com.hypergryph.arknights",
|
||||
"uuid": "[Adb] -s [Address] shell \"settings get secure android_id | awk 'NR == 1 {p = $0} NR > 1 {print p; p = $0} END{printf p}' \"",
|
||||
"uuid": "[Adb] -s [Address] shell settings get secure android_id",
|
||||
"click": "[Adb] -s [Address] shell input -d [DisplayId] tap [x] [y]",
|
||||
"swipe": "[Adb] -s [Address] shell input -d [DisplayId] swipe [x1] [y1] [x2] [y2] [duration]",
|
||||
"display": "[Adb] -s [Address] shell \"wm size -d [DisplayId]\"",
|
||||
|
||||
@@ -619,9 +619,19 @@ namespace MeoAsstGui
|
||||
settings.TryToSetBlueStacksHyperVAddress();
|
||||
|
||||
bool ret = AsstConnect(_handle, settings.AdbPath, settings.ConnectAddress, settings.ConnectConfig);
|
||||
|
||||
// 尝试默认的备选端口
|
||||
if (!ret)
|
||||
{
|
||||
error = "连接失败\n请检查连接设置\n";
|
||||
foreach (var address in settings.DefaultAddress[settings.ConnectConfig])
|
||||
{
|
||||
ret = AsstConnect(_handle, settings.AdbPath, address, settings.ConnectConfig);
|
||||
if (ret)
|
||||
{
|
||||
settings.ConnectAddress = address;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -132,8 +132,6 @@ namespace MeoAsstGui
|
||||
new CombData { Display = "刷源石锭投资,第一层商店后直接退出", Value = "1" },
|
||||
new CombData { Display = "刷源石锭投资,投资过后退出", Value = "2" }
|
||||
};
|
||||
|
||||
ConnectAddressList = new ObservableCollection<string>();
|
||||
}
|
||||
|
||||
private bool _idle = true;
|
||||
@@ -154,7 +152,6 @@ namespace MeoAsstGui
|
||||
public List<CombData> UsesOfDronesList { get; set; }
|
||||
public List<CombData> RoguelikeModeList { get; set; }
|
||||
public List<CombData> ConnectConfigList { get; set; }
|
||||
public ObservableCollection<string> ConnectAddressList { get; set; }
|
||||
|
||||
private int _dormThreshold = Convert.ToInt32(ViewStatusStorage.Get("Infrast.DormThreshold", "30"));
|
||||
|
||||
@@ -922,39 +919,6 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
public void QueryAdbDevices()
|
||||
{
|
||||
ConnectAddressList.Clear();
|
||||
var adbProcess = new Process
|
||||
{
|
||||
StartInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = AdbPath,
|
||||
Arguments = "devices",
|
||||
UseShellExecute = false,
|
||||
RedirectStandardOutput = true,
|
||||
RedirectStandardError = true,
|
||||
CreateNoWindow = true,
|
||||
},
|
||||
EnableRaisingEvents = true
|
||||
};
|
||||
|
||||
adbProcess.Start();
|
||||
adbProcess.WaitForExit();
|
||||
string output = adbProcess.StandardOutput.ReadToEnd();
|
||||
adbProcess.Close();
|
||||
var addressList = new List<string>(output.Split('\n'));
|
||||
addressList.RemoveAt(0);
|
||||
foreach (var address in addressList)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(address))
|
||||
continue;
|
||||
|
||||
var device = address.Split('\t')[0];
|
||||
ConnectAddressList.Add(device);
|
||||
}
|
||||
}
|
||||
|
||||
private string _connectConfig = ViewStatusStorage.Get("Connect.ConnectConfig", "General");
|
||||
|
||||
public string ConnectConfig
|
||||
@@ -967,15 +931,15 @@ namespace MeoAsstGui
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Dictionary<string, string> DefaultAddress = new Dictionary<string, string>
|
||||
public readonly Dictionary<string, List<string>> DefaultAddress = new Dictionary<string, List<string>>
|
||||
{
|
||||
{ "General", "" },
|
||||
{ "BlueStacks", "127.0.0.1:5555" },
|
||||
{ "MuMuEmulator", "127.0.0.1:7555" },
|
||||
{ "LDPlayer", "emulator-5554" },
|
||||
{ "Nox", "127.0.0.1:62001" },
|
||||
{ "XYAZ", "127.0.0.1:21503" },
|
||||
{ "WSA","127.0.0.1:58526" },
|
||||
{ "General", new List<string>{ "" } },
|
||||
{ "BlueStacks", new List<string>{ "127.0.0.1:5555", "127.0.0.1:5556", "127.0.0.1:5557", "127.0.0.1:5554" } },
|
||||
{ "MuMuEmulator", new List<string>{ "127.0.0.1:7555", "127.0.0.1:7556" } },
|
||||
{ "LDPlayer", new List<string>{ "emulator-5554", "127.0.0.1:5555", "127.0.0.1:5556", "127.0.0.1:5554" } },
|
||||
{ "Nox", new List<string>{ "127.0.0.1:62001", "127.0.0.1:59865" } },
|
||||
{ "XYAZ", new List<string>{ "127.0.0.1:21503" } },
|
||||
{ "WSA", new List<string>{ "127.0.0.1:58526" } },
|
||||
};
|
||||
|
||||
public bool RefreshAdbConfig(ref string error)
|
||||
@@ -1006,7 +970,7 @@ namespace MeoAsstGui
|
||||
if (ConnectAddress.Length == 0)
|
||||
{
|
||||
var addresses = adapter.GetAdbAddresses(AdbPath);
|
||||
// 傻逼雷电已经关掉了用别的 adb 还能检测出来这个端口 device
|
||||
// 傻逼雷电已经关掉了,用别的 adb 还能检测出来这个端口 device
|
||||
if (addresses.Count == 1 && addresses.First() != "emulator-5554")
|
||||
{
|
||||
ConnectAddress = addresses.First();
|
||||
@@ -1026,7 +990,7 @@ namespace MeoAsstGui
|
||||
|
||||
if (ConnectAddress.Length == 0)
|
||||
{
|
||||
ConnectAddress = DefaultAddress[ConnectConfig];
|
||||
ConnectAddress = DefaultAddress[ConnectConfig][0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user