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

Commit e12a1a09 authored by Xia Wang's avatar Xia Wang Committed by Android (Google) Code Review
Browse files

Merge "Port wi-fi stress test into GB DO NOT MERGE" into gingerbread

parents c7c8c599 e9ba454a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -25,6 +25,6 @@ LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PACKAGE_NAME := ConnectivityManagerTest

#LOCAL_INSTRUMENTATION_FOR := connectivitymanagertest
LOCAL_CERTIFICATE := platform

include $(BUILD_PACKAGE)
+6 −1
Original line number Diff line number Diff line
@@ -16,7 +16,8 @@

<!-- package name must be unique so suffix with "tests" so package loader doesn't ignore us -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.connectivitymanagertest">
  package="com.android.connectivitymanagertest"
  android:sharedUserId="com.android.uid.test">

    <!-- We add an application tag here just so that we can indicate that
         this package needs to link against the android.test library,
@@ -67,5 +68,9 @@
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
    <uses-permission android:name="android.permission.WRITE_SETTINGS" />
    <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.DEVICE_POWER" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

</manifest>
+47 −7
Original line number Diff line number Diff line
@@ -19,8 +19,8 @@ package com.android.connectivitymanagertest;
import android.os.Bundle;
import android.test.InstrumentationTestRunner;
import android.test.InstrumentationTestSuite;
import android.util.Log;
import com.android.connectivitymanagertest.stress.WifiApStress;
import com.android.connectivitymanagertest.stress.WifiStressTest;

import junit.framework.TestSuite;

@@ -34,10 +34,18 @@ import junit.framework.TestSuite;
 */

public class ConnectivityManagerStressTestRunner extends InstrumentationTestRunner {
    public int mSoftapIterations = 100;
    public int mScanIterations = 100;
    public int mReconnectIterations = 100;
    public int mSleepTime = 30 * 1000;  // default sleep time is 30 seconds
    public String mReconnectSsid = "securenetdhcp";
    public String mReconnectPassword = "androidwifi";

    @Override
    public TestSuite getAllTests() {
        TestSuite suite = new InstrumentationTestSuite(this);
        suite.addTestSuite(WifiApStress.class);
        suite.addTestSuite(WifiStressTest.class);
        return suite;
    }

@@ -49,14 +57,46 @@ public class ConnectivityManagerStressTestRunner extends InstrumentationTestRunn
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        String stressValue = (String) icicle.get("stressnum");
        if (stressValue != null) {
            int iteration = Integer.parseInt(stressValue);
        String valueStr = (String) icicle.get("softap_iterations");
        if (valueStr != null) {
            int iteration = Integer.parseInt(valueStr);
            if (iteration > 0) {
                numStress = iteration;
                mSoftapIterations = iteration;
            }
        }

        String scanIterationStr = (String) icicle.get("scan_iterations");
        if (scanIterationStr != null) {
            int scanIteration = Integer.parseInt(scanIterationStr);
            if (scanIteration > 0) {
                mScanIterations = scanIteration;
            }
        }

        String ssidStr= (String) icicle.get("reconnect_ssid");
        if (ssidStr != null) {
            mReconnectSsid = ssidStr;
        }

        String passwordStr = (String) icicle.get("reconnect_password");
        if (passwordStr != null) {
            mReconnectPassword = passwordStr;
        }

        String reconnectStr = (String) icicle.get("reconnect_iterations");
        if (reconnectStr != null) {
            int iteration = Integer.parseInt(reconnectStr);
            if (iteration > 0) {
                mReconnectIterations = iteration;
            }
        }

    public int numStress = 100;
        String sleepTimeStr = (String) icicle.get("sleep_time");
        if (sleepTimeStr != null) {
            int sleepTime = Integer.parseInt(sleepTimeStr);
            if (sleepTime > 0) {
                mSleepTime = 1000 * sleepTime;
            }
        }
    }
}
+107 −37
Original line number Diff line number Diff line
@@ -24,11 +24,17 @@ import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.os.IPowerManager;
import android.os.PowerManager;
import android.os.ServiceManager;
import android.os.SystemClock;
import android.provider.Settings;
import android.util.Log;
import android.view.KeyEvent;

