Remove location scanning settings completely
Bug: 148482487
Test: manual
Change-Id: I08e7f0e66d936203275a1cc9614bfd6f88d1e5bc
Merged-In: I08e7f0e66d936203275a1cc9614bfd6f88d1e5bc
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0106167..7cad377 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -128,11 +128,6 @@
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
- <intent-filter android:priority="100">
- <action android:name="android.settings.LOCATION_SCANNING_SETTINGS" />
- <category android:name="android.intent.category.DEFAULT"/>
- </intent-filter>
-
<intent-filter android:priority="1">
<action android:name="android.settings.APPLICATION_SETTINGS" />
<action android:name="android.settings.MANAGE_APPLICATIONS_SETTINGS" />
diff --git a/res/values/preference_keys.xml b/res/values/preference_keys.xml
index fffc0df..28b61b1 100644
--- a/res/values/preference_keys.xml
+++ b/res/values/preference_keys.xml
@@ -284,10 +284,6 @@
</string>
<string name="pk_location_app_permissions" translatable="false">location_app_permissions
</string>
- <string name="pk_location_scanning" translatable="false">location_scanning</string>
- <string name="pk_location_scanning_wifi" translatable="false">location_scanning_wifi</string>
- <string name="pk_location_scanning_bluetooth" translatable="false">location_scanning_bluetooth
- </string>
<string name="pk_location_services" translatable="false">location_services</string>
<string name="pk_location_footer" translatable="false">location_footer</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 7b27df0..b0584ed 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -683,21 +683,9 @@
<string name="location_settings_recent_requests_empty_message">No recent location requests</string>
<!-- Title of Location App-level Permissions setting [CHAR LIMIT=60] -->
<string name="location_settings_app_permissions_title">App-level permissions</string>
- <!-- Title of Location Scanning setting [CHAR LIMIT=60] -->
- <string name="location_settings_scanning_title">Scanning</string>
<!-- Title of Location Services category [CHAR LIMIT=60] -->
<string name="location_settings_services_title">Location Services</string>
- <!-- Location Scanning --><skip/>
- <!-- Title of Wi-Fi scanning preference [CHAR LIMIT=60] -->
- <string name="location_settings_wifi_scanning_title">Wi\u2011Fi scanning</string>
- <!-- Summary of Wi-Fi scanning preference [CHAR LIMIT=240] -->
- <string name="location_settings_wifi_scanning_summary">Allow apps and services to scan for Wi\u2011Fi networks at any time, even when Wi\u2011Fi is off. This can be used, for example, to improve location-based features and services.</string>
- <!-- Title of Bluetooth scanning preference [CHAT LIMIT=60]-->
- <string name="location_settings_bluetooth_scanning_title">Bluetooth scanning</string>
- <!-- Summary of Bluetooth scanning preference [CHAR LIMIT=240] -->
- <string name="location_settings_bluetooth_scanning_summary">Allow apps and services to scan for nearby devices at any time, even when Bluetooth is off. This can be used, for example, to improve location-based features and services.</string>
-
<!-- System --><skip/>
<!-- Main setting menu item to go into system settings -->
<string name="system_setting_title">System</string>
diff --git a/res/xml/location_scanning_fragment.xml b/res/xml/location_scanning_fragment.xml
deleted file mode 100644
index f71f246..0000000
--- a/res/xml/location_scanning_fragment.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright 2018 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res-auto"
- android:title="@string/location_settings_scanning_title">
- <SwitchPreference
- android:key="@string/pk_location_scanning_wifi"
- android:summary="@string/location_settings_wifi_scanning_summary"
- android:title="@string/location_settings_wifi_scanning_title"
- settings:controller="com.android.car.settings.location.WifiScanningPreferenceController"/>
- <SwitchPreference
- android:key="@string/pk_location_scanning_bluetooth"
- android:summary="@string/location_settings_bluetooth_scanning_summary"
- android:title="@string/location_settings_bluetooth_scanning_title"
- settings:controller="com.android.car.settings.location.BluetoothScanningPreferenceController"/>
-</PreferenceScreen>
diff --git a/res/xml/location_settings_fragment.xml b/res/xml/location_settings_fragment.xml
index 4f1b57c..3f3d121 100644
--- a/res/xml/location_settings_fragment.xml
+++ b/res/xml/location_settings_fragment.xml
@@ -33,11 +33,6 @@
android:value="android.permission-group.LOCATION"/>
</intent>
</Preference>
- <Preference
- android:fragment="com.android.car.settings.location.LocationScanningFragment"
- android:key="@string/pk_location_scanning"
- android:title="@string/location_settings_scanning_title"
- settings:controller="com.android.car.settings.location.LocationScanningPreferenceController"/>
<PreferenceCategory
android:key="@string/pk_location_services"
android:title="@string/location_settings_services_title"
diff --git a/src/com/android/car/settings/common/FragmentResolver.java b/src/com/android/car/settings/common/FragmentResolver.java
index 5350cbf..ed94fb4 100644
--- a/src/com/android/car/settings/common/FragmentResolver.java
+++ b/src/com/android/car/settings/common/FragmentResolver.java
@@ -44,7 +44,6 @@
import com.android.car.settings.home.HomepageFragment;
import com.android.car.settings.inputmethod.KeyboardFragment;
import com.android.car.settings.language.LanguagePickerFragment;
-import com.android.car.settings.location.LocationScanningFragment;
import com.android.car.settings.network.MobileNetworkFragment;
import com.android.car.settings.quicksettings.QuickSettingFragment;
import com.android.car.settings.sound.SoundSettingsFragment;
@@ -111,9 +110,6 @@
case Settings.ACTION_BLUETOOTH_SETTINGS:
return new BluetoothSettingsFragment();
- case Settings.ACTION_LOCATION_SCANNING_SETTINGS:
- return new LocationScanningFragment();
-
case Settings.ACTION_APPLICATION_SETTINGS:
case Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS:
case Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS:
diff --git a/src/com/android/car/settings/location/BluetoothScanningPreferenceController.java b/src/com/android/car/settings/location/BluetoothScanningPreferenceController.java
deleted file mode 100644
index 1427bfd..0000000
--- a/src/com/android/car/settings/location/BluetoothScanningPreferenceController.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.car.settings.location;
-
-import android.car.drivingstate.CarUxRestrictions;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-
-import androidx.preference.TwoStatePreference;
-
-import com.android.car.settings.common.FragmentController;
-import com.android.car.settings.common.PreferenceController;
-
-/**
- * Handles Bluetooth location scanning settings.
- */
-public class BluetoothScanningPreferenceController extends
- PreferenceController<TwoStatePreference> {
-
- public BluetoothScanningPreferenceController(Context context, String preferenceKey,
- FragmentController fragmentController, CarUxRestrictions uxRestrictions) {
- super(context, preferenceKey, fragmentController, uxRestrictions);
- }
-
- @Override
- protected Class<TwoStatePreference> getPreferenceType() {
- return TwoStatePreference.class;
- }
-
- @Override
- protected int getAvailabilityStatus() {
- return getContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_BLUETOOTH_LE) ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- protected void updateState(TwoStatePreference preference) {
- preference.setChecked(Settings.Global.getInt(getContext().getContentResolver(),
- Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1);
- }
-
- @Override
- protected boolean handlePreferenceChanged(TwoStatePreference preference, Object newValue) {
- boolean isBluetoothScanningEnabled = (boolean) newValue;
- Settings.Global.putInt(getContext().getContentResolver(),
- Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, isBluetoothScanningEnabled ? 1 : 0);
- return true;
- }
-}
diff --git a/src/com/android/car/settings/location/LocationScanningFragment.java b/src/com/android/car/settings/location/LocationScanningFragment.java
deleted file mode 100644
index 7b7fa5d..0000000
--- a/src/com/android/car/settings/location/LocationScanningFragment.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.car.settings.location;
-
-import androidx.annotation.XmlRes;
-
-import com.android.car.settings.R;
-import com.android.car.settings.common.SettingsFragment;
-
-/**
- * Fragment that hosts Location Scanning settings.
- */
-public class LocationScanningFragment extends SettingsFragment {
-
- @Override
- @XmlRes
- protected int getPreferenceScreenResId() {
- return R.xml.location_scanning_fragment;
- }
-}
diff --git a/src/com/android/car/settings/location/LocationScanningPreferenceController.java b/src/com/android/car/settings/location/LocationScanningPreferenceController.java
deleted file mode 100644
index 9b7a259..0000000
--- a/src/com/android/car/settings/location/LocationScanningPreferenceController.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.car.settings.location;
-
-import android.car.drivingstate.CarUxRestrictions;
-import android.content.Context;
-import android.content.pm.PackageManager;
-
-import androidx.preference.Preference;
-
-import com.android.car.settings.common.FragmentController;
-import com.android.car.settings.common.PreferenceController;
-
-/**
- * Hides the Scanning entry if neither Wi-Fi nor Bluetooth are supported.
- */
-public class LocationScanningPreferenceController extends PreferenceController<Preference> {
-
- public LocationScanningPreferenceController(Context context, String preferenceKey,
- FragmentController fragmentController, CarUxRestrictions uxRestrictions) {
- super(context, preferenceKey, fragmentController, uxRestrictions);
- }
-
- @Override
- protected Class<Preference> getPreferenceType() {
- return Preference.class;
- }
-
- @Override
- public int getAvailabilityStatus() {
- PackageManager packageManager = getContext().getPackageManager();
- return (packageManager.hasSystemFeature(PackageManager.FEATURE_WIFI)
- || packageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE))
- ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
- }
-}
diff --git a/src/com/android/car/settings/location/WifiScanningPreferenceController.java b/src/com/android/car/settings/location/WifiScanningPreferenceController.java
deleted file mode 100644
index 6a8031a..0000000
--- a/src/com/android/car/settings/location/WifiScanningPreferenceController.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.car.settings.location;
-
-import android.car.drivingstate.CarUxRestrictions;
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-
-import androidx.preference.TwoStatePreference;
-
-import com.android.car.settings.common.FragmentController;
-import com.android.car.settings.common.PreferenceController;
-
-/**
- * Handles Wi-Fi location scanning settings.
- */
-public class WifiScanningPreferenceController extends PreferenceController<TwoStatePreference> {
-
- public WifiScanningPreferenceController(Context context, String preferenceKey,
- FragmentController fragmentController, CarUxRestrictions uxRestrictions) {
- super(context, preferenceKey, fragmentController, uxRestrictions);
- }
-
- @Override
- protected Class<TwoStatePreference> getPreferenceType() {
- return TwoStatePreference.class;
- }
-
- @Override
- protected int getAvailabilityStatus() {
- return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)
- ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
- }
-
- @Override
- protected void updateState(TwoStatePreference preference) {
- preference.setChecked(Settings.Global.getInt(getContext().getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1);
- }
-
- @Override
- protected boolean handlePreferenceChanged(TwoStatePreference preference, Object newValue) {
- boolean isWifiScanningEnabled = (boolean) newValue;
- Settings.Global.putInt(getContext().getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, isWifiScanningEnabled ? 1 : 0);
- return true;
- }
-}
diff --git a/tests/robotests/src/com/android/car/settings/location/BluetoothScanningPreferenceControllerTest.java b/tests/robotests/src/com/android/car/settings/location/BluetoothScanningPreferenceControllerTest.java
deleted file mode 100644
index abb822b..0000000
--- a/tests/robotests/src/com/android/car/settings/location/BluetoothScanningPreferenceControllerTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.car.settings.location;
-
-import static com.android.car.settings.common.PreferenceController.AVAILABLE;
-import static com.android.car.settings.common.PreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-
-import androidx.lifecycle.Lifecycle;
-import androidx.preference.SwitchPreference;
-
-import com.android.car.settings.CarSettingsRobolectricTestRunner;
-import com.android.car.settings.common.PreferenceControllerTestHelper;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-
-@RunWith(CarSettingsRobolectricTestRunner.class)
-public class BluetoothScanningPreferenceControllerTest {
-
- private Context mContext;
- private SwitchPreference mPreference;
- private BluetoothScanningPreferenceController mController;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mPreference = new SwitchPreference(mContext);
- PreferenceControllerTestHelper<BluetoothScanningPreferenceController> controllerHelper =
- new PreferenceControllerTestHelper<>(mContext,
- BluetoothScanningPreferenceController.class, mPreference);
- mController = controllerHelper.getController();
- Shadows.shadowOf(mContext.getPackageManager()).setSystemFeature(
- PackageManager.FEATURE_BLUETOOTH_LE, /* supported= */ true);
- controllerHelper.sendLifecycleEvent(Lifecycle.Event.ON_CREATE);
- }
-
- @Test
- public void getAvailabilityStatus_hasBluetoothFeature_available() {
- Shadows.shadowOf(mContext.getPackageManager()).setSystemFeature(
- PackageManager.FEATURE_BLUETOOTH_LE, /* supported= */ true);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_noBluetoothFeature_unsupported() {
- Shadows.shadowOf(mContext.getPackageManager()).setSystemFeature(
- PackageManager.FEATURE_BLUETOOTH_LE, /* supported= */ false);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
- }
-
- @Test
- public void refreshUi_bluetoothScanningEnabled_shouldCheckPreference() {
- mPreference.setChecked(false);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 1);
- mController.refreshUi();
-
- assertThat(mPreference.isChecked()).isTrue();
- }
-
- @Test
- public void refreshUi_bluetoothScanningDisabled_shouldUncheckPreference() {
- mPreference.setChecked(true);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0);
- mController.refreshUi();
-
- assertThat(mPreference.isChecked()).isFalse();
- }
-
- @Test
- public void handlePreferenceChanged_preferenceChecked_shouldEnableBluetoothScanning() {
- mPreference.callChangeListener(true);
-
- assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0)).isEqualTo(1);
- }
-
- @Test
- public void handlePreferenceChanged_preferenceUnchecked_shouldDisableBluetoothScanning() {
- mPreference.callChangeListener(false);
-
- assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 1)).isEqualTo(0);
- }
-}
diff --git a/tests/robotests/src/com/android/car/settings/location/LocationScanningPreferenceControllerTest.java b/tests/robotests/src/com/android/car/settings/location/LocationScanningPreferenceControllerTest.java
deleted file mode 100644
index 15a9716..0000000
--- a/tests/robotests/src/com/android/car/settings/location/LocationScanningPreferenceControllerTest.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.car.settings.location;
-
-import static com.android.car.settings.common.PreferenceController.AVAILABLE;
-import static com.android.car.settings.common.PreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-
-import androidx.lifecycle.Lifecycle;
-import androidx.preference.Preference;
-
-import com.android.car.settings.CarSettingsRobolectricTestRunner;
-import com.android.car.settings.common.PreferenceControllerTestHelper;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-import org.robolectric.shadows.ShadowPackageManager;
-
-@RunWith(CarSettingsRobolectricTestRunner.class)
-public class LocationScanningPreferenceControllerTest {
-
- private ShadowPackageManager mShadowPackageManager;
- private LocationScanningPreferenceController mController;
-
- @Before
- public void setUp() {
- Context context = RuntimeEnvironment.application;
- PreferenceControllerTestHelper<LocationScanningPreferenceController> controllerHelper =
- new PreferenceControllerTestHelper<>(context,
- LocationScanningPreferenceController.class, new Preference(context));
- mController = controllerHelper.getController();
- controllerHelper.sendLifecycleEvent(Lifecycle.Event.ON_CREATE);
- mShadowPackageManager = Shadows.shadowOf(context.getPackageManager());
- }
-
- @Test
- public void getAvailabilityStatus_available_wifiOrBluetooth() {
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_WIFI, /* supported= */ true);
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE,
- /* supported= */ false);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
-
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_WIFI, /* supported= */ false);
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE,
- /* supported= */ true);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_notAvailable_noWifiNoBluetooth() {
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_WIFI, /* supported= */ false);
- mShadowPackageManager.setSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE,
- /* supported= */ false);
-
- assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
- }
-}
diff --git a/tests/robotests/src/com/android/car/settings/location/WifiScanningPreferenceControllerTest.java b/tests/robotests/src/com/android/car/settings/location/WifiScanningPreferenceControllerTest.java
deleted file mode 100644
index b97887d..0000000
--- a/tests/robotests/src/com/android/car/settings/location/WifiScanningPreferenceControllerTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.car.settings.location;
-
-import static com.android.car.settings.common.PreferenceController.AVAILABLE;
-import static com.android.car.settings.common.PreferenceController.UNSUPPORTED_ON_DEVICE;
-
-import static com.google.common.truth.Truth.assertThat;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.provider.Settings;
-
-import androidx.lifecycle.Lifecycle;
-import androidx.preference.SwitchPreference;
-
-import com.android.car.settings.CarSettingsRobolectricTestRunner;
-import com.android.car.settings.common.PreferenceControllerTestHelper;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.robolectric.RuntimeEnvironment;
-import org.robolectric.Shadows;
-
-@RunWith(CarSettingsRobolectricTestRunner.class)
-public class WifiScanningPreferenceControllerTest {
-
- private Context mContext;
- private SwitchPreference mPreference;
- private WifiScanningPreferenceController mController;
-
- @Before
- public void setUp() {
- mContext = RuntimeEnvironment.application;
- mPreference = new SwitchPreference(mContext);
- PreferenceControllerTestHelper<WifiScanningPreferenceController> controllerHelper =
- new PreferenceControllerTestHelper<>(mContext,
- WifiScanningPreferenceController.class, mPreference);
- mController = controllerHelper.getController();
- Shadows.shadowOf(mContext.getPackageManager()).setSystemFeature(
- PackageManager.FEATURE_WIFI, /* supported= */ true);
- controllerHelper.sendLifecycleEvent(Lifecycle.Event.ON_CREATE);
- }
-
- @Test
- public void getAvailabilityStatus_hasWifiFeature_available() {
- Shadows.shadowOf(mContext.getPackageManager()).setSystemFeature(
- PackageManager.FEATURE_WIFI, /* supported= */ true);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(AVAILABLE);
- }
-
- @Test
- public void getAvailabilityStatus_noWifiFeature_unsupported() {
- Shadows.shadowOf(mContext.getPackageManager()).setSystemFeature(
- PackageManager.FEATURE_WIFI, /* supported= */ false);
- assertThat(mController.getAvailabilityStatus()).isEqualTo(UNSUPPORTED_ON_DEVICE);
- }
-
- @Test
- public void refreshUi_wifiScanningEnabled_shouldCheckPreference() {
- mPreference.setChecked(false);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1);
- mController.refreshUi();
-
- assertThat(mPreference.isChecked()).isTrue();
- }
-
- @Test
- public void refreshUi_wifiScanningDisabled_shouldUncheckPreference() {
- mPreference.setChecked(true);
- Settings.Global.putInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0);
- mController.refreshUi();
-
- assertThat(mPreference.isChecked()).isFalse();
- }
-
- @Test
- public void handlePreferenceChanged_preferenceChecked_shouldEnableWifiScanning() {
- mPreference.callChangeListener(true);
-
- assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0)).isEqualTo(1);
- }
-
- @Test
- public void handlePreferenceChanged_preferenceUnchecked_shouldDisableWifiScanning() {
- mPreference.callChangeListener(false);
-
- assertThat(Settings.Global.getInt(mContext.getContentResolver(),
- Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 1)).isEqualTo(0);
- }
-}