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

Commit 9b8f383d authored by Alexander Dorokhine's avatar Alexander Dorokhine Committed by Android (Google) Code Review
Browse files

Merge changes from topic "sync-2021-01-05"

* changes:
  Unhide APIs in Framework that were already unhidden in Jetpack.
  Sync Framework from Jetpack.
parents 77ed525b 98abb2ec
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ package android.app.appsearch {
    method public long getCreationTimestampMillis();
    method public static int getMaxIndexedProperties();
    method @NonNull public String getNamespace();
    method @Nullable public Object getProperty(@NonNull String);
    method public boolean getPropertyBoolean(@NonNull String);
    method @Nullable public boolean[] getPropertyBooleanArray(@NonNull String);
    method @Nullable public byte[] getPropertyBytes(@NonNull String);
@@ -148,6 +149,12 @@ package android.app.appsearch {
    method @NonNull public android.app.appsearch.GetByUriRequest.Builder setNamespace(@NonNull String);
  }

  public class PackageIdentifier {
    ctor public PackageIdentifier(@NonNull String, @NonNull byte[]);
    method @NonNull public String getPackageName();
    method @NonNull public byte[] getSha256Certificate();
  }

  public final class PutDocumentsRequest {
    method @NonNull public java.util.List<android.app.appsearch.GenericDocument> getDocuments();
  }
@@ -233,6 +240,8 @@ package android.app.appsearch {

  public final class SetSchemaRequest {
    method @NonNull public java.util.Set<android.app.appsearch.AppSearchSchema> getSchemas();
    method @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 public boolean isForceOverride();
  }

@@ -242,6 +251,17 @@ package android.app.appsearch {
    method @NonNull public android.app.appsearch.SetSchemaRequest.Builder addSchema(@NonNull java.util.Collection<android.app.appsearch.AppSearchSchema>);
    method @NonNull public android.app.appsearch.SetSchemaRequest build();
    method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setForceOverride(boolean);
    method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeVisibilityForPackage(@NonNull String, boolean, @NonNull android.app.appsearch.PackageIdentifier);
    method @NonNull public android.app.appsearch.SetSchemaRequest.Builder setSchemaTypeVisibilityForSystemUi(@NonNull String, boolean);
  }

}

package android.app.appsearch.exceptions {

  public class AppSearchException extends java.lang.Exception {
    method public int getResultCode();
    method @NonNull public <T> android.app.appsearch.AppSearchResult<T> toAppSearchResult();
  }

}
+19 −4
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.app.appsearch.exceptions.AppSearchException;
import android.app.appsearch.util.BundleUtil;
import android.os.Bundle;
import android.util.Log;
@@ -92,9 +91,7 @@ public class GenericDocument {
    /** Contains {@link GenericDocument} basic information (uri, schemaType etc). */
    @NonNull final Bundle mBundle;

    /**
     * Contains all properties in {@link GenericDocument} to support getting properties via keys.
     */
    /** Contains all properties in {@link GenericDocument} to support getting properties via keys */
    @NonNull private final Bundle mProperties;

    @NonNull private final String mUri;
@@ -201,6 +198,24 @@ public class GenericDocument {
        return Collections.unmodifiableSet(mProperties.keySet());
    }

    /**
     * Retrieves the property value with the given key as {@link Object}.
     *
     * @param key The key to look for.
     * @return The entry with the given key as an object or {@code null} if there is no such key.
     */
    @Nullable
    public Object getProperty(@NonNull String key) {
        Preconditions.checkNotNull(key);
        Object property = mProperties.get(key);
        if (property instanceof ArrayList) {
            return getPropertyBytesArray(key);
        } else if (property instanceof Bundle[]) {
            return getPropertyDocumentArray(key);
        }
        return property;
    }

    /**
     * Retrieves a {@link String} value by key.
     *
+1 −4
Original line number Diff line number Diff line
@@ -23,10 +23,7 @@ import com.android.internal.util.Preconditions;
import java.util.Arrays;
import java.util.Objects;

/**
 * This class represents a uniquely identifiable package.
 * @hide
 */
/** This class represents a uniquely identifiable package. */
public class PackageIdentifier {
    private final String mPackageName;
    private final byte[] mSha256Certificate;
+0 −1
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package android.app.appsearch;

import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.app.appsearch.exceptions.AppSearchException;

import com.android.internal.util.Preconditions;

+22 −18
Original line number Diff line number Diff line
@@ -49,31 +49,20 @@ public final class SearchResult {
    /** @hide */
    public static final String MATCHES_FIELD = "matches";

    @NonNull private final Bundle mBundle;
    /** @hide */
    public static final String PACKAGE_NAME_FIELD = "packageName";

    @NonNull private final Bundle mDocumentBundle;
    @NonNull private final Bundle mBundle;

    /** Cache of the inflated document. Comes from inflating mDocumentBundle at first use. */
    @Nullable private GenericDocument mDocument;

    /**
     * Contains a list of MatchInfo bundles that matched the request.
     *
     * <p>Only populated when requested in both {@link SearchSpec.Builder#setSnippetCount} and
     * {@link SearchSpec.Builder#setSnippetCountPerProperty}.
     *
     * @see #getMatches()
     */
    @NonNull private final List<Bundle> mMatchBundles;

    /** Cache of the inflated matches. Comes from inflating mMatchBundles at first use. */
    @Nullable private List<MatchInfo> mMatches;

    /** @hide */
    public SearchResult(@NonNull Bundle bundle) {
        mBundle = Preconditions.checkNotNull(bundle);
        mDocumentBundle = Preconditions.checkNotNull(bundle.getBundle(DOCUMENT_FIELD));
        mMatchBundles = Preconditions.checkNotNull(bundle.getParcelableArrayList(MATCHES_FIELD));
    }

    /** @hide */
@@ -90,7 +79,9 @@ public final class SearchResult {
    @NonNull
    public GenericDocument getDocument() {
        if (mDocument == null) {
            mDocument = new GenericDocument(mDocumentBundle);
            mDocument =
                    new GenericDocument(
                            Preconditions.checkNotNull(mBundle.getBundle(DOCUMENT_FIELD)));
        }
        return mDocument;
    }
@@ -106,15 +97,28 @@ public final class SearchResult {
    @NonNull
    public List<MatchInfo> getMatches() {
        if (mMatches == null) {
            mMatches = new ArrayList<>(mMatchBundles.size());
            for (int i = 0; i < mMatchBundles.size(); i++) {
                MatchInfo matchInfo = new MatchInfo(getDocument(), mMatchBundles.get(i));
            List<Bundle> matchBundles =
                    Preconditions.checkNotNull(mBundle.getParcelableArrayList(MATCHES_FIELD));
            mMatches = new ArrayList<>(matchBundles.size());
            for (int i = 0; i < matchBundles.size(); i++) {
                MatchInfo matchInfo = new MatchInfo(getDocument(), matchBundles.get(i));
                mMatches.add(matchInfo);
            }
        }
        return mMatches;
    }

    /**
     * Contains the package name that stored the {@link GenericDocument}.
     *
     * @return Package name that stored the document
     * @hide
     */
    @NonNull
    public String getPackageName() {
        return Preconditions.checkNotNull(mBundle.getString(PACKAGE_NAME_FIELD));
    }

    /**
     * This class represents a match objects for any Snippets that might be present in {@link
     * SearchResults} from query. Using this class user can get the full text, exact matches and
Loading