private void updateConnectionState(DetailedState state) { /* sticky broadcasts can call this when wifi is disabled */ if (!mWifiManager.isWifiEnabled()) { mScanner.pause(); return; } if (state == DetailedState.OBTAINING_IPADDR) { mScanner.pause(); } else { mScanner.resume(); } mLastInfo = mWifiManager.getConnectionInfo(); if (state != null) { mLastState = state; } for (int i = getPreferenceScreen().getPreferenceCount() - 1; i >= 0; --i) { // Maybe there's a WifiConfigPreference Preference preference = getPreferenceScreen().getPreference(i); if (preference instanceof AccessPoint) { final AccessPoint accessPoint = (AccessPoint) preference; accessPoint.update(mLastInfo, mLastState); } } }
private void updateWifiState(int state) { Activity activity = getActivity(); if (activity != null) { activity.invalidateOptionsMenu(); } switch (state) { case WifiManager.WIFI_STATE_ENABLED: // this function only returns valid results in enabled state mIbssSupported = mWifiManager.isIbssSupported(); mSupportedChannels = mWifiManager.getSupportedChannels(); mScanner.resume(); return; // not break, to avoid the call to pause() below case WifiManager.WIFI_STATE_ENABLING: addMessagePreference(R.string.wifi_starting); break; case WifiManager.WIFI_STATE_DISABLED: setOffMessage(); break; } mLastInfo = null; mLastState = null; mScanner.pause(); }
@Override public void onPause() { super.onPause(); if (mWifiEnabler != null) { mWifiEnabler.pause(); } getActivity().unregisterReceiver(mReceiver); mScanner.pause(); }
/** Requests wifi module to pause wifi scan. May be ignored when the module is disabled. */ /* package */ void pauseWifiScan() { if (mWifiManager.isWifiEnabled()) { mScanner.pause(); } }