ClientModeImpl: Reset state on exiting ConnectingOrConnectedState
Add a new parent state for all connection related states called
ConnectingOrConnectedState. This is needed since the previous state
hierarchy does not allow us to transition cleanly from ConnectedState to
ConnectingState (one is in the parent chain of the other). This causes
us to unnecessarily transition out & back into ConnectingState whenever
we trigger connection to a new network while already connected. The
connectingstate will only process events that can happen only while
connecting to a network. Other events that can happen while connected or
connecting is moved to the new parent state.
With this new parent state - ConnectingOrConnectedState, we can now use
the exit() of the state to perform any cleanups needed when not
connected or connecting to a network such as:
a) Set a random MAC address to ensure that we don't leak MAC address
while disconnected. For ex: DPP uses the iface MAC address, so setting
iface MAC address to a random address ensures we don't leak the
factory MAC or any other network's MAC address.
b) Disable the network in supplicant to ensure supplicant does not
trigger any scans or connection on it's own. This has previously caused
various issues like the one tracked in the associated bug. Also, look
at b/70839791 for other historical side-effects of supplicant sometimes
triggering connection on it's own.
Note: I still see a lot of redundant message handling. I want to fix the
state hierarchy working first (& unit tests) before I start cleaning up
duplicated message handling.
Bug: 135503681
Test: atest com.android.server.wifi
Test: ACTS presubmit test.
Test: Ensured that (a) & (b) is performed on disconnect.
Change-Id: Ib6bae0d015021c3c5787294b104a0acd80444732
2 files changed