Merge "WifiStateMachinePrime: activate scan mode"
diff --git a/service/java/com/android/server/wifi/WifiBackupDataParser.java b/service/java/com/android/server/wifi/WifiBackupDataParser.java
new file mode 100644
index 0000000..7699c55
--- /dev/null
+++ b/service/java/com/android/server/wifi/WifiBackupDataParser.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi;
+
+import android.net.wifi.WifiConfiguration;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Interface describing parser of WiFi backup data for each major version.
+ * Note that implementations of this interface should be returned
+ * from {@link WifiBackupRestore#getWifiBackupDataParser()} method based on major version they
+ * belong to.
+ */
+interface WifiBackupDataParser {
+
+    /**
+     * Parses the list of configurations from the provided XML stream.
+     *
+     * @param in            XmlPullParser instance pointing to the XML stream.
+     * @param outerTagDepth depth of the outer tag in the XML document.
+     * @param minorVersion  minor version number parsed from incoming data.
+     * @return List<WifiConfiguration> object if parsing is successful, null otherwise.
+     */
+    List<WifiConfiguration> parseNetworkConfigurationsFromXml(XmlPullParser in, int outerTagDepth,
+            int minorVersion) throws XmlPullParserException, IOException;
+}
diff --git a/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
new file mode 100644
index 0000000..5757321
--- /dev/null
+++ b/service/java/com/android/server/wifi/WifiBackupDataV1Parser.java
@@ -0,0 +1,533 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server.wifi;
+
+import android.net.IpConfiguration;
+import android.net.IpConfiguration.IpAssignment;
+import android.net.IpConfiguration.ProxySettings;
+import android.net.LinkAddress;
+import android.net.NetworkUtils;
+import android.net.ProxyInfo;
+import android.net.RouteInfo;
+import android.net.StaticIpConfiguration;
+import android.net.wifi.WifiConfiguration;
+import android.util.Log;
+import android.util.Pair;
+
+import com.android.server.wifi.util.XmlUtil;
+import com.android.server.wifi.util.XmlUtil.IpConfigurationXmlUtil;
+import com.android.server.wifi.util.XmlUtil.WifiConfigurationXmlUtil;
+
+import org.xmlpull.v1.XmlPullParser;
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.BitSet;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Parser for major version 1 of WiFi backup data.
+ * Contains whitelists of tags for WifiConfiguration and IpConfiguration sections for each of
+ * the minor versions.
+ *
+ * Overall structure of the major version 1 XML schema:
+ * <?xml version='1.0' encoding='utf-8' standalone='yes' ?>
+ * <WifiConfigStore>
+ *  <float name="Version" value="1.0" />
+ *  <NetworkList>
+ *   <Network>
+ *    <WifiConfiguration>
+ *     <string name="ConfigKey">value</string>
+ *     <string name="SSID">value</string>
+ *     <string name="BSSID" />value</string>
+ *     <string name="PreSharedKey" />value</string>
+ *     <string-array name="WEPKeys" num="4">
+ *      <item value="WifiConfigStoreWep1" />
+ *      <item value="WifiConfigStoreWep2" />
+ *      <item value="WifiConfigStoreWep3" />
+ *      <item value="WifiConfigStoreWep3" />
+ *     </string-array>
+ *     ... (other supported tag names in minor version 1: "WEPTxKeyIndex", "HiddenSSID",
+ *          "RequirePMF", "AllowedKeyMgmt", "AllowedProtocols", "AllowedAuthAlgos",
+ *          "AllowedGroupCiphers", "AllowedPairwiseCiphers", "Shared")
+ *    </WifiConfiguration>
+ *    <IpConfiguration>
+ *     <string name="IpAssignment">value</string>
+ *     <string name="ProxySettings">value</string>
+ *      ... (other supported tag names in minor version 1: "LinkAddress", "LinkPrefixLength",
+ *           "GatewayAddress", "DNSServers", "ProxyHost", "ProxyPort", "ProxyPac",
+ *           "ProxyExclusionList")
+ *    </IpConfiguration>
+ *   </Network>
+ *   <Network>
+ *    ... (format as above)
+ *   </Network>
+ *  </NetworkList>
+ * </WifiConfigStore>
+ */
+class WifiBackupDataV1Parser implements WifiBackupDataParser {
+
+    private static final String TAG = "WifiBackupDataV1Parser";
+
+    private static final int HIGHEST_SUPPORTED_MINOR_VERSION = 0;
+
+    // List of tags supported for <WifiConfiguration> section in minor version 0
+    private static final Set<String> WIFI_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS =
+            new HashSet<String>(Arrays.asList(new String[] {
+                WifiConfigurationXmlUtil.XML_TAG_CONFIG_KEY,
+                WifiConfigurationXmlUtil.XML_TAG_SSID,
+                WifiConfigurationXmlUtil.XML_TAG_BSSID,
+                WifiConfigurationXmlUtil.XML_TAG_PRE_SHARED_KEY,
+                WifiConfigurationXmlUtil.XML_TAG_WEP_KEYS,
+                WifiConfigurationXmlUtil.XML_TAG_WEP_TX_KEY_INDEX,
+                WifiConfigurationXmlUtil.XML_TAG_HIDDEN_SSID,
+                WifiConfigurationXmlUtil.XML_TAG_REQUIRE_PMF,
+                WifiConfigurationXmlUtil.XML_TAG_ALLOWED_KEY_MGMT,
+                WifiConfigurationXmlUtil.XML_TAG_ALLOWED_PROTOCOLS,
+                WifiConfigurationXmlUtil.XML_TAG_ALLOWED_AUTH_ALGOS,
+                WifiConfigurationXmlUtil.XML_TAG_ALLOWED_GROUP_CIPHERS,
+                WifiConfigurationXmlUtil.XML_TAG_ALLOWED_PAIRWISE_CIPHERS,
+                WifiConfigurationXmlUtil.XML_TAG_SHARED,
+            }));
+
+    // List of tags supported for <IpConfiguration> section in minor version 0
+    private static final Set<String> IP_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS =
+            new HashSet<String>(Arrays.asList(new String[] {
+                IpConfigurationXmlUtil.XML_TAG_IP_ASSIGNMENT,
+                IpConfigurationXmlUtil.XML_TAG_LINK_ADDRESS,
+                IpConfigurationXmlUtil.XML_TAG_LINK_PREFIX_LENGTH,
+                IpConfigurationXmlUtil.XML_TAG_GATEWAY_ADDRESS,
+                IpConfigurationXmlUtil.XML_TAG_DNS_SERVER_ADDRESSES,
+                IpConfigurationXmlUtil.XML_TAG_PROXY_SETTINGS,
+                IpConfigurationXmlUtil.XML_TAG_PROXY_HOST,
+                IpConfigurationXmlUtil.XML_TAG_PROXY_PORT,
+                IpConfigurationXmlUtil.XML_TAG_PROXY_EXCLUSION_LIST,
+                IpConfigurationXmlUtil.XML_TAG_PROXY_PAC_FILE,
+            }));
+
+    public List<WifiConfiguration> parseNetworkConfigurationsFromXml(XmlPullParser in,
+            int outerTagDepth, int minorVersion) throws XmlPullParserException, IOException {
+        // clamp down the minorVersion to the highest one that this parser version supports
+        if (minorVersion > HIGHEST_SUPPORTED_MINOR_VERSION) {
+            minorVersion = HIGHEST_SUPPORTED_MINOR_VERSION;
+        }
+        // Find the configuration list section.
+        XmlUtil.gotoNextSectionWithName(in, WifiBackupRestore.XML_TAG_SECTION_HEADER_NETWORK_LIST,
+                outerTagDepth);
+        // Find all the configurations within the configuration list section.
+        int networkListTagDepth = outerTagDepth + 1;
+        List<WifiConfiguration> configurations = new ArrayList<>();
+        while (XmlUtil.gotoNextSectionWithNameOrEnd(
+                in, WifiBackupRestore.XML_TAG_SECTION_HEADER_NETWORK, networkListTagDepth)) {
+            WifiConfiguration configuration =
+                    parseNetworkConfigurationFromXml(in, minorVersion, networkListTagDepth);
+            if (configuration != null) {
+                Log.v(TAG, "Parsed Configuration: " + configuration.configKey());
+                configurations.add(configuration);
+            }
+        }
+        return configurations;
+    }
+
+    /**
+     * Parses the configuration data elements from the provided XML stream to a Configuration.
+     *
+     * @param in            XmlPullParser instance pointing to the XML stream.
+     * @param minorVersion  minor version number parsed from incoming data.
+     * @param outerTagDepth depth of the outer tag in the XML document.
+     * @return WifiConfiguration object if parsing is successful, null otherwise.
+     */
+    private WifiConfiguration parseNetworkConfigurationFromXml(XmlPullParser in, int minorVersion,
+            int outerTagDepth) throws XmlPullParserException, IOException {
+        WifiConfiguration configuration = null;
+        int networkTagDepth = outerTagDepth + 1;
+        // Retrieve WifiConfiguration object first.
+        XmlUtil.gotoNextSectionWithName(
+                in, WifiBackupRestore.XML_TAG_SECTION_HEADER_WIFI_CONFIGURATION,
+                networkTagDepth);
+        int configTagDepth = networkTagDepth + 1;
+        configuration = parseWifiConfigurationFromXmlAndValidateConfigKey(in, configTagDepth,
+                minorVersion);
+        if (configuration == null) {
+            return null;
+        }
+        // Now retrieve any IP configuration info.
+        XmlUtil.gotoNextSectionWithName(
+                in, WifiBackupRestore.XML_TAG_SECTION_HEADER_IP_CONFIGURATION, networkTagDepth);
+        IpConfiguration ipConfiguration = parseIpConfigurationFromXml(in, configTagDepth,
+                minorVersion);
+        configuration.setIpConfiguration(ipConfiguration);
+        return configuration;
+    }
+
+    /**
+     * Helper method to parse the WifiConfiguration object and validate the configKey parsed.
+     */
+    private WifiConfiguration parseWifiConfigurationFromXmlAndValidateConfigKey(XmlPullParser in,
+            int outerTagDepth, int minorVersion) throws XmlPullParserException, IOException {
+        Pair<String, WifiConfiguration> parsedConfig =
+                parseWifiConfigurationFromXml(in, outerTagDepth, minorVersion);
+        if (parsedConfig == null || parsedConfig.first == null || parsedConfig.second == null) {
+            return null;
+        }
+        String configKeyParsed = parsedConfig.first;
+        WifiConfiguration configuration = parsedConfig.second;
+        String configKeyCalculated = configuration.configKey();
+        if (!configKeyParsed.equals(configKeyCalculated)) {
+            String configKeyMismatchLog =
+                    "Configuration key does not match. Retrieved: " + configKeyParsed
+                            + ", Calculated: " + configKeyCalculated;
+            if (configuration.shared) {
+                Log.e(TAG, configKeyMismatchLog);
+                return null;
+            } else {
+                // ConfigKey mismatches are expected for private networks because the
+                // UID is not preserved across backup/restore.
+                Log.w(TAG, configKeyMismatchLog);
+            }
+        }
+        return configuration;
+    }
+
+    /**
+     * Parses the configuration data elements from the provided XML stream to a
+     * WifiConfiguration object.
+     * Looping through the tags makes it easy to add elements in the future minor versions if
+     * needed. Unsupported elements will be ignored.
+     *
+     * @param in            XmlPullParser instance pointing to the XML stream.
+     * @param outerTagDepth depth of the outer tag in the XML document.
+     * @param minorVersion  minor version number parsed from incoming data.
+     * @return Pair<Config key, WifiConfiguration object> if parsing is successful, null otherwise.
+     */
+    private static Pair<String, WifiConfiguration> parseWifiConfigurationFromXml(XmlPullParser in,
+            int outerTagDepth, int minorVersion) throws XmlPullParserException, IOException {
+        WifiConfiguration configuration = new WifiConfiguration();
+        String configKeyInData = null;
+        Set<String> supportedTags = getSupportedWifiConfigurationTags(minorVersion);
+
+        // Loop through and parse out all the elements from the stream within this section.
+        while (!XmlUtil.isNextSectionEnd(in, outerTagDepth)) {
+            String[] valueName = new String[1];
+            Object value = XmlUtil.readCurrentValue(in, valueName);
+            String tagName = valueName[0];
+            if (tagName == null) {
+                throw new XmlPullParserException("Missing value name");
+            }
+
+            // ignore the tags that are not supported up until the current minor version
+            if (!supportedTags.contains(tagName)) {
+                Log.w(TAG, "Unsupported tag + \"" + tagName + "\" found in <WifiConfiguration>"
+                        + " section, ignoring.");
+                continue;
+            }
+
+            // note: the below switch case list should contain all tags supported up until the
+            // highest minor version supported by this parser
+            switch (tagName) {
+                case WifiConfigurationXmlUtil.XML_TAG_CONFIG_KEY:
+                    configKeyInData = (String) value;
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_SSID:
+                    configuration.SSID = (String) value;
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_BSSID:
+                    configuration.BSSID = (String) value;
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_PRE_SHARED_KEY:
+                    configuration.preSharedKey = (String) value;
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_WEP_KEYS:
+                    populateWepKeysFromXmlValue(value, configuration.wepKeys);
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_WEP_TX_KEY_INDEX:
+                    configuration.wepTxKeyIndex = (int) value;
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_HIDDEN_SSID:
+                    configuration.hiddenSSID = (boolean) value;
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_REQUIRE_PMF:
+                    configuration.requirePMF = (boolean) value;
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_ALLOWED_KEY_MGMT:
+                    byte[] allowedKeyMgmt = (byte[]) value;
+                    configuration.allowedKeyManagement = BitSet.valueOf(allowedKeyMgmt);
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_ALLOWED_PROTOCOLS:
+                    byte[] allowedProtocols = (byte[]) value;
+                    configuration.allowedProtocols = BitSet.valueOf(allowedProtocols);
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_ALLOWED_AUTH_ALGOS:
+                    byte[] allowedAuthAlgorithms = (byte[]) value;
+                    configuration.allowedAuthAlgorithms = BitSet.valueOf(allowedAuthAlgorithms);
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_ALLOWED_GROUP_CIPHERS:
+                    byte[] allowedGroupCiphers = (byte[]) value;
+                    configuration.allowedGroupCiphers = BitSet.valueOf(allowedGroupCiphers);
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_ALLOWED_PAIRWISE_CIPHERS:
+                    byte[] allowedPairwiseCiphers = (byte[]) value;
+                    configuration.allowedPairwiseCiphers =
+                            BitSet.valueOf(allowedPairwiseCiphers);
+                    break;
+                case WifiConfigurationXmlUtil.XML_TAG_SHARED:
+                    configuration.shared = (boolean) value;
+                    break;
+                default:
+                    // should never happen, since other tags are filtered out earlier
+                    throw new XmlPullParserException(
+                            "Unknown value name found: " + valueName[0]);
+            }
+        }
+        return Pair.create(configKeyInData, configuration);
+    }
+
+    /**
+     * Returns a set of supported tags of <WifiConfiguration> element for all minor versions of
+     * this major version up to and including the specified minorVersion (only adding tags is
+     * supported in minor versions, removal or changing the meaning of tags requires bumping
+     * the major version and reseting the minor to 0).
+     *
+     * @param minorVersion  minor version number parsed from incoming data.
+     */
+    private static Set<String> getSupportedWifiConfigurationTags(int minorVersion) {
+        switch (minorVersion) {
+            case 0: return WIFI_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS;
+            default:
+                Log.e(TAG, "Invalid minorVersion: " + minorVersion);
+                return Collections.<String>emptySet();
+        }
+    }
+
+    /**
+     * Populate wepKeys array elements only if they were non-empty in the backup data.
+     *
+     * @throws XmlPullParserException if parsing errors occur.
+     */
+    private static void populateWepKeysFromXmlValue(Object value, String[] wepKeys)
+            throws XmlPullParserException, IOException {
+        String[] wepKeysInData = (String[]) value;
+        if (wepKeysInData == null) {
+            return;
+        }
+        if (wepKeysInData.length != wepKeys.length) {
+            throw new XmlPullParserException(
+                    "Invalid Wep Keys length: " + wepKeysInData.length);
+        }
+        for (int i = 0; i < wepKeys.length; i++) {
+            if (wepKeysInData[i].isEmpty()) {
+                wepKeys[i] = null;
+            } else {
+                wepKeys[i] = wepKeysInData[i];
+            }
+        }
+    }
+
+    /**
+     * Parses the IP configuration data elements from the provided XML stream to an
+     * IpConfiguration object.
+     *
+     * @param in            XmlPullParser instance pointing to the XML stream.
+     * @param outerTagDepth depth of the outer tag in the XML document.
+     * @param minorVersion  minor version number parsed from incoming data.
+     * @return IpConfiguration object if parsing is successful, null otherwise.
+     */
+    private static IpConfiguration parseIpConfigurationFromXml(XmlPullParser in,
+            int outerTagDepth, int minorVersion) throws XmlPullParserException, IOException {
+        // First parse *all* of the tags in <IpConfiguration> section
+        Set<String> supportedTags = getSupportedIpConfigurationTags(minorVersion);
+
+        String ipAssignmentString = null;
+        String linkAddressString = null;
+        Integer linkPrefixLength = null;
+        String gatewayAddressString = null;
+        String[] dnsServerAddressesString = null;
+        String proxySettingsString = null;
+        String proxyHost = null;
+        int proxyPort = -1;
+        String proxyExclusionList = null;
+        String proxyPacFile = null;
+
+        // Loop through and parse out all the elements from the stream within this section.
+        while (!XmlUtil.isNextSectionEnd(in, outerTagDepth)) {
+            String[] valueName = new String[1];
+            Object value = XmlUtil.readCurrentValue(in, valueName);
+            String tagName = valueName[0];
+            if (tagName == null) {
+                throw new XmlPullParserException("Missing value name");
+            }
+
+            // ignore the tags that are not supported up until the current minor version
+            if (!supportedTags.contains(tagName)) {
+                Log.w(TAG, "Unsupported tag + \"" + tagName + "\" found in <IpConfiguration>"
+                        + " section, ignoring.");
+                continue;
+            }
+
+            // note: the below switch case list should contain all tags supported up until the
+            // highest minor version supported by this parser
+            // should any tags be added in next minor versions, conditional processing of them
+            // also needs to be added in the below code (processing into IpConfiguration object)
+            switch (tagName) {
+                case IpConfigurationXmlUtil.XML_TAG_IP_ASSIGNMENT:
+                    ipAssignmentString = (String) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_LINK_ADDRESS:
+                    linkAddressString = (String) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_LINK_PREFIX_LENGTH:
+                    linkPrefixLength = (Integer) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_GATEWAY_ADDRESS:
+                    gatewayAddressString = (String) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_DNS_SERVER_ADDRESSES:
+                    dnsServerAddressesString = (String[]) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_PROXY_SETTINGS:
+                    proxySettingsString = (String) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_PROXY_HOST:
+                    proxyHost = (String) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_PROXY_PORT:
+                    proxyPort = (int) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_PROXY_EXCLUSION_LIST:
+                    proxyExclusionList = (String) value;
+                    break;
+                case IpConfigurationXmlUtil.XML_TAG_PROXY_PAC_FILE:
+                    proxyPacFile = (String) value;
+                    break;
+                default:
+                    // should never happen, since other tags are filtered out earlier
+                    throw new XmlPullParserException(
+                            "Unknown value name found: " + valueName[0]);
+            }
+        }
+
+        // Now process the values into IpConfiguration object
+        IpConfiguration ipConfiguration = new IpConfiguration();
+        if (ipAssignmentString == null) {
+            throw new XmlPullParserException("IpAssignment was missing in IpConfiguration section");
+        }
+        IpAssignment ipAssignment = IpAssignment.valueOf(ipAssignmentString);
+        ipConfiguration.setIpAssignment(ipAssignment);
+        switch (ipAssignment) {
+            case STATIC:
+                StaticIpConfiguration staticIpConfiguration = new StaticIpConfiguration();
+                if (linkAddressString != null && linkPrefixLength != null) {
+                    LinkAddress linkAddress = new LinkAddress(
+                            NetworkUtils.numericToInetAddress(linkAddressString), linkPrefixLength);
+                    if (linkAddress.getAddress() instanceof Inet4Address) {
+                        staticIpConfiguration.ipAddress = linkAddress;
+                    } else {
+                        Log.w(TAG, "Non-IPv4 address: " + linkAddress);
+                    }
+                }
+                if (gatewayAddressString != null) {
+                    LinkAddress dest = null;
+                    InetAddress gateway = NetworkUtils.numericToInetAddress(gatewayAddressString);
+                    RouteInfo route = new RouteInfo(dest, gateway);
+                    if (route.isIPv4Default()) {
+                        staticIpConfiguration.gateway = gateway;
+                    } else {
+                        Log.w(TAG, "Non-IPv4 default route: " + route);
+                    }
+                }
+                if (dnsServerAddressesString != null) {
+                    for (String dnsServerAddressString : dnsServerAddressesString) {
+                        InetAddress dnsServerAddress =
+                                NetworkUtils.numericToInetAddress(dnsServerAddressString);
+                        staticIpConfiguration.dnsServers.add(dnsServerAddress);
+                    }
+                }
+                ipConfiguration.setStaticIpConfiguration(staticIpConfiguration);
+                break;
+            case DHCP:
+            case UNASSIGNED:
+                break;
+            default:
+                throw new XmlPullParserException("Unknown ip assignment type: " + ipAssignment);
+        }
+
+        // Process the proxy settings next
+        if (proxySettingsString == null) {
+            throw new XmlPullParserException("ProxySettings was missing in"
+                    + " IpConfiguration section");
+        }
+        ProxySettings proxySettings = ProxySettings.valueOf(proxySettingsString);
+        ipConfiguration.setProxySettings(proxySettings);
+        switch (proxySettings) {
+            case STATIC:
+                if (proxyHost == null) {
+                    throw new XmlPullParserException("ProxyHost was missing in"
+                            + " IpConfiguration section");
+                }
+                if (proxyPort == -1) {
+                    throw new XmlPullParserException("ProxyPort was missing in"
+                            + " IpConfiguration section");
+                }
+                if (proxyExclusionList == null) {
+                    throw new XmlPullParserException("ProxyExclusionList was missing in"
+                            + " IpConfiguration section");
+                }
+                ipConfiguration.setHttpProxy(
+                        new ProxyInfo(proxyHost, proxyPort, proxyExclusionList));
+                break;
+            case PAC:
+                if (proxyPacFile == null) {
+                    throw new XmlPullParserException("ProxyPac was missing in"
+                            + " IpConfiguration section");
+                }
+                ipConfiguration.setHttpProxy(new ProxyInfo(proxyPacFile));
+                break;
+            case NONE:
+            case UNASSIGNED:
+                break;
+            default:
+                throw new XmlPullParserException(
+                        "Unknown proxy settings type: " + proxySettings);
+        }
+
+        return ipConfiguration;
+    }
+
+    /**
+     * Returns a set of supported tags of <IpConfiguration> element for all minor versions of
+     * this major version up to and including the specified minorVersion (only adding tags is
+     * supported in minor versions, removal or changing the meaning of tags requires bumping
+     * the major version and reseting the minor to 0).
+     *
+     * @param minorVersion  minor version number parsed from incoming data.
+     */
+    private static Set<String> getSupportedIpConfigurationTags(int minorVersion) {
+        switch (minorVersion) {
+            case 0: return IP_CONFIGURATION_MINOR_V0_SUPPORTED_TAGS;
+            default:
+                Log.e(TAG, "Invalid minorVersion: " + minorVersion);
+                return Collections.<String>emptySet();
+        }
+    }
+}
diff --git a/service/java/com/android/server/wifi/WifiBackupRestore.java b/service/java/com/android/server/wifi/WifiBackupRestore.java
index ae5e411..6b854b1 100644
--- a/service/java/com/android/server/wifi/WifiBackupRestore.java
+++ b/service/java/com/android/server/wifi/WifiBackupRestore.java
@@ -21,7 +21,6 @@
 import android.net.wifi.WifiEnterpriseConfig;
 import android.os.Process;
 import android.util.Log;
-import android.util.Pair;
 import android.util.SparseArray;
 import android.util.Xml;
 
@@ -62,9 +61,27 @@
     private static final String TAG = "WifiBackupRestore";
 
     /**
-     * Current backup data version. This will be incremented for any additions.
+     * Current backup data version.
+     * Note: before Android P this used to be an {@code int}, however support for minor versions
+     * has been added in Android P. Currently this field is a {@code float} representing
+     * "majorVersion.minorVersion" of the backed up data. MinorVersion starts with 0 and should
+     * be incremented when necessary. MajorVersion starts with 1 and bumping it up requires
+     * also resetting minorVersion to 0.
+     *
+     * MajorVersion will be incremented for modifications of the XML schema, excluding additive
+     * modifications in <WifiConfiguration> and/or <IpConfiguration> tags.
+     * Should the major version be bumped up, a new {@link WifiBackupDataParser} parser needs to
+     * be added and returned from {@link getWifiBackupDataParser()}.
+     * Note that bumping up the major version will result in inability to restore the backup
+     * set to those lower versions of SDK_INT that don't support the version.
+     *
+     * MinorVersion will only be incremented for addition of <WifiConfiguration> and/or
+     * <IpConfiguration> tags. Any other modifications to the schema should result in bumping up
+     * the major version and resetting the minor version to 0.
+     * Note that bumping up only the minor version will still allow restoring the backup set to
+     * lower versions of SDK_INT.
      */
-    private static final int CURRENT_BACKUP_DATA_VERSION = 1;
+    private static final float CURRENT_BACKUP_DATA_VERSION = 1.0f;
 
     /** This list of older versions will be used to restore data from older backups. */
     /**
@@ -77,10 +94,11 @@
      */
     private static final String XML_TAG_DOCUMENT_HEADER = "WifiBackupData";
     private static final String XML_TAG_VERSION = "Version";
-    private static final String XML_TAG_SECTION_HEADER_NETWORK_LIST = "NetworkList";
-    private static final String XML_TAG_SECTION_HEADER_NETWORK = "Network";
-    private static final String XML_TAG_SECTION_HEADER_WIFI_CONFIGURATION = "WifiConfiguration";
-    private static final String XML_TAG_SECTION_HEADER_IP_CONFIGURATION = "IpConfiguration";
+
+    static final String XML_TAG_SECTION_HEADER_NETWORK_LIST = "NetworkList";
+    static final String XML_TAG_SECTION_HEADER_NETWORK = "Network";
+    static final String XML_TAG_SECTION_HEADER_WIFI_CONFIGURATION = "WifiConfiguration";
+    static final String XML_TAG_SECTION_HEADER_IP_CONFIGURATION = "IpConfiguration";
 
     /**
      * Regex to mask out passwords in backup data dump.
@@ -207,7 +225,6 @@
             Log.e(TAG, "Invalid backup data received");
             return null;
         }
-
         try {
             if (mVerboseLoggingEnabled) {
                 mDebugLastBackupDataRestored = data;
@@ -221,13 +238,37 @@
             XmlUtil.gotoDocumentStart(in, XML_TAG_DOCUMENT_HEADER);
             int rootTagDepth = in.getDepth();
 
-            int version = (int) XmlUtil.readNextValueWithName(in, XML_TAG_VERSION);
-            if (version < INITIAL_BACKUP_DATA_VERSION || version > CURRENT_BACKUP_DATA_VERSION) {
-                Log.e(TAG, "Invalid version of data: " + version);
-                return null;
-            }
+            int majorVersion = -1;
+            int minorVersion = -1;
+            try {
+                float version = (float) XmlUtil.readNextValueWithName(in, XML_TAG_VERSION);
 
-            return parseNetworkConfigurationsFromXml(in, rootTagDepth, version);
+                // parse out major and minor versions
+                String versionStr = new Float(version).toString();
+                int separatorPos = versionStr.indexOf('.');
+                if (separatorPos == -1) {
+                    majorVersion = Integer.parseInt(versionStr);
+                    minorVersion = 0;
+                } else {
+                    majorVersion = Integer.parseInt(versionStr.substring(0, separatorPos));
+                    minorVersion = Integer.parseInt(versionStr.substring(separatorPos + 1));
+                }
+            } catch (ClassCastException cce) {
+                // Integer cannot be cast to Float for data coming from before Android P
+                majorVersion = 1;
+                minorVersion = 0;
+            }
+            Log.d(TAG, "Version of backup data - major: " + majorVersion
+                    + "; minor: " + minorVersion);
+
+            WifiBackupDataParser parser = getWifiBackupDataParser(majorVersion);
+            if (parser == null) {
+                Log.w(TAG, "Major version of backup data is unknown to this Android"
+                        + " version; not restoring");
+                return null;
+            } else {
+                return parser.parseNetworkConfigurationsFromXml(in, rootTagDepth, minorVersion);
+            }
         } catch (XmlPullParserException | IOException | ClassCastException
                 | IllegalArgumentException e) {
             Log.e(TAG, "Error parsing the backup data: " + e);
@@ -235,96 +276,14 @@
         return null;
     }
 
-    /**
-     * Parses the list of configurations from the provided XML stream.
-     *
-     * @param in            XmlPullParser instance pointing to the XML stream.
-     * @param outerTagDepth depth of the outer tag in the XML document.
-     * @param dataVersion   version number parsed from incoming data.
-     * @return List<WifiConfiguration> object if parsing is successful, null otherwise.
-     */
-    private List<WifiConfiguration> parseNetworkConfigurationsFromXml(
-            XmlPullParser in, int outerTagDepth, int dataVersion)
-            throws XmlPullParserException, IOException {
-        // Find the configuration list section.
-        XmlUtil.gotoNextSectionWithName(in, XML_TAG_SECTION_HEADER_NETWORK_LIST, outerTagDepth);
-        // Find all the configurations within the configuration list section.
-        int networkListTagDepth = outerTagDepth + 1;
-        List<WifiConfiguration> configurations = new ArrayList<>();
-        while (XmlUtil.gotoNextSectionWithNameOrEnd(
-                in, XML_TAG_SECTION_HEADER_NETWORK, networkListTagDepth)) {
-            WifiConfiguration configuration =
-                    parseNetworkConfigurationFromXml(in, dataVersion, networkListTagDepth);
-            if (configuration != null) {
-                Log.v(TAG, "Parsed Configuration: " + configuration.configKey());
-                configurations.add(configuration);
-            }
-        }
-        return configurations;
-    }
-
-    /**
-     * Helper method to parse the WifiConfiguration object and validate the configKey parsed.
-     */
-    private WifiConfiguration parseWifiConfigurationFromXmlAndValidateConfigKey(
-            XmlPullParser in, int outerTagDepth)
-            throws XmlPullParserException, IOException {
-        Pair<String, WifiConfiguration> parsedConfig =
-                WifiConfigurationXmlUtil.parseFromXml(in, outerTagDepth);
-        if (parsedConfig == null || parsedConfig.first == null || parsedConfig.second == null) {
-            return null;
-        }
-        String configKeyParsed = parsedConfig.first;
-        WifiConfiguration configuration = parsedConfig.second;
-        String configKeyCalculated = configuration.configKey();
-        if (!configKeyParsed.equals(configKeyCalculated)) {
-            String configKeyMismatchLog =
-                    "Configuration key does not match. Retrieved: " + configKeyParsed
-                            + ", Calculated: " + configKeyCalculated;
-            if (configuration.shared) {
-                Log.e(TAG, configKeyMismatchLog);
+    private WifiBackupDataParser getWifiBackupDataParser(int majorVersion) {
+        switch (majorVersion) {
+            case INITIAL_BACKUP_DATA_VERSION:
+                return new WifiBackupDataV1Parser();
+            default:
+                Log.e(TAG, "Unrecognized majorVersion of backup data: " + majorVersion);
                 return null;
-            } else {
-                // ConfigKey mismatches are expected for private networks because the
-                // UID is not preserved across backup/restore.
-                Log.w(TAG, configKeyMismatchLog);
-            }
         }
-       return configuration;
-    }
-
-    /**
-     * Parses the configuration data elements from the provided XML stream to a Configuration.
-     *
-     * @param in            XmlPullParser instance pointing to the XML stream.
-     * @param outerTagDepth depth of the outer tag in the XML document.
-     * @param dataVersion   version number parsed from incoming data.
-     * @return WifiConfiguration object if parsing is successful, null otherwise.
-     */
-    private WifiConfiguration parseNetworkConfigurationFromXml(XmlPullParser in, int dataVersion,
-            int outerTagDepth)
-            throws XmlPullParserException, IOException {
-        // Any version migration needs to be handled here in future.
-        if (dataVersion == INITIAL_BACKUP_DATA_VERSION) {
-            WifiConfiguration configuration = null;
-            int networkTagDepth = outerTagDepth + 1;
-            // Retrieve WifiConfiguration object first.
-            XmlUtil.gotoNextSectionWithName(
-                    in, XML_TAG_SECTION_HEADER_WIFI_CONFIGURATION, networkTagDepth);
-            int configTagDepth = networkTagDepth + 1;
-            configuration = parseWifiConfigurationFromXmlAndValidateConfigKey(in, configTagDepth);
-            if (configuration == null) {
-                return null;
-            }
-            // Now retrieve any IP configuration info.
-            XmlUtil.gotoNextSectionWithName(
-                    in, XML_TAG_SECTION_HEADER_IP_CONFIGURATION, networkTagDepth);
-            IpConfiguration ipConfiguration =
-                    IpConfigurationXmlUtil.parseFromXml(in, configTagDepth);
-            configuration.setIpConfiguration(ipConfiguration);
-            return configuration;
-        }
-        return null;
     }
 
     /**
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index ee3c26a..7384a78 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -1587,17 +1587,6 @@
     }
 
     /**
-     * Get the framework network ID corresponding to the provided supplicant network ID for the
-     * network configured in wpa_supplicant.
-     *
-     * @param supplicantNetworkId network ID in wpa_supplicant for the network.
-     * @return Corresponding framework network ID if found, -1 if network not found.
-     */
-    public int getFrameworkNetworkId(int supplicantNetworkId) {
-        return supplicantNetworkId;
-    }
-
-    /**
      * Remove all the networks.
      *
      * @return {@code true} if it succeeds, {@code false} otherwise
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index a93267c..f2d608e 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -1270,20 +1270,6 @@
     }
 
     /**
-     * Helper method to lookup the framework network ID of the network currently configured in
-     * wpa_supplicant using the provided supplicant network ID. This is needed for translating the
-     * networkID received from all {@link WifiMonitor} events.
-     *
-     * @param supplicantNetworkId Network ID of network in wpa_supplicant.
-     * @return Corresponding Internal configured network ID
-     * TODO(b/31080843): This is ugly! We need to hide this translation of networkId's. This will
-     * be handled once we move all of this connection logic to wificond.
-     */
-    private int lookupFrameworkNetworkId(int supplicantNetworkId) {
-        return mWifiNative.getFrameworkNetworkId(supplicantNetworkId);
-    }
-
-    /**
      * Initiates connection to a network specified by the user/app. This method checks if the
      * requesting app holds the NETWORK_SETTINGS permission.
      *
@@ -3211,7 +3197,7 @@
         }
         // Network id and SSID are only valid when we start connecting
         if (SupplicantState.isConnecting(state)) {
-            mWifiInfo.setNetworkId(lookupFrameworkNetworkId(stateChangeResult.networkId));
+            mWifiInfo.setNetworkId(stateChangeResult.networkId);
             mWifiInfo.setBSSID(stateChangeResult.BSSID);
             mWifiInfo.setSSID(stateChangeResult.wifiSsid);
         } else {
@@ -4985,8 +4971,7 @@
                     mBackupManagerProxy.notifyDataChanged();
                     break;
                 case WifiMonitor.SUP_REQUEST_IDENTITY:
-                    int supplicantNetworkId = message.arg2;
-                    netId = lookupFrameworkNetworkId(supplicantNetworkId);
+                    netId = message.arg2;
                     boolean identitySent = false;
                     // For SIM & AKA/AKA' EAP method Only, get identity from ICC
                     if (targetWificonfiguration != null
@@ -4996,7 +4981,7 @@
                                 TelephonyUtil.getSimIdentity(getTelephonyManager(),
                                         targetWificonfiguration);
                         if (identity != null) {
-                            mWifiNative.simIdentityResponse(supplicantNetworkId, identity);
+                            mWifiNative.simIdentityResponse(netId, identity);
                             identitySent = true;
                         } else {
                             Log.e(TAG, "Unable to retrieve identity from Telephony");
@@ -5286,7 +5271,7 @@
                     return NOT_HANDLED;
                 case WifiMonitor.NETWORK_CONNECTION_EVENT:
                     if (mVerboseLoggingEnabled) log("Network connection established");
-                    mLastNetworkId = lookupFrameworkNetworkId(message.arg1);
+                    mLastNetworkId = message.arg1;
                     mWifiConfigManager.clearRecentFailureReason(mLastNetworkId);
                     mLastBssid = (String) message.obj;
                     reasonCode = message.arg2;
@@ -5769,7 +5754,7 @@
                     return NOT_HANDLED;
                 case WifiMonitor.NETWORK_CONNECTION_EVENT:
                     mWifiInfo.setBSSID((String) message.obj);
-                    mLastNetworkId = lookupFrameworkNetworkId(message.arg1);
+                    mLastNetworkId = message.arg1;
                     mWifiInfo.setNetworkId(mLastNetworkId);
                     if(!mLastBssid.equals(message.obj)) {
                         mLastBssid = (String) message.obj;
@@ -6136,7 +6121,7 @@
                         if (mVerboseLoggingEnabled) {
                             log("roaming and Network connection established");
                         }
-                        mLastNetworkId = lookupFrameworkNetworkId(message.arg1);
+                        mLastNetworkId = message.arg1;
                         mLastBssid = (String) message.obj;
                         mWifiInfo.setBSSID(mLastBssid);
                         mWifiInfo.setNetworkId(mLastNetworkId);
@@ -6952,7 +6937,7 @@
     void handleGsmAuthRequest(SimAuthRequestData requestData) {
         if (targetWificonfiguration == null
                 || targetWificonfiguration.networkId
-                == lookupFrameworkNetworkId(requestData.networkId)) {
+                == requestData.networkId) {
             logd("id matches targetWifiConfiguration");
         } else {
             logd("id does not match targetWifiConfiguration");
@@ -6973,7 +6958,7 @@
     void handle3GAuthRequest(SimAuthRequestData requestData) {
         if (targetWificonfiguration == null
                 || targetWificonfiguration.networkId
-                == lookupFrameworkNetworkId(requestData.networkId)) {
+                == requestData.networkId) {
             logd("id matches targetWifiConfiguration");
         } else {
             logd("id does not match targetWifiConfiguration");
diff --git a/service/java/com/android/server/wifi/util/XmlUtil.java b/service/java/com/android/server/wifi/util/XmlUtil.java
index f4c3ab1..5cceca3 100644
--- a/service/java/com/android/server/wifi/util/XmlUtil.java
+++ b/service/java/com/android/server/wifi/util/XmlUtil.java
@@ -296,7 +296,7 @@
     }
 
     /**
-     * Utility class to serialize and deseriaize {@link WifiConfiguration} object to XML &
+     * Utility class to serialize and deserialize {@link WifiConfiguration} object to XML &
      * vice versa.
      * This is used by both {@link com.android.server.wifi.WifiConfigStore} &
      * {@link com.android.server.wifi.WifiBackupRestore} modules.
diff --git a/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java b/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java
index d51f16e..cf6684c 100644
--- a/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java
+++ b/tests/wifitests/src/com/android/server/wifi/CustomTestRunner.java
@@ -20,14 +20,12 @@
 import android.support.test.runner.AndroidJUnitRunner;
 import android.util.Log;
 
-import static org.mockito.Mockito.mock;
-
 public class CustomTestRunner extends AndroidJUnitRunner {
     @Override
     public void onCreate(Bundle arguments) {
         // Override the default TerribleFailureHandler, as that handler might terminate
         // the process (if we're on an eng build).
-        Log.setWtfHandler(mock(Log.TerribleFailureHandler.class));
+        Log.setWtfHandler((tag, what, system) -> Log.e(tag, "WTF", what));
         super.onCreate(arguments);
     }
 }
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java
index 58b8d39..267d00c 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiBackupRestoreTest.java
@@ -19,6 +19,7 @@
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
+import android.net.IpConfiguration;
 import android.net.wifi.WifiConfiguration;
 import android.os.Process;
 import android.test.suitebuilder.annotation.SmallTest;
@@ -51,6 +52,37 @@
 @SmallTest
 public class WifiBackupRestoreTest {
 
+    private static final String WIFI_BACKUP_DATA_WITH_UNSUPPORTED_TAG =
+            "<?xml version='1.0' encoding='utf-8' standalone='yes' ?>"
+            + "<WifiBackupData>"
+            + "<int name=\"Version\" value=\"1\" />"
+            + "<NetworkList>"
+            + "<Network>"
+            + "<WifiConfiguration>"
+            + "<string name=\"ConfigKey\">&quot;GoogleGuest-Legacy&quot;NONE</string>"
+            + "<string name=\"SSID\">&quot;GoogleGuest-Legacy&quot;</string>"
+            + "<null name=\"BSSID\" />"
+            + "<null name=\"PreSharedKey\" />"
+            + "<null name=\"WEPKeys\" />"
+            + "<int name=\"WEPTxKeyIndex\" value=\"0\" />"
+            + "<boolean name=\"HiddenSSID\" value=\"false\" />"
+            + "<boolean name=\"RequirePMF\" value=\"false\" />"
+            + "<byte-array name=\"AllowedKeyMgmt\" num=\"1\">01</byte-array>"
+            + "<byte-array name=\"AllowedProtocols\" num=\"1\">03</byte-array>"
+            + "<byte-array name=\"AllowedAuthAlgos\" num=\"1\">01</byte-array>"
+            + "<byte-array name=\"AllowedGroupCiphers\" num=\"1\">0f</byte-array>"
+            + "<byte-array name=\"AllowedPairwiseCiphers\" num=\"1\">06</byte-array>"
+            + "<boolean name=\"Shared\" value=\"true\" />"
+            + "<null name=\"SimSlot\" />"
+            + "</WifiConfiguration>"
+            + "<IpConfiguration>"
+            + "<string name=\"IpAssignment\">DHCP</string>"
+            + "<string name=\"ProxySettings\">NONE</string>"
+            + "</IpConfiguration>"
+            + "</Network>"
+            + "</NetworkList>"
+            + "</WifiBackupData>";
+
     @Mock WifiPermissionsUtil mWifiPermissionsUtil;
     private WifiBackupRestore mWifiBackupRestore;
     private boolean mCheckDump = true;
@@ -177,6 +209,55 @@
     }
 
     /**
+     * Verify that restoring of configuration that contains unsupported tags works correctly
+     * (unsupported tags are ignored).
+     */
+    @Test
+    public void testConfigurationWithUnsupportedTagsRestore() {
+        List<WifiConfiguration> configurations = new ArrayList<>();
+        configurations.add(createNetworkForConfigurationWithUnsupportedTag());
+
+        byte[] backupData = WIFI_BACKUP_DATA_WITH_UNSUPPORTED_TAG.getBytes();
+        List<WifiConfiguration> retrievedConfigurations =
+                mWifiBackupRestore.retrieveConfigurationsFromBackupData(backupData);
+        WifiConfigurationTestUtil.assertConfigurationsEqualForBackup(
+                configurations, retrievedConfigurations);
+
+        // No valid data to check in dump.
+        mCheckDump = false;
+    }
+
+    /**
+     * Creates correct WiFiConfiguration that should be parsed out of
+     * {@link #WIFI_BACKUP_DATA_WITH_UNSUPPORTED_TAG} configuration which contains unsupported tag.
+     */
+    private static WifiConfiguration createNetworkForConfigurationWithUnsupportedTag() {
+        final WifiConfiguration config = new WifiConfiguration();
+        config.SSID = "\"GoogleGuest-Legacy\"";
+        config.wepTxKeyIndex = 0;
+        config.hiddenSSID = false;
+        config.requirePMF = false;
+        config.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE);
+        config.allowedProtocols.set(WifiConfiguration.Protocol.WPA);
+        config.allowedProtocols.set(WifiConfiguration.Protocol.RSN);
+        config.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN);
+        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40);
+        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104);
+        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP);
+        config.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP);
+        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP);
+        config.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP);
+        config.shared = true;
+
+        IpConfiguration ipConfiguration = new IpConfiguration();
+        ipConfiguration.setIpAssignment(IpConfiguration.IpAssignment.DHCP);
+        ipConfiguration.setProxySettings(IpConfiguration.ProxySettings.NONE);
+        config.setIpConfiguration(ipConfiguration);
+
+        return config;
+    }
+
+    /**
      * Verify that a single WEP network configuration with only 1 key is serialized & deserialized
      * correctly.
      */
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
index 16c9f30..07d75a5 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigurationTestUtil.java
@@ -283,7 +283,6 @@
         return configuration;
     }
 
