forked from qt-creator/qt-creator
Android: Get rid of the avd info fields in AndroidDeviceInfo
The AVD specific fields don't need to be carried out by QtC settings, these can be read from the AVD's config file when they are needed. This also is good because those values can change at any time, either manually or by some other IDE like Android Studio, and thus we don't really need to manage them ourselves. The fields in question are: skin name, target name, sdcard size, openGL status. Change-Id: I86163500ec2fed035e32ec02ed17e182778db4a7 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -753,28 +753,6 @@ QString AndroidConfig::getAvdName(const QString &serialnumber)
|
|||||||
return QString::fromLatin1(name).trimmed();
|
return QString::fromLatin1(name).trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidConfig::OpenGl AndroidConfig::getOpenGLEnabled(const QString &emulator) const
|
|
||||||
{
|
|
||||||
QDir dir = QDir::home();
|
|
||||||
if (!dir.cd(QLatin1String(".android")))
|
|
||||||
return OpenGl::Unknown;
|
|
||||||
if (!dir.cd(QLatin1String("avd")))
|
|
||||||
return OpenGl::Unknown;
|
|
||||||
if (!dir.cd(emulator + QLatin1String(".avd")))
|
|
||||||
return OpenGl::Unknown;
|
|
||||||
QFile file(dir.filePath(QLatin1String("config.ini")));
|
|
||||||
if (!file.exists())
|
|
||||||
return OpenGl::Unknown;
|
|
||||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
|
||||||
return OpenGl::Unknown;
|
|
||||||
while (!file.atEnd()) {
|
|
||||||
QByteArray line = file.readLine();
|
|
||||||
if (line.contains("hw.gpu.enabled") && line.contains("yes"))
|
|
||||||
return OpenGl::Enabled;
|
|
||||||
}
|
|
||||||
return OpenGl::Disabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
//!
|
//!
|
||||||
//! \brief AndroidConfigurations::getProductModel
|
//! \brief AndroidConfigurations::getProductModel
|
||||||
//! \param device serial number
|
//! \param device serial number
|
||||||
|
@@ -156,8 +156,6 @@ public:
|
|||||||
static QLatin1String displayName(const ProjectExplorer::Abi &abi);
|
static QLatin1String displayName(const ProjectExplorer::Abi &abi);
|
||||||
|
|
||||||
QString getProductModel(const QString &device) const;
|
QString getProductModel(const QString &device) const;
|
||||||
enum class OpenGl { Enabled, Disabled, Unknown };
|
|
||||||
OpenGl getOpenGLEnabled(const QString &emulator) const;
|
|
||||||
bool isConnected(const QString &serialNumber) const;
|
bool isConnected(const QString &serialNumber) const;
|
||||||
|
|
||||||
bool isCmdlineSdkToolsInstalled() const;
|
bool isCmdlineSdkToolsInstalled() const;
|
||||||
|
@@ -99,11 +99,8 @@ const char SdkLocation[] = "SdkLocation"; // FileName
|
|||||||
const Utils::Id AndroidSerialNumber = "AndroidSerialNumber";
|
const Utils::Id AndroidSerialNumber = "AndroidSerialNumber";
|
||||||
const Utils::Id AndroidAvdName = "AndroidAvdName";
|
const Utils::Id AndroidAvdName = "AndroidAvdName";
|
||||||
const Utils::Id AndroidCpuAbi = "AndroidCpuAbi";
|
const Utils::Id AndroidCpuAbi = "AndroidCpuAbi";
|
||||||
const Utils::Id AndroidAvdTarget = "AndroidAvdTarget";
|
|
||||||
const Utils::Id AndroidAvdDevice = "AndroidAvdDevice";
|
|
||||||
const Utils::Id AndroidAvdSkin = "AndroidAvdSkin";
|
|
||||||
const Utils::Id AndroidAvdSdcard = "AndroidAvdSdcard";
|
|
||||||
const Utils::Id AndroidSdk = "AndroidSdk";
|
const Utils::Id AndroidSdk = "AndroidSdk";
|
||||||
|
const Utils::Id AndroidAvdPath = "AndroidAvdPath";
|
||||||
|
|
||||||
} // namespace Constants;
|
} // namespace Constants;
|
||||||
} // namespace Android
|
} // namespace Android
|
||||||
|
@@ -58,6 +58,7 @@
|
|||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static Q_LOGGING_CATEGORY(androidDeviceLog, "qtc.android.androiddevice", QtWarningMsg)
|
static Q_LOGGING_CATEGORY(androidDeviceLog, "qtc.android.androiddevice", QtWarningMsg)
|
||||||
@@ -116,7 +117,7 @@ AndroidDeviceWidget::AndroidDeviceWidget(const IDevice::Ptr &device)
|
|||||||
formLayout->addRow(AndroidDevice::tr("Android target flavor:"), new QLabel(targetName));
|
formLayout->addRow(AndroidDevice::tr("Android target flavor:"), new QLabel(targetName));
|
||||||
formLayout->addRow(AndroidDevice::tr("SD card size:"), new QLabel(dev->sdcardSize()));
|
formLayout->addRow(AndroidDevice::tr("SD card size:"), new QLabel(dev->sdcardSize()));
|
||||||
formLayout->addRow(AndroidDevice::tr("Skin type:"), new QLabel(dev->skinName()));
|
formLayout->addRow(AndroidDevice::tr("Skin type:"), new QLabel(dev->skinName()));
|
||||||
const QString openGlStatus = dev->openGlStatusString();
|
const QString openGlStatus = dev->openGLStatus();
|
||||||
formLayout->addRow(AndroidDevice::tr("OpenGL status:"), new QLabel(openGlStatus));
|
formLayout->addRow(AndroidDevice::tr("OpenGL status:"), new QLabel(openGlStatus));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,7 +161,7 @@ AndroidDevice::AndroidDevice()
|
|||||||
setDefaultDisplayName(tr("Run on Android"));
|
setDefaultDisplayName(tr("Run on Android"));
|
||||||
setDisplayType(tr("Android"));
|
setDisplayType(tr("Android"));
|
||||||
setMachineType(IDevice::Hardware);
|
setMachineType(IDevice::Hardware);
|
||||||
setOsType(Utils::OsTypeOtherUnix);
|
setOsType(OsType::OsTypeOtherUnix);
|
||||||
setDeviceState(DeviceConnected);
|
setDeviceState(DeviceConnected);
|
||||||
|
|
||||||
addDeviceAction({tr("Refresh"), [](const IDevice::Ptr &device, QWidget *parent) {
|
addDeviceAction({tr("Refresh"), [](const IDevice::Ptr &device, QWidget *parent) {
|
||||||
@@ -215,6 +216,7 @@ void AndroidDevice::addEmulatorActionsIfNotFound()
|
|||||||
void AndroidDevice::fromMap(const QVariantMap &map)
|
void AndroidDevice::fromMap(const QVariantMap &map)
|
||||||
{
|
{
|
||||||
IDevice::fromMap(map);
|
IDevice::fromMap(map);
|
||||||
|
initAvdSettings();
|
||||||
// Add Actions for Emulator is not added already.
|
// Add Actions for Emulator is not added already.
|
||||||
// This is needed because actions for Emulators and physical devices are not the same.
|
// This is needed because actions for Emulators and physical devices are not the same.
|
||||||
addEmulatorActionsIfNotFound();
|
addEmulatorActionsIfNotFound();
|
||||||
@@ -232,28 +234,14 @@ AndroidDeviceInfo AndroidDevice::androidDeviceInfoFromIDevice(const IDevice *dev
|
|||||||
info.avdname = dev->extraData(Constants::AndroidAvdName).toString();
|
info.avdname = dev->extraData(Constants::AndroidAvdName).toString();
|
||||||
info.serialNumber = dev->extraData(Constants::AndroidSerialNumber).toString();
|
info.serialNumber = dev->extraData(Constants::AndroidSerialNumber).toString();
|
||||||
info.cpuAbi = dev->extraData(Constants::AndroidCpuAbi).toStringList();
|
info.cpuAbi = dev->extraData(Constants::AndroidCpuAbi).toStringList();
|
||||||
info.avdTarget = dev->extraData(Constants::AndroidAvdTarget).toString();
|
const QString avdPath = dev->extraData(Constants::AndroidAvdPath).toString();
|
||||||
info.avdDevice = dev->extraData(Constants::AndroidAvdDevice).toString();
|
info.avdPath = FilePath::fromUserInput(avdPath);
|
||||||
info.avdSkin = dev->extraData(Constants::AndroidAvdSkin).toString();
|
|
||||||
info.avdSdcardSize = dev->extraData(Constants::AndroidAvdSdcard).toString();
|
|
||||||
info.sdk = dev->extraData(Constants::AndroidSdk).toInt();
|
info.sdk = dev->extraData(Constants::AndroidSdk).toInt();
|
||||||
info.type = dev->machineType();
|
info.type = dev->machineType();
|
||||||
|
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AndroidDevice::setAndroidDeviceInfoExtras(IDevice *dev, const AndroidDeviceInfo &info)
|
|
||||||
{
|
|
||||||
dev->setExtraData(Constants::AndroidAvdName, info.avdname);
|
|
||||||
dev->setExtraData(Constants::AndroidSerialNumber, info.serialNumber);
|
|
||||||
dev->setExtraData(Constants::AndroidCpuAbi, info.cpuAbi);
|
|
||||||
dev->setExtraData(Constants::AndroidAvdTarget, info.avdTarget);
|
|
||||||
dev->setExtraData(Constants::AndroidAvdDevice, info.avdDevice);
|
|
||||||
dev->setExtraData(Constants::AndroidAvdSkin, info.avdSkin);
|
|
||||||
dev->setExtraData(Constants::AndroidAvdSdcard, info.avdSdcardSize);
|
|
||||||
dev->setExtraData(Constants::AndroidSdk, info.sdk);
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AndroidDevice::displayNameFromInfo(const AndroidDeviceInfo &info)
|
QString AndroidDevice::displayNameFromInfo(const AndroidDeviceInfo &info)
|
||||||
{
|
{
|
||||||
return info.type == IDevice::Hardware
|
return info.type == IDevice::Hardware
|
||||||
@@ -261,15 +249,15 @@ QString AndroidDevice::displayNameFromInfo(const AndroidDeviceInfo &info)
|
|||||||
: info.avdname;
|
: info.avdname;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Id AndroidDevice::idFromDeviceInfo(const AndroidDeviceInfo &info)
|
Id AndroidDevice::idFromDeviceInfo(const AndroidDeviceInfo &info)
|
||||||
{
|
{
|
||||||
const QString id = (info.type == IDevice::Hardware ? info.serialNumber : info.avdname);
|
const QString id = (info.type == IDevice::Hardware ? info.serialNumber : info.avdname);
|
||||||
return Utils::Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + id);
|
return Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::Id AndroidDevice::idFromAvdInfo(const CreateAvdInfo &info)
|
Id AndroidDevice::idFromAvdInfo(const CreateAvdInfo &info)
|
||||||
{
|
{
|
||||||
return Utils::Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + info.name);
|
return Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + info.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AndroidDevice::supportedAbis() const
|
QStringList AndroidDevice::supportedAbis() const
|
||||||
@@ -342,6 +330,17 @@ int AndroidDevice::sdkLevel() const
|
|||||||
return extraData(Constants::AndroidSdk).toInt();
|
return extraData(Constants::AndroidSdk).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FilePath AndroidDevice::avdPath() const
|
||||||
|
{
|
||||||
|
return FilePath::fromUserInput(extraData(Constants::AndroidAvdPath).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidDevice::setAvdPath(const FilePath &path)
|
||||||
|
{
|
||||||
|
setExtraData(Constants::AndroidAvdPath, path.toUserOutput());
|
||||||
|
initAvdSettings();
|
||||||
|
}
|
||||||
|
|
||||||
QString AndroidDevice::androidVersion() const
|
QString AndroidDevice::androidVersion() const
|
||||||
{
|
{
|
||||||
return AndroidManager::androidNameForApiLevel(sdkLevel());
|
return AndroidManager::androidNameForApiLevel(sdkLevel());
|
||||||
@@ -350,46 +349,32 @@ QString AndroidDevice::androidVersion() const
|
|||||||
QString AndroidDevice::deviceTypeName() const
|
QString AndroidDevice::deviceTypeName() const
|
||||||
{
|
{
|
||||||
if (machineType() == Emulator)
|
if (machineType() == Emulator)
|
||||||
return tr("Emulator for ") + extraData(Constants::AndroidAvdDevice).toString();
|
return tr("Emulator for \"%1\"").arg(avdSettings()->value("hw.device.name").toString());
|
||||||
return tr("Physical device");
|
return tr("Physical device");
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AndroidDevice::skinName() const
|
QString AndroidDevice::skinName() const
|
||||||
{
|
{
|
||||||
const QString skin = extraData(Constants::AndroidAvdSkin).toString();
|
const QString skin = avdSettings()->value("skin.name").toString();
|
||||||
return skin.isEmpty() ? tr("None") : skin;
|
return skin.isEmpty() ? tr("None") : skin;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AndroidDevice::androidTargetName() const
|
QString AndroidDevice::androidTargetName() const
|
||||||
{
|
{
|
||||||
const QString target = extraData(Constants::AndroidAvdTarget).toString();
|
const QString target = avdSettings()->value("tag.display").toString();
|
||||||
return target.isEmpty() ? tr("Unknown") : target;
|
return target.isEmpty() ? tr("Unknown") : target;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString AndroidDevice::sdcardSize() const
|
QString AndroidDevice::sdcardSize() const
|
||||||
{
|
{
|
||||||
const QString size = extraData(Constants::AndroidAvdSdcard).toString();
|
const QString size = avdSettings()->value("sdcard.size").toString();
|
||||||
return size.isEmpty() ? tr("Unknown") : size;
|
return size.isEmpty() ? tr("Unknown") : size;
|
||||||
}
|
}
|
||||||
|
|
||||||
AndroidConfig::OpenGl AndroidDevice::openGlStatus() const
|
QString AndroidDevice::openGLStatus() const
|
||||||
{
|
{
|
||||||
return AndroidConfigurations::currentConfig().getOpenGLEnabled(displayName());
|
const QString openGL = avdSettings()->value("hw.gpu.enabled").toString();
|
||||||
}
|
return openGL.isEmpty() ? tr("Unknown") : openGL;
|
||||||
|
|
||||||
QString AndroidDevice::openGlStatusString() const
|
|
||||||
{
|
|
||||||
const AndroidConfig::OpenGl glStatus = AndroidConfigurations::currentConfig()
|
|
||||||
.getOpenGLEnabled(displayName());
|
|
||||||
switch (glStatus) {
|
|
||||||
case (AndroidConfig::OpenGl::Enabled):
|
|
||||||
return tr("Enabled");
|
|
||||||
case (AndroidConfig::OpenGl::Disabled):
|
|
||||||
return tr("Disabled");
|
|
||||||
case (AndroidConfig::OpenGl::Unknown):
|
|
||||||
return tr("Unknown");
|
|
||||||
}
|
|
||||||
return tr("Unknown");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IDevice::DeviceInfo AndroidDevice::deviceInformation() const
|
IDevice::DeviceInfo AndroidDevice::deviceInformation() const
|
||||||
@@ -420,6 +405,17 @@ QUrl AndroidDevice::toolControlChannel(const ControlChannelHint &) const
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSettings *AndroidDevice::avdSettings() const
|
||||||
|
{
|
||||||
|
return m_avdSettings.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
void AndroidDevice::initAvdSettings()
|
||||||
|
{
|
||||||
|
const FilePath configPath = avdPath().resolvePath(QStringLiteral("config.ini"));
|
||||||
|
m_avdSettings.reset(new QSettings(configPath.toUserOutput(), QSettings::IniFormat));
|
||||||
|
}
|
||||||
|
|
||||||
void AndroidDeviceManager::updateAvdsList()
|
void AndroidDeviceManager::updateAvdsList()
|
||||||
{
|
{
|
||||||
if (!m_avdsFutureWatcher.isRunning() && m_androidConfig.adbToolPath().exists())
|
if (!m_avdsFutureWatcher.isRunning() && m_androidConfig.adbToolPath().exists())
|
||||||
@@ -621,27 +617,26 @@ void AndroidDeviceManager::HandleAvdsListChange()
|
|||||||
{
|
{
|
||||||
DeviceManager *const devMgr = DeviceManager::instance();
|
DeviceManager *const devMgr = DeviceManager::instance();
|
||||||
|
|
||||||
QVector<IDevice::ConstPtr> existingAvds;
|
QVector<Id> existingAvds;
|
||||||
for (int i = 0; i < devMgr->deviceCount(); ++i) {
|
for (int i = 0; i < devMgr->deviceCount(); ++i) {
|
||||||
const IDevice::ConstPtr dev = devMgr->deviceAt(i);
|
const IDevice::ConstPtr dev = devMgr->deviceAt(i);
|
||||||
const bool isEmulator = dev->machineType() == IDevice::Emulator;
|
const bool isEmulator = dev->machineType() == IDevice::Emulator;
|
||||||
if (isEmulator && dev->type() == Constants::ANDROID_DEVICE_TYPE)
|
if (isEmulator && dev->type() == Constants::ANDROID_DEVICE_TYPE)
|
||||||
existingAvds.append(dev);
|
existingAvds.append(dev->id());
|
||||||
}
|
}
|
||||||
|
|
||||||
QVector<IDevice::ConstPtr> connectedDevs;
|
QVector<Id> connectedDevs;
|
||||||
for (auto item : m_avdsFutureWatcher.result()) {
|
for (auto item : m_avdsFutureWatcher.result()) {
|
||||||
const Utils::Id deviceId = AndroidDevice::idFromDeviceInfo(item);
|
const Utils::Id deviceId = AndroidDevice::idFromDeviceInfo(item);
|
||||||
const QString displayName = AndroidDevice::displayNameFromInfo(item);
|
const QString displayName = AndroidDevice::displayNameFromInfo(item);
|
||||||
IDevice::ConstPtr dev = devMgr->find(deviceId);
|
IDevice::ConstPtr dev = devMgr->find(deviceId);
|
||||||
if (!dev.isNull()) {
|
if (!dev.isNull()) {
|
||||||
const auto androidDev = static_cast<const AndroidDevice *>(dev.data());
|
const auto androidDev = static_cast<const AndroidDevice *>(dev.data());
|
||||||
// DeviceManager doens't seem to hav a way to directly update the name, if the name
|
// DeviceManager doens't seem to have a way to directly update the name, if the name
|
||||||
// of the device has changed, remove it and register it again with the new name.
|
// of the device has changed, remove it and register it again with the new name.
|
||||||
// Also account for the case of an AVD registered through old QC which might have
|
// Also account for the case of an AVD registered through old QC which might have
|
||||||
// invalid data by checking the sdcard size value.
|
// invalid data by checking if the avdPath is not empty.
|
||||||
if (dev->displayName() != displayName
|
if (dev->displayName() != displayName || androidDev->avdPath().toString().isEmpty()) {
|
||||||
|| androidDev->sdcardSize() == AndroidDevice::tr("Unknown")) {
|
|
||||||
devMgr->removeDevice(dev->id());
|
devMgr->removeDevice(dev->id());
|
||||||
} else {
|
} else {
|
||||||
// Find the state of the AVD retrieved from the AVD watcher
|
// Find the state of the AVD retrieved from the AVD watcher
|
||||||
@@ -652,7 +647,7 @@ void AndroidDeviceManager::HandleAvdsListChange()
|
|||||||
qCDebug(androidDeviceLog, "Device id \"%s\" changed its state.",
|
qCDebug(androidDeviceLog, "Device id \"%s\" changed its state.",
|
||||||
dev->id().toString().toUtf8().data());
|
dev->id().toString().toUtf8().data());
|
||||||
}
|
}
|
||||||
connectedDevs.append(dev);
|
connectedDevs.append(dev->id());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,20 +657,26 @@ void AndroidDeviceManager::HandleAvdsListChange()
|
|||||||
newDev->setDisplayName(displayName);
|
newDev->setDisplayName(displayName);
|
||||||
newDev->setMachineType(item.type);
|
newDev->setMachineType(item.type);
|
||||||
newDev->setDeviceState(item.state);
|
newDev->setDeviceState(item.state);
|
||||||
AndroidDevice::setAndroidDeviceInfoExtras(newDev, item);
|
|
||||||
|
newDev->setExtraData(Constants::AndroidAvdName, item.avdname);
|
||||||
|
newDev->setExtraData(Constants::AndroidSerialNumber, item.serialNumber);
|
||||||
|
newDev->setExtraData(Constants::AndroidCpuAbi, item.cpuAbi);
|
||||||
|
newDev->setExtraData(Constants::AndroidSdk, item.sdk);
|
||||||
|
newDev->setAvdPath(item.avdPath);
|
||||||
|
|
||||||
qCDebug(androidDeviceLog, "Registering new Android device id \"%s\".",
|
qCDebug(androidDeviceLog, "Registering new Android device id \"%s\".",
|
||||||
newDev->id().toString().toUtf8().data());
|
newDev->id().toString().toUtf8().data());
|
||||||
const IDevice::ConstPtr constNewDev = IDevice::ConstPtr(newDev);
|
const IDevice::ConstPtr constNewDev = IDevice::ConstPtr(newDev);
|
||||||
devMgr->addDevice(IDevice::ConstPtr(constNewDev));
|
devMgr->addDevice(IDevice::ConstPtr(constNewDev));
|
||||||
connectedDevs.append(constNewDev);
|
connectedDevs.append(constNewDev->id());
|
||||||
|
}
|
||||||
|
|
||||||
// Set devices no longer connected to disconnected state.
|
// Set devices no longer connected to disconnected state.
|
||||||
for (const IDevice::ConstPtr &dev : existingAvds) {
|
for (const Id &id : existingAvds) {
|
||||||
if (!connectedDevs.contains(dev)) {
|
if (!connectedDevs.contains(id)) {
|
||||||
qCDebug(androidDeviceLog, "Removing AVD id \"%s\" because it no longer exists.",
|
qCDebug(androidDeviceLog, "Removing AVD id \"%s\" because it no longer exists.",
|
||||||
dev->id().toString().toUtf8().data());
|
id.toString().toUtf8().data());
|
||||||
devMgr->removeDevice(dev->id());
|
devMgr->removeDevice(id);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
|
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
#include <QFileSystemWatcher>
|
#include <QFileSystemWatcher>
|
||||||
|
#include <QSettings>
|
||||||
|
|
||||||
namespace Utils { class QtcProcess; }
|
namespace Utils { class QtcProcess; }
|
||||||
|
|
||||||
@@ -50,7 +51,6 @@ public:
|
|||||||
|
|
||||||
static IDevice::Ptr create();
|
static IDevice::Ptr create();
|
||||||
static AndroidDeviceInfo androidDeviceInfoFromIDevice(const IDevice *dev);
|
static AndroidDeviceInfo androidDeviceInfoFromIDevice(const IDevice *dev);
|
||||||
static void setAndroidDeviceInfoExtras(IDevice *dev, const AndroidDeviceInfo &info);
|
|
||||||
|
|
||||||
static QString displayNameFromInfo(const AndroidDeviceInfo &info);
|
static QString displayNameFromInfo(const AndroidDeviceInfo &info);
|
||||||
static Utils::Id idFromDeviceInfo(const AndroidDeviceInfo &info);
|
static Utils::Id idFromDeviceInfo(const AndroidDeviceInfo &info);
|
||||||
@@ -66,14 +66,17 @@ public:
|
|||||||
QString avdName() const;
|
QString avdName() const;
|
||||||
int sdkLevel() const;
|
int sdkLevel() const;
|
||||||
|
|
||||||
|
Utils::FilePath avdPath() const;
|
||||||
|
void setAvdPath(const Utils::FilePath &path);
|
||||||
|
|
||||||
QString deviceTypeName() const;
|
QString deviceTypeName() const;
|
||||||
QString androidVersion() const;
|
QString androidVersion() const;
|
||||||
|
|
||||||
|
// AVD specific
|
||||||
QString skinName() const;
|
QString skinName() const;
|
||||||
QString androidTargetName() const;
|
QString androidTargetName() const;
|
||||||
QString sdcardSize() const;
|
QString sdcardSize() const;
|
||||||
QString openGlStatusString() const;
|
QString openGLStatus() const;
|
||||||
// TODO: remove not used
|
|
||||||
AndroidConfig::OpenGl openGlStatus() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void fromMap(const QVariantMap &map) final;
|
void fromMap(const QVariantMap &map) final;
|
||||||
@@ -85,6 +88,11 @@ private:
|
|||||||
bool canAutoDetectPorts() const override;
|
bool canAutoDetectPorts() const override;
|
||||||
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
ProjectExplorer::DeviceProcessSignalOperation::Ptr signalOperation() const override;
|
||||||
QUrl toolControlChannel(const ControlChannelHint &) const override;
|
QUrl toolControlChannel(const ControlChannelHint &) const override;
|
||||||
|
|
||||||
|
QSettings *avdSettings() const;
|
||||||
|
void initAvdSettings();
|
||||||
|
|
||||||
|
std::unique_ptr<QSettings> m_avdSettings;
|
||||||
};
|
};
|
||||||
|
|
||||||
class AndroidDeviceFactory final : public ProjectExplorer::IDeviceFactory
|
class AndroidDeviceFactory final : public ProjectExplorer::IDeviceFactory
|
||||||
|
@@ -54,10 +54,9 @@ bool AndroidDeviceInfo::operator<(const AndroidDeviceInfo &other) const
|
|||||||
|
|
||||||
bool AndroidDeviceInfo::operator==(const AndroidDeviceInfo &other) const
|
bool AndroidDeviceInfo::operator==(const AndroidDeviceInfo &other) const
|
||||||
{
|
{
|
||||||
return serialNumber == other.serialNumber && avdname == other.avdname && cpuAbi == other.cpuAbi
|
return serialNumber == other.serialNumber && avdname == other.avdname
|
||||||
&& avdTarget == other.avdTarget && avdDevice == other.avdDevice
|
&& avdPath == other.avdPath && cpuAbi == other.cpuAbi
|
||||||
&& avdSkin == other.avdSkin && avdSdcardSize == other.avdSdcardSize && sdk == other.sdk
|
&& sdk == other.sdk && state == other.state && type == other.type;
|
||||||
&& state == other.state && type == other.type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device)
|
QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device)
|
||||||
|
@@ -42,13 +42,10 @@ public:
|
|||||||
QString serialNumber;
|
QString serialNumber;
|
||||||
QString avdname;
|
QString avdname;
|
||||||
QStringList cpuAbi;
|
QStringList cpuAbi;
|
||||||
QString avdTarget;
|
|
||||||
QString avdDevice;
|
|
||||||
QString avdSkin;
|
|
||||||
QString avdSdcardSize;
|
|
||||||
int sdk = -1;
|
int sdk = -1;
|
||||||
IDevice::DeviceState state = IDevice::DeviceDisconnected;
|
IDevice::DeviceState state = IDevice::DeviceDisconnected;
|
||||||
IDevice::MachineType type = IDevice::Emulator;
|
IDevice::MachineType type = IDevice::Emulator;
|
||||||
|
Utils::FilePath avdPath;
|
||||||
|
|
||||||
static QStringList adbSelector(const QString &serialNumber);
|
static QStringList adbSelector(const QString &serialNumber);
|
||||||
|
|
||||||
|
@@ -145,10 +145,6 @@ ProjectExplorer::IDevice::Ptr AvdDialog::device() const
|
|||||||
dev->setExtraData(Constants::AndroidAvdName, m_createdAvdInfo.name);
|
dev->setExtraData(Constants::AndroidAvdName, m_createdAvdInfo.name);
|
||||||
dev->setExtraData(Constants::AndroidCpuAbi, {m_createdAvdInfo.abi});
|
dev->setExtraData(Constants::AndroidCpuAbi, {m_createdAvdInfo.abi});
|
||||||
dev->setExtraData(Constants::AndroidSdk, m_createdAvdInfo.systemImage->apiLevel());
|
dev->setExtraData(Constants::AndroidSdk, m_createdAvdInfo.systemImage->apiLevel());
|
||||||
dev->setExtraData(Constants::AndroidAvdSdcard, QString("%1 MB")
|
|
||||||
.arg(m_createdAvdInfo.sdcardSize));
|
|
||||||
dev->setExtraData(Constants::AndroidAvdDevice, m_createdAvdInfo.deviceDefinition);
|
|
||||||
|
|
||||||
return IDevice::Ptr(dev);
|
return IDevice::Ptr(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -46,10 +46,6 @@ const char avdInfoPathKey[] = "Path:";
|
|||||||
const char avdInfoAbiKey[] = "abi.type";
|
const char avdInfoAbiKey[] = "abi.type";
|
||||||
const char avdInfoTargetKey[] = "target";
|
const char avdInfoTargetKey[] = "target";
|
||||||
const char avdInfoErrorKey[] = "Error:";
|
const char avdInfoErrorKey[] = "Error:";
|
||||||
const char avdInfoSdcardKey[] = "Sdcard";
|
|
||||||
const char avdInfoTargetTypeKey[] = "Target";
|
|
||||||
const char avdInfoDeviceKey[] = "Device";
|
|
||||||
const char avdInfoSkinKey[] = "Skin";
|
|
||||||
|
|
||||||
namespace Android {
|
namespace Android {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -81,6 +77,7 @@ static Utils::optional<AndroidDeviceInfo> parseAvd(const QStringList &deviceInfo
|
|||||||
avd.avdname = value;
|
avd.avdname = value;
|
||||||
} else if (valueForKey(avdInfoPathKey, line, &value)) {
|
} else if (valueForKey(avdInfoPathKey, line, &value)) {
|
||||||
const Utils::FilePath avdPath = Utils::FilePath::fromUserInput(value);
|
const Utils::FilePath avdPath = Utils::FilePath::fromUserInput(value);
|
||||||
|
avd.avdPath = avdPath;
|
||||||
if (avdPath.exists()) {
|
if (avdPath.exists()) {
|
||||||
// Get ABI.
|
// Get ABI.
|
||||||
const Utils::FilePath configFile = avdPath.pathAppended("config.ini");
|
const Utils::FilePath configFile = avdPath.pathAppended("config.ini");
|
||||||
@@ -103,14 +100,6 @@ static Utils::optional<AndroidDeviceInfo> parseAvd(const QStringList &deviceInfo
|
|||||||
qCDebug(avdOutputParserLog)
|
qCDebug(avdOutputParserLog)
|
||||||
<< "Avd Parsing: Cannot find sdk API:" << avdInfoFile.toString();
|
<< "Avd Parsing: Cannot find sdk API:" << avdInfoFile.toString();
|
||||||
}
|
}
|
||||||
} else if (valueForKey(avdInfoDeviceKey, line, &value)) {
|
|
||||||
avd.avdDevice = value.remove(0, 2);
|
|
||||||
} else if (valueForKey(avdInfoTargetTypeKey, line, &value)) {
|
|
||||||
avd.avdTarget = value.remove(0, 2);
|
|
||||||
} else if (valueForKey(avdInfoSkinKey, line, &value)) {
|
|
||||||
avd.avdSkin = value.remove(0, 2);
|
|
||||||
} else if (valueForKey(avdInfoSdcardKey, line, &value)) {
|
|
||||||
avd.avdSdcardSize = value.remove(0, 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (avd != AndroidDeviceInfo())
|
if (avd != AndroidDeviceInfo())
|
||||||
|
@@ -58,13 +58,10 @@ void tst_AvdManagerOutputParser::parse_data()
|
|||||||
<< AndroidDeviceInfoList({{"",
|
<< AndroidDeviceInfoList({{"",
|
||||||
"Test",
|
"Test",
|
||||||
{"x86"},
|
{"x86"},
|
||||||
"Google APIs (Google Inc.)",
|
|
||||||
"Galaxy Nexus (Google)",
|
|
||||||
"",
|
|
||||||
"512 MB",
|
|
||||||
-1,
|
-1,
|
||||||
IDevice::DeviceConnected,
|
IDevice::DeviceConnected,
|
||||||
IDevice::Emulator}})
|
IDevice::Emulator,
|
||||||
|
Utils::FilePath::fromString(":Test.avd")}})
|
||||||
<< QStringList();
|
<< QStringList();
|
||||||
|
|
||||||
QTest::newRow("two") << "Available Android Virtual Devices:\n"
|
QTest::newRow("two") << "Available Android Virtual Devices:\n"
|
||||||
@@ -84,23 +81,18 @@ void tst_AvdManagerOutputParser::parse_data()
|
|||||||
<< AndroidDeviceInfoList({{"",
|
<< AndroidDeviceInfoList({{"",
|
||||||
"Test",
|
"Test",
|
||||||
{"x86"},
|
{"x86"},
|
||||||
"Google APIs (Google Inc.)",
|
|
||||||
"Galaxy Nexus (Google)",
|
|
||||||
"",
|
|
||||||
"512 MB",
|
|
||||||
-1,
|
-1,
|
||||||
IDevice::DeviceConnected,
|
IDevice::DeviceConnected,
|
||||||
IDevice::Emulator},
|
IDevice::Emulator,
|
||||||
|
Utils::FilePath::fromString(":Test.avd")},
|
||||||
{"",
|
{"",
|
||||||
"TestTablet",
|
"TestTablet",
|
||||||
{"x86"},
|
{"x86"},
|
||||||
"Google APIs (Google Inc.)",
|
|
||||||
"7in WSVGA (Tablet) (Generic)",
|
|
||||||
"",
|
|
||||||
"256 MB",
|
|
||||||
-1,
|
-1,
|
||||||
IDevice::DeviceConnected,
|
IDevice::DeviceConnected,
|
||||||
IDevice::Emulator}})
|
IDevice::Emulator,
|
||||||
|
Utils::FilePath::fromString(":TestTablet.avd")}}
|
||||||
|
)
|
||||||
<< QStringList();
|
<< QStringList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user