1 /* 2 * Copyright 2020 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 import android.annotation.NonNull; 20 import android.app.appsearch.stats.SchemaMigrationStats; 21 22 import com.android.server.appsearch.external.localstorage.stats.CallStats; 23 import com.android.server.appsearch.external.localstorage.stats.InitializeStats; 24 import com.android.server.appsearch.external.localstorage.stats.OptimizeStats; 25 import com.android.server.appsearch.external.localstorage.stats.PutDocumentStats; 26 import com.android.server.appsearch.external.localstorage.stats.RemoveStats; 27 import com.android.server.appsearch.external.localstorage.stats.SearchSessionStats; 28 import com.android.server.appsearch.external.localstorage.stats.SearchStats; 29 import com.android.server.appsearch.external.localstorage.stats.SetSchemaStats; 30 31 import java.util.List; 32 33 /** 34 * An interface for implementing client-defined logging AppSearch operations stats. 35 * 36 * <p>Any implementation needs to provide general information on how to log all the stats types. 37 * (for example {@link CallStats}) 38 * 39 * <p>All implementations of this interface must be thread safe. 40 * 41 * @hide 42 */ 43 public interface AppSearchLogger { 44 /** Logs {@link CallStats} */ logStats(@onNull CallStats stats)45 void logStats(@NonNull CallStats stats); 46 47 /** Logs {@link PutDocumentStats} */ logStats(@onNull PutDocumentStats stats)48 void logStats(@NonNull PutDocumentStats stats); 49 50 /** Logs {@link InitializeStats} */ logStats(@onNull InitializeStats stats)51 void logStats(@NonNull InitializeStats stats); 52 53 /** Logs {@link SearchStats} */ logStats(@onNull SearchStats stats)54 void logStats(@NonNull SearchStats stats); 55 56 /** Logs {@link RemoveStats} */ logStats(@onNull RemoveStats stats)57 void logStats(@NonNull RemoveStats stats); 58 59 /** Logs {@link OptimizeStats} */ logStats(@onNull OptimizeStats stats)60 void logStats(@NonNull OptimizeStats stats); 61 62 /** Logs {@link SetSchemaStats} */ logStats(@onNull SetSchemaStats stats)63 void logStats(@NonNull SetSchemaStats stats); 64 65 /** Logs {@link SchemaMigrationStats} */ logStats(@onNull SchemaMigrationStats stats)66 void logStats(@NonNull SchemaMigrationStats stats); 67 68 /** 69 * Logs a list of {@link SearchSessionStats}. 70 * 71 * <p>Since the client app may report search intents belonging to different search sessions in a 72 * single taken action reporting request, the stats extractor will separate them into multiple 73 * search sessions. Therefore, we need a list of {@link SearchSessionStats} here. 74 * 75 * <p>For example, the client app reports the following search intent sequence: 76 * 77 * <ul> 78 * <li>t = 1, the user searches "a" with some clicks. 79 * <li>t = 5, the user searches "app" with some clicks. 80 * <li>t = 10000, the user searches "email" with some clicks. 81 * </ul> 82 * 83 * The extractor will detect "email" belongs to a completely independent search session, and 84 * creates 2 {@link SearchSessionStats} with search intents ["a", "app"] and ["email"] 85 * respectively. 86 */ logStats(@onNull List<SearchSessionStats> searchSessionsStats)87 void logStats(@NonNull List<SearchSessionStats> searchSessionsStats); 88 89 // TODO(b/173532925) Add remaining logStats once we add all the stats. 90 } 91