summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/wifi/WifiEnabler.java
diff options
context:
space:
mode:
authorIrfan Sheriff <isheriff@google.com>2011-09-15 14:45:25 -0700
committerIrfan Sheriff <isheriff@google.com>2011-09-15 19:11:29 -0700
commitb1c0e0b1c93acbc71a2063411ae4ac86f9fc9fbf (patch)
tree1c34d9f5fd9cd6a03a62bdf2431f71a7334e500e /src/com/android/settings/wifi/WifiEnabler.java
parentec10578884e3c23b3585bccde76e9c12978dda05 (diff)
downloadpackages_apps_Settings-b1c0e0b1c93acbc71a2063411ae4ac86f9fc9fbf.tar.gz
packages_apps_Settings-b1c0e0b1c93acbc71a2063411ae4ac86f9fc9fbf.tar.bz2
packages_apps_Settings-b1c0e0b1c93acbc71a2063411ae4ac86f9fc9fbf.zip
Fix settings handling of wifi events
When wifi events come out, settings has to change the switch state. Changing switch state causes settings to also enable/disable wifi which gets into a loop when there is a driver hung event. Fix to only send framework calls when a user has changed the switch settings Bug: 5271322 Change-Id: I0a7d03a3fe0f28622de05981e5f72a9a8814b2d2
Diffstat (limited to 'src/com/android/settings/wifi/WifiEnabler.java')
-rw-r--r--src/com/android/settings/wifi/WifiEnabler.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index 223022dde..987294b59 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -40,6 +40,7 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
private AtomicBoolean mConnected = new AtomicBoolean(false);
private final WifiManager mWifiManager;
+ private boolean mStateMachineEvent;
private final IntentFilter mIntentFilter;
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
@@ -98,6 +99,10 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
}
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ //Do nothing if called as a result of a state machine event
+ if (mStateMachineEvent) {
+ return;
+ }
// Show toast message if Wi-Fi is not allowed in airplane mode
if (isChecked && !WirelessSettings.isRadioAllowed(mContext, Settings.System.RADIO_WIFI)) {
Toast.makeText(mContext, R.string.wifi_in_airplane_mode, Toast.LENGTH_SHORT).show();
@@ -127,19 +132,28 @@ public class WifiEnabler implements CompoundButton.OnCheckedChangeListener {
mSwitch.setEnabled(false);
break;
case WifiManager.WIFI_STATE_ENABLED:
- mSwitch.setChecked(true);
+ setSwitchChecked(true);
mSwitch.setEnabled(true);
break;
case WifiManager.WIFI_STATE_DISABLING:
mSwitch.setEnabled(false);
break;
case WifiManager.WIFI_STATE_DISABLED:
- mSwitch.setChecked(false);
+ setSwitchChecked(false);
mSwitch.setEnabled(true);
break;
default:
- mSwitch.setChecked(false);
+ setSwitchChecked(false);
mSwitch.setEnabled(true);
+ break;
+ }
+ }
+
+ private void setSwitchChecked(boolean checked) {
+ if (checked != mSwitch.isChecked()) {
+ mStateMachineEvent = true;
+ mSwitch.setChecked(checked);
+ mStateMachineEvent = false;
}
}