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:
Assam Boudjelthia
2021-10-06 22:35:12 +03:00
parent affe3ccf51
commit ec55b1a483
9 changed files with 33 additions and 51 deletions

View File

@@ -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());