summaryrefslogtreecommitdiffstats
path: root/src/utils/qdroidutils.cpp
diff options
context:
space:
mode:
authorKalle Viironen <kalle.viironen@digia.com>2014-07-04 09:51:36 +0300
committerKalle Viironen <kalle.viironen@digia.com>2014-07-04 09:51:40 +0300
commita0816ae05210bdfdd149cd67938f64b151fa23c0 (patch)
tree5bfd1eb1f3513444f536052809ee2032f29f503b /src/utils/qdroidutils.cpp
parent5cdc15a7b82b7adfd4c5cae85ffb4327593dd076 (diff)
parent64164764fdfe9ed736b7367d573c0daa026b777f (diff)
Merge commit '64164764fdfe9ed736b7367d573c0daa026b777f' into releaseQtEE_v3.1.0
* commit '64164764fdfe9ed736b7367d573c0daa026b777f': Doc: ChangeLog for 3.1.0 release Doc: Android-specific instructions for Qt Creator Kit setup Doc: Add note about crash message when closing an application Fix #ifdef for Android detection Doc: Bump version to 3.1.0 Doc: Update the Supported Platforms page Doc: Fix path for sabre install doc: add documentation for Toradex Apalis iMX6 Doc: injection to eAndroid reference devices Fix Wifi issues on Android 4.4.2 Don't hardcode interface name in getIPAddress() Doc: Update the list of supported platforms Add plugins.qmltypes for Wi-Fi library Change-Id: I73af0af038f8bf9e5f10387b558c428f7a23461c
Diffstat (limited to 'src/utils/qdroidutils.cpp')
-rw-r--r--src/utils/qdroidutils.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp
index d880de9..379fc20 100644
--- a/src/utils/qdroidutils.cpp
+++ b/src/utils/qdroidutils.cpp
@@ -225,14 +225,20 @@ bool QDroidUtils::setDisplayBrightness(quint8 value)
*/
QString QDroidUtils::getIPAddress()
{
- QStringList addresses;
- QNetworkInterface interface = QNetworkInterface::interfaceFromName(QStringLiteral("eth0"));
- QList<QNetworkAddressEntry> entries;
- entries = interface.addressEntries();
- foreach (const QNetworkAddressEntry &entry, entries) {
- addresses.append(entry.ip().toString().split('%').first());
+ QList<QNetworkInterface> availableInterfaces = QNetworkInterface::allInterfaces();
+ if (availableInterfaces.length() > 0) {
+ foreach (const QNetworkInterface &interface, availableInterfaces) {
+ if (interface.flags() & QNetworkInterface::IsRunning
+ && (interface.flags() & QNetworkInterface::IsLoopBack) == 0) {
+ QList<QNetworkAddressEntry> entries = interface.addressEntries();
+ QStringList addresses;
+ foreach (const QNetworkAddressEntry &entry, entries)
+ addresses.append(entry.ip().toString().split('%').first());
+ return addresses.join(QStringLiteral(", "));
+ }
+ }
}
- return addresses.join(QStringLiteral(", "));
+ return QString();
}
/*!