diff --git a/src/plugins/ios/iosdevice.cpp b/src/plugins/ios/iosdevice.cpp index c3853e0df94..8cf394cbfac 100644 --- a/src/plugins/ios/iosdevice.cpp +++ b/src/plugins/ios/iosdevice.cpp @@ -85,6 +85,8 @@ const char vOff[] = "*off*"; const char vDevelopment[] = "Development"; const char vYes[] = "YES"; +const char kHandler[] = "Handler"; + class IosDeviceInfoWidget : public IDeviceWidget { public: @@ -145,6 +147,7 @@ void IosDevice::fromMap(const Store &map) const Store vMap = storeFromVariant(map.value(Constants::EXTRA_INFO_KEY)); for (auto i = vMap.cbegin(), end = vMap.cend(); i != end; ++i) m_extraInfo.insert(stringFromKey(i.key()), i.value().toString()); + m_handler = Handler(map.value(kHandler).toInt()); } Store IosDevice::toMap() const @@ -154,6 +157,7 @@ Store IosDevice::toMap() const for (auto i = m_extraInfo.cbegin(), end = m_extraInfo.cend(); i != end; ++i) vMap.insert(keyFromString(i.key()), i.value()); res.insert(Constants::EXTRA_INFO_KEY, variantFromStore(vMap)); + res.insert(kHandler, int(m_handler)); return res; } @@ -195,6 +199,11 @@ Utils::Port IosDevice::nextPort() const return Utils::Port(m_lastPort); } +IosDevice::Handler IosDevice::handler() const +{ + return m_handler; +} + // IosDeviceManager IosDeviceManager::TranslationMap IosDeviceManager::translationMap() @@ -293,7 +302,7 @@ void IosDeviceManager::updateInfo(const QString &devId) info[kCpuArchitecture] = device["hardwareProperties"]["cpuType"]["name"].toString(); info[kUniqueDeviceId] = udid; - deviceInfo(nullptr, devId, info); + deviceInfo(devId, IosDevice::Handler::DeviceCtl, info); return DoneResult::Success; } } @@ -305,11 +314,14 @@ void IosDeviceManager::updateInfo(const QString &devId) const auto infoFromIosTool = IosToolTask([this, devId](IosToolRunner &runner) { runner.setDeviceType(IosDeviceType::IosDevice); runner.setStartHandler([this, devId](IosToolHandler *handler) { - connect(handler, - &IosToolHandler::deviceInfo, - this, - &IosDeviceManager::deviceInfo, - Qt::QueuedConnection); + connect( + handler, + &IosToolHandler::deviceInfo, + this, + [this](IosToolHandler *, const QString &uid, const Ios::IosToolHandler::Dict &info) { + deviceInfo(uid, IosDevice::Handler::IosTool, info); + }, + Qt::QueuedConnection); handler->requestDeviceInfo(devId); }); }); @@ -320,7 +332,8 @@ void IosDeviceManager::updateInfo(const QString &devId) task->start(); } -void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid, +void IosDeviceManager::deviceInfo(const QString &uid, + IosDevice::Handler handler, const Ios::IosToolHandler::Dict &info) { DeviceManager *devManager = DeviceManager::instance(); @@ -332,7 +345,7 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid, IosDevice *newDev = nullptr; if (!dev.isNull() && dev->type() == devType) { auto iosDev = static_cast(dev.data()); - if (iosDev->m_extraInfo == info) { + if (iosDev->m_handler == handler && iosDev->m_extraInfo == info) { skipUpdate = true; newDev = const_cast(iosDev); } else { @@ -346,6 +359,7 @@ void IosDeviceManager::deviceInfo(IosToolHandler *, const QString &uid, if (info.contains(kDeviceName)) newDev->settings()->displayName.setValue(info.value(kDeviceName)); newDev->m_extraInfo = info; + newDev->m_handler = handler; qCDebug(detectLog) << "updated info of ios device " << uid; dev = IDevice::ConstPtr(newDev); devManager->addDevice(dev); diff --git a/src/plugins/ios/iosdevice.h b/src/plugins/ios/iosdevice.h index bdbd1d43a2c..f67e608477a 100644 --- a/src/plugins/ios/iosdevice.h +++ b/src/plugins/ios/iosdevice.h @@ -23,6 +23,8 @@ public: using ConstPtr = QSharedPointer; using Ptr = QSharedPointer; + enum class Handler { IosTool, DeviceCtl }; + ProjectExplorer::IDevice::DeviceInfo deviceInformation() const override; ProjectExplorer::IDeviceWidget *createWidget() override; @@ -32,6 +34,7 @@ public: QString osVersion() const; QString cpuArchitecture() const; Utils::Port nextPort() const; + Handler handler() const; static QString name(); @@ -48,6 +51,7 @@ protected: IosDevice(CtorHelper); Dict m_extraInfo; + Handler m_handler = Handler::IosTool; bool m_ignoreDevice = false; mutable quint16 m_lastPort; }; @@ -73,7 +77,8 @@ public: void deviceDisconnected(const QString &uid); friend class IosConfigurations; void updateInfo(const QString &devId); - void deviceInfo(Ios::IosToolHandler *gatherer, const QString &deviceId, + void deviceInfo(const QString &deviceId, + IosDevice::Handler handler, const Ios::IosToolHandler::Dict &info); void monitorAvailableDevices();