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.adselection.SignedContextualAds;
20 
21 import com.android.adservices.LoggerFactory;
22 import com.android.adservices.data.customaudience.DBCustomAudience;
23 
24 import java.util.List;
25 
26 /** Replacement for {@link FrequencyCapAdFiltererImpl} if filtering is turned off. */
27 public final class FrequencyCapAdFiltererNoOpImpl implements FrequencyCapAdFilterer {
28 
29     private static final LoggerFactory.Logger sLogger = LoggerFactory.getFledgeLogger();
30 
31     /**
32      * Identity function that returns its input.
33      *
34      * @param cas A list of CAs.
35      * @return cas
36      */
37     @Override
filterCustomAudiences(List<DBCustomAudience> cas)38     public List<DBCustomAudience> filterCustomAudiences(List<DBCustomAudience> cas) {
39         logSkip();
40         return cas;
41     }
42 
43     /**
44      * Identity function that returns its input.
45      *
46      * @param contextualAds An object containing ads.
47      * @return contextual ads
48      */
49     @Override
filterContextualAds(SignedContextualAds contextualAds)50     public SignedContextualAds filterContextualAds(SignedContextualAds contextualAds) {
51         logSkip();
52         return contextualAds;
53     }
54 
logSkip()55     private static void logSkip() {
56         sLogger.v("Frequency Cap filtering is disabled, skipping");
57     }
58 }
59