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
This commit is contained in:
Irfan Sheriff
2010-04-14 15:15:09 -07:00
parent 3957b3c147
commit 2d4e135fec

View File

@@ -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();
}
}
}