blob: 436676df55862498578877edde21b33cbca0cbb7 [file] [log] [blame]
Ben Line8377712018-01-11 15:32:36 -08001/*
2 * Copyright (C) 2018 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
17package com.android.settings.location;
18
19import android.content.Context;
Lifu Tangbee74712018-12-05 16:06:20 -080020import android.provider.Settings;
Ben Line8377712018-01-11 15:32:36 -080021
Ben Line8377712018-01-11 15:32:36 -080022import com.android.settings.R;
Fan Zhangc7162cd2018-06-18 15:21:41 -070023import com.android.settings.core.BasePreferenceController;
Ben Line8377712018-01-11 15:32:36 -080024
Ben Line8377712018-01-11 15:32:36 -080025
26public class LocationScanningPreferenceController extends BasePreferenceController {
Ben Line8377712018-01-11 15:32:36 -080027
Raff Tsai22295852019-11-22 11:35:40 +080028 public LocationScanningPreferenceController(Context context, String key) {
29 super(context, key);
Lifu Tangbee74712018-12-05 16:06:20 -080030 }
31
32 @Override
33 public CharSequence getSummary() {
34 final boolean wifiScanOn = Settings.Global.getInt(mContext.getContentResolver(),
35 Settings.Global.WIFI_SCAN_ALWAYS_AVAILABLE, 0) == 1;
36 final boolean bleScanOn = Settings.Global.getInt(mContext.getContentResolver(),
37 Settings.Global.BLE_SCAN_ALWAYS_AVAILABLE, 0) == 1;
38 int resId;
39 if (wifiScanOn && bleScanOn) {
40 resId = R.string.scanning_status_text_wifi_on_ble_on;
41 } else if (wifiScanOn && !bleScanOn) {
42 resId = R.string.scanning_status_text_wifi_on_ble_off;
43 } else if (!wifiScanOn && bleScanOn) {
44 resId = R.string.scanning_status_text_wifi_off_ble_on;
45 } else {
46 resId = R.string.scanning_status_text_wifi_off_ble_off;
47 }
48 return mContext.getString(resId);
Ben Line8377712018-01-11 15:32:36 -080049 }
50
51 @AvailabilityStatus
52 public int getAvailabilityStatus() {
53 return mContext.getResources().getBoolean(R.bool.config_show_location_scanning)
54 ? AVAILABLE
Matthew Fritzef87a1f32018-05-03 16:46:51 -070055 : UNSUPPORTED_ON_DEVICE;
Ben Line8377712018-01-11 15:32:36 -080056 }
57}