ActiveModeManager: Start mode managers in a specific role

Currently mode managers are started in 2 steps by ActiveModeWarden:
1. Invoke start() to start the mode manager.
2. Invoke setRole() to set the desired role.

To compensate for this 2 step initialization, we currently start the
ConcreteClientModeManager in scan only role first and then switch (if
necessary) to the appropriate connectivity role (because we don't know
when start is processed if we are going to scan only or connect mode).
This works ok for the primary client mode instance, but causes issues
when secondary client mode managers are created. The secondary managers
will now also start in SCAN_ONLY role and then switch to the appropriate
secondary connectivity role. For external modules interacting with this
secondary client mode instance, they will initially assume that the device
went into scan only mode (i.e wifi was toggled off) when the secondary
client mode manager instance is created and interacts with it before it's
final connectivity role is set in step 2. This for example causes
WakeUpController to start the "wake" feature momentarily when the
secondary client interface is created.
Fix this by starting mode managers in their target role. This helps
secondary ConcreteClientModeManager instances to directly move to the
connect state & corresponding secondary connectivity role.

Also, remove extra battery stats update in
switchPrimaryOrScanOnlyClientModeManager (this will be triggered after
the role switch via onStarted() callback).

Bug: 169878126
Test: atest com.android.server.wifi
Test: Manual steps:
i) Create second STA using peer to peer API (on a STA + STA enabled
device)
ii) Ensure that wakeup feature does not kick in.

Change-Id: I1d91e033a0005179be33ae61e2124e53e978af0c
9 files changed
tree: 17cbfde1cd91ac846e0be89abf574dbbc7ba7bf6
  1. apex/
  2. service/
  3. metrics_pdd_hook.py
  4. PREUPLOAD.cfg