diff options
author | Gatis Paeglis <gatis.paeglis@digia.com> | 2014-02-07 11:33:40 +0100 |
---|---|---|
committer | Gatis Paeglis <gatis.paeglis@digia.com> | 2014-02-07 12:59:57 +0200 |
commit | 2b81193fa8837116942aed19ed68c00e20cc8ece (patch) | |
tree | 187d1c805419b314a0826a798b4b09ae12e14f1b /src | |
parent | 1b6fd6de76b4491902f519438ca0b8ed7582daa9 (diff) |
Disable QConnectivity daemon on emulator
Once we will know how, we can use this daemon to enable
internet on emulator as well.
Change-Id: I01eaa9a56cecfc92dfc5bc0cfb3ce6c3b482e610
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qconnectivity/main.cpp | 46 |
1 files changed, 33 insertions, 13 deletions
diff --git a/src/qconnectivity/main.cpp b/src/qconnectivity/main.cpp index 4095c45..fb8b857 100644 --- a/src/qconnectivity/main.cpp +++ b/src/qconnectivity/main.cpp @@ -76,6 +76,7 @@ protected slots: void sendReply(QLocalSocket *requester, const QByteArray &reply) const; void updateLease(); void handleError(QLocalSocket::LocalSocketError /*socketError*/) const; + bool isEmulator() const; private: friend class LeaseTimer; @@ -118,22 +119,41 @@ QConnectivityDaemon::QConnectivityDaemon() : m_netdSocket(0), m_serverSocket(0), m_linkUp(false), m_leaseTimer(0) { qDebug() << "starting QConnectivityDaemon..."; + if (isEmulator()) { + // ### TODO - init Internet setup on emulator + } else { + initNetdConnection(); + m_leaseTimer = new LeaseTimer(this); + m_leaseTimer->setSingleShot(true); + connect(m_leaseTimer, SIGNAL(timeout()), this, SLOT(updateLease())); + + int serverFd = socket_local_server("qconnectivity", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); + if (serverFd != -1) { + m_serverSocket = new QLocalServer(this); + if (m_serverSocket->listen(serverFd)) + connect(m_serverSocket, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); + else + qWarning() << "QConnectivityDaemon: not able to listen on the server socket..."; + } else { + qWarning() << "QConnectivityDaemon: failed to open qconnectivity server socket"; + } + } +} - initNetdConnection(); - m_leaseTimer = new LeaseTimer(this); - m_leaseTimer->setSingleShot(true); - connect(m_leaseTimer, SIGNAL(timeout()), this, SLOT(updateLease())); - - int serverFd = socket_local_server("qconnectivity", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); - if (serverFd != -1) { - m_serverSocket = new QLocalServer(this); - if (m_serverSocket->listen(serverFd)) - connect(m_serverSocket, SIGNAL(newConnection()), this, SLOT(handleNewConnection())); - else - qWarning() << "QConnectivityDaemon: not able to listen on the server socket..."; +bool QConnectivityDaemon::isEmulator() const +{ + bool isEmulator = false; + QString content; + QFile conf("/system/bin/appcontroller.conf"); + if (conf.open(QIODevice::ReadOnly)) { + QTextStream stream(&conf); + content = stream.readAll(); + isEmulator = content.contains("platform=emulator"); } else { - qWarning() << "QConnectivityDaemon: failed to open qconnectivity server socket"; + qWarning() << "Failed to read appcontroller.conf"; } + conf.close(); + return isEmulator; } void QConnectivityDaemon::initNetdConnection() |