-
     public static WifiConfiguration createWepNetworkWithSingleKey() {
         WifiConfiguration configuration =
                 generateWifiConfig(TEST_NETWORK_ID, TEST_UID, createNewSSID(), true, true, null,
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index d9bdfe9..8782cfc 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -418,7 +418,6 @@
         when(mWifiNative.getInterfaceName()).thenReturn(WIFI_IFACE_NAME);
         when(mWifiNative.enableSupplicant()).thenReturn(true);
         when(mWifiNative.disableSupplicant()).thenReturn(true);
-        when(mWifiNative.getFrameworkNetworkId(anyInt())).thenReturn(0);
         when(mWifiNative.initializeVendorHal(any(WifiNative.VendorHalDeathEventHandler.class)))
                 .thenReturn(true);
         when(mWifiNative.registerWificondDeathHandler(any())).thenReturn(true);
@@ -2050,8 +2049,6 @@
                 .thenReturn(new NetworkUpdateResult(WPS_FRAMEWORK_NETWORK_ID));
         when(mWifiConfigManager.enableNetwork(eq(WPS_FRAMEWORK_NETWORK_ID), anyBoolean(), anyInt()))
                 .thenReturn(true);
-        when(mWifiNative.getFrameworkNetworkId(eq(WPS_FRAMEWORK_NETWORK_ID))).thenReturn(
-                WPS_FRAMEWORK_NETWORK_ID);
         when(mWifiConfigManager.getConfiguredNetwork(eq(WPS_FRAMEWORK_NETWORK_ID))).thenReturn(
                 config);
     }