1 /** 2 * Copyright 2020, 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 android.app.appsearch.aidl; 17 18 import android.os.Bundle; 19 import android.os.UserHandle; 20 21 import android.app.appsearch.aidl.IAppSearchBatchResultCallback; 22 import android.app.appsearch.aidl.IAppSearchResultCallback; 23 import android.os.ParcelFileDescriptor; 24 25 /** {@hide} */ 26 interface IAppSearchManager { 27 /** 28 * Updates the AppSearch schema for this database. 29 * 30 * @param packageName The name of the package that owns this schema. 31 * @param databaseName The name of the database where this schema lives. 32 * @param schemaBundles List of {@link AppSearchSchema} bundles. 33 * @param schemasNotDisplayedBySystem Schema types that should not be surfaced on platform 34 * surfaces. 35 * @param schemasVisibleToPackagesBundles Schema types that are visible to the specified 36 * packages. The value List contains PackageIdentifier Bundles. 37 * @param forceOverride Whether to apply the new schema even if it is incompatible. All 38 * incompatible documents will be deleted. 39 * @param schemaVersion The overall schema version number of the request. 40 * @param userHandle Handle of the calling user 41 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 42 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 43 * {@link AppSearchResult}<{@link Bundle}>, where the value are 44 * {@link SetSchemaResponse} bundle. 45 */ setSchema( in String packageName, in String databaseName, in List<Bundle> schemaBundles, in List<String> schemasNotDisplayedBySystem, in Map<String, List<Bundle>> schemasVisibleToPackagesBundles, boolean forceOverride, in int schemaVersion, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchResultCallback callback)46 void setSchema( 47 in String packageName, 48 in String databaseName, 49 in List<Bundle> schemaBundles, 50 in List<String> schemasNotDisplayedBySystem, 51 in Map<String, List<Bundle>> schemasVisibleToPackagesBundles, 52 boolean forceOverride, 53 in int schemaVersion, 54 in UserHandle userHandle, 55 in long binderCallStartTimeMillis, 56 in IAppSearchResultCallback callback); 57 58 /** 59 * Retrieves the AppSearch schema for this database. 60 * 61 * @param packageName The name of the package that owns the schema. 62 * @param databaseName The name of the database to retrieve. 63 * @param userHandle Handle of the calling user 64 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 65 * {@link AppSearchResult}<{@link Bundle}> where the bundle is a GetSchemaResponse. 66 */ getSchema( in String packageName, in String databaseName, in UserHandle userHandle, in IAppSearchResultCallback callback)67 void getSchema( 68 in String packageName, 69 in String databaseName, 70 in UserHandle userHandle, 71 in IAppSearchResultCallback callback); 72 73 /** 74 * Retrieves the set of all namespaces in the current database with at least one document. 75 * 76 * @param packageName The name of the package that owns the schema. 77 * @param databaseName The name of the database to retrieve. 78 * @param userHandle Handle of the calling user 79 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 80 * {@link AppSearchResult}<{@link List}<{@link String}>>. 81 */ getNamespaces( in String packageName, in String databaseName, in UserHandle userHandle, in IAppSearchResultCallback callback)82 void getNamespaces( 83 in String packageName, 84 in String databaseName, 85 in UserHandle userHandle, 86 in IAppSearchResultCallback callback); 87 88 /** 89 * Inserts documents into the index. 90 * 91 * @param packageName The name of the package that owns this document. 92 * @param databaseName The name of the database where this document lives. 93 * @param documentBundes List of GenericDocument bundles. 94 * @param userHandle Handle of the calling user 95 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 96 * @param callback 97 * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError} 98 * will be called with the cause throwable. Otherwise, 99 * {@link IAppSearchBatchResultCallback#onResult} will be called with an 100 * {@link AppSearchBatchResult}<{@link String}, {@link Void}> 101 * where the keys are document IDs, and the values are {@code null}. 102 */ putDocuments( in String packageName, in String databaseName, in List<Bundle> documentBundles, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchBatchResultCallback callback)103 void putDocuments( 104 in String packageName, 105 in String databaseName, 106 in List<Bundle> documentBundles, 107 in UserHandle userHandle, 108 in long binderCallStartTimeMillis, 109 in IAppSearchBatchResultCallback callback); 110 111 /** 112 * Retrieves documents from the index. 113 * 114 * @param packageName The name of the package that owns this document. 115 * @param databaseName The databaseName this document resides in. 116 * @param namespace The namespace this document resides in. 117 * @param ids The IDs of the documents to retrieve 118 * @param typePropertyPaths A map of schema type to a list of property paths to return in the 119 * result. 120 * @param userHandle Handle of the calling user 121 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 122 * @param callback 123 * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError} 124 * will be called with the cause throwable. Otherwise, 125 * {@link IAppSearchBatchResultCallback#onResult} will be called with an 126 * {@link AppSearchBatchResult}<{@link String}, {@link Bundle}> 127 * where the keys are document IDs, and the values are Document bundles. 128 */ getDocuments( in String packageName, in String databaseName, in String namespace, in List<String> ids, in Map<String, List<String>> typePropertyPaths, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchBatchResultCallback callback)129 void getDocuments( 130 in String packageName, 131 in String databaseName, 132 in String namespace, 133 in List<String> ids, 134 in Map<String, List<String>> typePropertyPaths, 135 in UserHandle userHandle, 136 in long binderCallStartTimeMillis, 137 in IAppSearchBatchResultCallback callback); 138 139 /** 140 * Searches a document based on a given specifications. 141 * 142 * @param packageName The name of the package to query over. 143 * @param databaseName The databaseName this query for. 144 * @param queryExpression String to search for 145 * @param searchSpecBundle SearchSpec bundle 146 * @param userHandle Handle of the calling user 147 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 148 * @param callback {@link AppSearchResult}<{@link Bundle}> of performing this 149 * operation. 150 */ query( in String packageName, in String databaseName, in String queryExpression, in Bundle searchSpecBundle, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchResultCallback callback)151 void query( 152 in String packageName, 153 in String databaseName, 154 in String queryExpression, 155 in Bundle searchSpecBundle, 156 in UserHandle userHandle, 157 in long binderCallStartTimeMillis, 158 in IAppSearchResultCallback callback); 159 160 /** 161 * Executes a global query, i.e. over all permitted databases, against the AppSearch index and 162 * returns results. 163 * 164 * @param packageName The name of the package making the query. 165 * @param queryExpression String to search for 166 * @param searchSpecBundle SearchSpec bundle 167 * @param userHandle Handle of the calling user 168 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 169 * @param callback {@link AppSearchResult}<{@link Bundle}> of performing this 170 * operation. 171 */ globalQuery( in String packageName, in String queryExpression, in Bundle searchSpecBundle, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchResultCallback callback)172 void globalQuery( 173 in String packageName, 174 in String queryExpression, 175 in Bundle searchSpecBundle, 176 in UserHandle userHandle, 177 in long binderCallStartTimeMillis, 178 in IAppSearchResultCallback callback); 179 180 /** 181 * Fetches the next page of results of a previously executed query. Results can be empty if 182 * next-page token is invalid or all pages have been returned. 183 * 184 * @param packageName The name of the package to persist to disk for. 185 * @param nextPageToken The token of pre-loaded results of previously executed query. 186 * @param userHandle Handle of the calling user 187 * @param callback {@link AppSearchResult}<{@link Bundle}> of performing this 188 * operation. 189 */ getNextPage( in String packageName, in long nextPageToken, in UserHandle userHandle, in IAppSearchResultCallback callback)190 void getNextPage( 191 in String packageName, 192 in long nextPageToken, 193 in UserHandle userHandle, 194 in IAppSearchResultCallback callback); 195 196 /** 197 * Invalidates the next-page token so that no more results of the related query can be returned. 198 * 199 * @param packageName The name of the package to persist to disk for. 200 * @param nextPageToken The token of pre-loaded results of previously executed query to be 201 * Invalidated. 202 * @param userHandle Handle of the calling user 203 */ invalidateNextPageToken( in String packageName, in long nextPageToken, in UserHandle userHandle)204 void invalidateNextPageToken( 205 in String packageName, 206 in long nextPageToken, 207 in UserHandle userHandle); 208 209 /** 210 * Searches a document based on a given specifications. 211 * 212 * <p>Documents will be save to the given ParcelFileDescriptor 213 * 214 * @param packageName The name of the package to query over. 215 * @param databaseName The databaseName this query for. 216 * @param fileDescriptor The ParcelFileDescriptor where documents should be written to. 217 * @param queryExpression String to search for. 218 * @param searchSpecBundle SearchSpec bundle. 219 * @param userHandle Handle of the calling user. 220 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 221 * {@link AppSearchResult}<{@code Void}>. 222 */ writeQueryResultsToFile( in String packageName, in String databaseName, in ParcelFileDescriptor fileDescriptor, in String queryExpression, in Bundle searchSpecBundle, in UserHandle userHandle, in IAppSearchResultCallback callback)223 void writeQueryResultsToFile( 224 in String packageName, 225 in String databaseName, 226 in ParcelFileDescriptor fileDescriptor, 227 in String queryExpression, 228 in Bundle searchSpecBundle, 229 in UserHandle userHandle, 230 in IAppSearchResultCallback callback); 231 232 /** 233 * Inserts documents from the given file into the index. 234 * 235 * @param packageName The name of the package that owns this document. 236 * @param databaseName The name of the database where this document lives. 237 * @param fileDescriptor The ParcelFileDescriptor where documents should be read from. 238 * @param userHandle Handle of the calling user. 239 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 240 * {@link AppSearchResult}<{@link List}<{@link Bundle}>>, where the value are 241 * MigrationFailure bundles. 242 */ putDocumentsFromFile( in String packageName, in String databaseName, in ParcelFileDescriptor fileDescriptor, in UserHandle userHandle, in IAppSearchResultCallback callback)243 void putDocumentsFromFile( 244 in String packageName, 245 in String databaseName, 246 in ParcelFileDescriptor fileDescriptor, 247 in UserHandle userHandle, 248 in IAppSearchResultCallback callback); 249 250 /** 251 * Reports usage of a particular document by namespace and id. 252 * 253 * <p>A usage report represents an event in which a user interacted with or viewed a document. 254 * 255 * <p>For each call to {@link #reportUsage}, AppSearch updates usage count and usage recency 256 * metrics for that particular document. These metrics are used for ordering {@link #query} 257 * results by the {@link SearchSpec#RANKING_STRATEGY_USAGE_COUNT} and 258 * {@link SearchSpec#RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP} ranking strategies. 259 * 260 * <p>Reporting usage of a document is optional. 261 * 262 * @param packageName The name of the package that owns this document. 263 * @param databaseName The name of the database to report usage against. 264 * @param namespace Namespace the document being used belongs to. 265 * @param id ID of the document being used. 266 * @param usageTimestampMillis The timestamp at which the document was used. 267 * @param systemUsage Whether the usage was reported by a system app against another app's doc. 268 * @param userHandle Handle of the calling user 269 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 270 * {@link AppSearchResult}<{@link Void}>. 271 */ reportUsage( in String packageName, in String databaseName, in String namespace, in String id, in long usageTimestampMillis, in boolean systemUsage, in UserHandle userHandle, in IAppSearchResultCallback callback)272 void reportUsage( 273 in String packageName, 274 in String databaseName, 275 in String namespace, 276 in String id, 277 in long usageTimestampMillis, 278 in boolean systemUsage, 279 in UserHandle userHandle, 280 in IAppSearchResultCallback callback); 281 282 /** 283 * Removes documents by ID. 284 * 285 * @param packageName The name of the package the document is in. 286 * @param databaseName The databaseName the document is in. 287 * @param namespace Namespace of the document to remove. 288 * @param ids The IDs of the documents to delete 289 * @param userHandle Handle of the calling user 290 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 291 * @param callback 292 * If the call fails to start, {@link IAppSearchBatchResultCallback#onSystemError} 293 * will be called with the cause throwable. Otherwise, 294 * {@link IAppSearchBatchResultCallback#onResult} will be called with an 295 * {@link AppSearchBatchResult}<{@link String}, {@link Void}> 296 * where the keys are document IDs. If a document doesn't exist, it will be reported as a 297 * failure where the {@code throwable} is {@code null}. 298 */ removeByDocumentId( in String packageName, in String databaseName, in String namespace, in List<String> ids, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchBatchResultCallback callback)299 void removeByDocumentId( 300 in String packageName, 301 in String databaseName, 302 in String namespace, 303 in List<String> ids, 304 in UserHandle userHandle, 305 in long binderCallStartTimeMillis, 306 in IAppSearchBatchResultCallback callback); 307 308 /** 309 * Removes documents by given query. 310 * 311 * @param packageName The name of the package to query over. 312 * @param databaseName The databaseName this query for. 313 * @param queryExpression String to search for 314 * @param searchSpecBundle SearchSpec bundle 315 * @param userHandle Handle of the calling user 316 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 317 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 318 * {@link AppSearchResult}<{@link Void}>. 319 */ removeByQuery( in String packageName, in String databaseName, in String queryExpression, in Bundle searchSpecBundle, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchResultCallback callback)320 void removeByQuery( 321 in String packageName, 322 in String databaseName, 323 in String queryExpression, 324 in Bundle searchSpecBundle, 325 in UserHandle userHandle, 326 in long binderCallStartTimeMillis, 327 in IAppSearchResultCallback callback); 328 329 /** 330 * Gets the storage info. 331 * 332 * @param packageName The name of the package to get the storage info for. 333 * @param databaseName The databaseName to get the storage info for. 334 * @param userHandle Handle of the calling user 335 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 336 * {@link AppSearchResult}<{@link Bundle}>, where the value is a 337 * {@link StorageInfo}. 338 */ getStorageInfo( in String packageName, in String databaseName, in UserHandle userHandle, in IAppSearchResultCallback callback)339 void getStorageInfo( 340 in String packageName, 341 in String databaseName, 342 in UserHandle userHandle, 343 in IAppSearchResultCallback callback); 344 345 /** 346 * Persists all update/delete requests to the disk. 347 * 348 * @param packageName The name of the package to persist to disk for. 349 * @param userHandle Handle of the calling user 350 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 351 */ persistToDisk( in String packageName, in UserHandle userHandle, in long binderCallStartTimeMillis)352 void persistToDisk( 353 in String packageName, 354 in UserHandle userHandle, 355 in long binderCallStartTimeMillis); 356 357 /** 358 * Creates and initializes AppSearchImpl for the calling app. 359 * 360 * @param packageName The name of the package to initialize for. 361 * @param userHandle Handle of the calling user 362 * @param binderCallStartTimeMillis start timestamp of binder call in Millis 363 * @param callback {@link IAppSearchResultCallback#onResult} will be called with an 364 * {@link AppSearchResult}<{@link Void}>. 365 */ initialize( in String packageName, in UserHandle userHandle, in long binderCallStartTimeMillis, in IAppSearchResultCallback callback)366 void initialize( 367 in String packageName, 368 in UserHandle userHandle, 369 in long binderCallStartTimeMillis, 370 in IAppSearchResultCallback callback); 371 } 372