• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 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.search;
18 
19 import android.content.Context;
20 import android.view.View;
21 
22 import com.android.settings.dashboard.SiteMapManager;
23 import com.android.settings.search.ranking.SearchResultsRankerCallback;
24 
25 /**
26  * FeatureProvider for Settings Search
27  */
28 public interface SearchFeatureProvider {
29 
30     /**
31      * @return true to use the new version of search
32      */
isEnabled(Context context)33     boolean isEnabled(Context context);
34 
35     /**
36      * Returns a new loader to search in index database.
37      */
getDatabaseSearchLoader(Context context, String query)38     DatabaseResultLoader getDatabaseSearchLoader(Context context, String query);
39 
40     /**
41      * Returns a new loader to search installed apps.
42      */
getInstalledAppSearchLoader(Context context, String query)43     InstalledAppResultLoader getInstalledAppSearchLoader(Context context, String query);
44 
45     /**
46      * Returns a new loader to search accessibility services.
47      */
getAccessibilityServiceResultLoader(Context context, String query)48     AccessibilityServiceResultLoader getAccessibilityServiceResultLoader(Context context,
49             String query);
50 
51     /**
52      * Returns a new loader to search input devices.
53      */
getInputDeviceResultLoader(Context context, String query)54     InputDeviceResultLoader getInputDeviceResultLoader(Context context, String query);
55 
56     /**
57      * Returns a new loader to get all recently saved queries search terms.
58      */
getSavedQueryLoader(Context context)59     SavedQueryLoader getSavedQueryLoader(Context context);
60 
61     /**
62      * Returns the manager for indexing Settings data.
63      */
getIndexingManager(Context context)64     DatabaseIndexingManager getIndexingManager(Context context);
65 
66     /**
67      * Returns the manager for looking up breadcrumbs.
68      */
getSiteMapManager()69     SiteMapManager getSiteMapManager();
70 
71     /**
72      * Updates the Settings indexes and calls {@link IndexingCallback#onIndexingFinished()} on
73      * {@param callback} when indexing is complete.
74      */
updateIndexAsync(Context context, IndexingCallback callback)75     void updateIndexAsync(Context context, IndexingCallback callback);
76 
77     /**
78      * Synchronously updates the Settings database.
79      */
updateIndex(Context context)80     void updateIndex(Context context);
81 
82     /**
83      * @returns true when indexing is complete.
84      */
isIndexingComplete(Context context)85     boolean isIndexingComplete(Context context);
86 
87     /**
88      * Initializes the feedback button in case it was dismissed.
89      */
initFeedbackButton()90     default void initFeedbackButton() {
91     }
92 
93     /**
94      * Show a button users can click to submit feedback on the quality of the search results.
95      */
showFeedbackButton(SearchFragment fragment, View view)96     default void showFeedbackButton(SearchFragment fragment, View view) {
97     }
98 
99     /**
100      * Hide the feedback button shown by
101      * {@link #showFeedbackButton(SearchFragment fragment, View view) showFeedbackButton}
102      */
hideFeedbackButton()103     default void hideFeedbackButton() {
104     }
105 
106     /**
107      * Query search results based on the input query.
108      *
109      * @param context                     application context
110      * @param query                       input user query
111      * @param searchResultsRankerCallback {@link SearchResultsRankerCallback}
112      */
querySearchResults(Context context, String query, SearchResultsRankerCallback searchResultsRankerCallback)113     default void querySearchResults(Context context, String query,
114             SearchResultsRankerCallback searchResultsRankerCallback) {
115     }
116 
117     /**
118      * Cancel pending search query
119      */
cancelPendingSearchQuery(Context context)120     default void cancelPendingSearchQuery(Context context) {
121     }
122 
123     /**
124      * Notify that a search result is clicked.
125      *
126      * @param context      application context
127      * @param query        input user query
128      * @param searchResult clicked result
129      */
searchResultClicked(Context context, String query, SearchResult searchResult)130     default void searchResultClicked(Context context, String query, SearchResult searchResult) {
131     }
132 
133     /**
134      * @return true to enable search ranking.
135      */
isSmartSearchRankingEnabled(Context context)136     default boolean isSmartSearchRankingEnabled(Context context) {
137         return false;
138     }
139 
140     /**
141      * @return smart ranking timeout in milliseconds.
142      */
smartSearchRankingTimeoutMs(Context context)143     default long smartSearchRankingTimeoutMs(Context context) {
144         return 300L;
145     }
146 
147     /**
148      * Prepare for search ranking predictions to avoid latency on the first prediction call.
149      */
searchRankingWarmup(Context context)150     default void searchRankingWarmup(Context context) {
151     }
152 
153 }
154