summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssam Boudjelthia <assam.boudjelthia@qt.io>2022-02-22 21:31:12 +0200
committerAssam Boudjelthia <assam.boudjelthia@qt.io>2022-02-23 17:21:36 +0000
commit0586418f8349f3ed5b36dfdc7efec75b4b17a284 (patch)
treeffeb8712ee2929c51bc546a75e0c8161d464a466
parentef6fbe373fb1463a341f1c88da32c0aa05c3ba39 (diff)
downloadqt-creator-0586418f8349f3ed5b36dfdc7efec75b4b17a284.tar.gz
Android: Differentiate between same devices connected via usb and wifi
ADB allows connecting the same device via USB or WiFi, so we need to make sure the name of the wifi which appears as a different device, make sure it does mean something instead of "Name2" as proposed by default by QC. So this adds the term wifi to the name to make it clear. Change-Id: I5923ca2430c8b51ae2525744dcc1f803ab976b35 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
-rw-r--r--src/plugins/android/androiddevice.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/android/androiddevice.cpp b/src/plugins/android/androiddevice.cpp
index 1ede608bdd..fbecdc1403 100644
--- a/src/plugins/android/androiddevice.cpp
+++ b/src/plugins/android/androiddevice.cpp
@@ -53,6 +53,7 @@
#include <QMessageBox>
#include <QPushButton>
#include <QTimer>
+#include <QRegularExpression>
#include <utils/qtcprocess.h>
@@ -716,7 +717,14 @@ void AndroidDeviceManager::HandleDevicesListChange(const QString &serialNumber)
devMgr->setDeviceState(avdId, state);
} else {
const Utils::Id id = Utils::Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + serial);
- const QString displayName = AndroidConfigurations::currentConfig().getProductModel(serial);
+ QString displayName = AndroidConfigurations::currentConfig().getProductModel(serial);
+ // Check if the device is connected via WiFi. A sample serial of such devices can be
+ // like: "192.168.1.190:5555"
+ const QRegularExpression wifiSerialRegExp(
+ QLatin1String("(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}):(\\d{1,5})"));
+ if (wifiSerialRegExp.match(serial).hasMatch())
+ displayName += QLatin1String(" (WiFi)");
+
if (IDevice::ConstPtr dev = devMgr->find(id)) {
// DeviceManager doens't seem to have a way to directly update the name, if the name
// of the device has changed, remove it and register it again with the new name.