From f6acf370753c4e9ddb2e6a49751047cd46c632e8 Mon Sep 17 00:00:00 2001 From: MistEO Date: Tue, 28 Nov 2023 14:20:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=88=A0=E9=99=A4toolkit=E4=B8=AD?= =?UTF-8?q?=E9=A2=84=E7=BD=AE=E7=9A=84adb=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/MaaToolKit/AdbDevice/AdbConfigDef.hpp | 14 -------------- source/MaaToolKit/AdbDevice/DeviceMgrMacOS.cpp | 10 +++++----- source/MaaToolKit/AdbDevice/DeviceMgrWin32.cpp | 10 +++++----- 3 files changed, 10 insertions(+), 24 deletions(-) delete mode 100644 source/MaaToolKit/AdbDevice/AdbConfigDef.hpp diff --git a/source/MaaToolKit/AdbDevice/AdbConfigDef.hpp b/source/MaaToolKit/AdbDevice/AdbConfigDef.hpp deleted file mode 100644 index b4fbde345..000000000 --- a/source/MaaToolKit/AdbDevice/AdbConfigDef.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#include "Conf/Conf.h" - -#include - -#include - -MAA_TOOLKIT_DEVICE_NS_BEGIN - -using namespace json::literals; -inline static const json::value kAdbConfig = "{}"_json; - -MAA_TOOLKIT_DEVICE_NS_END diff --git a/source/MaaToolKit/AdbDevice/DeviceMgrMacOS.cpp b/source/MaaToolKit/AdbDevice/DeviceMgrMacOS.cpp index 695084366..f0aaaeb10 100644 --- a/source/MaaToolKit/AdbDevice/DeviceMgrMacOS.cpp +++ b/source/MaaToolKit/AdbDevice/DeviceMgrMacOS.cpp @@ -39,12 +39,12 @@ std::vector DeviceMgrMacOS::find_device_impl() const auto& constant = kEmulators.at(e.name); std::filesystem::path adb_path = get_adb_path(constant, e.process.pid); - auto serials = request_adb_serials(adb_path, kAdbConfig); + auto serials = request_adb_serials(adb_path, json::value()); serials.insert(serials.end(), constant.adb_common_serials.begin(), constant.adb_common_serials.end()); // Deduplication auto set = std::set(serials.begin(), serials.end()); serials.assign(set.begin(), set.end()); - serials = check_available_adb_serials(adb_path, serials, kAdbConfig); + serials = check_available_adb_serials(adb_path, serials, json::value()); for (const std::string& ser : serials) { Device device; @@ -52,7 +52,7 @@ std::vector DeviceMgrMacOS::find_device_impl() device.adb_path = path_to_utf8_string(adb_path); device.adb_serial = ser; // TODO: 根据设备情况使用不同的配置 - device.adb_config = kAdbConfig.to_string(); + device.adb_config = json::value().to_string(); device.adb_controller_type = check_adb_controller_type(device.adb_path, device.adb_serial, device.adb_config); result.emplace_back(std::move(device)); @@ -66,14 +66,14 @@ std::vector DeviceMgrMacOS::find_device_with_adb_impl(std::string_view a { std::vector result; - auto serials = request_adb_serials(path(adb_path), kAdbConfig); + auto serials = request_adb_serials(path(adb_path), json::value()); for (const std::string& ser : serials) { Device device; device.name = adb_path; device.adb_path = adb_path; device.adb_serial = ser; - device.adb_config = kAdbConfig.to_string(); + device.adb_config = json::value().to_string(); device.adb_controller_type = check_adb_controller_type(device.adb_path, device.adb_serial, device.adb_config); result.emplace_back(std::move(device)); } diff --git a/source/MaaToolKit/AdbDevice/DeviceMgrWin32.cpp b/source/MaaToolKit/AdbDevice/DeviceMgrWin32.cpp index ba16b1676..b9de636cc 100644 --- a/source/MaaToolKit/AdbDevice/DeviceMgrWin32.cpp +++ b/source/MaaToolKit/AdbDevice/DeviceMgrWin32.cpp @@ -68,12 +68,12 @@ std::vector DeviceMgrWin32::find_device_impl() const auto& constant = kEmulators.at(e.name); std::filesystem::path adb_path = get_adb_path(constant, e.process.pid); - auto serials = request_adb_serials(adb_path, kAdbConfig); + auto serials = request_adb_serials(adb_path, json::value()); serials.insert(serials.end(), constant.adb_common_serials.begin(), constant.adb_common_serials.end()); // Deduplication auto set = std::set(serials.begin(), serials.end()); serials.assign(set.begin(), set.end()); - serials = check_available_adb_serials(adb_path, serials, kAdbConfig); + serials = check_available_adb_serials(adb_path, serials, json::value()); for (const std::string& ser : serials) { Device device; @@ -81,7 +81,7 @@ std::vector DeviceMgrWin32::find_device_impl() device.adb_path = path_to_utf8_string(adb_path); device.adb_serial = ser; // TODO: 根据设备情况使用不同的配置 - device.adb_config = kAdbConfig.to_string(); + device.adb_config = json::value().to_string(); device.adb_controller_type = check_adb_controller_type(device.adb_path, device.adb_serial, device.adb_config); result.emplace_back(std::move(device)); @@ -95,14 +95,14 @@ std::vector DeviceMgrWin32::find_device_with_adb_impl(std::string_view a { std::vector result; - auto serials = request_adb_serials(path(adb_path), kAdbConfig); + auto serials = request_adb_serials(path(adb_path), json::value()); for (const std::string& ser : serials) { Device device; device.name = adb_path; device.adb_path = adb_path; device.adb_serial = ser; - device.adb_config = kAdbConfig.to_string(); + device.adb_config = json::value().to_string(); device.adb_controller_type = check_adb_controller_type(device.adb_path, device.adb_serial, device.adb_config); result.emplace_back(std::move(device)); }