Merge "WifiSupplicantControl: Remove this class (Part 1)"
diff --git a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java
index b3b7747..09ee4cc 100644
--- a/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java
+++ b/service/java/com/android/server/wifi/WifiConfigStoreLegacy.java
@@ -76,13 +76,13 @@
      * List of external dependencies for WifiConfigManager.
      */
     private final WifiNetworkHistory mWifiNetworkHistory;
-    private final WifiSupplicantControl mWifiSupplicantControl;
+    private final WifiNative mWifiNative;
     private final IpConfigStore mIpconfigStore;
 
     WifiConfigStoreLegacy(WifiNetworkHistory wifiNetworkHistory,
-            WifiSupplicantControl wifiSupplicantControl, IpConfigStore ipConfigStore) {
+            WifiNative wifiNative, IpConfigStore ipConfigStore) {
         mWifiNetworkHistory = wifiNetworkHistory;
-        mWifiSupplicantControl = wifiSupplicantControl;
+        mWifiNative = wifiNative;
         mIpconfigStore = ipConfigStore;
     }
 
@@ -163,7 +163,7 @@
             Map<String, WifiConfiguration> configurationMap,
             MaskedWpaSupplicantFieldSetter setter) {
         Map<String, String> configKeyToValueMap =
-                mWifiSupplicantControl.readNetworkVariablesFromSupplicantFile(fieldName);
+                mWifiNative.readNetworkVariablesFromSupplicantFile(fieldName);
         if (configKeyToValueMap == null || configKeyToValueMap.isEmpty()) {
             Log.w(TAG, "Cannot retrieve field: " + fieldName + " values");
             return;
@@ -225,7 +225,7 @@
     private void loadFromWpaSupplicant(
             Map<String, WifiConfiguration> configurationMap,
             SparseArray<Map<String, String>> networkExtras) {
-        mWifiSupplicantControl.loadNetworks(configurationMap, networkExtras);
+        mWifiNative.migrateNetworksFromSupplicant(configurationMap, networkExtras);
         if (configurationMap.isEmpty()) {
             Log.w(TAG, "No wifi configurations found in wpa_supplicant");
             return;
@@ -236,7 +236,7 @@
 
     /**
      * Helper function to load from the different legacy stores:
-     * 1. Read the network configurations from wpa_supplicant using {@link WifiSupplicantControl}.
+     * 1. Read the network configurations from wpa_supplicant using {@link WifiNative}.
      * 2. Read the network configurations from networkHistory.txt using {@link WifiNetworkHistory}.
      * 3. Read the Ip configurations from ipconfig.txt using {@link IpConfigStore}.
      * 4. Read all the passpoint info from PerProviderSubscription.conf using
@@ -283,11 +283,11 @@
     public boolean removeStores() {
         // TODO(b/29352330): Delete wpa_supplicant.conf file instead.
         // First remove all networks from wpa_supplicant and save configuration.
-        if (!mWifiSupplicantControl.removeAllNetworks()) {
+        if (!mWifiNative.removeAllNetworks()) {
             Log.e(TAG, "Removing networks from wpa_supplicant failed");
             return false;
         }
-        mWifiSupplicantControl.saveConfig();
+        mWifiNative.saveConfig();
 
         // Now remove the ipconfig.txt file.
         if (!IP_CONFIG_FILE.delete()) {
diff --git a/service/java/com/android/server/wifi/WifiInjector.java b/service/java/com/android/server/wifi/WifiInjector.java
index 84adfd1..55670e2 100644
--- a/service/java/com/android/server/wifi/WifiInjector.java
+++ b/service/java/com/android/server/wifi/WifiInjector.java
@@ -178,9 +178,10 @@
         mWifiNetworkHistory = new WifiNetworkHistory(mContext, mWifiNative.getLocalLog(), writer);
         mWifiSupplicantControl = new WifiSupplicantControl(
                 TelephonyManager.from(mContext), mWifiNative, mWifiNative.getLocalLog());
+        mWifiNative.setWifiSupplicantControl(mWifiSupplicantControl);
         mIpConfigStore = new IpConfigStore(writer);
         mWifiConfigStoreLegacy = new WifiConfigStoreLegacy(
-                mWifiNetworkHistory, mWifiSupplicantControl, mIpConfigStore);
+                mWifiNetworkHistory, mWifiNative, mIpConfigStore);
         // Config Manager
         mWifiConfigManager = new WifiConfigManager(mContext, mFrameworkFacade, mClock,
                 UserManager.get(mContext), TelephonyManager.from(mContext),
@@ -312,10 +313,6 @@
         return mWifiMulticastLockManager;
     }
 
-    public WifiSupplicantControl getWifiSupplicantControl() {
-        return mWifiSupplicantControl;
-    }
-
     public WifiConfigManager getWifiConfigManager() {
         return mWifiConfigManager;
     }
diff --git a/service/java/com/android/server/wifi/WifiNative.java b/service/java/com/android/server/wifi/WifiNative.java
index c22b5b1..44fc5f4 100644
--- a/service/java/com/android/server/wifi/WifiNative.java
+++ b/service/java/com/android/server/wifi/WifiNative.java
@@ -40,6 +40,7 @@
 import android.text.TextUtils;
 import android.util.LocalLog;
 import android.util.Log;
+import android.util.SparseArray;
 
 import com.android.internal.annotations.Immutable;
 import com.android.internal.annotations.VisibleForTesting;
@@ -140,6 +141,7 @@
     private SupplicantP2pIfaceHal mSupplicantP2pIfaceHal;
     private WifiVendorHal mWifiVendorHal;
     private WificondControl mWificondControl;
+    private WifiSupplicantControl mWifiSupplicantControl;
 
     private Context mContext = null;
     public void initContext(Context context) {
@@ -175,6 +177,14 @@
     }
 
 
+    /** Explicitly sets the WifiSupplicantControl instance
+     * TODO(b/34722734): move this into the constructor of WifiNative when I clean up the awful
+     * double singleton pattern
+     */
+    public void setWifiSupplicantControl(WifiSupplicantControl wifiSupplicantControl) {
+        mWifiSupplicantControl = wifiSupplicantControl;
+    }
+
     /**
      * Explicitly sets the WifiVendorHal instance
      * TODO(b/34722734): move this into the constructor of WifiNative when I clean up the awful
@@ -584,13 +594,6 @@
         return doBooleanCommand("REMOVE_NETWORK " + netId);
     }
 
-    /**
-     * Remove all saved networks from wpa_supplicant.
-     */
-    public boolean removeAllNetworks() {
-        return doBooleanCommand("REMOVE_NETWORK all");
-    }
-
     private void logDbg(String debug) {
         long now = SystemClock.elapsedRealtimeNanos();
         String ts = String.format("[%,d us] ", now/1000);
@@ -817,10 +820,6 @@
         doBooleanCommand("SET update_config 1");
     }
 
-    public boolean saveConfig() {
-        return doBooleanCommand("SAVE_CONFIG");
-    }
-
     public boolean addToBlacklist(String bssid) {
         if (TextUtils.isEmpty(bssid)) return false;
         return doBooleanCommand("BLACKLIST " + bssid);
@@ -1412,6 +1411,117 @@
         return doBooleanCommand("NFC_REPORT_HANDOVER RESP P2P " + requestMessage + " 00");
     }
 
+    /** WifiSupplicantControl methods. TODO: These should use HIDL soon. */
+    /**
+     * Migrate all the configured networks from wpa_supplicant.
+     *
+     * @param configs       Map of configuration key to configuration objects corresponding to all
+     *                      the networks.
+     * @param networkExtras Map of extra configuration parameters stored in wpa_supplicant.conf
+     * @return Max priority of all the configs.
+     */
+    public int migrateNetworksFromSupplicant(Map<String, WifiConfiguration> configs,
+                                             SparseArray<Map<String, String>> networkExtras) {
+        return mWifiSupplicantControl.loadNetworks(configs, networkExtras);
+    }
+
+    /**
+     * Add the provided network configuration to wpa_supplicant and initiate connection to it.
+     * This method does the following:
+     * 1. Triggers disconnect command to wpa_supplicant (if |shouldDisconnect| is true).
+     * 2. Remove any existing network in wpa_supplicant.
+     * 3. Add a new network to wpa_supplicant.
+     * 4. Save the provided configuration to wpa_supplicant.
+     * 5. Select the new network in wpa_supplicant.
+     * 6. Triggers reconnect command to wpa_supplicant.
+     *
+     * @param configuration WifiConfiguration parameters for the provided network.
+     * @param shouldDisconnect whether to trigger a disconnection or not.
+     * @return {@code true} if it succeeds, {@code false} otherwise
+     */
+    public boolean connectToNetwork(WifiConfiguration configuration, boolean shouldDisconnect) {
+        return mWifiSupplicantControl.connectToNetwork(configuration, shouldDisconnect);
+    }
+
+    /**
+     * Initiates roaming to the already configured network in wpa_supplicant. If the network
+     * configuration provided does not match the already configured network, then this triggers
+     * a new connection attempt (instead of roam).
+     * 1. First check if we're attempting to connect to the same network as we currently have
+     * configured.
+     * 2. Set the new bssid for the network in wpa_supplicant.
+     * 3. Triggers reassociate command to wpa_supplicant.
+     *
+     * @param configuration WifiConfiguration parameters for the provided network.
+     * @return {@code true} if it succeeds, {@code false} otherwise
+     */
+    public boolean roamToNetwork(WifiConfiguration configuration) {
+        return mWifiSupplicantControl.roamToNetwork(configuration);
+    }
+
+    /**
+     * 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 mWifiSupplicantControl.getFrameworkNetworkId(supplicantNetworkId);
+    }
+
+    /**
+     * Remove all the networks.
+     *
+     * @return {@code true} if it succeeds, {@code false} otherwise
+     */
+    public boolean removeAllNetworks() {
+        if (!doBooleanCommand("REMOVE_NETWORK all")) {
+            Log.e(TAG, "Remove all networks in wpa_supplicant failed");
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Set the BSSID for the currently configured network in wpa_supplicant.
+     *
+     * @return true if successful, false otherwise.
+     */
+    public boolean setConfiguredNetworkBSSID(String bssid) {
+        return mWifiSupplicantControl.setConfiguredNetworkBSSID(bssid);
+    }
+
+    /**
+     * Save the current configuration to wpa_supplicant.conf.
+     */
+    public boolean saveConfig() {
+        return doBooleanCommand("SAVE_CONFIG");
+    }
+
+    /**
+     * Read network variables from wpa_supplicant.conf.
+     *
+     * @param key The parameter to be parsed.
+     * @return Map of corresponding configKey to the value of the param requested.
+     */
+    public Map<String, String> readNetworkVariablesFromSupplicantFile(String key) {
+        return mWifiSupplicantControl.readNetworkVariablesFromSupplicantFile(key);
+    }
+
+    /**
+     * Get Fast BSS Transition capability.
+     */
+    public boolean getSystemSupportsFastBssTransition() {
+        return mWifiSupplicantControl.getSystemSupportsFastBssTransition();
+    }
+
+    /**
+     * Set Fast BSS Transition capability.
+     */
+    public void setSystemSupportsFastBssTransition(boolean supported) {
+        mWifiSupplicantControl.setSystemSupportsFastBssTransition(supported);
+    }
 
     /* kernel logging support */
     private static native byte[] readKernelLogNative();
@@ -3132,5 +3242,4 @@
         Log.e(TAG, "LEGACY HAL th " + cur.getId()
                 + " line " + s.getLineNumber() + " " + s.getMethodName());
     }
-
 }
diff --git a/service/java/com/android/server/wifi/WifiStateMachine.java b/service/java/com/android/server/wifi/WifiStateMachine.java
index 9e93730..8fa52b3 100644
--- a/service/java/com/android/server/wifi/WifiStateMachine.java
+++ b/service/java/com/android/server/wifi/WifiStateMachine.java
@@ -198,7 +198,6 @@
     private WifiMonitor mWifiMonitor;
     private WifiNative mWifiNative;
     private WifiConfigManager mWifiConfigManager;
-    private WifiSupplicantControl mWifiSupplicantControl;
     private WifiConnectivityManager mWifiConnectivityManager;
     private WifiNetworkSelector mWifiNetworkSelector;
     private INetworkManagementService mNwService;
@@ -396,7 +395,7 @@
             logd(dbg + " clearTargetBssid " + bssid + " key=" + config.configKey());
         }
         mTargetRoamBSSID = bssid;
-        return mWifiSupplicantControl.setConfiguredNetworkBSSID(bssid);
+        return mWifiNative.setConfiguredNetworkBSSID(bssid);
     }
 
     /**
@@ -882,8 +881,7 @@
 
         mWifiConfigManager = mWifiInjector.getWifiConfigManager();
         mWifiApConfigStore = mWifiInjector.getWifiApConfigStore();
-        mWifiSupplicantControl = mWifiInjector.getWifiSupplicantControl();
-        mWifiSupplicantControl.setSystemSupportsFastBssTransition(
+        mWifiNative.setSystemSupportsFastBssTransition(
                 mContext.getResources().getBoolean(R.bool.config_wifi_fast_bss_transition_enabled));
 
         mPasspointManager = mWifiInjector.getPasspointManager();
@@ -1250,7 +1248,7 @@
      * be handled once we move all of this connection logic to wificond.
      */
     private int lookupFrameworkNetworkId(int supplicantNetworkId) {
-        return mWifiSupplicantControl.getFrameworkNetworkId(supplicantNetworkId);
+        return mWifiNative.getFrameworkNetworkId(supplicantNetworkId);
     }
 
     /**
@@ -2087,7 +2085,7 @@
         pw.println("mUserWantsSuspendOpt " + mUserWantsSuspendOpt);
         pw.println("mSuspendOptNeedsDisabled " + mSuspendOptNeedsDisabled);
         pw.println("mSystemSupportsFastBssTransition "
-                + mWifiSupplicantControl.getSystemSupportsFastBssTransition());
+                + mWifiNative.getSystemSupportsFastBssTransition());
         if (mCountryCode.getCountryCodeSentToDriver() != null) {
             pw.println("CountryCode sent to driver " + mCountryCode.getCountryCodeSentToDriver());
         } else {
@@ -5015,7 +5013,7 @@
                     reportConnectionAttemptStart(config, mTargetRoamBSSID,
                             WifiMetricsProto.ConnectionEvent.ROAM_UNRELATED);
                     boolean shouldDisconnect = (getCurrentState() != mDisconnectedState);
-                    if (mWifiSupplicantControl.connectToNetwork(config, shouldDisconnect)) {
+                    if (mWifiNative.connectToNetwork(config, shouldDisconnect)) {
                         lastConnectAttemptTimestamp = mClock.getWallClockMillis();
                         targetWificonfiguration = config;
                         mAutoRoaming = false;
@@ -5146,17 +5144,32 @@
                     break;
                 case WifiManager.START_WPS:
                     WpsInfo wpsInfo = (WpsInfo) message.obj;
-                    WpsResult wpsResult;
+                    WpsResult wpsResult = new WpsResult();
                     switch (wpsInfo.setup) {
                         case WpsInfo.PBC:
-                            wpsResult = mWifiSupplicantControl.startWpsPbc(wpsInfo);
+                            if (mWifiNative.startWpsPbc(wpsInfo.BSSID)) {
+                                wpsResult.status = WpsResult.Status.SUCCESS;
+                            } else {
+                                Log.e(TAG, "Failed to start WPS push button configuration");
+                                wpsResult.status = WpsResult.Status.FAILURE;
+                            }
                             break;
                         case WpsInfo.KEYPAD:
-                            wpsResult =
-                                    mWifiSupplicantControl.startWpsWithPinFromAccessPoint(wpsInfo);
+                            if (mWifiNative.startWpsRegistrar(wpsInfo.BSSID, wpsInfo.pin)) {
+                                wpsResult.status = WpsResult.Status.SUCCESS;
+                            } else {
+                                Log.e(TAG, "Failed to start WPS push button configuration");
+                                wpsResult.status = WpsResult.Status.FAILURE;
+                            }
                             break;
                         case WpsInfo.DISPLAY:
-                            wpsResult = mWifiSupplicantControl.startWpsWithPinFromDevice(wpsInfo);
+                            wpsResult.pin = mWifiNative.startWpsPinDisplay(wpsInfo.BSSID);
+                            if (!TextUtils.isEmpty(wpsResult.pin)) {
+                                wpsResult.status = WpsResult.Status.SUCCESS;
+                            } else {
+                                Log.e(TAG, "Failed to start WPS pin method configuration");
+                                wpsResult.status = WpsResult.Status.FAILURE;
+                            }
                             break;
                         default:
                             wpsResult = new WpsResult(Status.FAILURE);
@@ -6182,7 +6195,7 @@
 
                     reportConnectionAttemptStart(config, mTargetRoamBSSID,
                             WifiMetricsProto.ConnectionEvent.ROAM_ENTERPRISE);
-                    if (mWifiSupplicantControl.roamToNetwork(config)) {
+                    if (mWifiNative.roamToNetwork(config)) {
                         lastConnectAttemptTimestamp = mClock.getWallClockMillis();
                         targetWificonfiguration = config;
                         mAutoRoaming = true;
diff --git a/service/java/com/android/server/wifi/WifiSupplicantControl.java b/service/java/com/android/server/wifi/WifiSupplicantControl.java
index 426aea8..8d7b111 100644
--- a/service/java/com/android/server/wifi/WifiSupplicantControl.java
+++ b/service/java/com/android/server/wifi/WifiSupplicantControl.java
@@ -22,8 +22,6 @@
 import android.net.wifi.WifiEnterpriseConfig;
 import android.net.wifi.WifiInfo;
 import android.net.wifi.WifiSsid;
-import android.net.wifi.WpsInfo;
-import android.net.wifi.WpsResult;
 import android.os.FileObserver;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
@@ -690,19 +688,6 @@
     }
 
     /**
-     * Remove all the networks.
-     *
-     * @return {@code true} if it succeeds, {@code false} otherwise
-     */
-    public boolean removeAllNetworks() {
-        if (!mWifiNative.removeAllNetworks()) {
-            loge("Remove all networks in wpa_supplicant failed");
-            return false;
-        }
-        return true;
-    }
-
-    /**
      * Set the BSSID for the currently configured network in wpa_supplicant.
      *
      * @return true if successful, false otherwise.
@@ -717,13 +702,6 @@
     }
 
     /**
-     * Save the current configuration to wpa_supplicant.conf.
-     */
-    public boolean saveConfig() {
-        return mWifiNative.saveConfig();
-    }
-
-    /**
      * Read network variables from wpa_supplicant.conf.
      *
      * @param key The parameter to be parsed.
@@ -805,60 +783,6 @@
         }
         return result;
     }
-
-    /**
-     * Start WPS pin method configuration with pin obtained
-     * from the access point
-     *
-     * @param config WPS configuration
-     * @return Wps result containing status and pin
-     */
-    public WpsResult startWpsWithPinFromAccessPoint(WpsInfo config) {
-        WpsResult result = new WpsResult();
-        if (mWifiNative.startWpsRegistrar(config.BSSID, config.pin)) {
-            result.status = WpsResult.Status.SUCCESS;
-        } else {
-            loge("Failed to start WPS pin method configuration");
-            result.status = WpsResult.Status.FAILURE;
-        }
-        return result;
-    }
-
-    /**
-     * Start WPS pin method configuration with obtained
-     * from the device
-     *
-     * @return WpsResult indicating status and pin
-     */
-    public WpsResult startWpsWithPinFromDevice(WpsInfo config) {
-        WpsResult result = new WpsResult();
-        result.pin = mWifiNative.startWpsPinDisplay(config.BSSID);
-        if (!TextUtils.isEmpty(result.pin)) {
-            result.status = WpsResult.Status.SUCCESS;
-        } else {
-            loge("Failed to start WPS pin method configuration");
-            result.status = WpsResult.Status.FAILURE;
-        }
-        return result;
-    }
-
-    /**
-     * Start WPS push button configuration
-     *
-     * @param config WPS configuration
-     * @return WpsResult indicating status and pin
-     */
-    public WpsResult startWpsPbc(WpsInfo config) {
-        WpsResult result = new WpsResult();
-        if (mWifiNative.startWpsPbc(config.BSSID)) {
-            result.status = WpsResult.Status.SUCCESS;
-        } else {
-            loge("Failed to start WPS push button configuration");
-            result.status = WpsResult.Status.FAILURE;
-        }
-        return result;
-    }
-
     private void logd(String s) {
         Log.d(TAG, s);
     }
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreLegacyTest.java b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreLegacyTest.java
index 060724a..271cc18 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreLegacyTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiConfigStoreLegacyTest.java
@@ -48,7 +48,7 @@
     private static final String MASKED_FIELD_VALUE = "*";
 
     // Test mocks
-    @Mock private WifiSupplicantControl mWifiSupplicantControl;
+    @Mock private WifiNative mWifiNative;
     @Mock private WifiNetworkHistory mWifiNetworkHistory;
     @Mock private IpConfigStore mIpconfigStore;
 
@@ -67,7 +67,7 @@
 
         mWifiConfigStore =
                 new WifiConfigStoreLegacy(
-                        mWifiNetworkHistory, mWifiSupplicantControl, mIpconfigStore);
+                        mWifiNetworkHistory, mWifiNative, mIpconfigStore);
     }
 
     /**
@@ -104,7 +104,7 @@
                 }
                 return 0;
             }
-        }).when(mWifiSupplicantControl).loadNetworks(any(Map.class), any(SparseArray.class));
+        }).when(mWifiNative).migrateNetworksFromSupplicant(any(Map.class), any(SparseArray.class));
 
         // Return the unmasked values during file parsing.
         doAnswer(new AnswerWithArguments() {
@@ -124,7 +124,7 @@
                 }
                 return new HashMap<>();
             }
-        }).when(mWifiSupplicantControl).readNetworkVariablesFromSupplicantFile(anyString());
+        }).when(mWifiNative).readNetworkVariablesFromSupplicantFile(anyString());
 
         WifiConfigStoreLegacy.WifiConfigStoreDataLegacy storeData = mWifiConfigStore.read();
 
diff --git a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
index 1a6b392..9186229 100644
--- a/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
+++ b/tests/wifitests/src/com/android/server/wifi/WifiStateMachineTest.java
@@ -303,7 +303,6 @@
     TestIpManager mTestIpManager;
     TestLooper mLooper;
 
-    @Mock WifiNative mWifiNative;
     @Mock WifiScanner mWifiScanner;
     @Mock SupplicantStateTracker mSupplicantStateTracker;
     @Mock WifiMetrics mWifiMetrics;
@@ -321,7 +320,7 @@
     @Mock IBinder mApInterfaceBinder;
     @Mock IBinder mClientInterfaceBinder;
     @Mock WifiConfigManager mWifiConfigManager;
-    @Mock WifiSupplicantControl mWifiSupplicantControl;
+    @Mock WifiNative mWifiNative;
     @Mock WifiConnectivityManager mWifiConnectivityManager;
     @Mock SoftApManager mSoftApManager;
 
@@ -352,7 +351,6 @@
                 mock(BaseWifiDiagnostics.class));
         when(mWifiInjector.makeWificond()).thenReturn(mWificond);
         when(mWifiInjector.getWifiConfigManager()).thenReturn(mWifiConfigManager);
-        when(mWifiInjector.getWifiSupplicantControl()).thenReturn(mWifiSupplicantControl);
         when(mWifiInjector.getWifiScanner()).thenReturn(mWifiScanner);
         when(mWifiInjector.getWifiNetworkSelector()).thenReturn(mock(WifiNetworkSelector.class));
         when(mWifiInjector.makeWifiConnectivityManager(any(WifiInfo.class), anyBoolean()))
@@ -367,7 +365,7 @@
         when(mWifiNative.getInterfaceName()).thenReturn("mockWlan");
         when(mWifiNative.enableSupplicant()).thenReturn(true);
         when(mWifiNative.disableSupplicant()).thenReturn(true);
-        when(mWifiSupplicantControl.getFrameworkNetworkId(anyInt())).thenReturn(0);
+        when(mWifiNative.getFrameworkNetworkId(anyInt())).thenReturn(0);
 
 
         FrameworkFacade factory = getFrameworkFacade();