Fix interface notification race

In one use case, I see that if we go straight from
wifi client mode to tethering operation, the interface change notifications
are reported in an order that causes to enter tethered state
without actually tethering through connectivity service.

It is because an interface down notification (from wifi going down) comes after
we have started soft ap and we think we have tethered after calling startTethering
and switch to Tethered state

Instead, we should make sure tethering has started before going to Tethered state.

Change-Id: Iba7e8fab0feeb5637d40938862a8638871df8b02
This commit is contained in:
Irfan Sheriff
2011-07-24 14:28:15 -07:00
parent 508e86e757
commit e8daf2a700

View File

@@ -1055,7 +1055,7 @@ public class WifiStateMachine extends StateMachine {
}
}
private void startTethering(ArrayList<String> available) {
private boolean startTethering(ArrayList<String> available) {
boolean wifiAvailable = false;
@@ -1081,18 +1081,20 @@ public class WifiStateMachine extends StateMachine {
} catch (Exception e) {
Log.e(TAG, "Error configuring interface " + intf + ", :" + e);
setWifiApEnabled(null, false);
return;
return false;
}
if(mCm.tether(intf) != ConnectivityManager.TETHER_ERROR_NO_ERROR) {
Log.e(TAG, "Error tethering on " + intf);
setWifiApEnabled(null, false);
return;
return false;
}
break;
return true;
}
}
}
// We found no interfaces to tether
return false;
}
private void stopTethering() {
@@ -3163,8 +3165,9 @@ public class WifiStateMachine extends StateMachine {
break;
case CMD_TETHER_INTERFACE:
ArrayList<String> available = (ArrayList<String>) message.obj;
startTethering(available);
transitionTo(mTetheredState);
if (startTethering(available)) {
transitionTo(mTetheredState);
}
break;
default:
return NOT_HANDLED;