Fix quickly toggling airplane mode on then off could leave Wifi disabled

If Wifi is enabled, and we toggle airplane mode on then off quickly,
afterwards wifi could be stuck in the disabled state, even though the
expected behavior is that Wifi return to enabled state. This is due to
a race between CMD_AIRPLANE_TOGGLED and ClientListener.onStopped().

To fix this, defer CMD_AIRPLANE_TOGGLED if we are still processing
a previous CMD_AIRPLANE_TOGGLED.

Bug: 160105640
Test: atest ActiveModeWardenTest
Test: manually toggle airplane mode on then off quickly while wifi is enabled
Change-Id: I8f40dbba0be170a5eca38f0221b4b722cb4b96a4
2 files changed