WifiManagerTest: Use addNetwork + enableNetwork instead of save

WifiManager.save() is an asynchronous operation. This is sometime
causing the tests to be flaky (dropShellIdentity occurs while this is
being processed). Use the synchronous legacy API's instead for rewinding
the effects of factory reset.

Bug: 152048238
Test: atest android.net.wifi.cts.WifiManagerTest
Change-Id: Ibb0e04cf931511fcda1b1a81fd6eda4583196c2e
diff --git a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
index 9700ca1..3153149 100644
--- a/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
+++ b/tests/cts/net/src/android/net/wifi/cts/WifiManagerTest.java
@@ -2183,7 +2183,9 @@
             // Restore the original saved networks.
             if (savedNetworks != null) {
                 for (WifiConfiguration network : savedNetworks) {
-                    mWifiManager.save(network, null);
+                    network.networkId = WifiConfiguration.INVALID_NETWORK_ID;
+                    int networkId = mWifiManager.addNetwork(network);
+                    mWifiManager.enableNetwork(networkId, false);
                 }
             }
             uiAutomation.dropShellPermissionIdentity();