Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[connectionagent] supress autoconnecting when tethering is enabled.
connman will bring cell online when wifi tethering is enabled.
  • Loading branch information
Lorn Potter committed Oct 5, 2013
1 parent 80dbe7f commit 5ce61a2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 20 additions & 2 deletions connd/qconnectionmanager.cpp
Expand Up @@ -61,7 +61,8 @@ QConnectionManager::QConnectionManager(QObject *parent) :
isEthernet(0),
connmanAvailable(0),
handoverInProgress(0),
oContext(0)
oContext(0),
tetheringWifiTech(0)
{
qDebug() << Q_FUNC_INFO;
connect(netman,SIGNAL(availabilityChanged(bool)),this,SLOT(connmanAvailabilityChanged(bool)));
Expand Down Expand Up @@ -286,6 +287,9 @@ bool QConnectionManager::autoConnect()
// }
// }

if (tetheringEnabled)
return false;

if (selectedService.isEmpty()) {
selectedService = findBestConnectableService();
}
Expand Down Expand Up @@ -411,6 +415,7 @@ void QConnectionManager::updateServicesMap()

Q_FOREACH (const QString &tech,techPreferenceList) {
QVector<NetworkService*> services = netman->getServices(tech);

Q_FOREACH (NetworkService *serv, services) {

servicesMap.insert(serv->path(), serv);
Expand Down Expand Up @@ -449,6 +454,7 @@ void QConnectionManager::updateServicesMap()
QObject::connect(serv, SIGNAL(serviceDisconnectionStarted()),
this,SLOT(onServiceDisconnectionStarted()), Qt::UniqueConnection);


}
}
qDebug() << Q_FUNC_INFO << orderedServicesList;
Expand Down Expand Up @@ -636,6 +642,12 @@ void QConnectionManager::setup()
Q_FOREACH(const NetworkTechnology *technology,netman->getTechnologies()) {
connect(technology,SIGNAL(poweredChanged(bool)),this,SLOT(technologyPowerChanged(bool)));
}
if (!tetheringWifiTech) {
tetheringWifiTech = netman->getTechnology("wifi");
}
QObject::connect(tetheringWifiTech, SIGNAL(tetheringChanged(bool)),
this,SLOT(techTetheringChanged(bool)), Qt::UniqueConnection);

}
}

Expand Down Expand Up @@ -673,9 +685,10 @@ bool QConnectionManager::isBestService(const QString &servicePath)
qDebug() << Q_FUNC_INFO
<< servicePath
<< manuallyDisconnectedService;
if (tetheringEnabled) return false;
if (!manuallyDisconnectedService.isEmpty() && manuallyDisconnectedService == servicePath) return false;
if (netman->defaultRoute()->path().contains(servicePath)) return false;
if (!serviceInProgress.isEmpty() && serviceInProgress != servicePath) return false;
// if (!serviceInProgress.isEmpty() && serviceInProgress != servicePath) return false;
if (netman->defaultRoute()->state() != "online") return true;
int dfIndex = orderedServicesList.indexOf(netman->defaultRoute()->path());
if (dfIndex == -1) return true;
Expand Down Expand Up @@ -753,3 +766,8 @@ void QConnectionManager::connectToContext(const QString &servicePath)
qWarning() << "Could not find service path for ofono context";
}

void QConnectionManager::techTetheringChanged(bool b)
{
qDebug() << Q_FUNC_INFO << b;
tetheringEnabled = b;
}
4 changes: 4 additions & 0 deletions connd/qconnectionmanager.h
Expand Up @@ -33,6 +33,7 @@ class ConnAdaptor;
class NetworkManager;
class NetworkService;
class QOfonoConnectionContext;
class NetworkTechnology;

class QConnectionManager : public QObject
{
Expand Down Expand Up @@ -109,6 +110,8 @@ public Q_SLOTS:
void requestDisconnect(const QString &service);
void requestConnect(const QString &service);
QOfonoConnectionContext *oContext;
bool tetheringEnabled;
NetworkTechnology *tetheringWifiTech;

private slots:
void onScanFinished();
Expand All @@ -132,6 +135,7 @@ private slots:

void onServiceDisconnectionStarted();
void connectToContext(const QString &servicePath);
void techTetheringChanged(bool);
};

#endif // QCONNECTIONMANAGER_H

0 comments on commit 5ce61a2

Please sign in to comment.