1 /* 2 * Copyright (C) 2009 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.globalsearch; 18 19 import android.content.ComponentName; 20 21 import java.util.ArrayList; 22 23 /** 24 * Holds information about shortcuts (results the user has clicked on before), and returns 25 * appropriate shortcuts for a given query. 26 */ 27 public interface ShortcutRepository { 28 29 /** 30 * Checks whether there is any stored history. 31 */ hasHistory()32 boolean hasHistory(); 33 34 /** 35 * Clears all shortcut history. 36 */ clearHistory()37 void clearHistory(); 38 39 /** 40 * Deletes any database files and other resources used by the repository. 41 * This is not necessary to clear the history, and is mostly useful 42 * for unit tests. 43 */ deleteRepository()44 void deleteRepository(); 45 46 /** 47 * Closes any database connections etc held by this object. 48 */ close()49 void close(); 50 51 /** 52 * Used to Report the stats about a completed {@link SuggestionSession}. 53 * 54 * @param stats The stats. 55 */ reportStats(SessionStats stats)56 void reportStats(SessionStats stats); 57 58 /** 59 * @param query The query. 60 * @return A list short-cutted results for the query. 61 */ getShortcutsForQuery(String query)62 ArrayList<SuggestionData> getShortcutsForQuery(String query); 63 64 /** 65 * @return A ranking of suggestion sources based on clicks and impressions. 66 */ getSourceRanking()67 ArrayList<ComponentName> getSourceRanking(); 68 69 /** 70 * Refreshes a shortcut. 71 * 72 * @param source Identifies the source of the shortcut. 73 * @param shortcutId Identifies the shortcut. 74 * @param refreshed An up to date shortcut, or <code>null</code> if the shortcut should be 75 * removed. 76 */ refreshShortcut(ComponentName source, String shortcutId, SuggestionData refreshed)77 void refreshShortcut(ComponentName source, String shortcutId, SuggestionData refreshed); 78 79 } 80