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

Commit 51a8c6b2 authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Update framework from jetpack." into sc-dev am: 4e229f44 am:...

Merge "Merge "Update framework from jetpack." into sc-dev am: 4e229f44 am: 2ec2f838 am: 2cb4d32c"
parents 562114cb 816dde1e
Loading
Loading
Loading
Loading
+5 −30
Original line number Diff line number Diff line
@@ -50,9 +50,6 @@ import java.util.Set;
public class GenericDocument {
    private static final String TAG = "AppSearchGenericDocumen";

    /** The maximum number of elements in a repeatable field. */
    private static final int MAX_REPEATED_PROPERTY_LENGTH = 100;

    /** The maximum {@link String#length} of a {@link String} field. */
    private static final int MAX_STRING_LENGTH = 20_000;

@@ -1187,8 +1184,8 @@ public class GenericDocument {
         * @param name the name associated with the {@code values}. Must match the name for this
         *     property as given in {@link AppSearchSchema.PropertyConfig#getName}.
         * @param values the {@code String} values of the property.
         * @throws IllegalArgumentException if no values are provided, if provided values exceed
         *     maximum repeated property length, or if a passed in {@code String} is {@code null}.
         * @throws IllegalArgumentException if no values are provided, or if a passed in {@code
         *     String} is {@code null}.
         */
        @NonNull
        public BuilderType setPropertyString(@NonNull String name, @NonNull String... values) {
@@ -1206,7 +1203,6 @@ public class GenericDocument {
         * @param name the name associated with the {@code values}. Must match the name for this
         *     property as given in {@link AppSearchSchema.PropertyConfig#getName}.
         * @param values the {@code boolean} values of the property.
         * @throws IllegalArgumentException if values exceed maximum repeated property length.
         */
        @NonNull
        public BuilderType setPropertyBoolean(@NonNull String name, @NonNull boolean... values) {
@@ -1223,7 +1219,6 @@ public class GenericDocument {
         * @param name the name associated with the {@code values}. Must match the name for this
         *     property as given in {@link AppSearchSchema.PropertyConfig#getName}.
         * @param values the {@code long} values of the property.
         * @throws IllegalArgumentException if values exceed maximum repeated property length.
         */
        @NonNull
        public BuilderType setPropertyLong(@NonNull String name, @NonNull long... values) {
@@ -1240,7 +1235,6 @@ public class GenericDocument {
         * @param name the name associated with the {@code values}. Must match the name for this
         *     property as given in {@link AppSearchSchema.PropertyConfig#getName}.
         * @param values the {@code double} values of the property.
         * @throws IllegalArgumentException if values exceed maximum repeated property length.
         */
        @NonNull
        public BuilderType setPropertyDouble(@NonNull String name, @NonNull double... values) {
@@ -1257,8 +1251,8 @@ public class GenericDocument {
         * @param name the name associated with the {@code values}. Must match the name for this
         *     property as given in {@link AppSearchSchema.PropertyConfig#getName}.
         * @param values the {@code byte[]} of the property.
         * @throws IllegalArgumentException if no values are provided, if provided values exceed
         *     maximum repeated property length, or if a passed in {@code byte[]} is {@code null}.
         * @throws IllegalArgumentException if no values are provided, or if a passed in {@code
         *     byte[]} is {@code null}.
         */
        @NonNull
        public BuilderType setPropertyBytes(@NonNull String name, @NonNull byte[]... values) {
@@ -1276,8 +1270,7 @@ public class GenericDocument {
         * @param name the name associated with the {@code values}. Must match the name for this
         *     property as given in {@link AppSearchSchema.PropertyConfig#getName}.
         * @param values the {@link GenericDocument} values of the property.
         * @throws IllegalArgumentException if no values are provided, if provided values exceed if
         *     provided values exceed maximum repeated property length, or if a passed in {@link
         * @throws IllegalArgumentException if no values are provided, or if a passed in {@link
         *     GenericDocument} is {@code null}.
         */
        @NonNull
@@ -1308,7 +1301,6 @@ public class GenericDocument {

        private void putInPropertyBundle(@NonNull String name, @NonNull String[] values)
                throws IllegalArgumentException {
            validateRepeatedPropertyLength(name, values.length);
            for (int i = 0; i < values.length; i++) {
                if (values[i] == null) {
                    throw new IllegalArgumentException("The String at " + i + " is null.");
@@ -1327,17 +1319,14 @@ public class GenericDocument {
        }

        private void putInPropertyBundle(@NonNull String name, @NonNull boolean[] values) {
            validateRepeatedPropertyLength(name, values.length);
            mProperties.putBooleanArray(name, values);
        }

        private void putInPropertyBundle(@NonNull String name, @NonNull double[] values) {
            validateRepeatedPropertyLength(name, values.length);
            mProperties.putDoubleArray(name, values);
        }

        private void putInPropertyBundle(@NonNull String name, @NonNull long[] values) {
            validateRepeatedPropertyLength(name, values.length);
            mProperties.putLongArray(name, values);
        }

@@ -1348,7 +1337,6 @@ public class GenericDocument {
         * into ArrayList<Bundle>, and each elements will contain a one dimension byte[].
         */
        private void putInPropertyBundle(@NonNull String name, @NonNull byte[][] values) {
            validateRepeatedPropertyLength(name, values.length);
            ArrayList<Bundle> bundles = new ArrayList<>(values.length);
            for (int i = 0; i < values.length; i++) {
                if (values[i] == null) {
@@ -1362,7 +1350,6 @@ public class GenericDocument {
        }

        private void putInPropertyBundle(@NonNull String name, @NonNull GenericDocument[] values) {
            validateRepeatedPropertyLength(name, values.length);
            Parcelable[] documentBundles = new Parcelable[values.length];
            for (int i = 0; i < values.length; i++) {
                if (values[i] == null) {
@@ -1373,18 +1360,6 @@ public class GenericDocument {
            mProperties.putParcelableArray(name, documentBundles);
        }

        private static void validateRepeatedPropertyLength(@NonNull String name, int length) {
            if (length > MAX_REPEATED_PROPERTY_LENGTH) {
                throw new IllegalArgumentException(
                        "Repeated property \""
                                + name
                                + "\" has length "
                                + length
                                + ", which exceeds the limit of "
                                + MAX_REPEATED_PROPERTY_LENGTH);
            }
        }

        /** Builds the {@link GenericDocument} object. */
        @NonNull
        public GenericDocument build() {
+9 −2
Original line number Diff line number Diff line
@@ -169,13 +169,14 @@ public final class SetSchemaRequest {

    /** Builder for {@link SetSchemaRequest} objects. */
    public static final class Builder {
        private static final int DEFAULT_VERSION = 1;
        private ArraySet<AppSearchSchema> mSchemas = new ArraySet<>();
        private ArraySet<String> mSchemasNotDisplayedBySystem = new ArraySet<>();
        private ArrayMap<String, Set<PackageIdentifier>> mSchemasVisibleToPackages =
                new ArrayMap<>();
        private ArrayMap<String, Migrator> mMigrators = new ArrayMap<>();
        private boolean mForceOverride = false;
        private int mVersion = 1;
        private int mVersion = DEFAULT_VERSION;
        private boolean mBuilt = false;

        /**
@@ -384,6 +385,9 @@ public final class SetSchemaRequest {
         * <p>The version number can stay the same, increase, or decrease relative to the current
         * version number that is already stored in the {@link AppSearchSession} database.
         *
         * <p>The version of an empty database will always be 0. You cannot set version to the
         * {@link SetSchemaRequest}, if it doesn't contains any {@link AppSearchSchema}.
         *
         * @param version A positive integer representing the version of the entire set of schemas
         *     represents the version of the whole schema in the {@link AppSearchSession} database,
         *     default version is 1.
@@ -423,7 +427,10 @@ public final class SetSchemaRequest {
                throw new IllegalArgumentException(
                        "Schema types " + referencedSchemas + " referenced, but were not added.");
            }

            if (mSchemas.isEmpty() && mVersion != DEFAULT_VERSION) {
                throw new IllegalArgumentException(
                        "Cannot set version to the request if schema is empty.");
            }
            mBuilt = true;
            return new SetSchemaRequest(
                    mSchemas,
+1 −1
Original line number Diff line number Diff line
@@ -60,8 +60,8 @@ import com.android.internal.annotations.GuardedBy;
import com.android.server.LocalManagerRegistry;
import com.android.server.SystemService;
import com.android.server.appsearch.external.localstorage.stats.CallStats;
import com.android.server.appsearch.external.localstorage.visibilitystore.VisibilityStore;
import com.android.server.appsearch.util.PackageUtil;
import com.android.server.appsearch.visibilitystore.VisibilityStore;
import com.android.server.usage.StorageStatsManagerLocal;
import com.android.server.usage.StorageStatsManagerLocal.StorageStatsAugmenter;

+4 −4
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ import android.annotation.NonNull;

import com.android.server.appsearch.external.localstorage.AppSearchImpl;
import com.android.server.appsearch.stats.PlatformLogger;
import com.android.server.appsearch.visibilitystore.VisibilityStore;
import com.android.server.appsearch.visibilitystore.VisibilityStoreImpl;

import java.util.Objects;

@@ -30,12 +30,12 @@ import java.util.Objects;
public final class AppSearchUserInstance {
    private final PlatformLogger mLogger;
    private final AppSearchImpl mAppSearchImpl;
    private final VisibilityStore mVisibilityStore;
    private final VisibilityStoreImpl mVisibilityStore;

    AppSearchUserInstance(
            @NonNull PlatformLogger logger,
            @NonNull AppSearchImpl appSearchImpl,
            @NonNull VisibilityStore visibilityStore) {
            @NonNull VisibilityStoreImpl visibilityStore) {
        mLogger = Objects.requireNonNull(logger);
        mAppSearchImpl = Objects.requireNonNull(appSearchImpl);
        mVisibilityStore = Objects.requireNonNull(visibilityStore);
@@ -52,7 +52,7 @@ public final class AppSearchUserInstance {
    }

    @NonNull
    public VisibilityStore getVisibilityStore() {
    public VisibilityStoreImpl getVisibilityStore() {
        return mVisibilityStore;
    }
}
+3 −2
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ import com.android.server.appsearch.external.localstorage.AppSearchImpl;
import com.android.server.appsearch.external.localstorage.FrameworkOptimizeStrategy;
import com.android.server.appsearch.external.localstorage.stats.InitializeStats;
import com.android.server.appsearch.stats.PlatformLogger;
import com.android.server.appsearch.visibilitystore.VisibilityStore;
import com.android.server.appsearch.visibilitystore.VisibilityStoreImpl;

import java.io.File;
import java.util.Map;
@@ -178,7 +178,8 @@ public final class AppSearchUserInstanceManager {
                AppSearchImpl.create(icingDir, initStatsBuilder, new FrameworkOptimizeStrategy());

        long prepareVisibilityStoreLatencyStartMillis = SystemClock.elapsedRealtime();
        VisibilityStore visibilityStore = VisibilityStore.create(appSearchImpl, userContext);
        VisibilityStoreImpl visibilityStore =
                VisibilityStoreImpl.create(appSearchImpl, userContext);
        long prepareVisibilityStoreLatencyEndMillis = SystemClock.elapsedRealtime();

        initStatsBuilder
Loading