• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.accessibility;
18 
19 import static android.os.UserManager.DISALLOW_CONFIG_BLUETOOTH;
20 
21 import android.app.settings.SettingsEnums;
22 import android.content.Context;
23 import android.util.FeatureFlagUtils;
24 
25 import androidx.annotation.VisibleForTesting;
26 
27 import com.android.settings.R;
28 import com.android.settings.dashboard.RestrictedDashboardFragment;
29 import com.android.settings.search.BaseSearchIndexProvider;
30 import com.android.settingslib.search.SearchIndexable;
31 
32 /** Settings fragment containing bluetooth audio routing. */
33 @SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
34 public class AccessibilityAudioRoutingFragment extends RestrictedDashboardFragment {
35     private static final String TAG = "AccessibilityAudioRoutingFragment";
36 
AccessibilityAudioRoutingFragment()37     public AccessibilityAudioRoutingFragment() {
38         super(DISALLOW_CONFIG_BLUETOOTH);
39     }
40 
41     @Override
getMetricsCategory()42     public int getMetricsCategory() {
43         return SettingsEnums.HEARING_AID_AUDIO_ROUTING;
44     }
45 
46     @Override
getPreferenceScreenResId()47     protected int getPreferenceScreenResId() {
48         return R.xml.accessibility_audio_routing_fragment;
49     }
50 
51     @Override
getLogTag()52     protected String getLogTag() {
53         return TAG;
54     }
55 
56     @VisibleForTesting
isPageSearchEnabled(Context context)57     static boolean isPageSearchEnabled(Context context) {
58         if (!FeatureFlagUtils.isEnabled(context, FeatureFlagUtils.SETTINGS_AUDIO_ROUTING)) {
59             return false;
60         }
61 
62         final HearingAidHelper mHelper = new HearingAidHelper(context);
63         return mHelper.isHearingAidSupported();
64     }
65 
66     public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
67             new BaseSearchIndexProvider(R.xml.accessibility_audio_routing_fragment) {
68                 @Override
69                 protected boolean isPageSearchEnabled(Context context) {
70                     if (Flags.fixA11ySettingsSearch()) {
71                         return AccessibilityAudioRoutingFragment.isPageSearchEnabled(context);
72                     } else {
73                         return super.isPageSearchEnabled(context);
74                     }
75                 }
76             };
77 }
78