forked from qt-creator/qt-creator
Android: Don't call getDeviceState() on empty serial number
Avoid calling getDeviceState() if the serial is empty, which won't give any useful info for emulators. This will avoid multiple state checks at QC start as well. Also, set the default new AndroidDevice state as Disconnected, which reflects better the state of an empty newsly constructed device which we don't know the state of. Change-Id: I854e95e28b150f09c3eff6b8a75b2df6bd4aa1ce Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -162,7 +162,7 @@ AndroidDevice::AndroidDevice()
|
||||
setDisplayType(tr("Android"));
|
||||
setMachineType(IDevice::Hardware);
|
||||
setOsType(OsType::OsTypeOtherUnix);
|
||||
setDeviceState(DeviceConnected);
|
||||
setDeviceState(DeviceDisconnected);
|
||||
|
||||
addDeviceAction({tr("Refresh"), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||
Q_UNUSED(parent)
|
||||
@@ -441,12 +441,10 @@ void AndroidDeviceManager::updateDeviceState(const ProjectExplorer::IDevice::Con
|
||||
const QString serial = dev->serialNumber();
|
||||
DeviceManager *const devMgr = DeviceManager::instance();
|
||||
const Utils::Id id = dev->id();
|
||||
if (serial.isEmpty() && dev->machineType() == IDevice::Emulator) {
|
||||
devMgr->setDeviceState(id, IDevice::DeviceConnected);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!serial.isEmpty())
|
||||
devMgr->setDeviceState(id, getDeviceState(serial, dev->machineType()));
|
||||
else if (dev->machineType() == IDevice::Emulator)
|
||||
devMgr->setDeviceState(id, IDevice::DeviceConnected);
|
||||
}
|
||||
|
||||
void AndroidDeviceManager::startAvd(const ProjectExplorer::IDevice::Ptr &device, QWidget *parent)
|
||||
@@ -641,12 +639,16 @@ void AndroidDeviceManager::HandleAvdsListChange()
|
||||
} else {
|
||||
// Find the state of the AVD retrieved from the AVD watcher
|
||||
const QString serial = getRunningAvdsSerialNumber(item.avdName);
|
||||
if (!serial.isEmpty()) {
|
||||
const IDevice::DeviceState state = getDeviceState(serial, IDevice::Emulator);
|
||||
if (dev->deviceState() != state) {
|
||||
devMgr->setDeviceState(dev->id(), state);
|
||||
qCDebug(androidDeviceLog, "Device id \"%s\" changed its state.",
|
||||
dev->id().toString().toUtf8().data());
|
||||
}
|
||||
} else {
|
||||
devMgr->setDeviceState(dev->id(), IDevice::DeviceConnected);
|
||||
}
|
||||
connectedDevs.append(dev->id());
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user