Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b477d231 authored by Alexander Dorokhine's avatar Alexander Dorokhine Committed by Automerger Merge Worker
Browse files

Merge "Remove deprecated methods from AppSearch APIs." into sc-dev am: 30ccdcd6

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13880672

Change-Id: Ic824bd043b7814898dd5e25048a67d640448ee73
parents 90545428 30ccdcd6
Loading
Loading
Loading
Loading
+1 −20
Original line number Diff line number Diff line
@@ -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);
  }

+1 −44
Original line number Diff line number Diff line
@@ -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() {
+0 −12
Original line number Diff line number Diff line
@@ -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.
+0 −18
Original line number Diff line number Diff line
@@ -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.
         *
+0 −67
Original line number Diff line number Diff line
@@ -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}.
         *
Loading