Merge change Ibad792b8
* changes:
Rename PdpConnection to GsmDataConnection
diff --git a/res/xml/wireless_settings.xml b/res/xml/wireless_settings.xml
index 1bb55ef..2493021 100644
--- a/res/xml/wireless_settings.xml
+++ b/res/xml/wireless_settings.xml
@@ -44,14 +44,12 @@
android:key="toggle_bluetooth"
android:title="@string/bluetooth_quick_toggle_title"
android:summary="@string/bluetooth_quick_toggle_summary"
- android:persistent="false"
- android:dependency="toggle_airplane" />
+ android:persistent="false" />
<PreferenceScreen
android:key="bt_settings"
android:title="@string/bluetooth_settings_title"
- android:summary="@string/bluetooth_settings_summary"
- android:dependency="toggle_airplane">
+ android:summary="@string/bluetooth_settings_summary">
<intent
android:action="android.intent.action.MAIN"
android:targetPackage="com.android.settings"
diff --git a/src/com/android/settings/WirelessSettings.java b/src/com/android/settings/WirelessSettings.java
index 22417bb..ccce2a3 100644
--- a/src/com/android/settings/WirelessSettings.java
+++ b/src/com/android/settings/WirelessSettings.java
@@ -107,12 +107,12 @@
Preference wifiPreference = findPreference(KEY_TOGGLE_WIFI);
Preference btPreference = findPreference(KEY_TOGGLE_BLUETOOTH);
Preference wifiSettings = findPreference(KEY_WIFI_SETTINGS);
+ Preference btSettings = findPreference(KEY_BT_SETTINGS);
Preference vpnSettings = findPreference(KEY_VPN_SETTINGS);
IBinder b = ServiceManager.getService(BluetoothAdapter.BLUETOOTH_SERVICE);
if (b == null) {
// Disable BT Settings if BT service is not available.
- Preference btSettings = findPreference(KEY_BT_SETTINGS);
btSettings.setEnabled(false);
}
@@ -131,6 +131,13 @@
wifiSettings.setDependency(airplanePreference.getKey());
vpnSettings.setDependency(airplanePreference.getKey());
}
+
+ // Manually set dependencies for Bluetooth when not toggleable.
+ if (toggleableRadios == null ||
+ !toggleableRadios.contains(Settings.System.RADIO_BLUETOOTH)) {
+ btPreference.setDependency(airplanePreference.getKey());
+ btSettings.setDependency(airplanePreference.getKey());
+ }
}
@Override
diff --git a/src/com/android/settings/bluetooth/BluetoothEnabler.java b/src/com/android/settings/bluetooth/BluetoothEnabler.java
index b872916..46793ce 100644
--- a/src/com/android/settings/bluetooth/BluetoothEnabler.java
+++ b/src/com/android/settings/bluetooth/BluetoothEnabler.java
@@ -16,6 +16,7 @@
package com.android.settings.bluetooth;
+import com.android.settings.AirplaneModeEnabler;
import com.android.settings.R;
import android.bluetooth.BluetoothAdapter;
@@ -25,6 +26,7 @@
import android.content.IntentFilter;
import android.preference.Preference;
import android.preference.CheckBoxPreference;
+import android.provider.Settings;
import android.text.TextUtils;
import android.util.Config;
@@ -116,14 +118,15 @@
mOriginalSummary :
null);
- /*
- * Don't ever disable the preference. Only enable here. Disablement
- * is taken care of by the dependency code. If this is disabled
- * here, it may not be re-enabled from the framework when dependency
- * is met. http://b/issue?id=2053751
- */
- if (isEnabledByDependency()) {
+ final boolean hasDependency = !TextUtils.isEmpty(mCheckBoxPreference.getDependency());
+ final boolean bluetoothAllowed = isBluetoothAllowed(mContext);
+
+ // Avoid disabling when dependencies have been manually set,
+ // workaround for framework bug http://b/2053751
+ if (bluetoothAllowed) {
mCheckBoxPreference.setEnabled(true);
+ } else if (!hasDependency) {
+ mCheckBoxPreference.setEnabled(false);
}
} else if (state == BluetoothAdapter.STATE_TURNING_ON ||
@@ -139,22 +142,21 @@
}
}
- private boolean isEnabledByDependency() {
- Preference dep = getDependencyPreference();
- if (dep == null) {
+ private static boolean isBluetoothAllowed(Context context) {
+ // allowed if we are not in airplane mode
+ if (!AirplaneModeEnabler.isAirplaneModeOn(context)) {
return true;
}
-
- return !dep.shouldDisableDependents();
- }
-
- private Preference getDependencyPreference() {
- String depKey = mCheckBoxPreference.getDependency();
- if (TextUtils.isEmpty(depKey)) {
- return null;
+ // allowed if bluetooth is not in AIRPLANE_MODE_RADIOS
+ String radios = Settings.System.getString(context.getContentResolver(),
+ Settings.System.AIRPLANE_MODE_RADIOS);
+ if (radios == null || !radios.contains(Settings.System.RADIO_BLUETOOTH)) {
+ return true;
}
-
- return mCheckBoxPreference.getPreferenceManager().findPreference(depKey);
+ // allowed if bluetooth is in AIRPLANE_MODE_TOGGLEABLE_RADIOS
+ radios = Settings.System.getString(context.getContentResolver(),
+ Settings.System.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
+ return (radios != null && radios.contains(Settings.System.RADIO_BLUETOOTH));
}
}
diff --git a/src/com/android/settings/wifi/WifiEnabler.java b/src/com/android/settings/wifi/WifiEnabler.java
index 10a672b..b6c0fb5 100644
--- a/src/com/android/settings/wifi/WifiEnabler.java
+++ b/src/com/android/settings/wifi/WifiEnabler.java
@@ -122,9 +122,18 @@
mWifiCheckBoxPref.setChecked(wifiState == WIFI_STATE_ENABLED);
mWifiCheckBoxPref
.setSummary(wifiState == WIFI_STATE_DISABLED ? mOriginalSummary : null);
-
- mWifiCheckBoxPref.setEnabled(isWifiAllowed(mContext));
-
+
+ final boolean hasDependency = !TextUtils.isEmpty(mWifiCheckBoxPref.getDependency());
+ final boolean wifiAllowed = isWifiAllowed(mContext);
+
+ // Avoid disabling when dependencies have been manually set,
+ // workaround for framework bug http://b/2053751
+ if (wifiAllowed) {
+ mWifiCheckBoxPref.setEnabled(true);
+ } else if (!hasDependency) {
+ mWifiCheckBoxPref.setEnabled(false);
+ }
+
} else if (wifiState == WIFI_STATE_DISABLING || wifiState == WIFI_STATE_ENABLING) {
mWifiCheckBoxPref.setSummary(wifiState == WIFI_STATE_ENABLING ? R.string.wifi_starting
: R.string.wifi_stopping);