• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 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.connecteddevice;
17 
18 import android.app.settings.SettingsEnums;
19 import android.content.Context;
20 import android.net.Uri;
21 import android.provider.DeviceConfig;
22 
23 import androidx.annotation.VisibleForTesting;
24 
25 import com.android.settings.R;
26 import com.android.settings.core.SettingsUIDeviceConfig;
27 import com.android.settings.dashboard.DashboardFragment;
28 import com.android.settings.search.BaseSearchIndexProvider;
29 import com.android.settings.slices.SlicePreferenceController;
30 import com.android.settingslib.search.SearchIndexable;
31 
32 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
33 public class ConnectedDeviceDashboardFragment extends DashboardFragment {
34 
35     private static final String TAG = "ConnectedDeviceFrag";
36 
37     @VisibleForTesting
38     static final String KEY_CONNECTED_DEVICES = "connected_device_list";
39     @VisibleForTesting
40     static final String KEY_AVAILABLE_DEVICES = "available_device_list";
41 
42     @Override
getMetricsCategory()43     public int getMetricsCategory() {
44         return SettingsEnums.SETTINGS_CONNECTED_DEVICE_CATEGORY;
45     }
46 
47     @Override
getLogTag()48     protected String getLogTag() {
49         return TAG;
50     }
51 
52     @Override
isParalleledControllers()53     protected boolean isParalleledControllers() {
54         return true;
55     }
56 
57     @Override
getHelpResource()58     public int getHelpResource() {
59         return R.string.help_url_connected_devices;
60     }
61 
62     @Override
getPreferenceScreenResId()63     protected int getPreferenceScreenResId() {
64         return R.xml.connected_devices;
65     }
66 
67     @Override
onAttach(Context context)68     public void onAttach(Context context) {
69         super.onAttach(context);
70         final boolean nearbyEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI,
71                 SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED, true);
72         use(AvailableMediaDeviceGroupController.class).init(this);
73         use(ConnectedDeviceGroupController.class).init(this);
74         use(PreviouslyConnectedDevicePreferenceController.class).init(this);
75         use(SlicePreferenceController.class).setSliceUri(nearbyEnabled
76                 ? Uri.parse(getString(R.string.config_nearby_devices_slice_uri))
77                 : null);
78     }
79 
80     /**
81      * For Search.
82      */
83     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
84             new BaseSearchIndexProvider(R.xml.connected_devices);
85 }
86