forked from qt-creator/qt-creator
Android: Search for a suitable emulator before starting a new avd
Note, that we don't know the names of the started avds, so we look for a avd that has the same abi and apiLevel. Task-number: QTCREATORBUG-10411 Change-Id: I5f6ff3ee0dddcf2bb8fca981ccedf437e32da677 Reviewed-by: BogDan Vatra <bogdan@kde.org>
This commit is contained in:
@@ -621,7 +621,7 @@ QVector<AndroidDeviceInfo> AndroidConfigurations::androidVirtualDevices() const
|
||||
|
||||
QString AndroidConfigurations::startAVD(const QString &name, int apiLevel, QString cpuAbi) const
|
||||
{
|
||||
if (startAVDAsync(name))
|
||||
if (findAvd(apiLevel, cpuAbi) || startAVDAsync(name))
|
||||
return waitForAvd(apiLevel, cpuAbi);
|
||||
return QString();
|
||||
}
|
||||
@@ -643,6 +643,21 @@ bool AndroidConfigurations::startAVDAsync(const QString &avdName) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AndroidConfigurations::findAvd(int apiLevel, const QString &cpuAbi) const
|
||||
{
|
||||
QVector<AndroidDeviceInfo> devices = connectedDevices();
|
||||
foreach (AndroidDeviceInfo device, devices) {
|
||||
if (!device.serialNumber.startsWith(QLatin1String("emulator")))
|
||||
continue;
|
||||
if (!device.cpuAbi.contains(cpuAbi))
|
||||
continue;
|
||||
if (device.sdk != apiLevel)
|
||||
continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
QString AndroidConfigurations::waitForAvd(int apiLevel, const QString &cpuAbi) const
|
||||
{
|
||||
// we cannot use adb -e wait-for-device, since that doesn't work if a emulator is already running
|
||||
|
||||
Reference in New Issue
Block a user