Skip to content

Commit

Permalink
[connectionagent] change good connect timer logic.
Browse files Browse the repository at this point in the history
This was causing many disconnect/reconnect when it retried, and
was confusing for some users.

Now this times out in 45 seconds, checks for online state. If it
is still in 'ready' state, will disconnect.

If this is still in association state, presume connman is stuck,
and power cycle the wifi tech, as this is the only way it seems
to be able to reset in this situation.
  • Loading branch information
Lorn Potter committed Feb 6, 2014
1 parent fd42c7c commit 5ad946b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
36 changes: 18 additions & 18 deletions connd/qconnectionmanager.cpp
Expand Up @@ -65,8 +65,7 @@ QConnectionManager::QConnectionManager(QObject *parent) :
tetheringWifiTech(0),
tetheringEnabled(false),
flightModeSuppression(false),
scanTimeoutInterval(1),
numberOfRetries(0)
scanTimeoutInterval(1)
{
qDebug() << Q_FUNC_INFO;

Expand Down Expand Up @@ -129,7 +128,6 @@ QConnectionManager::QConnectionManager(QObject *parent) :
connmanAvailable = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman");
goodConnectTimer = new QTimer(this);
goodConnectTimer->setSingleShot(true);
goodConnectTimer->setInterval(12 * 1000);
connect(goodConnectTimer,SIGNAL(timeout()),this,SLOT(goodConnectionTimeout()));

scanTimer = new QTimer(this);
Expand Down Expand Up @@ -252,18 +250,14 @@ void QConnectionManager::serviceStateChanged(const QString &state)
}
if (state == "disconnect") {
ua->sendConnectReply("Clear");
// Stop the good connect timer when a service disconnects.
if (service->path() == serviceInProgress) {
qDebug() << "stopping good connection timer";
goodConnectTimer->stop();
}
}
if (state == "failure") {
serviceInProgress.clear();
service->requestDisconnect();
}
if (currentNetworkState == "idle" && state == "association") {
qDebug() << "Starting good connection timer";
goodConnectTimer->setInterval(120 * 1000); //2 minutes, same as connman input request timeout
goodConnectTimer->start();
}

Expand All @@ -274,7 +268,6 @@ void QConnectionManager::serviceStateChanged(const QString &state)
manualConnnectionTimer.start();
}

//auto migrate
if (service->path() == serviceInProgress
&& state == "online") {
Q_EMIT connectionState(state, service->type());
Expand Down Expand Up @@ -789,6 +782,10 @@ void QConnectionManager::browserRequest(const QString &servicePath, const QStrin
Q_UNUSED(servicePath)
qDebug() << servicePath;
qDebug() << url;
goodConnectTimer->stop();

goodConnectTimer->setInterval(5 * 60 * 1000);//may take user up to 5 mintues to figure out the passphrase
goodConnectTimer->start();

Q_EMIT requestBrowser(url);
}
Expand Down Expand Up @@ -897,19 +894,22 @@ void QConnectionManager::sleepStateChanged(bool on)

void QConnectionManager::goodConnectionTimeout()
{
qDebug() <<netman->state() << numberOfRetries;
qDebug() <<netman->state();
if (netman->state() != "online") {

if (numberOfRetries < 3) {
numberOfRetries++;
if (servicesMap.contains(serviceInProgress) && servicesMap.value(serviceInProgress)->state() == "ready") {
delayedConnectService = serviceInProgress;
if (servicesMap.contains(serviceInProgress) && servicesMap.value(serviceInProgress)->state() != "idle")
requestDisconnect(serviceInProgress);
} else {
numberOfRetries = 0;
errorReported(serviceInProgress,"limited connection");
serviceInProgress.clear();
requestDisconnect(serviceInProgress);
}
errorReported(serviceInProgress,"connection failure");

if (servicesMap.value(serviceInProgress)->state() == "association"
&& servicesMap.value(serviceInProgress)->type() == "wifi") {
// connman is stuck in association state, we need to do something drastic to reset
netman->getTechnology("wifi")->setPowered(false);
netman->getTechnology("wifi")->setPowered(true);
}
serviceInProgress.clear();
}
}

Expand Down
3 changes: 1 addition & 2 deletions connd/qconnectionmanager.h
Expand Up @@ -45,7 +45,7 @@ class QConnectionManager : public QObject

public:
~QConnectionManager();

static QConnectionManager &instance();
bool askRoaming() const;
void setAskRoaming(bool value);
Expand Down Expand Up @@ -121,7 +121,6 @@ public Q_SLOTS:

QString delayedConnectService;
void delayedConnect();
int numberOfRetries;
QTimer *scanTimer;

QMap <QString, QList <uint> > wifiStrengths;
Expand Down

0 comments on commit 5ad946b

Please sign in to comment.