Merge cherrypicks of ['googleplex-android-review.googlesource.com/22861203'] into tm-qpr3-release.
Change-Id: Ic475f6b2145d7a1056cde4b151f565d94c7bbc61
diff --git a/src/com/android/settings/location/BluetoothScanningMainSwitchPreferenceController.java b/src/com/android/settings/location/BluetoothScanningMainSwitchPreferenceController.java
index b491ec9..78e3184 100644
--- a/src/com/android/settings/location/BluetoothScanningMainSwitchPreferenceController.java
+++ b/src/com/android/settings/location/BluetoothScanningMainSwitchPreferenceController.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.provider.Settings;
import android.widget.Switch;
+import android.os.UserManager;
import androidx.preference.PreferenceScreen;
@@ -33,9 +34,11 @@
implements OnMainSwitchChangeListener {
private static final String KEY_BLUETOOTH_SCANNING_SWITCH = "bluetooth_always_scanning_switch";
+ private final UserManager mUserManager;
public BluetoothScanningMainSwitchPreferenceController(Context context) {
super(context, KEY_BLUETOOTH_SCANNING_SWITCH);
+ mUserManager = UserManager.get(context);
}
@Override
@@ -49,7 +52,9 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_location_scanning)
- ? AVAILABLE
+ ? (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_LOCATION)
+ ? DISABLED_DEPENDENT_SETTING
+ : AVAILABLE)
: UNSUPPORTED_ON_DEVICE;
}
diff --git a/src/com/android/settings/location/WifiScanningMainSwitchPreferenceController.java b/src/com/android/settings/location/WifiScanningMainSwitchPreferenceController.java
index 546f1e1..e22b0a0 100644
--- a/src/com/android/settings/location/WifiScanningMainSwitchPreferenceController.java
+++ b/src/com/android/settings/location/WifiScanningMainSwitchPreferenceController.java
@@ -18,6 +18,7 @@
import android.content.Context;
import android.net.wifi.WifiManager;
import android.widget.Switch;
+import android.os.UserManager;
import androidx.preference.PreferenceScreen;
@@ -34,10 +35,12 @@
private static final String KEY_WIFI_SCANNING_SWITCH = "wifi_always_scanning_switch";
private final WifiManager mWifiManager;
+ private final UserManager mUserManager;
public WifiScanningMainSwitchPreferenceController(Context context) {
super(context, KEY_WIFI_SCANNING_SWITCH);
mWifiManager = context.getSystemService(WifiManager.class);
+ mUserManager = UserManager.get(context);
}
@Override
@@ -52,7 +55,9 @@
@Override
public int getAvailabilityStatus() {
return mContext.getResources().getBoolean(R.bool.config_show_location_scanning)
- ? AVAILABLE
+ ? (mUserManager.hasUserRestriction(UserManager.DISALLOW_CONFIG_LOCATION)
+ ? DISABLED_DEPENDENT_SETTING
+ : AVAILABLE)
: UNSUPPORTED_ON_DEVICE;
}