1 /* 2 * Copyright (C) 2024 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.indexer; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 22 import com.android.server.LocalManagerRegistry; 23 import com.android.server.appsearch.appsindexer.AppOpenEventIndexerMaintenanceConfig; 24 import com.android.server.appsearch.appsindexer.AppsIndexerMaintenanceConfig; 25 import com.android.server.appsearch.contactsindexer.ContactsIndexerMaintenanceConfig; 26 27 import java.lang.annotation.Retention; 28 import java.lang.annotation.RetentionPolicy; 29 30 /** Contains information needed to dispatch a maintenance job for an indexer. */ 31 public interface IndexerMaintenanceConfig { 32 int APPS_INDEXER = 0; 33 int CONTACTS_INDEXER = 1; 34 int APP_OPEN_EVENT_INDEXER = 2; 35 36 int MIN_CONTACTS_INDEXER_JOB_ID = 16942831; // corresponds to ag/16942831 37 38 int MIN_APPS_INDEXER_JOB_ID = 16964307; // Contacts Indexer Max Job Id + 1 39 40 int MIN_APP_OPEN_EVENT_INDEXER_JOB_ID = 16985783; // Apps Indexer Max Job Id + 1 41 42 @IntDef( 43 value = { 44 APPS_INDEXER, 45 CONTACTS_INDEXER, 46 APP_OPEN_EVENT_INDEXER, 47 }) 48 @Retention(RetentionPolicy.SOURCE) 49 @interface IndexerType {} 50 51 /** Returns the {@link IndexerMaintenanceConfig} for the requested indexer type. */ 52 @NonNull getConfigForIndexer(@ndexerType int indexerType)53 static IndexerMaintenanceConfig getConfigForIndexer(@IndexerType int indexerType) { 54 if (indexerType == APPS_INDEXER) { 55 return AppsIndexerMaintenanceConfig.INSTANCE; 56 } else if (indexerType == CONTACTS_INDEXER) { 57 return ContactsIndexerMaintenanceConfig.INSTANCE; 58 } else if (indexerType == APP_OPEN_EVENT_INDEXER) { 59 return AppOpenEventIndexerMaintenanceConfig.INSTANCE; 60 } else { 61 throw new IllegalArgumentException( 62 "Attempted to get config for invalid indexer type: " + indexerType); 63 } 64 } 65 66 /** 67 * Returns the local service for the indexer. 68 * 69 * @see LocalManagerRegistry#addManager 70 */ 71 @NonNull getLocalService()72 Class<? extends IndexerLocalService> getLocalService(); 73 74 /** Returns the minimum job id for the indexer. */ getMinJobId()75 int getMinJobId(); 76 } 77