OSDN Git Service

Merge "Fix search indexing for encryption_and_credential page" into oc-dr1-dev
[android-x86/packages-apps-Settings.git] / src / com / android / settings / core / PreferenceControllerMixin.java
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 com.android.settings.search.ResultPayload;
19 import com.android.settings.search.SearchIndexableRaw;
20 import com.android.settingslib.core.AbstractPreferenceController;
21
22 import java.util.List;
23
24 /**
25  * A controller mixin that adds mobile settings specific functionality
26  */
27 public interface PreferenceControllerMixin {
28
29     /**
30      * Updates non-indexable keys for search provider.
31      *
32      * Called by SearchIndexProvider#getNonIndexableKeys
33      */
34     default void updateNonIndexableKeys(List<String> keys) {
35         if (this instanceof AbstractPreferenceController) {
36             if (!((AbstractPreferenceController) this).isAvailable()) {
37                 keys.add(((AbstractPreferenceController) this).getPreferenceKey());
38             }
39         }
40     }
41
42     /**
43      * Updates raw data for search provider.
44      *
45      * Called by SearchIndexProvider#getRawDataToIndex
46      */
47     default void updateRawDataToIndex(List<SearchIndexableRaw> rawData) {
48     }
49
50     /**
51      * @return the {@link ResultPayload} corresponding to the search result type for the preference.
52      */
53     default ResultPayload getResultPayload() {
54         return null;
55     }
56 }