forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -53,6 +53,7 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
|
||||||
@@ -716,7 +717,14 @@ void AndroidDeviceManager::HandleDevicesListChange(const QString &serialNumber)
|
|||||||
devMgr->setDeviceState(avdId, state);
|
devMgr->setDeviceState(avdId, state);
|
||||||
} else {
|
} else {
|
||||||
const Utils::Id id = Utils::Id(Constants::ANDROID_DEVICE_ID).withSuffix(':' + serial);
|
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)) {
|
if (IDevice::ConstPtr dev = devMgr->find(id)) {
|
||||||
// DeviceManager doens't seem to have a way to directly update the name, if the name
|
// 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.
|
// of the device has changed, remove it and register it again with the new name.
|
||||||
|
Reference in New Issue
Block a user