summaryrefslogtreecommitdiff
path: root/core/tests/bandwidthtests
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2012-02-24 10:54:13 -0800
committerIrfan Sheriff <isheriff@google.com>2012-03-01 13:57:23 -0800
commitd3975a917799b85cacaf382b65c5832813066b51 (patch)
tree35f249be09330ebf5222b139bd1c2355823e7e88 /core/tests/bandwidthtests
parent5bb59daf42fb24c1131effd4265c2386304feceb (diff)
Fix WifiManager async API
Fix the current asynchronous API to use callback like the way was done with p2p API. In the process, fix the use of WPS Change-Id: Ib6f8714cf51b3525b655948268804e7eaaf17587
Diffstat (limited to 'core/tests/bandwidthtests')
-rw-r--r--core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
index 8d778c46b5cf..e799d15bbc65 100644
--- a/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
+++ b/core/tests/bandwidthtests/src/com/android/bandwidthtest/util/ConnectionUtil.java
@@ -74,6 +74,7 @@ public class ConnectionUtil {
private int mWifiState;
private NetworkInfo mWifiNetworkInfo;
private WifiManager mWifiManager;
+ private WifiManager.Channel mChannel;
private Context mContext;
// Verify connectivity state
private static final int NUM_NETWORK_TYPES = ConnectivityManager.MAX_NETWORK_TYPE + 1;
@@ -114,7 +115,7 @@ public class ConnectionUtil {
// Get an instance of WifiManager
mWifiManager =(WifiManager)mContext.getSystemService(Context.WIFI_SERVICE);
- mWifiManager.asyncConnect(mContext, new WifiServiceHandler());
+ mChannel = mWifiManager.initialize(mContext, mContext.getMainLooper(), null);
mDownloadManager = (DownloadManager)mContext.getSystemService(Context.DOWNLOAD_SERVICE);
@@ -567,7 +568,14 @@ public class ConnectionUtil {
Log.v(LOG_TAG, "Found " + ssid + " in the scan result list.");
Log.v(LOG_TAG, "Retry: " + retry);
foundApInScanResults = true;
- mWifiManager.connectNetwork(config);
+ mWifiManager.connect(mChannel, config, new WifiManager.ActionListener() {
+ public void onSuccess() {
+ }
+ public void onFailure(int reason) {
+ Log.e(LOG_TAG, "connect failed " + reason);
+ }
+ });
+
break;
}
}
@@ -614,7 +622,13 @@ public class ConnectionUtil {
for (WifiConfiguration wifiConfig: wifiConfigList) {
Log.v(LOG_TAG, "Remove wifi configuration: " + wifiConfig.networkId);
int netId = wifiConfig.networkId;
- mWifiManager.forgetNetwork(netId);
+ mWifiManager.forget(mChannel, netId, new WifiManager.ActionListener() {
+ public void onSuccess() {
+ }
+ public void onFailure(int reason) {
+ Log.e(LOG_TAG, "forget failed " + reason);
+ }
+ });
}
return true;
}
@@ -723,4 +737,4 @@ public class ConnectionUtil {
}
return false;
}
-} \ No newline at end of file
+}