Merge "Remove deprecated methods from AppSearch APIs." into sc-dev

This commit is contained in:
Alexander Dorokhine
2021-03-25 05:34:38 +00:00
committed by Android (Google) Code Review
18 changed files with 53 additions and 367 deletions

View File

@@ -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<ValueType> {
@@ -53,7 +51,6 @@ package android.app.appsearch {
public final class AppSearchSchema {
method @NonNull public java.util.List<android.app.appsearch.AppSearchSchema.PropertyConfig> 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<android.app.appsearch.AppSearchResult<java.lang.Void>>);
method public void reportUsage(@NonNull android.app.appsearch.ReportUsageRequest, @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);
method @Deprecated public void setSchema(@NonNull android.app.appsearch.SetSchemaRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.SetSchemaResponse>>);
method public void setSchema(@NonNull android.app.appsearch.SetSchemaRequest, @NonNull java.util.concurrent.Executor, @NonNull java.util.concurrent.Executor, @NonNull java.util.function.Consumer<android.app.appsearch.AppSearchResult<android.app.appsearch.SetSchemaResponse>>);
}
@@ -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<BuilderType extends android.app.appsearch.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<java.lang.String>);
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<java.lang.String>);
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<android.app.appsearch.AppSearchSchema> {
public class GetSchemaResponse {
method @NonNull public java.util.Set<android.app.appsearch.AppSearchSchema> 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<java.lang.String>);
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<android.app.appsearch.SearchResult.MatchInfo> 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<java.lang.String,android.app.appsearch.Migrator> getMigrators();
method @NonNull public java.util.Set<android.app.appsearch.AppSearchSchema> getSchemas();
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();
@@ -421,7 +403,6 @@ package android.app.appsearch {
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);
}

View File

@@ -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}.
*
* <p>{@link AppSearchSession} will create or open a database under the given name.
*
* <p>Databases with different names are fully separate with distinct types, namespaces,
* and data.
*
* <p>Database name cannot contain {@code '/'}.
*
* <p>If not specified, defaults to the empty string.
*
* <p>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() {

View File

@@ -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<AppSearchResult<SetSchemaResponse>> callback) {
setSchema(request, callbackExecutor, callbackExecutor, callback);
}
/**
* Sets the schema that represents the organizational structure of data within the AppSearch
* database.

View File

@@ -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.
*

View File

@@ -46,15 +46,6 @@ import java.util.Set;
public class GenericDocument {
private static final String TAG = "AppSearchGenericDocumen";
/**
* The default empty namespace.
*
* <p>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}.
*
* <p>Once {@link #build} is called, the instance can no longer be used.
*
* <p>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.
*
* <p>URIs are unique within a namespace.
*
* <p>The number of namespaces per app should be kept small for efficiency reasons.
*
* <p>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}.
*

View File

@@ -107,48 +107,16 @@ public final class GetByUriRequest {
* <p>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<String> mUris = new ArraySet<>();
private final Map<String, List<String>> 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.
*
* <p>If this is not called, the namespace defaults to an empty string.
*
* <p>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.
*

View File

@@ -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<AppSearchSchema> {
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<AppSearchSchema> getSchemasFromBundle(Bundle bundle) {
ArrayList<Bundle> schemaBundles = bundle.getParcelableArrayList(SCHEMAS_FIELD);
Set<AppSearchSchema> 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<AppSearchSchema> {
/**
* Return the schemas most recently successfully provided to {@link AppSearchSession#setSchema}.
*
* <p>It is inefficient to call this method repeatedly.
*/
@NonNull
public Set<AppSearchSchema> getSchemas() {
return this;
ArrayList<Bundle> schemaBundles = mBundle.getParcelableArrayList(SCHEMAS_FIELD);
Set<AppSearchSchema> 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. */

View File

@@ -59,47 +59,15 @@ public final class RemoveByUriRequest {
* <p>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<String> 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.
*
* <p>If this is not set, it defaults to an empty string.
*
* <p>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.
*

View File

@@ -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.
*
* <p>If this is not set, it defaults to an empty string.
*
* <p>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.
*

View File

@@ -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 {
* <ul>
* <li>{@link SearchSpec#RANKING_STRATEGY_NONE} - this value will be 0
* <li>{@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()}
* <li>{@link SearchSpec#RANKING_STRATEGY_CREATION_TIMESTAMP} - the value returned by calling
* {@link GenericDocument#getCreationTimestampMillis()} on the document returned by {@link
* #getDocument()}
* #getGenericDocument()}
* <li>{@link SearchSpec#RANKING_STRATEGY_RELEVANCE_SCORE} - an arbitrary double value where a
* higher value means more relevant
* <li>{@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()}
* <li>{@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()}
* </ul>
*
* @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.
*

View File

@@ -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<String> 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.

View File

@@ -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<String, List<PackageIdentifier>> 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()));

View File

@@ -107,7 +107,7 @@ public class AppSearchPerson extends GenericDocument {
public static class Builder extends GenericDocument.Builder<Builder> {
public Builder(@NonNull final String id) {
super(id, SCHEMA_TYPE);
super(/*namespace=*/ "", id, SCHEMA_TYPE);
}
/** @hide */

View File

@@ -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<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
*/

View File

@@ -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<AppSearchResult<AppSearchSession>> future = new CompletableFuture<>();
mAppSearch.createSearchSession(searchContext, mExecutor, future::complete);
mSearchSession = future.get().getResultValue();

View File

@@ -45,7 +45,7 @@ public class AppSearchShortcutInfoTest {
final Set<String> 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)

View File

@@ -2347,7 +2347,7 @@ class ShortcutPackage extends ShortcutPackageItem {
}
final List<ShortcutInfo> 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<AppSearchSession, CompletableFuture<T>> 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<AppSearchSession> 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()));

View File

@@ -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