import java.io.IOException;
import java.io.InputStream;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -54,7 +60,7 @@ public class ConnectivityManagerTestActivity extends Activity {

    public static final String LOG_TAG = "ConnectivityManagerTestActivity";
    public static final int WAIT_FOR_SCAN_RESULT = 10 * 1000; //10 seconds
    public static final int WIFI_SCAN_TIMEOUT = 20 * 1000;
    public static final int WIFI_SCAN_TIMEOUT = 50 * 1000;
    public static final int SHORT_TIMEOUT = 5 * 1000;
    public static final long LONG_TIMEOUT = 50 * 1000;
    public static final int SUCCESS = 0;  // for Wifi tethering state change
@@ -64,6 +70,7 @@ public class ConnectivityManagerTestActivity extends Activity {
    public ConnectivityReceiver mConnectivityReceiver = null;
    public WifiReceiver mWifiReceiver = null;
    private AccessPointParserHelper mParseHelper = null;
    public boolean scanResultAvailable = false;
    /*
     * Track network connectivity information
     */
@@ -79,7 +86,7 @@ public class ConnectivityManagerTestActivity extends Activity {
    public int mWifiState;
    public NetworkInfo mWifiNetworkInfo;
    public String mBssid;
    public String mPowerSsid = "GoogleGuest"; //Default power SSID
    public String mPowerSsid = "opennet"; //Default power SSID
    private Context mContext;

    /*
@@ -104,7 +111,7 @@ public class ConnectivityManagerTestActivity extends Activity {
    private class ConnectivityReceiver extends BroadcastReceiver {
        @Override
        public void onReceive(Context context, Intent intent) {
            Log.v(LOG_TAG, "ConnectivityReceiver: onReceive() is called with " + intent);
            log("ConnectivityReceiver: onReceive() is called with " + intent);
            String action = intent.getAction();
            if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                Log.v("ConnectivityReceiver", "onReceive() called with " + intent);
@@ -129,9 +136,9 @@ public class ConnectivityManagerTestActivity extends Activity {
            mReason = intent.getStringExtra(ConnectivityManager.EXTRA_REASON);
            mIsFailOver = intent.getBooleanExtra(ConnectivityManager.EXTRA_IS_FAILOVER, false);

            Log.v(LOG_TAG, "mNetworkInfo: " + mNetworkInfo.toString());
            log("mNetworkInfo: " + mNetworkInfo.toString());
            if (mOtherNetworkInfo != null) {
                Log.v(LOG_TAG, "mOtherNetworkInfo: " + mOtherNetworkInfo.toString());
                log("mOtherNetworkInfo: " + mOtherNetworkInfo.toString());
            }
            recordNetworkState(mNetworkInfo.getType(), mNetworkInfo.getState());
            if (mOtherNetworkInfo != null) {
@@ -151,7 +158,7 @@ public class ConnectivityManagerTestActivity extends Activity {
            } else if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) {
                mWifiNetworkInfo =
                    (NetworkInfo) intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO);
                Log.v(LOG_TAG, "mWifiNetworkInfo: " + mWifiNetworkInfo.toString());
                log("mWifiNetworkInfo: " + mWifiNetworkInfo.toString());
                if (mWifiNetworkInfo.getState() == State.CONNECTED) {
                    mBssid = intent.getStringExtra(WifiManager.EXTRA_BSSID);
                }
@@ -159,7 +166,7 @@ public class ConnectivityManagerTestActivity extends Activity {
            } else if (action.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) {
                mWifiState = intent.getIntExtra(WifiManager.EXTRA_WIFI_STATE,
                                                WifiManager.WIFI_STATE_UNKNOWN);
                Log.v(LOG_TAG, "mWifiState: " + mWifiState);
                log("mWifiState: " + mWifiState);
                notifyWifiState();
            } else if (action.equals(WifiManager.WIFI_AP_STATE_CHANGED_ACTION)) {
                notifyWifiAPState();
@@ -180,12 +187,13 @@ public class ConnectivityManagerTestActivity extends Activity {

    public ConnectivityManagerTestActivity() {
        mState = State.UNKNOWN;
        scanResultAvailable = false;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.v(LOG_TAG, "onCreate, inst=" + Integer.toHexString(hashCode()));
        log("onCreate, inst=" + Integer.toHexString(hashCode()));

        // Create a simple layout
        LinearLayout contentView = new LinearLayout(this);
@@ -216,7 +224,7 @@ public class ConnectivityManagerTestActivity extends Activity {
        initializeNetworkStates();

        if (mWifiManager.isWifiEnabled()) {
            Log.v(LOG_TAG, "Clear Wifi before we start the test.");
            log("Clear Wifi before we start the test.");
            removeConfiguredNetworksAndDisableWifi();
        }
        mWifiRegexs = mCM.getTetherableWifiRegexs();
@@ -240,9 +248,9 @@ public class ConnectivityManagerTestActivity extends Activity {
    private void printNetConfig(String[] configuration) {
        for (int i = 0; i < configuration.length; i++) {
            if (i == 0) {
                Log.v(LOG_TAG, "SSID: " + configuration[0]);
                log("SSID: " + configuration[0]);
            } else {
                Log.v(LOG_TAG, "      " + configuration[i]);
                log("      " + configuration[i]);
            }
        }
    }
@@ -251,14 +259,14 @@ public class ConnectivityManagerTestActivity extends Activity {
    public void initializeNetworkStates() {
        for (int networkType = NUM_NETWORK_TYPES - 1; networkType >=0; networkType--) {
            connectivityState[networkType] =  new NetworkState();
            Log.v(LOG_TAG, "Initialize network state for " + networkType + ": " +
            log("Initialize network state for " + networkType + ": " +
                    connectivityState[networkType].toString());
        }
    }

    // deposit a network state
    public void recordNetworkState(int networkType, State networkState) {
        Log.v(LOG_TAG, "record network state for network " +  networkType +
        log("record network state for network " +  networkType +
                ", state is " + networkState);
        connectivityState[networkType].recordState(networkState);
    }
@@ -272,40 +280,41 @@ public class ConnectivityManagerTestActivity extends Activity {

    // Validate the states recorded
    public boolean validateNetworkStates(int networkType) {
        Log.v(LOG_TAG, "validate network state for " + networkType + ": ");
        log("validate network state for " + networkType + ": ");
        return connectivityState[networkType].validateStateTransition();
    }

    // return result from network state validation
    public String getTransitionFailureReason(int networkType) {
        Log.v(LOG_TAG, "get network state transition failure reason for " + networkType + ": " +
        log("get network state transition failure reason for " + networkType + ": " +
                connectivityState[networkType].toString());
        return connectivityState[networkType].getReason();
    }

    private void notifyNetworkConnectivityChange() {
        synchronized(connectivityObject) {
            Log.v(LOG_TAG, "notify network connectivity changed");
            log("notify network connectivity changed");
            connectivityObject.notifyAll();
        }
    }
    private void notifyScanResult() {
        synchronized (this) {
            Log.v(LOG_TAG, "notify that scan results are available");
            log("notify that scan results are available");
            scanResultAvailable = true;
            this.notify();
        }
    }

    private void notifyWifiState() {
        synchronized (wifiObject) {
            Log.v(LOG_TAG, "notify wifi state changed");
            log("notify wifi state changed");
            wifiObject.notify();
        }
    }

    private void notifyWifiAPState() {
        synchronized (this) {
            Log.v(LOG_TAG, "notify wifi AP state changed");
            log("notify wifi AP state changed");
            this.notify();
        }
    }
@@ -319,7 +328,7 @@ public class ConnectivityManagerTestActivity extends Activity {
            for (Object obj: tethered) {
                String str = (String)obj;
                for (String tethRex: mWifiRegexs) {
                    Log.v(LOG_TAG, "str: " + str +"tethRex: " + tethRex);
                    log("str: " + str +"tethRex: " + tethRex);
                    if (str.matches(tethRex)) {
                        wifiTethered = true;
                    }
@@ -329,7 +338,7 @@ public class ConnectivityManagerTestActivity extends Activity {
            for (Object obj: errored) {
                String str = (String)obj;
                for (String tethRex: mWifiRegexs) {
                    Log.v(LOG_TAG, "error: str: " + str +"tethRex: " + tethRex);
                    log("error: str: " + str +"tethRex: " + tethRex);
                    if (str.matches(tethRex)) {
                        wifiErrored = true;
                    }
@@ -341,7 +350,7 @@ public class ConnectivityManagerTestActivity extends Activity {
            } else if (wifiErrored) {
                mWifiTetherResult = FAILURE;   // wifi tethering failed
            }
            Log.v(LOG_TAG, "mWifiTetherResult: " + mWifiTetherResult);
            log("mWifiTetherResult: " + mWifiTetherResult);
            this.notify();
        }
    }
@@ -357,12 +366,12 @@ public class ConnectivityManagerTestActivity extends Activity {
                    return false;
                } else {
                    // the broadcast has been sent out. the state has been changed.
                    Log.v(LOG_TAG, "networktype: " + networkType + " state: " +
                    log("networktype: " + networkType + " state: " +
                            mCM.getNetworkInfo(networkType));
                    return true;
                }
            }
            Log.v(LOG_TAG, "Wait for the connectivity state for network: " + networkType +
            log("Wait for the connectivity state for network: " + networkType +
                    " to be " + expectedState.toString());
            synchronized (connectivityObject) {
                try {
@@ -372,7 +381,7 @@ public class ConnectivityManagerTestActivity extends Activity {
                }
                if ((mNetworkInfo.getType() != networkType) ||
                    (mNetworkInfo.getState() != expectedState)) {
                    Log.v(LOG_TAG, "network state for " + mNetworkInfo.getType() +
                    log("network state for " + mNetworkInfo.getType() +
                            "is: " + mNetworkInfo.getState());
                    continue;
                }
@@ -393,7 +402,7 @@ public class ConnectivityManagerTestActivity extends Activity {
                    return true;
                }
            }
            Log.v(LOG_TAG, "Wait for wifi state to be: " + expectedState);
            log("Wait for wifi state to be: " + expectedState);
            synchronized (wifiObject) {
                try {
                    wifiObject.wait(SHORT_TIMEOUT);
@@ -401,7 +410,7 @@ public class ConnectivityManagerTestActivity extends Activity {
                    e.printStackTrace();
                }
                if (mWifiState != expectedState) {
                    Log.v(LOG_TAG, "Wifi state is: " + mWifiState);
                    log("Wifi state is: " + mWifiState);
                    continue;
                }
                return true;
@@ -421,7 +430,7 @@ public class ConnectivityManagerTestActivity extends Activity {
                    return true;
                }
            }
            Log.v(LOG_TAG, "Wait for wifi AP state to be: " + expectedState);
            log("Wait for wifi AP state to be: " + expectedState);
            synchronized (wifiObject) {
                try {
                    wifiObject.wait(SHORT_TIMEOUT);
@@ -429,7 +438,7 @@ public class ConnectivityManagerTestActivity extends Activity {
                    e.printStackTrace();
                }
                if (mWifiManager.getWifiApState() != expectedState) {
                    Log.v(LOG_TAG, "Wifi state is: " + mWifiManager.getWifiApState());
                    log("Wifi state is: " + mWifiManager.getWifiApState());
                    continue;
                }
                return true;
@@ -449,7 +458,7 @@ public class ConnectivityManagerTestActivity extends Activity {
            if ((System.currentTimeMillis() - startTime) > timeout) {
                return mWifiTetherResult;
            }
            Log.v(LOG_TAG, "Wait for wifi tethering result.");
            log("Wait for wifi tethering result.");
            synchronized (this) {
                try {
                    this.wait(SHORT_TIMEOUT);
@@ -479,6 +488,64 @@ public class ConnectivityManagerTestActivity extends Activity {
        return mWifiManager.setWifiEnabled(true);
    }

    // Turn screen off
    public void turnScreenOff() {
        log("Turn screen off");
        PowerManager pm =
            (PowerManager) getSystemService(Context.POWER_SERVICE);
        pm.goToSleep(SystemClock.uptimeMillis() + 100);
    }

    // Turn screen on
    public void turnScreenOn() {
        log("Turn screen on");
        IPowerManager mPowerManagerService = IPowerManager.Stub.asInterface(
                ServiceManager.getService("power"));;
        try {
            mPowerManagerService.userActivityWithForce(SystemClock.uptimeMillis(), false, true);
        } catch (Exception e) {
            log(e.toString());
        }
    }

    /**
     * @param pingServerList a list of servers that can be used for ping test, can be null
     * @return true if the ping test is successful, false otherwise.
     */
    public boolean pingTest(String[] pingServerList) {
        boolean result = false;
        String[] hostList = {"www.google.com", "www.yahoo.com",
                "www.bing.com", "www.facebook.com", "www.ask.com"};
        if (pingServerList != null) {
            hostList = pingServerList;
        }
        try {
            // assume the chance that all servers are down is very small
            for (int i = 0; i < hostList.length; i++ ) {
                String host = hostList[i];
                log("Start ping test, ping " + host);
                Process p = Runtime.getRuntime().exec("ping -c 10 -w 100 " + host);
                int status = p.waitFor();
                if (status == 0) {
                    // if any of the ping test is successful, return true
                    result = true;
                    break;
                } else {
                    result = false;
                    log("ping " + host + " failed.");
                }
            }
        } catch (UnknownHostException e) {
            log("Ping test Fail: Unknown Host");
        } catch (IOException e) {
            log("Ping test Fail:  IOException");
        } catch (InterruptedException e) {
            log("Ping test Fail: InterruptedException");
        }
        log("return");
        return result;
    }

    /**
     * Associate the device to given SSID
     * If the device is already associated with a WiFi, disconnect and forget it,
@@ -503,13 +570,13 @@ public class ConnectivityManagerTestActivity extends Activity {

        //If Wifi is not enabled, enable it
        if (!mWifiManager.isWifiEnabled()) {
            Log.v(LOG_TAG, "Wifi is not enabled, enable it");
            log("Wifi is not enabled, enable it");
            mWifiManager.setWifiEnabled(true);
        }

        List<ScanResult> netList = mWifiManager.getScanResults();
        if (netList == null) {
            Log.v(LOG_TAG, "scan results are null");
            log("scan results are null");
            // if no scan results are available, start active scan
            mWifiManager.startScanActive();
            mScanResultIsAvailable = false;
@@ -540,7 +607,7 @@ public class ConnectivityManagerTestActivity extends Activity {
        for (int i = 0; i < netList.size(); i++) {
            ScanResult sr= netList.get(i);
            if (sr.SSID.equals(ssid)) {
                Log.v(LOG_TAG, "found " + ssid + " in the scan result list");
                log("found " + ssid + " in the scan result list");
                int networkId = mWifiManager.addNetwork(config);
                // Connect to network by disabling others.
                mWifiManager.enableNetwork(networkId, true);
@@ -552,7 +619,7 @@ public class ConnectivityManagerTestActivity extends Activity {

        List<WifiConfiguration> netConfList = mWifiManager.getConfiguredNetworks();
        if (netConfList.size() <= 0) {
            Log.v(LOG_TAG, ssid + " is not available");
            log(ssid + " is not available");
            return false;
        }
        return true;
@@ -575,7 +642,7 @@ public class ConnectivityManagerTestActivity extends Activity {
            // remove other saved networks
            List<WifiConfiguration> netConfList = mWifiManager.getConfiguredNetworks();
            if (netConfList != null) {
                Log.v(LOG_TAG, "remove configured network ids");
                log("remove configured network ids");
                for (int i = 0; i < netConfList.size(); i++) {
                    WifiConfiguration conf = new WifiConfiguration();
                    conf = netConfList.get(i);
@@ -640,7 +707,7 @@ public class ConnectivityManagerTestActivity extends Activity {
        if (mWifiReceiver != null) {
            unregisterReceiver(mWifiReceiver);
        }
        Log.v(LOG_TAG, "onDestroy, inst=" + Integer.toHexString(hashCode()));
        log("onDestroy, inst=" + Integer.toHexString(hashCode()));
    }

    @Override
@@ -682,5 +749,8 @@ public class ConnectivityManagerTestActivity extends Activity {
        }
        return super.onKeyDown(keyCode, event);
    }
}

    private void log(String message) {
        Log.v(LOG_TAG, message);
    }
}
+41 −8
Original line number Diff line number Diff line
@@ -19,25 +19,33 @@ package com.android.connectivitymanagertest.stress;

import com.android.connectivitymanagertest.ConnectivityManagerStressTestRunner;
import com.android.connectivitymanagertest.ConnectivityManagerTestActivity;
import com.android.connectivitymanagertest.ConnectivityManagerTestRunner;

import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiConfiguration.KeyMgmt;
import android.net.wifi.WifiConfiguration.AuthAlgorithm;
import android.net.wifi.WifiManager;
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.LargeTest;
import android.util.Log;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;

/**
 * Stress the wifi driver as access point.
 */
public class WifiApStress
    extends ActivityInstrumentationTestCase2<ConnectivityManagerTestActivity> {
    private final static String TAG = "WifiApStress";
    private ConnectivityManagerTestActivity mAct;
    private static String NETWORK_ID = "AndroidAPTest";
    private static String PASSWD = "androidwifi";
    private int max_num;
    private final static String OUTPUT_FILE = "WifiStressTestOutput.txt";
    private ConnectivityManagerTestActivity mAct;
    private int iterations;
    private BufferedWriter mOutputWriter = null;
    private int mLastIteration = 0;

    public WifiApStress() {
        super(ConnectivityManagerTestActivity.class);
@@ -47,11 +55,20 @@ public class WifiApStress
    public void setUp() throws Exception {
        super.setUp();
        mAct = getActivity();
        max_num = ((ConnectivityManagerStressTestRunner)getInstrumentation()).numStress;
        ConnectivityManagerStressTestRunner mRunner =
            (ConnectivityManagerStressTestRunner)getInstrumentation();
        iterations = mRunner.mSoftapIterations;
        mAct.turnScreenOn();
    }

    @Override
    public void tearDown() throws Exception {
        // write the total number of iterations into output file
        mOutputWriter = new BufferedWriter(new FileWriter(new File(
                Environment.getExternalStorageDirectory(), OUTPUT_FILE)));
        mOutputWriter.write(String.format("iteration %d out of %d\n", mLastIteration, iterations));
        mOutputWriter.flush();
        mOutputWriter.close();
        super.tearDown();
    }

@@ -67,22 +84,38 @@ public class WifiApStress
        if (mAct.mWifiManager.isWifiEnabled()) {
            mAct.disableWifi();
        }
        for (int i = 0; i < max_num; i++) {
        int i;
        for (i = 0; i < iterations; i++) {
            Log.v(TAG, "iteration: " + i);
            mLastIteration = i;
            // enable Wifi tethering
            assertTrue(mAct.mWifiManager.setWifiApEnabled(config, true));
            // Wait for wifi ap state to be ENABLED
            assertTrue(mAct.waitForWifiAPState(mAct.mWifiManager.WIFI_AP_STATE_ENABLED,
                    mAct.LONG_TIMEOUT));
            assertTrue(mAct.waitForWifiAPState(WifiManager.WIFI_AP_STATE_ENABLED,
                    ConnectivityManagerTestActivity.LONG_TIMEOUT));
            // Wait for wifi tethering result
            assertEquals(mAct.SUCCESS, mAct.waitForTetherStateChange(2*mAct.SHORT_TIMEOUT));
            assertEquals(ConnectivityManagerTestActivity.SUCCESS,
                    mAct.waitForTetherStateChange(2*ConnectivityManagerTestActivity.SHORT_TIMEOUT));
            // Allow the wifi tethering to be enabled for 10 seconds
            try {
                Thread.sleep(2 * ConnectivityManagerTestActivity.SHORT_TIMEOUT);
            } catch (Exception e) {
                fail("thread in sleep is interrupted");
            }
            assertTrue("no uplink data connection after Wi-Fi tethering", mAct.pingTest(null));
            // Disable soft AP
            assertTrue(mAct.mWifiManager.setWifiApEnabled(config, false));
            // Wait for 30 seconds until Wi-Fi tethering is stopped
            try {
                Thread.sleep(30 * 1000);
                Log.v(TAG, "wait for Wi-Fi tethering to be disabled.");
            } catch (Exception e) {
                fail("thread in sleep is interrupted");
            }
            assertFalse("Wi-Fi AP disable failed", mAct.mWifiManager.isWifiApEnabled());
        }
        if (i == iterations) {
            mLastIteration = iterations;
        }
    }

Loading