@@ -57,7 +57,7 @@ public class ConnectionUtil {
5757 private static final int WAIT_FOR_SCAN_RESULT = 10 * 1000 ; // 10 seconds
5858 private static final int WIFI_SCAN_TIMEOUT = 50 * 1000 ;
5959 public static final int SHORT_TIMEOUT = 5 * 1000 ;
60- public static final int LONG_TIMEOUT = 10 * 1000 ;
60+ public static final int LONG_TIMEOUT = 120 * 1000 ; // 2 minutes
6161 private ConnectivityReceiver mConnectivityReceiver = null ;
6262 private WifiReceiver mWifiReceiver = null ;
6363 private DownloadReceiver mDownloadReceiver = null ;
@@ -118,8 +118,14 @@ public void initialize() throws Exception {
118118
119119 initializeNetworkStates ();
120120
121- mWifiManager .setWifiEnabled (true );
122121
122+ }
123+
124+ /**
125+ * Additional initialization needed for wifi related tests.
126+ */
127+ public void wifiTestInit () {
128+ mWifiManager .setWifiEnabled (true );
123129 Log .v (LOG_TAG , "Clear Wifi before we start the test." );
124130 sleep (SHORT_TIMEOUT );
125131 removeConfiguredNetworksAndDisableWifi ();
@@ -146,10 +152,10 @@ public void onReceive(Context context, Intent intent) {
146152 Log .v ("ConnectivityReceiver" , "onReceive() called with " + intent );
147153 return ;
148154 }
149- if ( intent . hasExtra ( ConnectivityManager . EXTRA_NETWORK_INFO )) {
150- mNetworkInfo = (NetworkInfo )
151- intent . getParcelableExtra ( ConnectivityManager . EXTRA_NETWORK_INFO );
152- }
155+
156+ final ConnectivityManager connManager = (ConnectivityManager ) context
157+ . getSystemService ( Context . CONNECTIVITY_SERVICE );
158+ mNetworkInfo = connManager . getActiveNetworkInfo ();
153159
154160 if (intent .hasExtra (ConnectivityManager .EXTRA_OTHER_NETWORK_INFO )) {
155161 mOtherNetworkInfo = (NetworkInfo )
@@ -525,7 +531,7 @@ public boolean connectToWifi(String knownSSID) {
525531 /**
526532 * Connect to Wi-Fi with the given configuration.
527533 * @param config
528- * @return true if we ar connected to a given
534+ * @return true if we are connected to a given AP.
529535 */
530536 public boolean connectToWifiWithConfiguration (WifiConfiguration config ) {
531537 // The SSID in the configuration is a pure string, need to convert it to a quoted string.
0 commit comments