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.AppsIndexerMaintenanceConfig; 24 import com.android.server.appsearch.contactsindexer.ContactsIndexerMaintenanceConfig; 25 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.RetentionPolicy; 28 29 /** Contains information needed to dispatch a maintenance job for an indexer. */ 30 public interface IndexerMaintenanceConfig { 31 int APPS_INDEXER = 0; 32 int CONTACTS_INDEXER = 1; 33 34 @IntDef( 35 value = { 36 APPS_INDEXER, 37 CONTACTS_INDEXER, 38 }) 39 @Retention(RetentionPolicy.SOURCE) 40 @interface IndexerType {} 41 42 /** Returns the {@link IndexerMaintenanceConfig} for the requested indexer type. */ 43 @NonNull getConfigForIndexer(@ndexerType int indexerType)44 static IndexerMaintenanceConfig getConfigForIndexer(@IndexerType int indexerType) { 45 if (indexerType == APPS_INDEXER) { 46 return AppsIndexerMaintenanceConfig.INSTANCE; 47 } else if (indexerType == CONTACTS_INDEXER) { 48 return ContactsIndexerMaintenanceConfig.INSTANCE; 49 } else { 50 throw new IllegalArgumentException( 51 "Attempted to get config for invalid indexer type: " + indexerType); 52 } 53 } 54 55 /** 56 * Returns the local service for the indexer. 57 * 58 * @see LocalManagerRegistry#addManager 59 */ 60 @NonNull getLocalService()61 Class<? extends IndexerLocalService> getLocalService(); 62 63 /** Returns the minimum job id for the indexer. */ getMinJobId()64 int getMinJobId(); 65 } 66