forked from qt-creator/qt-creator
Android: Introduce devicesCommandOutput() helper and reuse it
Change-Id: I098aa17328efcf66a3fb80416e65a2f82d190edc Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
@@ -89,14 +89,7 @@ bool startAvdAsync(const QString &avdName)
|
|||||||
|
|
||||||
QString findAvd(const QString &avdName)
|
QString findAvd(const QString &avdName)
|
||||||
{
|
{
|
||||||
Process adbProcess;
|
const QStringList lines = AndroidConfig::devicesCommandOutput();
|
||||||
adbProcess.setCommand({AndroidConfig::adbToolPath(), {"devices"}});
|
|
||||||
adbProcess.runBlocking();
|
|
||||||
if (adbProcess.result() != ProcessResult::FinishedWithSuccess)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// mid(1) - remove "List of devices attached" header line
|
|
||||||
const QStringList lines = adbProcess.allOutput().split('\n', Qt::SkipEmptyParts).mid(1);
|
|
||||||
for (const QString &line : lines) {
|
for (const QString &line : lines) {
|
||||||
// skip the daemon logs
|
// skip the daemon logs
|
||||||
if (line.startsWith("* daemon"))
|
if (line.startsWith("* daemon"))
|
||||||
|
@@ -674,17 +674,22 @@ FilePath keytoolPath()
|
|||||||
return openJDKBinPath().pathAppended(keytoolName).withExecutableSuffix();
|
return openJDKBinPath().pathAppended(keytoolName).withExecutableSuffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isConnected(const QString &serialNumber)
|
QStringList devicesCommandOutput()
|
||||||
{
|
{
|
||||||
Process adbProcess;
|
Process adbProcess;
|
||||||
adbProcess.setCommand({adbToolPath(), {"devices"}});
|
adbProcess.setCommand({adbToolPath(), {"devices"}});
|
||||||
adbProcess.runBlocking();
|
adbProcess.runBlocking();
|
||||||
if (adbProcess.result() != ProcessResult::FinishedWithSuccess)
|
if (adbProcess.result() != ProcessResult::FinishedWithSuccess)
|
||||||
return false;
|
return {};
|
||||||
|
|
||||||
// mid(1) - remove "List of devices attached" header line.
|
// mid(1) - remove "List of devices attached" header line.
|
||||||
// Example output: "List of devices attached\nemulator-5554\tdevice\n\n".
|
// Example output: "List of devices attached\nemulator-5554\tdevice\n\n".
|
||||||
const QStringList lines = adbProcess.allOutput().split('\n', Qt::SkipEmptyParts).mid(1);
|
return adbProcess.allOutput().split('\n', Qt::SkipEmptyParts).mid(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isConnected(const QString &serialNumber)
|
||||||
|
{
|
||||||
|
const QStringList lines = devicesCommandOutput();
|
||||||
for (const QString &line : lines) {
|
for (const QString &line : lines) {
|
||||||
// skip the daemon logs
|
// skip the daemon logs
|
||||||
if (!line.startsWith("* daemon") && line.left(line.indexOf('\t')).trimmed() == serialNumber)
|
if (!line.startsWith("* daemon") && line.left(line.indexOf('\t')).trimmed() == serialNumber)
|
||||||
|
@@ -89,6 +89,8 @@ Utils::FilePath makePathFromNdk(const Utils::FilePath &ndkLocation);
|
|||||||
|
|
||||||
Utils::FilePath keytoolPath();
|
Utils::FilePath keytoolPath();
|
||||||
|
|
||||||
|
QStringList devicesCommandOutput();
|
||||||
|
|
||||||
QString bestNdkPlatformMatch(int target, const QtSupport::QtVersion *qtVersion);
|
QString bestNdkPlatformMatch(int target, const QtSupport::QtVersion *qtVersion);
|
||||||
|
|
||||||
QLatin1String displayName(const ProjectExplorer::Abi &abi);
|
QLatin1String displayName(const ProjectExplorer::Abi &abi);
|
||||||
|
@@ -151,14 +151,7 @@ static QString emulatorName(const QString &serialNumber)
|
|||||||
|
|
||||||
static QString getRunningAvdsSerialNumber(const QString &name)
|
static QString getRunningAvdsSerialNumber(const QString &name)
|
||||||
{
|
{
|
||||||
Process adbProcess;
|
const QStringList lines = AndroidConfig::devicesCommandOutput();
|
||||||
adbProcess.setCommand({AndroidConfig::adbToolPath(), {"devices"}});
|
|
||||||
adbProcess.runBlocking();
|
|
||||||
if (adbProcess.result() != ProcessResult::FinishedWithSuccess)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
// mid(1) - remove "List of devices attached" header line
|
|
||||||
const QStringList lines = adbProcess.allOutput().split('\n', Qt::SkipEmptyParts).mid(1);
|
|
||||||
for (const QString &line : lines) {
|
for (const QString &line : lines) {
|
||||||
// skip the daemon logs
|
// skip the daemon logs
|
||||||
if (line.startsWith("* daemon"))
|
if (line.startsWith("* daemon"))
|
||||||
|
Reference in New Issue
Block a user