diff --git a/apex/appsearch/framework/api/current.txt b/apex/appsearch/framework/api/current.txt index 47cf17cb1d4ca..5acfe6ab64309 100644 --- a/apex/appsearch/framework/api/current.txt +++ b/apex/appsearch/framework/api/current.txt @@ -26,10 +26,8 @@ package android.app.appsearch { } public static final class AppSearchManager.SearchContext.Builder { - ctor @Deprecated public AppSearchManager.SearchContext.Builder(); ctor public AppSearchManager.SearchContext.Builder(@NonNull String); method @NonNull public android.app.appsearch.AppSearchManager.SearchContext build(); - method @Deprecated @NonNull public android.app.appsearch.AppSearchManager.SearchContext.Builder setDatabaseName(@NonNull String); } public final class AppSearchResult { @@ -53,7 +51,6 @@ package android.app.appsearch { public final class AppSearchSchema { method @NonNull public java.util.List getProperties(); method @NonNull public String getSchemaType(); - method @Deprecated @IntRange(from=0) public int getVersion(); } public static final class AppSearchSchema.BooleanPropertyConfig extends android.app.appsearch.AppSearchSchema.PropertyConfig { @@ -69,7 +66,6 @@ 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 @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 { @@ -149,7 +145,6 @@ package android.app.appsearch { method public void remove(@NonNull String, @NonNull android.app.appsearch.SearchSpec, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer>); method public void reportUsage(@NonNull android.app.appsearch.ReportUsageRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer>); method @NonNull public android.app.appsearch.SearchResults search(@NonNull String, @NonNull android.app.appsearch.SearchSpec); - method @Deprecated public void setSchema(@NonNull android.app.appsearch.SetSchemaRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer>); method public void setSchema(@NonNull android.app.appsearch.SetSchemaRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer>); } @@ -181,15 +176,12 @@ package android.app.appsearch { method public int getScore(); method public long getTtlMillis(); method @NonNull public String getUri(); - field @Deprecated public static final String DEFAULT_NAMESPACE = ""; } public static class GenericDocument.Builder { - ctor @Deprecated public GenericDocument.Builder(@NonNull String, @NonNull String); ctor public GenericDocument.Builder(@NonNull String, @NonNull String, @NonNull String); method @NonNull public android.app.appsearch.GenericDocument build(); method @NonNull public BuilderType setCreationTimestampMillis(long); - method @Deprecated @NonNull public BuilderType setNamespace(@NonNull String); method @NonNull public BuilderType setPropertyBoolean(@NonNull String, @NonNull boolean...); method @NonNull public BuilderType setPropertyBytes(@NonNull String, @NonNull byte[]...); method @NonNull public BuilderType setPropertyDocument(@NonNull String, @NonNull android.app.appsearch.GenericDocument...); @@ -208,16 +200,14 @@ package android.app.appsearch { } public static final class GetByUriRequest.Builder { - ctor @Deprecated public GetByUriRequest.Builder(); ctor public GetByUriRequest.Builder(@NonNull String); method @NonNull public android.app.appsearch.GetByUriRequest.Builder addProjection(@NonNull String, @NonNull java.util.Collection); method @NonNull public android.app.appsearch.GetByUriRequest.Builder addUris(@NonNull java.lang.String...); method @NonNull public android.app.appsearch.GetByUriRequest.Builder addUris(@NonNull java.util.Collection); method @NonNull public android.app.appsearch.GetByUriRequest build(); - method @Deprecated @NonNull public android.app.appsearch.GetByUriRequest.Builder setNamespace(@NonNull String); } - public class GetSchemaResponse extends java.util.HashSet { + public class GetSchemaResponse { method @NonNull public java.util.Set getSchemas(); method @IntRange(from=0) public int getVersion(); } @@ -265,12 +255,10 @@ package android.app.appsearch { } public static final class RemoveByUriRequest.Builder { - ctor @Deprecated public RemoveByUriRequest.Builder(); ctor public RemoveByUriRequest.Builder(@NonNull String); method @NonNull public android.app.appsearch.RemoveByUriRequest.Builder addUris(@NonNull java.lang.String...); method @NonNull public android.app.appsearch.RemoveByUriRequest.Builder addUris(@NonNull java.util.Collection); method @NonNull public android.app.appsearch.RemoveByUriRequest build(); - method @Deprecated @NonNull public android.app.appsearch.RemoveByUriRequest.Builder setNamespace(@NonNull String); } public final class ReportSystemUsageRequest { @@ -295,17 +283,14 @@ package android.app.appsearch { } public static final class ReportUsageRequest.Builder { - ctor @Deprecated public ReportUsageRequest.Builder(); ctor public ReportUsageRequest.Builder(@NonNull String); method @NonNull public android.app.appsearch.ReportUsageRequest build(); - method @Deprecated @NonNull public android.app.appsearch.ReportUsageRequest.Builder setNamespace(@NonNull String); method @NonNull public android.app.appsearch.ReportUsageRequest.Builder setUri(@NonNull String); method @NonNull public android.app.appsearch.ReportUsageRequest.Builder setUsageTimeMillis(long); } public final class SearchResult { method @NonNull public String getDatabaseName(); - method @Deprecated @NonNull public android.app.appsearch.GenericDocument getDocument(); method @NonNull public android.app.appsearch.GenericDocument getGenericDocument(); method @NonNull public java.util.List getMatches(); method @NonNull public String getPackageName(); @@ -322,12 +307,10 @@ package android.app.appsearch { public static final class SearchResult.MatchInfo { method @NonNull public CharSequence getExactMatch(); - method @Deprecated @NonNull public android.app.appsearch.SearchResult.MatchRange getExactMatchPosition(); method @NonNull public android.app.appsearch.SearchResult.MatchRange getExactMatchRange(); method @NonNull public String getFullText(); method @NonNull public String getPropertyPath(); method @NonNull public CharSequence getSnippet(); - method @Deprecated @NonNull public android.app.appsearch.SearchResult.MatchRange getSnippetPosition(); method @NonNull public android.app.appsearch.SearchResult.MatchRange getSnippetRange(); } @@ -405,7 +388,6 @@ package android.app.appsearch { method @NonNull public java.util.Map getMigrators(); method @NonNull public java.util.Set getSchemas(); method @NonNull public java.util.Set getSchemasNotDisplayedBySystem(); - method @Deprecated @NonNull public java.util.Set getSchemasNotVisibleToSystemUi(); method @NonNull public java.util.Map> getSchemasVisibleToPackages(); method @IntRange(from=1) public int getVersion(); method public boolean isForceOverride(); @@ -421,7 +403,6 @@ package android.app.appsearch { method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setMigrators(@NonNull java.util.Map); 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); } diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java index 0c6b86b686367..977682771ca3c 100644 --- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java +++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchManager.java @@ -147,21 +147,9 @@ public class AppSearchManager { /** Builder for {@link SearchContext} objects. */ public static final class Builder { - private String mDatabaseName; + private final String mDatabaseName; private boolean mBuilt = false; - /** - * TODO(b/181887768): This method exists only for dogfooder transition and must be - * removed. - * - * @deprecated Please supply the databaseName in {@link #Builder(String)} instead. This - * method exists only for dogfooder transition and must be removed. - */ - @Deprecated - public Builder() { - mDatabaseName = ""; - } - /** * Creates a new {@link SearchContext.Builder}. * @@ -182,37 +170,6 @@ public class AppSearchManager { mDatabaseName = databaseName; } - /** - * Sets the name of the database associated with {@link AppSearchSession}. - * - *

{@link AppSearchSession} will create or open a database under the given name. - * - *

Databases with different names are fully separate with distinct types, namespaces, - * and data. - * - *

Database name cannot contain {@code '/'}. - * - *

If not specified, defaults to the empty string. - * - *

TODO(b/181887768): This method exists only for dogfooder transition and must be - * removed. - * - * @param databaseName The name of the database. - * @throws IllegalArgumentException if the databaseName contains {@code '/'}. - * @deprecated Please supply the databaseName in {@link #Builder(String)} instead. This - * method exists only for dogfooder transition and must be removed. - */ - @Deprecated - @NonNull - public Builder setDatabaseName(@NonNull String databaseName) { - Preconditions.checkState(!mBuilt, "Builder has already been used"); - Objects.requireNonNull(databaseName); - Preconditions.checkArgument( - !databaseName.contains("/"), "Database name cannot contain '/'"); - mDatabaseName = databaseName; - return this; - } - /** Builds a {@link SearchContext} instance. */ @NonNull public SearchContext build() { diff --git a/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java b/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java index a0718dc956f72..0f6468a62794e 100644 --- a/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java +++ b/apex/appsearch/framework/java/android/app/appsearch/AppSearchSession.java @@ -107,18 +107,6 @@ public final class AppSearchSession implements Closeable { mDatabaseName = databaseName; } - /** - * TODO(b/181887768): This method exists only for dogfooder transition and must be removed. - * @deprecated This method exists only for dogfooder transition and must be removed. - */ - @Deprecated - public void setSchema( - @NonNull SetSchemaRequest request, - @NonNull @CallbackExecutor Executor callbackExecutor, - @NonNull Consumer> callback) { - setSchema(request, callbackExecutor, callbackExecutor, callback); - } - /** * Sets the schema that represents the organizational structure of data within the AppSearch * database. diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchSchema.java b/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchSchema.java index 79b7b75521961..a8048dc5a4c43 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchSchema.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/AppSearchSchema.java @@ -17,7 +17,6 @@ package android.app.appsearch; import android.annotation.IntDef; -import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.app.appsearch.exceptions.IllegalSchemaException; @@ -77,12 +76,6 @@ public final class AppSearchSchema { return mBundle.getString(SCHEMA_TYPE_FIELD, ""); } - /** @deprecated Use {@link GetSchemaResponse#getVersion()} instead. */ - @Deprecated - public @IntRange(from = 0) int getVersion() { - return 0; - } - /** * Returns the list of {@link PropertyConfig}s that are part of this schema. * @@ -149,17 +142,6 @@ public final class AppSearchSchema { return this; } - /** - * @deprecated TODO(b/181887768): This method is a no-op and only exists for dogfooder - * transition. - */ - @Deprecated - @NonNull - public AppSearchSchema.Builder setVersion(@IntRange(from = 0) int version) { - Preconditions.checkState(!mBuilt, "Builder has already been used"); - return this; - } - /** * Constructs a new {@link AppSearchSchema} from the contents of this builder. * diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java b/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java index 4ce95ea358f45..8c9d950abe25f 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/GenericDocument.java @@ -46,15 +46,6 @@ import java.util.Set; public class GenericDocument { private static final String TAG = "AppSearchGenericDocumen"; - /** - * The default empty namespace. - * - *

TODO(b/181887768): This exists only for dogfooder transition and must be removed. - * - * @deprecated This exists only for dogfooder transition and must be removed. - */ - @Deprecated public static final String DEFAULT_NAMESPACE = ""; - /** The maximum number of elements in a repeatable field. */ private static final int MAX_REPEATED_PROPERTY_LENGTH = 100; @@ -580,41 +571,6 @@ public class GenericDocument { private final BuilderType mBuilderTypeInstance; private boolean mBuilt = false; - /** - * Creates a new {@link GenericDocument.Builder}. - * - *

Once {@link #build} is called, the instance can no longer be used. - * - *

TODO(b/181887768): This method exists only for dogfooder transition and must be - * removed. - * - * @param uri the URI to set for the {@link GenericDocument}. - * @param schemaType the {@link AppSearchSchema} type of the {@link GenericDocument}. The - * provided {@code schemaType} must be defined using {@link AppSearchSession#setSchema} - * prior to inserting a document of this {@code schemaType} into the AppSearch index - * using {@link AppSearchSession#put}. Otherwise, the document will be rejected by - * {@link AppSearchSession#put} with result code {@link - * AppSearchResult#RESULT_NOT_FOUND}. - * @deprecated Please supply the namespace in {@link #Builder(String, String, String)} - * instead. This method exists only for dogfooder transition and must be removed. - */ - @Deprecated - @SuppressWarnings("unchecked") - public Builder(@NonNull String uri, @NonNull String schemaType) { - Preconditions.checkNotNull(uri); - Preconditions.checkNotNull(schemaType); - mBuilderTypeInstance = (BuilderType) this; - mBundle.putString(GenericDocument.URI_FIELD, uri); - mBundle.putString(GenericDocument.SCHEMA_TYPE_FIELD, schemaType); - mBundle.putString(GenericDocument.NAMESPACE_FIELD, DEFAULT_NAMESPACE); - // Set current timestamp for creation timestamp by default. - mBundle.putLong( - GenericDocument.CREATION_TIMESTAMP_MILLIS_FIELD, System.currentTimeMillis()); - mBundle.putLong(GenericDocument.TTL_MILLIS_FIELD, DEFAULT_TTL_MILLIS); - mBundle.putInt(GenericDocument.SCORE_FIELD, DEFAULT_SCORE); - mBundle.putBundle(PROPERTIES_FIELD, mProperties); - } - /** * Creates a new {@link GenericDocument.Builder}. * @@ -650,29 +606,6 @@ public class GenericDocument { mBundle.putBundle(PROPERTIES_FIELD, mProperties); } - /** - * Sets the app-defined namespace this document resides in. No special values are reserved - * or understood by the infrastructure. - * - *

URIs are unique within a namespace. - * - *

The number of namespaces per app should be kept small for efficiency reasons. - * - *

TODO(b/181887768): This method exists only for dogfooder transition and must be - * removed. - * - * @throws IllegalStateException if the builder has already been used. - * @deprecated Please supply the namespace in {@link #Builder(String, String, String)} - * instead. This method exists only for dogfooder transition and must be removed. - */ - @Deprecated - @NonNull - public BuilderType setNamespace(@NonNull String namespace) { - Preconditions.checkState(!mBuilt, "Builder has already been used"); - mBundle.putString(GenericDocument.NAMESPACE_FIELD, namespace); - return mBuilderTypeInstance; - } - /** * Sets the score of the {@link GenericDocument}. * diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/GetByUriRequest.java b/apex/appsearch/framework/java/external/android/app/appsearch/GetByUriRequest.java index 6881a27d6846e..1719e14b01e31 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/GetByUriRequest.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/GetByUriRequest.java @@ -107,48 +107,16 @@ public final class GetByUriRequest { *

Once {@link #build} is called, the instance can no longer be used. */ public static final class Builder { - private String mNamespace; + private final String mNamespace; private final Set mUris = new ArraySet<>(); private final Map> mProjectionTypePropertyPaths = new ArrayMap<>(); private boolean mBuilt = false; - /** - * TODO(b/181887768): This method exists only for dogfooder transition and must be removed. - * - * @deprecated Please supply the namespace in {@link #Builder(String)} instead. This method - * exists only for dogfooder transition and must be removed. - */ - @Deprecated - public Builder() { - mNamespace = GenericDocument.DEFAULT_NAMESPACE; - } - /** Creates a {@link GetByUriRequest.Builder} instance. */ public Builder(@NonNull String namespace) { mNamespace = Preconditions.checkNotNull(namespace); } - /** - * Sets the namespace to retrieve documents for. - * - *

If this is not called, the namespace defaults to an empty string. - * - *

TODO(b/181887768): This method exists only for dogfooder transition and must be - * removed. - * - * @throws IllegalStateException if the builder has already been used. - * @deprecated Please supply the namespace in {@link #Builder(String)} instead. This method - * exists only for dogfooder transition and must - */ - @Deprecated - @NonNull - public Builder setNamespace(@NonNull String namespace) { - Preconditions.checkState(!mBuilt, "Builder has already been used"); - Preconditions.checkNotNull(namespace); - mNamespace = namespace; - return this; - } - /** * Adds one or more URIs to the request. * diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/GetSchemaResponse.java b/apex/appsearch/framework/java/external/android/app/appsearch/GetSchemaResponse.java index 3e693670f7bcd..1f56ef3588b1f 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/GetSchemaResponse.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/GetSchemaResponse.java @@ -24,30 +24,17 @@ import android.util.ArraySet; import com.android.internal.util.Preconditions; import java.util.ArrayList; -import java.util.HashSet; import java.util.Set; /** The response class of {@link AppSearchSession#getSchema} */ -// TODO(b/181887768) extends only for dogfooder transition. */ -public class GetSchemaResponse extends HashSet { +public class GetSchemaResponse { private static final String VERSION_FIELD = "version"; private static final String SCHEMAS_FIELD = "schemas"; private final Bundle mBundle; - // TODO(b/181887768) Remove this method once this class no longer extends HashSet. */ - private static Set getSchemasFromBundle(Bundle bundle) { - ArrayList schemaBundles = bundle.getParcelableArrayList(SCHEMAS_FIELD); - Set schemas = new ArraySet<>(schemaBundles.size()); - for (int i = 0; i < schemaBundles.size(); i++) { - schemas.add(new AppSearchSchema(schemaBundles.get(i))); - } - return schemas; - } - GetSchemaResponse(@NonNull Bundle bundle) { - super(getSchemasFromBundle(Preconditions.checkNotNull(bundle))); - mBundle = bundle; + mBundle = Preconditions.checkNotNull(bundle); } /** @@ -72,10 +59,17 @@ public class GetSchemaResponse extends HashSet { /** * Return the schemas most recently successfully provided to {@link AppSearchSession#setSchema}. + * + *

It is inefficient to call this method repeatedly. */ @NonNull public Set getSchemas() { - return this; + ArrayList schemaBundles = mBundle.getParcelableArrayList(SCHEMAS_FIELD); + Set schemas = new ArraySet<>(schemaBundles.size()); + for (int i = 0; i < schemaBundles.size(); i++) { + schemas.add(new AppSearchSchema(schemaBundles.get(i))); + } + return schemas; } /** Builder for {@link GetSchemaResponse} objects. */ diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/RemoveByUriRequest.java b/apex/appsearch/framework/java/external/android/app/appsearch/RemoveByUriRequest.java index 455cf3a26b50f..8da68c0b48989 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/RemoveByUriRequest.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/RemoveByUriRequest.java @@ -59,47 +59,15 @@ public final class RemoveByUriRequest { *

Once {@link #build} is called, the instance can no longer be used. */ public static final class Builder { - private String mNamespace; + private final String mNamespace; private final Set mUris = new ArraySet<>(); private boolean mBuilt = false; - /** - * TODO(b/181887768): This method exists only for dogfooder transition and must be removed. - * - * @deprecated Please supply the namespace in {@link #Builder(String)} instead. This method - * exists only for dogfooder transition and must be removed. - */ - @Deprecated - public Builder() { - mNamespace = GenericDocument.DEFAULT_NAMESPACE; - } - /** Creates a {@link RemoveByUriRequest.Builder} instance. */ public Builder(@NonNull String namespace) { mNamespace = Preconditions.checkNotNull(namespace); } - /** - * Sets the namespace to remove documents for. - * - *

If this is not set, it defaults to an empty string. - * - *

TODO(b/181887768): This method exists only for dogfooder transition and must be - * removed. - * - * @throws IllegalStateException if the builder has already been used. - * @deprecated Please supply the namespace in {@link #Builder(String)} instead. This method - * exists only for dogfooder transition and must - */ - @Deprecated - @NonNull - public Builder setNamespace(@NonNull String namespace) { - Preconditions.checkState(!mBuilt, "Builder has already been used"); - Preconditions.checkNotNull(namespace); - mNamespace = namespace; - return this; - } - /** * Adds one or more URIs to the request. * diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/ReportUsageRequest.java b/apex/appsearch/framework/java/external/android/app/appsearch/ReportUsageRequest.java index 2cd08c631006b..646e73c24bd99 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/ReportUsageRequest.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/ReportUsageRequest.java @@ -62,48 +62,16 @@ public final class ReportUsageRequest { /** Builder for {@link ReportUsageRequest} objects. */ public static final class Builder { - private String mNamespace; + private final String mNamespace; private String mUri; private Long mUsageTimeMillis; private boolean mBuilt = false; - /** - * TODO(b/181887768): This method exists only for dogfooder transition and must be removed. - * - * @deprecated Please supply the namespace in {@link #Builder(String)} instead. This method - * exists only for dogfooder transition and must be removed. - */ - @Deprecated - public Builder() { - mNamespace = GenericDocument.DEFAULT_NAMESPACE; - } - /** Creates a {@link ReportUsageRequest.Builder} instance. */ public Builder(@NonNull String namespace) { mNamespace = Preconditions.checkNotNull(namespace); } - /** - * Sets which namespace the document being used belongs to. - * - *

If this is not set, it defaults to an empty string. - * - *

TODO(b/181887768): This method exists only for dogfooder transition and must be - * removed. - * - * @throws IllegalStateException if the builder has already been used - * @deprecated Please supply the namespace in {@link #Builder(String)} instead. This method - * exists only for dogfooder transition and must - */ - @Deprecated - @NonNull - public ReportUsageRequest.Builder setNamespace(@NonNull String namespace) { - Preconditions.checkState(!mBuilt, "Builder has already been used"); - Preconditions.checkNotNull(namespace); - mNamespace = namespace; - return this; - } - /** * Sets the URI of the document being used. * diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java b/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java index e66056f0380b5..55a228d94c10d 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/SearchResult.java @@ -68,13 +68,6 @@ public final class SearchResult { return mBundle; } - /** @deprecated TODO(b/181887768): This method exists only for dogfooder transition. */ - @NonNull - @Deprecated - public GenericDocument getDocument() { - return getGenericDocument(); - } - /** * Contains the matching {@link GenericDocument}. * @@ -142,17 +135,18 @@ public final class SearchResult { *

    *
  • {@link SearchSpec#RANKING_STRATEGY_NONE} - this value will be 0 *
  • {@link SearchSpec#RANKING_STRATEGY_DOCUMENT_SCORE} - the value returned by calling - * {@link GenericDocument#getScore()} on the document returned by {@link #getDocument()} + * {@link GenericDocument#getScore()} on the document returned by {@link + * #getGenericDocument()} *
  • {@link SearchSpec#RANKING_STRATEGY_CREATION_TIMESTAMP} - the value returned by calling * {@link GenericDocument#getCreationTimestampMillis()} on the document returned by {@link - * #getDocument()} + * #getGenericDocument()} *
  • {@link SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE} - an arbitrary double value where a * higher value means more relevant *
  • {@link SearchSpec#RANKING_STRATEGY_USAGE_COUNT} - the number of times usage has been - * reported for the document returned by {@link #getDocument()} + * reported for the document returned by {@link #getGenericDocument()} *
  • {@link SearchSpec#RANKING_STRATEGY_USAGE_LAST_USED_TIMESTAMP} - the timestamp of the * most recent usage that has been reported for the document returned by {@link - * #getDocument()} + * #getGenericDocument()} *
* * @return Ranking signal of the document @@ -354,13 +348,6 @@ public final class SearchResult { return mFullText; } - /** @deprecated TODO(b/181887768): This method exists only for dogfooder transition. */ - @NonNull - @Deprecated - public MatchRange getExactMatchPosition() { - return getExactMatchRange(); - } - /** * Gets the exact {@link MatchRange} corresponding to the given entry. * @@ -387,13 +374,6 @@ public final class SearchResult { return getSubstring(getExactMatchRange()); } - /** @deprecated TODO(b/181887768): This method exists only for dogfooder transition. */ - @NonNull - @Deprecated - public MatchRange getSnippetPosition() { - return getSnippetRange(); - } - /** * Gets the snippet {@link MatchRange} corresponding to the given entry. * diff --git a/apex/appsearch/framework/java/external/android/app/appsearch/SetSchemaRequest.java b/apex/appsearch/framework/java/external/android/app/appsearch/SetSchemaRequest.java index e840ffcc69b1e..1324451f47f9f 100644 --- a/apex/appsearch/framework/java/external/android/app/appsearch/SetSchemaRequest.java +++ b/apex/appsearch/framework/java/external/android/app/appsearch/SetSchemaRequest.java @@ -108,16 +108,6 @@ public final class SetSchemaRequest { return Collections.unmodifiableSet(mSchemas); } - /** - * TODO(b/181887768): This method exists only for dogfooder transition and must be removed. - * @deprecated This method exists only for dogfooder transition and must be removed. - */ - @Deprecated - @NonNull - public Set getSchemasNotVisibleToSystemUi() { - return getSchemasNotDisplayedBySystem(); - } - /** * Returns all the schema types that are opted out of being displayed and visible on any system * UI surface. @@ -221,17 +211,6 @@ public final class SetSchemaRequest { return this; } - /** - * TODO(b/181887768): This method exists only for dogfooder transition and must be removed. - * @deprecated This method exists only for dogfooder transition and must be removed. - */ - @Deprecated - @NonNull - public Builder setSchemaTypeVisibilityForSystemUi( - @NonNull String schemaType, boolean displayed) { - return setSchemaTypeDisplayedBySystem(schemaType, displayed); - } - /** * Sets whether or not documents from the provided {@code schemaType} will be displayed and * visible on any system UI surface. diff --git a/apex/appsearch/service/java/com/android/server/appsearch/VisibilityStore.java b/apex/appsearch/service/java/com/android/server/appsearch/VisibilityStore.java index 78474295078a1..1ed26d670f362 100644 --- a/apex/appsearch/service/java/com/android/server/appsearch/VisibilityStore.java +++ b/apex/appsearch/service/java/com/android/server/appsearch/VisibilityStore.java @@ -156,7 +156,7 @@ public class VisibilityStore { AppSearchImpl.createPrefix(PACKAGE_NAME, DATABASE_NAME); /** Namespace of documents that contain visibility settings */ - private static final String NAMESPACE = GenericDocument.DEFAULT_NAMESPACE; + private static final String NAMESPACE = ""; /** * Prefix to add to all visibility document uri's. IcingSearchEngine doesn't allow empty uri's. @@ -337,9 +337,9 @@ public class VisibilityStore { Preconditions.checkNotNull(schemasPackageAccessible); // Persist the document - GenericDocument.Builder visibilityDocument = - new GenericDocument.Builder(/*uri=*/ addUriPrefix(prefix), VISIBILITY_TYPE) - .setNamespace(NAMESPACE); + GenericDocument.Builder visibilityDocument = + new GenericDocument.Builder<>( + NAMESPACE, /*uri=*/ addUriPrefix(prefix), VISIBILITY_TYPE); if (!schemasNotPlatformSurfaceable.isEmpty()) { visibilityDocument.setPropertyString( NOT_PLATFORM_SURFACEABLE_PROPERTY, @@ -351,17 +351,16 @@ public class VisibilityStore { for (Map.Entry> entry : schemasPackageAccessible.entrySet()) { for (int i = 0; i < entry.getValue().size(); i++) { - GenericDocument packageAccessibleDocument = - new GenericDocument.Builder(/*uri=*/ "", PACKAGE_ACCESSIBLE_TYPE) - .setNamespace(NAMESPACE) - .setPropertyString( - PACKAGE_NAME_PROPERTY, - entry.getValue().get(i).getPackageName()) - .setPropertyBytes( - SHA_256_CERT_PROPERTY, - entry.getValue().get(i).getSha256Certificate()) - .setPropertyString(ACCESSIBLE_SCHEMA_PROPERTY, entry.getKey()) - .build(); + GenericDocument packageAccessibleDocument = new GenericDocument.Builder<>( + NAMESPACE, /*uri=*/ "", PACKAGE_ACCESSIBLE_TYPE) + .setPropertyString( + PACKAGE_NAME_PROPERTY, + entry.getValue().get(i).getPackageName()) + .setPropertyBytes( + SHA_256_CERT_PROPERTY, + entry.getValue().get(i).getSha256Certificate()) + .setPropertyString(ACCESSIBLE_SCHEMA_PROPERTY, entry.getKey()) + .build(); packageAccessibleDocuments.add(packageAccessibleDocument); } schemaToPackageIdentifierMap.put(entry.getKey(), new ArraySet<>(entry.getValue())); diff --git a/core/java/android/content/pm/AppSearchPerson.java b/core/java/android/content/pm/AppSearchPerson.java index 66295eb513d88..9283e5fd3cbd9 100644 --- a/core/java/android/content/pm/AppSearchPerson.java +++ b/core/java/android/content/pm/AppSearchPerson.java @@ -107,7 +107,7 @@ public class AppSearchPerson extends GenericDocument { public static class Builder extends GenericDocument.Builder { public Builder(@NonNull final String id) { - super(id, SCHEMA_TYPE); + super(/*namespace=*/ "", id, SCHEMA_TYPE); } /** @hide */ diff --git a/core/java/android/content/pm/AppSearchShortcutInfo.java b/core/java/android/content/pm/AppSearchShortcutInfo.java index c04d3bef3af35..b2478ca12191a 100644 --- a/core/java/android/content/pm/AppSearchShortcutInfo.java +++ b/core/java/android/content/pm/AppSearchShortcutInfo.java @@ -217,9 +217,8 @@ public class AppSearchShortcutInfo extends GenericDocument { @NonNull public static AppSearchShortcutInfo instance(@NonNull final ShortcutInfo shortcutInfo) { Objects.requireNonNull(shortcutInfo); - return new Builder(shortcutInfo.getId()) + return new Builder(shortcutInfo.getPackage(), shortcutInfo.getId()) .setActivity(shortcutInfo.getActivity()) - .setNamespace(shortcutInfo.getPackage()) .setShortLabel(shortcutInfo.getShortLabel()) .setShortLabelResId(shortcutInfo.getShortLabelResourceId()) .setShortLabelResName(shortcutInfo.getTitleResName()) @@ -345,8 +344,8 @@ public class AppSearchShortcutInfo extends GenericDocument { @VisibleForTesting public static class Builder extends GenericDocument.Builder { - public Builder(String id) { - super(id, SCHEMA_TYPE); + public Builder(String packageName, String id) { + super(/*namespace=*/ packageName, id, SCHEMA_TYPE); } /** @@ -571,16 +570,6 @@ public class AppSearchShortcutInfo extends GenericDocument { return this; } - /** - * @hide - */ - public Builder setPackageName(@Nullable final String packageName) { - if (!TextUtils.isEmpty(packageName)) { - setNamespace(packageName); - } - return this; - } - /** * @hide */ diff --git a/core/tests/coretests/src/android/app/appsearch/AppSearchSessionUnitTest.java b/core/tests/coretests/src/android/app/appsearch/AppSearchSessionUnitTest.java index 6d9e2ea5acabc..56c685afa0268 100644 --- a/core/tests/coretests/src/android/app/appsearch/AppSearchSessionUnitTest.java +++ b/core/tests/coretests/src/android/app/appsearch/AppSearchSessionUnitTest.java @@ -42,8 +42,8 @@ public class AppSearchSessionUnitTest { public void setUp() throws Exception { // Remove all documents from any instances that may have been created in the tests. Objects.requireNonNull(mAppSearch); - AppSearchManager.SearchContext searchContext = new AppSearchManager.SearchContext.Builder() - .setDatabaseName("testDb").build(); + AppSearchManager.SearchContext searchContext = + new AppSearchManager.SearchContext.Builder("testDb").build(); CompletableFuture> future = new CompletableFuture<>(); mAppSearch.createSearchSession(searchContext, mExecutor, future::complete); mSearchSession = future.get().getResultValue(); diff --git a/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java b/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java index ffe93bc99cf5a..21eb44ad113a3 100644 --- a/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java +++ b/core/tests/coretests/src/android/content/pm/AppSearchShortcutInfoTest.java @@ -45,7 +45,7 @@ public class AppSearchShortcutInfoTest { final Set categorySet = new ArraySet<>(); categorySet.add(category); final Intent shortcutIntent = new Intent(Intent.ACTION_VIEW); - final ShortcutInfo shortcut = new AppSearchShortcutInfo.Builder(id) + final ShortcutInfo shortcut = new AppSearchShortcutInfo.Builder(/*packageName=*/"", id) .setActivity(activity) .setLongLabel(id) .setIconResName(shortcutIconResName) diff --git a/services/core/java/com/android/server/pm/ShortcutPackage.java b/services/core/java/com/android/server/pm/ShortcutPackage.java index 8c3c42374acb2..884c59d9d3a4b 100644 --- a/services/core/java/com/android/server/pm/ShortcutPackage.java +++ b/services/core/java/com/android/server/pm/ShortcutPackage.java @@ -2347,7 +2347,7 @@ class ShortcutPackage extends ShortcutPackageItem { } final List page = new ArrayList<>(results.size()); for (SearchResult result : results) { - final ShortcutInfo si = new AppSearchShortcutInfo(result.getDocument()) + final ShortcutInfo si = new AppSearchShortcutInfo(result.getGenericDocument()) .toShortcutInfo(mShortcutUser.getUserId()); page.add(si); } @@ -2398,8 +2398,7 @@ class ShortcutPackage extends ShortcutPackageItem { @NonNull final Function> cb) { final long callingIdentity = Binder.clearCallingIdentity(); final AppSearchManager.SearchContext searchContext = - new AppSearchManager.SearchContext.Builder() - .setDatabaseName(getPackageName()).build(); + new AppSearchManager.SearchContext.Builder(getPackageName()).build(); final AppSearchSession session; try { session = ConcurrentUtils.waitForFutureNoInterrupt( @@ -2427,7 +2426,8 @@ class ShortcutPackage extends ShortcutPackageItem { AppSearchShortcutInfo.SCHEMA_TYPE, true, pi); } final AndroidFuture future = new AndroidFuture<>(); - session.setSchema(schemaBuilder.build(), mShortcutUser.mExecutor, result -> { + session.setSchema( + schemaBuilder.build(), mShortcutUser.mExecutor, mShortcutUser.mExecutor, result -> { if (!result.isSuccess()) { future.completeExceptionally( new IllegalArgumentException(result.getErrorMessage())); diff --git a/services/tests/servicestests/src/com/android/server/appsearch/AppSearchImplPlatformTest.java b/services/tests/servicestests/src/com/android/server/appsearch/AppSearchImplPlatformTest.java index f3ee2332906f3..4240581bc5049 100644 --- a/services/tests/servicestests/src/com/android/server/appsearch/AppSearchImplPlatformTest.java +++ b/services/tests/servicestests/src/com/android/server/appsearch/AppSearchImplPlatformTest.java @@ -104,12 +104,12 @@ public class AppSearchImplPlatformTest { // Insert package1 document GenericDocument document1 = - new GenericDocument.Builder<>("uri", "schema1").setNamespace("namespace").build(); + new GenericDocument.Builder<>("namespace", "uri", "schema1").build(); mAppSearchImpl.putDocument("package1", "database1", document1, /*logger=*/ null); // Insert package2 document GenericDocument document2 = - new GenericDocument.Builder<>("uri", "schema2").setNamespace("namespace").build(); + new GenericDocument.Builder<>("namespace", "uri", "schema2").build(); mAppSearchImpl.putDocument("package2", "database2", document2, /*logger=*/ null); // No query filters specified, global query can retrieve all documents. @@ -122,8 +122,8 @@ public class AppSearchImplPlatformTest { // Document2 will be first since it got indexed later and has a "better", aka more recent // score. - assertThat(searchResultPage.getResults().get(0).getDocument()).isEqualTo(document2); - assertThat(searchResultPage.getResults().get(1).getDocument()).isEqualTo(document1); + assertThat(searchResultPage.getResults().get(0).getGenericDocument()).isEqualTo(document2); + assertThat(searchResultPage.getResults().get(1).getGenericDocument()).isEqualTo(document1); } /** @@ -158,12 +158,12 @@ public class AppSearchImplPlatformTest { // Insert package1 document GenericDocument document1 = - new GenericDocument.Builder<>("uri", "schema1").setNamespace("namespace").build(); + new GenericDocument.Builder<>("namespace", "uri", "schema1").build(); mAppSearchImpl.putDocument("package1", "database1", document1, /*logger=*/ null); // Insert package2 document GenericDocument document2 = - new GenericDocument.Builder<>("uri", "schema2").setNamespace("namespace").build(); + new GenericDocument.Builder<>("namespace", "uri", "schema2").build(); mAppSearchImpl.putDocument("package2", "database2", document2, /*logger=*/ null); // "package1" filter specified @@ -176,7 +176,7 @@ public class AppSearchImplPlatformTest { mAppSearchImpl.globalQuery( "", searchSpec, mContext.getPackageName(), mGlobalQuerierUid); assertThat(searchResultPage.getResults()).hasSize(1); - assertThat(searchResultPage.getResults().get(0).getDocument()).isEqualTo(document1); + assertThat(searchResultPage.getResults().get(0).getGenericDocument()).isEqualTo(document1); // "package2" filter specified searchSpec = @@ -188,7 +188,7 @@ public class AppSearchImplPlatformTest { mAppSearchImpl.globalQuery( "", searchSpec, mContext.getPackageName(), mGlobalQuerierUid); assertThat(searchResultPage.getResults()).hasSize(1); - assertThat(searchResultPage.getResults().get(0).getDocument()).isEqualTo(document2); + assertThat(searchResultPage.getResults().get(0).getGenericDocument()).isEqualTo(document2); } @Test