Fix merge conflict. The old onSubmit was a no-op. It now correctly pipes onSubmit to WifiManager#save() with the new WifiConfiguration. On successful save, it displays the new network in the list, and on failure, it displays a toast indicating that the save action failed. Adds a test for the WifiDialog behaviors on this page. Bug: 66177765 Test: make RunSettingsRoboTests, manual - tested with Wifi enabled and disabled, and with networks that were visible and not. Change-Id: I27446aa49bc9efaf1ea1d6c6158928b62ce01ba2
54 lines
1.4 KiB
Java
54 lines
1.4 KiB
Java
package com.android.settings.wrapper;
|
|
|
|
import android.net.wifi.WifiConfiguration;
|
|
import android.net.wifi.WifiManager;
|
|
|
|
/**
|
|
* Wrapper around {@link WifiManager} to facilitate unit testing.
|
|
*
|
|
* TODO: delete this class once robolectric supports Android O
|
|
*/
|
|
public class WifiManagerWrapper {
|
|
private final WifiManager mWifiManager;
|
|
|
|
public WifiManagerWrapper(WifiManager wifiManager) {
|
|
mWifiManager = wifiManager;
|
|
}
|
|
|
|
/**
|
|
* Gets the real WifiManager
|
|
* @return the real WifiManager
|
|
*/
|
|
public WifiManager getWifiManager() {
|
|
return mWifiManager;
|
|
}
|
|
|
|
/**
|
|
* {@link WifiManager#getCurrentNetworkWpsNfcConfigurationToken}
|
|
*/
|
|
public String getCurrentNetworkWpsNfcConfigurationToken() {
|
|
return mWifiManager.getCurrentNetworkWpsNfcConfigurationToken();
|
|
}
|
|
|
|
/**
|
|
* {@link WifiManager#removePasspointConfiguration}
|
|
*/
|
|
public void removePasspointConfiguration(String fqdn) {
|
|
mWifiManager.removePasspointConfiguration(fqdn);
|
|
}
|
|
|
|
/**
|
|
* {@link WifiManager#forget}
|
|
*/
|
|
public void forget(int netId, WifiManager.ActionListener listener) {
|
|
mWifiManager.forget(netId, listener);
|
|
}
|
|
|
|
/**
|
|
* {@link WifiManager#save}
|
|
*/
|
|
public void save(WifiConfiguration config, WifiManager.ActionListener listener) {
|
|
mWifiManager.save(config, listener);
|
|
}
|
|
}
|