forked from qt-creator/qt-creator
Android: Modernize AndroidDevice a bit
Hidden friends for comparison etc. Change-Id: Ife6fc2b0c231f2f3174d86267cd39f8974b8dfe3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -3,33 +3,28 @@
|
||||
|
||||
#include "androiddeviceinfo.h"
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Android::Internal {
|
||||
|
||||
bool AndroidDeviceInfo::operator<(const AndroidDeviceInfo &other) const
|
||||
bool operator<(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs)
|
||||
{
|
||||
if (serialNumber.contains("????") != other.serialNumber.contains("????"))
|
||||
return !serialNumber.contains("????");
|
||||
if (type != other.type)
|
||||
return type == ProjectExplorer::IDevice::Hardware;
|
||||
if (sdk != other.sdk)
|
||||
return sdk < other.sdk;
|
||||
if (avdName != other.avdName)
|
||||
return avdName < other.avdName;
|
||||
if (lhs.serialNumber.contains("????") != rhs.serialNumber.contains("????"))
|
||||
return !lhs.serialNumber.contains("????");
|
||||
if (lhs.type != rhs.type)
|
||||
return lhs.type == IDevice::Hardware;
|
||||
if (lhs.sdk != rhs.sdk)
|
||||
return lhs.sdk < rhs.sdk;
|
||||
if (lhs.avdName != rhs.avdName)
|
||||
return lhs.avdName < rhs.avdName;
|
||||
|
||||
return serialNumber < other.serialNumber;
|
||||
}
|
||||
|
||||
bool AndroidDeviceInfo::operator==(const AndroidDeviceInfo &other) const
|
||||
{
|
||||
return serialNumber == other.serialNumber && avdName == other.avdName
|
||||
&& avdPath == other.avdPath && cpuAbi == other.cpuAbi
|
||||
&& sdk == other.sdk && state == other.state && type == other.type;
|
||||
return lhs.serialNumber < rhs.serialNumber;
|
||||
}
|
||||
|
||||
QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device)
|
||||
{
|
||||
stream.nospace()
|
||||
<< "Type:" << (device.type == ProjectExplorer::IDevice::Emulator ? "Emulator" : "Device")
|
||||
<< "Type:" << (device.type == IDevice::Emulator ? "Emulator" : "Device")
|
||||
<< ", ABI:" << device.cpuAbi << ", Serial:" << device.serialNumber
|
||||
<< ", Name:" << device.avdName << ", API:" << device.sdk
|
||||
<< ", Authorised:" << (device.state == IDevice::DeviceReadyToUse);
|
||||
|
@@ -10,29 +10,29 @@
|
||||
|
||||
#include <projectexplorer/devicesupport/idevice.h>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Android::Internal {
|
||||
|
||||
class AndroidDeviceInfo
|
||||
{
|
||||
public:
|
||||
bool isValid() const { return !serialNumber.isEmpty() || !avdName.isEmpty(); }
|
||||
|
||||
QString serialNumber;
|
||||
QString avdName;
|
||||
QStringList cpuAbi;
|
||||
int sdk = -1;
|
||||
IDevice::DeviceState state = IDevice::DeviceDisconnected;
|
||||
IDevice::MachineType type = IDevice::Emulator;
|
||||
ProjectExplorer::IDevice::DeviceState state = ProjectExplorer::IDevice::DeviceDisconnected;
|
||||
ProjectExplorer::IDevice::MachineType type = ProjectExplorer::IDevice::Emulator;
|
||||
Utils::FilePath avdPath;
|
||||
|
||||
bool isValid() const { return !serialNumber.isEmpty() || !avdName.isEmpty(); }
|
||||
bool operator<(const AndroidDeviceInfo &other) const;
|
||||
bool operator==(const AndroidDeviceInfo &other) const; // should be = default with C++20
|
||||
bool operator!=(const AndroidDeviceInfo &other) const { return !(*this == other); }
|
||||
private:
|
||||
friend bool operator<(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs);
|
||||
friend bool operator==(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs) = default;
|
||||
friend bool operator!=(const AndroidDeviceInfo &lhs, const AndroidDeviceInfo &rhs) = default;
|
||||
friend QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device);
|
||||
};
|
||||
using AndroidDeviceInfoList = QList<AndroidDeviceInfo>;
|
||||
|
||||
QDebug &operator<<(QDebug &stream, const AndroidDeviceInfo &device);
|
||||
using AndroidDeviceInfoList = QList<AndroidDeviceInfo>;
|
||||
|
||||
} // namespace Android::Internal
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
#include <optional>
|
||||
#include <variant>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace Android::Internal {
|
||||
|
@@ -7,6 +7,7 @@
|
||||
|
||||
using namespace Android;
|
||||
using namespace Android::Internal;
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
class tst_AvdManagerOutputParser : public QObject
|
||||
{
|
||||
|
Reference in New Issue
Block a user