Ben Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.settings.location; |
| 18 | |
| 19 | import android.content.Context; |
Lifu Tang | bee7471 | 2018-12-05 16:06:20 -0800 | [diff] [blame] | 20 | import android.provider.Settings; |
Ben Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 21 | |
Ben Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 22 | import com.android.settings.R; |
Fan Zhang | c7162cd | 2018-06-18 15:21:41 -0700 | [diff] [blame] | 23 | import com.android.settings.core.BasePreferenceController; |
Ben Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 24 | |
Ben Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 25 | |
| 26 | public class LocationScanningPreferenceController extends BasePreferenceController { |
Ben Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 27 | |
Raff Tsai | 2229585 | 2019-11-22 11:35:40 +0800 | [diff] [blame] | 28 | public LocationScanningPreferenceController(Context context, String key) { |
| 29 | super(context, key); |
Lifu Tang | bee7471 | 2018-12-05 16:06:20 -0800 | [diff] [blame] | 30 | } |
| 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 Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | @AvailabilityStatus |
| 52 | public int getAvailabilityStatus() { |
| 53 | return mContext.getResources().getBoolean(R.bool.config_show_location_scanning) |
| 54 | ? AVAILABLE |
Matthew Fritze | f87a1f3 | 2018-05-03 16:46:51 -0700 | [diff] [blame] | 55 | : UNSUPPORTED_ON_DEVICE; |
Ben Lin | e837771 | 2018-01-11 15:32:36 -0800 | [diff] [blame] | 56 | } |
| 57 | } |