iOS: Add a "handler" property for the tool that is used for device ops

To the IosDevice. So other parts of the code know if the device can (and
should) be handled via devicectl instead of iostool.

Change-Id: I700bd1528fad505c3f4b6442d73e24b09ceba68a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Eike Ziller
2024-01-12 11:40:20 +01:00
parent b2eac9acf8
commit 1a29b9e36c
2 changed files with 28 additions and 9 deletions

View File

@@ -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<const IosDevice *>(dev.data());
if (iosDev->m_extraInfo == info) {
if (iosDev->m_handler == handler && iosDev->m_extraInfo == info) {
skipUpdate = true;
newDev = const_cast<IosDevice *>(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);

View File

@@ -23,6 +23,8 @@ public:
using ConstPtr = QSharedPointer<const IosDevice>;
using Ptr = QSharedPointer<IosDevice>;
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();