forked from qt-creator/qt-creator
Android: remove AndroidDeviceType and State from AndroidDeviceInfo
No need to have these enums which are now only a duplication of IDevice::MachineType and IDevice::DeviceState. Change-Id: Icc3f112f2670c7354bb282b36fad0f0631b9e047 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -320,7 +320,7 @@ QString AndroidAvdManager::findAvd(const QString &avdName) const
|
||||
{
|
||||
QVector<AndroidDeviceInfo> devices = m_config.connectedDevices();
|
||||
foreach (AndroidDeviceInfo device, devices) {
|
||||
if (device.type != AndroidDeviceInfo::Emulator)
|
||||
if (device.type != ProjectExplorer::IDevice::Emulator)
|
||||
continue;
|
||||
if (device.avdname == avdName)
|
||||
return device.serialNumber;
|
||||
|
||||
@@ -613,17 +613,18 @@ QVector<AndroidDeviceInfo> AndroidConfig::connectedDevices(QString *error) const
|
||||
const QString deviceType = device.mid(device.indexOf('\t')).trimmed();
|
||||
AndroidDeviceInfo dev;
|
||||
dev.serialNumber = serialNo;
|
||||
dev.type = serialNo.startsWith(QLatin1String("emulator")) ? AndroidDeviceInfo::Emulator : AndroidDeviceInfo::Hardware;
|
||||
dev.type = serialNo.startsWith(QLatin1String("emulator")) ? IDevice::Emulator
|
||||
: IDevice::Hardware;
|
||||
dev.sdk = getSDKVersion(dev.serialNumber);
|
||||
dev.cpuAbi = getAbis(dev.serialNumber);
|
||||
if (deviceType == QLatin1String("unauthorized"))
|
||||
dev.state = AndroidDeviceInfo::UnAuthorizedState;
|
||||
dev.state = IDevice::DeviceConnected;
|
||||
else if (deviceType == QLatin1String("offline"))
|
||||
dev.state = AndroidDeviceInfo::OfflineState;
|
||||
dev.state = IDevice::DeviceDisconnected;
|
||||
else
|
||||
dev.state = AndroidDeviceInfo::OkState;
|
||||
dev.state = IDevice::DeviceReadyToUse;
|
||||
|
||||
if (dev.type == AndroidDeviceInfo::Emulator) {
|
||||
if (dev.type == IDevice::Emulator) {
|
||||
dev.avdname = getAvdName(dev.serialNumber);
|
||||
if (dev.avdname.isEmpty())
|
||||
dev.avdname = serialNo;
|
||||
|
||||
@@ -216,14 +216,7 @@ IDevice::Ptr AndroidDevice::create()
|
||||
AndroidDeviceInfo AndroidDevice::androidDeviceInfoFromIDevice(const IDevice *dev)
|
||||
{
|
||||
AndroidDeviceInfo info;
|
||||
AndroidDeviceInfo::State state;
|
||||
if (dev->deviceState() == IDevice::DeviceReadyToUse)
|
||||
state = AndroidDeviceInfo::OkState;
|
||||
else if (dev->deviceState() == IDevice::DeviceDisconnected)
|
||||
state = AndroidDeviceInfo::OfflineState;
|
||||
else if (dev->deviceState() == IDevice::DeviceConnected)
|
||||
state = AndroidDeviceInfo::UnAuthorizedState;
|
||||
info.state = state;
|
||||
info.state = dev->deviceState();
|
||||
info.avdname = dev->extraData(Constants::AndroidAvdName).toString();
|
||||
info.serialNumber = dev->extraData(Constants::AndroidSerialNumber).toString();
|
||||
info.cpuAbi = dev->extraData(Constants::AndroidCpuAbi).toStringList();
|
||||
@@ -232,18 +225,13 @@ AndroidDeviceInfo AndroidDevice::androidDeviceInfoFromIDevice(const IDevice *dev
|
||||
info.avdSkin = dev->extraData(Constants::AndroidAvdSkin).toString();
|
||||
info.avdSdcardSize = dev->extraData(Constants::AndroidAvdSdcard).toString();
|
||||
info.sdk = dev->extraData(Constants::AndroidSdk).toInt();
|
||||
info.type = (dev->machineType() == ProjectExplorer::IDevice::Hardware
|
||||
? AndroidDeviceInfo::Hardware : AndroidDeviceInfo::Emulator);
|
||||
info.type = dev->machineType();
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void AndroidDevice::setAndroidDeviceInfoExtras(IDevice *dev, const AndroidDeviceInfo &info)
|
||||
{
|
||||
dev->setMachineType(info.type == AndroidDeviceInfo::Hardware
|
||||
? ProjectExplorer::IDevice::Hardware
|
||||
: ProjectExplorer::IDevice::Emulator);
|
||||
dev->setDeviceState(deviceStateFromInfo(info.state));
|
||||
dev->setExtraData(Constants::AndroidAvdName, info.avdname);
|
||||
dev->setExtraData(Constants::AndroidSerialNumber, info.serialNumber);
|
||||
dev->setExtraData(Constants::AndroidCpuAbi, info.cpuAbi);
|
||||
@@ -256,15 +244,14 @@ void AndroidDevice::setAndroidDeviceInfoExtras(IDevice *dev, const AndroidDevice
|
||||
|
||||
QString AndroidDevice::displayNameFromInfo(const AndroidDeviceInfo &info)
|
||||
{
|
||||
return info.type == AndroidDeviceInfo::Hardware
|
||||
return info.type == IDevice::Hardware
|
||||
? AndroidConfigurations::currentConfig().getProductModel(info.serialNumber)
|
||||
: info.avdname;
|
||||
}
|
||||
|
||||
Utils::Id AndroidDevice::idFromDeviceInfo(const AndroidDeviceInfo &info)
|
||||
{
|
||||
const QString id = (info.type == AndroidDeviceInfo::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);
|
||||
}
|
||||
|
||||
@@ -273,15 +260,6 @@ Utils::Id AndroidDevice::idFromAvdInfo(const CreateAvdInfo &info)
|
||||
return Utils::Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + info.name);
|
||||
}
|
||||
|
||||
IDevice::DeviceState AndroidDevice::deviceStateFromInfo(AndroidDeviceInfo::State state)
|
||||
{
|
||||
if (state == AndroidDeviceInfo::OkState)
|
||||
return IDevice::DeviceReadyToUse;
|
||||
if (state == AndroidDeviceInfo::OfflineState)
|
||||
return IDevice::DeviceDisconnected;
|
||||
return IDevice::DeviceConnected;
|
||||
}
|
||||
|
||||
QStringList AndroidDevice::supportedAbis() const
|
||||
{
|
||||
return extraData(Constants::AndroidCpuAbi).toStringList();
|
||||
@@ -596,7 +574,7 @@ void AndroidDeviceManager::devicesListUpdated()
|
||||
if (dev->machineType() == IDevice::Emulator && !runningAvds.contains(displayName))
|
||||
newState = IDevice::DeviceConnected;
|
||||
else
|
||||
newState = AndroidDevice::deviceStateFromInfo(item.state);
|
||||
newState = item.state;
|
||||
if (dev->deviceState() != newState) {
|
||||
qCDebug(androidDeviceLog, "Device id \"%s\" changed its state.",
|
||||
dev->id().toString().toUtf8().data());
|
||||
@@ -614,6 +592,8 @@ void AndroidDeviceManager::devicesListUpdated()
|
||||
AndroidDevice *newDev = new AndroidDevice();
|
||||
newDev->setupId(IDevice::AutoDetected, deviceId);
|
||||
newDev->setDisplayName(displayName);
|
||||
newDev->setMachineType(item.type);
|
||||
newDev->setDeviceState(item.state);
|
||||
AndroidDevice::setAndroidDeviceInfoExtras(newDev, item);
|
||||
qCDebug(androidDeviceLog, "Registering new Android device id \"%s\".",
|
||||
newDev->id().toString().toUtf8().data());
|
||||
|
||||
@@ -55,7 +55,6 @@ public:
|
||||
static QString displayNameFromInfo(const AndroidDeviceInfo &info);
|
||||
static Utils::Id idFromDeviceInfo(const AndroidDeviceInfo &info);
|
||||
static Utils::Id idFromAvdInfo(const CreateAvdInfo &info);
|
||||
static IDevice::DeviceState deviceStateFromInfo(AndroidDeviceInfo::State state);
|
||||
|
||||
QStringList supportedAbis() const;
|
||||
bool canSupportAbis(const QStringList &abis) const;
|
||||
|
||||
@@ -43,7 +43,7 @@ bool AndroidDeviceInfo::operator<(const AndroidDeviceInfo &other) const
|
||||
if (serialNumber.contains("????") != other.serialNumber.contains("????"))
|
||||
return !serialNumber.contains("????");
|
||||
if (type != other.type)
|
||||
return type == AndroidDeviceInfo::Hardware;
|
||||
return type == ProjectExplorer::IDevice::Hardware;
|
||||
if (sdk != other.sdk)
|
||||
return sdk < other.sdk;
|
||||
if (avdname != other.avdname)
|
||||
@@ -62,7 +62,7 @@ bool AndroidDeviceInfo::operator==(const AndroidDeviceInfo &other) const
|
||||
|
||||
QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device)
|
||||
{
|
||||
stream << "Type:" << (device.type == AndroidDeviceInfo::Emulator ? "Emulator" : "Device")
|
||||
stream << "Type:" << (device.type == ProjectExplorer::IDevice::Emulator ? "Emulator" : "Device")
|
||||
<< ", ABI:" << device.cpuAbi << ", Serial:" << device.serialNumber
|
||||
<< ", Name:" << device.avdname << ", API:" << device.sdk
|
||||
<< ", Authorised:" << !device.unauthorized;
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Android {
|
||||
|
||||
class AndroidDeviceInfo
|
||||
@@ -44,11 +48,9 @@ public:
|
||||
QString avdSdcardSize;
|
||||
|
||||
int sdk = -1;
|
||||
enum State { OkState, UnAuthorizedState, OfflineState };
|
||||
State state = OfflineState;
|
||||
IDevice::DeviceState state = IDevice::DeviceDisconnected;
|
||||
bool unauthorized = false;
|
||||
enum AndroidDeviceType { Hardware, Emulator };
|
||||
AndroidDeviceType type = Emulator;
|
||||
IDevice::MachineType type = IDevice::Emulator;
|
||||
|
||||
static QStringList adbSelector(const QString &serialNumber);
|
||||
|
||||
|
||||
@@ -558,7 +558,7 @@ void AndroidManager::installQASIPackage(Target *target, const FilePath &packageP
|
||||
return;
|
||||
|
||||
QString deviceSerialNumber = info.serialNumber;
|
||||
if (info.type == AndroidDeviceInfo::Emulator) {
|
||||
if (info.type == IDevice::Emulator) {
|
||||
deviceSerialNumber = AndroidAvdManager().startAvd(info.avdname);
|
||||
if (deviceSerialNumber.isEmpty())
|
||||
Core::MessageManager::writeDisrupting(tr("Starting Android virtual device failed."));
|
||||
|
||||
@@ -134,10 +134,10 @@ AndroidDeviceInfoList parseAvdList(const QString &output, QStringList *avdErrorP
|
||||
}
|
||||
} else if (Utils::optional<AndroidDeviceInfo> avd = parseAvd(avdInfo)) {
|
||||
// armeabi-v7a devices can also run armeabi code
|
||||
if (avd->cpuAbi.contains(ProjectExplorer::Constants::ANDROID_ABI_ARMEABI_V7A))
|
||||
avd->cpuAbi << ProjectExplorer::Constants::ANDROID_ABI_ARMEABI;
|
||||
avd->state = AndroidDeviceInfo::OkState;
|
||||
avd->type = AndroidDeviceInfo::Emulator;
|
||||
if (avd->cpuAbi.contains(Constants::ANDROID_ABI_ARMEABI_V7A))
|
||||
avd->cpuAbi << Constants::ANDROID_ABI_ARMEABI;
|
||||
avd->state = IDevice::DeviceConnected;
|
||||
avd->type = IDevice::Emulator;
|
||||
return AvdResult(*avd);
|
||||
} else {
|
||||
qCDebug(avdOutputParserLog) << "Avd Parsing: Parsing failed: " << avdInfo;
|
||||
|
||||
@@ -63,9 +63,9 @@ void tst_AvdManagerOutputParser::parse_data()
|
||||
"",
|
||||
"512 MB",
|
||||
-1,
|
||||
AndroidDeviceInfo::OkState,
|
||||
IDevice::DeviceConnected,
|
||||
false,
|
||||
AndroidDeviceInfo::Emulator}})
|
||||
IDevice::Emulator}})
|
||||
<< QStringList();
|
||||
|
||||
QTest::newRow("two") << "Available Android Virtual Devices:\n"
|
||||
@@ -90,9 +90,9 @@ void tst_AvdManagerOutputParser::parse_data()
|
||||
"",
|
||||
"512 MB",
|
||||
-1,
|
||||
AndroidDeviceInfo::OkState,
|
||||
IDevice::DeviceConnected,
|
||||
false,
|
||||
AndroidDeviceInfo::Emulator},
|
||||
IDevice::Emulator},
|
||||
{"",
|
||||
"TestTablet",
|
||||
{"x86"},
|
||||
@@ -101,9 +101,9 @@ void tst_AvdManagerOutputParser::parse_data()
|
||||
"",
|
||||
"256 MB",
|
||||
-1,
|
||||
AndroidDeviceInfo::OkState,
|
||||
IDevice::DeviceConnected,
|
||||
false,
|
||||
AndroidDeviceInfo::Emulator}})
|
||||
IDevice::Emulator}})
|
||||
<< QStringList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user