List of usage examples for android.net.wifi SupplicantState COMPLETED
SupplicantState COMPLETED
To view the source code for android.net.wifi SupplicantState COMPLETED.
Click Source Link
From source file:com.wiyun.engine.network.Network.java
static boolean isWifiConnected() { Context context = Director.getInstance().getContext(); if (context.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_WIFI_STATE) == PackageManager.PERMISSION_GRANTED) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wm != null) { WifiInfo info = wm.getConnectionInfo(); return info != null && info.getSupplicantState() == SupplicantState.COMPLETED; } else {/*from w w w . j av a 2 s . c om*/ return false; } } else { Log.w("libwiengine", "you need add ACCESS_WIFI_STATE permission"); return false; } }
From source file:com.tvs.signaltracker.STService.java
private void UpdateWiFi() { SupplicantState supState;//w ww . ja v a2 s .c o m WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); supState = wifiInfo.getSupplicantState(); CommonHandler.WifiConnected = (supState == SupplicantState.COMPLETED); }
From source file:com.geniatech.client_phone.wifi.WifiStatusTest.java
private void setSupplicantStateText(SupplicantState supplicantState) { if (SupplicantState.FOUR_WAY_HANDSHAKE.equals(supplicantState)) { mSupplicantState.setText("FOUR WAY HANDSHAKE"); } else if (SupplicantState.ASSOCIATED.equals(supplicantState)) { mSupplicantState.setText("ASSOCIATED"); } else if (SupplicantState.ASSOCIATING.equals(supplicantState)) { mSupplicantState.setText("ASSOCIATING"); } else if (SupplicantState.COMPLETED.equals(supplicantState)) { mSupplicantState.setText("COMPLETED"); } else if (SupplicantState.DISCONNECTED.equals(supplicantState)) { mSupplicantState.setText("DISCONNECTED"); } else if (SupplicantState.DORMANT.equals(supplicantState)) { mSupplicantState.setText("DORMANT"); } else if (SupplicantState.GROUP_HANDSHAKE.equals(supplicantState)) { mSupplicantState.setText("GROUP HANDSHAKE"); } else if (SupplicantState.INACTIVE.equals(supplicantState)) { mSupplicantState.setText("INACTIVE"); } else if (SupplicantState.INVALID.equals(supplicantState)) { mSupplicantState.setText("INVALID"); } else if (SupplicantState.SCANNING.equals(supplicantState)) { mSupplicantState.setText("SCANNING"); } else if (SupplicantState.UNINITIALIZED.equals(supplicantState)) { mSupplicantState.setText("UNINITIALIZED"); } else {/*from w ww .j ava2 s . co m*/ mSupplicantState.setText("BAD"); Log.e(TAG, "supplicant state is bad"); } }
From source file:org.peterbaldwin.vlcremote.app.PickServerActivity.java
private WifiInfo getConnectionInfo() { Object service = getSystemService(WIFI_SERVICE); WifiManager manager = (WifiManager) service; WifiInfo info = manager.getConnectionInfo(); if (info != null) { SupplicantState state = info.getSupplicantState(); if (state.equals(SupplicantState.COMPLETED)) { return info; }//from w w w. java2s.c o m } return null; }
From source file:tv.matchstick.demo.flingpic.FlingPicActivity.java
private void startWetServer(int port) { try {/* w ww . jav a 2 s . c o m*/ WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE); WifiInfo wifiInfo = wifiManager.getConnectionInfo(); mIpAddress = intToIp(wifiInfo.getIpAddress()); if (wifiInfo.getSupplicantState() != SupplicantState.COMPLETED) { new AlertDialog.Builder(this).setTitle("Error") .setMessage("Please connect to a WIFI-network for starting the webserver.") .setPositiveButton("OK", null).show(); throw new Exception("Please connect to a WIFI-network."); } Log.e(TAG, "Starting server " + mIpAddress + ":" + port + "."); List<File> rootDirs = new ArrayList<File>(); boolean quiet = false; Map<String, String> options = new HashMap<String, String>(); rootDirs.add(new File(mRootDir).getAbsoluteFile()); // mNanoHTTPD try { mNanoHTTPD = new SimpleWebServer(mIpAddress, port, rootDirs, quiet); mNanoHTTPD.start(); } catch (IOException ioe) { Log.e(TAG, "Couldn't start server:\n" + ioe); } } catch (Exception e) { Log.e(TAG, e.getMessage()); } }
From source file:org.eeiiaa.wifi.WifiConnector.java
@Override public void onReceive(Context context, Intent intent) { // handle stuff related to scanning requested when: // normal scan is issued // when forgetting a network and re-connecting to a previously configured // existing one // when connecting and need a scan to verify connection can be established Log.i(TAG, "action: " + intent.getAction()); if (intent.getAction().equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION) && (mWaitingScan || mConnecting)) { // forgetting current and reconnecting to highest priority existing // network Log.i(TAG, "ACTION SCAN: mWaitingScan:" + mWaitingScan + " connecting " + mConnecting); // normal scan request if (mWaitingScan) { String json = new String(); switch (scanResultOption) { case GET_ALL: json = getScannedNetworksAllJSON(); break; case GET_BSSID_ONLY: json = getScannedNetworksJSON(); break; }/*from www .j a v a2 s . c om*/ mScanListener.scanResultsJSON(json); mWaitingScan = false; // scan is done - unregister mContext.unregisterReceiver(this); Log.i(TAG, "processing scan results as JSON"); } if (mConnecting && !mWaitingConnection) { // look for the network we want to connect to in the scanned results ScanResult scannedNet = searchNetwork(mNetssid); if (scannedNet == null) { Log.i(TAG, "ssid not found...: " + mNetssid); mConnecting = false; mContext.unregisterReceiver(this); notifyConnectionFailed(); return; // didn't find requested network noting to connect } WifiConfiguration configuredNet = searchConfiguration(scannedNet); boolean result_ok = false; if (configuredNet != null) { // configuration exits connect to a configured network mWaitingConnection = true; result_ok = Wifi.connectToConfiguredNetwork(mContext, mWifiMgr, configuredNet, false); Log.i(TAG, "configuration exits connect to a configured network"); } else { // configure and connect to network mWaitingConnection = true; result_ok = Wifi.connectToNewNetwork(mContext, mWifiMgr, scannedNet, mPwd, MAX_OPEN_NETS); Log.i(TAG, "configure and connect to network"); } // failed to connect - unregister and notify if (!result_ok) { mContext.unregisterReceiver(this); mWaitingConnection = false; mConnecting = false; Log.e(TAG, "error connecting Wifi.connect returned error"); notifyConnectionFailed(); } } } else if (intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION) && (mConnected || (mConnecting && mWaitingConnection))) { Log.i(TAG, "ACTION CONNECTIVITY: mWaitingScan:" + mWaitingScan + " forgetting: " + forgetting_ + " connecting " + mConnecting); NetworkInfo networkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if (!mConnected && networkInfo.getType() == ConnectivityManager.TYPE_WIFI && networkInfo.isConnected()) { if (mWifiMgr.getConnectionInfo().getSupplicantState() == SupplicantState.COMPLETED) { Log.i(TAG, " getConnectionInfo: " + mWifiMgr.getConnectionInfo() + " getSSID: " + mWifiMgr.getConnectionInfo().getSSID()); String connectionSsid = unQuote(mWifiMgr.getConnectionInfo().getSSID()); // when phone turns into AP mode, wifimgr returns null... // fail protection for such cases... if (connectionSsid != null) { Log.i(TAG, "mNetssid: |" + mNetssid + "| connectionSsid |" + connectionSsid + "|"); if (connectionSsid.equals(mNetssid)) { mConnected = true; mConnecting = false; mWaitingConnection = false; forgetting_ = false; Log.i(TAG, "VERIFIED SUCCESSFUL CONNECTION to: " + mNetssid); // connection done notify - do not unregister to get disconnection detected notifyConnectionListener(); } } } } else if (mConnected && networkInfo.getType() == ConnectivityManager.TYPE_WIFI && !networkInfo.isConnected()) { Log.i(TAG, "network is disconnected..."); // Wifi is disconnected mConnected = false; mWaitingConnection = false; if (mDataListener != null && used_ != null) { used_.updateUsageCounters(); transmitted = used_.getWifiTransmitted(); received = used_.getWifiReceived(); } // network lost was not expected (when forgetting we expect network to // be lost) if (!forgetting_) { Log.i(TAG, "network lost " + networkInfo); notifyNetworkLost(networkInfo); mContext.unregisterReceiver(this); } else { Log.i(TAG, "network lost when forgetting " + networkInfo); } } Log.i(TAG, "end of CONNECTIVITY_ACTION"); } }
From source file:com.mozilla.SUTAgentAndroid.SUTAgentAndroid.java
public boolean setUpNetwork(String sIniFile) { boolean bRet = false; int lcv = 0;/*ww w . j a va 2 s .com*/ int lcv2 = 0; WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE); WifiConfiguration wc = new WifiConfiguration(); DoCommand tmpdc = new DoCommand(getApplication()); String ssid = tmpdc.GetIniData("Network Settings", "SSID", sIniFile); String auth = tmpdc.GetIniData("Network Settings", "AUTH", sIniFile); String encr = tmpdc.GetIniData("Network Settings", "ENCR", sIniFile); String key = tmpdc.GetIniData("Network Settings", "KEY", sIniFile); String eap = tmpdc.GetIniData("Network Settings", "EAP", sIniFile); String adhoc = tmpdc.GetIniData("Network Settings", "ADHOC", sIniFile); Toast.makeText(getApplication().getApplicationContext(), "Starting and configuring network", Toast.LENGTH_LONG).show(); /* ContentResolver cr = getContentResolver(); int nRet; try { nRet = Settings.System.getInt(cr, Settings.System.WIFI_USE_STATIC_IP); String foo2 = "" + nRet; } catch (SettingNotFoundException e1) { e1.printStackTrace(); } */ /* wc.SSID = "\"Mozilla-Build\""; wc.preSharedKey = "\"MozillaBuildQA500\""; wc.hiddenSSID = true; wc.status = WifiConfiguration.Status.ENABLED; wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN); */ wc.SSID = "\"" + ssid + "\""; // wc.SSID = "\"Mozilla-G\""; // wc.SSID = "\"Mozilla\""; if (auth.contentEquals("wpa2")) { wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN); wc.preSharedKey = null; } if (encr.contentEquals("aes")) { wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); } if (eap.contentEquals("peap")) { wc.eap.setValue("PEAP"); wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP); wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X); } wc.status = WifiConfiguration.Status.ENABLED; if (!wifi.isWifiEnabled()) wifi.setWifiEnabled(true); while (wifi.getWifiState() != WifiManager.WIFI_STATE_ENABLED) { Thread.yield(); if (++lcv > 10000) return (bRet); } wl = wifi.createWifiLock(WifiManager.WIFI_MODE_FULL, "SUTAgent"); if (wl != null) wl.acquire(); WifiConfiguration foo = null; int nNetworkID = -1; List<WifiConfiguration> connsLst = wifi.getConfiguredNetworks(); int nConns = connsLst.size(); for (int i = 0; i < nConns; i++) { foo = connsLst.get(i); if (foo.SSID.equalsIgnoreCase(wc.SSID)) { nNetworkID = foo.networkId; wc.networkId = foo.networkId; break; } } int res; if (nNetworkID != -1) { res = wifi.updateNetwork(wc); } else { res = wifi.addNetwork(wc); } Log.d("WifiPreference", "add Network returned " + res); boolean b = wifi.enableNetwork(res, true); Log.d("WifiPreference", "enableNetwork returned " + b); wifi.saveConfiguration(); WifiInfo wi = wifi.getConnectionInfo(); SupplicantState ss = wi.getSupplicantState(); lcv = 0; lcv2 = 0; while (ss.compareTo(SupplicantState.COMPLETED) != 0) { try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } if (wi != null) wi = null; if (ss != null) ss = null; wi = wifi.getConnectionInfo(); ss = wi.getSupplicantState(); if (++lcv > 60) { if (++lcv2 > 5) { Toast.makeText(getApplication().getApplicationContext(), "Unable to start and configure network", Toast.LENGTH_LONG).show(); return (bRet); } else { Toast.makeText(getApplication().getApplicationContext(), "Resetting wifi interface", Toast.LENGTH_LONG).show(); if (wl != null) wl.release(); wifi.setWifiEnabled(false); while (wifi.getWifiState() != WifiManager.WIFI_STATE_DISABLED) { Thread.yield(); } wifi.setWifiEnabled(true); while (wifi.getWifiState() != WifiManager.WIFI_STATE_ENABLED) { Thread.yield(); } b = wifi.enableNetwork(res, true); Log.d("WifiPreference", "enableNetwork returned " + b); if (wl != null) wl.acquire(); lcv = 0; } } } lcv = 0; while (getLocalIpAddress() == null) { if (++lcv > 10000) return (bRet); } Toast.makeText(getApplication().getApplicationContext(), "Network started and configured", Toast.LENGTH_LONG).show(); bRet = true; return (bRet); }
From source file:com.compal.wifitest.WifiTestCase.java
public boolean saveAPConfig(String mAPType) { WifiConfiguration wc = new WifiConfiguration(); if (mAPType.equalsIgnoreCase(dWpa)) { wc.SSID = WpaAPSsid;// w ww . j a v a2s . co m wc.preSharedKey = WpaAPKey; wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); wc.priority = 40; //!! } if (mAPType.equalsIgnoreCase(dWep)) { wc.SSID = WepAPSsid; wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP40); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.WEP104); wc.wepKeys[0] = WepAPKey; //This is the WEP Password wc.wepTxKeyIndex = 0; } if (mAPType.equalsIgnoreCase(dWpa2)) { wc.SSID = Wpa2APSsid; wc.preSharedKey = Wpa2APKey; wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_PSK); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); } if (mAPType.equalsIgnoreCase(dShared)) { wc.SSID = SharedAPSsid; wc.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.NONE); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.CCMP); wc.allowedGroupCiphers.set(WifiConfiguration.GroupCipher.TKIP); } wc.hiddenSSID = true; wc.status = WifiConfiguration.Status.DISABLED; wc.priority = 41; //!! wc.allowedProtocols.set(WifiConfiguration.Protocol.RSN); wc.allowedProtocols.set(WifiConfiguration.Protocol.WPA); wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.OPEN); wc.allowedAuthAlgorithms.set(WifiConfiguration.AuthAlgorithm.SHARED); wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.CCMP); wc.allowedPairwiseCiphers.set(WifiConfiguration.PairwiseCipher.TKIP); //boolean res1 = mWifiManager.setWifiEnabled(true); int res = mWifiManager.addNetwork(wc); Log.i(tag, "add" + mAPType + "Network returned " + res); boolean es = mWifiManager.saveConfiguration(); Log.i(tag, mAPType + " saveConfiguration returned " + es); boolean b = mWifiManager.enableNetwork(res, true); Log.i(tag, mAPType + " enableNetwork returned " + b); long startTime = System.currentTimeMillis(); while ((System.currentTimeMillis() - startTime) < LONG_TIMEOUT * 5) { if (mWifiManager.getConnectionInfo().getSupplicantState() .equals((SupplicantState) SupplicantState.COMPLETED) && !Formatter.formatIpAddress(mWifiManager.getConnectionInfo().getIpAddress()) .equalsIgnoreCase("0.0.0.0")) { Log.i(tag, Formatter.formatIpAddress(mWifiManager.getConnectionInfo().getIpAddress())); Log.i(tag, "getConnectionInfo().getSupplicantState().equals((SupplicantState) SupplicantState.COMPLETED)"); Log.i(tag, "IP && supplicant state complete = true : " + mAPType); return true; } sleep(100); } Log.i(tag, "IP || supplicant state complete = false : " + mAPType); return false; }
From source file:org.sipdroid.sipua.ui.Receiver.java
@Override public void onReceive(Context context, Intent intent) { String intentAction = intent.getAction(); if (!Sipdroid.on(context)) return;// w w w . j ava 2 s . c o m if (!Sipdroid.release) Log.i("SipUA:", intentAction); if (mContext == null) mContext = context; if (intentAction.equals(Intent.ACTION_BOOT_COMPLETED)) { on_vpn(false); engine(context).register(); } else if (intentAction.equals(ConnectivityManager.CONNECTIVITY_ACTION) || intentAction.equals(ACTION_EXTERNAL_APPLICATIONS_AVAILABLE) || intentAction.equals(ACTION_EXTERNAL_APPLICATIONS_UNAVAILABLE) || intentAction.equals(Intent.ACTION_PACKAGE_REPLACED)) { engine(context).register(); } else if (intentAction.equals(ACTION_VPN_CONNECTIVITY) && intent.hasExtra("connection_state")) { String state = intent.getSerializableExtra("connection_state").toString(); if (state != null && on_vpn() != state.equals("CONNECTED")) { on_vpn(state.equals("CONNECTED")); for (SipProvider sip_provider : engine(context).sip_providers) if (sip_provider != null) sip_provider.haltConnections(); engine(context).register(); } } else if (intentAction.equals(ACTION_DATA_STATE_CHANGED)) { engine(context).registerMore(); } else if (intentAction.equals(ACTION_PHONE_STATE_CHANGED) && !intent.getBooleanExtra(context.getString(R.string.app_name), false)) { stopRingtone(); pstn_state = intent.getStringExtra("state"); pstn_time = SystemClock.elapsedRealtime(); if (pstn_state.equals("IDLE") && call_state != UserAgent.UA_STATE_IDLE) broadcastCallStateChanged(null, null); if (!pstn_state.equals("IDLE") && call_state == UserAgent.UA_STATE_INCALL) mHandler.sendEmptyMessageDelayed(MSG_HOLD, 5000); else if (!pstn_state.equals("IDLE") && (call_state == UserAgent.UA_STATE_INCOMING_CALL || call_state == UserAgent.UA_STATE_OUTGOING_CALL)) mHandler.sendEmptyMessageDelayed(MSG_HANGUP, 5000); else if (pstn_state.equals("IDLE")) { mHandler.removeMessages(MSG_HOLD); mHandler.removeMessages(MSG_HANGUP); if (call_state == UserAgent.UA_STATE_HOLD) mHandler.sendEmptyMessageDelayed(MSG_HOLD, 1000); } } else if (intentAction.equals(ACTION_DOCK_EVENT)) { docked = intent.getIntExtra(EXTRA_DOCK_STATE, -1) & 7; if (call_state == UserAgent.UA_STATE_INCALL) engine(mContext).speaker(speakermode()); } else if (intentAction.equals(ACTION_SCO_AUDIO_STATE_CHANGED)) { bluetooth = intent.getIntExtra(EXTRA_SCO_AUDIO_STATE, -1); progress(); RtpStreamSender.changed = true; } else if (intentAction.equals(Intent.ACTION_HEADSET_PLUG)) { headset = intent.getIntExtra("state", -1); if (call_state == UserAgent.UA_STATE_INCALL) engine(mContext).speaker(speakermode()); } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) { if (!PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_OWNWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_OWNWIFI)) alarm(0, OwnWifi.class); } else if (intentAction.equals(Intent.ACTION_USER_PRESENT)) { mHandler.sendEmptyMessageDelayed(MSG_ENABLE, 3000); } else if (intentAction.equals(Intent.ACTION_SCREEN_OFF)) { if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_OWNWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_OWNWIFI)) { WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); if (wm.getWifiState() != WifiManager.WIFI_STATE_ENABLED || wi == null || wi.getSupplicantState() != SupplicantState.COMPLETED || wi.getIpAddress() == 0) alarm(2 * 60, OwnWifi.class); else alarm(15 * 60, OwnWifi.class); } if (SipdroidEngine.pwl != null) for (PowerManager.WakeLock pwl : SipdroidEngine.pwl) if (pwl != null && pwl.isHeld()) { pwl.release(); pwl.acquire(); } } else if (intentAction.equals(WifiManager.WIFI_STATE_CHANGED_ACTION)) { if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_SELECTWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_SELECTWIFI)) mHandler.sendEmptyMessageDelayed(MSG_SCAN, 3000); } else if (intentAction.equals(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION)) { if (SystemClock.uptimeMillis() > lastscan + 45000 && PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_SELECTWIFI, org.sipdroid.sipua.ui.Settings.DEFAULT_SELECTWIFI)) { WifiManager wm = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE); WifiInfo wi = wm.getConnectionInfo(); String activeSSID = null; if (wi != null) activeSSID = wi.getSSID(); if (activeSSID != null && (activeSSID.length() == 0 || activeSSID.equals("0x"))) activeSSID = null; List<ScanResult> mScanResults = wm.getScanResults(); List<WifiConfiguration> configurations = wm.getConfiguredNetworks(); if (configurations != null) { WifiConfiguration bestconfig = null, maxconfig = null, activeconfig = null; for (final WifiConfiguration config : configurations) { if (maxconfig == null || config.priority > maxconfig.priority) { maxconfig = config; } if (config.SSID != null && (config.SSID.equals("\"" + activeSSID + "\"") || config.SSID.equals(activeSSID))) activeconfig = config; } ScanResult bestscan = null, activescan = null; if (mScanResults != null) for (final ScanResult scan : mScanResults) { for (final WifiConfiguration config : configurations) { if (config.SSID != null && config.SSID.equals("\"" + scan.SSID + "\"")) { if (bestscan == null || scan.level > bestscan.level) { bestscan = scan; bestconfig = config; } if (config == activeconfig) activescan = scan; } } } if (activescan != null) System.out.println("debug wifi asu(active)" + asu(activescan)); if (bestconfig != null && (activeconfig == null || bestconfig.priority != activeconfig.priority) && asu(bestscan) > asu(activescan) * 1.5 && /* (activeSSID == null || activescan != null) && */ asu(bestscan) > 22) { if (!Sipdroid.release) Log.i("SipUA:", "changing to " + bestconfig.SSID); if (activeSSID == null || !activeSSID.equals(bestscan.SSID)) wm.disconnect(); bestconfig.priority = maxconfig.priority + 1; wm.updateNetwork(bestconfig); wm.enableNetwork(bestconfig.networkId, true); wm.saveConfiguration(); if (activeSSID == null || !activeSSID.equals(bestscan.SSID)) wm.reconnect(); lastscan = SystemClock.uptimeMillis(); } else if (activescan != null && asu(activescan) < 15) { wm.disconnect(); wm.disableNetwork(activeconfig.networkId); wm.saveConfiguration(); } } } } }