1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package com.android.settings.location; 17 18 import android.content.Context; 19 import android.provider.Settings; 20 21 import com.android.settings.R; 22 import com.android.settings.core.BasePreferenceController; 23 24 /** 25 * Preference controller for Bluetooth scanning in Location Services. 26 */ 27 public class LocationServicesBluetoothScanningPreferenceController extends 28 BasePreferenceController { 29 LocationServicesBluetoothScanningPreferenceController(Context context, String key)30 public LocationServicesBluetoothScanningPreferenceController(Context context, String key) { 31 super(context, key); 32 } 33 34 @Override getSummary()35 public CharSequence getSummary() { 36 final boolean bleScanOn = Settings.Global.getInt(mContext.getContentResolver(), 37 Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1; 38 int resId = 39 bleScanOn ? R.string.scanning_status_text_on : R.string.scanning_status_text_off; 40 return mContext.getString(resId); 41 } 42 43 @AvailabilityStatus getAvailabilityStatus()44 public int getAvailabilityStatus() { 45 return mContext.getResources().getBoolean(R.bool.config_show_location_scanning) 46 ? AVAILABLE 47 : UNSUPPORTED_ON_DEVICE; 48 } 49 } 50