forked from qt-creator/qt-creator
Android: Skip device list update no Android Kit is active
This adds workaround to reduce the load added by the update of the Android device list, which currently happens in a polling style. Skip an update if (*): - The current open project is configured with a non-Android kit - No project is open - the current project target is null To summarize the timeline of the timer used here: - AndroidDeviceManager::setupDevicesWatcher() is called when Creator is started or when settings are changed. The setup makes the connections for the timeout and for AVD list future watcher. This will be done once. If the timer is active it won't be done again, so no duplicate connections. - In the setup, the list of devices in updated once. - On timer timeout, we attempt to update the list, however with conditions listed in (*) as well as only when an Android adb path is found. Fixes: QTCREATORBUG-26547 Change-Id: I13312c4b507ce4e4064adb1c1342f4648f915394 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
@@ -37,7 +37,10 @@
|
||||
|
||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||
#include <projectexplorer/devicesupport/idevicewidget.h>
|
||||
#include <projectexplorer/kitinformation.h>
|
||||
#include <projectexplorer/runconfiguration.h>
|
||||
#include <projectexplorer/session.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/runextensions.h>
|
||||
@@ -418,11 +421,19 @@ QUrl AndroidDevice::toolControlChannel(const ControlChannelHint &) const
|
||||
|
||||
void AndroidDeviceManager::updateDevicesList()
|
||||
{
|
||||
connect(&m_devicesUpdaterTimer, &QTimer::timeout, this, [this]() {
|
||||
// If a non-Android Kit is currently active, skip the device list update
|
||||
const Target *startupTarget = SessionManager::startupTarget();
|
||||
if (!startupTarget)
|
||||
return;
|
||||
|
||||
const Kit *kit = startupTarget->kit();
|
||||
if (!kit)
|
||||
return;
|
||||
|
||||
if (DeviceTypeKitAspect::deviceTypeId(kit) != Constants::ANDROID_DEVICE_TYPE)
|
||||
return;
|
||||
|
||||
updateDevicesListOnce();
|
||||
});
|
||||
updateDevicesListOnce();
|
||||
m_devicesUpdaterTimer.start(deviceUpdaterMsInterval);
|
||||
}
|
||||
|
||||
void AndroidDeviceManager::updateDevicesListOnce()
|
||||
@@ -537,11 +548,17 @@ void AndroidDeviceManager::setEmulatorArguments(QWidget *parent)
|
||||
|
||||
void AndroidDeviceManager::setupDevicesWatcher()
|
||||
{
|
||||
if (!m_devicesUpdaterTimer.isActive()) {
|
||||
// The call to avdmanager is always slower than the call to adb devices,
|
||||
// so connecting the slot to the slower call should be enough.
|
||||
connect(&m_avdsFutureWatcher, &QFutureWatcherBase::finished,
|
||||
this, &AndroidDeviceManager::devicesListUpdated);
|
||||
connect(&m_devicesUpdaterTimer, &QTimer::timeout, this, [this]() {
|
||||
updateDevicesList();
|
||||
});
|
||||
m_devicesUpdaterTimer.start(deviceUpdaterMsInterval);
|
||||
}
|
||||
updateDevicesListOnce();
|
||||
}
|
||||
|
||||
void AndroidDeviceManager::devicesListUpdated()
|
||||
|
Reference in New Issue
Block a user