Loading apex/appsearch/framework/api/current.txt +71 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,14 @@ package android.app.appsearch { method public boolean isSuccess(); } public static final class AppSearchBatchResult.Builder<KeyType, ValueType> { ctor public AppSearchBatchResult.Builder(); method @NonNull public android.app.appsearch.AppSearchBatchResult<KeyType,ValueType> build(); method @NonNull public android.app.appsearch.AppSearchBatchResult.Builder<KeyType,ValueType> setFailure(@NonNull KeyType, int, @Nullable String); method @NonNull public android.app.appsearch.AppSearchBatchResult.Builder<KeyType,ValueType> setResult(@NonNull KeyType, @NonNull android.app.appsearch.AppSearchResult<ValueType>); method @NonNull public android.app.appsearch.AppSearchBatchResult.Builder<KeyType,ValueType> setSuccess(@NonNull KeyType, @Nullable ValueType); } public class AppSearchManager { method public void createGlobalSearchSession(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.GlobalSearchSession>>); method public void createSearchSession(@NonNull android.app.appsearch.AppSearchManager.SearchContext, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.AppSearchSession>>); Loading @@ -29,6 +37,8 @@ package android.app.appsearch { method public int getResultCode(); method @Nullable public ValueType getResultValue(); method public boolean isSuccess(); method @NonNull public static <ValueType> android.app.appsearch.AppSearchResult<ValueType> newFailedResult(int, @Nullable String); method @NonNull public static <ValueType> android.app.appsearch.AppSearchResult<ValueType> newSuccessfulResult(@Nullable ValueType); field public static final int RESULT_INTERNAL_ERROR = 2; // 0x2 field public static final int RESULT_INVALID_ARGUMENT = 3; // 0x3 field public static final int RESULT_INVALID_SCHEMA = 7; // 0x7 Loading @@ -36,13 +46,14 @@ package android.app.appsearch { field public static final int RESULT_NOT_FOUND = 6; // 0x6 field public static final int RESULT_OK = 0; // 0x0 field public static final int RESULT_OUT_OF_SPACE = 5; // 0x5 field public static final int RESULT_SECURITY_ERROR = 8; // 0x8 field public static final int RESULT_UNKNOWN_ERROR = 1; // 0x1 } public final class AppSearchSchema { method @NonNull public java.util.List<android.app.appsearch.AppSearchSchema.PropertyConfig> getProperties(); method @NonNull public String getSchemaType(); method @IntRange(from=0) public int getVersion(); method @Deprecated @IntRange(from=0) public int getVersion(); } public static final class AppSearchSchema.BooleanPropertyConfig extends android.app.appsearch.AppSearchSchema.PropertyConfig { Loading @@ -58,7 +69,7 @@ package android.app.appsearch { ctor public AppSearchSchema.Builder(@NonNull String); method @NonNull public android.app.appsearch.AppSearchSchema.Builder addProperty(@NonNull android.app.appsearch.AppSearchSchema.PropertyConfig); method @NonNull public android.app.appsearch.AppSearchSchema build(); method @NonNull public android.app.appsearch.AppSearchSchema.Builder setVersion(@IntRange(from=0) int); method @Deprecated @NonNull public android.app.appsearch.AppSearchSchema.Builder setVersion(@IntRange(from=0) int); } public static final class AppSearchSchema.BytesPropertyConfig extends android.app.appsearch.AppSearchSchema.PropertyConfig { Loading Loading @@ -130,7 +141,9 @@ package android.app.appsearch { public final class AppSearchSession implements java.io.Closeable { method public void close(); method public void getByUri(@NonNull android.app.appsearch.GetByUriRequest, @NonNull java.util.concurrent.Executor, @NonNull android.app.appsearch.BatchResultCallback<java.lang.String,android.app.appsearch.GenericDocument>); method public void getSchema(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.util.Set<android.app.appsearch.AppSearchSchema>>>); method public void getNamespaces(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.util.Set<java.lang.String>>>); method public void getSchema(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.GetSchemaResponse>>); method public void getStorageInfo(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.StorageInfo>>); method public void put(@NonNull android.app.appsearch.PutDocumentsRequest, @NonNull java.util.concurrent.Executor, @NonNull android.app.appsearch.BatchResultCallback<java.lang.String,java.lang.Void>); method public void remove(@NonNull android.app.appsearch.RemoveByUriRequest, @NonNull java.util.concurrent.Executor, @NonNull android.app.appsearch.BatchResultCallback<java.lang.String,java.lang.Void>); method public void remove(@NonNull String, @NonNull android.app.appsearch.SearchSpec, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.lang.Void>>); Loading Loading @@ -203,16 +216,29 @@ package android.app.appsearch { method @Deprecated @NonNull public android.app.appsearch.GetByUriRequest.Builder setNamespace(@NonNull String); } public class GetSchemaResponse extends java.util.HashSet<android.app.appsearch.AppSearchSchema> { method @NonNull public java.util.Set<android.app.appsearch.AppSearchSchema> getSchemas(); method @IntRange(from=0) public int getVersion(); } public static final class GetSchemaResponse.Builder { ctor public GetSchemaResponse.Builder(); method @NonNull public android.app.appsearch.GetSchemaResponse.Builder addSchema(@NonNull android.app.appsearch.AppSearchSchema); method @NonNull public android.app.appsearch.GetSchemaResponse build(); method @NonNull public android.app.appsearch.GetSchemaResponse.Builder setVersion(@IntRange(from=0) int); } public class GlobalSearchSession implements java.io.Closeable { method public void close(); method public void reportSystemUsage(@NonNull android.app.appsearch.ReportSystemUsageRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.lang.Void>>); method @NonNull public android.app.appsearch.SearchResults search(@NonNull String, @NonNull android.app.appsearch.SearchSpec); } public abstract class Migrator { ctor public Migrator(); ctor public Migrator(int); method @NonNull @WorkerThread public abstract android.app.appsearch.GenericDocument onDowngrade(int, int, @NonNull android.app.appsearch.GenericDocument); method @NonNull @WorkerThread public abstract android.app.appsearch.GenericDocument onUpgrade(int, int, @NonNull android.app.appsearch.GenericDocument); method public abstract boolean shouldMigrate(int, int); } public class PackageIdentifier { Loading Loading @@ -246,6 +272,21 @@ package android.app.appsearch { method @Deprecated @NonNull public android.app.appsearch.RemoveByUriRequest.Builder setNamespace(@NonNull String); } public final class ReportSystemUsageRequest { method @NonNull public String getDatabaseName(); method @NonNull public String getNamespace(); method @NonNull public String getPackageName(); method @NonNull public String getUri(); method public long getUsageTimeMillis(); } public static final class ReportSystemUsageRequest.Builder { ctor public ReportSystemUsageRequest.Builder(@NonNull String, @NonNull String, @NonNull String); method @NonNull public android.app.appsearch.ReportSystemUsageRequest build(); method @NonNull public android.app.appsearch.ReportSystemUsageRequest.Builder setUri(@NonNull String); method @NonNull public android.app.appsearch.ReportSystemUsageRequest.Builder setUsageTimeMillis(long); } public final class ReportUsageRequest { method @NonNull public String getNamespace(); method @NonNull public String getUri(); Loading @@ -267,6 +308,7 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.GenericDocument getGenericDocument(); method @NonNull public java.util.List<android.app.appsearch.SearchResult.MatchInfo> getMatches(); method @NonNull public String getPackageName(); method public double getRankingSignal(); } public static final class SearchResult.Builder { Loading @@ -274,6 +316,7 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SearchResult.Builder addMatch(@NonNull android.app.appsearch.SearchResult.MatchInfo); method @NonNull public android.app.appsearch.SearchResult build(); method @NonNull public android.app.appsearch.SearchResult.Builder setGenericDocument(@NonNull android.app.appsearch.GenericDocument); method @NonNull public android.app.appsearch.SearchResult.Builder setRankingSignal(double); } public static final class SearchResult.MatchInfo { Loading Loading @@ -315,9 +358,13 @@ package android.app.appsearch { method @NonNull public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getProjections(); method public int getRankingStrategy(); method public int getResultCountPerPage(); method public int getResultGroupingLimit(); method public int getResultGroupingTypeFlags(); method public int getSnippetCount(); method public int getSnippetCountPerProperty(); method public int getTermMatch(); field public static final int GROUPING_TYPE_PER_NAMESPACE = 2; // 0x2 field public static final int GROUPING_TYPE_PER_PACKAGE = 1; // 0x1 field public static final int ORDER_ASCENDING = 1; // 0x1 field public static final int ORDER_DESCENDING = 0; // 0x0 field public static final String PROJECTION_SCHEMA_TYPE_WILDCARD = "*"; Loading @@ -325,6 +372,8 @@ package android.app.appsearch { field public static final int RANKING_STRATEGY_DOCUMENT_SCORE = 1; // 0x1 field public static final int RANKING_STRATEGY_NONE = 0; // 0x0 field public static final int RANKING_STRATEGY_RELEVANCE_SCORE = 3; // 0x3 field public static final int RANKING_STRATEGY_SYSTEM_USAGE_COUNT = 6; // 0x6 field public static final int RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP = 7; // 0x7 field public static final int RANKING_STRATEGY_USAGE_COUNT = 4; // 0x4 field public static final int RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP = 5; // 0x5 field public static final int TERM_MATCH_EXACT_ONLY = 1; // 0x1 Loading @@ -345,6 +394,7 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SearchSpec.Builder setOrder(int); method @NonNull public android.app.appsearch.SearchSpec.Builder setRankingStrategy(int); method @NonNull public android.app.appsearch.SearchSpec.Builder setResultCountPerPage(@IntRange(from=0, to=android.app.appsearch.SearchSpec.MAX_NUM_PER_PAGE) int); method @NonNull public android.app.appsearch.SearchSpec.Builder setResultGrouping(int, int); method @NonNull public android.app.appsearch.SearchSpec.Builder setSnippetCount(@IntRange(from=0, to=android.app.appsearch.SearchSpec.MAX_SNIPPET_COUNT) int); method @NonNull public android.app.appsearch.SearchSpec.Builder setSnippetCountPerProperty(@IntRange(from=0, to=android.app.appsearch.SearchSpec.MAX_SNIPPET_PER_PROPERTY_COUNT) int); method @NonNull public android.app.appsearch.SearchSpec.Builder setTermMatch(int); Loading @@ -356,6 +406,7 @@ package android.app.appsearch { method @NonNull public java.util.Set<java.lang.String> getSchemasNotDisplayedBySystem(); method @Deprecated @NonNull public java.util.Set<java.lang.String> getSchemasNotVisibleToSystemUi(); method @NonNull public java.util.Map<java.lang.String,java.util.Set<android.app.appsearch.PackageIdentifier>> getSchemasVisibleToPackages(); method @IntRange(from=1) public int getVersion(); method public boolean isForceOverride(); } Loading @@ -366,9 +417,11 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SetSchemaRequest build(); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setForceOverride(boolean); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setMigrator(@NonNull String, @NonNull android.app.appsearch.Migrator); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setMigrators(@NonNull java.util.Map<java.lang.String,android.app.appsearch.Migrator>); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeDisplayedBySystem(@NonNull String, boolean); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeVisibilityForPackage(@NonNull String, boolean, @NonNull android.app.appsearch.PackageIdentifier); method @Deprecated @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeVisibilityForSystemUi(@NonNull String, boolean); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setVersion(@IntRange(from=1) int); } public class SetSchemaResponse { Loading Loading @@ -407,6 +460,20 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SetSchemaResponse.MigrationFailure.Builder setUri(@NonNull String); } public class StorageInfo { method public int getAliveDocumentsCount(); method public int getAliveNamespacesCount(); method public long getSizeBytes(); } public static final class StorageInfo.Builder { ctor public StorageInfo.Builder(); method @NonNull public android.app.appsearch.StorageInfo build(); method @NonNull public android.app.appsearch.StorageInfo.Builder setAliveDocumentsCount(int); method @NonNull public android.app.appsearch.StorageInfo.Builder setAliveNamespacesCount(int); method @NonNull public android.app.appsearch.StorageInfo.Builder setSizeBytes(long); } } package android.app.appsearch.exceptions { Loading apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.java +9 −9 Original line number Diff line number Diff line Loading @@ -30,10 +30,10 @@ import java.util.Map; /** * Provides results for AppSearch batch operations which encompass multiple documents. * * <p>Individual results of a batch operation are separated into two maps: one for successes and one * for failures. For successes, {@link #getSuccesses()} will return a map of keys to instances of * the value type. For failures, {@link #getFailures()} will return a map of keys to {@link * AppSearchResult} objects. * <p>Individual results of a batch operation are separated into two maps: one for successes and * one for failures. For successes, {@link #getSuccesses()} will return a map of keys to * instances of the value type. For failures, {@link #getFailures()} will return a map of keys to * {@link AppSearchResult} objects. * * <p>Alternatively, {@link #getAll()} returns a map of keys to {@link AppSearchResult} objects for * both successes and failures. Loading Loading @@ -97,8 +97,8 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl } /** * Returns a {@link Map} of keys mapped to instances of {@link AppSearchResult} for all failed * individual results. * Returns a {@link Map} of keys mapped to instances of {@link AppSearchResult} for all * failed individual results. * * <p>The values of the {@link Map} will not be {@code null}. */ Loading @@ -120,7 +120,6 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl /** * Asserts that this {@link AppSearchBatchResult} has no failures. * * @hide */ public void checkSuccess() { Loading Loading @@ -162,8 +161,6 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * Builder for {@link AppSearchBatchResult} objects. * * <p>Once {@link #build} is called, the instance can no longer be used. * * @hide */ public static final class Builder<KeyType, ValueType> { private final Map<KeyType, ValueType> mSuccesses = new ArrayMap<>(); Loading @@ -178,6 +175,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * * @throws IllegalStateException if the builder has already been used. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getSuccesses @NonNull public Builder<KeyType, ValueType> setSuccess( @NonNull KeyType key, @Nullable ValueType result) { Loading @@ -193,6 +191,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * * @throws IllegalStateException if the builder has already been used. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getFailures @NonNull public Builder<KeyType, ValueType> setFailure( @NonNull KeyType key, Loading @@ -210,6 +209,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * * @throws IllegalStateException if the builder has already been used. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getAll @NonNull public Builder<KeyType, ValueType> setResult( @NonNull KeyType key, @NonNull AppSearchResult<ValueType> result) { Loading apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.java +32 −18 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import com.android.internal.util.Preconditions; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading @@ -37,11 +39,9 @@ import java.util.Objects; public final class AppSearchResult<ValueType> implements Parcelable { /** * Result codes from {@link AppSearchSession} methods. * * @hide */ @IntDef( value = { @IntDef(value = { RESULT_OK, RESULT_UNKNOWN_ERROR, RESULT_INTERNAL_ERROR, Loading @@ -50,6 +50,7 @@ public final class AppSearchResult<ValueType> implements Parcelable { RESULT_OUT_OF_SPACE, RESULT_NOT_FOUND, RESULT_INVALID_SCHEMA, RESULT_SECURITY_ERROR, }) @Retention(RetentionPolicy.SOURCE) public @interface ResultCode {} Loading Loading @@ -90,6 +91,9 @@ public final class AppSearchResult<ValueType> implements Parcelable { /** The caller supplied a schema which is invalid or incompatible with the previous schema. */ public static final int RESULT_INVALID_SCHEMA = 7; /** The caller requested an operation it does not have privileges for. */ public static final int RESULT_SECURITY_ERROR = 8; private final @ResultCode int mResultCode; @Nullable private final ValueType mResultValue; @Nullable private final String mErrorMessage; Loading Loading @@ -148,8 +152,8 @@ public final class AppSearchResult<ValueType> implements Parcelable { * * <p>If {@link #isSuccess} is {@code true}, the error message is always {@code null}. The error * message may be {@code null} even if {@link #isSuccess} is {@code false}. See the * documentation of the particular {@link AppSearchSession} call producing this {@link * AppSearchResult} for what is returned by {@link #getErrorMessage}. * documentation of the particular {@link AppSearchSession} call producing this * {@link AppSearchResult} for what is returned by {@link #getErrorMessage}. */ @Nullable public String getErrorMessage() { Loading Loading @@ -208,8 +212,6 @@ public final class AppSearchResult<ValueType> implements Parcelable { /** * Creates a new successful {@link AppSearchResult}. * * @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> newSuccessfulResult( Loading @@ -219,8 +221,6 @@ public final class AppSearchResult<ValueType> implements Parcelable { /** * Creates a new failed {@link AppSearchResult}. * * @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> newFailedResult( Loading @@ -228,6 +228,20 @@ public final class AppSearchResult<ValueType> implements Parcelable { return new AppSearchResult<>(resultCode, /*resultValue=*/ null, errorMessage); } /** * Creates a new failed {@link AppSearchResult} by a AppSearchResult in another type. * * @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> newFailedResult( @NonNull AppSearchResult<?> otherFailedResult) { Preconditions.checkState(!otherFailedResult.isSuccess(), "Cannot convert a success result to a failed result"); return AppSearchResult.newFailedResult( otherFailedResult.getResultCode(), otherFailedResult.getErrorMessage()); } /** @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> throwableToFailedResult( Loading apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java +64 −9 Original line number Diff line number Diff line Loading @@ -45,11 +45,13 @@ import java.util.function.Consumer; */ public final class AppSearchSession implements Closeable { private static final String TAG = "AppSearchSession"; private final String mPackageName; private final String mDatabaseName; @UserIdInt private final int mUserId; private final IAppSearchManager mService; private boolean mIsMutated = false; private boolean mIsClosed = false; Loading Loading @@ -148,6 +150,7 @@ public final class AppSearchSession implements Closeable { schemasPackageAccessibleBundles, request.isForceOverride(), mUserId, request.getVersion(), new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { executor.execute(() -> { Loading Loading @@ -176,7 +179,7 @@ public final class AppSearchSession implements Closeable { */ public void getSchema( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<AppSearchResult<Set<AppSearchSchema>>> callback) { @NonNull Consumer<AppSearchResult<GetSchemaResponse>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); Preconditions.checkState(!mIsClosed, "AppSearchSession has already been closed"); Loading @@ -189,14 +192,46 @@ public final class AppSearchSession implements Closeable { public void onResult(AppSearchResult result) { executor.execute(() -> { if (result.isSuccess()) { 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(AppSearchResult.newSuccessfulResult(schemas)); Bundle responseBundle = (Bundle) result.getResultValue(); GetSchemaResponse response = new GetSchemaResponse(responseBundle); callback.accept(AppSearchResult.newSuccessfulResult(response)); } else { callback.accept(result); } }); } }); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Retrieves the set of all namespaces in the current database with at least one document. * * @param executor Executor on which to invoke the callback. * @param callback Callback to receive the namespaces. */ public void getNamespaces( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<AppSearchResult<Set<String>>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); Preconditions.checkState(!mIsClosed, "AppSearchSession has already been closed"); try { mService.getNamespaces( mPackageName, mDatabaseName, mUserId, new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { executor.execute(() -> { if (result.isSuccess()) { Set<String> namespaces = new ArraySet<>((List<String>) result.getResultValue()); callback.accept( AppSearchResult.newSuccessfulResult(namespaces)); } else { callback.accept(result); } Loading Loading @@ -437,6 +472,7 @@ public final class AppSearchSession implements Closeable { request.getNamespace(), request.getUri(), request.getUsageTimeMillis(), /*systemUsage=*/ false, mUserId, new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { Loading Loading @@ -540,6 +576,25 @@ public final class AppSearchSession implements Closeable { } } /** * Gets the storage info for this {@link AppSearchSession} database. * * <p>This may take time proportional to the number of documents and may be inefficient to * call repeatedly. * * @param executor Executor on which to invoke the callback. * @param callback Callback to receive the storage info. */ public void getStorageInfo( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<AppSearchResult<StorageInfo>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); Preconditions.checkState(!mIsClosed, "AppSearchSession has already been closed"); // TODO(b/182909475): Implement getStorageInfo throw new UnsupportedOperationException(); } /** * Closes the {@link AppSearchSession} to persist all schema and document updates, additions, * and deletes to disk. Loading apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java +65 −6 File changed.Preview size limit exceeded, changes collapsed. Show changes Loading
apex/appsearch/framework/api/current.txt +71 −4 Original line number Diff line number Diff line Loading @@ -8,6 +8,14 @@ package android.app.appsearch { method public boolean isSuccess(); } public static final class AppSearchBatchResult.Builder<KeyType, ValueType> { ctor public AppSearchBatchResult.Builder(); method @NonNull public android.app.appsearch.AppSearchBatchResult<KeyType,ValueType> build(); method @NonNull public android.app.appsearch.AppSearchBatchResult.Builder<KeyType,ValueType> setFailure(@NonNull KeyType, int, @Nullable String); method @NonNull public android.app.appsearch.AppSearchBatchResult.Builder<KeyType,ValueType> setResult(@NonNull KeyType, @NonNull android.app.appsearch.AppSearchResult<ValueType>); method @NonNull public android.app.appsearch.AppSearchBatchResult.Builder<KeyType,ValueType> setSuccess(@NonNull KeyType, @Nullable ValueType); } public class AppSearchManager { method public void createGlobalSearchSession(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.GlobalSearchSession>>); method public void createSearchSession(@NonNull android.app.appsearch.AppSearchManager.SearchContext, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.AppSearchSession>>); Loading @@ -29,6 +37,8 @@ package android.app.appsearch { method public int getResultCode(); method @Nullable public ValueType getResultValue(); method public boolean isSuccess(); method @NonNull public static <ValueType> android.app.appsearch.AppSearchResult<ValueType> newFailedResult(int, @Nullable String); method @NonNull public static <ValueType> android.app.appsearch.AppSearchResult<ValueType> newSuccessfulResult(@Nullable ValueType); field public static final int RESULT_INTERNAL_ERROR = 2; // 0x2 field public static final int RESULT_INVALID_ARGUMENT = 3; // 0x3 field public static final int RESULT_INVALID_SCHEMA = 7; // 0x7 Loading @@ -36,13 +46,14 @@ package android.app.appsearch { field public static final int RESULT_NOT_FOUND = 6; // 0x6 field public static final int RESULT_OK = 0; // 0x0 field public static final int RESULT_OUT_OF_SPACE = 5; // 0x5 field public static final int RESULT_SECURITY_ERROR = 8; // 0x8 field public static final int RESULT_UNKNOWN_ERROR = 1; // 0x1 } public final class AppSearchSchema { method @NonNull public java.util.List<android.app.appsearch.AppSearchSchema.PropertyConfig> getProperties(); method @NonNull public String getSchemaType(); method @IntRange(from=0) public int getVersion(); method @Deprecated @IntRange(from=0) public int getVersion(); } public static final class AppSearchSchema.BooleanPropertyConfig extends android.app.appsearch.AppSearchSchema.PropertyConfig { Loading @@ -58,7 +69,7 @@ package android.app.appsearch { ctor public AppSearchSchema.Builder(@NonNull String); method @NonNull public android.app.appsearch.AppSearchSchema.Builder addProperty(@NonNull android.app.appsearch.AppSearchSchema.PropertyConfig); method @NonNull public android.app.appsearch.AppSearchSchema build(); method @NonNull public android.app.appsearch.AppSearchSchema.Builder setVersion(@IntRange(from=0) int); method @Deprecated @NonNull public android.app.appsearch.AppSearchSchema.Builder setVersion(@IntRange(from=0) int); } public static final class AppSearchSchema.BytesPropertyConfig extends android.app.appsearch.AppSearchSchema.PropertyConfig { Loading Loading @@ -130,7 +141,9 @@ package android.app.appsearch { public final class AppSearchSession implements java.io.Closeable { method public void close(); method public void getByUri(@NonNull android.app.appsearch.GetByUriRequest, @NonNull java.util.concurrent.Executor, @NonNull android.app.appsearch.BatchResultCallback<java.lang.String,android.app.appsearch.GenericDocument>); method public void getSchema(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.util.Set<android.app.appsearch.AppSearchSchema>>>); method public void getNamespaces(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.util.Set<java.lang.String>>>); method public void getSchema(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.GetSchemaResponse>>); method public void getStorageInfo(@NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.StorageInfo>>); method public void put(@NonNull android.app.appsearch.PutDocumentsRequest, @NonNull java.util.concurrent.Executor, @NonNull android.app.appsearch.BatchResultCallback<java.lang.String,java.lang.Void>); method public void remove(@NonNull android.app.appsearch.RemoveByUriRequest, @NonNull java.util.concurrent.Executor, @NonNull android.app.appsearch.BatchResultCallback<java.lang.String,java.lang.Void>); method public void remove(@NonNull String, @NonNull android.app.appsearch.SearchSpec, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.lang.Void>>); Loading Loading @@ -203,16 +216,29 @@ package android.app.appsearch { method @Deprecated @NonNull public android.app.appsearch.GetByUriRequest.Builder setNamespace(@NonNull String); } public class GetSchemaResponse extends java.util.HashSet<android.app.appsearch.AppSearchSchema> { method @NonNull public java.util.Set<android.app.appsearch.AppSearchSchema> getSchemas(); method @IntRange(from=0) public int getVersion(); } public static final class GetSchemaResponse.Builder { ctor public GetSchemaResponse.Builder(); method @NonNull public android.app.appsearch.GetSchemaResponse.Builder addSchema(@NonNull android.app.appsearch.AppSearchSchema); method @NonNull public android.app.appsearch.GetSchemaResponse build(); method @NonNull public android.app.appsearch.GetSchemaResponse.Builder setVersion(@IntRange(from=0) int); } public class GlobalSearchSession implements java.io.Closeable { method public void close(); method public void reportSystemUsage(@NonNull android.app.appsearch.ReportSystemUsageRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.lang.Void>>); method @NonNull public android.app.appsearch.SearchResults search(@NonNull String, @NonNull android.app.appsearch.SearchSpec); } public abstract class Migrator { ctor public Migrator(); ctor public Migrator(int); method @NonNull @WorkerThread public abstract android.app.appsearch.GenericDocument onDowngrade(int, int, @NonNull android.app.appsearch.GenericDocument); method @NonNull @WorkerThread public abstract android.app.appsearch.GenericDocument onUpgrade(int, int, @NonNull android.app.appsearch.GenericDocument); method public abstract boolean shouldMigrate(int, int); } public class PackageIdentifier { Loading Loading @@ -246,6 +272,21 @@ package android.app.appsearch { method @Deprecated @NonNull public android.app.appsearch.RemoveByUriRequest.Builder setNamespace(@NonNull String); } public final class ReportSystemUsageRequest { method @NonNull public String getDatabaseName(); method @NonNull public String getNamespace(); method @NonNull public String getPackageName(); method @NonNull public String getUri(); method public long getUsageTimeMillis(); } public static final class ReportSystemUsageRequest.Builder { ctor public ReportSystemUsageRequest.Builder(@NonNull String, @NonNull String, @NonNull String); method @NonNull public android.app.appsearch.ReportSystemUsageRequest build(); method @NonNull public android.app.appsearch.ReportSystemUsageRequest.Builder setUri(@NonNull String); method @NonNull public android.app.appsearch.ReportSystemUsageRequest.Builder setUsageTimeMillis(long); } public final class ReportUsageRequest { method @NonNull public String getNamespace(); method @NonNull public String getUri(); Loading @@ -267,6 +308,7 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.GenericDocument getGenericDocument(); method @NonNull public java.util.List<android.app.appsearch.SearchResult.MatchInfo> getMatches(); method @NonNull public String getPackageName(); method public double getRankingSignal(); } public static final class SearchResult.Builder { Loading @@ -274,6 +316,7 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SearchResult.Builder addMatch(@NonNull android.app.appsearch.SearchResult.MatchInfo); method @NonNull public android.app.appsearch.SearchResult build(); method @NonNull public android.app.appsearch.SearchResult.Builder setGenericDocument(@NonNull android.app.appsearch.GenericDocument); method @NonNull public android.app.appsearch.SearchResult.Builder setRankingSignal(double); } public static final class SearchResult.MatchInfo { Loading Loading @@ -315,9 +358,13 @@ package android.app.appsearch { method @NonNull public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getProjections(); method public int getRankingStrategy(); method public int getResultCountPerPage(); method public int getResultGroupingLimit(); method public int getResultGroupingTypeFlags(); method public int getSnippetCount(); method public int getSnippetCountPerProperty(); method public int getTermMatch(); field public static final int GROUPING_TYPE_PER_NAMESPACE = 2; // 0x2 field public static final int GROUPING_TYPE_PER_PACKAGE = 1; // 0x1 field public static final int ORDER_ASCENDING = 1; // 0x1 field public static final int ORDER_DESCENDING = 0; // 0x0 field public static final String PROJECTION_SCHEMA_TYPE_WILDCARD = "*"; Loading @@ -325,6 +372,8 @@ package android.app.appsearch { field public static final int RANKING_STRATEGY_DOCUMENT_SCORE = 1; // 0x1 field public static final int RANKING_STRATEGY_NONE = 0; // 0x0 field public static final int RANKING_STRATEGY_RELEVANCE_SCORE = 3; // 0x3 field public static final int RANKING_STRATEGY_SYSTEM_USAGE_COUNT = 6; // 0x6 field public static final int RANKING_STRATEGY_SYSTEM_USAGE_LAST_USED_TIMESTAMP = 7; // 0x7 field public static final int RANKING_STRATEGY_USAGE_COUNT = 4; // 0x4 field public static final int RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP = 5; // 0x5 field public static final int TERM_MATCH_EXACT_ONLY = 1; // 0x1 Loading @@ -345,6 +394,7 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SearchSpec.Builder setOrder(int); method @NonNull public android.app.appsearch.SearchSpec.Builder setRankingStrategy(int); method @NonNull public android.app.appsearch.SearchSpec.Builder setResultCountPerPage(@IntRange(from=0, to=android.app.appsearch.SearchSpec.MAX_NUM_PER_PAGE) int); method @NonNull public android.app.appsearch.SearchSpec.Builder setResultGrouping(int, int); method @NonNull public android.app.appsearch.SearchSpec.Builder setSnippetCount(@IntRange(from=0, to=android.app.appsearch.SearchSpec.MAX_SNIPPET_COUNT) int); method @NonNull public android.app.appsearch.SearchSpec.Builder setSnippetCountPerProperty(@IntRange(from=0, to=android.app.appsearch.SearchSpec.MAX_SNIPPET_PER_PROPERTY_COUNT) int); method @NonNull public android.app.appsearch.SearchSpec.Builder setTermMatch(int); Loading @@ -356,6 +406,7 @@ package android.app.appsearch { method @NonNull public java.util.Set<java.lang.String> getSchemasNotDisplayedBySystem(); method @Deprecated @NonNull public java.util.Set<java.lang.String> getSchemasNotVisibleToSystemUi(); method @NonNull public java.util.Map<java.lang.String,java.util.Set<android.app.appsearch.PackageIdentifier>> getSchemasVisibleToPackages(); method @IntRange(from=1) public int getVersion(); method public boolean isForceOverride(); } Loading @@ -366,9 +417,11 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SetSchemaRequest build(); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setForceOverride(boolean); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setMigrator(@NonNull String, @NonNull android.app.appsearch.Migrator); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setMigrators(@NonNull java.util.Map<java.lang.String,android.app.appsearch.Migrator>); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeDisplayedBySystem(@NonNull String, boolean); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeVisibilityForPackage(@NonNull String, boolean, @NonNull android.app.appsearch.PackageIdentifier); method @Deprecated @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeVisibilityForSystemUi(@NonNull String, boolean); method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setVersion(@IntRange(from=1) int); } public class SetSchemaResponse { Loading Loading @@ -407,6 +460,20 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SetSchemaResponse.MigrationFailure.Builder setUri(@NonNull String); } public class StorageInfo { method public int getAliveDocumentsCount(); method public int getAliveNamespacesCount(); method public long getSizeBytes(); } public static final class StorageInfo.Builder { ctor public StorageInfo.Builder(); method @NonNull public android.app.appsearch.StorageInfo build(); method @NonNull public android.app.appsearch.StorageInfo.Builder setAliveDocumentsCount(int); method @NonNull public android.app.appsearch.StorageInfo.Builder setAliveNamespacesCount(int); method @NonNull public android.app.appsearch.StorageInfo.Builder setSizeBytes(long); } } package android.app.appsearch.exceptions { Loading
apex/appsearch/framework/java/android/app/appsearch/AppSearchBatchResult.java +9 −9 Original line number Diff line number Diff line Loading @@ -30,10 +30,10 @@ import java.util.Map; /** * Provides results for AppSearch batch operations which encompass multiple documents. * * <p>Individual results of a batch operation are separated into two maps: one for successes and one * for failures. For successes, {@link #getSuccesses()} will return a map of keys to instances of * the value type. For failures, {@link #getFailures()} will return a map of keys to {@link * AppSearchResult} objects. * <p>Individual results of a batch operation are separated into two maps: one for successes and * one for failures. For successes, {@link #getSuccesses()} will return a map of keys to * instances of the value type. For failures, {@link #getFailures()} will return a map of keys to * {@link AppSearchResult} objects. * * <p>Alternatively, {@link #getAll()} returns a map of keys to {@link AppSearchResult} objects for * both successes and failures. Loading Loading @@ -97,8 +97,8 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl } /** * Returns a {@link Map} of keys mapped to instances of {@link AppSearchResult} for all failed * individual results. * Returns a {@link Map} of keys mapped to instances of {@link AppSearchResult} for all * failed individual results. * * <p>The values of the {@link Map} will not be {@code null}. */ Loading @@ -120,7 +120,6 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl /** * Asserts that this {@link AppSearchBatchResult} has no failures. * * @hide */ public void checkSuccess() { Loading Loading @@ -162,8 +161,6 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * Builder for {@link AppSearchBatchResult} objects. * * <p>Once {@link #build} is called, the instance can no longer be used. * * @hide */ public static final class Builder<KeyType, ValueType> { private final Map<KeyType, ValueType> mSuccesses = new ArrayMap<>(); Loading @@ -178,6 +175,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * * @throws IllegalStateException if the builder has already been used. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getSuccesses @NonNull public Builder<KeyType, ValueType> setSuccess( @NonNull KeyType key, @Nullable ValueType result) { Loading @@ -193,6 +191,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * * @throws IllegalStateException if the builder has already been used. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getFailures @NonNull public Builder<KeyType, ValueType> setFailure( @NonNull KeyType key, Loading @@ -210,6 +209,7 @@ public final class AppSearchBatchResult<KeyType, ValueType> implements Parcelabl * * @throws IllegalStateException if the builder has already been used. */ @SuppressWarnings("MissingGetterMatchingBuilder") // See getAll @NonNull public Builder<KeyType, ValueType> setResult( @NonNull KeyType key, @NonNull AppSearchResult<ValueType> result) { Loading
apex/appsearch/framework/java/android/app/appsearch/AppSearchResult.java +32 −18 Original line number Diff line number Diff line Loading @@ -24,6 +24,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.Log; import com.android.internal.util.Preconditions; import java.io.IOException; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; Loading @@ -37,11 +39,9 @@ import java.util.Objects; public final class AppSearchResult<ValueType> implements Parcelable { /** * Result codes from {@link AppSearchSession} methods. * * @hide */ @IntDef( value = { @IntDef(value = { RESULT_OK, RESULT_UNKNOWN_ERROR, RESULT_INTERNAL_ERROR, Loading @@ -50,6 +50,7 @@ public final class AppSearchResult<ValueType> implements Parcelable { RESULT_OUT_OF_SPACE, RESULT_NOT_FOUND, RESULT_INVALID_SCHEMA, RESULT_SECURITY_ERROR, }) @Retention(RetentionPolicy.SOURCE) public @interface ResultCode {} Loading Loading @@ -90,6 +91,9 @@ public final class AppSearchResult<ValueType> implements Parcelable { /** The caller supplied a schema which is invalid or incompatible with the previous schema. */ public static final int RESULT_INVALID_SCHEMA = 7; /** The caller requested an operation it does not have privileges for. */ public static final int RESULT_SECURITY_ERROR = 8; private final @ResultCode int mResultCode; @Nullable private final ValueType mResultValue; @Nullable private final String mErrorMessage; Loading Loading @@ -148,8 +152,8 @@ public final class AppSearchResult<ValueType> implements Parcelable { * * <p>If {@link #isSuccess} is {@code true}, the error message is always {@code null}. The error * message may be {@code null} even if {@link #isSuccess} is {@code false}. See the * documentation of the particular {@link AppSearchSession} call producing this {@link * AppSearchResult} for what is returned by {@link #getErrorMessage}. * documentation of the particular {@link AppSearchSession} call producing this * {@link AppSearchResult} for what is returned by {@link #getErrorMessage}. */ @Nullable public String getErrorMessage() { Loading Loading @@ -208,8 +212,6 @@ public final class AppSearchResult<ValueType> implements Parcelable { /** * Creates a new successful {@link AppSearchResult}. * * @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> newSuccessfulResult( Loading @@ -219,8 +221,6 @@ public final class AppSearchResult<ValueType> implements Parcelable { /** * Creates a new failed {@link AppSearchResult}. * * @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> newFailedResult( Loading @@ -228,6 +228,20 @@ public final class AppSearchResult<ValueType> implements Parcelable { return new AppSearchResult<>(resultCode, /*resultValue=*/ null, errorMessage); } /** * Creates a new failed {@link AppSearchResult} by a AppSearchResult in another type. * * @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> newFailedResult( @NonNull AppSearchResult<?> otherFailedResult) { Preconditions.checkState(!otherFailedResult.isSuccess(), "Cannot convert a success result to a failed result"); return AppSearchResult.newFailedResult( otherFailedResult.getResultCode(), otherFailedResult.getErrorMessage()); } /** @hide */ @NonNull public static <ValueType> AppSearchResult<ValueType> throwableToFailedResult( Loading
apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java +64 −9 Original line number Diff line number Diff line Loading @@ -45,11 +45,13 @@ import java.util.function.Consumer; */ public final class AppSearchSession implements Closeable { private static final String TAG = "AppSearchSession"; private final String mPackageName; private final String mDatabaseName; @UserIdInt private final int mUserId; private final IAppSearchManager mService; private boolean mIsMutated = false; private boolean mIsClosed = false; Loading Loading @@ -148,6 +150,7 @@ public final class AppSearchSession implements Closeable { schemasPackageAccessibleBundles, request.isForceOverride(), mUserId, request.getVersion(), new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { executor.execute(() -> { Loading Loading @@ -176,7 +179,7 @@ public final class AppSearchSession implements Closeable { */ public void getSchema( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<AppSearchResult<Set<AppSearchSchema>>> callback) { @NonNull Consumer<AppSearchResult<GetSchemaResponse>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); Preconditions.checkState(!mIsClosed, "AppSearchSession has already been closed"); Loading @@ -189,14 +192,46 @@ public final class AppSearchSession implements Closeable { public void onResult(AppSearchResult result) { executor.execute(() -> { if (result.isSuccess()) { 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(AppSearchResult.newSuccessfulResult(schemas)); Bundle responseBundle = (Bundle) result.getResultValue(); GetSchemaResponse response = new GetSchemaResponse(responseBundle); callback.accept(AppSearchResult.newSuccessfulResult(response)); } else { callback.accept(result); } }); } }); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } } /** * Retrieves the set of all namespaces in the current database with at least one document. * * @param executor Executor on which to invoke the callback. * @param callback Callback to receive the namespaces. */ public void getNamespaces( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<AppSearchResult<Set<String>>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); Preconditions.checkState(!mIsClosed, "AppSearchSession has already been closed"); try { mService.getNamespaces( mPackageName, mDatabaseName, mUserId, new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { executor.execute(() -> { if (result.isSuccess()) { Set<String> namespaces = new ArraySet<>((List<String>) result.getResultValue()); callback.accept( AppSearchResult.newSuccessfulResult(namespaces)); } else { callback.accept(result); } Loading Loading @@ -437,6 +472,7 @@ public final class AppSearchSession implements Closeable { request.getNamespace(), request.getUri(), request.getUsageTimeMillis(), /*systemUsage=*/ false, mUserId, new IAppSearchResultCallback.Stub() { public void onResult(AppSearchResult result) { Loading Loading @@ -540,6 +576,25 @@ public final class AppSearchSession implements Closeable { } } /** * Gets the storage info for this {@link AppSearchSession} database. * * <p>This may take time proportional to the number of documents and may be inefficient to * call repeatedly. * * @param executor Executor on which to invoke the callback. * @param callback Callback to receive the storage info. */ public void getStorageInfo( @NonNull @CallbackExecutor Executor executor, @NonNull Consumer<AppSearchResult<StorageInfo>> callback) { Objects.requireNonNull(executor); Objects.requireNonNull(callback); Preconditions.checkState(!mIsClosed, "AppSearchSession has already been closed"); // TODO(b/182909475): Implement getStorageInfo throw new UnsupportedOperationException(); } /** * Closes the {@link AppSearchSession} to persist all schema and document updates, additions, * and deletes to disk. Loading
apex/appsearch/framework/java/android/app/appsearch/GlobalSearchSession.java +65 −6 File changed.Preview size limit exceeded, changes collapsed. Show changes