diff --git a/res/values/strings.xml b/res/values/strings.xml
index 85f133f2a22..a59e3fb1018 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2878,6 +2878,14 @@
PRL version
MEID (sim slot %1$d)
+
+ Both Wi\u2011Fi and Bluetooth are allowed to determine location
+
+ Only Wi\u2011Fi is allowed to determine location
+
+ Only Bluetooth is allowed to determine location
+
+ Neither Wi\u2011Fi nor Bluetooth is allowed to determine location
MEID
@@ -3612,8 +3620,8 @@
High battery use
Low battery use
-
- Scanning
+
+ Wi\u2011Fi and Bluetooth scanning
Wi\u2011Fi scanning
diff --git a/src/com/android/settings/location/LocationScanningPreferenceController.java b/src/com/android/settings/location/LocationScanningPreferenceController.java
index 9d1bdc0dc86..2c05a39e540 100644
--- a/src/com/android/settings/location/LocationScanningPreferenceController.java
+++ b/src/com/android/settings/location/LocationScanningPreferenceController.java
@@ -17,6 +17,7 @@
package com.android.settings.location;
import android.content.Context;
+import android.provider.Settings;
import androidx.annotation.VisibleForTesting;
@@ -25,11 +26,31 @@ import com.android.settings.core.BasePreferenceController;
public class LocationScanningPreferenceController extends BasePreferenceController {
-
@VisibleForTesting static final String KEY_LOCATION_SCANNING = "location_scanning";
+ private final Context mContext;
public LocationScanningPreferenceController(Context context) {
super(context, KEY_LOCATION_SCANNING);
+ mContext = context;
+ }
+
+ @Override
+ public CharSequence getSummary() {
+ final boolean wifiScanOn = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
+ final boolean bleScanOn = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1;
+ int resId;
+ if (wifiScanOn && bleScanOn) {
+ resId = R.string.scanning_status_text_wifi_on_ble_on;
+ } else if (wifiScanOn && !bleScanOn) {
+ resId = R.string.scanning_status_text_wifi_on_ble_off;
+ } else if (!wifiScanOn && bleScanOn) {
+ resId = R.string.scanning_status_text_wifi_off_ble_on;
+ } else {
+ resId = R.string.scanning_status_text_wifi_off_ble_off;
+ }
+ return mContext.getString(resId);
}
@AvailabilityStatus
diff --git a/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java b/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java
index e25b226ed51..994a8fd4316 100644
--- a/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java
+++ b/tests/robotests/src/com/android/settings/location/LocationScanningPreferenceControllerTest.java
@@ -18,7 +18,11 @@ package com.android.settings.location;
import static com.google.common.truth.Truth.assertThat;
+import android.content.Context;
+import android.provider.Settings;
+
import com.android.settings.testutils.SettingsRobolectricTestRunner;
+import com.android.settings.R;
import org.junit.Before;
import org.junit.Test;
@@ -28,22 +32,63 @@ import org.robolectric.annotation.Config;
@RunWith(SettingsRobolectricTestRunner.class)
public class LocationScanningPreferenceControllerTest {
+ private Context mContext;
+ private LocationScanningPreferenceController mController;
- private LocationScanningPreferenceController mController;
+ @Before
+ public void setUp() {
+ mContext = RuntimeEnvironment.application;
+ mController = new LocationScanningPreferenceController(mContext);
+ }
- @Before
- public void setUp() {
- mController = new LocationScanningPreferenceController(RuntimeEnvironment.application);
- }
+ @Test
+ public void testLocationScanning_byDefault_shouldBeShown() {
+ assertThat(mController.isAvailable()).isTrue();
+ }
- @Test
- public void testLocationScanning_byDefault_shouldBeShown() {
- assertThat(mController.isAvailable()).isTrue();
- }
+ @Test
+ public void testLocationScanning_WifiOnBleOn() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 1);
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.scanning_status_text_wifi_on_ble_on));
+ }
- @Test
- @Config(qualifiers = "mcc999")
- public void testLocationScanning_ifDisabled_shouldNotBeShown() {
- assertThat(mController.isAvailable()).isFalse();
- }
+ @Test
+ public void testLocationScanning_WifiOnBleOff() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0);
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.scanning_status_text_wifi_on_ble_off));
+ }
+
+ @Test
+ public void testLocationScanning_WifiOffBleOn() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0);
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 1);
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.scanning_status_text_wifi_off_ble_on));
+ }
+
+ @Test
+ public void testLocationScanning_WifiOffBleOff() {
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0);
+ Settings.Global.putInt(mContext.getContentResolver(),
+ Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0);
+ assertThat(mController.getSummary()).isEqualTo(
+ mContext.getString(R.string.scanning_status_text_wifi_off_ble_off));
+ }
+
+ @Test
+ @Config(qualifiers = "mcc999")
+ public void testLocationScanning_ifDisabled_shouldNotBeShown() {
+ assertThat(mController.isAvailable()).isFalse();
+ }
}
\ No newline at end of file