From 7f67372c8de7c396d6938f1efc68ea0788ff91b0 Mon Sep 17 00:00:00 2001 From: MistEO Date: Mon, 20 Dec 2021 22:28:53 +0800 Subject: [PATCH] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8DADB=E5=AD=90=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E4=B8=8D=E9=87=8A=E6=94=BE=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?:=20https://github.com/MistEO/MeoAssistantArknights/issues/53?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- resource/config.json | 21 ++++++++++++------- src/MeoAssistant/AsstDef.h | 1 + src/MeoAssistant/Controller.cpp | 11 +++++++++- src/MeoAssistant/GeneralConfiger.cpp | 1 + .../ViewModels/VersionUpdateViewModel.cs | 4 ++++ 5 files changed, 30 insertions(+), 8 deletions(-) diff --git a/resource/config.json b/resource/config.json index 93a1df5696..75870982be 100644 --- a/resource/config.json +++ b/resource/config.json @@ -38,7 +38,8 @@ "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 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p" + "screencap": "[Adb] -s [Address] exec-out screencap -p", + "release": "[Adb] kill-server" } }, "BlueStacksInternational": { @@ -56,7 +57,8 @@ "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 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p" + "screencap": "[Adb] -s [Address] exec-out screencap -p", + "release": "[Adb] kill-server" } }, "MuMuEmulator": { @@ -74,7 +76,8 @@ "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 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p" + "screencap": "[Adb] -s [Address] exec-out screencap -p", + "release": "[Adb] kill-server" } }, "LDPlayer": { @@ -92,7 +95,8 @@ "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 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] shell screencap -p" + "screencap": "[Adb] -s [Address] shell screencap -p", + "release": "[Adb] kill-server" } }, "Nox": { @@ -110,7 +114,8 @@ "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 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p" + "screencap": "[Adb] -s [Address] exec-out screencap -p", + "release": "[Adb] kill-server" } }, "XYAZ": { @@ -128,7 +133,8 @@ "swipe": "[Adb] -s [Address] shell input swipe [x1] [y1] [x2] [y2] [duration]", "display": "[Adb] -s [Address] shell dumpsys window displays | grep init=", "displayFormat": " init=%dx%d", - "screencap": "[Adb] -s [Address] shell screencap -p" + "screencap": "[Adb] -s [Address] shell screencap -p", + "release": "[Adb] kill-server" } }, "Custom": { @@ -148,7 +154,8 @@ "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 } '", "displayFormat": "cur=%dx%d", - "screencap": "[Adb] -s [Address] exec-out screencap -p" + "screencap": "[Adb] -s [Address] exec-out screencap -p", + "release": "[Adb] kill-server" } } } diff --git a/src/MeoAssistant/AsstDef.h b/src/MeoAssistant/AsstDef.h index 49befdbd55..48d91ef472 100644 --- a/src/MeoAssistant/AsstDef.h +++ b/src/MeoAssistant/AsstDef.h @@ -242,6 +242,7 @@ namespace asst std::string display; std::string display_format; std::string screencap; + std::string release; //std::string pullscreen; int display_width = 0; int display_height = 0; diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index ed932639e5..8cf89ffd02 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -98,6 +98,7 @@ bool asst::Controller::connect_adb(const std::string& address) m_emulator_info.adb.click = utils::string_replace_all(utils::string_replace_all(m_emulator_info.adb.click, "[Adb]", m_adb_path), "[Address]", address); m_emulator_info.adb.swipe = utils::string_replace_all(utils::string_replace_all(m_emulator_info.adb.swipe, "[Adb]", m_adb_path), "[Address]", address); m_emulator_info.adb.screencap = utils::string_replace_all(utils::string_replace_all(m_emulator_info.adb.screencap, "[Adb]", m_adb_path), "[Address]", address); + m_emulator_info.adb.release = utils::string_replace_all(m_emulator_info.adb.release, "[Adb]", m_adb_path); return true; } @@ -115,6 +116,10 @@ asst::Controller::~Controller() m_cmd_thread.join(); } + if (!m_emulator_info.adb.release.empty()) { + call_command(m_emulator_info.adb.release); + } + ::CloseHandle(m_pipe_read); ::CloseHandle(m_pipe_write); ::CloseHandle(m_pipe_child_read); @@ -220,10 +225,14 @@ bool asst::Controller::try_capture(const EmulatorInfo& info, bool without_handle { LogTraceScope("try_capture | " + info.name); + if (!m_emulator_info.adb.release.empty()) { + call_command(m_emulator_info.adb.release); + } + const HandleInfo& handle_info = info.handle; if (!without_handle) { // 使用模拟器自带的adb -// 转成宽字符的 + // 转成宽字符的 wchar_t* class_wbuff = nullptr; if (!handle_info.class_name.empty()) { size_t class_len = (handle_info.class_name.size() + 1) * 2; diff --git a/src/MeoAssistant/GeneralConfiger.cpp b/src/MeoAssistant/GeneralConfiger.cpp index a39dda4cce..36fa9fb09c 100644 --- a/src/MeoAssistant/GeneralConfiger.cpp +++ b/src/MeoAssistant/GeneralConfiger.cpp @@ -52,6 +52,7 @@ bool asst::GeneralConfiger::parse(const json::value& json) emulator_info.adb.display = adb_json.at("display").as_string(); emulator_info.adb.display_format = adb_json.at("displayFormat").as_string(); emulator_info.adb.screencap = adb_json.at("screencap").as_string(); + emulator_info.adb.release = adb_json.at("release").as_string(); //emulator_info.adb.pullscreen = adb_json.at("pullscreen").as_string(); m_emulators_info.emplace(name, std::move(emulator_info)); diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index 7f03d5429c..3aeff6d8ae 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -374,6 +374,10 @@ namespace MeoAsstGui string cur_sha = ViewStatusStorage.Get(filename, string.Empty); string response = RequestApi(req_base_url + url); + if (response == String.Empty) + { + continue; + } string cloud_sha; string cur_message = ""; try