diff --git a/res/values/strings.xml b/res/values/strings.xml index 120c701b2ac..57ecabf073e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -1219,11 +1219,10 @@ - To improve location accuracy, apps and - services will scan for Bluetooth devices, even when Bluetooth is off. - You can change this in - LINK_BEGINscanning - settingsLINK_END. + To improve location accuracy, system apps and services can + still detect Bluetooth devices. You can change this in + LINK_BEGINscanning + settingsLINK_END. @@ -1401,9 +1400,8 @@ - To improve location accuracy, apps and - services will scan for Wi\u2011Fi networks, even when Wi\u2011Fi is off. - You can change this in + To improve location accuracy, system apps and services can + still scan for Wi\u2011Fi networks. You can change this in LINK_BEGINscanning settingsLINK_END. @@ -2791,9 +2789,9 @@ Location mode - Use GPS, Wi\u2011Fi, and cellular networks to determine location + Use GPS, Wi\u2011Fi, Bluetooth, or cellular networks to determine location - Use Wi\u2011Fi and cellular networks to determine location + Use Wi\u2011Fi, Bluetooth, or cellular networks to determine location Use GPS to determine location Wi\u2011Fi scanning - Improve - location by allowing apps and services to scan for Wi\u2011Fi networks - even when Wi\u2011Fi is off + Improve location by allowing + system apps and services to detect Wi\u2011Fi networks at any time. Bluetooth scanning - Improve location by allowing system services to scan for Bluetooth - devices, even when Bluetooth is off + Improve location by allowing system apps and services to detect Bluetooth devices at any + time. Wi\u2011Fi & cellular network location diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java index 663deef6a3f..68f47e7a6e4 100755 --- a/src/com/android/settings/bluetooth/BluetoothSettings.java +++ b/src/com/android/settings/bluetooth/BluetoothSettings.java @@ -21,6 +21,7 @@ import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH; import android.bluetooth.BluetoothAdapter; import android.bluetooth.BluetoothDevice; import android.content.BroadcastReceiver; +import android.content.ContentResolver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; @@ -30,6 +31,7 @@ import android.preference.Preference; import android.preference.PreferenceCategory; import android.preference.PreferenceGroup; import android.preference.PreferenceScreen; +import android.provider.Settings; import android.text.Spannable; import android.text.style.TextAppearanceSpan; import android.util.Log; @@ -381,20 +383,30 @@ public final class BluetoothSettings extends DeviceListPreferenceFragment implem return; } final CharSequence briefText = getText(R.string.bluetooth_empty_list_bluetooth_off); - final StringBuilder contentBuilder = new StringBuilder(); - contentBuilder.append(briefText); - contentBuilder.append("\n\n"); - contentBuilder.append(getText(R.string.ble_scan_notify_text)); + + final ContentResolver resolver = getActivity().getContentResolver(); + final boolean bleScanningMode = Settings.Global.getInt( + resolver, Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1; + + if (!bleScanningMode) { + // Show only the brief text if the scanning mode has been turned off. + mEmptyView.setText(briefText, TextView.BufferType.SPANNABLE); + } else { + final StringBuilder contentBuilder = new StringBuilder(); + contentBuilder.append(briefText); + contentBuilder.append("\n\n"); + contentBuilder.append(getText(R.string.ble_scan_notify_text)); + LinkifyUtils.linkify(mEmptyView, contentBuilder, new LinkifyUtils.OnClickListener() { + @Override + public void onClick() { + final SettingsActivity activity = + (SettingsActivity) BluetoothSettings.this.getActivity(); + activity.startPreferencePanel(ScanningSettings.class.getName(), null, + R.string.location_scanning_screen_title, null, null, 0); + } + }); + } getPreferenceScreen().removeAll(); - LinkifyUtils.linkify(mEmptyView, contentBuilder, new LinkifyUtils.OnClickListener() { - @Override - public void onClick() { - final SettingsActivity activity = - (SettingsActivity) BluetoothSettings.this.getActivity(); - activity.startPreferencePanel(ScanningSettings.class.getName(), null, - R.string.location_scanning_screen_title, null, null, 0); - } - }); Spannable boldSpan = (Spannable) mEmptyView.getText(); boldSpan.setSpan( new TextAppearanceSpan(getActivity(), android.R.style.TextAppearance_Medium), 0, diff --git a/src/com/android/settings/wifi/WifiSettings.java b/src/com/android/settings/wifi/WifiSettings.java index 0ea7da91d44..56d1b97d3f0 100644 --- a/src/com/android/settings/wifi/WifiSettings.java +++ b/src/com/android/settings/wifi/WifiSettings.java @@ -708,8 +708,17 @@ public class WifiSettings extends RestrictedSettingsFragment } final CharSequence briefText = getText(R.string.wifi_empty_list_wifi_off); - if (isUiRestricted()) { - // Show only the brief text if the user is not allowed to configure scanning settings. + + // Don't use WifiManager.isScanAlwaysAvailable() to check the Wi-Fi scanning mode. Instead, + // read the system settings directly. Because when the device is in Airplane mode, even if + // Wi-Fi scanning mode is on, WifiManager.isScanAlwaysAvailable() still returns "off". + final ContentResolver resolver = getActivity().getContentResolver(); + final boolean wifiScanningMode = Settings.Global.getInt( + resolver, Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1; + + if (isUiRestricted() || !wifiScanningMode) { + // Show only the brief text if the user is not allowed to configure scanning settings, + // or the scanning mode has been turned off. mEmptyView.setText(briefText, BufferType.SPANNABLE); } else { // Append the description of scanning settings with link.