Commit bff8c310 authored by hjk's avatar hjk

Android: Make avd name extraction more robust.

The output of the console seems to have changed lately and includes
some initial help hint now. Try to ignore that by always using the
output before the last OK in the the response.

Change-Id: I1cd5bfedd1aaea9de0d494b92d965ce0c60d1655
Reviewed-by: Christian Stenger's avatarChristian Stenger <christian.stenger@qt.io>
Reviewed-by: Eike Ziller's avatarEike Ziller <eike.ziller@qt.io>
Reviewed-by: default avatarVikas Pachdha <vikas.pachdha@theqtcompany.com>
parent ad1fb8d0
......@@ -917,7 +917,7 @@ QString AndroidConfig::getAvdName(const QString &serialnumber)
if (!ok)
return QString();
QByteArray avdName = "avd name\n";
const QByteArray avdName = "avd name\n";
QTcpSocket tcpSocket;
tcpSocket.connectToHost(QHostAddress(QHostAddress::LocalHost), port);
......@@ -925,16 +925,15 @@ QString AndroidConfig::getAvdName(const QString &serialnumber)
tcpSocket.write(avdName + "exit\n");
tcpSocket.waitForDisconnected();
QByteArray response = tcpSocket.readAll();
int start = response.indexOf("OK\r\n");
if (start == -1)
return QString();
start = start + 4;
int end = response.indexOf("\r\n", start);
if (end == -1)
return QString();
return QString::fromLatin1(response.mid(start, end - start));
QByteArray name;
const QByteArrayList response = tcpSocket.readAll().split('\n');
// The input "avd name" might not be echoed as-is, but contain ASCII
// control sequences.
for (int i = response.size() - 1; i > 1; --i) {
if (response.at(i).startsWith("OK"))
name = response.at(i - 1);
}
return QString::fromLatin1(name).trimmed();
}
AndroidConfig::OpenGl AndroidConfig::getOpenGLEnabled(const QString &emulator) const
......
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