Commit 184abbac authored by Daniel Teske's avatar Daniel Teske

Android: For Emulators show if opengl is enabled or not

Change-Id: Ib20c1f425f91f34749bce837f14ef7a1e36273e3
Task-number: QTCREATORBUG-13615
Reviewed-by: default avatarBogDan Vatra <bogdan@kde.org>
parent 513239bc
......@@ -848,20 +848,51 @@ bool AndroidConfig::isBootToQt(const QString &device) const
return adbProc.readAll().contains("Boot2Qt");
}
int AndroidConfig::getSDKVersion(const QString &device) const
QString AndroidConfig::getDeviceProperty(const QString &device, const QString &property) const
{
// workaround for '????????????' serial numbers
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
arguments << QLatin1String("shell") << QLatin1String("getprop")
<< QLatin1String("ro.build.version.sdk");
<< property;
QProcess adbProc;
adbProc.start(adbToolPath().toString(), arguments);
if (!adbProc.waitForFinished(10000)) {
adbProc.kill();
return QString();
}
return QString::fromLocal8Bit(adbProc.readAll());
}
int AndroidConfig::getSDKVersion(const QString &device) const
{
QString tmp = getDeviceProperty(device, QLatin1String("ro.build.version.sdk"));
if (tmp.isEmpty())
return -1;
return tmp.trimmed().toInt();
}
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 adbProc.readAll().trimmed().toInt();
return OpenGl::Disabled;
}
//!
......@@ -873,20 +904,11 @@ QString AndroidConfig::getProductModel(const QString &device) const
{
if (m_serialNumberToDeviceName.contains(device))
return m_serialNumberToDeviceName.value(device);
// workaround for '????????????' serial numbers
QStringList arguments = AndroidDeviceInfo::adbSelector(device);
arguments << QLatin1String("shell") << QLatin1String("getprop")
<< QLatin1String("ro.product.model");
QProcess adbProc;
adbProc.start(adbToolPath().toString(), arguments);
if (!adbProc.waitForFinished(10000)) {
adbProc.kill();
return device;
}
QString model = QString::fromLocal8Bit(adbProc.readAll().trimmed());
QString model = getDeviceProperty(device, QLatin1String("ro.product.model")).trimmed();
if (model.isEmpty())
return device;
if (!device.startsWith(QLatin1String("????")))
m_serialNumberToDeviceName.insert(device, model);
return model;
......
......@@ -164,6 +164,8 @@ public:
static QLatin1String displayName(const ProjectExplorer::Abi &abi);
QString getProductModel(const QString &device) const;
enum class OpenGl { Enabled, Disabled, Unknown };
OpenGl getOpenGLEnabled(const QString &emulator) const;
bool hasFinishedBooting(const QString &device) const;
bool waitForBooted(const QString &serialNumber, const QFutureInterface<bool> &fi) const;
bool isConnected(const QString &serialNumber) const;
......@@ -172,6 +174,7 @@ public:
private:
static CreateAvdInfo createAVDImpl(CreateAvdInfo info, Utils::FileName androidToolPath, Utils::Environment env);
static QVector<AndroidDeviceInfo> androidVirtualDevicesImpl(const Utils::FileName &androidTool, const Utils::Environment &environment);
QString getDeviceProperty(const QString &device, const QString &property) const;
Utils::FileName toolPath(const ProjectExplorer::Abi &abi, const QString &ndkToolChainVersion) const;
Utils::FileName openJDKBinPath() const;
......
......@@ -169,10 +169,28 @@ public:
topLeft = AndroidConfigurations::currentConfig().getProductModel(device.serialNumber);
painter->drawText(size + 12, 2 + opt.rect.top() + fm.ascent(), topLeft);
QString topRight = device.serialNumber;
// topRight
if (device.type == AndroidDeviceInfo::Hardware) // otherwise it's not very informative
painter->drawText(opt.rect.right() - fm.width(topRight) - 6 , 2 + opt.rect.top() + fm.ascent(), topRight);
auto drawTopRight = [&](const QString text, const QFontMetrics &fm) {
painter->drawText(opt.rect.right() - fm.width(text) - 6 , 2 + opt.rect.top() + fm.ascent(), text);
};
if (device.type == AndroidDeviceInfo::Hardware) {
drawTopRight(device.serialNumber, fm);
} else {
AndroidConfig::OpenGl openGl = AndroidConfigurations::currentConfig().getOpenGLEnabled(device.serialNumber);
if (openGl == AndroidConfig::OpenGl::Enabled) {
drawTopRight(tr("Open GL enabled"), fm);
} else if (openGl == AndroidConfig::OpenGl::Disabled) {
QFont font = painter->font();
font.setBold(true);
painter->setFont(font);
QFontMetrics fmBold(font);
drawTopRight(tr("OpenGL disabled"), fmBold);
font.setBold(false);
painter->setFont(font);
}
}
// Directory
QColor mix;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment