Merge "Language Update for Wi-Fi/Bluetooth Scanning" into mnc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 667d07f..3b62f4c 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1222,11 +1222,10 @@
     <!-- Message to describe "BLE scan always available feature" when Bluetooth is off. The
       place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring
       the user to "scanning settings" screen. -->
-    <string name="ble_scan_notify_text">To improve location accuracy, apps and
-        services will scan for Bluetooth devices, even when Bluetooth is off.
-        You can change this in
-        <xliff:g id="link_begin">LINK_BEGIN</xliff:g>scanning
-        settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
+    <string name="ble_scan_notify_text">To improve location accuracy, system apps and services can
+      still detect Bluetooth devices. You can change this in
+      <xliff:g id="link_begin">LINK_BEGIN</xliff:g>scanning
+      settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
 
 
     <!-- Bluetooth settings.  The title of the screen to pick which profiles to connect to on the device.  For example, headphones may have both A2DP and headset, this allows the user to choose which one he wants to connect to. -->
@@ -1404,9 +1403,8 @@
     <!-- Message to describe "Wi-Fi scan always available feature" when Wi-Fi is off. The
       place-holders "LINK_BEGIN" and "LINK_END" must NOT be translated. They mark a link to bring
       the user to "scanning settings" screen. -->
-    <string name="wifi_scan_notify_text">To improve location accuracy, apps and
-        services will scan for Wi\u2011Fi networks, even when Wi\u2011Fi is off.
-        You can change this in
+    <string name="wifi_scan_notify_text">To improve location accuracy, system apps and services can
+        still scan for Wi\u2011Fi networks. You can change this in
         <xliff:g id="link_begin">LINK_BEGIN</xliff:g>scanning
         settings<xliff:g id="link_end">LINK_END</xliff:g>.</string>
     <!-- Wifi scan always mode checkbox text -->
@@ -2794,9 +2792,9 @@
     <!-- [CHAR LIMIT=30] Location mode screen, screen title -->
     <string name="location_mode_screen_title">Location mode</string>
     <!-- [CHAR LIMIT=130] Location mode screen, description for high accuracy mode -->
-    <string name="location_mode_high_accuracy_description">Use GPS, Wi\u2011Fi, and cellular networks to determine location </string>
+    <string name="location_mode_high_accuracy_description">Use GPS, Wi\u2011Fi, Bluetooth, or cellular networks to determine location </string>
     <!-- [CHAR LIMIT=130] Location mode screen, description for battery saving mode -->
-    <string name="location_mode_battery_saving_description">Use Wi\u2011Fi and cellular networks to determine location</string>
+    <string name="location_mode_battery_saving_description">Use Wi\u2011Fi, Bluetooth, or cellular networks to determine location</string>
     <!-- [CHAR LIMIT=130] Location mode screen, description for sensors only mode -->
     <string name="location_mode_sensors_only_description">Use GPS to determine location</string>
     <!-- Help menu label [CHAR LIMIT=20] Location settings screen, overflow menu that takes the user
@@ -2807,15 +2805,14 @@
     <!-- [CHAR LIMIT=130] Preference title for Wi-Fi always scanning -->
     <string name="location_scanning_wifi_always_scanning_title">Wi\u2011Fi scanning</string>
     <!-- Preference description text for Wi-Fi always scanning -->
-    <string name="location_scanning_wifi_always_scanning_description">Improve
-        location by allowing apps and services to scan for Wi\u2011Fi networks
-        even when Wi\u2011Fi is off</string>
+    <string name="location_scanning_wifi_always_scanning_description">Improve location by allowing
+      system apps and services to detect Wi\u2011Fi networks at any time.</string>
     <!-- [CHAR LIMIT=130] Description text for Bluetooth always scanning -->
     <string name="location_scanning_bluetooth_always_scanning_title">Bluetooth scanning</string>
     <!-- Description text for Bluetooth always scanning -->
     <string name="location_scanning_bluetooth_always_scanning_description">
-        Improve location by allowing system services to scan for Bluetooth
-        devices, even when Bluetooth is off</string>
+        Improve location by allowing system apps and services to detect Bluetooth devices at any
+        time.</string>
 
     <!-- [CHAR LIMIT=30] Security & location settings screen, setting check box label for Google location service (cell ID, wifi, etc.) -->
     <string name="location_network_based">Wi\u2011Fi &amp; cellular network location</string>
diff --git a/src/com/android/settings/bluetooth/BluetoothSettings.java b/src/com/android/settings/bluetooth/BluetoothSettings.java
index 663deef..68f47e7 100755
--- a/src/com/android/settings/bluetooth/BluetoothSettings.java
+++ b/src/com/android/settings/bluetooth/BluetoothSettings.java
@@ -21,6 +21,7 @@
 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.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 @@
             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 0ea7da9..56d1b97 100644
--- a/src/com/android/settings/wifi/WifiSettings.java
+++ b/src/com/android/settings/wifi/WifiSettings.java
@@ -708,8 +708,17 @@
         }
 
         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.