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 package com.android.adservices.service;
17 
18 /**
19  * Provides {@link Flags} implementations that override some common values that are used in tests.
20  */
21 public final class FakeFlagsFactory {
22 
23     /**
24      * @deprecated TODO(b/332723427): each API should use its own fake factory.
25      */
26     @Deprecated
getFlagsForTest()27     public static Flags getFlagsForTest() {
28         // Use the Flags that has constant values.
29         return new TestFlags();
30     }
31 
32     /**
33      * @deprecated TODO(b/332723427): copied "as-is" from {@link FlagsFactory} - each API should use
34      *     its own fake flags.
35      */
36     @Deprecated
37     public static class TestFlags implements Flags {
38         // Using tolerant timeouts for tests to avoid flakiness.
39         // Tests that need to validate timeout behaviours will override these values too.
40         @Override
getAdSelectionBiddingTimeoutPerCaMs()41         public long getAdSelectionBiddingTimeoutPerCaMs() {
42             return 10000;
43         }
44 
45         @Override
getAdSelectionScoringTimeoutMs()46         public long getAdSelectionScoringTimeoutMs() {
47             return 10000;
48         }
49 
50         @Override
getAdSelectionOverallTimeoutMs()51         public long getAdSelectionOverallTimeoutMs() {
52             return 600000;
53         }
54 
55         @Override
getEnforceIsolateMaxHeapSize()56         public boolean getEnforceIsolateMaxHeapSize() {
57             return false;
58         }
59 
60         @Override
getDisableFledgeEnrollmentCheck()61         public boolean getDisableFledgeEnrollmentCheck() {
62             return true;
63         }
64 
65         @Override
getFledgeRegisterAdBeaconEnabled()66         public boolean getFledgeRegisterAdBeaconEnabled() {
67             return true;
68         }
69 
70         @Override
getFledgeFetchCustomAudienceEnabled()71         public boolean getFledgeFetchCustomAudienceEnabled() {
72             return true;
73         }
74 
75         @Override
getFledgeScheduleCustomAudienceUpdateEnabled()76         public boolean getFledgeScheduleCustomAudienceUpdateEnabled() {
77             return true;
78         }
79 
80         @Override
getFledgeScheduleCustomAudienceMinDelayMinsOverride()81         public int getFledgeScheduleCustomAudienceMinDelayMinsOverride() {
82             // Lets the delay be set in past for easier testing
83             return -100;
84         }
85 
86         @Override
getEnableLoggedTopic()87         public boolean getEnableLoggedTopic() {
88             return true;
89         }
90 
91         @Override
getEnableDatabaseSchemaVersion8()92         public boolean getEnableDatabaseSchemaVersion8() {
93             return true;
94         }
95 
96         @Override
getFledgeAuctionServerEnabled()97         public boolean getFledgeAuctionServerEnabled() {
98             return true;
99         }
100 
101         @Override
getFledgeEventLevelDebugReportingEnabled()102         public boolean getFledgeEventLevelDebugReportingEnabled() {
103             return true;
104         }
105 
106         @Override
getFledgeBeaconReportingMetricsEnabled()107         public boolean getFledgeBeaconReportingMetricsEnabled() {
108             return true;
109         }
110 
111         @Override
getFledgeAppPackageNameLoggingEnabled()112         public boolean getFledgeAppPackageNameLoggingEnabled() {
113             return true;
114         }
115 
116         @Override
getFledgeAuctionServerKeyFetchMetricsEnabled()117         public boolean getFledgeAuctionServerKeyFetchMetricsEnabled() {
118             return true;
119         }
120 
121         @Override
getPasExtendedMetricsEnabled()122         public boolean getPasExtendedMetricsEnabled() {
123             return true;
124         }
125     }
126 
FakeFlagsFactory()127     private FakeFlagsFactory() {
128         throw new UnsupportedOperationException("provides only static methods");
129     }
130 }
131