1 /* 2 * Copyright (C) 2022 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; 18 19 /** Factory class to create AdServices Flags */ 20 public class FlagsFactory { 21 /** Ad Services Flags backed by Phenotype/Heterodyne. */ getFlags()22 public static Flags getFlags() { 23 // Use the Flags backed by PH. 24 return PhFlags.getInstance(); 25 } 26 27 /** Ad Services Flags backed by hard coded constants. This should be used in unit tests only */ getFlagsForTest()28 public static Flags getFlagsForTest() { 29 // Use the Flags that has constant values. 30 return new Flags() { 31 // Using tolerant timeouts for tests to avoid flakiness. 32 // Tests that need to validate timeout behaviours will override these values too. 33 @Override 34 public long getAdSelectionBiddingTimeoutPerCaMs() { 35 return 10000; 36 } 37 38 @Override 39 public long getAdSelectionScoringTimeoutMs() { 40 return 10000; 41 } 42 43 @Override 44 public long getAdSelectionOverallTimeoutMs() { 45 return 600000; 46 } 47 48 @Override 49 public boolean getEnforceIsolateMaxHeapSize() { 50 return false; 51 } 52 53 @Override 54 public boolean getDisableFledgeEnrollmentCheck() { 55 return true; 56 } 57 58 @Override 59 public boolean getFledgeRegisterAdBeaconEnabled() { 60 return true; 61 } 62 63 @Override 64 public boolean getFledgeAdSelectionFilteringEnabled() { 65 return true; 66 } 67 }; 68 } 69 } 70