Act on supplicant changes only when disconnected

When wifi network state is disconnected, supplicant
state changes provide more fine grained information to display.
When network is connected, the UI should ignore supplicant
state changes.

Change-Id: I46aa8c2ba80303aae5c74415825102a13cc41380
This commit is contained in:
Irfan Sheriff
2010-11-23 07:43:19 -08:00
parent f48945a7ae
commit 582ab4d414

View File

@@ -59,6 +59,7 @@ import android.widget.Toast;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* This currently provides three types of UI. * This currently provides three types of UI.
@@ -95,6 +96,8 @@ public class WifiSettings extends SettingsPreferenceFragment
private DetailedState mLastState; private DetailedState mLastState;
private WifiInfo mLastInfo; private WifiInfo mLastInfo;
private AtomicBoolean mConnected = new AtomicBoolean(false);
private int mKeyStoreNetworkId = INVALID_NETWORK_ID; private int mKeyStoreNetworkId = INVALID_NETWORK_ID;
private WifiDialog mDialog; private WifiDialog mDialog;
@@ -423,11 +426,20 @@ public class WifiSettings extends SettingsPreferenceFragment
WifiManager.SUPPLICANT_CONFIG_CHANGED_ACTION.equals(action)) { WifiManager.SUPPLICANT_CONFIG_CHANGED_ACTION.equals(action)) {
updateAccessPoints(); updateAccessPoints();
} else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) { } else if (WifiManager.SUPPLICANT_STATE_CHANGED_ACTION.equals(action)) {
//Ignore supplicant state changes when network is connected
//TODO: we should deprecate SUPPLICANT_STATE_CHANGED_ACTION and
//introduce a broadcast that combines the supplicant and network
//network state change events so the apps dont have to worry about
//ignoring supplicant state change when network is connected
//to get more fine grained information.
if (!mConnected.get()) {
updateConnectionState(WifiInfo.getDetailedStateOf((SupplicantState) updateConnectionState(WifiInfo.getDetailedStateOf((SupplicantState)
intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE))); intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE)));
}
} else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) { } else if (WifiManager.NETWORK_STATE_CHANGED_ACTION.equals(action)) {
NetworkInfo info = (NetworkInfo) intent.getParcelableExtra( NetworkInfo info = (NetworkInfo) intent.getParcelableExtra(
WifiManager.EXTRA_NETWORK_INFO); WifiManager.EXTRA_NETWORK_INFO);
mConnected.set(info.isConnected());
changeNextButtonState(info.isConnected()); changeNextButtonState(info.isConnected());
updateConnectionState(info.getDetailedState()); updateConnectionState(info.getDetailedState());
} else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) { } else if (WifiManager.RSSI_CHANGED_ACTION.equals(action)) {