Loading apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java +6 −53 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.NonNull; import android.os.Bundle; import android.os.ParcelableException; import android.os.RemoteException; import android.util.ArraySet; import java.util.ArrayList; import java.util.List; Loading @@ -34,8 +33,6 @@ import java.util.function.Consumer; /** * Represents a connection to an AppSearch storage system where {@link GenericDocument}s can be * placed and queried. * * This class is thread safe. * @hide */ public final class AppSearchSession { Loading Loading @@ -81,7 +78,7 @@ public final class AppSearchSession { } /** * Sets the schema that will be used by documents provided to the {@link #putDocuments} method. * Sets the schema will be used by documents provided to the {@link #putDocuments} method. * * <p>The schema provided here is compared to the stored copy of the schema previously supplied * to {@link #setSchema}, if any, to determine how to treat existing documents. The following Loading Loading @@ -125,19 +122,11 @@ public final class AppSearchSession { * <p>It is a no-op to set the same schema as has been previously set; this is handled * efficiently. * * <p>By default, documents are visible on platform surfaces. To opt out, call {@code * SetSchemaRequest.Builder#setPlatformSurfaceable} with {@code surfaceable} as false. Any * visibility settings apply only to the schemas that are included in the {@code request}. * Visibility settings for a schema type do not apply or persist across * {@link SetSchemaRequest}s. * * @param request The schema update request. * @param executor Executor on which to invoke the callback. * @param callback Callback to receive errors resulting from setting the schema. If the * operation succeeds, the callback will be invoked with {@code null}. */ // TODO(b/169883602): Change @code references to @link when setPlatformSurfaceable APIs are // exposed. public void setSchema( @NonNull SetSchemaRequest request, @NonNull @CallbackExecutor Executor executor, Loading Loading @@ -165,39 +154,6 @@ public final class AppSearchSession { } } /** * Retrieves the schema most recently successfully provided to {@link #setSchema}. * * @param executor Executor on which to invoke the callback. * @param callback Callback to receive the pending results of schema. If the operation succeeds, * the callback will be invoked with a {@link Set}<{@link AppSearchSchema}> */ @NonNull public void getSchema( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Set<AppSearchSchema>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); try { mService.getSchema( mDatabaseName, new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { executor.execute(() -> { List<Bundle> schemaBundles = (List<Bundle>) result.getResultValue(); Set<AppSearchSchema> schemas = new ArraySet<>(schemaBundles.size()); for (int i = 0; i < schemaBundles.size(); i++) { schemas.add(new AppSearchSchema(schemaBundles.get(i))); } callback.accept(schemas); }); } }); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Indexes documents into AppSearch. * Loading Loading @@ -412,7 +368,7 @@ public final class AppSearchSession { /** * Removes {@link GenericDocument}s from the index by Query. Documents will be removed if they * match the {@code queryExpression} in given namespaces and schemaTypes which is set via * {@link SearchSpec.Builder#addNamespace} and {@link SearchSpec.Builder#addSchemaType}. * {@link SearchSpec.Builder#addNamespace} and {@link SearchSpec.Builder#addSchema}. * * <p> An empty {@code queryExpression} matches all documents. * Loading @@ -420,13 +376,10 @@ public final class AppSearchSession { * the current database. * * @param queryExpression Query String to search. * @param searchSpec Spec containing schemaTypes, namespaces and query expression indicates * how document will be removed. All specific about how to scoring, * ordering, snippeting and resulting will be ignored. * @param searchSpec Defines what and how to remove * @param executor Executor on which to invoke the callback. * @param callback Callback to receive errors resulting from removing the documents. If * the operation succeeds, the callback will be invoked with * {@code null}. * @param callback Callback to receive errors resulting from removing the documents. If the * operation succeeds, the callback will be invoked with {@code null}. */ public void removeByQuery(@NonNull String queryExpression, @NonNull SearchSpec searchSpec, Loading apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ public class GlobalSearchSession { * @return The search result of performing this operation. */ @NonNull public SearchResults query( public SearchResults globalQuery( @NonNull String queryExpression, @NonNull SearchSpec searchSpec, @NonNull @CallbackExecutor Executor executor) { Loading apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl +3 −14 Original line number Diff line number Diff line Loading @@ -28,10 +28,10 @@ parcelable SearchResults; /** {@hide} */ interface IAppSearchManager { /** * Updates the AppSearch schema for this database. * Sets the schema. * * @param databaseName The name of the database where this schema lives. * @param schemaBundles List of {@link AppSearchSchema} bundles. * @param databaseName The databaseName this document resides in. * @param schemaBundles List of AppSearchSchema bundles. * @param schemasNotPlatformSurfaceable Schema types that should not be surfaced on platform * surfaces. * @param forceOverride Whether to apply the new schema even if it is incompatible. All Loading @@ -46,17 +46,6 @@ interface IAppSearchManager { boolean forceOverride, in IAppSearchResultCallback callback); /** * Retrieves the AppSearch schema for this database. * * @param databaseName The name of the database to retrieve. * @param callback {@link IAppSearchResultCallback#onResult} will be called with an * {@link AppSearchResult}<{@link List}<{@link Bundle}>>, where the value are * AppSearchSchema bundle. */ void getSchema(in String databaseName, in IAppSearchResultCallback callback); /** * Inserts documents into the index. * Loading apex/appsearch/framework/java/android/app/appsearch/SearchResults.java +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class SearchResults implements Closeable { * <p>Re-call this method to get next page of {@link SearchResult}, until it returns an * empty list. * * <p>The page size is set by {@link SearchSpec.Builder#setResultCountPerPage}. * <p>The page size is set by {@link SearchSpec.Builder#setNumPerPage}. * * @param callback Callback to receive the pending result of performing this operation. */ Loading apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java +0 −26 Original line number Diff line number Diff line Loading @@ -89,32 +89,6 @@ public class AppSearchManagerService extends SystemService { } } @Override public void getSchema( @NonNull String databaseName, @NonNull IAppSearchResultCallback callback) { Preconditions.checkNotNull(databaseName); Preconditions.checkNotNull(callback); int callingUid = Binder.getCallingUidOrThrow(); int callingUserId = UserHandle.getUserId(callingUid); final long callingIdentity = Binder.clearCallingIdentity(); try { AppSearchImpl impl = ImplInstanceManager.getInstance(getContext(), callingUserId); databaseName = rewriteDatabaseNameWithUid(databaseName, callingUid); List<AppSearchSchema> schemas = impl.getSchema(databaseName); List<Bundle> schemaBundles = new ArrayList<>(schemas.size()); for (int i = 0; i < schemas.size(); i++) { schemaBundles.add(schemas.get(i).getBundle()); } invokeCallbackOnResult(callback, AppSearchResult.newSuccessfulResult(schemaBundles)); } catch (Throwable t) { invokeCallbackOnError(callback, t); } finally { Binder.restoreCallingIdentity(callingIdentity); } } @Override public void putDocuments( @NonNull String databaseName, Loading Loading
apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java +6 −53 Original line number Diff line number Diff line Loading @@ -21,7 +21,6 @@ import android.annotation.NonNull; import android.os.Bundle; import android.os.ParcelableException; import android.os.RemoteException; import android.util.ArraySet; import java.util.ArrayList; import java.util.List; Loading @@ -34,8 +33,6 @@ import java.util.function.Consumer; /** * Represents a connection to an AppSearch storage system where {@link GenericDocument}s can be * placed and queried. * * This class is thread safe. * @hide */ public final class AppSearchSession { Loading Loading @@ -81,7 +78,7 @@ public final class AppSearchSession { } /** * Sets the schema that will be used by documents provided to the {@link #putDocuments} method. * Sets the schema will be used by documents provided to the {@link #putDocuments} method. * * <p>The schema provided here is compared to the stored copy of the schema previously supplied * to {@link #setSchema}, if any, to determine how to treat existing documents. The following Loading Loading @@ -125,19 +122,11 @@ public final class AppSearchSession { * <p>It is a no-op to set the same schema as has been previously set; this is handled * efficiently. * * <p>By default, documents are visible on platform surfaces. To opt out, call {@code * SetSchemaRequest.Builder#setPlatformSurfaceable} with {@code surfaceable} as false. Any * visibility settings apply only to the schemas that are included in the {@code request}. * Visibility settings for a schema type do not apply or persist across * {@link SetSchemaRequest}s. * * @param request The schema update request. * @param executor Executor on which to invoke the callback. * @param callback Callback to receive errors resulting from setting the schema. If the * operation succeeds, the callback will be invoked with {@code null}. */ // TODO(b/169883602): Change @code references to @link when setPlatformSurfaceable APIs are // exposed. public void setSchema( @NonNull SetSchemaRequest request, @NonNull @CallbackExecutor Executor executor, Loading Loading @@ -165,39 +154,6 @@ public final class AppSearchSession { } } /** * Retrieves the schema most recently successfully provided to {@link #setSchema}. * * @param executor Executor on which to invoke the callback. * @param callback Callback to receive the pending results of schema. If the operation succeeds, * the callback will be invoked with a {@link Set}<{@link AppSearchSchema}> */ @NonNull public void getSchema( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<Set<AppSearchSchema>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); try { mService.getSchema( mDatabaseName, new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { executor.execute(() -> { List<Bundle> schemaBundles = (List<Bundle>) result.getResultValue(); Set<AppSearchSchema> schemas = new ArraySet<>(schemaBundles.size()); for (int i = 0; i < schemaBundles.size(); i++) { schemas.add(new AppSearchSchema(schemaBundles.get(i))); } callback.accept(schemas); }); } }); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Indexes documents into AppSearch. * Loading Loading @@ -412,7 +368,7 @@ public final class AppSearchSession { /** * Removes {@link GenericDocument}s from the index by Query. Documents will be removed if they * match the {@code queryExpression} in given namespaces and schemaTypes which is set via * {@link SearchSpec.Builder#addNamespace} and {@link SearchSpec.Builder#addSchemaType}. * {@link SearchSpec.Builder#addNamespace} and {@link SearchSpec.Builder#addSchema}. * * <p> An empty {@code queryExpression} matches all documents. * Loading @@ -420,13 +376,10 @@ public final class AppSearchSession { * the current database. * * @param queryExpression Query String to search. * @param searchSpec Spec containing schemaTypes, namespaces and query expression indicates * how document will be removed. All specific about how to scoring, * ordering, snippeting and resulting will be ignored. * @param searchSpec Defines what and how to remove * @param executor Executor on which to invoke the callback. * @param callback Callback to receive errors resulting from removing the documents. If * the operation succeeds, the callback will be invoked with * {@code null}. * @param callback Callback to receive errors resulting from removing the documents. If the * operation succeeds, the callback will be invoked with {@code null}. */ public void removeByQuery(@NonNull String queryExpression, @NonNull SearchSpec searchSpec, Loading
apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java +1 −1 Original line number Diff line number Diff line Loading @@ -115,7 +115,7 @@ public class GlobalSearchSession { * @return The search result of performing this operation. */ @NonNull public SearchResults query( public SearchResults globalQuery( @NonNull String queryExpression, @NonNull SearchSpec searchSpec, @NonNull @CallbackExecutor Executor executor) { Loading
apex/appsearch/framework/java/android/app/appsearch/IAppSearchManager.aidl +3 −14 Original line number Diff line number Diff line Loading @@ -28,10 +28,10 @@ parcelable SearchResults; /** {@hide} */ interface IAppSearchManager { /** * Updates the AppSearch schema for this database. * Sets the schema. * * @param databaseName The name of the database where this schema lives. * @param schemaBundles List of {@link AppSearchSchema} bundles. * @param databaseName The databaseName this document resides in. * @param schemaBundles List of AppSearchSchema bundles. * @param schemasNotPlatformSurfaceable Schema types that should not be surfaced on platform * surfaces. * @param forceOverride Whether to apply the new schema even if it is incompatible. All Loading @@ -46,17 +46,6 @@ interface IAppSearchManager { boolean forceOverride, in IAppSearchResultCallback callback); /** * Retrieves the AppSearch schema for this database. * * @param databaseName The name of the database to retrieve. * @param callback {@link IAppSearchResultCallback#onResult} will be called with an * {@link AppSearchResult}<{@link List}<{@link Bundle}>>, where the value are * AppSearchSchema bundle. */ void getSchema(in String databaseName, in IAppSearchResultCallback callback); /** * Inserts documents into the index. * Loading
apex/appsearch/framework/java/android/app/appsearch/SearchResults.java +1 −1 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ public class SearchResults implements Closeable { * <p>Re-call this method to get next page of {@link SearchResult}, until it returns an * empty list. * * <p>The page size is set by {@link SearchSpec.Builder#setResultCountPerPage}. * <p>The page size is set by {@link SearchSpec.Builder#setNumPerPage}. * * @param callback Callback to receive the pending result of performing this operation. */ Loading
apex/appsearch/service/java/com/android/server/appsearch/AppSearchManagerService.java +0 −26 Original line number Diff line number Diff line Loading @@ -89,32 +89,6 @@ public class AppSearchManagerService extends SystemService { } } @Override public void getSchema( @NonNull String databaseName, @NonNull IAppSearchResultCallback callback) { Preconditions.checkNotNull(databaseName); Preconditions.checkNotNull(callback); int callingUid = Binder.getCallingUidOrThrow(); int callingUserId = UserHandle.getUserId(callingUid); final long callingIdentity = Binder.clearCallingIdentity(); try { AppSearchImpl impl = ImplInstanceManager.getInstance(getContext(), callingUserId); databaseName = rewriteDatabaseNameWithUid(databaseName, callingUid); List<AppSearchSchema> schemas = impl.getSchema(databaseName); List<Bundle> schemaBundles = new ArrayList<>(schemas.size()); for (int i = 0; i < schemas.size(); i++) { schemaBundles.add(schemas.get(i).getBundle()); } invokeCallbackOnResult(callback, AppSearchResult.newSuccessfulResult(schemaBundles)); } catch (Throwable t) { invokeCallbackOnError(callback, t); } finally { Binder.restoreCallingIdentity(callingIdentity); } } @Override public void putDocuments( @NonNull String databaseName, Loading