WifiConfigManager: Handle duplicate network adds

When apps add multiple networks with an empty |allowedKeyMgmt| & same
|SSID| field, we end up adding multiple networks with the same config
key currently. This is because the configKey (SSID + allowedKeyMgmt)
changes once the defaults for the network configuration are set (when
the respective fields are empty in the provided config).

Changes in the CL:
1. When a new config is added, first check if we already have a network
with the same configKey in our internal records.
2. If no, create a new network with the defaults set and fields merged
from the external config.
3. Then check again if we have a duplicate network with the same
configKey as the new internal config.
4. If yes, treat this as a network update instead of add.

Refactored existing methods for the above changes.

BUG: 31473411
TEST: Added Unit test fails without the fix.
Change-Id: I2044503d5d14e46412713e9309ae77b018421cf1
2 files changed
tree: 5ccb0b0f86df8fd1d21705fbc7c302652550779d
  1. service/