aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/android/androiddevice.cpp
diff options
context:
space:
mode:
authorAssam Boudjelthia <[email protected]>2022-03-05 16:59:01 +0200
committerAssam Boudjelthia <[email protected]>2022-03-15 09:03:49 +0000
commita141d56991f6e91efe1d43e3e1c438d9dc8ecc3c (patch)
tree45e91671f5de3e13a026d7108d204d600935bbd5 /src/plugins/android/androiddevice.cpp
parent525d26db03cbb46ed35d0d8e1544e8708b4b4214 (diff)
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 <[email protected]>
Diffstat (limited to 'src/plugins/android/androiddevice.cpp')
-rw-r--r--src/plugins/android/androiddevice.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp
index 3e78f43b329..3c2d4fd5d1a 100644
--- a/src/plugins/android/androiddevice.cpp
+++ b/src/plugins/android/androiddevice.cpp
@@ -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) {
+ if (!serial.isEmpty())
+ devMgr->setDeviceState(id, getDeviceState(serial, dev->machineType()));
+ else if (dev->machineType() == IDevice::Emulator)
devMgr->setDeviceState(id, IDevice::DeviceConnected);
- return;
- }
-
- devMgr->setDeviceState(id, getDeviceState(serial, dev->machineType()));
}
void AndroidDeviceManager::startAvd(const ProjectExplorer::IDevice::Ptr &device, QWidget *parent)
@@ -641,11 +639,15 @@ void AndroidDeviceManager::HandleAvdsListChange()
} else {
// Find the state of the AVD retrieved from the AVD watcher
const QString serial = getRunningAvdsSerialNumber(item.avdName);
- 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());
+ 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;