Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d69ec89f authored by Xia Wang's avatar Xia Wang Committed by Android Git Automerger
Browse files

am 46b59ef0: Merge "Fix access point parsing: reset static link property after...

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 '46b59ef0':
  Fix access point parsing: reset static link property after parsing static ip setting Fix removeConfiguredNetwork: add sleep between remove configured network and disable wifi
parents 34cd123a 46b59ef0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ public class AccessPointParserHelper {
                }
                config.proxySettings = ProxySettings.NONE;
                networks.add(config);
                mLinkProperties = null;
            }
        }

+25 −22
Original line number Diff line number Diff line
@@ -242,10 +242,10 @@ public class ConnectivityManagerTestActivity extends Activity {

        initializeNetworkStates();

        if (mWifiManager.isWifiEnabled()) {
        mWifiManager.setWifiEnabled(true);
        log("Clear Wifi before we start the test.");
        sleep(SHORT_TIMEOUT);
        removeConfiguredNetworksAndDisableWifi();
        }
        mWifiRegexs = mCM.getTetherableWifiRegexs();
     }

@@ -633,13 +633,13 @@ public class ConnectivityManagerTestActivity extends Activity {
     * Disconnect from the current AP and remove configured networks.
     */
    public boolean disconnectAP() {
        if (mWifiManager.isWifiEnabled()) {
        // remove saved networks
        List<WifiConfiguration> wifiConfigList = mWifiManager.getConfiguredNetworks();
        log("size of wifiConfigList: " + wifiConfigList.size());
        for (WifiConfiguration wifiConfig: wifiConfigList) {
                log("remove wifi configuration: " + wifiConfig.toString());
                mWifiManager.forgetNetwork(wifiConfig.networkId);
            }
            log("remove wifi configuration: " + wifiConfig.networkId);
            int netId = wifiConfig.networkId;
            mWifiManager.forgetNetwork(netId);
        }
        return true;
    }
@@ -658,15 +658,18 @@ public class ConnectivityManagerTestActivity extends Activity {
        if (!disconnectAP()) {
           return false;
        }
            // Disable Wifi
        sleep(SHORT_TIMEOUT);
        if (!mWifiManager.setWifiEnabled(false)) {
            return false;
        }
            // Wait for the actions to be completed
        sleep(SHORT_TIMEOUT);
        return true;
    }

    private void sleep(long sleeptime) {
        try {
                Thread.sleep(SHORT_TIMEOUT);
            Thread.sleep(sleeptime);
        } catch (InterruptedException e) {}
        return true;
    }

    /**
+0 −35
Original line number Diff line number Diff line
@@ -72,10 +72,8 @@ public class WifiConnectionTest
    @Override
    public void setUp() throws Exception {
        super.setUp();
        log("before we launch the test activity, we preserve all the configured networks.");
        mRunner = ((ConnectivityManagerTestRunner)getInstrumentation());
        mWifiManager = (WifiManager) mRunner.getContext().getSystemService(Context.WIFI_SERVICE);
        enabledNetworks = getEnabledNetworks(mWifiManager.getConfiguredNetworks());

        mAct = getActivity();
        mWifiManager.asyncConnect(mAct, new WifiServiceHandler());
@@ -123,42 +121,9 @@ public class WifiConnectionTest
    public void tearDown() throws Exception {
        log("tearDown()");
        mAct.removeConfiguredNetworksAndDisableWifi();
        reEnableNetworks(enabledNetworks);
        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
     * @param config is the network configuration