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 getHelpResource()53 public int getHelpResource() { 54 return R.string.help_url_connected_devices; 55 } 56 57 @Override getPreferenceScreenResId()58 protected int getPreferenceScreenResId() { 59 return R.xml.connected_devices; 60 } 61 62 @Override onAttach(Context context)63 public void onAttach(Context context) { 64 super.onAttach(context); 65 final boolean nearbyEnabled = DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SETTINGS_UI, 66 SettingsUIDeviceConfig.BT_NEAR_BY_SUGGESTION_ENABLED, true); 67 use(AvailableMediaDeviceGroupController.class).init(this); 68 use(ConnectedDeviceGroupController.class).init(this); 69 use(PreviouslyConnectedDevicePreferenceController.class).init(this); 70 use(SlicePreferenceController.class).setSliceUri(nearbyEnabled 71 ? Uri.parse(getString(R.string.config_nearby_devices_slice_uri)) 72 : null); 73 } 74 75 /** 76 * For Search. 77 */ 78 public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = 79 new BaseSearchIndexProvider(R.xml.connected_devices); 80 } 81