From 9e8e389e99c406c22dadea2987e07cd8e9075aaa Mon Sep 17 00:00:00 2001 From: NissimHadar Date: Fri, 15 Mar 2019 13:38:43 -0700 Subject: [PATCH] Improved detection of device model. --- tools/nitpick/src/TestRunnerMobile.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/nitpick/src/TestRunnerMobile.cpp b/tools/nitpick/src/TestRunnerMobile.cpp index ad5151bcc0..72b3ea5cc9 100644 --- a/tools/nitpick/src/TestRunnerMobile.cpp +++ b/tools/nitpick/src/TestRunnerMobile.cpp @@ -98,6 +98,8 @@ void TestRunnerMobile::connectDevice() { QString line2 = devicesFile.readLine(); const QString DEVICE{ "device" }; + const QString MODEL{ "model" }; + if (line2.contains("unauthorized")) { QMessageBox::critical(0, "Unauthorized device detected", "Please allow USB debugging on device"); } else if (line2.contains(DEVICE)) { @@ -110,10 +112,21 @@ void TestRunnerMobile::connectDevice() { QStringList tokens = line2.split(QRegExp("[\r\n\t ]+")); QString deviceID = tokens[0]; - QString modelID = tokens[3].split(':')[1]; + // Find the model entry + int i; + for (i = 0; i < tokens.size(); ++i) { + if (tokens[i].contains(MODEL)) { + break; + } + } + _modelName = "UNKNOWN"; - if (modelNames.count(modelID) == 1) { - _modelName = modelNames[modelID]; + if (i < tokens.size()) { + QString modelID = tokens[i].split(':')[1]; + + if (modelNames.count(modelID) == 1) { + _modelName = modelNames[modelID]; + } } _detectedDeviceLabel->setText(_modelName + " [" + deviceID + "]");