• 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.core;
17 
18 import android.text.TextUtils;
19 import android.util.Log;
20 
21 import com.android.settingslib.core.AbstractPreferenceController;
22 import com.android.settingslib.search.SearchIndexableRaw;
23 
24 import java.util.List;
25 
26 /**
27  * A controller mixin that adds mobile settings specific functionality
28  * TODO (b/69808530) Replace with BasePreferenceController.
29  */
30 public interface PreferenceControllerMixin {
31 
32     String TAG = "PrefControllerMixin";
33 
34     /**
35      * Updates non-indexable keys for search provider.
36      *
37      * Called by SearchIndexProvider#getNonIndexableKeys
38      */
updateNonIndexableKeys(List<String> keys)39     default void updateNonIndexableKeys(List<String> keys) {
40         if (this instanceof AbstractPreferenceController) {
41             if (!((AbstractPreferenceController) this).isAvailable()) {
42                 final String key = ((AbstractPreferenceController) this).getPreferenceKey();
43                 if (TextUtils.isEmpty(key)) {
44                     Log.w(TAG,
45                             "Skipping updateNonIndexableKeys due to empty key " + toString());
46                     return;
47                 }
48                 if (keys.contains(key)) {
49                     Log.w(TAG, "Skipping updateNonIndexableKeys, key already in list. "
50                             + toString());
51                     return;
52                 }
53                 keys.add(key);
54             }
55         }
56     }
57 
58     /**
59      * Updates raw data for search provider.
60      *
61      * Called by SearchIndexProvider#getRawDataToIndex
62      */
updateRawDataToIndex(List<SearchIndexableRaw> rawData)63     default void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
64     }
65 
66     /**
67      * Updates dynamic raw data for search provider.
68      *
69      * Called by SearchIndexProvider#getDynamicRawDataToIndex
70      */
updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData)71     default void updateDynamicRawDataToIndex(List<SearchIndexableRaw> rawData) {
72     }
73 }
74