1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.server.appsearch.external.localstorage; 18 19 20 /** 21 * Defines limits placed on users of AppSearch and enforced by {@link AppSearchImpl}. 22 * 23 * @hide 24 */ 25 public interface LimitConfig { 26 /** 27 * The maximum number of bytes a single document is allowed to be. 28 * 29 * <p>Enforced at the time of serializing the document into a proto. 30 * 31 * <p>This limit has two purposes: 32 * 33 * <ol> 34 * <li>Prevent the system service from using too much memory during indexing or querying by 35 * capping the size of the data structures it needs to buffer 36 * <li>Prevent apps from using a very large amount of data by storing exceptionally large 37 * documents. 38 * </ol> 39 */ getMaxDocumentSizeBytes()40 int getMaxDocumentSizeBytes(); 41 42 /** 43 * The maximum number of documents a single app is allowed to index. 44 * 45 * <p>Enforced at indexing time. 46 * 47 * <p>This limit has two purposes: 48 * 49 * <ol> 50 * <li>Protect icing lib's docid space from being overwhelmed by a single app. The overall 51 * docid limit is currently 2^20 (~1 million) 52 * <li>Prevent apps from using a very large amount of data on the system by storing too many 53 * documents. 54 * </ol> 55 */ getMaxDocumentCount()56 int getMaxDocumentCount(); 57 58 /** 59 * The maximum number of suggestion results a single app is allowed to search. 60 * 61 * <p>Enforced at searching suggestion time. 62 * 63 * <p>The purpose of this limit is to protect Android framework system resource like memory from 64 * being overwhelmed by a single app. 65 */ getMaxSuggestionCount()66 int getMaxSuggestionCount(); 67 } 68