Allow enabling Wifi when in airplane mode.

If the new system settings value for AIRPLANE_MODE_TOGGLEABLE_RADIOS
contains RADIO_WIFI, then the user will be allowed to enable Wifi
while in airplane mode.
Turning on airplane mode will still disable Wifi, but the user will
be free to reenable it in the Settings app.

We also allow access to the VPN settings under the same circumstances.

Signed-off-by: Mike Lockwood <lockwood@android.com>
This commit is contained in:
Mike Lockwood
2009-07-29 23:25:10 -07:00
parent f0484951fb
commit 83bcc98af1
4 changed files with 47 additions and 34 deletions

View File

@@ -21,14 +21,18 @@ import com.android.settings.wifi.WifiEnabler;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.provider.Settings;
public class WirelessSettings extends PreferenceActivity {
private static final String KEY_TOGGLE_AIRPLANE = "toggle_airplane";
private static final String KEY_TOGGLE_BLUETOOTH = "toggle_bluetooth";
private static final String KEY_TOGGLE_WIFI = "toggle_wifi";
private static final String KEY_WIFI_SETTINGS = "wifi_settings";
private static final String KEY_VPN_SETTINGS = "vpn_settings";
private WifiEnabler mWifiEnabler;
private AirplaneModeEnabler mAirplaneModeEnabler;
@@ -63,18 +67,27 @@ public class WirelessSettings extends PreferenceActivity {
private void initToggles() {
Preference airplanePreference = findPreference(KEY_TOGGLE_AIRPLANE);
Preference wifiPreference = findPreference(KEY_TOGGLE_WIFI);
Preference btPreference = findPreference(KEY_TOGGLE_BLUETOOTH);
Preference wifiSettings = findPreference(KEY_WIFI_SETTINGS);
Preference vpnSettings = findPreference(KEY_VPN_SETTINGS);
mWifiEnabler = new WifiEnabler(
this,
(WifiManager) getSystemService(WIFI_SERVICE),
(CheckBoxPreference) findPreference(KEY_TOGGLE_WIFI));
this, (WifiManager) getSystemService(WIFI_SERVICE),
(CheckBoxPreference) wifiPreference);
mAirplaneModeEnabler = new AirplaneModeEnabler(
this,
(CheckBoxPreference) findPreference(KEY_TOGGLE_AIRPLANE));
mBtEnabler = new BluetoothEnabler(
this,
(CheckBoxPreference) findPreference(KEY_TOGGLE_BLUETOOTH));
this, (CheckBoxPreference) airplanePreference);
mBtEnabler = new BluetoothEnabler(this, (CheckBoxPreference) btPreference);
// manually set up dependencies for Wifi if its radio is not toggleable in airplane mode
String toggleableRadios = Settings.System.getString(getContentResolver(),
Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
if (toggleableRadios == null || !toggleableRadios.contains(Settings.System.RADIO_WIFI)) {
wifiPreference.setDependency(airplanePreference.getKey());
wifiSettings.setDependency(airplanePreference.getKey());
vpnSettings.setDependency(airplanePreference.getKey());
}
}
}