1 /*
2  * Copyright (C) 2023 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.adservices.service.adselection;
18 
19 import android.adservices.common.AdTechIdentifier;
20 import android.adservices.common.FrequencyCapFilters;
21 import android.annotation.NonNull;
22 
23 import com.android.adservices.data.adselection.DBAdSelection;
24 import com.android.adservices.data.adselection.datahandlers.AdSelectionInitialization;
25 import com.android.adservices.data.adselection.datahandlers.WinningCustomAudience;
26 
27 import java.time.Instant;
28 
29 /**
30  * Interface for updating ad counter histograms either during ad selection or after the service is
31  * called.
32  */
33 public interface AdCounterHistogramUpdater {
34     /**
35      * Updates the ad counter histogram for the buyer and custom audience with a win event.
36      *
37      * <p>Works with on-device ad selection DB objects that are in process of being replaced in
38      * go/rb-rm-unified-adselection-dao-design
39      */
updateWinHistogram(@onNull DBAdSelection dbAdSelection)40     void updateWinHistogram(@NonNull DBAdSelection dbAdSelection);
41 
42     /**
43      * Updates the ad counter histogram for the buyer and custom audience with a win event.
44      *
45      * <p>Works with the new storage design in go/rb-rm-unified-adselection-dao-design
46      */
updateWinHistogram( @onNull AdTechIdentifier buyer, @NonNull AdSelectionInitialization adSelectionInitialization, @NonNull WinningCustomAudience winningCustomAudience)47     void updateWinHistogram(
48             @NonNull AdTechIdentifier buyer,
49             @NonNull AdSelectionInitialization adSelectionInitialization,
50             @NonNull WinningCustomAudience winningCustomAudience);
51 
52     /**
53      * Updates the ad counter histogram for the ad associated with the given ad selection ID with a
54      * non-win event.
55      */
updateNonWinHistogram( long adSelectionId, @NonNull String callerPackageName, @FrequencyCapFilters.AdEventType int adEventType, @NonNull Instant eventTimestamp)56     void updateNonWinHistogram(
57             long adSelectionId,
58             @NonNull String callerPackageName,
59             @FrequencyCapFilters.AdEventType int adEventType,
60             @NonNull Instant eventTimestamp);
61 }
62