Commit 8695c640 authored by Fawzi Mohamed's avatar Fawzi Mohamed

ios: remove temporary devices

Developer mode activation generates temporary devices that will never
be usable again. Remove them if they were picked up.

Change-Id: Iff35b640d2c2e8394b108fd8d224a2b6ea8e1626
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 0db9d98d
......@@ -61,6 +61,8 @@ const quint16 IOS_DEVICE_PORT_END = 31000;
const quint16 IOS_SIMULATOR_PORT_START = 30000;
const quint16 IOS_SIMULATOR_PORT_END = 31000;
const char EXTRA_INFO_KEY[] = "extraInfo";
} // namespace Constants;
} // namespace Ios
......
......@@ -79,8 +79,6 @@ static QString CFStringRef2QString(CFStringRef s)
namespace Ios {
namespace Internal {
const char extraInfoKey[] = "extraInfo";
IosDevice::IosDevice()
: IDevice(Core::Id(Constants::IOS_DEVICE_TYPE),
IDevice::AutoDetected,
......@@ -166,7 +164,7 @@ IDevice::Ptr IosDevice::clone() const
void IosDevice::fromMap(const QVariantMap &map)
{
IDevice::fromMap(map);
QVariantMap vMap = map.value(QLatin1String(extraInfoKey)).toMap();
QVariantMap vMap = map.value(QLatin1String(Constants::EXTRA_INFO_KEY)).toMap();
QMapIterator<QString, QVariant> i(vMap);
m_extraInfo.clear();
while (i.hasNext()) {
......@@ -184,7 +182,7 @@ QVariantMap IosDevice::toMap() const
i.next();
vMap.insert(i.key(), i.value());
}
res.insert(QLatin1String(extraInfoKey), vMap);
res.insert(QLatin1String(Constants::EXTRA_INFO_KEY), vMap);
return res;
}
......@@ -281,7 +279,10 @@ void IosDeviceManager::deviceDisconnected(const QString &uid)
qDebug() << "ignoring disconnection of ios device " << uid; // should neve happen
} else {
const IosDevice *iosDev = static_cast<const IosDevice *>(dev.data());
if (iosDev->deviceState() != IDevice::DeviceDisconnected) {
if (iosDev->m_extraInfo.isEmpty()
|| iosDev->m_extraInfo.value(QLatin1String("deviceName")) == QLatin1String("*unknown*")) {
devManager->removeDevice(iosDev->id());
} else if (iosDev->deviceState() != IDevice::DeviceDisconnected) {
if (debugDeviceDetection)
qDebug() << "disconnecting device " << iosDev->uniqueDeviceID();
devManager->setDeviceState(iosDev->id(), IDevice::DeviceDisconnected);
......
......@@ -63,7 +63,13 @@ ProjectExplorer::IDevice::Ptr IosDeviceFactory::create(Core::Id id) const
bool IosDeviceFactory::canRestore(const QVariantMap &map) const
{
return ProjectExplorer::IDevice::typeFromMap(map) == Constants::IOS_DEVICE_TYPE;
if (ProjectExplorer::IDevice::typeFromMap(map) != Constants::IOS_DEVICE_TYPE)
return false;
QVariantMap vMap = map.value(QLatin1String(Constants::EXTRA_INFO_KEY)).toMap();
if (vMap.isEmpty()
|| vMap.value(QLatin1String("deviceName")).toString() == QLatin1String("*unknown*"))
return false; // transient device (probably generated during an activation)
return true;
}
ProjectExplorer::IDevice::Ptr IosDeviceFactory::restore(const QVariantMap &map) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment