Loading apex/appsearch/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ apex { key: "com.android.appsearch.key", certificate: ":com.android.appsearch.certificate", updatable: false, jni_libs: ["libicing"], generate_hashtree: false, } Loading apex/appsearch/service/Android.bp +0 −3 Original line number Diff line number Diff line Loading @@ -53,9 +53,6 @@ java_library { "framework-appsearch.impl", "unsupportedappusage", // TODO(b/181887768) should be removed ], required: [ "libicing", ], defaults: ["framework-system-server-module-defaults"], permitted_packages: [ "com.android.server.appsearch", Loading apex/appsearch/service/java/com/android/server/appsearch/AppSearchConfig.java +44 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,11 @@ public final class AppSearchConfig implements AutoCloseable { @VisibleForTesting static final int DEFAULT_SAMPLING_INTERVAL = 10; @VisibleForTesting static final int DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES = 512 * 1024; // 512KiB @VisibleForTesting static final int DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_COUNT = 20_000; /* * Keys for ALL the flags stored in DeviceConfig. */ Loading @@ -70,13 +75,19 @@ public final class AppSearchConfig implements AutoCloseable { "sampling_interval_for_batch_call_stats"; public static final String KEY_SAMPLING_INTERVAL_FOR_PUT_DOCUMENT_STATS = "sampling_interval_for_put_document_stats"; public static final String KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES = "limit_config_max_document_size_bytes"; public static final String KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT = "limit_config_max_document_docunt"; // Array contains all the corresponding keys for the cached values. private static final String[] KEYS_TO_ALL_CACHED_VALUES = { KEY_MIN_TIME_INTERVAL_BETWEEN_SAMPLES_MILLIS, KEY_SAMPLING_INTERVAL_DEFAULT, KEY_SAMPLING_INTERVAL_FOR_BATCH_CALL_STATS, KEY_SAMPLING_INTERVAL_FOR_PUT_DOCUMENT_STATS KEY_SAMPLING_INTERVAL_FOR_PUT_DOCUMENT_STATS, KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES, KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT, }; // Lock needed for all the operations in this class. Loading Loading @@ -222,6 +233,24 @@ public final class AppSearchConfig implements AutoCloseable { } } /** Returns the maximum serialized size an indexed document can be, in bytes. */ public int getCachedLimitConfigMaxDocumentSizeBytes() { synchronized (mLock) { throwIfClosedLocked(); return mBundleLocked.getInt(KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES); } } /** Returns the maximum number of active docs allowed per package. */ public int getCachedLimitConfigMaxDocumentCount() { synchronized (mLock) { throwIfClosedLocked(); return mBundleLocked.getInt(KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_COUNT); } } @GuardedBy("mLock") private void throwIfClosedLocked() { if (mIsClosedLocked) { Loading Loading @@ -264,6 +293,20 @@ public final class AppSearchConfig implements AutoCloseable { mBundleLocked.putInt(key, properties.getInt(key, DEFAULT_SAMPLING_INTERVAL)); } break; case KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES: synchronized (mLock) { mBundleLocked.putInt( key, properties.getInt(key, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES)); } break; case KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT: synchronized (mLock) { mBundleLocked.putInt( key, properties.getInt(key, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_COUNT)); } break; default: break; } Loading apex/appsearch/service/java/com/android/server/appsearch/AppSearchUserInstanceManager.java +5 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,11 @@ public final class AppSearchUserInstanceManager { File appSearchDir = getAppSearchDir(userHandle); File icingDir = new File(appSearchDir, "icing"); Log.i(TAG, "Creating new AppSearch instance at: " + icingDir); AppSearchImpl appSearchImpl = AppSearchImpl.create(icingDir, initStatsBuilder, new FrameworkOptimizeStrategy()); AppSearchImpl appSearchImpl = AppSearchImpl.create( icingDir, new FrameworkLimitConfig(config), initStatsBuilder, new FrameworkOptimizeStrategy()); long prepareVisibilityStoreLatencyStartMillis = SystemClock.elapsedRealtime(); VisibilityStoreImpl visibilityStore = Loading apex/appsearch/service/java/com/android/server/appsearch/FrameworkLimitConfig.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appsearch; import android.annotation.NonNull; import com.android.server.appsearch.external.localstorage.LimitConfig; import java.util.Objects; class FrameworkLimitConfig implements LimitConfig { private final AppSearchConfig mAppSearchConfig; FrameworkLimitConfig(@NonNull AppSearchConfig appSearchConfig) { mAppSearchConfig = Objects.requireNonNull(appSearchConfig); } @Override public int getMaxDocumentSizeBytes() { return mAppSearchConfig.getCachedLimitConfigMaxDocumentSizeBytes(); } @Override public int getMaxDocumentCount() { return mAppSearchConfig.getCachedLimitConfigMaxDocumentCount(); } } Loading
apex/appsearch/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -29,6 +29,7 @@ apex { key: "com.android.appsearch.key", certificate: ":com.android.appsearch.certificate", updatable: false, jni_libs: ["libicing"], generate_hashtree: false, } Loading
apex/appsearch/service/Android.bp +0 −3 Original line number Diff line number Diff line Loading @@ -53,9 +53,6 @@ java_library { "framework-appsearch.impl", "unsupportedappusage", // TODO(b/181887768) should be removed ], required: [ "libicing", ], defaults: ["framework-system-server-module-defaults"], permitted_packages: [ "com.android.server.appsearch", Loading
apex/appsearch/service/java/com/android/server/appsearch/AppSearchConfig.java +44 −1 Original line number Diff line number Diff line Loading @@ -60,6 +60,11 @@ public final class AppSearchConfig implements AutoCloseable { @VisibleForTesting static final int DEFAULT_SAMPLING_INTERVAL = 10; @VisibleForTesting static final int DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES = 512 * 1024; // 512KiB @VisibleForTesting static final int DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_COUNT = 20_000; /* * Keys for ALL the flags stored in DeviceConfig. */ Loading @@ -70,13 +75,19 @@ public final class AppSearchConfig implements AutoCloseable { "sampling_interval_for_batch_call_stats"; public static final String KEY_SAMPLING_INTERVAL_FOR_PUT_DOCUMENT_STATS = "sampling_interval_for_put_document_stats"; public static final String KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES = "limit_config_max_document_size_bytes"; public static final String KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT = "limit_config_max_document_docunt"; // Array contains all the corresponding keys for the cached values. private static final String[] KEYS_TO_ALL_CACHED_VALUES = { KEY_MIN_TIME_INTERVAL_BETWEEN_SAMPLES_MILLIS, KEY_SAMPLING_INTERVAL_DEFAULT, KEY_SAMPLING_INTERVAL_FOR_BATCH_CALL_STATS, KEY_SAMPLING_INTERVAL_FOR_PUT_DOCUMENT_STATS KEY_SAMPLING_INTERVAL_FOR_PUT_DOCUMENT_STATS, KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES, KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT, }; // Lock needed for all the operations in this class. Loading Loading @@ -222,6 +233,24 @@ public final class AppSearchConfig implements AutoCloseable { } } /** Returns the maximum serialized size an indexed document can be, in bytes. */ public int getCachedLimitConfigMaxDocumentSizeBytes() { synchronized (mLock) { throwIfClosedLocked(); return mBundleLocked.getInt(KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES); } } /** Returns the maximum number of active docs allowed per package. */ public int getCachedLimitConfigMaxDocumentCount() { synchronized (mLock) { throwIfClosedLocked(); return mBundleLocked.getInt(KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_COUNT); } } @GuardedBy("mLock") private void throwIfClosedLocked() { if (mIsClosedLocked) { Loading Loading @@ -264,6 +293,20 @@ public final class AppSearchConfig implements AutoCloseable { mBundleLocked.putInt(key, properties.getInt(key, DEFAULT_SAMPLING_INTERVAL)); } break; case KEY_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES: synchronized (mLock) { mBundleLocked.putInt( key, properties.getInt(key, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_SIZE_BYTES)); } break; case KEY_LIMIT_CONFIG_MAX_DOCUMENT_COUNT: synchronized (mLock) { mBundleLocked.putInt( key, properties.getInt(key, DEFAULT_LIMIT_CONFIG_MAX_DOCUMENT_COUNT)); } break; default: break; } Loading
apex/appsearch/service/java/com/android/server/appsearch/AppSearchUserInstanceManager.java +5 −2 Original line number Diff line number Diff line Loading @@ -173,8 +173,11 @@ public final class AppSearchUserInstanceManager { File appSearchDir = getAppSearchDir(userHandle); File icingDir = new File(appSearchDir, "icing"); Log.i(TAG, "Creating new AppSearch instance at: " + icingDir); AppSearchImpl appSearchImpl = AppSearchImpl.create(icingDir, initStatsBuilder, new FrameworkOptimizeStrategy()); AppSearchImpl appSearchImpl = AppSearchImpl.create( icingDir, new FrameworkLimitConfig(config), initStatsBuilder, new FrameworkOptimizeStrategy()); long prepareVisibilityStoreLatencyStartMillis = SystemClock.elapsedRealtime(); VisibilityStoreImpl visibilityStore = Loading
apex/appsearch/service/java/com/android/server/appsearch/FrameworkLimitConfig.java 0 → 100644 +41 −0 Original line number Diff line number Diff line /* * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.server.appsearch; import android.annotation.NonNull; import com.android.server.appsearch.external.localstorage.LimitConfig; import java.util.Objects; class FrameworkLimitConfig implements LimitConfig { private final AppSearchConfig mAppSearchConfig; FrameworkLimitConfig(@NonNull AppSearchConfig appSearchConfig) { mAppSearchConfig = Objects.requireNonNull(appSearchConfig); } @Override public int getMaxDocumentSizeBytes() { return mAppSearchConfig.getCachedLimitConfigMaxDocumentSizeBytes(); } @Override public int getMaxDocumentCount() { return mAppSearchConfig.getCachedLimitConfigMaxDocumentCount(); } }