Terry Wang | febbead | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 1 | /** |
sidchhabra | a7c8f8a | 2020-01-16 18:38:17 -0800 | [diff] [blame] | 2 | * Copyright 2020, The Android Open Source Project |
Terry Wang | febbead | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 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 android.app.appsearch; |
Alexander Dorokhine | fd07eba | 2020-01-13 20:22:20 -0800 | [diff] [blame] | 17 | |
Alexander Dorokhine | 92ce353 | 2020-10-06 01:39:36 -0700 | [diff] [blame] | 18 | import android.os.Bundle; |
| 19 | |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 20 | import android.app.appsearch.AppSearchBatchResult; |
| 21 | import android.app.appsearch.AppSearchResult; |
| 22 | import android.app.appsearch.IAppSearchBatchResultCallback; |
| 23 | import android.app.appsearch.IAppSearchResultCallback; |
Alexander Dorokhine | fd07eba | 2020-01-13 20:22:20 -0800 | [diff] [blame] | 24 | import com.android.internal.infra.AndroidFuture; |
| 25 | |
Alexander Dorokhine | c66d67c | 2020-10-08 13:44:04 -0700 | [diff] [blame] | 26 | parcelable SearchResults; |
Alexander Dorokhine | 1846584 | 2020-01-21 01:08:57 -0800 | [diff] [blame] | 27 | |
Terry Wang | febbead | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 28 | /** {@hide} */ |
| 29 | interface IAppSearchManager { |
Alexander Dorokhine | fd07eba | 2020-01-13 20:22:20 -0800 | [diff] [blame] | 30 | /** |
| 31 | * Sets the schema. |
| 32 | * |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 33 | * @param databaseName The databaseName this document resides in. |
Alexander Dorokhine | 92ce353 | 2020-10-06 01:39:36 -0700 | [diff] [blame] | 34 | * @param schemaBundles List of AppSearchSchema bundles. |
Alexander Dorokhine | 321e4b1 | 2020-01-18 11:15:00 -0800 | [diff] [blame] | 35 | * @param forceOverride Whether to apply the new schema even if it is incompatible. All |
| 36 | * incompatible documents will be deleted. |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 37 | * @param callback {@link IAppSearchResultCallback#onResult} will be called with an |
| 38 | * {@link AppSearchResult}<{@link Void}>. |
Alexander Dorokhine | fd07eba | 2020-01-13 20:22:20 -0800 | [diff] [blame] | 39 | */ |
Alexander Dorokhine | 969f446 | 2020-03-05 15:54:19 -0800 | [diff] [blame] | 40 | void setSchema( |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 41 | in String databaseName, |
Alexander Dorokhine | 92ce353 | 2020-10-06 01:39:36 -0700 | [diff] [blame] | 42 | in List<Bundle> schemaBundles, |
| 43 | boolean forceOverride, |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 44 | in IAppSearchResultCallback callback); |
Alexander Dorokhine | cc22345 | 2020-01-19 03:00:28 -0800 | [diff] [blame] | 45 | |
| 46 | /** |
Alexander Dorokhine | 1846584 | 2020-01-21 01:08:57 -0800 | [diff] [blame] | 47 | * Inserts documents into the index. |
Alexander Dorokhine | cc22345 | 2020-01-19 03:00:28 -0800 | [diff] [blame] | 48 | * |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 49 | * @param databaseName The name of the database where this document lives. |
Alexander Dorokhine | c66d67c | 2020-10-08 13:44:04 -0700 | [diff] [blame] | 50 | * @param documentBundes List of GenericDocument bundles. |
Alexander Dorokhine | 1846584 | 2020-01-21 01:08:57 -0800 | [diff] [blame] | 51 | * @param callback |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 52 | * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError} |
| 53 | * will be called with the cause throwable. Otherwise, |
| 54 | * {@link IAppSearchBatchResultCallback#onResult} will be called with an |
Alexander Dorokhine | 1846584 | 2020-01-21 01:08:57 -0800 | [diff] [blame] | 55 | * {@link AppSearchBatchResult}<{@link String}, {@link Void}> |
| 56 | * where the keys are document URIs, and the values are {@code null}. |
Alexander Dorokhine | cc22345 | 2020-01-19 03:00:28 -0800 | [diff] [blame] | 57 | */ |
Alexander Dorokhine | c66d67c | 2020-10-08 13:44:04 -0700 | [diff] [blame] | 58 | void putDocuments( |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 59 | in String databaseName, |
| 60 | in List<Bundle> documentBundles, |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 61 | in IAppSearchBatchResultCallback callback); |
Alexander Dorokhine | cc22345 | 2020-01-19 03:00:28 -0800 | [diff] [blame] | 62 | |
sidchhabra | a7c8f8a | 2020-01-16 18:38:17 -0800 | [diff] [blame] | 63 | /** |
Alexander Dorokhine | 69a8d9f | 2020-03-06 10:43:16 -0800 | [diff] [blame] | 64 | * Retrieves documents from the index. |
| 65 | * |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 66 | * @param databaseName The databaseName this document resides in. |
| 67 | * @param namespace The namespace this document resides in. |
Alexander Dorokhine | 69a8d9f | 2020-03-06 10:43:16 -0800 | [diff] [blame] | 68 | * @param uris The URIs of the documents to retrieve |
Alexander Dorokhine | a95f44f | 2020-03-06 13:53:14 -0800 | [diff] [blame] | 69 | * @param callback |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 70 | * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError} |
| 71 | * will be called with the cause throwable. Otherwise, |
| 72 | * {@link IAppSearchBatchResultCallback#onResult} will be called with an |
Alexander Dorokhine | c66d67c | 2020-10-08 13:44:04 -0700 | [diff] [blame] | 73 | * {@link AppSearchBatchResult}<{@link String}, {@link Bundle}> |
| 74 | * where the keys are document URIs, and the values are Document bundles. |
Alexander Dorokhine | 69a8d9f | 2020-03-06 10:43:16 -0800 | [diff] [blame] | 75 | */ |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 76 | void getDocuments( |
| 77 | in String databaseName, |
| 78 | in String namespace, |
| 79 | in List<String> uris, |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 80 | in IAppSearchBatchResultCallback callback); |
Alexander Dorokhine | 69a8d9f | 2020-03-06 10:43:16 -0800 | [diff] [blame] | 81 | |
| 82 | /** |
sidchhabra | b009838 | 2020-01-22 11:47:22 -0800 | [diff] [blame] | 83 | * Searches a document based on a given specifications. |
sidchhabra | a7c8f8a | 2020-01-16 18:38:17 -0800 | [diff] [blame] | 84 | * |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 85 | * @param databaseName The databaseName this query for. |
Alexander Dorokhine | c9fc960 | 2020-10-06 01:39:50 -0700 | [diff] [blame] | 86 | * @param queryExpression String to search for |
| 87 | * @param searchSpecBundle SearchSpec bundle |
Alexander Dorokhine | d48f236 | 2020-10-20 17:40:49 -0700 | [diff] [blame] | 88 | * @param callback {@link AppSearchResult}<{@link Bundle}> of performing this |
| 89 | * operation. |
sidchhabra | a7c8f8a | 2020-01-16 18:38:17 -0800 | [diff] [blame] | 90 | */ |
Alexander Dorokhine | e708e18 | 2020-03-06 15:30:34 -0800 | [diff] [blame] | 91 | void query( |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 92 | in String databaseName, |
Alexander Dorokhine | c9fc960 | 2020-10-06 01:39:50 -0700 | [diff] [blame] | 93 | in String queryExpression, |
| 94 | in Bundle searchSpecBundle, |
Alexander Dorokhine | d48f236 | 2020-10-20 17:40:49 -0700 | [diff] [blame] | 95 | in IAppSearchResultCallback callback); |
| 96 | |
| 97 | /** |
Terry Wang | bfbfcac | 2020-11-06 15:46:44 -0800 | [diff] [blame^] | 98 | * Executes a global query, i.e. over all permitted databases, against the AppSearch index and |
| 99 | * returns results. |
| 100 | * |
| 101 | * @param queryExpression String to search for |
| 102 | * @param searchSpecBundle SearchSpec bundle |
| 103 | * @param callback {@link AppSearchResult}<{@link Bundle}> of performing this |
| 104 | * operation. |
| 105 | */ |
| 106 | void globalQuery( |
| 107 | in String queryExpression, |
| 108 | in Bundle searchSpecBundle, |
| 109 | in IAppSearchResultCallback callback); |
| 110 | |
| 111 | /** |
Alexander Dorokhine | d48f236 | 2020-10-20 17:40:49 -0700 | [diff] [blame] | 112 | * Fetches the next page of results of a previously executed query. Results can be empty if |
| 113 | * next-page token is invalid or all pages have been returned. |
| 114 | * |
| 115 | * @param nextPageToken The token of pre-loaded results of previously executed query. |
| 116 | * @param callback {@link AppSearchResult}<{@link Bundle}> of performing this |
| 117 | * operation. |
| 118 | */ |
| 119 | void getNextPage(in long nextPageToken, in IAppSearchResultCallback callback); |
| 120 | |
| 121 | /** |
| 122 | * Invalidates the next-page token so that no more results of the related query can be returned. |
| 123 | * |
| 124 | * @param nextPageToken The token of pre-loaded results of previously executed query to be |
| 125 | * Invalidated. |
| 126 | */ |
| 127 | void invalidateNextPageToken(in long nextPageToken); |
Alexander Dorokhine | f6c66ae | 2020-03-09 14:47:25 -0700 | [diff] [blame] | 128 | |
| 129 | /** |
Terry Wang | 26b9e5c | 2020-10-23 02:05:01 -0700 | [diff] [blame] | 130 | * Removes documents by URI. |
Alexander Dorokhine | ff82fba | 2020-03-09 16:35:24 -0700 | [diff] [blame] | 131 | * |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 132 | * @param databaseName The databaseName the document is in. |
| 133 | * @param namespace Namespace of the document to remove. |
Alexander Dorokhine | ff82fba | 2020-03-09 16:35:24 -0700 | [diff] [blame] | 134 | * @param uris The URIs of the documents to delete |
| 135 | * @param callback |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 136 | * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError} |
| 137 | * will be called with the cause throwable. Otherwise, |
| 138 | * {@link IAppSearchBatchResultCallback#onResult} will be called with an |
Alexander Dorokhine | ff82fba | 2020-03-09 16:35:24 -0700 | [diff] [blame] | 139 | * {@link AppSearchBatchResult}<{@link String}, {@link Void}> |
| 140 | * where the keys are document URIs. If a document doesn't exist, it will be reported as a |
| 141 | * failure where the {@code throwable} is {@code null}. |
| 142 | */ |
Terry Wang | 26b9e5c | 2020-10-23 02:05:01 -0700 | [diff] [blame] | 143 | void removeByUri( |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 144 | in String databaseName, |
| 145 | in String namespace, |
| 146 | in List<String> uris, |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 147 | in IAppSearchBatchResultCallback callback); |
Alexander Dorokhine | ff82fba | 2020-03-09 16:35:24 -0700 | [diff] [blame] | 148 | |
| 149 | /** |
Terry Wang | 26b9e5c | 2020-10-23 02:05:01 -0700 | [diff] [blame] | 150 | * Removes documents by given query. |
Alexander Dorokhine | 7f46d6f | 2020-04-14 14:40:21 -0700 | [diff] [blame] | 151 | * |
Terry Wang | 26b9e5c | 2020-10-23 02:05:01 -0700 | [diff] [blame] | 152 | * @param databaseName The databaseName this query for. |
| 153 | * @param queryExpression String to search for |
| 154 | * @param searchSpecBundle SearchSpec bundle |
Alexander Dorokhine | 178366b | 2020-10-20 17:40:49 -0700 | [diff] [blame] | 155 | * @param callback {@link IAppSearchResultCallback#onResult} will be called with an |
| 156 | * {@link AppSearchResult}<{@link Void}>. |
Alexander Dorokhine | 7f46d6f | 2020-04-14 14:40:21 -0700 | [diff] [blame] | 157 | */ |
Terry Wang | 26b9e5c | 2020-10-23 02:05:01 -0700 | [diff] [blame] | 158 | void removeByQuery( |
Terry Wang | 6413aee | 2020-10-07 03:04:58 -0700 | [diff] [blame] | 159 | in String databaseName, |
Terry Wang | 26b9e5c | 2020-10-23 02:05:01 -0700 | [diff] [blame] | 160 | in String queryExpression, |
| 161 | in Bundle searchSpecBundle, |
Alexander Dorokhine | 178366b | 2020-10-20 17:40:49 -0700 | [diff] [blame] | 162 | in IAppSearchResultCallback callback); |
Terry Wang | dbd1dca | 2020-11-03 17:03:56 -0800 | [diff] [blame] | 163 | |
| 164 | /** |
| 165 | * Creates and initializes AppSearchImpl for the calling app. |
| 166 | * |
| 167 | * @param callback {@link IAppSearchResultCallback#onResult} will be called with an |
| 168 | * {@link AppSearchResult}<{@link Void}>. |
| 169 | */ |
| 170 | void initialize(in IAppSearchResultCallback callback); |
Terry Wang | febbead | 2019-10-17 17:05:18 -0700 | [diff] [blame] | 171 | } |