am 46b59ef0: Merge "Fix access point parsing: reset static link property after parsing static ip setting Fix removeConfiguredNetwork: add sleep between remove configured network and disable wifi" into honeycomb-mr1
* commit '46b59ef01be530a6bbe3f0e9a2bed27de9985f40': Fix access point parsing: reset static link property after parsing static ip setting Fix removeConfiguredNetwork: add sleep between remove configured network and disable wifi
This commit is contained in:
@@ -182,6 +182,7 @@ public class AccessPointParserHelper {
|
|||||||
}
|
}
|
||||||
config.proxySettings = ProxySettings.NONE;
|
config.proxySettings = ProxySettings.NONE;
|
||||||
networks.add(config);
|
networks.add(config);
|
||||||
|
mLinkProperties = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -242,10 +242,10 @@ public class ConnectivityManagerTestActivity extends Activity {
|
|||||||
|
|
||||||
initializeNetworkStates();
|
initializeNetworkStates();
|
||||||
|
|
||||||
if (mWifiManager.isWifiEnabled()) {
|
mWifiManager.setWifiEnabled(true);
|
||||||
log("Clear Wifi before we start the test.");
|
log("Clear Wifi before we start the test.");
|
||||||
removeConfiguredNetworksAndDisableWifi();
|
sleep(SHORT_TIMEOUT);
|
||||||
}
|
removeConfiguredNetworksAndDisableWifi();
|
||||||
mWifiRegexs = mCM.getTetherableWifiRegexs();
|
mWifiRegexs = mCM.getTetherableWifiRegexs();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -633,13 +633,13 @@ public class ConnectivityManagerTestActivity extends Activity {
|
|||||||
* Disconnect from the current AP and remove configured networks.
|
* Disconnect from the current AP and remove configured networks.
|
||||||
*/
|
*/
|
||||||
public boolean disconnectAP() {
|
public boolean disconnectAP() {
|
||||||
if (mWifiManager.isWifiEnabled()) {
|
// remove saved networks
|
||||||
// remove saved networks
|
List<WifiConfiguration> wifiConfigList = mWifiManager.getConfiguredNetworks();
|
||||||
List<WifiConfiguration> wifiConfigList = mWifiManager.getConfiguredNetworks();
|
log("size of wifiConfigList: " + wifiConfigList.size());
|
||||||
for (WifiConfiguration wifiConfig: wifiConfigList) {
|
for (WifiConfiguration wifiConfig: wifiConfigList) {
|
||||||
log("remove wifi configuration: " + wifiConfig.toString());
|
log("remove wifi configuration: " + wifiConfig.networkId);
|
||||||
mWifiManager.forgetNetwork(wifiConfig.networkId);
|
int netId = wifiConfig.networkId;
|
||||||
}
|
mWifiManager.forgetNetwork(netId);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -655,20 +655,23 @@ public class ConnectivityManagerTestActivity extends Activity {
|
|||||||
* Remove configured networks and disable wifi
|
* Remove configured networks and disable wifi
|
||||||
*/
|
*/
|
||||||
public boolean removeConfiguredNetworksAndDisableWifi() {
|
public boolean removeConfiguredNetworksAndDisableWifi() {
|
||||||
if (!disconnectAP()) {
|
if (!disconnectAP()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Disable Wifi
|
sleep(SHORT_TIMEOUT);
|
||||||
if (!mWifiManager.setWifiEnabled(false)) {
|
if (!mWifiManager.setWifiEnabled(false)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Wait for the actions to be completed
|
sleep(SHORT_TIMEOUT);
|
||||||
try {
|
|
||||||
Thread.sleep(SHORT_TIMEOUT);
|
|
||||||
} catch (InterruptedException e) {}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void sleep(long sleeptime) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(sleeptime);
|
||||||
|
} catch (InterruptedException e) {}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set airplane mode
|
* Set airplane mode
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -72,10 +72,8 @@ public class WifiConnectionTest
|
|||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
log("before we launch the test activity, we preserve all the configured networks.");
|
|
||||||
mRunner = ((ConnectivityManagerTestRunner)getInstrumentation());
|
mRunner = ((ConnectivityManagerTestRunner)getInstrumentation());
|
||||||
mWifiManager = (WifiManager) mRunner.getContext().getSystemService(Context.WIFI_SERVICE);
|
mWifiManager = (WifiManager) mRunner.getContext().getSystemService(Context.WIFI_SERVICE);
|
||||||
enabledNetworks = getEnabledNetworks(mWifiManager.getConfiguredNetworks());
|
|
||||||
|
|
||||||
mAct = getActivity();
|
mAct = getActivity();
|
||||||
mWifiManager.asyncConnect(mAct, new WifiServiceHandler());
|
mWifiManager.asyncConnect(mAct, new WifiServiceHandler());
|
||||||
@@ -123,42 +121,9 @@ public class WifiConnectionTest
|
|||||||
public void tearDown() throws Exception {
|
public void tearDown() throws Exception {
|
||||||
log("tearDown()");
|
log("tearDown()");
|
||||||
mAct.removeConfiguredNetworksAndDisableWifi();
|
mAct.removeConfiguredNetworksAndDisableWifi();
|
||||||
reEnableNetworks(enabledNetworks);
|
|
||||||
super.tearDown();
|
super.tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Set<WifiConfiguration> getEnabledNetworks(List<WifiConfiguration> configuredNetworks) {
|
|
||||||
Set<WifiConfiguration> networks = new HashSet<WifiConfiguration>();
|
|
||||||
for (WifiConfiguration wifiConfig : configuredNetworks) {
|
|
||||||
if (wifiConfig.status == Status.ENABLED || wifiConfig.status == Status.CURRENT) {
|
|
||||||
networks.add(wifiConfig);
|
|
||||||
log("remembering enabled network " + wifiConfig.SSID +
|
|
||||||
" status is " + wifiConfig.status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return networks;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void reEnableNetworks(Set<WifiConfiguration> enabledNetworks) {
|
|
||||||
if (!mWifiManager.isWifiEnabled()) {
|
|
||||||
log("reEnableNetworks: enable Wifi");
|
|
||||||
mWifiManager.setWifiEnabled(true);
|
|
||||||
sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT,
|
|
||||||
"interruped while waiting for wifi to be enabled");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (WifiConfiguration config : enabledNetworks) {
|
|
||||||
if (DEBUG) {
|
|
||||||
log("recover wifi configuration: " + config.toString());
|
|
||||||
}
|
|
||||||
config.SSID = "\"" + config.SSID + "\"";
|
|
||||||
config.networkId = -1;
|
|
||||||
mWifiManager.connectNetwork(config);
|
|
||||||
sleep(ConnectivityManagerTestActivity.SHORT_TIMEOUT,
|
|
||||||
"interruped while connecting to " + config.SSID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connect to the provided Wi-Fi network
|
* Connect to the provided Wi-Fi network
|
||||||
* @param config is the network configuration
|
* @param config is the network configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user