diff --git a/source/MaaToolkit/API/MaaToolkitDevice.cpp b/source/MaaToolkit/API/MaaToolkitDevice.cpp index 1f72d417d..44f5a3777 100644 --- a/source/MaaToolkit/API/MaaToolkitDevice.cpp +++ b/source/MaaToolkit/API/MaaToolkitDevice.cpp @@ -44,7 +44,7 @@ MaaBool MaaToolkitPostFindDeviceWithAdb(MaaStringView adb_path) { LogFunc; - return device_mgr.post_find_device_with_adb(adb_path); + return device_mgr.post_find_device_with_adb(MAA_NS::path(adb_path)); } MaaBool MaaToolkitIsFindDeviceCompleted() diff --git a/source/MaaToolkit/AdbDevice/DeviceAPI.h b/source/MaaToolkit/AdbDevice/DeviceAPI.h index bb59e0c07..7a33d40c6 100644 --- a/source/MaaToolkit/AdbDevice/DeviceAPI.h +++ b/source/MaaToolkit/AdbDevice/DeviceAPI.h @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include "Conf/Conf.h" @@ -57,7 +57,7 @@ struct MaaToolkitDeviceMgrAPI virtual ~MaaToolkitDeviceMgrAPI() = default; virtual bool post_find_device() = 0; - virtual bool post_find_device_with_adb(std::string adb_path) = 0; + virtual bool post_find_device_with_adb(std::filesystem::path adb_path) = 0; virtual bool is_find_completed() const = 0; virtual const std::optional>& get_devices() = 0; }; diff --git a/source/MaaToolkit/AdbDevice/DeviceMgr.cpp b/source/MaaToolkit/AdbDevice/DeviceMgr.cpp index 90ebc1ade..1b9fe27b0 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgr.cpp +++ b/source/MaaToolkit/AdbDevice/DeviceMgr.cpp @@ -23,11 +23,12 @@ bool DeviceMgr::post_find_device() } devices_ = std::nullopt; - find_device_future_ = std::async(std::launch::async, [=]() { return find_device_impl(); }); + find_device_future_ = + std::async(std::launch::async, [=, this]() { return find_device_impl(); }); return true; } -bool DeviceMgr::post_find_device_with_adb(std::string adb_path) +bool DeviceMgr::post_find_device_with_adb(std::filesystem::path adb_path) { LogFunc; @@ -38,7 +39,7 @@ bool DeviceMgr::post_find_device_with_adb(std::string adb_path) devices_ = std::nullopt; find_device_future_ = - std::async(std::launch::async, [=]() { return find_device_with_adb_impl(adb_path); }); + std::async(std::launch::async, [=, this]() { return find_device_with_adb_impl(adb_path); }); return true; } diff --git a/source/MaaToolkit/AdbDevice/DeviceMgr.h b/source/MaaToolkit/AdbDevice/DeviceMgr.h index d76d76606..034b0747f 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgr.h +++ b/source/MaaToolkit/AdbDevice/DeviceMgr.h @@ -28,13 +28,13 @@ class DeviceMgr : public MaaToolkitDeviceMgrAPI }; virtual bool post_find_device() override final; - virtual bool post_find_device_with_adb(std::string adb_path) override final; + virtual bool post_find_device_with_adb(std::filesystem::path adb_path) override final; virtual bool is_find_completed() const override final; virtual const std::optional>& get_devices() override final; protected: virtual std::vector find_device_impl() = 0; - virtual std::vector find_device_with_adb_impl(std::string adb_path) = 0; + virtual std::vector find_device_with_adb_impl(std::filesystem::path adb_path) = 0; protected: std::vector request_adb_serials( diff --git a/source/MaaToolkit/AdbDevice/DeviceMgrLinux.cpp b/source/MaaToolkit/AdbDevice/DeviceMgrLinux.cpp index 13b0428b1..e20802e68 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgrLinux.cpp +++ b/source/MaaToolkit/AdbDevice/DeviceMgrLinux.cpp @@ -11,7 +11,7 @@ std::vector DeviceMgrLinux::find_device_impl() return {}; } -std::vector DeviceMgrLinux::find_device_with_adb_impl(std::string adb_path) +std::vector DeviceMgrLinux::find_device_with_adb_impl(std::filesystem::path adb_path) { std::ignore = adb_path; return {}; diff --git a/source/MaaToolkit/AdbDevice/DeviceMgrLinux.h b/source/MaaToolkit/AdbDevice/DeviceMgrLinux.h index 591b83db5..10ae9aa3b 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgrLinux.h +++ b/source/MaaToolkit/AdbDevice/DeviceMgrLinux.h @@ -19,7 +19,7 @@ class DeviceMgrLinux public: // from DeviceMgr virtual std::vector find_device_impl() override; - virtual std::vector find_device_with_adb_impl(std::string adb_path) override; + virtual std::vector find_device_with_adb_impl(std::filesystem::path adb_path) override; private: DeviceMgrLinux() = default; diff --git a/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.cpp b/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.cpp index fd164e576..60188f1ae 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.cpp +++ b/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.cpp @@ -87,20 +87,20 @@ std::vector DeviceMgrMacOS::find_device_impl() return result; } -std::vector DeviceMgrMacOS::find_device_with_adb_impl(std::string adb_path) +std::vector DeviceMgrMacOS::find_device_with_adb_impl(std::filesystem::path adb_path) { std::vector result; - auto serials = request_adb_serials(path(adb_path), json::object()); + auto serials = request_adb_serials(adb_path, json::object()); for (const std::string& ser : serials) { Device device; - device.name = adb_path; - device.adb_path = adb_path; + device.adb_path = path_to_utf8_string(adb_path); + device.name = device.adb_path; device.adb_serial = ser; device.adb_config = json::object().to_string(); device.adb_controller_type = - check_adb_controller_type(device.adb_path, device.adb_serial, device.adb_config); + check_adb_controller_type(adb_path, device.adb_serial, device.adb_config); result.emplace_back(std::move(device)); } return result; diff --git a/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.h b/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.h index 006714721..dbb2df167 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.h +++ b/source/MaaToolkit/AdbDevice/DeviceMgrMacOS.h @@ -19,7 +19,7 @@ class DeviceMgrMacOS public: // from DeviceMgr virtual std::vector find_device_impl() override; - virtual std::vector find_device_with_adb_impl(std::string adb_path) override; + virtual std::vector find_device_with_adb_impl(std::filesystem::path adb_path) override; private: DeviceMgrMacOS() = default; diff --git a/source/MaaToolkit/AdbDevice/DeviceMgrWin32.cpp b/source/MaaToolkit/AdbDevice/DeviceMgrWin32.cpp index f3a1b7e4a..7786ebc38 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgrWin32.cpp +++ b/source/MaaToolkit/AdbDevice/DeviceMgrWin32.cpp @@ -118,20 +118,20 @@ std::vector DeviceMgrWin32::find_device_impl() return result; } -std::vector DeviceMgrWin32::find_device_with_adb_impl(std::string adb_path) +std::vector DeviceMgrWin32::find_device_with_adb_impl(std::filesystem::path adb_path) { std::vector result; - auto serials = request_adb_serials(path(adb_path), json::object()); + auto serials = request_adb_serials(adb_path, json::object()); for (const std::string& ser : serials) { Device device; - device.name = adb_path; - device.adb_path = adb_path; + device.adb_path = path_to_utf8_string(adb_path); + device.name = device.adb_path; device.adb_serial = ser; device.adb_config = json::object().to_string(); device.adb_controller_type = - check_adb_controller_type(device.adb_path, device.adb_serial, device.adb_config); + check_adb_controller_type(adb_path, device.adb_serial, device.adb_config); result.emplace_back(std::move(device)); } return result; diff --git a/source/MaaToolkit/AdbDevice/DeviceMgrWin32.h b/source/MaaToolkit/AdbDevice/DeviceMgrWin32.h index eba933423..1809f4726 100644 --- a/source/MaaToolkit/AdbDevice/DeviceMgrWin32.h +++ b/source/MaaToolkit/AdbDevice/DeviceMgrWin32.h @@ -22,7 +22,7 @@ class DeviceMgrWin32 public: // from DeviceMgr virtual std::vector find_device_impl() override; - virtual std::vector find_device_with_adb_impl(std::string adb_path) override; + virtual std::vector find_device_with_adb_impl(std::filesystem::path adb_path) override; private: DeviceMgrWin32() = default;