From 2d4e135fec1e6e2df65d9a8ad762e4b9f2e57325 Mon Sep 17 00:00:00 2001 From: Irfan Sheriff Date: Wed, 14 Apr 2010 15:15:09 -0700 Subject: [PATCH] Grey out wifi tethering in airplane mode When airplane mode is enabled, wifi tethering should be disabled since there is no real use case for it. This also addresses the issue of trying to restore Wifi (with tethering on) when airplane mode is disabled. Bug: 2594720 Change-Id: I7379ebed74a58b148ae82ed589d09aa2b9ca767d --- src/com/android/settings/wifi/WifiApEnabler.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/com/android/settings/wifi/WifiApEnabler.java b/src/com/android/settings/wifi/WifiApEnabler.java index b8b70c6e063..e907cf70edc 100644 --- a/src/com/android/settings/wifi/WifiApEnabler.java +++ b/src/com/android/settings/wifi/WifiApEnabler.java @@ -88,6 +88,7 @@ public class WifiApEnabler implements Preference.OnPreferenceChangeListener { public void resume() { mContext.registerReceiver(mReceiver, mIntentFilter); + enableWifiCheckBox(); mCheckBox.setOnPreferenceChangeListener(this); } @@ -96,6 +97,16 @@ public class WifiApEnabler implements Preference.OnPreferenceChangeListener { mCheckBox.setOnPreferenceChangeListener(null); } + private void enableWifiCheckBox() { + boolean isAirplaneMode = Settings.System.getInt(mContext.getContentResolver(), + Settings.System.AIRPLANE_MODE_ON, 0) != 0; + if(!isAirplaneMode) { + mCheckBox.setEnabled(true); + } else { + mCheckBox.setEnabled(false); + } + } + public boolean onPreferenceChange(Preference preference, Object value) { final ContentResolver cr = mContext.getContentResolver(); @@ -182,6 +193,7 @@ public class WifiApEnabler implements Preference.OnPreferenceChangeListener { * broadcast notice */ mCheckBox.setChecked(true); + /* Doesnt need the airplane check */ mCheckBox.setEnabled(true); break; case WifiManager.WIFI_AP_STATE_DISABLING: @@ -191,12 +203,12 @@ public class WifiApEnabler implements Preference.OnPreferenceChangeListener { case WifiManager.WIFI_AP_STATE_DISABLED: mCheckBox.setChecked(false); mCheckBox.setSummary(mOriginalSummary); - mCheckBox.setEnabled(true); + enableWifiCheckBox(); break; default: mCheckBox.setChecked(false); mCheckBox.setSummary(R.string.wifi_error); - mCheckBox.setEnabled(true); + enableWifiCheckBox(); } } }