diff options
author | Kalle Viironen <kalle.viironen@digia.com> | 2014-02-25 13:58:01 +0200 |
---|---|---|
committer | Kalle Viironen <kalle.viironen@digia.com> | 2014-02-25 13:58:07 +0200 |
commit | 4987da748585642b8fcfaa488b1591d47390bb54 (patch) | |
tree | ab5e6b48e711a3c3a2e2cd4399ce1b3d34347406 /src/utils/qdroidutils.cpp | |
parent | 711bfedc706f609cce586406647cfb4ef4547f15 (diff) | |
parent | 4738811e35a559d238ba20703eb792fca8f5756b (diff) |
Merge branch 'stable' into dev
* stable: (28 commits)
Doc: Document support services for Yocto recipes
doc: minor changes to customization inline code blocks
Doc: Clarify which Qt Creator templates work out of the box
Doc: Fix missing sudo for i.MX6 embedded Linux deployment
Doc: Fixed 32bit package install command for newer ubuntu versions
doc: add quide how to use b2qt_build_scripts
Doc: Add instructions how to install newer VirtualBox
[Wifi] Fix initialization code
Doc: Explain about disabling surfaceflinger
Enable internet on eAndroid emulator
Doc: Add instructions for building Boot2Qt demos
Doc: Troubleshooting entry for BeagleBone Black HDMI issues
Don't use wifi on Emulator
Doc: Document building your own embedded linux stack
Update copyright year
Doc: Fix the 2.0 release date
Doc: ChangeLog: Remove 'black screen after exit' from bugfixes
Doc: Use a global Qt documentation template
Doc: Add changelog
Disable QConnectivity daemon on emulator
...
Change-Id: Id524cd8897915b6762210ddece159731c1ef2e67
Diffstat (limited to 'src/utils/qdroidutils.cpp')
-rw-r--r-- | src/utils/qdroidutils.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/src/utils/qdroidutils.cpp b/src/utils/qdroidutils.cpp index 0952345..7ab2098 100644 --- a/src/utils/qdroidutils.cpp +++ b/src/utils/qdroidutils.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc +** Copyright (C) 2014 Digia Plc ** All rights reserved. ** For any questions to Digia, please use the contact form at ** http://qt.digia.com/ @@ -20,16 +20,15 @@ #include <unistd.h> #include <QDebug> #include <math.h> - -#ifdef Q_OS_ANDROID_NO_SDK -#include <cutils/android_reboot.h> -#include <hardware/lights.h> -#include <media/AudioSystem.h> -#else #include <sys/reboot.h> #include <QNetworkInterface> #include <QHostInfo> #include <QFile> + +#ifdef Q_OS_ANDROID_NO_SDK +#include <cutils/properties.h> +#include <hardware/lights.h> +#include <media/AudioSystem.h> #endif /*! @@ -40,11 +39,7 @@ void QDroidUtils::rebootSystem() { sync(); -#ifdef Q_OS_ANDROID_NO_SDK - (void)android_reboot(ANDROID_RB_RESTART, 0, 0); -#else reboot(RB_AUTOBOOT); -#endif qWarning("reboot returned"); } @@ -56,11 +51,7 @@ void QDroidUtils::rebootSystem() void QDroidUtils::powerOffSystem() { sync(); -#ifdef Q_OS_ANDROID_NO_SDK - (void)android_reboot(ANDROID_RB_POWEROFF, 0, 0); -#else reboot(RB_POWER_OFF); -#endif qWarning("powerOff returned"); } @@ -234,16 +225,12 @@ bool QDroidUtils::setDisplayBrightness(quint8 value) QString QDroidUtils::getIPAddress() { QStringList addresses; -#ifdef Q_OS_ANDROID_NO_SDK - qDebug("QDroidUtils::getIPAddress()"); -#else QNetworkInterface interface = QNetworkInterface::interfaceFromName("eth0"); QList<QNetworkAddressEntry> entries; entries = interface.addressEntries(); foreach (const QNetworkAddressEntry &entry, entries) { addresses.append(entry.ip().toString().split('%').first()); } -#endif return addresses.join(QStringLiteral(", ")); } @@ -254,7 +241,10 @@ QString QDroidUtils::getHostname() { QString hostname; #ifdef Q_OS_ANDROID_NO_SDK - qDebug("QDroidUtils::getHostname()"); + char prop_value[PROPERTY_VALUE_MAX]; + int len = property_get("net.hostname", prop_value, 0); + if (len) + hostname = QString::fromLocal8Bit(prop_value, len); #else hostname = QHostInfo::localHostName(); #endif @@ -267,7 +257,7 @@ QString QDroidUtils::getHostname() bool QDroidUtils::setHostname(QString hostname) { #ifdef Q_OS_ANDROID_NO_SDK - qDebug("QDroidUtils::setHostname()"); + property_set("net.hostname", hostname.toLocal8Bit().constData()); #else QFile file("/etc/hostname"); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { |