Remove mWifiTetherRequested
Removing "mWifiTetherRequested" because it might cause Wi-Fi tethering
to not have an upstream if P2P is turned on. The issue could be
recovered when the upstream's capabilities or link properties change,
tethering calls "chooseUpstreamType" to select an upstream. If none of
the above situations happen, Wi-Fi tethering won't have an upstream.
1. When Wifi P2P is enabled and tethering enters TetherModeAliveState.
2. Turning on wifi tethering, TetherModeAliveState would first receive
EVENT_IFACE_SERVING_STATE_INACTIVE when wifi tethering's IpServer
is created and enters IpServer's InitialState. Then it will call
updateUpstreamWanted and change mUpstreamWanted from false to true
before wifi tethering's IpServer actually enters TetheredState.
3. When TetherModeAliveState receives EVENT_IFACE_SERVING_STATE_ACTIVE,
which is triggered by wifi tethering's IpServer entering
TetheredState, it won't call chooseUpstreamType() because
mUpstreamWanted is already true.
case EVENT_IFACE_SERVING_STATE_ACTIVE: {
IpServer who = (IpServer) message.obj;
if (VDBG) Log.d(TAG, "Tether Mode requested by " + who);
handleInterfaceServingStateActive(message.arg1, who);
who.sendMessage(IpServer.CMD_TETHER_CONNECTION_CHANGED,
mCurrentUpstreamIfaceSet);
// If there has been a change and an upstream is now
// desired, kick off the selection process.
final boolean previousUpstreamWanted = updateUpstreamWanted();
if (!previousUpstreamWanted && mUpstreamWanted) {
chooseUpstreamType(true);
}
mWifiTetherRequested is only used to check upstreamWanted() and only be
used in TetherModeAliveState so that it is
safe to remove mWifiTetherRequested and always use mForwardedDownstreams
to check whether upstream is needed for TetherModeAliveState because all
the Tethered IpServer is added to mForwardedDownstreams when it enter
Tethered State and be removed from mForwardedDownstreams when it exit
Tethered State.
This change also move the upstreamWanted() function inside TetherMainSM
to prevent it from being used incorrectly outside of TetherMainSM.
Bug: 329552689
Test: atest TetheringTests
Change-Id: I6842170f455b280dd79aae039a1117d5e6d677f3
2 files changed