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 import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREGROUND_SERVICE;
20 import static android.os.Build.VERSION.SDK_INT;
21 
22 import static com.android.adservices.shared.common.flags.FeatureFlag.Type.DEBUG;
23 import static com.android.adservices.shared.common.flags.FeatureFlag.Type.LEGACY_KILL_SWITCH;
24 import static com.android.adservices.shared.common.flags.FeatureFlag.Type.LEGACY_KILL_SWITCH_GLOBAL;
25 import static com.android.adservices.shared.common.flags.FeatureFlag.Type.LEGACY_KILL_SWITCH_RAMPED_UP;
26 
27 import android.annotation.IntDef;
28 import android.app.job.JobInfo;
29 import android.os.Build;
30 
31 import androidx.annotation.Nullable;
32 
33 import com.android.adservices.cobalt.CobaltConstants;
34 import com.android.adservices.shared.common.flags.ConfigFlag;
35 import com.android.adservices.shared.common.flags.FeatureFlag;
36 import com.android.adservices.shared.common.flags.ModuleSharedFlags;
37 import com.android.internal.annotations.VisibleForTesting;
38 import com.android.modules.utils.build.SdkLevel;
39 
40 import com.google.common.collect.ImmutableList;
41 
42 import java.io.PrintWriter;
43 import java.lang.annotation.Retention;
44 import java.lang.annotation.RetentionPolicy;
45 import java.util.HashMap;
46 import java.util.Map;
47 import java.util.concurrent.TimeUnit;
48 
49 /**
50  * AdServices Feature Flags interface. This Flags interface hold the default values of Ad Services
51  * Flags. The default values in this class must match with the default values in PH since we will
52  * migrate to Flag Codegen in the future. With that migration, the Flags.java file will be generated
53  * from the GCL.
54  *
55  * <p><b>NOTE: </b>cannot have any dependency on Android or other AdServices code.
56  */
57 public interface Flags extends ModuleSharedFlags {
58     /** Topics Epoch Job Period. */
59     long TOPICS_EPOCH_JOB_PERIOD_MS = 7 * 86_400_000; // 7 days.
60 
61     /** Returns the max time period (in millis) between each epoch computation job run. */
getTopicsEpochJobPeriodMs()62     default long getTopicsEpochJobPeriodMs() {
63         return TOPICS_EPOCH_JOB_PERIOD_MS;
64     }
65 
66     /** Topics Epoch Job Flex. Note the minimum value system allows is +8h24m0s0ms */
67     @ConfigFlag long TOPICS_EPOCH_JOB_FLEX_MS = 9 * 60 * 60 * 1000; // 5 hours.
68 
69     /** Returns flex for the Epoch computation job in Millisecond. */
getTopicsEpochJobFlexMs()70     default long getTopicsEpochJobFlexMs() {
71         return TOPICS_EPOCH_JOB_FLEX_MS;
72     }
73 
74     /* The percentage that we will return a random topic from the Taxonomy. */
75     int TOPICS_PERCENTAGE_FOR_RANDOM_TOPIC = 5;
76 
77     /** Returns the percentage that we will return a random topic from the Taxonomy. */
getTopicsPercentageForRandomTopic()78     default int getTopicsPercentageForRandomTopic() {
79         return TOPICS_PERCENTAGE_FOR_RANDOM_TOPIC;
80     }
81 
82     /** The number of top Topics for each epoch. */
83     int TOPICS_NUMBER_OF_TOP_TOPICS = 5;
84 
85     /** Returns the number of top topics. */
getTopicsNumberOfTopTopics()86     default int getTopicsNumberOfTopTopics() {
87         return TOPICS_NUMBER_OF_TOP_TOPICS;
88     }
89 
90     /** The number of random Topics for each epoch. */
91     int TOPICS_NUMBER_OF_RANDOM_TOPICS = 1;
92 
93     /** Returns the number of top topics. */
getTopicsNumberOfRandomTopics()94     default int getTopicsNumberOfRandomTopics() {
95         return TOPICS_NUMBER_OF_RANDOM_TOPICS;
96     }
97 
98     /** Global blocked Topics. Default value is empty list. */
99     ImmutableList<Integer> TOPICS_GLOBAL_BLOCKED_TOPIC_IDS = ImmutableList.of();
100 
101     /** Returns a list of global blocked topics. */
getGlobalBlockedTopicIds()102     default ImmutableList<Integer> getGlobalBlockedTopicIds() {
103         return TOPICS_GLOBAL_BLOCKED_TOPIC_IDS;
104     }
105 
106     /** How many epochs to look back when deciding if a caller has observed a topic before. */
107     int TOPICS_NUMBER_OF_LOOK_BACK_EPOCHS = 3;
108 
109     /** Flag to disable direct app calls for Topics API. go/app-calls-for-topics-api */
110     boolean TOPICS_DISABLE_DIRECT_APP_CALLS = false;
111 
112     /** Returns the flag to disable direct app calls for Topics API. */
getTopicsDisableDirectAppCalls()113     default boolean getTopicsDisableDirectAppCalls() {
114         return TOPICS_DISABLE_DIRECT_APP_CALLS;
115     }
116 
117     /** Flag to enable encrypted Topics feature for Topics API. */
118     boolean TOPICS_ENCRYPTION_ENABLED = false;
119 
120     /** Returns the feature flag to enable encryption for Topics API. */
getTopicsEncryptionEnabled()121     default boolean getTopicsEncryptionEnabled() {
122         return TOPICS_ENCRYPTION_ENABLED;
123     }
124 
125     /** Flag to enable Topics encryption metrics for Topics API. */
126     boolean TOPICS_ENCRYPTION_METRICS_ENABLED = false;
127 
128     /** Returns the feature flag to enable Topics encryption metrics for Topics API. */
getTopicsEncryptionMetricsEnabled()129     default boolean getTopicsEncryptionMetricsEnabled() {
130         return TOPICS_ENCRYPTION_METRICS_ENABLED;
131     }
132 
133     /** Flag to disable plaintext Topics for Topics API response. */
134     boolean TOPICS_DISABLE_PLAINTEXT_RESPONSE = false;
135 
136     /** Returns the feature flag to disable plaintext fields Topics API response. */
getTopicsDisablePlaintextResponse()137     default boolean getTopicsDisablePlaintextResponse() {
138         return TOPICS_DISABLE_PLAINTEXT_RESPONSE;
139     }
140 
141     /**
142      * Flag to override base64 public key used for encryption testing.
143      *
144      * <p>Note: Default value for this flag should not be changed from empty.
145      */
146     String TOPICS_TEST_ENCRYPTION_PUBLIC_KEY = "";
147 
148     /** Returns test public key used for encrypting topics for testing. */
getTopicsTestEncryptionPublicKey()149     default String getTopicsTestEncryptionPublicKey() {
150         return TOPICS_TEST_ENCRYPTION_PUBLIC_KEY;
151     }
152 
153     /**
154      * Returns the number of epochs to look back when deciding if a caller has observed a topic
155      * before.
156      */
getTopicsNumberOfLookBackEpochs()157     default int getTopicsNumberOfLookBackEpochs() {
158         return TOPICS_NUMBER_OF_LOOK_BACK_EPOCHS;
159     }
160 
161     /** Privacy budget for logging topic ID distributions with randomized response. */
162     float TOPICS_PRIVACY_BUDGET_FOR_TOPIC_ID_DISTRIBUTION = 5f;
163 
164     /** Returns the privacy budget for logging topic ID distributions with randomized response. */
getTopicsPrivacyBudgetForTopicIdDistribution()165     default float getTopicsPrivacyBudgetForTopicIdDistribution() {
166         return TOPICS_PRIVACY_BUDGET_FOR_TOPIC_ID_DISTRIBUTION;
167     }
168 
169     /** Available types of classifier behaviours for the Topics API. */
170     @IntDef(
171             flag = true,
172             value = {
173                 UNKNOWN_CLASSIFIER,
174                 ON_DEVICE_CLASSIFIER,
175                 PRECOMPUTED_CLASSIFIER,
176                 PRECOMPUTED_THEN_ON_DEVICE_CLASSIFIER
177             })
178     @Retention(RetentionPolicy.SOURCE)
179     @interface ClassifierType {}
180 
181     /** Unknown classifier option. */
182     int UNKNOWN_CLASSIFIER = 0;
183 
184     /** Only on-device classification. */
185     int ON_DEVICE_CLASSIFIER = 1;
186 
187     /** Only Precomputed classification. */
188     int PRECOMPUTED_CLASSIFIER = 2;
189 
190     /** Precomputed classification values are preferred over on-device classification values. */
191     int PRECOMPUTED_THEN_ON_DEVICE_CLASSIFIER = 3;
192 
193     /* Type of classifier intended to be used by default. */
194     @ClassifierType int DEFAULT_CLASSIFIER_TYPE = PRECOMPUTED_THEN_ON_DEVICE_CLASSIFIER;
195 
196     /** Returns the type of classifier currently used by Topics. */
197     @ClassifierType
getClassifierType()198     default int getClassifierType() {
199         return DEFAULT_CLASSIFIER_TYPE;
200     }
201 
202     /** Number of top labels allowed for every app. */
203     int CLASSIFIER_NUMBER_OF_TOP_LABELS = 3;
204 
205     /** Returns the number of top labels allowed for every app after the classification process. */
getClassifierNumberOfTopLabels()206     default int getClassifierNumberOfTopLabels() {
207         return CLASSIFIER_NUMBER_OF_TOP_LABELS;
208     }
209 
210     /** Threshold value for classification values. */
211     float CLASSIFIER_THRESHOLD = 0.2f;
212 
213     /** Returns the threshold value for classification values. */
getClassifierThreshold()214     default float getClassifierThreshold() {
215         return CLASSIFIER_THRESHOLD;
216     }
217 
218     /** Number of max words allowed in the description for topics classifier. */
219     int CLASSIFIER_DESCRIPTION_MAX_WORDS = 500;
220 
221     /** Returns the number of max words allowed in the description for topics classifier. */
getClassifierDescriptionMaxWords()222     default int getClassifierDescriptionMaxWords() {
223         return CLASSIFIER_DESCRIPTION_MAX_WORDS;
224     }
225 
226     /** Number of max characters allowed in the description for topics classifier. */
227     int CLASSIFIER_DESCRIPTION_MAX_LENGTH = 2500;
228 
229     /** Returns the number of max characters allowed in the description for topics classifier. */
getClassifierDescriptionMaxLength()230     default int getClassifierDescriptionMaxLength() {
231         return CLASSIFIER_DESCRIPTION_MAX_LENGTH;
232     }
233 
234     // TODO(b/243829477): Remove this flag when flow of pushing models is refined.
235     /**
236      * Whether classifier should force using bundled files. This flag is mainly used in CTS tests to
237      * force using precomputed_app_list to avoid model mismatch due to update. Default value is
238      * false which means to use downloaded files.
239      */
240     boolean CLASSIFIER_FORCE_USE_BUNDLED_FILES = false;
241 
242     /** Returns whether to force using bundled files */
getClassifierForceUseBundledFiles()243     default boolean getClassifierForceUseBundledFiles() {
244         return CLASSIFIER_FORCE_USE_BUNDLED_FILES;
245     }
246 
247     /* The default period for the Maintenance job. */
248     long MAINTENANCE_JOB_PERIOD_MS = 86_400_000; // 1 day.
249 
250     /** Returns the max time period (in millis) between each idle maintenance job run. */
getMaintenanceJobPeriodMs()251     default long getMaintenanceJobPeriodMs() {
252         return MAINTENANCE_JOB_PERIOD_MS;
253     }
254 
255     /* The default flex for Maintenance Job. */
256     long MAINTENANCE_JOB_FLEX_MS = 3 * 60 * 60 * 1000; // 3 hours.
257 
258     /** Returns flex for the Daily Maintenance job in Millisecond. */
getMaintenanceJobFlexMs()259     default long getMaintenanceJobFlexMs() {
260         return MAINTENANCE_JOB_FLEX_MS;
261     }
262 
getEncryptionKeyNetworkConnectTimeoutMs()263     default int getEncryptionKeyNetworkConnectTimeoutMs() {
264         return ENCRYPTION_KEY_NETWORK_CONNECT_TIMEOUT_MS;
265     }
266 
267     int ENCRYPTION_KEY_NETWORK_CONNECT_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(5);
268 
getEncryptionKeyNetworkReadTimeoutMs()269     default int getEncryptionKeyNetworkReadTimeoutMs() {
270         return ENCRYPTION_KEY_NETWORK_READ_TIMEOUT_MS;
271     }
272 
273     int ENCRYPTION_KEY_NETWORK_READ_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(30);
274 
275     /* The default min time period (in millis) between each event main reporting job run. */
276     long MEASUREMENT_EVENT_MAIN_REPORTING_JOB_PERIOD_MS = 4 * 60 * 60 * 1000; // 4 hours.
277 
278     /** Returns min time period (in millis) between each event main reporting job run. */
getMeasurementEventMainReportingJobPeriodMs()279     default long getMeasurementEventMainReportingJobPeriodMs() {
280         return MEASUREMENT_EVENT_MAIN_REPORTING_JOB_PERIOD_MS;
281     }
282 
283     /* The default min time period (in millis) between each event fallback reporting job run. */
284     long MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_PERIOD_MS = 24 * 60 * 60 * 1000; // 24 hours.
285 
286     /** Returns min time period (in millis) between each event fallback reporting job run. */
getMeasurementEventFallbackReportingJobPeriodMs()287     default long getMeasurementEventFallbackReportingJobPeriodMs() {
288         return MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_PERIOD_MS;
289     }
290 
291     /**
292      * The suffix that is appended to the aggregation coordinator origin for retrieving the
293      * encryption keys.
294      */
295     String MEASUREMENT_AGGREGATION_COORDINATOR_PATH = "v1alpha/publicKeys";
296 
297     /** Returns the URL for fetching public encryption keys for aggregatable reports. */
getMeasurementAggregationCoordinatorPath()298     default String getMeasurementAggregationCoordinatorPath() {
299         return MEASUREMENT_AGGREGATION_COORDINATOR_PATH;
300     }
301 
302     boolean MEASUREMENT_AGGREGATION_COORDINATOR_ORIGIN_ENABLED = true;
303 
304     /** Returns true if aggregation coordinator origin is enabled. */
getMeasurementAggregationCoordinatorOriginEnabled()305     default boolean getMeasurementAggregationCoordinatorOriginEnabled() {
306         return MEASUREMENT_AGGREGATION_COORDINATOR_ORIGIN_ENABLED;
307     }
308 
309     /**
310      * Default list(comma-separated) of origins for creating a URL used to fetch public encryption
311      * keys for aggregatable reports.
312      */
313     String MEASUREMENT_AGGREGATION_COORDINATOR_ORIGIN_LIST =
314             "https://publickeyservice.aws.privacysandboxservices.com";
315 
316     /**
317      * Returns a string which is a comma separated list of origins used to fetch public encryption
318      * keys for aggregatable reports.
319      */
getMeasurementAggregationCoordinatorOriginList()320     default String getMeasurementAggregationCoordinatorOriginList() {
321         return MEASUREMENT_AGGREGATION_COORDINATOR_ORIGIN_LIST;
322     }
323 
324     /* The list of origins for creating a URL used to fetch public encryption keys for
325     aggregatable reports. AWS is the current default. */
326     String MEASUREMENT_DEFAULT_AGGREGATION_COORDINATOR_ORIGIN =
327             "https://publickeyservice.aws.privacysandboxservices.com";
328 
329     /**
330      * Returns the default origin for creating the URI used to fetch public encryption keys for
331      * aggregatable reports.
332      */
getMeasurementDefaultAggregationCoordinatorOrigin()333     default String getMeasurementDefaultAggregationCoordinatorOrigin() {
334         return MEASUREMENT_DEFAULT_AGGREGATION_COORDINATOR_ORIGIN;
335     }
336 
337     /* The default min time period (in millis) between each aggregate main reporting job run. */
338     long MEASUREMENT_AGGREGATE_MAIN_REPORTING_JOB_PERIOD_MS = 4 * 60 * 60 * 1000; // 4 hours.
339 
340     /** Returns min time period (in millis) between each aggregate main reporting job run. */
getMeasurementAggregateMainReportingJobPeriodMs()341     default long getMeasurementAggregateMainReportingJobPeriodMs() {
342         return MEASUREMENT_AGGREGATE_MAIN_REPORTING_JOB_PERIOD_MS;
343     }
344 
345     /* The default min time period (in millis) between each aggregate fallback reporting job run. */
346     long MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_PERIOD_MS = 24 * 60 * 60 * 1000; // 24 hours.
347 
348     /** Returns min time period (in millis) between each aggregate fallback job run. */
getMeasurementAggregateFallbackReportingJobPeriodMs()349     default long getMeasurementAggregateFallbackReportingJobPeriodMs() {
350         return MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_PERIOD_MS;
351     }
352 
353     /**
354      * Returns the maximum time in milliseconds allowed for a network call to open its initial
355      * connection during Measurement API calls.
356      */
getMeasurementNetworkConnectTimeoutMs()357     default int getMeasurementNetworkConnectTimeoutMs() {
358         return MEASUREMENT_NETWORK_CONNECT_TIMEOUT_MS;
359     }
360 
361     /**
362      * Returns the maximum time in milliseconds allowed for a network call to read a response from a
363      * target server during Measurement API calls.
364      */
getMeasurementNetworkReadTimeoutMs()365     default int getMeasurementNetworkReadTimeoutMs() {
366         return MEASUREMENT_NETWORK_READ_TIMEOUT_MS;
367     }
368 
369     long MEASUREMENT_DB_SIZE_LIMIT = (1024 * 1024) * 10; // 10 MBs
370     int MEASUREMENT_NETWORK_CONNECT_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(5);
371     int MEASUREMENT_NETWORK_READ_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(30);
372     int MEASUREMENT_REPORT_RETRY_LIMIT = 3;
373     boolean MEASUREMENT_REPORT_RETRY_LIMIT_ENABLED = true;
374 
375     /**
376      * Returns the window that an InputEvent has to be within for the system to register it as a
377      * click.
378      */
379     long MEASUREMENT_REGISTRATION_INPUT_EVENT_VALID_WINDOW_MS = 60 * 1000; // 1 minute.
380 
getMeasurementRegistrationInputEventValidWindowMs()381     default long getMeasurementRegistrationInputEventValidWindowMs() {
382         return MEASUREMENT_REGISTRATION_INPUT_EVENT_VALID_WINDOW_MS;
383     }
384 
385     /** Returns whether a click event should be verified before a registration request. */
386     boolean MEASUREMENT_IS_CLICK_VERIFICATION_ENABLED = true;
387 
getMeasurementIsClickVerificationEnabled()388     default boolean getMeasurementIsClickVerificationEnabled() {
389         return MEASUREMENT_IS_CLICK_VERIFICATION_ENABLED;
390     }
391 
392     /** Returns whether a click is verified by Input Event. */
393     boolean MEASUREMENT_IS_CLICK_VERIFIED_BY_INPUT_EVENT = false;
394 
getMeasurementIsClickVerifiedByInputEvent()395     default boolean getMeasurementIsClickVerifiedByInputEvent() {
396         return MEASUREMENT_IS_CLICK_VERIFIED_BY_INPUT_EVENT;
397     }
398 
399     /** Returns whether measurement click deduplication is enabled. */
getMeasurementIsClickDeduplicationEnabled()400     default boolean getMeasurementIsClickDeduplicationEnabled() {
401         return MEASUREMENT_IS_CLICK_DEDUPLICATION_ENABLED;
402     }
403 
404     /** Default whether measurement click deduplication is enabled. */
405     boolean MEASUREMENT_IS_CLICK_DEDUPLICATION_ENABLED = false;
406 
407     /** Returns whether measurement click deduplication is enforced. */
getMeasurementIsClickDeduplicationEnforced()408     default boolean getMeasurementIsClickDeduplicationEnforced() {
409         return MEASUREMENT_IS_CLICK_DEDUPLICATION_ENFORCED;
410     }
411 
412     /** Default whether measurement click deduplication is enforced. */
413     boolean MEASUREMENT_IS_CLICK_DEDUPLICATION_ENFORCED = false;
414 
415     /** Returns the number of sources that can be registered with a single click. */
getMeasurementMaxSourcesPerClick()416     default long getMeasurementMaxSourcesPerClick() {
417         return MEASUREMENT_MAX_SOURCES_PER_CLICK;
418     }
419 
420     /** Default max number of sources that can be registered with single click. */
421     long MEASUREMENT_MAX_SOURCES_PER_CLICK = 1;
422 
423     /** Returns the DB size limit for measurement. */
getMeasurementDbSizeLimit()424     default long getMeasurementDbSizeLimit() {
425         return MEASUREMENT_DB_SIZE_LIMIT;
426     }
427 
428     /** Returns Whether to limit number of Retries for Measurement Reports */
getMeasurementReportingRetryLimitEnabled()429     default boolean getMeasurementReportingRetryLimitEnabled() {
430         return MEASUREMENT_REPORT_RETRY_LIMIT_ENABLED;
431     }
432 
433     /** Returns Maximum number of Retries for Measurement Reportss */
getMeasurementReportingRetryLimit()434     default int getMeasurementReportingRetryLimit() {
435         return MEASUREMENT_REPORT_RETRY_LIMIT;
436     }
437 
438     /** Measurement manifest file url, used for MDD download. */
439     String MEASUREMENT_MANIFEST_FILE_URL =
440             "https://www.gstatic.com/mdi-serving/rubidium-adservices-adtech-enrollment/4503"
441                     + "/fecd522d3dcfbe1b3b1f1054947be8528be43e97";
442 
443     /** Measurement manifest file url. */
getMeasurementManifestFileUrl()444     default String getMeasurementManifestFileUrl() {
445         return MEASUREMENT_MANIFEST_FILE_URL;
446     }
447 
448     boolean MEASUREMENT_ENABLE_XNA = false;
449 
450     /** Returns whether XNA should be used for eligible sources. */
getMeasurementEnableXNA()451     default boolean getMeasurementEnableXNA() {
452         return MEASUREMENT_ENABLE_XNA;
453     }
454 
455     boolean MEASUREMENT_ENABLE_SHARED_SOURCE_DEBUG_KEY = true;
456 
457     /** Enable/disable shared_debug_key processing from source RBR. */
getMeasurementEnableSharedSourceDebugKey()458     default boolean getMeasurementEnableSharedSourceDebugKey() {
459         return MEASUREMENT_ENABLE_SHARED_SOURCE_DEBUG_KEY;
460     }
461 
462     boolean MEASUREMENT_ENABLE_SHARED_FILTER_DATA_KEYS_XNA = true;
463 
464     /** Enable/disable shared_filter_data_keys processing from source RBR. */
getMeasurementEnableSharedFilterDataKeysXNA()465     default boolean getMeasurementEnableSharedFilterDataKeysXNA() {
466         return MEASUREMENT_ENABLE_SHARED_FILTER_DATA_KEYS_XNA;
467     }
468 
469     boolean MEASUREMENT_ENABLE_DEBUG_REPORT = true;
470 
471     /** Returns whether verbose debug report generation is enabled. */
getMeasurementEnableDebugReport()472     default boolean getMeasurementEnableDebugReport() {
473         return MEASUREMENT_ENABLE_DEBUG_REPORT;
474     }
475 
476     boolean MEASUREMENT_ENABLE_SOURCE_DEBUG_REPORT = true;
477 
478     /** Returns whether source debug report generation is enabled. */
getMeasurementEnableSourceDebugReport()479     default boolean getMeasurementEnableSourceDebugReport() {
480         return MEASUREMENT_ENABLE_SOURCE_DEBUG_REPORT;
481     }
482 
483     boolean MEASUREMENT_ENABLE_TRIGGER_DEBUG_REPORT = true;
484 
485     /** Returns whether trigger debug report generation is enabled. */
getMeasurementEnableTriggerDebugReport()486     default boolean getMeasurementEnableTriggerDebugReport() {
487         return MEASUREMENT_ENABLE_TRIGGER_DEBUG_REPORT;
488     }
489 
490     /** Default value for whether header error debug report is enabled. */
491     @FeatureFlag boolean MEASUREMENT_ENABLE_HEADER_ERROR_DEBUG_REPORT = false;
492 
493     /** Returns whether header error debug report generation is enabled. */
getMeasurementEnableHeaderErrorDebugReport()494     default boolean getMeasurementEnableHeaderErrorDebugReport() {
495         return MEASUREMENT_ENABLE_HEADER_ERROR_DEBUG_REPORT;
496     }
497 
498     long MEASUREMENT_DATA_EXPIRY_WINDOW_MS = TimeUnit.DAYS.toMillis(37);
499 
500     /** Returns the data expiry window in milliseconds. */
getMeasurementDataExpiryWindowMs()501     default long getMeasurementDataExpiryWindowMs() {
502         return MEASUREMENT_DATA_EXPIRY_WINDOW_MS;
503     }
504 
505     int MEASUREMENT_MAX_REGISTRATION_REDIRECTS = 20;
506 
507     /** Returns the number of maximum registration redirects allowed. */
getMeasurementMaxRegistrationRedirects()508     default int getMeasurementMaxRegistrationRedirects() {
509         return MEASUREMENT_MAX_REGISTRATION_REDIRECTS;
510     }
511 
512     int MEASUREMENT_MAX_REGISTRATIONS_PER_JOB_INVOCATION = 100;
513 
514     /** Returns the number of maximum registration per job invocation. */
getMeasurementMaxRegistrationsPerJobInvocation()515     default int getMeasurementMaxRegistrationsPerJobInvocation() {
516         return MEASUREMENT_MAX_REGISTRATIONS_PER_JOB_INVOCATION;
517     }
518 
519     int MEASUREMENT_MAX_RETRIES_PER_REGISTRATION_REQUEST = 5;
520 
521     /** Returns the number of maximum retires per registration request. */
getMeasurementMaxRetriesPerRegistrationRequest()522     default int getMeasurementMaxRetriesPerRegistrationRequest() {
523         return MEASUREMENT_MAX_RETRIES_PER_REGISTRATION_REQUEST;
524     }
525 
526     long DEFAULT_MEASUREMENT_ASYNC_REGISTRATION_JOB_TRIGGER_MIN_DELAY_MS =
527             TimeUnit.MINUTES.toMillis(2);
528 
529     /**
530      * Returns the minimum delay (in milliseconds) in job triggering after a registration request is
531      * received.
532      */
getMeasurementAsyncRegistrationJobTriggerMinDelayMs()533     default long getMeasurementAsyncRegistrationJobTriggerMinDelayMs() {
534         return DEFAULT_MEASUREMENT_ASYNC_REGISTRATION_JOB_TRIGGER_MIN_DELAY_MS;
535     }
536 
537     long DEFAULT_MEASUREMENT_ASYNC_REGISTRATION_JOB_TRIGGER_MAX_DELAY_MS =
538             TimeUnit.MINUTES.toMillis(5);
539 
540     /**
541      * Returns the maximum delay (in milliseconds) in job triggering after a registration request is
542      * received.
543      */
getMeasurementAsyncRegistrationJobTriggerMaxDelayMs()544     default long getMeasurementAsyncRegistrationJobTriggerMaxDelayMs() {
545         return DEFAULT_MEASUREMENT_ASYNC_REGISTRATION_JOB_TRIGGER_MAX_DELAY_MS;
546     }
547 
548     long DEFAULT_MEASUREMENT_ATTRIBUTION_JOB_TRIGGERING_DELAY_MS = TimeUnit.MINUTES.toMillis(2);
549 
550     /** Delay from trigger registration to attribution job triggering */
getMeasurementAttributionJobTriggerDelayMs()551     default long getMeasurementAttributionJobTriggerDelayMs() {
552         return DEFAULT_MEASUREMENT_ATTRIBUTION_JOB_TRIGGERING_DELAY_MS;
553     }
554 
555     boolean MEASUREMENT_ENABLE_AGGREGATABLE_REPORT_PAYLOAD_PADDING = false;
556 
557     /** Returns true if aggregatable report padding is enabled else false. */
getMeasurementEnableAggregatableReportPayloadPadding()558     default boolean getMeasurementEnableAggregatableReportPayloadPadding() {
559         return MEASUREMENT_ENABLE_AGGREGATABLE_REPORT_PAYLOAD_PADDING;
560     }
561 
562     int DEFAULT_MEASUREMENT_MAX_ATTRIBUTIONS_PER_INVOCATION = 100;
563 
564     /** Max number of {@link Trigger} to process per job for {@link AttributionJobService} */
getMeasurementMaxAttributionsPerInvocation()565     default int getMeasurementMaxAttributionsPerInvocation() {
566         return DEFAULT_MEASUREMENT_MAX_ATTRIBUTIONS_PER_INVOCATION;
567     }
568 
569     long DEFAULT_MEASUREMENT_MAX_EVENT_REPORT_UPLOAD_RETRY_WINDOW_MS = TimeUnit.DAYS.toMillis(28);
570 
571     /** Maximum event report upload retry window. */
getMeasurementMaxEventReportUploadRetryWindowMs()572     default long getMeasurementMaxEventReportUploadRetryWindowMs() {
573         return DEFAULT_MEASUREMENT_MAX_EVENT_REPORT_UPLOAD_RETRY_WINDOW_MS;
574     }
575 
576     long DEFAULT_MEASUREMENT_MAX_AGGREGATE_REPORT_UPLOAD_RETRY_WINDOW_MS =
577             TimeUnit.DAYS.toMillis(28);
578 
579     /** Maximum aggregate report upload retry window. */
getMeasurementMaxAggregateReportUploadRetryWindowMs()580     default long getMeasurementMaxAggregateReportUploadRetryWindowMs() {
581         return DEFAULT_MEASUREMENT_MAX_AGGREGATE_REPORT_UPLOAD_RETRY_WINDOW_MS;
582     }
583 
584     long DEFAULT_MEASUREMENT_MAX_DELAYED_SOURCE_REGISTRATION_WINDOW = TimeUnit.MINUTES.toMillis(2);
585 
586     /** Maximum window for a delayed source to be considered valid instead of missed. */
getMeasurementMaxDelayedSourceRegistrationWindow()587     default long getMeasurementMaxDelayedSourceRegistrationWindow() {
588         return DEFAULT_MEASUREMENT_MAX_DELAYED_SOURCE_REGISTRATION_WINDOW;
589     }
590 
591     int DEFAULT_MEASUREMENT_MAX_BYTES_PER_ATTRIBUTION_FILTER_STRING = 25;
592 
593     /** Maximum number of bytes allowed in an attribution filter string. */
getMeasurementMaxBytesPerAttributionFilterString()594     default int getMeasurementMaxBytesPerAttributionFilterString() {
595         return DEFAULT_MEASUREMENT_MAX_BYTES_PER_ATTRIBUTION_FILTER_STRING;
596     }
597 
598     int DEFAULT_MEASUREMENT_MAX_FILTER_MAPS_PER_FILTER_SET = 5;
599 
600     /** Maximum number of filter maps allowed in an attribution filter set. */
getMeasurementMaxFilterMapsPerFilterSet()601     default int getMeasurementMaxFilterMapsPerFilterSet() {
602         return DEFAULT_MEASUREMENT_MAX_FILTER_MAPS_PER_FILTER_SET;
603     }
604 
605     int DEFAULT_MEASUREMENT_MAX_VALUES_PER_ATTRIBUTION_FILTER = 50;
606 
607     /** Maximum number of values allowed in an attribution filter. */
getMeasurementMaxValuesPerAttributionFilter()608     default int getMeasurementMaxValuesPerAttributionFilter() {
609         return DEFAULT_MEASUREMENT_MAX_VALUES_PER_ATTRIBUTION_FILTER;
610     }
611 
612     int DEFAULT_MEASUREMENT_MAX_ATTRIBUTION_FILTERS = 50;
613 
614     /** Maximum number of attribution filters allowed for a source. */
getMeasurementMaxAttributionFilters()615     default int getMeasurementMaxAttributionFilters() {
616         return DEFAULT_MEASUREMENT_MAX_ATTRIBUTION_FILTERS;
617     }
618 
619     int DEFAULT_MEASUREMENT_MAX_BYTES_PER_ATTRIBUTION_AGGREGATE_KEY_ID = 25;
620 
621     /** Maximum number of bytes allowed in an aggregate key ID. */
getMeasurementMaxBytesPerAttributionAggregateKeyId()622     default int getMeasurementMaxBytesPerAttributionAggregateKeyId() {
623         return DEFAULT_MEASUREMENT_MAX_BYTES_PER_ATTRIBUTION_AGGREGATE_KEY_ID;
624     }
625 
626     int DEFAULT_MEASUREMENT_MAX_AGGREGATE_DEDUPLICATION_KEYS_PER_REGISTRATION = 50;
627 
628     /** Maximum number of aggregate deduplication keys allowed during trigger registration. */
getMeasurementMaxAggregateDeduplicationKeysPerRegistration()629     default int getMeasurementMaxAggregateDeduplicationKeysPerRegistration() {
630         return DEFAULT_MEASUREMENT_MAX_AGGREGATE_DEDUPLICATION_KEYS_PER_REGISTRATION;
631     }
632 
633     @FeatureFlag(LEGACY_KILL_SWITCH_RAMPED_UP)
634     boolean MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_KILL_SWITCH = false;
635 
636     /** Returns the feature flag for Attribution Fallback Job . */
getMeasurementAttributionFallbackJobEnabled()637     default boolean getMeasurementAttributionFallbackJobEnabled() {
638         return getMeasurementEnabled() && !MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_KILL_SWITCH;
639     }
640 
641     long MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_PERIOD_MS = TimeUnit.HOURS.toMillis(1);
642 
643     /** Returns the job period in millis for Attribution Fallback Job . */
getMeasurementAttributionFallbackJobPeriodMs()644     default long getMeasurementAttributionFallbackJobPeriodMs() {
645         return MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_PERIOD_MS;
646     }
647 
648     int MEASUREMENT_MAX_ATTRIBUTION_PER_RATE_LIMIT_WINDOW = 100;
649 
650     /**
651      * Returns maximum attributions per rate limit window. Rate limit unit: (Source Site,
652      * Destination Site, Reporting Site, Window).
653      */
getMeasurementMaxAttributionPerRateLimitWindow()654     default int getMeasurementMaxAttributionPerRateLimitWindow() {
655         return MEASUREMENT_MAX_ATTRIBUTION_PER_RATE_LIMIT_WINDOW;
656     }
657 
658     int MEASUREMENT_MAX_EVENT_ATTRIBUTION_PER_RATE_LIMIT_WINDOW = 100;
659 
660     /**
661      * Returns maximum event attributions per rate limit window. Rate limit unit: (Source Site,
662      * Destination Site, Reporting Site, Window).
663      */
getMeasurementMaxEventAttributionPerRateLimitWindow()664     default int getMeasurementMaxEventAttributionPerRateLimitWindow() {
665         return MEASUREMENT_MAX_EVENT_ATTRIBUTION_PER_RATE_LIMIT_WINDOW;
666     }
667 
668     int MEASUREMENT_MAX_AGGREGATE_ATTRIBUTION_PER_RATE_LIMIT_WINDOW = 100;
669 
670     /**
671      * Returns maximum aggregate attributions per rate limit window. Rate limit unit: (Source Site,
672      * Destination Site, Reporting Site, Window).
673      */
getMeasurementMaxAggregateAttributionPerRateLimitWindow()674     default int getMeasurementMaxAggregateAttributionPerRateLimitWindow() {
675         return MEASUREMENT_MAX_AGGREGATE_ATTRIBUTION_PER_RATE_LIMIT_WINDOW;
676     }
677 
678     int MEASUREMENT_MAX_DISTINCT_REPORTING_ORIGINS_IN_ATTRIBUTION = 10;
679 
680     /**
681      * Returns max distinct reporting origins for attribution per { Advertiser X Publisher X
682      * TimePeriod }.
683      */
getMeasurementMaxDistinctReportingOriginsInAttribution()684     default int getMeasurementMaxDistinctReportingOriginsInAttribution() {
685         return MEASUREMENT_MAX_DISTINCT_REPORTING_ORIGINS_IN_ATTRIBUTION;
686     }
687 
688     int MEASUREMENT_MAX_DISTINCT_DESTINATIONS_IN_ACTIVE_SOURCE = 100;
689 
690     /**
691      * Returns max distinct advertisers with pending impressions per { Publisher X Enrollment X
692      * TimePeriod }.
693      */
getMeasurementMaxDistinctDestinationsInActiveSource()694     default int getMeasurementMaxDistinctDestinationsInActiveSource() {
695         return MEASUREMENT_MAX_DISTINCT_DESTINATIONS_IN_ACTIVE_SOURCE;
696     }
697 
698     int MEASUREMENT_MAX_REPORTING_ORIGINS_PER_SOURCE_REPORTING_SITE_PER_WINDOW = 1;
699 
700     /**
701      * Returns the maximum number of reporting origins per source site, reporting site,
702      * reporting-origin-update-window counted per source registration.
703      */
704     default int
getMeasurementMaxReportingOriginsPerSourceReportingSitePerWindow()705         getMeasurementMaxReportingOriginsPerSourceReportingSitePerWindow() {
706         return MEASUREMENT_MAX_REPORTING_ORIGINS_PER_SOURCE_REPORTING_SITE_PER_WINDOW;
707     }
708 
709     int MEASUREMENT_MAX_DISTINCT_REP_ORIG_PER_PUBLISHER_X_DEST_IN_SOURCE = 100;
710 
711     /**
712      * Max distinct reporting origins with source registration per { Publisher X Advertiser X
713      * TimePeriod }.
714      */
getMeasurementMaxDistinctRepOrigPerPublXDestInSource()715     default int getMeasurementMaxDistinctRepOrigPerPublXDestInSource() {
716         return MEASUREMENT_MAX_DISTINCT_REP_ORIG_PER_PUBLISHER_X_DEST_IN_SOURCE;
717     }
718 
719     boolean MEASUREMENT_ENABLE_DESTINATION_RATE_LIMIT = true;
720 
721     /** Returns {@code true} if Measurement destination rate limit is enabled. */
getMeasurementEnableDestinationRateLimit()722     default boolean getMeasurementEnableDestinationRateLimit() {
723         return MEASUREMENT_ENABLE_DESTINATION_RATE_LIMIT;
724     }
725 
726     int MEASUREMENT_MAX_DESTINATIONS_PER_PUBLISHER_PER_RATE_LIMIT_WINDOW = 50;
727 
728     /**
729      * Returns the maximum number of distinct destination sites per source site per rate limit
730      * window.
731      */
getMeasurementMaxDestinationsPerPublisherPerRateLimitWindow()732     default int getMeasurementMaxDestinationsPerPublisherPerRateLimitWindow() {
733         return MEASUREMENT_MAX_DESTINATIONS_PER_PUBLISHER_PER_RATE_LIMIT_WINDOW;
734     }
735 
736     int MEASUREMENT_MAX_DEST_PER_PUBLISHER_X_ENROLLMENT_PER_RATE_LIMIT_WINDOW = 200;
737 
738     /**
739      * Returns the maximum number of distinct destination sites per source site X enrollment per
740      * rate limit window.
741      */
getMeasurementMaxDestPerPublisherXEnrollmentPerRateLimitWindow()742     default int getMeasurementMaxDestPerPublisherXEnrollmentPerRateLimitWindow() {
743         return MEASUREMENT_MAX_DEST_PER_PUBLISHER_X_ENROLLMENT_PER_RATE_LIMIT_WINDOW;
744     }
745 
746     long MEASUREMENT_DESTINATION_RATE_LIMIT_WINDOW = TimeUnit.MINUTES.toMillis(1);
747 
748     /** Returns the duration that controls the rate-limiting window for destinations. */
getMeasurementDestinationRateLimitWindow()749     default long getMeasurementDestinationRateLimitWindow() {
750         return MEASUREMENT_DESTINATION_RATE_LIMIT_WINDOW;
751     }
752 
753     float MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_EVENT = 6.5F;
754 
755     /** Returns max information gain in Flexible Event API for Event sources */
getMeasurementFlexApiMaxInformationGainEvent()756     default float getMeasurementFlexApiMaxInformationGainEvent() {
757         return MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_EVENT;
758     }
759 
760     float MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_NAVIGATION = 11.5F;
761 
762     /** Returns max information gain in Flexible Event API for Navigation sources */
getMeasurementFlexApiMaxInformationGainNavigation()763     default float getMeasurementFlexApiMaxInformationGainNavigation() {
764         return MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_NAVIGATION;
765     }
766 
767     float MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_DUAL_DESTINATION_EVENT = 6.5F;
768 
769     /** Returns max information gain for Flexible Event, dual destination Event sources */
getMeasurementFlexApiMaxInformationGainDualDestinationEvent()770     default float getMeasurementFlexApiMaxInformationGainDualDestinationEvent() {
771         return MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_DUAL_DESTINATION_EVENT;
772     }
773 
774     float MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_DUAL_DESTINATION_NAVIGATION = 11.5F;
775 
776     /** Returns max information gain for Flexible Event, dual destination Navigation sources */
getMeasurementFlexApiMaxInformationGainDualDestinationNavigation()777     default float getMeasurementFlexApiMaxInformationGainDualDestinationNavigation() {
778         return MEASUREMENT_FLEX_API_MAX_INFORMATION_GAIN_DUAL_DESTINATION_NAVIGATION;
779     }
780 
781     long MEASUREMENT_MAX_REPORT_STATES_PER_SOURCE_REGISTRATION = (1L << 32) - 1L;
782 
783     /** Returns max repot states per source registration */
getMeasurementMaxReportStatesPerSourceRegistration()784     default long getMeasurementMaxReportStatesPerSourceRegistration() {
785         return MEASUREMENT_MAX_REPORT_STATES_PER_SOURCE_REGISTRATION;
786     }
787 
788     int MEASUREMENT_FLEX_API_MAX_EVENT_REPORTS = 20;
789 
790     /** Returns max event reports in Flexible Event API */
getMeasurementFlexApiMaxEventReports()791     default int getMeasurementFlexApiMaxEventReports() {
792         return MEASUREMENT_FLEX_API_MAX_EVENT_REPORTS;
793     }
794 
795     int MEASUREMENT_FLEX_API_MAX_EVENT_REPORT_WINDOWS = 5;
796 
797     /** Returns max event report windows in Flexible Event API */
getMeasurementFlexApiMaxEventReportWindows()798     default int getMeasurementFlexApiMaxEventReportWindows() {
799         return MEASUREMENT_FLEX_API_MAX_EVENT_REPORT_WINDOWS;
800     }
801 
802     int MEASUREMENT_FLEX_API_MAX_TRIGGER_DATA_CARDINALITY = 32;
803 
804     /** Returns max trigger data cardinality in Flexible Event API */
getMeasurementFlexApiMaxTriggerDataCardinality()805     default int getMeasurementFlexApiMaxTriggerDataCardinality() {
806         return MEASUREMENT_FLEX_API_MAX_TRIGGER_DATA_CARDINALITY;
807     }
808 
809     long MEASUREMENT_MINIMUM_EVENT_REPORT_WINDOW_IN_SECONDS = TimeUnit.HOURS.toSeconds(1);
810 
811     /** Returns minimum event report window */
getMeasurementMinimumEventReportWindowInSeconds()812     default long getMeasurementMinimumEventReportWindowInSeconds() {
813         return MEASUREMENT_MINIMUM_EVENT_REPORT_WINDOW_IN_SECONDS;
814     }
815 
816     long MEASUREMENT_MINIMUM_AGGREGATABLE_REPORT_WINDOW_IN_SECONDS = TimeUnit.HOURS.toSeconds(1);
817 
818     /** Returns minimum aggregatable report window */
getMeasurementMinimumAggregatableReportWindowInSeconds()819     default long getMeasurementMinimumAggregatableReportWindowInSeconds() {
820         return MEASUREMENT_MINIMUM_AGGREGATABLE_REPORT_WINDOW_IN_SECONDS;
821     }
822 
823     boolean MEASUREMENT_ENABLE_LOOKBACK_WINDOW_FILTER = false;
824 
825     /** Returns true if lookback window filter is enabled else false. */
getMeasurementEnableLookbackWindowFilter()826     default boolean getMeasurementEnableLookbackWindowFilter() {
827         return MEASUREMENT_ENABLE_LOOKBACK_WINDOW_FILTER;
828     }
829 
830     /** Default FLEDGE app package name logging flag. */
831     boolean FLEDGE_APP_PACKAGE_NAME_LOGGING_ENABLED = false;
832 
833     /** Returns whether FLEDGE app package name logging is enabled. */
getFledgeAppPackageNameLoggingEnabled()834     default boolean getFledgeAppPackageNameLoggingEnabled() {
835         return FLEDGE_APP_PACKAGE_NAME_LOGGING_ENABLED;
836     }
837 
838     long FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT = 4000L;
839     long FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT = 1000L;
840     long FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT = 1000L;
841     long FLEDGE_CUSTOM_AUDIENCE_DEFAULT_EXPIRE_IN_MS = 60L * 24L * 60L * 60L * 1000L; // 60 days
842     long FLEDGE_CUSTOM_AUDIENCE_MAX_ACTIVATION_DELAY_IN_MS =
843             60L * 24L * 60L * 60L * 1000L; // 60 days
844     long FLEDGE_CUSTOM_AUDIENCE_MAX_EXPIRE_IN_MS = 60L * 24L * 60L * 60L * 1000L; // 60 days
845     int FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B = 200;
846     int FLEDGE_CUSTOM_AUDIENCE_MAX_DAILY_UPDATE_URI_SIZE_B = 400;
847     int FLEDGE_CUSTOM_AUDIENCE_MAX_BIDDING_LOGIC_URI_SIZE_B = 400;
848     int FLEDGE_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B = 10 * 1024; // 10 KiB
849     int FLEDGE_CUSTOM_AUDIENCE_MAX_TRUSTED_BIDDING_DATA_SIZE_B = 10 * 1024; // 10 KiB
850     int FLEDGE_CUSTOM_AUDIENCE_MAX_ADS_SIZE_B = 10 * 1024; // 10 KiB
851     int FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS = 100;
852     // Keeping TTL as long as expiry, could be reduced later as we get more fresh CAs with adoption
853     long FLEDGE_CUSTOM_AUDIENCE_ACTIVE_TIME_WINDOW_MS = 60 * 24 * 60L * 60L * 1000; // 60 days
854     long FLEDGE_ENCRYPTION_KEY_MAX_AGE_SECONDS = TimeUnit.DAYS.toSeconds(14);
855     long FLEDGE_FETCH_CUSTOM_AUDIENCE_MIN_RETRY_AFTER_VALUE_MS = 30 * 1000; // 30 seconds
856     long FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_RETRY_AFTER_VALUE_MS =
857             24 * 60 * 60 * 1000; // 24 hours in ms
858 
859     /**
860      * Returns the minimum number of milliseconds before the same fetch CA request can be retried.
861      */
getFledgeFetchCustomAudienceMinRetryAfterValueMs()862     default long getFledgeFetchCustomAudienceMinRetryAfterValueMs() {
863         return FLEDGE_FETCH_CUSTOM_AUDIENCE_MIN_RETRY_AFTER_VALUE_MS;
864     }
865 
866     /**
867      * Returns the maximum number of milliseconds before the same fetch CA request can be retried.
868      */
getFledgeFetchCustomAudienceMaxRetryAfterValueMs()869     default long getFledgeFetchCustomAudienceMaxRetryAfterValueMs() {
870         return FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_RETRY_AFTER_VALUE_MS;
871     }
872 
873     /** Returns the maximum number of custom audience can stay in the storage. */
getFledgeCustomAudienceMaxCount()874     default long getFledgeCustomAudienceMaxCount() {
875         return FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT;
876     }
877 
878     /** Returns the maximum number of custom audience an app can create. */
getFledgeCustomAudiencePerAppMaxCount()879     default long getFledgeCustomAudiencePerAppMaxCount() {
880         return FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT;
881     }
882 
883     /** Returns the maximum number of apps can have access to custom audience. */
getFledgeCustomAudienceMaxOwnerCount()884     default long getFledgeCustomAudienceMaxOwnerCount() {
885         return FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT;
886     }
887 
888     /**
889      * Returns the default amount of time in milliseconds a custom audience object will live before
890      * being expiring and being removed
891      */
getFledgeCustomAudienceDefaultExpireInMs()892     default long getFledgeCustomAudienceDefaultExpireInMs() {
893         return FLEDGE_CUSTOM_AUDIENCE_DEFAULT_EXPIRE_IN_MS;
894     }
895 
896     /**
897      * Returns the maximum permitted difference in milliseconds between the custom audience object's
898      * creation time and its activation time
899      */
getFledgeCustomAudienceMaxActivationDelayInMs()900     default long getFledgeCustomAudienceMaxActivationDelayInMs() {
901         return FLEDGE_CUSTOM_AUDIENCE_MAX_ACTIVATION_DELAY_IN_MS;
902     }
903 
904     /**
905      * Returns the maximum permitted difference in milliseconds between the custom audience object's
906      * activation time and its expiration time
907      */
getFledgeCustomAudienceMaxExpireInMs()908     default long getFledgeCustomAudienceMaxExpireInMs() {
909         return FLEDGE_CUSTOM_AUDIENCE_MAX_EXPIRE_IN_MS;
910     }
911 
912     /** Returns the maximum size in bytes allowed for name in each FLEDGE custom audience. */
getFledgeCustomAudienceMaxNameSizeB()913     default int getFledgeCustomAudienceMaxNameSizeB() {
914         return FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B;
915     }
916 
917     /**
918      * Returns the maximum size in bytes allowed for daily update uri in each FLEDGE custom
919      * audience.
920      */
getFledgeCustomAudienceMaxDailyUpdateUriSizeB()921     default int getFledgeCustomAudienceMaxDailyUpdateUriSizeB() {
922         return FLEDGE_CUSTOM_AUDIENCE_MAX_DAILY_UPDATE_URI_SIZE_B;
923     }
924 
925     /**
926      * Returns the maximum size in bytes allowed for bidding logic uri in each FLEDGE custom
927      * audience.
928      */
getFledgeCustomAudienceMaxBiddingLogicUriSizeB()929     default int getFledgeCustomAudienceMaxBiddingLogicUriSizeB() {
930         return FLEDGE_CUSTOM_AUDIENCE_MAX_BIDDING_LOGIC_URI_SIZE_B;
931     }
932 
933     /**
934      * Returns the maximum size in bytes allowed for user bidding signals in each FLEDGE custom
935      * audience.
936      */
getFledgeCustomAudienceMaxUserBiddingSignalsSizeB()937     default int getFledgeCustomAudienceMaxUserBiddingSignalsSizeB() {
938         return FLEDGE_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B;
939     }
940 
941     /**
942      * Returns the maximum size in bytes allowed for trusted bidding data in each FLEDGE custom
943      * audience.
944      */
getFledgeCustomAudienceMaxTrustedBiddingDataSizeB()945     default int getFledgeCustomAudienceMaxTrustedBiddingDataSizeB() {
946         return FLEDGE_CUSTOM_AUDIENCE_MAX_TRUSTED_BIDDING_DATA_SIZE_B;
947     }
948 
949     /** Returns the maximum size in bytes allowed for ads in each FLEDGE custom audience. */
getFledgeCustomAudienceMaxAdsSizeB()950     default int getFledgeCustomAudienceMaxAdsSizeB() {
951         return FLEDGE_CUSTOM_AUDIENCE_MAX_ADS_SIZE_B;
952     }
953 
954     /** Returns the maximum allowed number of ads per FLEDGE custom audience. */
getFledgeCustomAudienceMaxNumAds()955     default int getFledgeCustomAudienceMaxNumAds() {
956         return FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS;
957     }
958 
959     /**
960      * Returns the time window that defines how long after a successful update a custom audience can
961      * participate in ad selection.
962      */
getFledgeCustomAudienceActiveTimeWindowInMs()963     default long getFledgeCustomAudienceActiveTimeWindowInMs() {
964         return FLEDGE_CUSTOM_AUDIENCE_ACTIVE_TIME_WINDOW_MS;
965     }
966 
967     int FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B = 8 * 1024; // 8 KiB
968     int FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_REQUEST_CUSTOM_HEADER_SIZE_B = 8 * 1024; // 8 KiB
969     int FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_CUSTOM_AUDIENCE_SIZE_B = 8 * 1024; // 8 KiB
970 
971     /**
972      * Returns the maximum size in bytes allowed for user bidding signals in each
973      * fetchAndJoinCustomAudience request.
974      */
getFledgeFetchCustomAudienceMaxUserBiddingSignalsSizeB()975     default int getFledgeFetchCustomAudienceMaxUserBiddingSignalsSizeB() {
976         return FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B;
977     }
978 
979     /**
980      * Returns the maximum size in bytes allowed for the request custom header derived from each
981      * fetchAndJoinCustomAudience request.
982      */
getFledgeFetchCustomAudienceMaxRequestCustomHeaderSizeB()983     default int getFledgeFetchCustomAudienceMaxRequestCustomHeaderSizeB() {
984         return FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_REQUEST_CUSTOM_HEADER_SIZE_B;
985     }
986 
987     /**
988      * Returns the maximum size in bytes for the fused custom audience allowed to be persisted by
989      * the fetchAndJoinCustomAudience API.
990      */
getFledgeFetchCustomAudienceMaxCustomAudienceSizeB()991     default int getFledgeFetchCustomAudienceMaxCustomAudienceSizeB() {
992         return FLEDGE_FETCH_CUSTOM_AUDIENCE_MAX_CUSTOM_AUDIENCE_SIZE_B;
993     }
994 
995     boolean FLEDGE_BACKGROUND_FETCH_ENABLED = true;
996     long FLEDGE_BACKGROUND_FETCH_JOB_PERIOD_MS = 4L * 60L * 60L * 1000L; // 4 hours
997     long FLEDGE_BACKGROUND_FETCH_JOB_FLEX_MS = 30L * 60L * 1000L; // 30 minutes
998     long FLEDGE_BACKGROUND_FETCH_JOB_MAX_RUNTIME_MS = 10L * 60L * 1000L; // 5 minutes
999     long FLEDGE_BACKGROUND_FETCH_MAX_NUM_UPDATED = 1000;
1000     int FLEDGE_BACKGROUND_FETCH_THREAD_POOL_SIZE = 8;
1001     long FLEDGE_BACKGROUND_FETCH_ELIGIBLE_UPDATE_BASE_INTERVAL_S = 24L * 60L * 60L; // 24 hours
1002     int FLEDGE_BACKGROUND_FETCH_NETWORK_CONNECT_TIMEOUT_MS = 5 * 1000; // 5 seconds
1003     int FLEDGE_BACKGROUND_FETCH_NETWORK_READ_TIMEOUT_MS = 30 * 1000; // 30 seconds
1004     int FLEDGE_BACKGROUND_FETCH_MAX_RESPONSE_SIZE_B = 10 * 1024; // 10 KiB
1005     boolean FLEDGE_HTTP_CACHE_ENABLE = true;
1006     boolean FLEDGE_HTTP_CACHE_ENABLE_JS_CACHING = true;
1007     long FLEDGE_HTTP_CACHE_DEFAULT_MAX_AGE_SECONDS = 2 * 24 * 60 * 60; // 2 days
1008     long FLEDGE_HTTP_CACHE_MAX_ENTRIES = 100;
1009     boolean FLEDGE_ON_DEVICE_AUCTION_SHOULD_USE_UNIFIED_TABLES = false;
1010 
1011     /** Returns {@code true} if the on device auction should use the unified flow tables */
getFledgeOnDeviceAuctionShouldUseUnifiedTables()1012     default boolean getFledgeOnDeviceAuctionShouldUseUnifiedTables() {
1013         return FLEDGE_ON_DEVICE_AUCTION_SHOULD_USE_UNIFIED_TABLES;
1014     }
1015 
1016     /** Returns {@code true} if the FLEDGE Background Fetch is enabled. */
getFledgeBackgroundFetchEnabled()1017     default boolean getFledgeBackgroundFetchEnabled() {
1018         return FLEDGE_BACKGROUND_FETCH_ENABLED;
1019     }
1020 
1021     /**
1022      * Returns the best effort max time (in milliseconds) between each FLEDGE Background Fetch job
1023      * run.
1024      */
getFledgeBackgroundFetchJobPeriodMs()1025     default long getFledgeBackgroundFetchJobPeriodMs() {
1026         return FLEDGE_BACKGROUND_FETCH_JOB_PERIOD_MS;
1027     }
1028 
1029     /**
1030      * Returns the amount of flex (in milliseconds) around the end of each period to run each FLEDGE
1031      * Background Fetch job.
1032      */
getFledgeBackgroundFetchJobFlexMs()1033     default long getFledgeBackgroundFetchJobFlexMs() {
1034         return FLEDGE_BACKGROUND_FETCH_JOB_FLEX_MS;
1035     }
1036 
1037     /**
1038      * Returns the maximum amount of time (in milliseconds) each FLEDGE Background Fetch job is
1039      * allowed to run.
1040      */
getFledgeBackgroundFetchJobMaxRuntimeMs()1041     default long getFledgeBackgroundFetchJobMaxRuntimeMs() {
1042         return FLEDGE_BACKGROUND_FETCH_JOB_MAX_RUNTIME_MS;
1043     }
1044 
1045     /**
1046      * Returns the maximum number of custom audiences updated in a single FLEDGE background fetch
1047      * job.
1048      */
getFledgeBackgroundFetchMaxNumUpdated()1049     default long getFledgeBackgroundFetchMaxNumUpdated() {
1050         return FLEDGE_BACKGROUND_FETCH_MAX_NUM_UPDATED;
1051     }
1052 
1053     /**
1054      * Returns the maximum thread pool size to draw workers from in a single FLEDGE background fetch
1055      * job.
1056      */
getFledgeBackgroundFetchThreadPoolSize()1057     default int getFledgeBackgroundFetchThreadPoolSize() {
1058         return FLEDGE_BACKGROUND_FETCH_THREAD_POOL_SIZE;
1059     }
1060 
1061     /**
1062      * Returns the base interval in seconds after a successful FLEDGE background fetch job after
1063      * which a custom audience is next eligible to be updated.
1064      */
getFledgeBackgroundFetchEligibleUpdateBaseIntervalS()1065     default long getFledgeBackgroundFetchEligibleUpdateBaseIntervalS() {
1066         return FLEDGE_BACKGROUND_FETCH_ELIGIBLE_UPDATE_BASE_INTERVAL_S;
1067     }
1068 
1069     /**
1070      * Returns the maximum time in milliseconds allowed for a network call to open its initial
1071      * connection during the FLEDGE background fetch.
1072      */
getFledgeBackgroundFetchNetworkConnectTimeoutMs()1073     default int getFledgeBackgroundFetchNetworkConnectTimeoutMs() {
1074         return FLEDGE_BACKGROUND_FETCH_NETWORK_CONNECT_TIMEOUT_MS;
1075     }
1076 
1077     /**
1078      * Returns the maximum time in milliseconds allowed for a network call to read a response from a
1079      * target server during the FLEDGE background fetch.
1080      */
getFledgeBackgroundFetchNetworkReadTimeoutMs()1081     default int getFledgeBackgroundFetchNetworkReadTimeoutMs() {
1082         return FLEDGE_BACKGROUND_FETCH_NETWORK_READ_TIMEOUT_MS;
1083     }
1084 
1085     /**
1086      * Returns the maximum size in bytes of a single custom audience update response during the
1087      * FLEDGE background fetch.
1088      */
getFledgeBackgroundFetchMaxResponseSizeB()1089     default int getFledgeBackgroundFetchMaxResponseSizeB() {
1090         return FLEDGE_BACKGROUND_FETCH_MAX_RESPONSE_SIZE_B;
1091     }
1092 
1093     /**
1094      * Returns boolean, if the caching is enabled for {@link
1095      * com.android.adservices.service.common.cache.FledgeHttpCache}
1096      */
getFledgeHttpCachingEnabled()1097     default boolean getFledgeHttpCachingEnabled() {
1098         return FLEDGE_HTTP_CACHE_ENABLE;
1099     }
1100 
1101     /** Returns boolean, if the caching is enabled for JS for bidding and scoring */
getFledgeHttpJsCachingEnabled()1102     default boolean getFledgeHttpJsCachingEnabled() {
1103         return FLEDGE_HTTP_CACHE_ENABLE_JS_CACHING;
1104     }
1105 
1106     /** Returns max number of entries that should be persisted in cache */
getFledgeHttpCacheMaxEntries()1107     default long getFledgeHttpCacheMaxEntries() {
1108         return FLEDGE_HTTP_CACHE_MAX_ENTRIES;
1109     }
1110 
1111     /** Returns the default max age of entries in cache */
getFledgeHttpCacheMaxAgeSeconds()1112     default long getFledgeHttpCacheMaxAgeSeconds() {
1113         return FLEDGE_HTTP_CACHE_DEFAULT_MAX_AGE_SECONDS;
1114     }
1115 
1116     boolean PROTECTED_SIGNALS_PERIODIC_ENCODING_ENABLED = true;
1117     long PROTECTED_SIGNALS_PERIODIC_ENCODING_JOB_PERIOD_MS = 1L * 60L * 60L * 1000L; // 1 hour
1118     long PROTECTED_SIGNALS_PERIODIC_ENCODING_JOB_FLEX_MS = 5L * 60L * 1000L; // 5 minutes
1119     int PROTECTED_SIGNALS_ENCODED_PAYLOAD_MAX_SIZE_BYTES = (int) (1.5 * 1024); // 1.5 KB
1120     int PROTECTED_SIGNALS_FETCH_SIGNAL_UPDATES_MAX_SIZE_BYTES = (int) (10 * 1024);
1121     int PROTECTED_SIGNALS_MAX_JS_FAILURE_EXECUTION_ON_CERTAIN_VERSION_BEFORE_STOP = 3;
1122     long PROTECTED_SIGNALS_ENCODER_REFRESH_WINDOW_SECONDS = 24L * 60L * 60L; // 1 day
1123     int PROTECTED_SIGNALS_MAX_SIGNAL_SIZE_PER_BUYER_BYTES = 10 * 1024;
1124     int PROTECTED_SIGNALS_MAX_SIGNAL_SIZE_PER_BUYER_WITH_OVERSUBSCIPTION_BYTES = 15 * 1024;
1125 
1126     /** Returns {@code true} feature flag if Periodic encoding of Protected Signals is enabled. */
getProtectedSignalsPeriodicEncodingEnabled()1127     default boolean getProtectedSignalsPeriodicEncodingEnabled() {
1128         return PROTECTED_SIGNALS_PERIODIC_ENCODING_ENABLED;
1129     }
1130 
1131     /** Returns period of running periodic encoding in milliseconds */
getProtectedSignalPeriodicEncodingJobPeriodMs()1132     default long getProtectedSignalPeriodicEncodingJobPeriodMs() {
1133         return PROTECTED_SIGNALS_PERIODIC_ENCODING_JOB_PERIOD_MS;
1134     }
1135 
1136     /** Returns the flexible period of running periodic encoding in milliseconds */
getProtectedSignalsPeriodicEncodingJobFlexMs()1137     default long getProtectedSignalsPeriodicEncodingJobFlexMs() {
1138         return PROTECTED_SIGNALS_PERIODIC_ENCODING_JOB_FLEX_MS;
1139     }
1140 
1141     /** Returns the max size in bytes for encoded payload */
getProtectedSignalsEncodedPayloadMaxSizeBytes()1142     default int getProtectedSignalsEncodedPayloadMaxSizeBytes() {
1143         return PROTECTED_SIGNALS_ENCODED_PAYLOAD_MAX_SIZE_BYTES;
1144     }
1145 
1146     /** Returns the maximum size of the signal update payload. */
getProtectedSignalsFetchSignalUpdatesMaxSizeBytes()1147     default int getProtectedSignalsFetchSignalUpdatesMaxSizeBytes() {
1148         return PROTECTED_SIGNALS_FETCH_SIGNAL_UPDATES_MAX_SIZE_BYTES;
1149     }
1150 
1151     /** Returns the maximum number of continues JS failure before we stop executing the JS. */
getProtectedSignalsMaxJsFailureExecutionOnCertainVersionBeforeStop()1152     default int getProtectedSignalsMaxJsFailureExecutionOnCertainVersionBeforeStop() {
1153         return PROTECTED_SIGNALS_MAX_JS_FAILURE_EXECUTION_ON_CERTAIN_VERSION_BEFORE_STOP;
1154     }
1155 
1156     /** Returns the maximum time window beyond which encoder logic should be refreshed */
getProtectedSignalsEncoderRefreshWindowSeconds()1157     default long getProtectedSignalsEncoderRefreshWindowSeconds() {
1158         return PROTECTED_SIGNALS_ENCODER_REFRESH_WINDOW_SECONDS;
1159     }
1160 
1161     /** Returns the maximum size of signals in storage per buyer. */
getProtectedSignalsMaxSignalSizePerBuyerBytes()1162     default int getProtectedSignalsMaxSignalSizePerBuyerBytes() {
1163         return PROTECTED_SIGNALS_MAX_SIGNAL_SIZE_PER_BUYER_BYTES;
1164     }
1165 
1166     /**
1167      * Returns the maximum size of signals in the storage per buyer with a graceful oversubscription
1168      * policy.
1169      */
getProtectedSignalsMaxSignalSizePerBuyerWithOversubsciptionBytes()1170     default int getProtectedSignalsMaxSignalSizePerBuyerWithOversubsciptionBytes() {
1171         return PROTECTED_SIGNALS_MAX_SIGNAL_SIZE_PER_BUYER_WITH_OVERSUBSCIPTION_BYTES;
1172     }
1173 
1174     int FLEDGE_AD_COUNTER_HISTOGRAM_ABSOLUTE_MAX_TOTAL_EVENT_COUNT = 10_000;
1175     int FLEDGE_AD_COUNTER_HISTOGRAM_LOWER_MAX_TOTAL_EVENT_COUNT = 9_500;
1176     int FLEDGE_AD_COUNTER_HISTOGRAM_ABSOLUTE_MAX_PER_BUYER_EVENT_COUNT = 1_000;
1177     int FLEDGE_AD_COUNTER_HISTOGRAM_LOWER_MAX_PER_BUYER_EVENT_COUNT = 900;
1178 
1179     /** Returns the maximum allowed number of events in the entire frequency cap histogram table. */
getFledgeAdCounterHistogramAbsoluteMaxTotalEventCount()1180     default int getFledgeAdCounterHistogramAbsoluteMaxTotalEventCount() {
1181         return FLEDGE_AD_COUNTER_HISTOGRAM_ABSOLUTE_MAX_TOTAL_EVENT_COUNT;
1182     }
1183 
1184     /**
1185      * Returns the number of events that the entire frequency cap histogram table should be trimmed
1186      * to, if there are too many entries.
1187      */
getFledgeAdCounterHistogramLowerMaxTotalEventCount()1188     default int getFledgeAdCounterHistogramLowerMaxTotalEventCount() {
1189         return FLEDGE_AD_COUNTER_HISTOGRAM_LOWER_MAX_TOTAL_EVENT_COUNT;
1190     }
1191 
1192     /**
1193      * Returns the maximum allowed number of events per buyer in the frequency cap histogram table.
1194      */
getFledgeAdCounterHistogramAbsoluteMaxPerBuyerEventCount()1195     default int getFledgeAdCounterHistogramAbsoluteMaxPerBuyerEventCount() {
1196         return FLEDGE_AD_COUNTER_HISTOGRAM_ABSOLUTE_MAX_PER_BUYER_EVENT_COUNT;
1197     }
1198 
1199     /**
1200      * Returns the number of events for a single buyer that the frequency cap histogram table should
1201      * be trimmed to, if there are too many entries for that buyer.
1202      */
getFledgeAdCounterHistogramLowerMaxPerBuyerEventCount()1203     default int getFledgeAdCounterHistogramLowerMaxPerBuyerEventCount() {
1204         return FLEDGE_AD_COUNTER_HISTOGRAM_LOWER_MAX_PER_BUYER_EVENT_COUNT;
1205     }
1206 
1207     int FLEDGE_AD_SELECTION_MAX_CONCURRENT_BIDDING_COUNT = 6;
1208 
1209     /** Returns the number of CA that can be bid in parallel for one Ad Selection */
getAdSelectionMaxConcurrentBiddingCount()1210     default int getAdSelectionMaxConcurrentBiddingCount() {
1211         return FLEDGE_AD_SELECTION_MAX_CONCURRENT_BIDDING_COUNT;
1212     }
1213 
1214     // TODO(b/240647148): Limits are increased temporarily, re-evaluate these numbers after
1215     //  getting real world data from telemetry & set accurately scoped timeout
1216     long FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_CA_MS = 5000;
1217     long FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_BUYER_MS = 10000;
1218     long FLEDGE_AD_SELECTION_SCORING_TIMEOUT_MS = 5000;
1219     long FLEDGE_AD_SELECTION_SELECTING_OUTCOME_TIMEOUT_MS = 5000;
1220     // For *on device* ad selection.
1221     long FLEDGE_AD_SELECTION_OVERALL_TIMEOUT_MS = 10000;
1222     long FLEDGE_AD_SELECTION_FROM_OUTCOMES_OVERALL_TIMEOUT_MS = 20_000;
1223     long FLEDGE_AD_SELECTION_OFF_DEVICE_OVERALL_TIMEOUT_MS = 10_000;
1224     long FLEDGE_AD_SELECTION_BIDDING_LOGIC_JS_VERSION = 2L;
1225 
1226     long FLEDGE_REPORT_IMPRESSION_OVERALL_TIMEOUT_MS = 2000;
1227 
1228     // RegisterAdBeacon  Constants
1229     long FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_TOTAL_COUNT = 1000; // Num entries
1230     long FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_PER_AD_TECH_COUNT = 10; // Num entries
1231     long FLEDGE_REPORT_IMPRESSION_REGISTERED_AD_BEACONS_MAX_INTERACTION_KEY_SIZE_B =
1232             20 * 2; // Num characters * 2 bytes per char in UTF-8
1233     long FLEDGE_REPORT_IMPRESSION_MAX_INTERACTION_REPORTING_URI_SIZE_B = 400;
1234 
1235     /** Returns the timeout constant in milliseconds that limits the bidding per CA */
getAdSelectionBiddingTimeoutPerCaMs()1236     default long getAdSelectionBiddingTimeoutPerCaMs() {
1237         return FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_CA_MS;
1238     }
1239 
1240     /** Returns the timeout constant in milliseconds that limits the bidding per Buyer */
getAdSelectionBiddingTimeoutPerBuyerMs()1241     default long getAdSelectionBiddingTimeoutPerBuyerMs() {
1242         return FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_BUYER_MS;
1243     }
1244 
1245     /** Returns the timeout constant in milliseconds that limits the scoring */
getAdSelectionScoringTimeoutMs()1246     default long getAdSelectionScoringTimeoutMs() {
1247         return FLEDGE_AD_SELECTION_SCORING_TIMEOUT_MS;
1248     }
1249 
1250     /**
1251      * Returns the timeout constant in milliseconds that limits the {@link
1252      * com.android.adservices.service.adselection.AdOutcomeSelectorImpl#runAdOutcomeSelector}
1253      */
getAdSelectionSelectingOutcomeTimeoutMs()1254     default long getAdSelectionSelectingOutcomeTimeoutMs() {
1255         return FLEDGE_AD_SELECTION_SELECTING_OUTCOME_TIMEOUT_MS;
1256     }
1257 
1258     /**
1259      * Returns the timeout constant in milliseconds that limits the overall *on device* ad selection
1260      * orchestration.
1261      */
getAdSelectionOverallTimeoutMs()1262     default long getAdSelectionOverallTimeoutMs() {
1263         return FLEDGE_AD_SELECTION_OVERALL_TIMEOUT_MS;
1264     }
1265 
1266     /**
1267      * Returns the timeout constant in milliseconds that limits the overall *on device* ad selection
1268      * from outcomes orchestration.
1269      */
getAdSelectionFromOutcomesOverallTimeoutMs()1270     default long getAdSelectionFromOutcomesOverallTimeoutMs() {
1271         return FLEDGE_AD_SELECTION_FROM_OUTCOMES_OVERALL_TIMEOUT_MS;
1272     }
1273 
1274     /**
1275      * Returns the timeout constant in milliseconds that limits the overall off device ad selection
1276      * orchestration.
1277      */
getAdSelectionOffDeviceOverallTimeoutMs()1278     default long getAdSelectionOffDeviceOverallTimeoutMs() {
1279         return FLEDGE_AD_SELECTION_OFF_DEVICE_OVERALL_TIMEOUT_MS;
1280     }
1281 
1282     /** Returns the default JS version for running bidding. */
getFledgeAdSelectionBiddingLogicJsVersion()1283     default long getFledgeAdSelectionBiddingLogicJsVersion() {
1284         return FLEDGE_AD_SELECTION_BIDDING_LOGIC_JS_VERSION;
1285     }
1286 
1287     /**
1288      * Returns the timeout constant in milliseconds that limits the overall impression reporting
1289      * execution
1290      */
getReportImpressionOverallTimeoutMs()1291     default long getReportImpressionOverallTimeoutMs() {
1292         return FLEDGE_REPORT_IMPRESSION_OVERALL_TIMEOUT_MS;
1293     }
1294 
1295     /**
1296      * Returns the maximum number of {@link
1297      * com.android.adservices.data.adselection.DBRegisteredAdInteraction} that can be in the {@code
1298      * registered_ad_interactions} database at any one time.
1299      */
getFledgeReportImpressionMaxRegisteredAdBeaconsTotalCount()1300     default long getFledgeReportImpressionMaxRegisteredAdBeaconsTotalCount() {
1301         return FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_TOTAL_COUNT;
1302     }
1303 
1304     /**
1305      * Returns the maximum number of {@link
1306      * com.android.adservices.data.adselection.DBRegisteredAdInteraction} that an ad-tech can
1307      * register in one call to {@code reportImpression}.
1308      */
getFledgeReportImpressionMaxRegisteredAdBeaconsPerAdTechCount()1309     default long getFledgeReportImpressionMaxRegisteredAdBeaconsPerAdTechCount() {
1310         return FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_PER_AD_TECH_COUNT;
1311     }
1312 
1313     /**
1314      * Returns the maximum size in bytes of {@link
1315      * com.android.adservices.data.adselection.DBRegisteredAdInteraction#getInteractionKey()}
1316      */
getFledgeReportImpressionRegisteredAdBeaconsMaxInteractionKeySizeB()1317     default long getFledgeReportImpressionRegisteredAdBeaconsMaxInteractionKeySizeB() {
1318         return FLEDGE_REPORT_IMPRESSION_REGISTERED_AD_BEACONS_MAX_INTERACTION_KEY_SIZE_B;
1319     }
1320 
1321     /**
1322      * Returns the maximum size in bytes of {@link
1323      * com.android.adservices.data.adselection.DBRegisteredAdInteraction#getInteractionReportingUri()}
1324      */
getFledgeReportImpressionMaxInteractionReportingUriSizeB()1325     default long getFledgeReportImpressionMaxInteractionReportingUriSizeB() {
1326         return FLEDGE_REPORT_IMPRESSION_MAX_INTERACTION_REPORTING_URI_SIZE_B;
1327     }
1328 
1329     // 24 hours in seconds
1330     long FLEDGE_AD_SELECTION_EXPIRATION_WINDOW_S = 60 * 60 * 24;
1331 
1332     /**
1333      * Returns the amount of time in seconds after which ad selection data is considered expired.
1334      */
getAdSelectionExpirationWindowS()1335     default long getAdSelectionExpirationWindowS() {
1336         return FLEDGE_AD_SELECTION_EXPIRATION_WINDOW_S;
1337     }
1338 
1339     // Filtering feature flag disabled by default
1340     boolean FLEDGE_APP_INSTALL_FILTERING_ENABLED = false;
1341 
1342     /** Returns {@code true} if app install filtering of ads during ad selection is enabled. */
getFledgeAppInstallFilteringEnabled()1343     default boolean getFledgeAppInstallFilteringEnabled() {
1344         return FLEDGE_APP_INSTALL_FILTERING_ENABLED;
1345     }
1346 
1347     // Filtering feature flag disabled by default
1348     boolean FLEDGE_FREQUENCY_CAP_FILTERING_ENABLED = false;
1349 
1350     /** Returns {@code true} if frequency cap filtering of ads during ad selection is enabled. */
getFledgeFrequencyCapFilteringEnabled()1351     default boolean getFledgeFrequencyCapFilteringEnabled() {
1352         return FLEDGE_FREQUENCY_CAP_FILTERING_ENABLED;
1353     }
1354 
1355     boolean FLEDGE_AD_SELECTION_CONTEXTUAL_ADS_ENABLED = false;
1356 
1357     /** Returns {@code true} if negative filtering of ads during ad selection is enabled. */
getFledgeAdSelectionContextualAdsEnabled()1358     default boolean getFledgeAdSelectionContextualAdsEnabled() {
1359         return FLEDGE_AD_SELECTION_CONTEXTUAL_ADS_ENABLED;
1360     }
1361 
1362     boolean FLEDGE_AD_SELECTION_CONTEXTUAL_ADS_METRICS_ENABLED = false;
1363 
1364     /** Returns {@code true} if contextual ads signing metrics collection is enabled */
getFledgeAdSelectionContextualAdsMetricsEnabled()1365     default boolean getFledgeAdSelectionContextualAdsMetricsEnabled() {
1366         return FLEDGE_AD_SELECTION_CONTEXTUAL_ADS_METRICS_ENABLED;
1367     }
1368 
1369     boolean FLEDGE_APP_INSTALL_FILTERING_METRICS_ENABLED = false;
1370 
1371     /** Returns {@code true} if App Install Filtering metrics is enabled. */
getFledgeAppInstallFilteringMetricsEnabled()1372     default boolean getFledgeAppInstallFilteringMetricsEnabled() {
1373         return FLEDGE_APP_INSTALL_FILTERING_METRICS_ENABLED;
1374     }
1375 
1376     boolean FLEDGE_FREQUENCY_CAP_FILTERING_METRICS_ENABLED = false;
1377 
1378     /** Returns {@code true} if Frequency Cap Filtering metrics is enabled. */
getFledgeFrequencyCapFilteringMetricsEnabled()1379     default boolean getFledgeFrequencyCapFilteringMetricsEnabled() {
1380         return FLEDGE_FREQUENCY_CAP_FILTERING_METRICS_ENABLED;
1381     }
1382 
1383     // Enable FLEDGE fetchAndJoinCustomAudience API.
1384     boolean FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED = false;
1385 
1386     /** Returns {@code true} if FLEDGE fetchAndJoinCustomAudience API is enabled. */
getFledgeFetchCustomAudienceEnabled()1387     default boolean getFledgeFetchCustomAudienceEnabled() {
1388         return FLEDGE_FETCH_CUSTOM_AUDIENCE_ENABLED;
1389     }
1390 
1391     /** Flags related to Delayed Custom Audience Updates */
1392 
1393     // Enable scheduleCustomAudienceUpdateApi()
1394     boolean FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_ENABLED = false;
1395 
1396     long FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_JOB_PERIOD_MS = 1L * 60L * 60L * 1000L; // 1 hour
1397     long FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_JOB_FLEX_MS = 5L * 60L * 1000L; // 5 minutes
1398     int FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_MIN_DELAY_MINS_OVERRIDE = 30;
1399 
getFledgeScheduleCustomAudienceUpdateEnabled()1400     default boolean getFledgeScheduleCustomAudienceUpdateEnabled() {
1401         return !getGlobalKillSwitch() && FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_ENABLED;
1402     }
1403 
getFledgeScheduleCustomAudienceUpdateJobPeriodMs()1404     default long getFledgeScheduleCustomAudienceUpdateJobPeriodMs() {
1405         return FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_JOB_PERIOD_MS;
1406     }
1407 
getFledgeScheduleCustomAudienceUpdateJobFlexMs()1408     default long getFledgeScheduleCustomAudienceUpdateJobFlexMs() {
1409         return FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_JOB_FLEX_MS;
1410     }
1411 
getFledgeScheduleCustomAudienceMinDelayMinsOverride()1412     default int getFledgeScheduleCustomAudienceMinDelayMinsOverride() {
1413         return FLEDGE_SCHEDULE_CUSTOM_AUDIENCE_UPDATE_MIN_DELAY_MINS_OVERRIDE;
1414     }
1415 
1416     boolean FLEDGE_AD_SELECTION_PREBUILT_URI_ENABLED = false;
1417 
1418     /** Returns whether to call trusted servers for off device ad selection. */
getFledgeAdSelectionPrebuiltUriEnabled()1419     default boolean getFledgeAdSelectionPrebuiltUriEnabled() {
1420         return FLEDGE_AD_SELECTION_PREBUILT_URI_ENABLED;
1421     }
1422 
1423     boolean FLEDGE_AUCTION_SERVER_ENABLED = false;
1424 
1425     /** Returns whether to enable server auction support in post-auction APIs. */
getFledgeAuctionServerEnabled()1426     default boolean getFledgeAuctionServerEnabled() {
1427         return FLEDGE_AUCTION_SERVER_ENABLED;
1428     }
1429 
1430     boolean FLEDGE_AUCTION_SERVER_ENABLED_FOR_REPORT_IMPRESSION = true;
1431 
1432     /** Returns whether to enable server auction support in report impression. */
getFledgeAuctionServerEnabledForReportImpression()1433     default boolean getFledgeAuctionServerEnabledForReportImpression() {
1434         return getFledgeAuctionServerEnabled()
1435                 && FLEDGE_AUCTION_SERVER_ENABLED_FOR_REPORT_IMPRESSION;
1436     }
1437 
1438     boolean FLEDGE_AUCTION_SERVER_ENABLED_FOR_REPORT_EVENT = true;
1439 
1440     /** Returns whether to enable server auction support in report event API. */
getFledgeAuctionServerEnabledForReportEvent()1441     default boolean getFledgeAuctionServerEnabledForReportEvent() {
1442         return getFledgeAuctionServerEnabled() && FLEDGE_AUCTION_SERVER_ENABLED_FOR_REPORT_EVENT;
1443     }
1444 
1445     boolean FLEDGE_AUCTION_SERVER_ENABLED_FOR_UPDATE_HISTOGRAM = true;
1446 
1447     /** Returns whether to enable server auction support in update histogram API. */
getFledgeAuctionServerEnabledForUpdateHistogram()1448     default boolean getFledgeAuctionServerEnabledForUpdateHistogram() {
1449         return getFledgeAuctionServerEnabled()
1450                 && FLEDGE_AUCTION_SERVER_ENABLED_FOR_UPDATE_HISTOGRAM;
1451     }
1452 
1453     boolean FLEDGE_AUCTION_SERVER_ENABLED_FOR_SELECT_ADS_MEDIATION = true;
1454 
1455     /** Returns whether to enable server auction support in select ads mediation API. */
getFledgeAuctionServerEnabledForSelectAdsMediation()1456     default boolean getFledgeAuctionServerEnabledForSelectAdsMediation() {
1457         return getFledgeAuctionServerEnabled()
1458                 && FLEDGE_AUCTION_SERVER_ENABLED_FOR_SELECT_ADS_MEDIATION;
1459     }
1460 
1461     boolean FLEDGE_AUCTION_SERVER_ENABLE_AD_FILTER_IN_GET_AD_SELECTION_DATA = true;
1462 
1463     /** Returns whether to enable ad filtering in get ad selection data API. */
getFledgeAuctionServerEnableAdFilterInGetAdSelectionData()1464     default boolean getFledgeAuctionServerEnableAdFilterInGetAdSelectionData() {
1465         return FLEDGE_AUCTION_SERVER_ENABLE_AD_FILTER_IN_GET_AD_SELECTION_DATA;
1466     }
1467 
1468     boolean FLEDGE_AUCTION_SERVER_MEDIA_TYPE_CHANGE_ENABLED = false;
1469 
1470     /** Returns whether to use the server auction media type. */
getFledgeAuctionServerMediaTypeChangeEnabled()1471     default boolean getFledgeAuctionServerMediaTypeChangeEnabled() {
1472         return FLEDGE_AUCTION_SERVER_MEDIA_TYPE_CHANGE_ENABLED;
1473     }
1474 
1475     ImmutableList<Integer> FLEDGE_AUCTION_SERVER_PAYLOAD_BUCKET_SIZES =
1476             ImmutableList.of(0, 1024, 2048, 4096, 8192, 16384, 32768, 65536);
1477 
1478     /** Returns available bucket sizes for auction server payloads. */
getFledgeAuctionServerPayloadBucketSizes()1479     default ImmutableList<Integer> getFledgeAuctionServerPayloadBucketSizes() {
1480         return FLEDGE_AUCTION_SERVER_PAYLOAD_BUCKET_SIZES;
1481     }
1482 
1483     // TODO(b/291680065): Remove when owner field is returned from B&A
1484     boolean FLEDGE_AUCTION_SERVER_FORCE_SEARCH_WHEN_OWNER_IS_ABSENT_ENABLED = false;
1485 
1486     /**
1487      * Returns true if forcing {@link
1488      * android.adservices.adselection.AdSelectionManager#persistAdSelectionResult} to continue when
1489      * owner is null, otherwise false.
1490      */
getFledgeAuctionServerForceSearchWhenOwnerIsAbsentEnabled()1491     default boolean getFledgeAuctionServerForceSearchWhenOwnerIsAbsentEnabled() {
1492         return FLEDGE_AUCTION_SERVER_FORCE_SEARCH_WHEN_OWNER_IS_ABSENT_ENABLED;
1493     }
1494 
1495     boolean FLEDGE_EVENT_LEVEL_DEBUG_REPORTING_ENABLED = false;
1496 
1497     /** Returns whether to call remote URLs for debug reporting. */
getFledgeEventLevelDebugReportingEnabled()1498     default boolean getFledgeEventLevelDebugReportingEnabled() {
1499         return FLEDGE_EVENT_LEVEL_DEBUG_REPORTING_ENABLED;
1500     }
1501 
1502     boolean FLEDGE_EVENT_LEVEL_DEBUG_REPORT_SEND_IMMEDIATELY = false;
1503 
1504     /** Returns whether to call remote URLs for debug reporting. */
getFledgeEventLevelDebugReportSendImmediately()1505     default boolean getFledgeEventLevelDebugReportSendImmediately() {
1506         return FLEDGE_EVENT_LEVEL_DEBUG_REPORT_SEND_IMMEDIATELY;
1507     }
1508 
1509     int FLEDGE_EVENT_LEVEL_DEBUG_REPORTING_BATCH_DELAY_SECONDS = 60 * 15;
1510 
1511     /** Returns minimum number of seconds between debug report batch. */
getFledgeEventLevelDebugReportingBatchDelaySeconds()1512     default int getFledgeEventLevelDebugReportingBatchDelaySeconds() {
1513         return FLEDGE_EVENT_LEVEL_DEBUG_REPORTING_BATCH_DELAY_SECONDS;
1514     }
1515 
1516     int FLEDGE_EVENT_LEVEL_DEBUG_REPORTING_MAX_ITEMS_PER_BATCH = 1000;
1517 
1518     /** Returns maximum number of items in a debug report batch. */
getFledgeEventLevelDebugReportingMaxItemsPerBatch()1519     default int getFledgeEventLevelDebugReportingMaxItemsPerBatch() {
1520         return FLEDGE_EVENT_LEVEL_DEBUG_REPORTING_MAX_ITEMS_PER_BATCH;
1521     }
1522 
1523     int FLEDGE_DEBUG_REPORT_SENDER_JOB_NETWORK_CONNECT_TIMEOUT_MS = 5 * 1000; // 5 seconds
1524 
1525     /**
1526      * Returns the maximum time in milliseconds allowed for a network call to open its initial
1527      * connection during the FLEDGE debug report sender job.
1528      */
getFledgeDebugReportSenderJobNetworkConnectionTimeoutMs()1529     default int getFledgeDebugReportSenderJobNetworkConnectionTimeoutMs() {
1530         return FLEDGE_DEBUG_REPORT_SENDER_JOB_NETWORK_CONNECT_TIMEOUT_MS;
1531     }
1532 
1533     int FLEDGE_DEBUG_REPORT_SENDER_JOB_NETWORK_READ_TIMEOUT_MS = 30 * 1000; // 30 seconds
1534 
1535     /**
1536      * Returns the maximum time in milliseconds allowed for a network call to read a response from a
1537      * target server during the FLEDGE debug report sender job.
1538      */
getFledgeDebugReportSenderJobNetworkReadTimeoutMs()1539     default int getFledgeDebugReportSenderJobNetworkReadTimeoutMs() {
1540         return FLEDGE_DEBUG_REPORT_SENDER_JOB_NETWORK_READ_TIMEOUT_MS;
1541     }
1542 
1543     long FLEDGE_DEBUG_REPORT_SENDER_JOB_MAX_RUNTIME_MS = 10L * 60L * 1000L; // 5 minutes
1544 
1545     /**
1546      * Returns the maximum amount of time (in milliseconds) each FLEDGE debug report sender job is
1547      * allowed to run.
1548      */
getFledgeDebugReportSenderJobMaxRuntimeMs()1549     default long getFledgeDebugReportSenderJobMaxRuntimeMs() {
1550         return FLEDGE_DEBUG_REPORT_SENDER_JOB_MAX_RUNTIME_MS;
1551     }
1552 
1553     long FLEDGE_DEBUG_REPORT_SENDER_JOB_PERIOD_MS = TimeUnit.MINUTES.toMillis(10);
1554 
1555     /**
1556      * Returns the best effort max time (in milliseconds) between each FLEDGE debug report sender
1557      * job run.
1558      */
getFledgeDebugReportSenderJobPeriodMs()1559     default long getFledgeDebugReportSenderJobPeriodMs() {
1560         return FLEDGE_DEBUG_REPORT_SENDER_JOB_PERIOD_MS;
1561     }
1562 
1563     long FLEDGE_DEBUG_REPORT_SENDER_JOB_FLEX_MS = TimeUnit.MINUTES.toMillis(2);
1564 
1565     /**
1566      * Returns the amount of flex (in milliseconds) around the end of each period to run each FLEDGE
1567      * debug report sender job.
1568      */
getFledgeDebugReportSenderJobFlexMs()1569     default long getFledgeDebugReportSenderJobFlexMs() {
1570         return FLEDGE_DEBUG_REPORT_SENDER_JOB_FLEX_MS;
1571     }
1572 
1573     boolean FLEDGE_AD_SELECTION_OFF_DEVICE_REQUEST_COMPRESSION_ENABLED = true;
1574 
1575     /** Returns whether to compress requests sent off device for ad selection. */
getAdSelectionOffDeviceRequestCompressionEnabled()1576     default boolean getAdSelectionOffDeviceRequestCompressionEnabled() {
1577         return FLEDGE_AD_SELECTION_OFF_DEVICE_REQUEST_COMPRESSION_ENABLED;
1578     }
1579 
1580     /** The server uses the following version numbers: 1. Brotli : 1 2. Gzip : 2 */
1581     int FLEDGE_AUCTION_SERVER_COMPRESSION_ALGORITHM_VERSION = 2;
1582 
1583     /** Returns the compression algorithm version */
getFledgeAuctionServerCompressionAlgorithmVersion()1584     default int getFledgeAuctionServerCompressionAlgorithmVersion() {
1585         return FLEDGE_AUCTION_SERVER_COMPRESSION_ALGORITHM_VERSION;
1586     }
1587 
1588     String FLEDGE_AUCTION_SERVER_AUCTION_KEY_FETCH_URI =
1589             "https://publickeyservice.pa.gcp.privacysandboxservices.com/.well-known/protected-auction/v1/public-keys";
1590 
1591     /** Returns Uri to fetch auction encryption key for fledge ad selection. */
getFledgeAuctionServerAuctionKeyFetchUri()1592     default String getFledgeAuctionServerAuctionKeyFetchUri() {
1593         return FLEDGE_AUCTION_SERVER_AUCTION_KEY_FETCH_URI;
1594     }
1595 
1596     boolean FLEDGE_AUCTION_SERVER_REFRESH_EXPIRED_KEYS_DURING_AUCTION = false;
1597 
getFledgeAuctionServerRefreshExpiredKeysDuringAuction()1598     default boolean getFledgeAuctionServerRefreshExpiredKeysDuringAuction() {
1599         return FLEDGE_AUCTION_SERVER_REFRESH_EXPIRED_KEYS_DURING_AUCTION;
1600     }
1601 
1602     /** Default value of the url to fetch keys for KAnon encryption */
1603     String FLEDGE_AUCTION_SERVER_JOIN_KEY_FETCH_URI = "";
1604 
1605     /** Returns Uri to fetch join encryption key for fledge ad selection. */
getFledgeAuctionServerJoinKeyFetchUri()1606     default String getFledgeAuctionServerJoinKeyFetchUri() {
1607         return FLEDGE_AUCTION_SERVER_JOIN_KEY_FETCH_URI;
1608     }
1609 
1610     int FLEDGE_AUCTION_SERVER_AUCTION_KEY_SHARDING = 5;
1611 
1612     /** Returns Shard count for using auction key for fledge ad selection. */
getFledgeAuctionServerAuctionKeySharding()1613     default int getFledgeAuctionServerAuctionKeySharding() {
1614         return FLEDGE_AUCTION_SERVER_AUCTION_KEY_SHARDING;
1615     }
1616 
1617     long FLEDGE_AUCTION_SERVER_ENCRYPTION_KEY_MAX_AGE_SECONDS = TimeUnit.DAYS.toSeconds(14);
1618 
getFledgeAuctionServerEncryptionKeyMaxAgeSeconds()1619     default long getFledgeAuctionServerEncryptionKeyMaxAgeSeconds() {
1620         return FLEDGE_AUCTION_SERVER_ENCRYPTION_KEY_MAX_AGE_SECONDS;
1621     }
1622 
1623     int FLEDGE_AUCTION_SERVER_ENCRYPTION_ALGORITHM_KDF_ID = 0x0001;
1624 
getFledgeAuctionServerEncryptionAlgorithmKdfId()1625     default int getFledgeAuctionServerEncryptionAlgorithmKdfId() {
1626         return FLEDGE_AUCTION_SERVER_ENCRYPTION_ALGORITHM_KDF_ID;
1627     }
1628 
1629     int FLEDGE_AUCTION_SERVER_ENCRYPTION_ALGORITHM_KEM_ID = 0x0020;
1630 
getFledgeAuctionServerEncryptionAlgorithmKemId()1631     default int getFledgeAuctionServerEncryptionAlgorithmKemId() {
1632         return FLEDGE_AUCTION_SERVER_ENCRYPTION_ALGORITHM_KEM_ID;
1633     }
1634 
1635     int FLEDGE_AUCTION_SERVER_ENCRYPTION_ALGORITHM_AEAD_ID = 0x0002;
1636 
getFledgeAuctionServerEncryptionAlgorithmAeadId()1637     default int getFledgeAuctionServerEncryptionAlgorithmAeadId() {
1638         return FLEDGE_AUCTION_SERVER_ENCRYPTION_ALGORITHM_AEAD_ID;
1639     }
1640 
1641     int FLEDGE_AUCTION_SERVER_PAYLOAD_FORMAT_VERSION = 0;
1642 
1643     /** Returns the payload formatter version */
getFledgeAuctionServerPayloadFormatVersion()1644     default int getFledgeAuctionServerPayloadFormatVersion() {
1645         return FLEDGE_AUCTION_SERVER_PAYLOAD_FORMAT_VERSION;
1646     }
1647 
1648     long FLEDGE_AUCTION_SERVER_AUCTION_KEY_FETCH_TIMEOUT_MS = 3000;
1649 
getFledgeAuctionServerAuctionKeyFetchTimeoutMs()1650     default long getFledgeAuctionServerAuctionKeyFetchTimeoutMs() {
1651         return FLEDGE_AUCTION_SERVER_AUCTION_KEY_FETCH_TIMEOUT_MS;
1652     }
1653 
1654     long FLEDGE_AUCTION_SERVER_OVERALL_TIMEOUT_MS = 5000;
1655 
getFledgeAuctionServerOverallTimeoutMs()1656     default long getFledgeAuctionServerOverallTimeoutMs() {
1657         return FLEDGE_AUCTION_SERVER_OVERALL_TIMEOUT_MS;
1658     }
1659 
1660     boolean FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_JOB_ENABLED = false;
1661 
1662     /** Returns whether to run periodic job to fetch encryption keys. */
getFledgeAuctionServerBackgroundKeyFetchJobEnabled()1663     default boolean getFledgeAuctionServerBackgroundKeyFetchJobEnabled() {
1664         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_JOB_ENABLED;
1665     }
1666 
1667     int FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_NETWORK_CONNECT_TIMEOUT_MS =
1668             5 * 1000; // 5 seconds
1669 
1670     /**
1671      * Returns the maximum time in milliseconds allowed for a network call to open its initial
1672      * connection during the FLEDGE encryption key fetch.
1673      */
getFledgeAuctionServerBackgroundKeyFetchNetworkConnectTimeoutMs()1674     default int getFledgeAuctionServerBackgroundKeyFetchNetworkConnectTimeoutMs() {
1675         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_NETWORK_CONNECT_TIMEOUT_MS;
1676     }
1677 
1678     int FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_NETWORK_READ_TIMEOUT_MS =
1679             30 * 1000; // 30 seconds
1680 
1681     /**
1682      * Returns the maximum time in milliseconds allowed for a network call to read a response from a
1683      * target server during the FLEDGE encryption key fetch.
1684      */
getFledgeAuctionServerBackgroundKeyFetchNetworkReadTimeoutMs()1685     default int getFledgeAuctionServerBackgroundKeyFetchNetworkReadTimeoutMs() {
1686         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_NETWORK_READ_TIMEOUT_MS;
1687     }
1688 
1689     int FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_MAX_RESPONSE_SIZE_B = 2 * 1024; // 2 KiB
1690 
1691     /**
1692      * Returns the maximum size in bytes of a single key fetch response during the FLEDGE encryption
1693      * key fetch.
1694      */
getFledgeAuctionServerBackgroundKeyFetchMaxResponseSizeB()1695     default int getFledgeAuctionServerBackgroundKeyFetchMaxResponseSizeB() {
1696         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_MAX_RESPONSE_SIZE_B;
1697     }
1698 
1699     boolean FLEDGE_AUCTION_SERVER_BACKGROUND_AUCTION_KEY_FETCH_ENABLED = false;
1700 
1701     /** Returns whether to run periodic job to fetch AUCTION keys. */
getFledgeAuctionServerBackgroundAuctionKeyFetchEnabled()1702     default boolean getFledgeAuctionServerBackgroundAuctionKeyFetchEnabled() {
1703         return getFledgeAuctionServerBackgroundKeyFetchJobEnabled()
1704                 && FLEDGE_AUCTION_SERVER_BACKGROUND_AUCTION_KEY_FETCH_ENABLED;
1705     }
1706 
1707     boolean FLEDGE_AUCTION_SERVER_BACKGROUND_JOIN_KEY_FETCH_ENABLED = false;
1708 
1709     /** Returns whether to run periodic job to fetch JOIN keys. */
getFledgeAuctionServerBackgroundJoinKeyFetchEnabled()1710     default boolean getFledgeAuctionServerBackgroundJoinKeyFetchEnabled() {
1711         return getFledgeAuctionServerBackgroundKeyFetchJobEnabled()
1712                 && FLEDGE_AUCTION_SERVER_BACKGROUND_JOIN_KEY_FETCH_ENABLED;
1713     }
1714 
1715     long FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_MAX_RUNTIME_MS = TimeUnit.MINUTES.toMillis(5);
1716 
1717     /**
1718      * Returns the maximum amount of time (in milliseconds) each Ad selection Background key Fetch
1719      * job is allowed to run.
1720      */
getFledgeAuctionServerBackgroundKeyFetchJobMaxRuntimeMs()1721     default long getFledgeAuctionServerBackgroundKeyFetchJobMaxRuntimeMs() {
1722         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_MAX_RUNTIME_MS;
1723     }
1724 
1725     long FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_JOB_PERIOD_MS = TimeUnit.HOURS.toMillis(24);
1726 
1727     /**
1728      * Returns the best effort max time (in milliseconds) between each Background Key Fetch job run.
1729      */
getFledgeAuctionServerBackgroundKeyFetchJobPeriodMs()1730     default long getFledgeAuctionServerBackgroundKeyFetchJobPeriodMs() {
1731         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_JOB_PERIOD_MS;
1732     }
1733 
1734     long FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_JOB_FLEX_MS = TimeUnit.HOURS.toMillis(2);
1735 
1736     /**
1737      * Returns the amount of flex (in milliseconds) around the end of each period to run each
1738      * Background Key Fetch job.
1739      */
getFledgeAuctionServerBackgroundKeyFetchJobFlexMs()1740     default long getFledgeAuctionServerBackgroundKeyFetchJobFlexMs() {
1741         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_JOB_FLEX_MS;
1742     }
1743 
1744     boolean FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_ON_EMPTY_DB_AND_IN_ADVANCE_ENABLED = false;
1745 
1746     /**
1747      * Returns whether that the periodic job to fetch encryption keys should force refresh if the
1748      * database is empty or if the keys are within
1749      * FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_IN_ADVANCE_INTERVAL_MS to expire.
1750      */
getFledgeAuctionServerBackgroundKeyFetchOnEmptyDbAndInAdvanceEnabled()1751     default boolean getFledgeAuctionServerBackgroundKeyFetchOnEmptyDbAndInAdvanceEnabled() {
1752         return getFledgeAuctionServerBackgroundKeyFetchJobEnabled()
1753                 && FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_ON_EMPTY_DB_AND_IN_ADVANCE_ENABLED;
1754     }
1755 
1756     long FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_IN_ADVANCE_INTERVAL_MS =
1757             TimeUnit.HOURS.toMillis(24);
1758 
1759     /**
1760      * Returns the interval at which a key is considered to be almost expired and preventive
1761      * refreshed
1762      */
getFledgeAuctionServerBackgroundKeyFetchInAdvanceIntervalMs()1763     default long getFledgeAuctionServerBackgroundKeyFetchInAdvanceIntervalMs() {
1764         return FLEDGE_AUCTION_SERVER_BACKGROUND_KEY_FETCH_IN_ADVANCE_INTERVAL_MS;
1765     }
1766 
1767     boolean FLEDGE_AUCTION_SERVER_ENABLE_DEBUG_REPORTING = true;
1768 
getFledgeAuctionServerEnableDebugReporting()1769     default boolean getFledgeAuctionServerEnableDebugReporting() {
1770         return FLEDGE_AUCTION_SERVER_ENABLE_DEBUG_REPORTING;
1771     }
1772 
1773     long DEFAULT_AUCTION_SERVER_AD_ID_FETCHER_TIMEOUT_MS = 20;
1774 
1775     /**
1776      * Returns configured timeout value for {@link
1777      * com.android.adservices.service.adselection.AdIdFetcher} logic for server auctions.
1778      *
1779      * <p>The intended goal is to override this value for tests.
1780      *
1781      * <p>Returns Timeout in mills.
1782      */
getFledgeAuctionServerAdIdFetcherTimeoutMs()1783     default long getFledgeAuctionServerAdIdFetcherTimeoutMs() {
1784         return DEFAULT_AUCTION_SERVER_AD_ID_FETCHER_TIMEOUT_MS;
1785     }
1786 
1787     /** Default value for feature flag for PAS unlimited egress in Server auctions. */
1788     boolean DEFAULT_FLEDGE_AUCTION_SERVER_ENABLE_PAS_UNLIMITED_EGRESS = false;
1789 
1790     /**
1791      * @return feature flag to enable PAS unlimited egress in Server auctions
1792      */
getFledgeAuctionServerEnablePasUnlimitedEgress()1793     default boolean getFledgeAuctionServerEnablePasUnlimitedEgress() {
1794         return DEFAULT_FLEDGE_AUCTION_SERVER_ENABLE_PAS_UNLIMITED_EGRESS;
1795     }
1796 
1797     boolean FLEDGE_AUCTION_SERVER_AD_RENDER_ID_ENABLED = false;
1798     long FLEDGE_AUCTION_SERVER_AD_RENDER_ID_MAX_LENGTH = 12L;
1799 
1800     /** Returns whether ad render id is enabled. */
getFledgeAuctionServerAdRenderIdEnabled()1801     default boolean getFledgeAuctionServerAdRenderIdEnabled() {
1802         return FLEDGE_AUCTION_SERVER_AD_RENDER_ID_ENABLED;
1803     }
1804 
1805     /** Returns the max length of Ad Render Id. */
getFledgeAuctionServerAdRenderIdMaxLength()1806     default long getFledgeAuctionServerAdRenderIdMaxLength() {
1807         return FLEDGE_AUCTION_SERVER_AD_RENDER_ID_MAX_LENGTH;
1808     }
1809 
1810     boolean FLEDGE_AUCTION_SERVER_REQUEST_FLAGS_ENABLED = false;
1811 
1812     /** Returns whether the server auction request flags are enabled */
getFledgeAuctionServerRequestFlagsEnabled()1813     default boolean getFledgeAuctionServerRequestFlagsEnabled() {
1814         return FLEDGE_AUCTION_SERVER_REQUEST_FLAGS_ENABLED;
1815     }
1816 
1817     boolean FLEDGE_AUCTION_SERVER_OMIT_ADS_ENABLED = false;
1818 
1819     /** Returns whether the omit-ads flag is enabled for the server auction. */
getFledgeAuctionServerOmitAdsEnabled()1820     default boolean getFledgeAuctionServerOmitAdsEnabled() {
1821         return FLEDGE_AUCTION_SERVER_OMIT_ADS_ENABLED;
1822     }
1823 
1824     boolean FLEDGE_AUCTION_SERVER_MULTI_CLOUD_ENABLED = false;
1825 
getFledgeAuctionServerMultiCloudEnabled()1826     default boolean getFledgeAuctionServerMultiCloudEnabled() {
1827         return FLEDGE_AUCTION_SERVER_MULTI_CLOUD_ENABLED;
1828     }
1829 
1830     String FLEDGE_AUCTION_SERVER_COORDINATOR_URL_ALLOWLIST =
1831             "https://publickeyservice-v150"
1832                 + ".coordinator-a.bas-gcp.pstest.dev/.well-known/protected-auction/v1/public-keys";
1833 
getFledgeAuctionServerCoordinatorUrlAllowlist()1834     default String getFledgeAuctionServerCoordinatorUrlAllowlist() {
1835         return FLEDGE_AUCTION_SERVER_COORDINATOR_URL_ALLOWLIST;
1836     }
1837 
1838     @FeatureFlag
1839     boolean FLEDGE_AUCTION_SERVER_GET_AD_SELECTION_DATA_PAYLOAD_METRICS_ENABLED = false;
1840 
1841     /** Returns whether the fledge GetAdSelectionData payload metrics are enabled. */
getFledgeAuctionServerGetAdSelectionDataPayloadMetricsEnabled()1842     default boolean getFledgeAuctionServerGetAdSelectionDataPayloadMetricsEnabled() {
1843         return FLEDGE_AUCTION_SERVER_GET_AD_SELECTION_DATA_PAYLOAD_METRICS_ENABLED;
1844     }
1845 
1846     @FeatureFlag boolean FLEDGE_GET_AD_SELECTION_DATA_SELLER_CONFIGURATION_ENABLED = false;
1847 
1848     /** Returns whether the seller configuration feature for getAdSelectionData is enabled. */
getFledgeGetAdSelectionDataSellerConfigurationEnabled()1849     default boolean getFledgeGetAdSelectionDataSellerConfigurationEnabled() {
1850         return FLEDGE_GET_AD_SELECTION_DATA_SELLER_CONFIGURATION_ENABLED;
1851     }
1852 
1853     @FeatureFlag int FLEDGE_GET_AD_SELECTION_DATA_BUYER_INPUT_CREATOR_VERSION = 0;
1854 
1855     /** Returns the getAdSelectionData data buyer input creator version */
getFledgeGetAdSelectionDataBuyerInputCreatorVersion()1856     default int getFledgeGetAdSelectionDataBuyerInputCreatorVersion() {
1857         return FLEDGE_GET_AD_SELECTION_DATA_BUYER_INPUT_CREATOR_VERSION;
1858     }
1859 
1860     // Protected signals cleanup feature flag disabled by default
1861     boolean PROTECTED_SIGNALS_CLEANUP_ENABLED = false;
1862 
1863     /** Returns {@code true} if protected signals cleanup is enabled. */
getProtectedSignalsCleanupEnabled()1864     default boolean getProtectedSignalsCleanupEnabled() {
1865         return PROTECTED_SIGNALS_CLEANUP_ENABLED;
1866     }
1867 
1868     boolean ADSERVICES_ENABLED = false;
1869 
getAdServicesEnabled()1870     default boolean getAdServicesEnabled() {
1871         return ADSERVICES_ENABLED;
1872     }
1873 
1874     /**
1875      * The number of epoch to look back to do garbage collection for old epoch data. Assume current
1876      * Epoch is T, then any epoch data of (T-NUMBER_OF_EPOCHS_TO_KEEP_IN_HISTORY-1) (inclusive)
1877      * should be erased
1878      */
1879     int NUMBER_OF_EPOCHS_TO_KEEP_IN_HISTORY = TOPICS_NUMBER_OF_LOOK_BACK_EPOCHS;
1880 
1881     /*
1882      * Return the number of epochs to keep in the history
1883      */
getNumberOfEpochsToKeepInHistory()1884     default int getNumberOfEpochsToKeepInHistory() {
1885         return NUMBER_OF_EPOCHS_TO_KEEP_IN_HISTORY;
1886     }
1887 
1888     /** Downloader Connection Timeout in Milliseconds. */
1889     int DOWNLOADER_CONNECTION_TIMEOUT_MS = 10 * 1000; // 10 seconds.
1890 
1891     /*
1892      * Return the Downloader Connection Timeout in Milliseconds.
1893      */
getDownloaderConnectionTimeoutMs()1894     default int getDownloaderConnectionTimeoutMs() {
1895         return DOWNLOADER_CONNECTION_TIMEOUT_MS;
1896     }
1897 
1898     /** Downloader Read Timeout in Milliseconds. */
1899     int DOWNLOADER_READ_TIMEOUT_MS = 10 * 1000; // 10 seconds.
1900 
1901     /** Returns the Downloader Read Timeout in Milliseconds. */
getDownloaderReadTimeoutMs()1902     default int getDownloaderReadTimeoutMs() {
1903         return DOWNLOADER_READ_TIMEOUT_MS;
1904     }
1905 
1906     /** Downloader max download threads. */
1907     int DOWNLOADER_MAX_DOWNLOAD_THREADS = 2;
1908 
1909     /** Returns the Downloader Read Timeout in Milliseconds. */
getDownloaderMaxDownloadThreads()1910     default int getDownloaderMaxDownloadThreads() {
1911         return DOWNLOADER_MAX_DOWNLOAD_THREADS;
1912     }
1913 
1914     /** MDD Topics API Classifier Manifest Url. Topics classifier v2-3. Build_id = 1467. */
1915     String MDD_TOPICS_CLASSIFIER_MANIFEST_FILE_URL =
1916             "https://www.gstatic.com/mdi-serving/rubidium-adservices-topics-classifier/1467/80c34503413cea9ea44cbe94cd38dabc44ea8d70";
1917 
getMddTopicsClassifierManifestFileUrl()1918     default String getMddTopicsClassifierManifestFileUrl() {
1919         return MDD_TOPICS_CLASSIFIER_MANIFEST_FILE_URL;
1920     }
1921 
1922     boolean CONSENT_MANAGER_LAZY_ENABLE_MODE = true;
1923 
getConsentManagerLazyEnableMode()1924     default boolean getConsentManagerLazyEnableMode() {
1925         return CONSENT_MANAGER_LAZY_ENABLE_MODE;
1926     }
1927 
1928     boolean CONSENT_ALREADY_INTERACTED_FIX_ENABLE = true;
1929 
getConsentAlreadyInteractedEnableMode()1930     default boolean getConsentAlreadyInteractedEnableMode() {
1931         return CONSENT_ALREADY_INTERACTED_FIX_ENABLE;
1932     }
1933 
1934     long CONSENT_NOTIFICATION_INTERVAL_BEGIN_MS =
1935             /* hours */ 9 * /* minutes */ 60 * /* seconds */ 60 * /* milliseconds */ 1000; // 9 AM
1936 
getConsentNotificationIntervalBeginMs()1937     default long getConsentNotificationIntervalBeginMs() {
1938         return CONSENT_NOTIFICATION_INTERVAL_BEGIN_MS;
1939     }
1940 
1941     long CONSENT_NOTIFICATION_INTERVAL_END_MS =
1942             /* hours */ 17 * /* minutes */ 60 * /* seconds */ 60 * /* milliseconds */ 1000; // 5 PM
1943 
getConsentNotificationIntervalEndMs()1944     default long getConsentNotificationIntervalEndMs() {
1945         return CONSENT_NOTIFICATION_INTERVAL_END_MS;
1946     }
1947 
1948     long CONSENT_NOTIFICATION_MINIMAL_DELAY_BEFORE_INTERVAL_ENDS =
1949             /* minutes */ 60 * /* seconds */ 60 * /* milliseconds */ 1000; // 1 hour
1950 
getConsentNotificationMinimalDelayBeforeIntervalEnds()1951     default long getConsentNotificationMinimalDelayBeforeIntervalEnds() {
1952         return CONSENT_NOTIFICATION_MINIMAL_DELAY_BEFORE_INTERVAL_ENDS;
1953     }
1954 
1955     @FeatureFlag(DEBUG)
1956     boolean CONSENT_NOTIFICATION_DEBUG_MODE = false;
1957 
getConsentNotificationDebugMode()1958     default boolean getConsentNotificationDebugMode() {
1959         return DebugFlags.getInstance().getConsentNotificationDebugMode();
1960     }
1961 
1962     /** The consent notification activity debug mode is off by default. */
1963     @FeatureFlag(DEBUG)
1964     boolean CONSENT_NOTIFICATION_ACTIVITY_DEBUG_MODE = false;
1965 
1966     /** Returns the consent notification activity debug mode. */
getConsentNotificationActivityDebugMode()1967     default boolean getConsentNotificationActivityDebugMode() {
1968         return DebugFlags.getInstance().getConsentNotificationActivityDebugMode();
1969     }
1970 
1971     @FeatureFlag(DEBUG)
1972     boolean CONSENT_NOTIFIED_DEBUG_MODE = false;
1973 
1974     /** Returns whether to suppress consent notified state. */
getConsentNotifiedDebugMode()1975     default boolean getConsentNotifiedDebugMode() {
1976         return DebugFlags.getInstance().getConsentNotifiedDebugMode();
1977     }
1978 
1979     @FeatureFlag(DEBUG)
1980     boolean CONSENT_MANAGER_DEBUG_MODE = false;
1981 
getConsentManagerDebugMode()1982     default boolean getConsentManagerDebugMode() {
1983         return DebugFlags.getInstance().getConsentManagerDebugMode();
1984     }
1985 
1986     @FeatureFlag(DEBUG)
1987     boolean DEFAULT_CONSENT_MANAGER_OTA_DEBUG_MODE = false;
1988 
1989     /** When enabled, the device is treated as OTA device. */
getConsentManagerOTADebugMode()1990     default boolean getConsentManagerOTADebugMode() {
1991         return DebugFlags.getInstance().getConsentManagerOTADebugMode();
1992     }
1993 
1994     boolean DEFAULT_RVC_POST_OTA_NOTIF_AGE_CHECK = false;
1995 
1996     /** When enabled, perform age check in rvc post ota notification channel. */
getRvcPostOtaNotifAgeCheck()1997     default boolean getRvcPostOtaNotifAgeCheck() {
1998         return DEFAULT_RVC_POST_OTA_NOTIF_AGE_CHECK;
1999     }
2000 
2001     /** Available sources of truth to get consent for PPAPI. */
2002     @IntDef(
2003             flag = true,
2004             value = {
2005                 SYSTEM_SERVER_ONLY,
2006                 PPAPI_ONLY,
2007                 PPAPI_AND_SYSTEM_SERVER,
2008                 APPSEARCH_ONLY,
2009                 PPAPI_AND_ADEXT_SERVICE,
2010             })
2011     @Retention(RetentionPolicy.SOURCE)
2012     @interface ConsentSourceOfTruth {}
2013 
2014     /** Write and read consent from system server only. */
2015     int SYSTEM_SERVER_ONLY = FlagsConstants.SYSTEM_SERVER_ONLY;
2016 
2017     /** Write and read consent from PPAPI only */
2018     int PPAPI_ONLY = FlagsConstants.PPAPI_ONLY;
2019 
2020     /** Write consent to both PPAPI and system server. Read consent from system server only. */
2021     int PPAPI_AND_SYSTEM_SERVER = FlagsConstants.PPAPI_AND_SYSTEM_SERVER;
2022 
2023     /**
2024      * Write consent data to AppSearch only. To store consent data in AppSearch the flag
2025      * enable_appsearch_consent_data must also be true. This ensures that both writes and reads can
2026      * happen to/from AppSearch. The writes are done by code on S-, while reads are done from code
2027      * running on S- for all consent requests and on T+ once after OTA.
2028      */
2029     int APPSEARCH_ONLY = FlagsConstants.APPSEARCH_ONLY;
2030 
2031     /**
2032      * Read and write data that need to be rollback-safe from AdServicesExtDataStorageService; rest
2033      * can be handled by PPAPI_API only. This is intended to be used on Android R as AppSearch and
2034      * system server are unavailable.
2035      */
2036     int PPAPI_AND_ADEXT_SERVICE = FlagsConstants.PPAPI_AND_ADEXT_SERVICE;
2037 
2038     /**
2039      * Consent source of truth intended to be used by default. On S devices, there is no AdServices
2040      * code running in the system server, so the default is APPSEARCH_ONLY. On R devices, there is
2041      * no system server and appseach, so the default is PPAPI_AND_ADEXT_SERVICE_ONLY.
2042      */
2043     @ConsentSourceOfTruth
2044     int DEFAULT_CONSENT_SOURCE_OF_TRUTH =
2045             SdkLevel.isAtLeastT()
2046                     ? PPAPI_AND_SYSTEM_SERVER
2047                     : (SdkLevel.isAtLeastS() ? APPSEARCH_ONLY : PPAPI_AND_ADEXT_SERVICE);
2048 
2049     /** Returns the consent source of truth currently used for PPAPI. */
2050     @ConsentSourceOfTruth
getConsentSourceOfTruth()2051     default int getConsentSourceOfTruth() {
2052         return DEFAULT_CONSENT_SOURCE_OF_TRUTH;
2053     }
2054 
2055     /**
2056      * Blocked topics source of truth intended to be used by default. On S devices, there is no
2057      * AdServices code running in the system server, so the default is APPSEARCH_ONLY. On R devices,
2058      * there is no system server and appseach, so the default is PPAPI_ADEXT_SERVICE_ONLY. However,
2059      * note that topics is not supported on R.
2060      */
2061     @ConsentSourceOfTruth
2062     int DEFAULT_BLOCKED_TOPICS_SOURCE_OF_TRUTH =
2063             SdkLevel.isAtLeastT()
2064                     ? PPAPI_AND_SYSTEM_SERVER
2065                     : (SdkLevel.isAtLeastS() ? APPSEARCH_ONLY : PPAPI_AND_ADEXT_SERVICE);
2066 
2067     /** Returns the blocked topics source of truth currently used for PPAPI */
2068     @ConsentSourceOfTruth
getBlockedTopicsSourceOfTruth()2069     default int getBlockedTopicsSourceOfTruth() {
2070         return DEFAULT_BLOCKED_TOPICS_SOURCE_OF_TRUTH;
2071     }
2072 
2073     /**
2074      * The debug and release SHA certificates of the AdServices APK. This is required when writing
2075      * consent data to AppSearch in order to allow reads from T+ APK. This is a comma separated
2076      * list.
2077      */
2078     String ADSERVICES_APK_SHA_CERTIFICATE =
2079             "686d5c450e00ebe600f979300a29234644eade42f24ede07a073f2bc6b94a3a2," // debug
2080                     + "80f8fbb9a026807f58d98dbc28bf70724d8f66bbfcec997c6bdc0102c3230dee"; // release
2081 
2082     /** Only App signatures belonging to this Allow List can use PP APIs. */
getAdservicesApkShaCertificate()2083     default String getAdservicesApkShaCertificate() {
2084         return ADSERVICES_APK_SHA_CERTIFICATE;
2085     }
2086 
2087     // Group of All Killswitches
2088 
2089     /**
2090      * Global PP API Kill Switch. This overrides all other killswitches. The default value is false
2091      * which means the PP API is enabled. This flag is used for emergency turning off the whole PP
2092      * API.
2093      */
2094     // Starting M-2023-05, global kill switch is enabled in the binary. Prior to this (namely in
2095     // M-2022-11), the value of this flag in the binary was false.
2096     @FeatureFlag(LEGACY_KILL_SWITCH_GLOBAL)
2097     boolean GLOBAL_KILL_SWITCH = true;
2098 
getGlobalKillSwitch()2099     default boolean getGlobalKillSwitch() {
2100         return GLOBAL_KILL_SWITCH;
2101     }
2102 
2103     // MEASUREMENT Killswitches
2104 
2105     /**
2106      * Measurement Kill Switch. This overrides all specific measurement kill switch. The default
2107      * value is {@code false} which means that Measurement is enabled.
2108      *
2109      * <p>This flag is used for emergency turning off the whole Measurement API.
2110      */
2111     @FeatureFlag(LEGACY_KILL_SWITCH_RAMPED_UP)
2112     boolean MEASUREMENT_KILL_SWITCH = false;
2113 
2114     /**
2115      * @deprecated - TODO(b/325074749): remove once all methods that call it are unit-tested and
2116      *     changed to use !getMeasurementEnabled()
2117      */
2118     @Deprecated
2119     @VisibleForTesting
getLegacyMeasurementKillSwitch()2120     default boolean getLegacyMeasurementKillSwitch() {
2121         return getGlobalKillSwitch() || MEASUREMENT_KILL_SWITCH;
2122     }
2123 
2124     /**
2125      * Returns whether the Global Measurement feature is enabled. Measurement will be disabled if
2126      * either the Global Kill Switch or the Measurement Kill Switch value is {@code true}.
2127      */
getMeasurementEnabled()2128     default boolean getMeasurementEnabled() {
2129         return getGlobalKillSwitch() ? false : !MEASUREMENT_KILL_SWITCH;
2130     }
2131 
2132     /**
2133      * Measurement API Delete Registrations Kill Switch. The default value is false which means
2134      * Delete Registrations API is enabled. This flag is used for emergency turning off the Delete
2135      * Registrations API.
2136      */
2137     boolean MEASUREMENT_API_DELETE_REGISTRATIONS_KILL_SWITCH = false;
2138 
2139     /**
2140      * Returns the kill switch value for Measurement API Delete Registrations. The API will be
2141      * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API
2142      * Delete Registration Kill Switch value is true.
2143      */
getMeasurementApiDeleteRegistrationsKillSwitch()2144     default boolean getMeasurementApiDeleteRegistrationsKillSwitch() {
2145         return getLegacyMeasurementKillSwitch() || MEASUREMENT_API_DELETE_REGISTRATIONS_KILL_SWITCH;
2146     }
2147 
2148     /**
2149      * Measurement API Status Kill Switch. The default value is false which means Status API is
2150      * enabled. This flag is used for emergency turning off the Status API.
2151      */
2152     boolean MEASUREMENT_API_STATUS_KILL_SWITCH = false;
2153 
2154     /**
2155      * Returns the kill switch value for Measurement API Status. The API will be disabled if either
2156      * the Global Kill Switch, Measurement Kill Switch, or the Measurement API Status Kill Switch
2157      * value is true.
2158      */
getMeasurementApiStatusKillSwitch()2159     default boolean getMeasurementApiStatusKillSwitch() {
2160         return getLegacyMeasurementKillSwitch() || MEASUREMENT_API_STATUS_KILL_SWITCH;
2161     }
2162 
2163     /**
2164      * Measurement API Register Source Kill Switch. The default value is false which means Register
2165      * Source API is enabled. This flag is used for emergency turning off the Register Source API.
2166      */
2167     boolean MEASUREMENT_API_REGISTER_SOURCE_KILL_SWITCH = false;
2168 
2169     /**
2170      * Returns the kill switch value for Measurement API Register Source. The API will be disabled
2171      * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API Register
2172      * Source Kill Switch value is true.
2173      */
getMeasurementApiRegisterSourceKillSwitch()2174     default boolean getMeasurementApiRegisterSourceKillSwitch() {
2175         return getLegacyMeasurementKillSwitch() || MEASUREMENT_API_REGISTER_SOURCE_KILL_SWITCH;
2176     }
2177 
2178     /**
2179      * Measurement API Register Trigger Kill Switch. The default value is false which means Register
2180      * Trigger API is enabled. This flag is used for emergency turning off the Register Trigger API.
2181      */
2182     boolean MEASUREMENT_API_REGISTER_TRIGGER_KILL_SWITCH = false;
2183 
2184     /**
2185      * Returns the kill switch value for Measurement API Register Trigger. The API will be disabled
2186      * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API Register
2187      * Trigger Kill Switch value is true.
2188      */
getMeasurementApiRegisterTriggerKillSwitch()2189     default boolean getMeasurementApiRegisterTriggerKillSwitch() {
2190         return getLegacyMeasurementKillSwitch() || MEASUREMENT_API_REGISTER_TRIGGER_KILL_SWITCH;
2191     }
2192 
2193     /**
2194      * Measurement API Register Web Source Kill Switch. The default value is false which means
2195      * Register Web Source API is enabled. This flag is used for emergency turning off the Register
2196      * Web Source API.
2197      */
2198     boolean MEASUREMENT_API_REGISTER_WEB_SOURCE_KILL_SWITCH = false;
2199 
2200     /**
2201      * Returns the kill switch value for Measurement API Register Web Source. The API will be
2202      * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API
2203      * Register Web Source Kill Switch value is true.
2204      */
getMeasurementApiRegisterWebSourceKillSwitch()2205     default boolean getMeasurementApiRegisterWebSourceKillSwitch() {
2206         return getLegacyMeasurementKillSwitch() || MEASUREMENT_API_REGISTER_WEB_SOURCE_KILL_SWITCH;
2207     }
2208 
2209     /**
2210      * Measurement API Register Sources Kill Switch. The default value is false which means Register
2211      * Sources API is enabled. This flag is used for emergency turning off the Register Sources API.
2212      */
2213     boolean MEASUREMENT_API_REGISTER_SOURCES_KILL_SWITCH = false;
2214 
2215     /**
2216      * Returns the kill switch value for Measurement API Register Sources. The API will be disabled
2217      * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API Register
2218      * Sources Kill Switch value is true.
2219      */
getMeasurementApiRegisterSourcesKillSwitch()2220     default boolean getMeasurementApiRegisterSourcesKillSwitch() {
2221         return getLegacyMeasurementKillSwitch() || MEASUREMENT_API_REGISTER_SOURCES_KILL_SWITCH;
2222     }
2223 
2224     /**
2225      * Measurement API Register Web Trigger Kill Switch. The default value is false which means
2226      * Register Web Trigger API is enabled. This flag is used for emergency turning off the Register
2227      * Web Trigger API.
2228      */
2229     boolean MEASUREMENT_API_REGISTER_WEB_TRIGGER_KILL_SWITCH = false;
2230 
2231     /**
2232      * Returns the kill switch value for Measurement API Register Web Trigger. The API will be
2233      * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API
2234      * Register Web Trigger Kill Switch value is true.
2235      */
getMeasurementApiRegisterWebTriggerKillSwitch()2236     default boolean getMeasurementApiRegisterWebTriggerKillSwitch() {
2237         return getLegacyMeasurementKillSwitch() || MEASUREMENT_API_REGISTER_WEB_TRIGGER_KILL_SWITCH;
2238     }
2239 
2240     /**
2241      * Measurement Job Aggregate Fallback Reporting Kill Switch. The default value is false which
2242      * means Aggregate Fallback Reporting Job is enabled. This flag is used for emergency turning
2243      * off the Aggregate Fallback Reporting Job.
2244      */
2245     boolean MEASUREMENT_JOB_AGGREGATE_FALLBACK_REPORTING_KILL_SWITCH = false;
2246 
2247     /**
2248      * Returns the kill switch value for Measurement Job Aggregate Fallback Reporting. The API will
2249      * be disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job
2250      * Aggregate Fallback Reporting Kill Switch value is true.
2251      */
getMeasurementJobAggregateFallbackReportingKillSwitch()2252     default boolean getMeasurementJobAggregateFallbackReportingKillSwitch() {
2253         return getLegacyMeasurementKillSwitch()
2254                 || MEASUREMENT_JOB_AGGREGATE_FALLBACK_REPORTING_KILL_SWITCH;
2255     }
2256 
2257     /**
2258      * Measurement Job Aggregate Reporting Kill Switch. The default value is false which means
2259      * Aggregate Reporting Job is enabled. This flag is used for emergency turning off the Aggregate
2260      * Reporting Job.
2261      */
2262     boolean MEASUREMENT_JOB_AGGREGATE_REPORTING_KILL_SWITCH = false;
2263 
2264     /**
2265      * Returns the kill switch value for Measurement Job Aggregate Reporting. The API will be
2266      * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job
2267      * Aggregate Reporting Kill Switch value is true.
2268      */
getMeasurementJobAggregateReportingKillSwitch()2269     default boolean getMeasurementJobAggregateReportingKillSwitch() {
2270         return getLegacyMeasurementKillSwitch() || MEASUREMENT_JOB_AGGREGATE_REPORTING_KILL_SWITCH;
2271     }
2272 
2273     /**
2274      * Measurement Immediate Aggregate Reporting Job Kill Switch. The default value is true which
2275      * means Immediate Aggregate Reporting Job is disabled. This flag is used for emergency turning
2276      * off of the Immediate Aggregate Reporting Job.
2277      */
2278     boolean MEASUREMENT_JOB_IMMEDIATE_AGGREGATE_REPORTING_KILL_SWITCH = true;
2279 
2280     /**
2281      * Returns the kill switch value for Measurement Immediate Aggregate Reporting Job. The API will
2282      * be disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job
2283      * Immediate Aggregate Reporting Kill Switch value is true.
2284      */
getMeasurementJobImmediateAggregateReportingKillSwitch()2285     default boolean getMeasurementJobImmediateAggregateReportingKillSwitch() {
2286         return !getMeasurementEnabled()
2287                 || MEASUREMENT_JOB_IMMEDIATE_AGGREGATE_REPORTING_KILL_SWITCH;
2288     }
2289 
2290     /**
2291      * Measurement Job Attribution Kill Switch. The default value is false which means Attribution
2292      * Job is enabled. This flag is used for emergency turning off the Attribution Job.
2293      */
2294     boolean MEASUREMENT_JOB_ATTRIBUTION_KILL_SWITCH = false;
2295 
2296     /**
2297      * Returns the kill switch value for Measurement Job Attribution. The API will be disabled if
2298      * either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Attribution
2299      * Kill Switch value is true.
2300      */
getMeasurementJobAttributionKillSwitch()2301     default boolean getMeasurementJobAttributionKillSwitch() {
2302         return getLegacyMeasurementKillSwitch() || MEASUREMENT_JOB_ATTRIBUTION_KILL_SWITCH;
2303     }
2304 
2305     /**
2306      * Measurement Job Delete Expired Kill Switch. The default value is false which means Delete
2307      * Expired Job is enabled. This flag is used for emergency turning off the Delete Expired Job.
2308      */
2309     boolean MEASUREMENT_JOB_DELETE_EXPIRED_KILL_SWITCH = false;
2310 
2311     /**
2312      * Returns the kill switch value for Measurement Job Delete Expired. The API will be disabled if
2313      * either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Delete Expired
2314      * Kill Switch value is true.
2315      */
getMeasurementJobDeleteExpiredKillSwitch()2316     default boolean getMeasurementJobDeleteExpiredKillSwitch() {
2317         return getLegacyMeasurementKillSwitch() || MEASUREMENT_JOB_DELETE_EXPIRED_KILL_SWITCH;
2318     }
2319 
2320     /**
2321      * Measurement Job Delete Uninstalled Kill Switch. The default value is false which means Delete
2322      * Uninstalled Job is enabled. This flag is used for emergency turning off the Delete
2323      * Uninstalled Job.
2324      */
2325     boolean MEASUREMENT_JOB_DELETE_UNINSTALLED_KILL_SWITCH = false;
2326 
2327     /**
2328      * Returns the kill switch value for Measurement Job Delete Uninstalled. The API will be
2329      * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job
2330      * Delete Uninstalled Kill Switch value is true.
2331      */
getMeasurementJobDeleteUninstalledKillSwitch()2332     default boolean getMeasurementJobDeleteUninstalledKillSwitch() {
2333         return getLegacyMeasurementKillSwitch() || MEASUREMENT_JOB_DELETE_UNINSTALLED_KILL_SWITCH;
2334     }
2335 
2336     /**
2337      * Measurement Job Event Fallback Reporting Kill Switch. The default value is false which means
2338      * Event Fallback Reporting Job is enabled. This flag is used for emergency turning off the
2339      * Event Fallback Reporting Job.
2340      */
2341     boolean MEASUREMENT_JOB_EVENT_FALLBACK_REPORTING_KILL_SWITCH = false;
2342 
2343     /**
2344      * Returns the kill switch value for Measurement Job Event Fallback Reporting. The API will be
2345      * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job
2346      * Event Fallback Reporting Kill Switch value is true.
2347      */
getMeasurementJobEventFallbackReportingKillSwitch()2348     default boolean getMeasurementJobEventFallbackReportingKillSwitch() {
2349         return getLegacyMeasurementKillSwitch()
2350                 || MEASUREMENT_JOB_EVENT_FALLBACK_REPORTING_KILL_SWITCH;
2351     }
2352 
2353     /**
2354      * Measurement Job Event Reporting Kill Switch. The default value is false which means Event
2355      * Reporting Job is enabled. This flag is used for emergency turning off the Event Reporting
2356      * Job.
2357      */
2358     boolean MEASUREMENT_JOB_EVENT_REPORTING_KILL_SWITCH = false;
2359 
2360     /**
2361      * Returns the kill switch value for Measurement Job Event Reporting. The API will be disabled
2362      * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Event
2363      * Reporting Kill Switch value is true.
2364      */
getMeasurementJobEventReportingKillSwitch()2365     default boolean getMeasurementJobEventReportingKillSwitch() {
2366         return getLegacyMeasurementKillSwitch() || MEASUREMENT_JOB_EVENT_REPORTING_KILL_SWITCH;
2367     }
2368 
2369     /**
2370      * Measurement Job Debug Reporting Kill Switch. The default value is false which means Debug
2371      * Reporting Job is enabled. This flag is used for emergency turning off the Debug Reporting
2372      * Job.
2373      */
2374     boolean MEASUREMENT_JOB_DEBUG_REPORTING_KILL_SWITCH = false;
2375 
2376     /**
2377      * Returns the kill switch value for Measurement Job Debug Reporting. The Job will be disabled
2378      * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Debug
2379      * Reporting Kill Switch value is true.
2380      */
getMeasurementJobDebugReportingKillSwitch()2381     default boolean getMeasurementJobDebugReportingKillSwitch() {
2382         return getLegacyMeasurementKillSwitch() || MEASUREMENT_JOB_DEBUG_REPORTING_KILL_SWITCH;
2383     }
2384 
2385     /**
2386      * Measurement Debug Reporting Fallback Job kill Switch. The default value is false which means
2387      * the job is enabled. This flag is used for emergency turning off the Debug Reporting Fallback
2388      * Job.
2389      */
2390     boolean MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_KILL_SWITCH = false;
2391 
2392     /**
2393      * Returns the kill switch value for the Measurement Debug Reporting Fallback Job. The API will
2394      * be disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement
2395      * Debug Reporting Fallback Job kill switch value is true.
2396      */
getMeasurementDebugReportingFallbackJobKillSwitch()2397     default boolean getMeasurementDebugReportingFallbackJobKillSwitch() {
2398         return getLegacyMeasurementKillSwitch()
2399                 || MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_KILL_SWITCH;
2400     }
2401 
2402     /**
2403      * Measurement Verbose Debug Reporting Fallback Job kill Switch. The default value is false
2404      * which means the job is enabled. This flag is used for emergency turning off the Verbose Debug
2405      * Reporting Fallback Job.
2406      */
2407     boolean MEASUREMENT_VERBOSE_DEBUG_REPORTING_FALLBACK_JOB_KILL_SWITCH = false;
2408 
2409     /**
2410      * Returns the kill switch value for the Measurement Debug Reporting Fallback Job. The API will
2411      * be disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement
2412      * Debug Reporting Fallback Job kill switch value is true.
2413      */
getMeasurementVerboseDebugReportingFallbackJobKillSwitch()2414     default boolean getMeasurementVerboseDebugReportingFallbackJobKillSwitch() {
2415         return getLegacyMeasurementKillSwitch()
2416                 || MEASUREMENT_VERBOSE_DEBUG_REPORTING_FALLBACK_JOB_KILL_SWITCH;
2417     }
2418 
2419     /**
2420      * Returns the job period in millis for the Measurement Verbose Debug Reporting Fallback Job.
2421      */
2422     long MEASUREMENT_VERBOSE_DEBUG_REPORTING_FALLBACK_JOB_PERIOD_MS = TimeUnit.HOURS.toMillis(1);
2423 
2424     /**
2425      * Returns the job period in millis for the Measurement Verbose Debug Reporting Fallback Job.
2426      */
getMeasurementVerboseDebugReportingFallbackJobPeriodMs()2427     default long getMeasurementVerboseDebugReportingFallbackJobPeriodMs() {
2428         return MEASUREMENT_VERBOSE_DEBUG_REPORTING_FALLBACK_JOB_PERIOD_MS;
2429     }
2430 
2431     /** Returns the job period in millis for the Measurement Debug Reporting Fallback Job. */
2432     long MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_PERIOD_MS = TimeUnit.HOURS.toMillis(1);
2433 
2434     /** Returns the job period in millis for the Measurement Debug Reporting Fallback Job. */
getMeasurementDebugReportingFallbackJobPeriodMs()2435     default long getMeasurementDebugReportingFallbackJobPeriodMs() {
2436         return MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_PERIOD_MS;
2437     }
2438 
2439     /*
2440      * Measurement Job Verbose Debug Reporting Kill Switch. The default value is false which means
2441      * the Verbose Debug Reporting Job is enabled. This flag is used for emergency turning off the
2442      * Verbose Debug Reporting Job.
2443      */
2444     boolean MEASUREMENT_JOB_VERBOSE_DEBUG_REPORTING_KILL_SWITCH = false;
2445 
2446     /**
2447      * Returns the kill switch value for Measurement Job Verbose Debug Reporting. The Job will be
2448      * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job
2449      * Verbose Debug Reporting Kill Switch value is true.
2450      */
getMeasurementJobVerboseDebugReportingKillSwitch()2451     default boolean getMeasurementJobVerboseDebugReportingKillSwitch() {
2452         return getLegacyMeasurementKillSwitch()
2453                 || MEASUREMENT_JOB_VERBOSE_DEBUG_REPORTING_KILL_SWITCH;
2454     }
2455 
2456     /**
2457      * Measurement Broadcast Receiver Install Attribution Kill Switch. The default value is false
2458      * which means Install Attribution is enabled. This flag is used for emergency turning off
2459      * Install Attribution Broadcast Receiver.
2460      */
2461     boolean MEASUREMENT_RECEIVER_INSTALL_ATTRIBUTION_KILL_SWITCH = false;
2462 
2463     /**
2464      * Returns the kill switch value for Measurement Broadcast Receiver Install Attribution. The
2465      * Broadcast Receiver will be disabled if either the Global Kill Switch, Measurement Kill Switch
2466      * or the Measurement Kill Switch value is true.
2467      */
getMeasurementReceiverInstallAttributionKillSwitch()2468     default boolean getMeasurementReceiverInstallAttributionKillSwitch() {
2469         return getLegacyMeasurementKillSwitch()
2470                 || MEASUREMENT_RECEIVER_INSTALL_ATTRIBUTION_KILL_SWITCH;
2471     }
2472 
2473     /**
2474      * Measurement Broadcast Receiver Delete Packages Kill Switch. The default value is false which
2475      * means Delete Packages is enabled. This flag is used for emergency turning off Delete Packages
2476      * Broadcast Receiver.
2477      */
2478     boolean MEASUREMENT_RECEIVER_DELETE_PACKAGES_KILL_SWITCH = false;
2479 
2480     /**
2481      * Returns the kill switch value for Measurement Broadcast Receiver Delete Packages. The
2482      * Broadcast Receiver will be disabled if either the Global Kill Switch, Measurement Kill Switch
2483      * or the Measurement Kill Switch value is true.
2484      */
getMeasurementReceiverDeletePackagesKillSwitch()2485     default boolean getMeasurementReceiverDeletePackagesKillSwitch() {
2486         return getLegacyMeasurementKillSwitch() || MEASUREMENT_RECEIVER_DELETE_PACKAGES_KILL_SWITCH;
2487     }
2488 
2489     /**
2490      * Measurement Rollback Kill Switch. The default value is false which means the rollback
2491      * handling on measurement service start is enabled. This flag is used for emergency turning off
2492      * measurement rollback data deletion handling.
2493      */
2494     boolean MEASUREMENT_ROLLBACK_DELETION_KILL_SWITCH = false;
2495 
2496     /**
2497      * Returns the kill switch value for Measurement rollback deletion handling. The rollback
2498      * deletion handling will be disabled if the Global Kill Switch, Measurement Kill Switch or the
2499      * Measurement rollback deletion Kill Switch value is true.
2500      */
getMeasurementRollbackDeletionKillSwitch()2501     default boolean getMeasurementRollbackDeletionKillSwitch() {
2502         return getLegacyMeasurementKillSwitch() || MEASUREMENT_ROLLBACK_DELETION_KILL_SWITCH;
2503     }
2504 
2505     /** Flag for storing Measurement Rollback data in External Storage for Android R. */
2506     boolean MEASUREMENT_ROLLBACK_DELETION_R_ENABLED = !SdkLevel.isAtLeastS();
2507 
2508     /**
2509      * Returns whether storing Measurement rollback deletion handling data in AdServices external
2510      * storage is enabled. Rollback deletion handling on Android R will be disabled if this value is
2511      * false.
2512      */
getMeasurementRollbackDeletionREnabled()2513     default boolean getMeasurementRollbackDeletionREnabled() {
2514         return MEASUREMENT_ROLLBACK_DELETION_R_ENABLED;
2515     }
2516 
2517     /**
2518      * Kill Switch for storing Measurement Rollback data in App Search for Android S. The default
2519      * value is false which means storing the rollback handling data in App Search is enabled. This
2520      * flag is used for emergency turning off measurement rollback data deletion handling on Android
2521      * S.
2522      */
2523     boolean MEASUREMENT_ROLLBACK_DELETION_APP_SEARCH_KILL_SWITCH = false;
2524 
2525     /**
2526      * Returns the kill switch value for storing Measurement rollback deletion handling data in App
2527      * Search. The rollback deletion handling on Android S will be disabled if this kill switch
2528      * value is true.
2529      */
getMeasurementRollbackDeletionAppSearchKillSwitch()2530     default boolean getMeasurementRollbackDeletionAppSearchKillSwitch() {
2531         return MEASUREMENT_ROLLBACK_DELETION_APP_SEARCH_KILL_SWITCH;
2532     }
2533 
2534     // ADID Killswitch.
2535     /**
2536      * AdId API Kill Switch. The default value is false which means the AdId API is enabled. This
2537      * flag is used for emergency turning off the AdId API.
2538      */
2539     boolean ADID_KILL_SWITCH = false; // By default, the AdId API is enabled.
2540 
2541     /** Gets the state of adId kill switch. */
getAdIdKillSwitch()2542     default boolean getAdIdKillSwitch() {
2543         return ADID_KILL_SWITCH;
2544     }
2545 
2546     // APPSETID Killswitch.
2547     /**
2548      * AppSetId API Kill Switch. The default value is false which means the AppSetId API is enabled.
2549      * This flag is used for emergency turning off the AppSetId API.
2550      */
2551     boolean APPSETID_KILL_SWITCH = false; // By default, the AppSetId API is enabled.
2552 
2553     /** Gets the state of the global and appSetId kill switch. */
getAppSetIdKillSwitch()2554     default boolean getAppSetIdKillSwitch() {
2555         return APPSETID_KILL_SWITCH;
2556     }
2557 
2558     // TOPICS Killswitches
2559 
2560     /**
2561      * Topics API Kill Switch. The default value is {@code true} which means the Topics API is
2562      * disabled.
2563      *
2564      * <p>This flag is used for emergency turning off the Topics API.
2565      */
2566     @FeatureFlag(LEGACY_KILL_SWITCH)
2567     boolean TOPICS_KILL_SWITCH = true;
2568 
2569     /** Returns value of Topics API kill switch */
getTopicsKillSwitch()2570     default boolean getTopicsKillSwitch() {
2571         return getGlobalKillSwitch() || TOPICS_KILL_SWITCH;
2572     }
2573 
2574     /**
2575      * Topics on-device classifier Kill Switch. The default value is false which means the on-device
2576      * classifier in enabled. This flag is used for emergency turning off the on-device classifier.
2577      */
2578     boolean TOPICS_ON_DEVICE_CLASSIFIER_KILL_SWITCH = false;
2579 
2580     /** Returns value of Topics on-device classifier kill switch. */
getTopicsOnDeviceClassifierKillSwitch()2581     default boolean getTopicsOnDeviceClassifierKillSwitch() {
2582         return TOPICS_ON_DEVICE_CLASSIFIER_KILL_SWITCH;
2583     }
2584 
2585     // MDD Killswitches
2586 
2587     /**
2588      * MDD Background Task Kill Switch. The default value is false which means the MDD background
2589      * task is enabled. This flag is used for emergency turning off the MDD background tasks.
2590      */
2591     boolean MDD_BACKGROUND_TASK_KILL_SWITCH = false;
2592 
2593     /** Returns value of Mdd Background Task kill switch */
getMddBackgroundTaskKillSwitch()2594     default boolean getMddBackgroundTaskKillSwitch() {
2595         return getGlobalKillSwitch() || MDD_BACKGROUND_TASK_KILL_SWITCH;
2596     }
2597 
2598     /**
2599      * MDD Logger Kill Switch. The default value is false which means the MDD Logger is enabled.
2600      * This flag is used for emergency turning off the MDD Logger.
2601      */
2602     @FeatureFlag(LEGACY_KILL_SWITCH_RAMPED_UP)
2603     boolean MDD_LOGGER_KILL_SWITCH = false;
2604 
2605     /**
2606      * Returns whether the MDD Logger feature is enabled.
2607      *
2608      * <p>MDD Logger will be disabled if either the {@link #getGlobalKillSwitch() Global Kill
2609      * Switch} or the {@link #MDD_LOGGER_KILL_SWITCH} value is {@code true}.
2610      */
getMddLoggerEnabled()2611     default boolean getMddLoggerEnabled() {
2612         return getGlobalKillSwitch() ? false : !MDD_LOGGER_KILL_SWITCH;
2613     }
2614 
2615     // FLEDGE Kill switches
2616 
2617     /**
2618      * Fledge AdSelectionService kill switch. The default value is false which means that
2619      * AdSelectionService is enabled by default. This flag should be should as emergency andon cord.
2620      */
2621     boolean FLEDGE_SELECT_ADS_KILL_SWITCH = false;
2622 
2623     /** Returns value of Fledge Ad Selection Service API kill switch . */
getFledgeSelectAdsKillSwitch()2624     default boolean getFledgeSelectAdsKillSwitch() {
2625         // Check for global kill switch first, as it should override all other kill switches
2626         return getGlobalKillSwitch() || FLEDGE_SELECT_ADS_KILL_SWITCH;
2627     }
2628 
2629     /**
2630      * Fledge Auction Server API Kill switch. The default value is true which means that Auction
2631      * server APIs is disabled by default.
2632      */
2633     boolean FLEDGE_AUCTION_SERVER_KILL_SWITCH = true;
2634 
2635     /** Returns value of Fledge Auction server API kill switch. */
getFledgeAuctionServerKillSwitch()2636     default boolean getFledgeAuctionServerKillSwitch() {
2637         return getFledgeSelectAdsKillSwitch() || FLEDGE_AUCTION_SERVER_KILL_SWITCH;
2638     }
2639 
2640     /**
2641      * Fledge On Device Auction API Kill switch. The default value is false which means that On
2642      * Device Auction APIs is enabled by default.
2643      */
2644     boolean FLEDGE_ON_DEVICE_AUCTION_KILL_SWITCH = false;
2645 
2646     /** Returns value of On Device Auction API kill switch. */
getFledgeOnDeviceAuctionKillSwitch()2647     default boolean getFledgeOnDeviceAuctionKillSwitch() {
2648         return getFledgeSelectAdsKillSwitch() || FLEDGE_ON_DEVICE_AUCTION_KILL_SWITCH;
2649     }
2650 
2651     /**
2652      * Fledge Join Custom Audience API kill switch. The default value is false which means that Join
2653      * Custom Audience API is enabled by default. This flag should be should as emergency andon
2654      * cord.
2655      */
2656     boolean FLEDGE_CUSTOM_AUDIENCE_SERVICE_KILL_SWITCH = false;
2657 
2658     /** Returns value of Fledge Join Custom Audience API kill switch */
getFledgeCustomAudienceServiceKillSwitch()2659     default boolean getFledgeCustomAudienceServiceKillSwitch() {
2660         // Check for global kill switch first, as it should override all other kill switches
2661         return getGlobalKillSwitch() || FLEDGE_CUSTOM_AUDIENCE_SERVICE_KILL_SWITCH;
2662     }
2663 
2664     /**
2665      * Protected signals API feature flag. The default value is {@code false}, which means that
2666      * protected signals is disabled by default.
2667      */
2668     @FeatureFlag boolean PROTECTED_SIGNALS_ENABLED = false;
2669 
2670     /** Returns value of the protected signals feature flag. */
getProtectedSignalsEnabled()2671     default boolean getProtectedSignalsEnabled() {
2672         // Check for global kill switch first, as it should override all other kill switches
2673         return getGlobalKillSwitch() ? false : PROTECTED_SIGNALS_ENABLED;
2674     }
2675 
2676     // Encryption key Kill switches
2677 
2678     /**
2679      * Encryption key new enrollment fetch kill switch. The default value is false which means
2680      * fetching encryption keys for new enrollments is enabled by default. This flag is used for
2681      * emergency turning off fetching encryption keys for new enrollments.
2682      *
2683      * <p>Set true to disable the function since no adtech actually provide encryption endpoint now.
2684      */
2685     boolean ENCRYPTION_KEY_NEW_ENROLLMENT_FETCH_KILL_SWITCH = true;
2686 
2687     /** Returns value of encryption key new enrollment fetch job kill switch */
getEncryptionKeyNewEnrollmentFetchKillSwitch()2688     default boolean getEncryptionKeyNewEnrollmentFetchKillSwitch() {
2689         return getGlobalKillSwitch() || ENCRYPTION_KEY_NEW_ENROLLMENT_FETCH_KILL_SWITCH;
2690     }
2691 
2692     /**
2693      * Encryption key periodic fetch job kill switch. The default value is false which means
2694      * periodically fetching encryption keys is enabled by default. This flag is used for emergency
2695      * turning off periodically fetching encryption keys.
2696      *
2697      * <p>Set true to disable the function since no adtech actually provide encryption endpoint now.
2698      */
2699     boolean ENCRYPTION_KEY_PERIODIC_FETCH_KILL_SWITCH = true;
2700 
2701     /** Returns value of encryption key new enrollment fetch job kill switch */
getEncryptionKeyPeriodicFetchKillSwitch()2702     default boolean getEncryptionKeyPeriodicFetchKillSwitch() {
2703         return getGlobalKillSwitch() || ENCRYPTION_KEY_PERIODIC_FETCH_KILL_SWITCH;
2704     }
2705 
2706     int ENCRYPTION_KEY_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_UNMETERED;
2707 
2708     /** Returns the required network type (Wifi) for encryption key fetch job. */
getEncryptionKeyJobRequiredNetworkType()2709     default int getEncryptionKeyJobRequiredNetworkType() {
2710         return ENCRYPTION_KEY_JOB_REQUIRED_NETWORK_TYPE;
2711     }
2712 
2713     /* The default time period (in millisecond) between each encryption key job to run. */
2714     long ENCRYPTION_KEY_JOB_PERIOD_MS = 24 * 60 * 60 * 1000L; // 24 hours.
2715 
2716     /** Returns min time period (in millis) between each event fallback reporting job run. */
getEncryptionKeyJobPeriodMs()2717     default long getEncryptionKeyJobPeriodMs() {
2718         return ENCRYPTION_KEY_JOB_PERIOD_MS;
2719     }
2720 
2721     /** Feature flag to ramp up mdd based encryption keys. */
2722     boolean ENABLE_MDD_ENCRYPTION_KEYS = false;
2723 
2724     /** Returns value of the feature flag used to determine ramp for mdd based encryption keys. */
getEnableMddEncryptionKeys()2725     default boolean getEnableMddEncryptionKeys() {
2726         return ENABLE_MDD_ENCRYPTION_KEYS;
2727     }
2728 
2729     /** Manifest URL for encryption keys file group registered with MDD. */
2730     String MDD_ENCRYPTION_KEYS_MANIFEST_FILE_URL =
2731             "https://www.gstatic.com/mdi-serving/rubidium-adservices-encryption-keys/4543/e9d118728752e6a6bfb5d7d8d1520807591f0717";
2732 
2733     /** Returns manifest URL for encryption keys file group registered with MDD. */
getMddEncryptionKeysManifestFileUrl()2734     default String getMddEncryptionKeysManifestFileUrl() {
2735         return MDD_ENCRYPTION_KEYS_MANIFEST_FILE_URL;
2736     }
2737 
2738     /**
2739      * Enable Back Compat feature flag. The default value is false which means that all back compat
2740      * related features are disabled by default. This flag would be enabled for R/S during rollout.
2741      */
2742     @FeatureFlag boolean ENABLE_BACK_COMPAT = false;
2743 
2744     /** Returns value of enable Back Compat */
getEnableBackCompat()2745     default boolean getEnableBackCompat() {
2746         return ENABLE_BACK_COMPAT;
2747     }
2748 
2749     /**
2750      * Enable Back Compat feature init flag. When enabled, the back compat feature is initialized
2751      * (if it hasn't been initialized already) within the enableAdServices system API.
2752      */
2753     @FeatureFlag boolean DEFAULT_ENABLE_BACK_COMPAT_INIT = false;
2754 
2755     /** Returns value of enable Back Compat */
getEnableBackCompatInit()2756     default boolean getEnableBackCompatInit() {
2757         return DEFAULT_ENABLE_BACK_COMPAT_INIT;
2758     }
2759 
2760     /**
2761      * Enable AppSearch read for consent data feature flag. The default value is false which means
2762      * AppSearch is not considered as source of truth after OTA. This flag should be enabled for OTA
2763      * support of consent data on T+ devices.
2764      */
2765     boolean ENABLE_APPSEARCH_CONSENT_DATA = SdkLevel.isAtLeastS() && !SdkLevel.isAtLeastT();
2766 
2767     /** Returns value of enable appsearch consent data flag */
getEnableAppsearchConsentData()2768     default boolean getEnableAppsearchConsentData() {
2769         return ENABLE_APPSEARCH_CONSENT_DATA;
2770     }
2771 
2772     /** Default U18 AppSearch migration feature flag. */
2773     boolean DEFAULT_ENABLE_U18_APPSEARCH_MIGRATION = false;
2774 
2775     /** Returns value of enable U18 appsearch migration flag */
getEnableU18AppsearchMigration()2776     default boolean getEnableU18AppsearchMigration() {
2777         return DEFAULT_ENABLE_U18_APPSEARCH_MIGRATION;
2778     }
2779 
2780     /**
2781      * Enable AdServicesExtDataStorageService read for consent data feature flag. The default value
2782      * on R devices is true as the consent source of truth is PPAPI_AND_ADEXT_SERVICE_ONLY. The
2783      * default value on S+ devices is false which means AdServicesExtDataStorageService is not
2784      * considered as source of truth after OTA. This flag should be enabled for OTA support of
2785      * consent data on S devices.
2786      */
2787     boolean ENABLE_ADEXT_SERVICE_CONSENT_DATA = SDK_INT == Build.VERSION_CODES.R;
2788 
2789     /** Returns value of enable AdExt service consent data flag. */
getEnableAdExtServiceConsentData()2790     default boolean getEnableAdExtServiceConsentData() {
2791         return ENABLE_ADEXT_SERVICE_CONSENT_DATA;
2792     }
2793 
2794     /**
2795      * Enables data migration from AdServicesExtDataStorageService to AppSearch (on S) and System
2796      * server (on T+) upon OTA from R.
2797      */
2798     boolean ENABLE_MIGRATION_FROM_ADEXT_SERVICE = SdkLevel.isAtLeastS();
2799 
2800     /**
2801      * @return value of enable migration AdExt service.
2802      */
getEnableMigrationFromAdExtService()2803     default boolean getEnableMigrationFromAdExtService() {
2804         return ENABLE_MIGRATION_FROM_ADEXT_SERVICE;
2805     }
2806 
2807     /*
2808      * The allow-list for PP APIs. This list has the list of app package names that we allow
2809      * using PP APIs.
2810      * App Package Name that does not belong to this allow-list will not be able to use PP APIs.
2811      * If this list has special value "*", then all package names are allowed.
2812      * There must be not any empty space between comma.
2813      */
2814     String PPAPI_APP_ALLOW_LIST =
2815             "android.platform.test.scenario,"
2816                     + "android.adservices.crystalball,"
2817                     + "android.adservices.cts,"
2818                     + "android.adservices.debuggablects,"
2819                     + "com.android.adservices.endtoendtest,"
2820                     + "com.android.adservices.servicecoretest,"
2821                     + "com.android.adservices.tests.permissions.appoptout,"
2822                     + "com.android.adservices.tests.permissions.valid,"
2823                     + "com.android.adservices.tests.adid,"
2824                     + "com.android.adservices.tests.appsetid,"
2825                     + "com.android.sdksandboxclient,"
2826                     + "com.android.tests.sandbox.adid,"
2827                     + "com.android.tests.sandbox.appsetid,"
2828                     + "com.android.tests.sandbox.fledge,"
2829                     + "com.android.tests.sandbox.measurement,"
2830                     + "com.example.adservices.samples.adid.app,"
2831                     + "com.example.adservices.samples.appsetid.app,"
2832                     + "com.example.adservices.samples.fledge.sampleapp,"
2833                     + "com.example.adservices.samples.fledge.sampleapp1,"
2834                     + "com.example.adservices.samples.fledge.sampleapp2,"
2835                     + "com.example.adservices.samples.fledge.sampleapp3,"
2836                     + "com.example.adservices.samples.fledge.sampleapp4,"
2837                     + "com.example.adservices.samples.signals.sampleapp,"
2838                     + "com.example.measurement.sampleapp,"
2839                     + "com.example.measurement.sampleapp2,"
2840                     + "com.android.adservices.tests.cts.endtoendtest.measurement";
2841 
2842     /**
2843      * Returns bypass List for PPAPI app signature check. Apps with package name on this list will
2844      * bypass the signature check
2845      */
getPpapiAppAllowList()2846     default String getPpapiAppAllowList() {
2847         return PPAPI_APP_ALLOW_LIST;
2848     }
2849 
getPasAppAllowList()2850     default String getPasAppAllowList() {
2851         // default to using the same fixed list as custom audiences
2852         return PPAPI_APP_ALLOW_LIST;
2853     }
2854 
2855     String AD_ID_API_APP_BLOCK_LIST = "";
2856 
2857     /** Get the app allow list for the AD ID API. */
getAdIdApiAppBlockList()2858     default String getAdIdApiAppBlockList() {
2859         return AD_ID_API_APP_BLOCK_LIST;
2860     }
2861 
2862     /*
2863      * The allow-list for Measurement APIs. This list has the list of app package names that we
2864      * allow using Measurement APIs. Overridden by Block List
2865      */
2866     String MSMT_API_APP_ALLOW_LIST =
2867             "android.platform.test.scenario,"
2868                     + "android.adservices.crystalball,"
2869                     + "android.adservices.cts,"
2870                     + "android.adservices.debuggablects,"
2871                     + "com.android.adservices.endtoendtest,"
2872                     + "com.android.adservices.servicecoretest,"
2873                     + "com.android.adservices.tests.permissions.appoptout,"
2874                     + "com.android.adservices.tests.permissions.valid,"
2875                     + "com.android.adservices.tests.adid,"
2876                     + "com.android.adservices.tests.appsetid,"
2877                     + "com.android.sdksandboxclient,"
2878                     + "com.android.tests.sandbox.adid,"
2879                     + "com.android.tests.sandbox.appsetid,"
2880                     + "com.android.tests.sandbox.fledge,"
2881                     + "com.android.tests.sandbox.measurement,"
2882                     + "com.example.adservices.samples.adid.app,"
2883                     + "com.example.adservices.samples.appsetid.app,"
2884                     + "com.example.adservices.samples.fledge.sampleapp,"
2885                     + "com.example.adservices.samples.fledge.sampleapp1,"
2886                     + "com.example.adservices.samples.fledge.sampleapp2,"
2887                     + "com.example.adservices.samples.fledge.sampleapp3,"
2888                     + "com.example.adservices.samples.fledge.sampleapp4,"
2889                     + "com.example.measurement.sampleapp,"
2890                     + "com.example.measurement.sampleapp2,"
2891                     + "com.android.adservices.tests.cts.endtoendtest.measurement";
2892 
2893     /*
2894      * App Package Name that does not belong to this allow-list will not be able to use Measurement
2895      * APIs.
2896      * If this list has special value "*", then all package names are allowed.
2897      * Block List takes precedence over Allow List.
2898      * There must be not any empty space between comma.
2899      */
getMsmtApiAppAllowList()2900     default String getMsmtApiAppAllowList() {
2901         return MSMT_API_APP_ALLOW_LIST;
2902     }
2903 
2904     /*
2905      * The blocklist for Measurement APIs. This list has the list of app package names that we
2906      * do not allow to use Measurement APIs.
2907      */
2908     String MSMT_API_APP_BLOCK_LIST = "";
2909 
2910     /*
2911      * App Package Name that belong to this blocklist will not be able to use Measurement
2912      * APIs.
2913      * If this list has special value "*", then all package names are blocked.
2914      * Block List takes precedence over Allow List.
2915      * There must be not any empty space between comma.
2916      */
getMsmtApiAppBlockList()2917     default String getMsmtApiAppBlockList() {
2918         return MSMT_API_APP_BLOCK_LIST;
2919     }
2920 
2921     /*
2922      * The allow-list for PP APIs. This list has the list of app signatures that we allow
2923      * using PP APIs. App Package signatures that do not belong to this allow-list will not be
2924      * able to use PP APIs, unless the package name of this app is in the bypass list.
2925      *
2926      * If this list has special value "*", then all package signatures are allowed.
2927      *
2928      * There must be not any empty space between comma.
2929      */
2930     String PPAPI_APP_SIGNATURE_ALLOW_LIST =
2931             // com.android.adservices.tests.cts.endtoendtest
2932             "6cecc50e34ae31bfb5678986d6d6d3736c571ded2f2459527793e1f054eb0c9b,"
2933                     // com.android.tests.sandbox.topics
2934                     + "a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc,"
2935                     // Topics Sample Apps
2936                     // For example, com.example.adservices.samples.topics.sampleapp1
2937                     + "301aa3cb081134501c45f1422abc66c24224fd5ded5fdc8f17e697176fd866aa,"
2938                     // com.android.adservices.tests.cts.topics.testapp1
2939                     // android.platform.test.scenario.adservices.GetTopicsApiCall
2940                     // Both have [certificate: "platform"] in .bp file
2941                     + "c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8";
2942 
2943     /** Only App signatures belonging to this Allow List can use PP APIs. */
getPpapiAppSignatureAllowList()2944     default String getPpapiAppSignatureAllowList() {
2945         return PPAPI_APP_SIGNATURE_ALLOW_LIST;
2946     }
2947 
2948     /**
2949      * The allow list for AppSearch writers. If non-empty, only results written by a package on the
2950      * allow list will be read for consent migration.
2951      */
2952     String APPSEARCH_WRITER_ALLOW_LIST_OVERRIDE = "";
2953 
2954     /** Only data written by packages in the allow list will be read from AppSearch. */
getAppsearchWriterAllowListOverride()2955     default String getAppsearchWriterAllowListOverride() {
2956         return APPSEARCH_WRITER_ALLOW_LIST_OVERRIDE;
2957     }
2958 
2959     /**
2960      * The client app packages that are allowed to invoke web context APIs, i.e. {@link
2961      * android.adservices.measurement.MeasurementManager#registerWebSource} and {@link
2962      * android.adservices.measurement.MeasurementManager#deleteRegistrations}. App packages that do
2963      * not belong to the list will be responded back with an error response.
2964      */
2965     String WEB_CONTEXT_CLIENT_ALLOW_LIST = "";
2966 
2967     // Rate Limit Flags.
2968 
2969     /**
2970      * PP API Rate Limit for each SDK. This is the max allowed QPS for one SDK to one PP API.
2971      * Negative Value means skipping the rate limiting checking.
2972      */
2973     float SDK_REQUEST_PERMITS_PER_SECOND = 1; // allow max 1 request to any PP API per second.
2974 
2975     /**
2976      * PP API Rate Limit for ad id. This is the max allowed QPS for one API client to one PP API.
2977      * Negative Value means skipping the rate limiting checking.
2978      */
2979     float ADID_REQUEST_PERMITS_PER_SECOND = FlagsConstants.ADID_REQUEST_PERMITS_PER_SECOND;
2980 
2981     /**
2982      * PP API Rate Limit for app set id. This is the max allowed QPS for one API client to one PP
2983      * API. Negative Value means skipping the rate limiting checking.
2984      */
2985     float APPSETID_REQUEST_PERMITS_PER_SECOND = 5;
2986 
2987     /**
2988      * PP API Rate Limit for measurement register source. This is the max allowed QPS for one API
2989      * client to one PP API. Negative Value means skipping the rate limiting checking.
2990      */
2991     float MEASUREMENT_REGISTER_SOURCE_REQUEST_PERMITS_PER_SECOND = 25;
2992 
2993     /**
2994      * PP API Rate Limit for measurement register web source. This is the max allowed QPS for one
2995      * API client to one PP API. Negative Value means skipping the rate limiting checking.
2996      */
2997     float MEASUREMENT_REGISTER_WEB_SOURCE_REQUEST_PERMITS_PER_SECOND = 25;
2998 
2999     /**
3000      * PP API Rate Limit for measurement register sources. This is the max allowed QPS for one API
3001      * client to one PP API. Negative Value means skipping the rate limiting checking.
3002      */
3003     float MEASUREMENT_REGISTER_SOURCES_REQUEST_PERMITS_PER_SECOND = 25;
3004 
3005     /**
3006      * PP API Rate Limit for measurement register trigger. This is the max allowed QPS for one API
3007      * client to one PP API. Negative Value means skipping the rate limiting checking.
3008      */
3009     float MEASUREMENT_REGISTER_TRIGGER_REQUEST_PERMITS_PER_SECOND = 25;
3010 
3011     /**
3012      * PP API Rate Limit for measurement register web trigger. This is the max allowed QPS for one
3013      * API client to one PP API. Negative Value means skipping the rate limiting checking.
3014      */
3015     float MEASUREMENT_REGISTER_WEB_TRIGGER_REQUEST_PERMITS_PER_SECOND = 25;
3016 
3017     /**
3018      * PP API Rate Limit for Topics API based on App Package name. This is the max allowed QPS for
3019      * one API client to one PP API. Negative Value means skipping the rate limiting checking.
3020      */
3021     float TOPICS_API_APP_REQUEST_PERMITS_PER_SECOND = 1;
3022 
3023     /**
3024      * PP API Rate Limit for Topics API based on Sdk Name. This is the max allowed QPS for one API
3025      * client to one PP API. Negative Value means skipping the rate limiting checking.
3026      */
3027     float TOPICS_API_SDK_REQUEST_PERMITS_PER_SECOND = 1;
3028 
3029     /**
3030      * PP API Rate Limit for Fledge Report Interaction API. This is the max allowed QPS for one SDK
3031      * to one the Report Interaction API. Negative Value means skipping the rate limiting checking.
3032      */
3033     float FLEDGE_REPORT_INTERACTION_REQUEST_PERMITS_PER_SECOND = 1;
3034 
3035     /** Returns the Sdk Request Permits Per Second. */
getSdkRequestPermitsPerSecond()3036     default float getSdkRequestPermitsPerSecond() {
3037         return SDK_REQUEST_PERMITS_PER_SECOND;
3038     }
3039 
3040     /** Returns the Ad id Request Permits Per Second. */
getAdIdRequestPermitsPerSecond()3041     default float getAdIdRequestPermitsPerSecond() {
3042         return ADID_REQUEST_PERMITS_PER_SECOND;
3043     }
3044 
3045     /** Returns the App Set Ad Request Permits Per Second. */
getAppSetIdRequestPermitsPerSecond()3046     default float getAppSetIdRequestPermitsPerSecond() {
3047         return APPSETID_REQUEST_PERMITS_PER_SECOND;
3048     }
3049 
3050     /** Returns the Topics API Based On App Package Name Request Permits Per Second. */
getTopicsApiAppRequestPermitsPerSecond()3051     default float getTopicsApiAppRequestPermitsPerSecond() {
3052         return TOPICS_API_APP_REQUEST_PERMITS_PER_SECOND;
3053     }
3054 
3055     /** Returns the Topics API Based On Sdk Name Request Permits Per Second. */
getTopicsApiSdkRequestPermitsPerSecond()3056     default float getTopicsApiSdkRequestPermitsPerSecond() {
3057         return TOPICS_API_SDK_REQUEST_PERMITS_PER_SECOND;
3058     }
3059 
3060     /** Returns the Measurement Register Source Request Permits Per Second. */
getMeasurementRegisterSourceRequestPermitsPerSecond()3061     default float getMeasurementRegisterSourceRequestPermitsPerSecond() {
3062         return MEASUREMENT_REGISTER_SOURCE_REQUEST_PERMITS_PER_SECOND;
3063     }
3064 
3065     /** Returns the Measurement Register Sources Request Permits Per Second. */
getMeasurementRegisterSourcesRequestPermitsPerSecond()3066     default float getMeasurementRegisterSourcesRequestPermitsPerSecond() {
3067         return MEASUREMENT_REGISTER_SOURCES_REQUEST_PERMITS_PER_SECOND;
3068     }
3069 
3070     /** Returns the Measurement Register Web Source Request Permits Per Second. */
getMeasurementRegisterWebSourceRequestPermitsPerSecond()3071     default float getMeasurementRegisterWebSourceRequestPermitsPerSecond() {
3072         return MEASUREMENT_REGISTER_WEB_SOURCE_REQUEST_PERMITS_PER_SECOND;
3073     }
3074 
3075     /** Returns the Measurement Register Trigger Request Permits Per Second. */
getMeasurementRegisterTriggerRequestPermitsPerSecond()3076     default float getMeasurementRegisterTriggerRequestPermitsPerSecond() {
3077         return MEASUREMENT_REGISTER_TRIGGER_REQUEST_PERMITS_PER_SECOND;
3078     }
3079 
3080     /** Returns the Measurement Register Web Trigger Request Permits Per Second. */
getMeasurementRegisterWebTriggerRequestPermitsPerSecond()3081     default float getMeasurementRegisterWebTriggerRequestPermitsPerSecond() {
3082         return MEASUREMENT_REGISTER_WEB_TRIGGER_REQUEST_PERMITS_PER_SECOND;
3083     }
3084 
3085     /** Returns the Fledge Report Interaction API Request Permits Per Second. */
getFledgeReportInteractionRequestPermitsPerSecond()3086     default float getFledgeReportInteractionRequestPermitsPerSecond() {
3087         return FLEDGE_REPORT_INTERACTION_REQUEST_PERMITS_PER_SECOND;
3088     }
3089 
3090     // Flags for ad tech enrollment enforcement
3091 
3092     boolean DISABLE_TOPICS_ENROLLMENT_CHECK = false;
3093     boolean DISABLE_FLEDGE_ENROLLMENT_CHECK = false;
3094     boolean DISABLE_MEASUREMENT_ENROLLMENT_CHECK = false;
3095     boolean ENABLE_ENROLLMENT_TEST_SEED = false;
3096 
3097     /** Returns {@code true} if the Topics API should disable the ad tech enrollment check */
isDisableTopicsEnrollmentCheck()3098     default boolean isDisableTopicsEnrollmentCheck() {
3099         return DISABLE_TOPICS_ENROLLMENT_CHECK;
3100     }
3101 
3102     /** Returns {@code true} if the FLEDGE APIs should disable the ad tech enrollment check */
getDisableFledgeEnrollmentCheck()3103     default boolean getDisableFledgeEnrollmentCheck() {
3104         return DISABLE_FLEDGE_ENROLLMENT_CHECK;
3105     }
3106 
3107     /** Returns {@code true} if the Measurement APIs should disable the ad tech enrollment check */
isDisableMeasurementEnrollmentCheck()3108     default boolean isDisableMeasurementEnrollmentCheck() {
3109         return DISABLE_MEASUREMENT_ENROLLMENT_CHECK;
3110     }
3111 
3112     /**
3113      * Returns {@code true} if the Enrollment seed is disabled. (Enrollment seed is only needed for
3114      * testing)
3115      */
isEnableEnrollmentTestSeed()3116     default boolean isEnableEnrollmentTestSeed() {
3117         return ENABLE_ENROLLMENT_TEST_SEED;
3118     }
3119 
3120     boolean ENFORCE_FOREGROUND_STATUS_ADID = true;
3121     boolean ENFORCE_FOREGROUND_STATUS_APPSETID = true;
3122     boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_RUN_AD_SELECTION = true;
3123     boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_IMPRESSION = true;
3124     boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_INTERACTION = true;
3125     boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_OVERRIDES = true;
3126     boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_CUSTOM_AUDIENCE = true;
3127     boolean ENFORCE_FOREGROUND_STATUS_TOPICS = true;
3128     boolean ENFORCE_FOREGROUND_STATUS_SIGNALS = true;
3129 
3130     /**
3131      * Returns true if FLEDGE runAdSelection API should require that the calling API is running in
3132      * foreground.
3133      */
getEnforceForegroundStatusForFledgeRunAdSelection()3134     default boolean getEnforceForegroundStatusForFledgeRunAdSelection() {
3135         return ENFORCE_FOREGROUND_STATUS_FLEDGE_RUN_AD_SELECTION;
3136     }
3137 
3138     /**
3139      * Returns true if FLEDGE reportImpression API should require that the calling API is running in
3140      * foreground.
3141      */
getEnforceForegroundStatusForFledgeReportImpression()3142     default boolean getEnforceForegroundStatusForFledgeReportImpression() {
3143         return ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_IMPRESSION;
3144     }
3145 
3146     /**
3147      * Returns true if FLEDGE reportInteraction API should require that the calling API is running
3148      * in foreground.
3149      */
getEnforceForegroundStatusForFledgeReportInteraction()3150     default boolean getEnforceForegroundStatusForFledgeReportInteraction() {
3151         return ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_INTERACTION;
3152     }
3153 
3154     /**
3155      * Returns true if FLEDGE override API methods (for Custom Audience and Ad Selection) should
3156      * require that the calling API is running in foreground.
3157      */
getEnforceForegroundStatusForFledgeOverrides()3158     default boolean getEnforceForegroundStatusForFledgeOverrides() {
3159         return ENFORCE_FOREGROUND_STATUS_FLEDGE_OVERRIDES;
3160     }
3161 
3162     /**
3163      * Returns true if FLEDGE Custom Audience API methods should require that the calling API is
3164      * running in foreground.
3165      */
getEnforceForegroundStatusForFledgeCustomAudience()3166     default boolean getEnforceForegroundStatusForFledgeCustomAudience() {
3167         return ENFORCE_FOREGROUND_STATUS_FLEDGE_CUSTOM_AUDIENCE;
3168     }
3169 
3170     boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_DELETE_REGISTRATIONS = true;
3171     boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_SOURCE = true;
3172     boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_TRIGGER = true;
3173     boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_SOURCE = true;
3174     boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_TRIGGER = true;
3175     boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_GET_STATUS = true;
3176     boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_SOURCES = true;
3177     boolean MEASUREMENT_ENFORCE_ENROLLMENT_ORIGIN_MATCH = false;
3178 
3179     /**
3180      * Returns true if Measurement Delete Registrations API should require that the calling API is
3181      * running in foreground.
3182      */
getEnforceForegroundStatusForMeasurementDeleteRegistrations()3183     default boolean getEnforceForegroundStatusForMeasurementDeleteRegistrations() {
3184         return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_DELETE_REGISTRATIONS;
3185     }
3186 
3187     /**
3188      * Returns true if Measurement Register Source API should require that the calling API is
3189      * running in foreground.
3190      */
getEnforceForegroundStatusForMeasurementRegisterSource()3191     default boolean getEnforceForegroundStatusForMeasurementRegisterSource() {
3192         return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_SOURCE;
3193     }
3194 
3195     /**
3196      * Returns true if Measurement Register Trigger API should require that the calling API is
3197      * running in foreground.
3198      */
getEnforceForegroundStatusForMeasurementRegisterTrigger()3199     default boolean getEnforceForegroundStatusForMeasurementRegisterTrigger() {
3200         return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_TRIGGER;
3201     }
3202 
3203     /**
3204      * Returns true if Measurement Register Web Source API should require that the calling API is
3205      * running in foreground.
3206      */
getEnforceForegroundStatusForMeasurementRegisterWebSource()3207     default boolean getEnforceForegroundStatusForMeasurementRegisterWebSource() {
3208         return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_SOURCE;
3209     }
3210 
3211     /**
3212      * Returns true if Measurement Register Web Trigger API should require that the calling API is
3213      * running in foreground.
3214      */
getEnforceForegroundStatusForMeasurementRegisterWebTrigger()3215     default boolean getEnforceForegroundStatusForMeasurementRegisterWebTrigger() {
3216         return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_TRIGGER;
3217     }
3218 
3219     /**
3220      * Returns true if Measurement Get Status API should require that the calling API is running in
3221      * foreground.
3222      */
getEnforceForegroundStatusForMeasurementStatus()3223     default boolean getEnforceForegroundStatusForMeasurementStatus() {
3224         return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_GET_STATUS;
3225     }
3226 
3227     /**
3228      * Returns true if Measurement Get Status API should require that the calling API is running in
3229      * foreground.
3230      */
getEnforceForegroundStatusForMeasurementRegisterSources()3231     default boolean getEnforceForegroundStatusForMeasurementRegisterSources() {
3232         return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_SOURCES;
3233     }
3234 
3235     /** Returns true if the Enrollment match is based on url origin matching */
getEnforceEnrollmentOriginMatch()3236     default boolean getEnforceEnrollmentOriginMatch() {
3237         return MEASUREMENT_ENFORCE_ENROLLMENT_ORIGIN_MATCH;
3238     }
3239 
3240     /** Returns true if Topics API should require that the calling API is running in foreground. */
getEnforceForegroundStatusForTopics()3241     default boolean getEnforceForegroundStatusForTopics() {
3242         return ENFORCE_FOREGROUND_STATUS_TOPICS;
3243     }
3244 
3245     /**
3246      * Returns true if Protected Signals API should require that the calling API is running in
3247      * foreground.
3248      */
getEnforceForegroundStatusForSignals()3249     default boolean getEnforceForegroundStatusForSignals() {
3250         return ENFORCE_FOREGROUND_STATUS_SIGNALS;
3251     }
3252 
3253     /** Returns true if AdId API should require that the calling API is running in foreground. */
getEnforceForegroundStatusForAdId()3254     default boolean getEnforceForegroundStatusForAdId() {
3255         return ENFORCE_FOREGROUND_STATUS_ADID;
3256     }
3257 
3258     int FOREGROUND_STATUS_LEVEL = IMPORTANCE_FOREGROUND_SERVICE;
3259 
3260     /**
3261      * Returns true if AppSetId API should require that the calling API is running in foreground.
3262      */
getEnforceForegroundStatusForAppSetId()3263     default boolean getEnforceForegroundStatusForAppSetId() {
3264         return ENFORCE_FOREGROUND_STATUS_APPSETID;
3265     }
3266 
3267     /** Returns the importance level to use to check if an application is in foreground. */
getForegroundStatuslLevelForValidation()3268     default int getForegroundStatuslLevelForValidation() {
3269         return FOREGROUND_STATUS_LEVEL;
3270     }
3271 
getWebContextClientAppAllowList()3272     default String getWebContextClientAppAllowList() {
3273         return WEB_CONTEXT_CLIENT_ALLOW_LIST;
3274     }
3275 
3276     boolean ENFORCE_ISOLATE_MAX_HEAP_SIZE = true;
3277     long ISOLATE_MAX_HEAP_SIZE_BYTES = 10 * 1024 * 1024L; // 10 MB
3278     long MAX_RESPONSE_BASED_REGISTRATION_SIZE_BYTES = 16 * 1024; // 16 kB
3279     long MAX_TRIGGER_REGISTRATION_HEADER_SIZE_BYTES = 250 * 1024; // 250 kB
3280     long MAX_ODP_TRIGGER_REGISTRATION_HEADER_SIZE_BYTES = 16 * 1024; // 16 kB
3281 
3282     /** Returns max allowed size in bytes for trigger registrations header. */
getMaxTriggerRegistrationHeaderSizeBytes()3283     default long getMaxTriggerRegistrationHeaderSizeBytes() {
3284         return MAX_TRIGGER_REGISTRATION_HEADER_SIZE_BYTES;
3285     }
3286 
3287     /** Returns max allowed size in bytes for ODP trigger registrations header. */
getMaxOdpTriggerRegistrationHeaderSizeBytes()3288     default long getMaxOdpTriggerRegistrationHeaderSizeBytes() {
3289         return MAX_ODP_TRIGGER_REGISTRATION_HEADER_SIZE_BYTES;
3290     }
3291 
3292     boolean MEASUREMENT_ENABLE_UPDATE_TRIGGER_REGISTRATION_HEADER_LIMIT = false;
3293 
3294     /** Returns true when the new trigger registration header size limitation are applied. */
getMeasurementEnableUpdateTriggerHeaderLimit()3295     default boolean getMeasurementEnableUpdateTriggerHeaderLimit() {
3296         return MEASUREMENT_ENABLE_UPDATE_TRIGGER_REGISTRATION_HEADER_LIMIT;
3297     }
3298 
3299     /**
3300      * Returns true if we enforce to check that JavaScriptIsolate supports limiting the max heap
3301      * size
3302      */
getEnforceIsolateMaxHeapSize()3303     default boolean getEnforceIsolateMaxHeapSize() {
3304         return ENFORCE_ISOLATE_MAX_HEAP_SIZE;
3305     }
3306 
3307     /** Returns size in bytes we bound the heap memory for JavaScript isolate */
getIsolateMaxHeapSizeBytes()3308     default long getIsolateMaxHeapSizeBytes() {
3309         return ISOLATE_MAX_HEAP_SIZE_BYTES;
3310     }
3311 
3312     /**
3313      * Returns max allowed size in bytes for response based registrations payload of an individual
3314      * source/trigger registration.
3315      */
getMaxResponseBasedRegistrationPayloadSizeBytes()3316     default long getMaxResponseBasedRegistrationPayloadSizeBytes() {
3317         return MAX_RESPONSE_BASED_REGISTRATION_SIZE_BYTES;
3318     }
3319 
3320     /** Ui OTA strings group name, used for MDD download. */
3321     String UI_OTA_STRINGS_GROUP_NAME = "ui-ota-strings";
3322 
3323     /** UI OTA strings group name. */
getUiOtaStringsGroupName()3324     default String getUiOtaStringsGroupName() {
3325         return UI_OTA_STRINGS_GROUP_NAME;
3326     }
3327 
3328     /** Ui OTA strings manifest file url, used for MDD download. */
3329     String UI_OTA_STRINGS_MANIFEST_FILE_URL =
3330             "https://www.gstatic.com/mdi-serving/rubidium-adservices-ui-ota-strings/1341/95580b00edbd8cbf62bfa0df9ebd79fba1e5b7ca";
3331 
3332     /** UI OTA strings manifest file url. */
getUiOtaStringsManifestFileUrl()3333     default String getUiOtaStringsManifestFileUrl() {
3334         return UI_OTA_STRINGS_MANIFEST_FILE_URL;
3335     }
3336 
3337     /** Ui OTA strings feature flag. */
3338     boolean UI_OTA_STRINGS_FEATURE_ENABLED = false;
3339 
3340     /** Returns if UI OTA strings feature is enabled. */
getUiOtaStringsFeatureEnabled()3341     default boolean getUiOtaStringsFeatureEnabled() {
3342         return UI_OTA_STRINGS_FEATURE_ENABLED;
3343     }
3344 
3345     /** UI OTA resources manifest file url, used for MDD download. */
3346     String UI_OTA_RESOURCES_MANIFEST_FILE_URL = "";
3347 
3348     /** UI OTA resources manifest file url. */
getUiOtaResourcesManifestFileUrl()3349     default String getUiOtaResourcesManifestFileUrl() {
3350         return UI_OTA_RESOURCES_MANIFEST_FILE_URL;
3351     }
3352 
3353     /** UI OTA resources feature flag. */
3354     boolean UI_OTA_RESOURCES_FEATURE_ENABLED = false;
3355 
3356     /** Returns if UI OTA resources feature is enabled. */
getUiOtaResourcesFeatureEnabled()3357     default boolean getUiOtaResourcesFeatureEnabled() {
3358         return UI_OTA_RESOURCES_FEATURE_ENABLED;
3359     }
3360 
3361     /** Deadline for downloading UI OTA strings. */
3362     long UI_OTA_STRINGS_DOWNLOAD_DEADLINE = 86700000; /* 1 day */
3363 
3364     /** Returns the deadline for downloading UI OTA strings. */
getUiOtaStringsDownloadDeadline()3365     default long getUiOtaStringsDownloadDeadline() {
3366         return UI_OTA_STRINGS_DOWNLOAD_DEADLINE;
3367     }
3368 
3369     /** UI Dialogs feature enabled. */
3370     boolean UI_DIALOGS_FEATURE_ENABLED = false;
3371 
3372     /** Returns if the UI Dialogs feature is enabled. */
getUiDialogsFeatureEnabled()3373     default boolean getUiDialogsFeatureEnabled() {
3374         return UI_DIALOGS_FEATURE_ENABLED;
3375     }
3376 
3377     /** UI Dialog Fragment feature enabled. */
3378     boolean UI_DIALOG_FRAGMENT = false;
3379 
3380     /** Returns if the UI Dialog Fragment is enabled. */
getUiDialogFragmentEnabled()3381     default boolean getUiDialogFragmentEnabled() {
3382         return UI_DIALOG_FRAGMENT;
3383     }
3384 
3385     /** The EEA device region feature is off by default. */
3386     boolean IS_EEA_DEVICE_FEATURE_ENABLED = false;
3387 
3388     /** Returns if the EEA device region feature has been enabled. */
isEeaDeviceFeatureEnabled()3389     default boolean isEeaDeviceFeatureEnabled() {
3390         return IS_EEA_DEVICE_FEATURE_ENABLED;
3391     }
3392 
3393     /** Default is that the device is in the EEA region. */
3394     boolean IS_EEA_DEVICE = true;
3395 
3396     /** Returns if device is in the EEA region. */
isEeaDevice()3397     default boolean isEeaDevice() {
3398         return IS_EEA_DEVICE;
3399     }
3400 
3401     /** Default is that the ui feature type logging is enabled. */
3402     boolean UI_FEATURE_TYPE_LOGGING_ENABLED = true;
3403 
3404     /** Returns if device is in the EEA region. */
isUiFeatureTypeLoggingEnabled()3405     default boolean isUiFeatureTypeLoggingEnabled() {
3406         return UI_FEATURE_TYPE_LOGGING_ENABLED;
3407     }
3408 
3409     /** Default is that the manual interaction feature is enabled. */
3410     boolean RECORD_MANUAL_INTERACTION_ENABLED = true;
3411 
3412     /** Returns if the manual interaction feature is enabled. */
getRecordManualInteractionEnabled()3413     default boolean getRecordManualInteractionEnabled() {
3414         return RECORD_MANUAL_INTERACTION_ENABLED;
3415     }
3416 
3417     /** Default is that the notification should be dismissed on click. */
3418     boolean DEFAULT_NOTIFICATION_DISMISSED_ON_CLICK = true;
3419 
3420     /** Determines whether the notification should be dismissed on click. */
getNotificationDismissedOnClick()3421     default boolean getNotificationDismissedOnClick() {
3422         return DEFAULT_NOTIFICATION_DISMISSED_ON_CLICK;
3423     }
3424 
3425     /**
3426      * The check activity feature is off by default. When enabled, we check whether all Rubidium
3427      * activities are enabled when we determine whether AdServices is enabled
3428      */
3429     boolean IS_BACK_COMPACT_ACTIVITY_FEATURE_ENABLED = false;
3430 
3431     /** Returns if the check activity feature has been enabled. */
isBackCompatActivityFeatureEnabled()3432     default boolean isBackCompatActivityFeatureEnabled() {
3433         return IS_BACK_COMPACT_ACTIVITY_FEATURE_ENABLED;
3434     }
3435 
3436     String UI_EEA_COUNTRIES =
3437             "AT," // Austria
3438                     + "BE," // Belgium
3439                     + "BG," // Bulgaria
3440                     + "HR," // Croatia
3441                     + "CY," // Republic of Cyprus
3442                     + "CZ," // Czech Republic
3443                     + "DK," // Denmark
3444                     + "EE," // Estonia
3445                     + "FI," // Finland
3446                     + "FR," // France
3447                     + "DE," // Germany
3448                     + "GR," // Greece
3449                     + "HU," // Hungary
3450                     + "IE," // Ireland
3451                     + "IT," // Italy
3452                     + "LV," // Latvia
3453                     + "LT," // Lithuania
3454                     + "LU," // Luxembourg
3455                     + "MT," // Malta
3456                     + "NL," // Netherlands
3457                     + "PL," // Poland
3458                     + "PT," // Portugal
3459                     + "RO," // Romania
3460                     + "SK," // Slovakia
3461                     + "SI," // Slovenia
3462                     + "ES," // Spain
3463                     + "SE," // Sweden
3464                     + "IS," // Iceland
3465                     + "LI," // Liechtenstein
3466                     + "NO," // Norway
3467                     + "CH," // Switzerland
3468                     + "GB," // Great Britain
3469                     + "GI," // Gibraltar
3470                     + "GP," // Guadeloupe
3471                     + "GG," // Guernsey
3472                     + "JE," // Jersey
3473                     + "VA," // Vatican City
3474                     + "AX," // Åland Islands
3475                     + "IC," // Canary Islands
3476                     + "EA," // Ceuta & Melilla
3477                     + "GF," // French Guiana
3478                     + "PF," // French Polynesia
3479                     + "TF," // French Southern Territories
3480                     + "MQ," // Martinique
3481                     + "YT," // Mayotte
3482                     + "NC," // New Caledonia
3483                     + "RE," // Réunion
3484                     + "BL," // St. Barthélemy
3485                     + "MF," // St. Martin
3486                     + "PM," // St. Pierre & Miquelon
3487                     + "SJ," // Svalbard & Jan Mayen
3488                     + "WF"; // Wallis & Futuna
3489 
3490     /** Returns the list of EEA countries in a String separated by comma */
getUiEeaCountries()3491     default String getUiEeaCountries() {
3492         return UI_EEA_COUNTRIES;
3493     }
3494 
3495     /**
3496      * GA UX enabled. It contains features that have to be enabled at the same time:
3497      *
3498      * <ul>
3499      *   <li>Updated consent landing page
3500      *   <li>Consent per API (instead of aggregated one)
3501      *   <li>Separate page to control Measurement API
3502      * </ul>
3503      *
3504      * This flag is set default to true as beta deprecated.
3505      */
3506     boolean GA_UX_FEATURE_ENABLED = true;
3507 
3508     /** Returns if the GA UX feature is enabled. */
getGaUxFeatureEnabled()3509     default boolean getGaUxFeatureEnabled() {
3510         return GA_UX_FEATURE_ENABLED;
3511     }
3512 
3513     /** Set the debug UX, which should correspond to the {@link PrivacySandboxUxCollection} enum. */
3514     String DEBUG_UX = "UNSUPPORTED_UX";
3515 
3516     /** Returns the debug UX. */
getDebugUx()3517     default String getDebugUx() {
3518         return DEBUG_UX;
3519     }
3520 
3521     /** add speed bump dialogs when turning on or off the toggle of Topics, apps, measurement */
3522     boolean TOGGLE_SPEED_BUMP_ENABLED = false;
3523 
3524     /** Returns if the toggle speed bump dialog feature is enabled. */
getToggleSpeedBumpEnabled()3525     default boolean getToggleSpeedBumpEnabled() {
3526         return TOGGLE_SPEED_BUMP_ENABLED;
3527     }
3528 
3529     long ASYNC_REGISTRATION_JOB_QUEUE_INTERVAL_MS = (int) TimeUnit.HOURS.toMillis(1);
3530 
3531     /** Returns the interval in which to run Registration Job Queue Service. */
getAsyncRegistrationJobQueueIntervalMs()3532     default long getAsyncRegistrationJobQueueIntervalMs() {
3533         return ASYNC_REGISTRATION_JOB_QUEUE_INTERVAL_MS;
3534     }
3535 
3536     /**
3537      * Registration Job Queue Kill Switch. The default value is false which means Registration Job
3538      * Queue is enabled. This flag is used for emergency shutdown of the Registration Job Queue.
3539      */
3540     boolean MEASUREMENT_REGISTRATION_JOB_QUEUE_KILL_SWITCH = false;
3541 
3542     /**
3543      * Returns the kill switch value for Registration Job Queue. The job will be disabled if either
3544      * the Global Kill Switch, Measurement Kill Switch, or the Registration Job Queue Kill Switch
3545      * value is true.
3546      */
getAsyncRegistrationJobQueueKillSwitch()3547     default boolean getAsyncRegistrationJobQueueKillSwitch() {
3548         return getLegacyMeasurementKillSwitch() || MEASUREMENT_REGISTRATION_JOB_QUEUE_KILL_SWITCH;
3549     }
3550 
3551     boolean MEASUREMENT_REGISTRATION_FALLBACK_JOB_KILL_SWITCH = false;
3552 
3553     /**
3554      * Returns the kill switch value for Registration Fallback Job. The Job will be disabled if
3555      * either the Global Kill Switch, Measurement Kill Switch, or the Registration Fallback Job Kill
3556      * Switch value is true.
3557      */
getAsyncRegistrationFallbackJobKillSwitch()3558     default boolean getAsyncRegistrationFallbackJobKillSwitch() {
3559         return getLegacyMeasurementKillSwitch()
3560                 || MEASUREMENT_REGISTRATION_FALLBACK_JOB_KILL_SWITCH;
3561     }
3562 
3563     /** Returns true if the given enrollmentId is blocked from using PP-API. */
isEnrollmentBlocklisted(String enrollmentId)3564     default boolean isEnrollmentBlocklisted(String enrollmentId) {
3565         return false;
3566     }
3567 
3568     /** Returns a list of enrollmentId blocked from using PP-API. */
getEnrollmentBlocklist()3569     default ImmutableList<String> getEnrollmentBlocklist() {
3570         return ImmutableList.of();
3571     }
3572 
3573     long DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_HASH_LIMIT = 100L;
3574 
3575     /** Returns debug keys hash limit. */
getMeasurementDebugJoinKeyHashLimit()3576     default long getMeasurementDebugJoinKeyHashLimit() {
3577         return DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_HASH_LIMIT;
3578     }
3579 
3580     /** Returns the limit to the number of unique AdIDs attempted to match for debug keys. */
3581     long DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_LIMIT = 5L;
3582 
getMeasurementPlatformDebugAdIdMatchingLimit()3583     default long getMeasurementPlatformDebugAdIdMatchingLimit() {
3584         return DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_LIMIT;
3585     }
3586 
3587     /** Kill switch to guard backward-compatible logging. See go/rbc-ww-logging */
3588     boolean COMPAT_LOGGING_KILL_SWITCH = false;
3589 
3590     /** Returns true if backward-compatible logging should be disabled; false otherwise. */
getCompatLoggingKillSwitch()3591     default boolean getCompatLoggingKillSwitch() {
3592         return COMPAT_LOGGING_KILL_SWITCH;
3593     }
3594 
3595     /** Kill switch to guard background jobs logging. */
3596     boolean BACKGROUND_JOBS_LOGGING_KILL_SWITCH = true;
3597 
3598     /** Returns true if background jobs logging should be disabled; false otherwise */
getBackgroundJobsLoggingKillSwitch()3599     default boolean getBackgroundJobsLoggingKillSwitch() {
3600         return BACKGROUND_JOBS_LOGGING_KILL_SWITCH;
3601     }
3602 
3603     // New Feature Flags
3604     boolean FLEDGE_REGISTER_AD_BEACON_ENABLED = false;
3605     boolean FLEDGE_CPC_BILLING_ENABLED = false;
3606     boolean FLEDGE_DATA_VERSION_HEADER_ENABLED = false;
3607 
3608     /** Returns whether the {@code registerAdBeacon} feature is enabled. */
getFledgeRegisterAdBeaconEnabled()3609     default boolean getFledgeRegisterAdBeaconEnabled() {
3610         return FLEDGE_REGISTER_AD_BEACON_ENABLED;
3611     }
3612 
3613     /** Returns whether the CPC billing feature is enabled. */
getFledgeCpcBillingEnabled()3614     default boolean getFledgeCpcBillingEnabled() {
3615         return FLEDGE_CPC_BILLING_ENABLED;
3616     }
3617 
3618     /** Returns whether the data version header feature is enabled. */
getFledgeDataVersionHeaderEnabled()3619     default boolean getFledgeDataVersionHeaderEnabled() {
3620         return FLEDGE_DATA_VERSION_HEADER_ENABLED;
3621     }
3622 
3623     // New fledge beacon reporting metrics flag.
3624     boolean FLEDGE_BEACON_REPORTING_METRICS_ENABLED = false;
3625 
3626     /**
3627      * Returns whether the fledge beacon reporting metrics is enabled. This flag should not be
3628      * ramped on S- prior to M-2024-04.
3629      */
getFledgeBeaconReportingMetricsEnabled()3630     default boolean getFledgeBeaconReportingMetricsEnabled() {
3631         return getFledgeRegisterAdBeaconEnabled() && FLEDGE_BEACON_REPORTING_METRICS_ENABLED;
3632     }
3633 
3634     // Fledge auction server API usage metrics flag.
3635     boolean FLEDGE_AUCTION_SERVER_API_USAGE_METRICS_ENABLED = false;
3636 
3637     /** Returns whether the fledge B&A API usage metrics is enabled */
getFledgeAuctionServerApiUsageMetricsEnabled()3638     default boolean getFledgeAuctionServerApiUsageMetricsEnabled() {
3639         return getFledgeAuctionServerEnabled() && FLEDGE_AUCTION_SERVER_API_USAGE_METRICS_ENABLED;
3640     }
3641 
3642     // Fledge key fetch metrics flag.
3643     boolean FLEDGE_AUCTION_SERVER_KEY_FETCH_METRICS_ENABLED = false;
3644 
3645     /** Returns whether the fledge auction server key fetch metrics feature is enabled */
getFledgeAuctionServerKeyFetchMetricsEnabled()3646     default boolean getFledgeAuctionServerKeyFetchMetricsEnabled() {
3647         return getFledgeAuctionServerEnabled() && FLEDGE_AUCTION_SERVER_KEY_FETCH_METRICS_ENABLED;
3648     }
3649 
3650     // Fledge select ads from outcomes API metrics flag.
3651     @FeatureFlag boolean FLEDGE_SELECT_ADS_FROM_OUTCOMES_API_METRICS_ENABLED = false;
3652 
3653     /** Returns whether the fledge select ads from outcomes API metrics feature is enabled */
getFledgeSelectAdsFromOutcomesApiMetricsEnabled()3654     default boolean getFledgeSelectAdsFromOutcomesApiMetricsEnabled() {
3655         return FLEDGE_SELECT_ADS_FROM_OUTCOMES_API_METRICS_ENABLED;
3656     }
3657 
3658     // Fledge CPC billing metrics flag.
3659     @FeatureFlag boolean FLEDGE_CPC_BILLING_METRICS_ENABLED = false;
3660 
3661     /** Returns whether the FLEDGE CPC billing metrics feature is enabled. */
getFledgeCpcBillingMetricsEnabled()3662     default boolean getFledgeCpcBillingMetricsEnabled() {
3663         return FLEDGE_CPC_BILLING_METRICS_ENABLED;
3664     }
3665 
3666     // Fledge data version header metrics flag.
3667     @FeatureFlag boolean FLEDGE_DATA_VERSION_HEADER_METRICS_ENABLED = false;
3668 
3669     /** Returns whether the FLEDGE data version header metrics feature is enabled. */
getFledgeDataVersionHeaderMetricsEnabled()3670     default boolean getFledgeDataVersionHeaderMetricsEnabled() {
3671         return FLEDGE_DATA_VERSION_HEADER_METRICS_ENABLED;
3672     }
3673 
3674     // Fledge report impression API metrics flag.
3675     @FeatureFlag boolean FLEDGE_REPORT_IMPRESSION_API_METRICS_ENABLED = false;
3676 
3677     /** Returns whether the FLEDGE report impression API metrics feature is enabled. */
getFledgeReportImpressionApiMetricsEnabled()3678     default boolean getFledgeReportImpressionApiMetricsEnabled() {
3679         return FLEDGE_REPORT_IMPRESSION_API_METRICS_ENABLED;
3680     }
3681 
3682     // Fledge JS script result code metrics flag.
3683     @FeatureFlag boolean FLEDGE_JS_SCRIPT_RESULT_CODE_METRICS_ENABLED = false;
3684 
3685     /** Returns whether the FLEDGE JS script result code metrics feature is enabled. */
getFledgeJsScriptResultCodeMetricsEnabled()3686     default boolean getFledgeJsScriptResultCodeMetricsEnabled() {
3687         return FLEDGE_JS_SCRIPT_RESULT_CODE_METRICS_ENABLED;
3688     }
3689 
3690     /**
3691      * Default allowlist of the enrollments for whom debug key insertion based on join key matching
3692      * is allowed.
3693      */
3694     String DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_ENROLLMENT_ALLOWLIST = "";
3695 
3696     /**
3697      * Allowlist of the enrollments for whom debug key insertion based on join key matching is
3698      * allowed.
3699      */
getMeasurementDebugJoinKeyEnrollmentAllowlist()3700     default String getMeasurementDebugJoinKeyEnrollmentAllowlist() {
3701         return DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_ENROLLMENT_ALLOWLIST;
3702     }
3703 
3704     /**
3705      * Default blocklist of the enrollments for whom debug key insertion based on AdID matching is
3706      * blocked.
3707      */
3708     String DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_BLOCKLIST = "*";
3709 
3710     /**
3711      * Blocklist of the enrollments for whom debug key insertion based on AdID matching is blocked.
3712      */
getMeasurementPlatformDebugAdIdMatchingEnrollmentBlocklist()3713     default String getMeasurementPlatformDebugAdIdMatchingEnrollmentBlocklist() {
3714         return DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_BLOCKLIST;
3715     }
3716 
3717     /** Default computation of adservices version */
3718     boolean DEFAULT_COMPUTE_VERSION_FROM_MAPPINGS_ENABLED = true;
3719 
3720     /** Get Compute adservices Version from mappings */
getEnableComputeVersionFromMappings()3721     default boolean getEnableComputeVersionFromMappings() {
3722         return DEFAULT_COMPUTE_VERSION_FROM_MAPPINGS_ENABLED;
3723     }
3724 
3725     /** Get mainline train version */
3726     String DEFAULT_MAINLINE_TRAIN_VERSION = "000000";
3727 
3728     /** Get mainline train version */
getMainlineTrainVersion()3729     default String getMainlineTrainVersion() {
3730         return DEFAULT_MAINLINE_TRAIN_VERSION;
3731     }
3732 
3733     /**
3734      * Default adservices version mappings Format -
3735      * start_range1,end_range1,header_version1|start_range2,end_range2,header_version2
3736      */
3737     String DEFAULT_ADSERVICES_VERSION_MAPPINGS =
3738             "341300000,341400000,202401|341400000,341500000,202402"
3739                     + "|341500000,341600000,202403|341600000,341700000,202404"
3740                     + "|341700000,341800000,202405|341800000,341900000,202406"
3741                     + "|341900000,342000000,202407|350800000,350900000,202408"
3742                     + "|350900000,351000000,202409|351000000,351100000,202410"
3743                     + "|351100000,351200000,202411|351200000,351300000,202412"
3744                     + "|351300000,351400000,202501|351400000,351500000,202502"
3745                     + "|351500000,351600000,202503|351600000,351700000,202504"
3746                     + "|351700000,351800000,202505|351800000,351900000,202506";
3747 
3748     /** Get adservices version mappings */
getAdservicesVersionMappings()3749     default String getAdservicesVersionMappings() {
3750         return DEFAULT_ADSERVICES_VERSION_MAPPINGS;
3751     }
3752 
3753     /** Default value for Measurement flexible event reporting API */
3754     boolean MEASUREMENT_FLEXIBLE_EVENT_REPORTING_API_ENABLED = false;
3755 
3756     /** Returns whether to enable Measurement flexible event reporting API */
getMeasurementFlexibleEventReportingApiEnabled()3757     default boolean getMeasurementFlexibleEventReportingApiEnabled() {
3758         return MEASUREMENT_FLEXIBLE_EVENT_REPORTING_API_ENABLED;
3759     }
3760 
3761     /** Default value for Measurement trigger data matching */
3762     boolean MEASUREMENT_ENABLE_TRIGGER_DATA_MATCHING = true;
3763 
3764     /** Returns whether to enable Measurement trigger data matching */
getMeasurementEnableTriggerDataMatching()3765     default boolean getMeasurementEnableTriggerDataMatching() {
3766         return MEASUREMENT_ENABLE_TRIGGER_DATA_MATCHING;
3767     }
3768 
3769     /** Default maximum sources per publisher */
3770     int MEASUREMENT_MAX_SOURCES_PER_PUBLISHER = 4096;
3771 
3772     /** Returns maximum sources per publisher */
getMeasurementMaxSourcesPerPublisher()3773     default int getMeasurementMaxSourcesPerPublisher() {
3774         return MEASUREMENT_MAX_SOURCES_PER_PUBLISHER;
3775     }
3776 
3777     /** Default maximum triggers per destination */
3778     int MEASUREMENT_MAX_TRIGGERS_PER_DESTINATION = 1024;
3779 
3780     /** Returns maximum triggers per destination */
getMeasurementMaxTriggersPerDestination()3781     default int getMeasurementMaxTriggersPerDestination() {
3782         return MEASUREMENT_MAX_TRIGGERS_PER_DESTINATION;
3783     }
3784 
3785     /** Default maximum Aggregate Reports per destination */
3786     int MEASUREMENT_MAX_AGGREGATE_REPORTS_PER_DESTINATION = 1024;
3787 
3788     /** Returns maximum Aggregate Reports per publisher */
getMeasurementMaxAggregateReportsPerDestination()3789     default int getMeasurementMaxAggregateReportsPerDestination() {
3790         return MEASUREMENT_MAX_AGGREGATE_REPORTS_PER_DESTINATION;
3791     }
3792 
3793     /** Default maximum Event Reports per destination */
3794     int MEASUREMENT_MAX_EVENT_REPORTS_PER_DESTINATION = 1024;
3795 
3796     /** Returns maximum Event Reports per destination */
getMeasurementMaxEventReportsPerDestination()3797     default int getMeasurementMaxEventReportsPerDestination() {
3798         return MEASUREMENT_MAX_EVENT_REPORTS_PER_DESTINATION;
3799     }
3800 
3801     /** Disable maximum number of aggregatable reports per source by default. */
3802     boolean MEASUREMENT_ENABLE_MAX_AGGREGATE_REPORTS_PER_SOURCE = false;
3803 
3804     /**
3805      * Returns true if maximum number of aggregatable reports per source is enabled, false
3806      * otherwise.
3807      */
getMeasurementEnableMaxAggregateReportsPerSource()3808     default boolean getMeasurementEnableMaxAggregateReportsPerSource() {
3809         return MEASUREMENT_ENABLE_MAX_AGGREGATE_REPORTS_PER_SOURCE;
3810     }
3811 
3812     /** Maximum Aggregate Reports per source. */
3813     int MEASUREMENT_MAX_AGGREGATE_REPORTS_PER_SOURCE = 20;
3814 
3815     /** Returns maximum Aggregate Reports per source. */
getMeasurementMaxAggregateReportsPerSource()3816     default int getMeasurementMaxAggregateReportsPerSource() {
3817         return MEASUREMENT_MAX_AGGREGATE_REPORTS_PER_SOURCE;
3818     }
3819 
3820     /** Maximum number of aggregation keys allowed during source registration. */
3821     int MEASUREMENT_MAX_AGGREGATE_KEYS_PER_SOURCE_REGISTRATION = 50;
3822 
3823     /** Returns maximum number of aggregation keys allowed during source registration. */
getMeasurementMaxAggregateKeysPerSourceRegistration()3824     default int getMeasurementMaxAggregateKeysPerSourceRegistration() {
3825         return MEASUREMENT_MAX_AGGREGATE_KEYS_PER_SOURCE_REGISTRATION;
3826     }
3827 
3828     /** Maximum number of aggregation keys allowed during trigger registration. */
3829     int MEASUREMENT_MAX_AGGREGATE_KEYS_PER_TRIGGER_REGISTRATION = 50;
3830 
3831     /** Returns maximum number of aggregation keys allowed during trigger registration. */
getMeasurementMaxAggregateKeysPerTriggerRegistration()3832     default int getMeasurementMaxAggregateKeysPerTriggerRegistration() {
3833         return MEASUREMENT_MAX_AGGREGATE_KEYS_PER_TRIGGER_REGISTRATION;
3834     }
3835 
3836     /**
3837      * Default early reporting windows for VTC type source. Derived from {@link
3838      * com.android.adservices.service.measurement.PrivacyParams#EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS}.
3839      */
3840     String MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS = "";
3841 
3842     /**
3843      * Returns configured comma separated early VTC based source's event reporting windows in
3844      * seconds.
3845      */
getMeasurementEventReportsVtcEarlyReportingWindows()3846     default String getMeasurementEventReportsVtcEarlyReportingWindows() {
3847         return MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS;
3848     }
3849 
3850     /**
3851      * Default early reporting windows for CTC type source. Derived from {@link
3852      * com.android.adservices.service.measurement.PrivacyParams#NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS}.
3853      */
3854     String MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS =
3855             String.join(
3856                     ",",
3857                     Long.toString(TimeUnit.DAYS.toSeconds(2)),
3858                     Long.toString(TimeUnit.DAYS.toSeconds(7)));
3859 
3860     /**
3861      * Returns configured comma separated early CTC based source's event reporting windows in
3862      * seconds.
3863      */
getMeasurementEventReportsCtcEarlyReportingWindows()3864     default String getMeasurementEventReportsCtcEarlyReportingWindows() {
3865         return MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS;
3866     }
3867 
3868     /** Disable aggregate report delay by default. */
3869     boolean MEASUREMENT_ENABLE_CONFIGURABLE_AGGREGATE_REPORT_DELAY = false;
3870 
3871     /** Returns true if aggregate report delay configurability is enabled, false otherwise. */
getMeasurementEnableConfigurableAggregateReportDelay()3872     default boolean getMeasurementEnableConfigurableAggregateReportDelay() {
3873         return MEASUREMENT_ENABLE_CONFIGURABLE_AGGREGATE_REPORT_DELAY;
3874     }
3875 
3876     /**
3877      * Default aggregate report delay. Derived from {@link
3878      * com.android.adservices.service.measurement.PrivacyParams#AGGREGATE_REPORT_MIN_DELAY} and
3879      * {@link com.android.adservices.service.measurement.PrivacyParams#AGGREGATE_REPORT_DELAY_SPAN}.
3880      */
3881     String MEASUREMENT_AGGREGATE_REPORT_DELAY_CONFIG =
3882             String.join(
3883                     ",",
3884                     Long.toString(TimeUnit.MINUTES.toMillis(0L)),
3885                     Long.toString(TimeUnit.MINUTES.toMillis(10L)));
3886 
3887     /**
3888      * Returns configured comma separated aggregate report min delay and aggregate report delay
3889      * span.
3890      */
getMeasurementAggregateReportDelayConfig()3891     default String getMeasurementAggregateReportDelayConfig() {
3892         return MEASUREMENT_AGGREGATE_REPORT_DELAY_CONFIG;
3893     }
3894 
3895     /** Default max allowed number of event reports. */
3896     int DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT = 1;
3897 
3898     /** Returns the default max allowed number of event reports. */
getMeasurementVtcConfigurableMaxEventReportsCount()3899     default int getMeasurementVtcConfigurableMaxEventReportsCount() {
3900         return DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT;
3901     }
3902 
3903     boolean MEASUREMENT_ENABLE_DESTINATION_PUBLISHER_ENROLLMENT_FIFO = false;
3904 
3905     /** Enable FIFO destinations based deletion of sources to accommodate an incoming source. */
getMeasurementEnableDestinationXPublisherXEnrollmentFifo()3906     default boolean getMeasurementEnableDestinationXPublisherXEnrollmentFifo() {
3907         return MEASUREMENT_ENABLE_DESTINATION_PUBLISHER_ENROLLMENT_FIFO;
3908     }
3909 
3910     boolean MEASUREMENT_ENABLE_FIFO_DESTINATIONS_DELETE_AGGREGATE_REPORTS = false;
3911 
3912     /**
3913      * Enable deletion of reports along with FIFO destinations. In practice it's a sub flag to
3914      * {@link #getMeasurementEnableDestinationXPublisherXEnrollmentFifo}
3915      */
getMeasurementEnableFifoDestinationsDeleteAggregateReports()3916     default boolean getMeasurementEnableFifoDestinationsDeleteAggregateReports() {
3917         return MEASUREMENT_ENABLE_FIFO_DESTINATIONS_DELETE_AGGREGATE_REPORTS;
3918     }
3919 
3920     /** Default Measurement ARA parsing alignment v1 feature flag. */
3921     boolean MEASUREMENT_ENABLE_ARA_DEDUPLICATION_ALIGNMENT_V1 = true;
3922 
3923     /** Returns whether Measurement ARA deduplication alignment v1 feature is enabled. */
getMeasurementEnableAraDeduplicationAlignmentV1()3924     default boolean getMeasurementEnableAraDeduplicationAlignmentV1() {
3925         return MEASUREMENT_ENABLE_ARA_DEDUPLICATION_ALIGNMENT_V1;
3926     }
3927 
3928     /** Default Measurement source deactivation after filtering feature flag. */
3929     boolean MEASUREMENT_ENABLE_SOURCE_DEACTIVATION_AFTER_FILTERING = false;
3930 
3931     /** Returns whether Measurement source deactivation after filtering feature is enabled. */
getMeasurementEnableSourceDeactivationAfterFiltering()3932     default boolean getMeasurementEnableSourceDeactivationAfterFiltering() {
3933         return MEASUREMENT_ENABLE_SOURCE_DEACTIVATION_AFTER_FILTERING;
3934     }
3935 
3936     /** Default Measurement app package name logging flag. */
3937     boolean MEASUREMENT_ENABLE_APP_PACKAGE_NAME_LOGGING = true;
3938 
3939     /** Returns whether Measurement app package name logging is enabled. */
getMeasurementEnableAppPackageNameLogging()3940     default boolean getMeasurementEnableAppPackageNameLogging() {
3941         return MEASUREMENT_ENABLE_APP_PACKAGE_NAME_LOGGING;
3942     }
3943 
3944     /** Default allowlist to enable app package name logging. */
3945     String MEASUREMENT_APP_PACKAGE_NAME_LOGGING_ALLOWLIST = "";
3946 
3947     /** Returns a list of app package names that allows logging. */
getMeasurementAppPackageNameLoggingAllowlist()3948     default String getMeasurementAppPackageNameLoggingAllowlist() {
3949         return MEASUREMENT_APP_PACKAGE_NAME_LOGGING_ALLOWLIST;
3950     }
3951 
3952     /** Disable measurement reporting jobs to throw unaccounted exceptions by default. */
3953     boolean MEASUREMENT_ENABLE_REPORTING_JOBS_THROW_UNACCOUNTED_EXCEPTION = false;
3954 
3955     /**
3956      * If enabled, measurement reporting jobs will throw unaccounted e.g. unexpected unchecked
3957      * exceptions.
3958      */
getMeasurementEnableReportingJobsThrowUnaccountedException()3959     default boolean getMeasurementEnableReportingJobsThrowUnaccountedException() {
3960         return MEASUREMENT_ENABLE_REPORTING_JOBS_THROW_UNACCOUNTED_EXCEPTION;
3961     }
3962 
3963     /**
3964      * Disable measurement reporting jobs to throw {@link org.json.JSONException} exception by
3965      * default.
3966      */
3967     boolean MEASUREMENT_ENABLE_REPORTING_JOBS_THROW_JSON_EXCEPTION = false;
3968 
3969     /** If enabled, measurement reporting jobs will throw {@link org.json.JSONException}. */
getMeasurementEnableReportingJobsThrowJsonException()3970     default boolean getMeasurementEnableReportingJobsThrowJsonException() {
3971         return MEASUREMENT_ENABLE_REPORTING_JOBS_THROW_JSON_EXCEPTION;
3972     }
3973 
3974     /** Disable measurement report to be deleted if any unrecoverable exception occurs. */
3975     boolean MEASUREMENT_ENABLE_DELETE_REPORTS_ON_UNRECOVERABLE_EXCEPTION = false;
3976 
3977     /** If enabled, measurement reports will get deleted if any unrecoverable exception occurs. */
getMeasurementEnableReportDeletionOnUnrecoverableException()3978     default boolean getMeasurementEnableReportDeletionOnUnrecoverableException() {
3979         return MEASUREMENT_ENABLE_DELETE_REPORTS_ON_UNRECOVERABLE_EXCEPTION;
3980     }
3981 
3982     /** Disable measurement aggregate reporting jobs to throw {@code CryptoException} by default. */
3983     boolean MEASUREMENT_ENABLE_REPORTING_JOBS_THROW_CRYPTO_EXCEPTION = false;
3984 
3985     /** If enabled, measurement aggregate reporting job will throw {@code CryptoException}. */
getMeasurementEnableReportingJobsThrowCryptoException()3986     default boolean getMeasurementEnableReportingJobsThrowCryptoException() {
3987         return MEASUREMENT_ENABLE_REPORTING_JOBS_THROW_CRYPTO_EXCEPTION;
3988     }
3989 
3990     /**
3991      * Disable measurement datastore to throw {@link
3992      * com.android.adservices.data.measurement.DatastoreException} when it occurs by default.
3993      */
3994     boolean MEASUREMENT_ENABLE_DATASTORE_MANAGER_THROW_DATASTORE_EXCEPTION = false;
3995 
3996     /**
3997      * If enabled, measurement DatastoreManager can throw DatastoreException wrapped in an unchecked
3998      * exception.
3999      */
getMeasurementEnableDatastoreManagerThrowDatastoreException()4000     default boolean getMeasurementEnableDatastoreManagerThrowDatastoreException() {
4001         return MEASUREMENT_ENABLE_DATASTORE_MANAGER_THROW_DATASTORE_EXCEPTION;
4002     }
4003 
4004     /** Set the sampling rate to 100% for unknown exceptions to be re-thrown. */
4005     float MEASUREMENT_THROW_UNKNOWN_EXCEPTION_SAMPLING_RATE = 1.0f;
4006 
4007     /** Sampling rate to decide whether to throw unknown exceptions for measurement. */
getMeasurementThrowUnknownExceptionSamplingRate()4008     default float getMeasurementThrowUnknownExceptionSamplingRate() {
4009         return MEASUREMENT_THROW_UNKNOWN_EXCEPTION_SAMPLING_RATE;
4010     }
4011 
4012     boolean MEASUREMENT_DELETE_UNINSTALLED_JOB_PERSISTED = true;
4013 
4014     /** Returns whether to persist this job across device reboots for delete uninstalled job. */
getMeasurementDeleteUninstalledJobPersisted()4015     default boolean getMeasurementDeleteUninstalledJobPersisted() {
4016         return MEASUREMENT_DELETE_UNINSTALLED_JOB_PERSISTED;
4017     }
4018 
4019     long MEASUREMENT_DELETE_UNINSTALLED_JOB_PERIOD_MS = TimeUnit.HOURS.toMillis(24);
4020 
4021     /**
4022      * Returns the min time period (in millis) between each uninstalled-record deletion maintenance
4023      * job run.
4024      */
getMeasurementDeleteUninstalledJobPeriodMs()4025     default long getMeasurementDeleteUninstalledJobPeriodMs() {
4026         return MEASUREMENT_DELETE_UNINSTALLED_JOB_PERIOD_MS;
4027     }
4028 
4029     boolean MEASUREMENT_DELETE_EXPIRED_JOB_PERSISTED = true;
4030 
4031     /** Returns whether to persist this job across device reboots for delete expired job. */
getMeasurementDeleteExpiredJobPersisted()4032     default boolean getMeasurementDeleteExpiredJobPersisted() {
4033         return MEASUREMENT_DELETE_EXPIRED_JOB_PERSISTED;
4034     }
4035 
4036     boolean MEASUREMENT_DELETE_EXPIRED_JOB_REQUIRES_DEVICE_IDLE = true;
4037 
4038     /** Returns whether to require device to be idle for delete expired job. */
getMeasurementDeleteExpiredJobRequiresDeviceIdle()4039     default boolean getMeasurementDeleteExpiredJobRequiresDeviceIdle() {
4040         return MEASUREMENT_DELETE_EXPIRED_JOB_REQUIRES_DEVICE_IDLE;
4041     }
4042 
4043     long MEASUREMENT_DELETE_EXPIRED_JOB_PERIOD_MS = TimeUnit.HOURS.toMillis(24);
4044 
4045     /**
4046      * Returns the min time period (in millis) between each expired-record deletion maintenance job
4047      * run.
4048      */
getMeasurementDeleteExpiredJobPeriodMs()4049     default long getMeasurementDeleteExpiredJobPeriodMs() {
4050         return MEASUREMENT_DELETE_EXPIRED_JOB_PERIOD_MS;
4051     }
4052 
4053     boolean MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW = true;
4054 
4055     /** Returns whether to require battery not low for event reporting job . */
getMeasurementEventReportingJobRequiredBatteryNotLow()4056     default boolean getMeasurementEventReportingJobRequiredBatteryNotLow() {
4057         return MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW;
4058     }
4059 
4060     int MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_UNMETERED;
4061 
4062     /** Returns the required network type for event reporting job . */
getMeasurementEventReportingJobRequiredNetworkType()4063     default int getMeasurementEventReportingJobRequiredNetworkType() {
4064         return MEASUREMENT_EVENT_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4065     }
4066 
4067     boolean MEASUREMENT_EVENT_REPORTING_JOB_PERSISTED = true;
4068 
4069     /** Returns whether to persist this job across device reboots for event reporting job. */
getMeasurementEventReportingJobPersisted()4070     default boolean getMeasurementEventReportingJobPersisted() {
4071         return MEASUREMENT_EVENT_REPORTING_JOB_PERSISTED;
4072     }
4073 
4074     boolean MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW = true;
4075 
4076     /** Returns whether to require battery not low for event fallback reporting job . */
getMeasurementEventFallbackReportingJobRequiredBatteryNotLow()4077     default boolean getMeasurementEventFallbackReportingJobRequiredBatteryNotLow() {
4078         return MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW;
4079     }
4080 
4081     int MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_ANY;
4082 
4083     /** Returns the required network type for event fallback reporting job . */
getMeasurementEventFallbackReportingJobRequiredNetworkType()4084     default int getMeasurementEventFallbackReportingJobRequiredNetworkType() {
4085         return MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4086     }
4087 
4088     boolean MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_PERSISTED = true;
4089 
4090     /**
4091      * Returns whether to persist this job across device reboots for event fallback reporting job.
4092      */
getMeasurementEventFallbackReportingJobPersisted()4093     default boolean getMeasurementEventFallbackReportingJobPersisted() {
4094         return MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_PERSISTED;
4095     }
4096 
4097     int MEASUREMENT_DEBUG_REPORTING_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_ANY;
4098 
4099     /** Returns the required network type for debug reporting job . */
getMeasurementDebugReportingJobRequiredNetworkType()4100     default int getMeasurementDebugReportingJobRequiredNetworkType() {
4101         return MEASUREMENT_DEBUG_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4102     }
4103 
4104     int MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_ANY;
4105 
4106     /** Returns the required network type for debug reporting fallback job . */
getMeasurementDebugReportingFallbackJobRequiredNetworkType()4107     default int getMeasurementDebugReportingFallbackJobRequiredNetworkType() {
4108         return MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_REQUIRED_NETWORK_TYPE;
4109     }
4110 
4111     boolean MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_PERSISTED = true;
4112 
4113     /**
4114      * Returns whether to persist this job across device reboots for debug fallback reporting job.
4115      */
getMeasurementDebugReportingFallbackJobPersisted()4116     default boolean getMeasurementDebugReportingFallbackJobPersisted() {
4117         return MEASUREMENT_DEBUG_REPORTING_FALLBACK_JOB_PERSISTED;
4118     }
4119 
4120     int MEASUREMENT_VERBOSE_DEBUG_REPORTING_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_ANY;
4121 
4122     /** Returns the required network type for verbose debug reporting job . */
getMeasurementVerboseDebugReportingJobRequiredNetworkType()4123     default int getMeasurementVerboseDebugReportingJobRequiredNetworkType() {
4124         return MEASUREMENT_VERBOSE_DEBUG_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4125     }
4126 
4127     boolean MEASUREMENT_VERBOSE_DEBUG_REPORTING_FALLBACK_JOB_PERSISTED = true;
4128 
4129     /**
4130      * Returns whether to persist this job across device reboots for verbose debug fallback
4131      * reporting job.
4132      */
getMeasurementVerboseDebugReportingFallbackJobPersisted()4133     default boolean getMeasurementVerboseDebugReportingFallbackJobPersisted() {
4134         return MEASUREMENT_VERBOSE_DEBUG_REPORTING_FALLBACK_JOB_PERSISTED;
4135     }
4136 
4137     boolean MEASUREMENT_ATTRIBUTION_JOB_PERSISTED = false;
4138 
4139     /** Returns whether to persist this job across device reboots for attribution job. */
getMeasurementAttributionJobPersisted()4140     default boolean getMeasurementAttributionJobPersisted() {
4141         return MEASUREMENT_ATTRIBUTION_JOB_PERSISTED;
4142     }
4143 
4144     long MEASUREMENT_ATTRIBUTION_JOB_TRIGGERING_DELAY_MS = TimeUnit.MINUTES.toMillis(2);
4145 
4146     /** Delay for attribution job triggering. */
getMeasurementAttributionJobTriggeringDelayMs()4147     default long getMeasurementAttributionJobTriggeringDelayMs() {
4148         return MEASUREMENT_ATTRIBUTION_JOB_TRIGGERING_DELAY_MS;
4149     }
4150 
4151     boolean MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_PERSISTED = true;
4152 
4153     /** Returns whether to persist this job across device reboots for attribution fallback job. */
getMeasurementAttributionFallbackJobPersisted()4154     default boolean getMeasurementAttributionFallbackJobPersisted() {
4155         return MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_PERSISTED;
4156     }
4157 
4158     int MEASUREMENT_ASYNC_REGISTRATION_QUEUE_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_ANY;
4159 
4160     /** Returns the required network type for async registration queue job. */
getMeasurementAsyncRegistrationQueueJobRequiredNetworkType()4161     default int getMeasurementAsyncRegistrationQueueJobRequiredNetworkType() {
4162         return MEASUREMENT_ASYNC_REGISTRATION_QUEUE_JOB_REQUIRED_NETWORK_TYPE;
4163     }
4164 
4165     boolean MEASUREMENT_ASYNC_REGISTRATION_QUEUE_JOB_PERSISTED = false;
4166 
4167     /**
4168      * Returns whether to persist this job across device reboots for async registration queue job.
4169      */
getMeasurementAsyncRegistrationQueueJobPersisted()4170     default boolean getMeasurementAsyncRegistrationQueueJobPersisted() {
4171         return MEASUREMENT_ASYNC_REGISTRATION_QUEUE_JOB_PERSISTED;
4172     }
4173 
4174     boolean MEASUREMENT_ASYNC_REGISTRATION_FALLBACK_JOB_REQUIRED_BATTERY_NOT_LOW = true;
4175 
4176     /** Returns whether to require battery not low for async registration queue fallback job. */
getMeasurementAsyncRegistrationFallbackJobRequiredBatteryNotLow()4177     default boolean getMeasurementAsyncRegistrationFallbackJobRequiredBatteryNotLow() {
4178         return MEASUREMENT_ASYNC_REGISTRATION_FALLBACK_JOB_REQUIRED_BATTERY_NOT_LOW;
4179     }
4180 
4181     int MEASUREMENT_ASYNC_REGISTRATION_FALLBACK_JOB_REQUIRED_NETWORK_TYPE =
4182             JobInfo.NETWORK_TYPE_ANY;
4183 
4184     /** Returns the required network type for async registration queue fallback job. */
getMeasurementAsyncRegistrationFallbackJobRequiredNetworkType()4185     default int getMeasurementAsyncRegistrationFallbackJobRequiredNetworkType() {
4186         return MEASUREMENT_ASYNC_REGISTRATION_FALLBACK_JOB_REQUIRED_NETWORK_TYPE;
4187     }
4188 
4189     boolean MEASUREMENT_ASYNC_REGISTRATION_FALLBACK_JOB_PERSISTED = true;
4190 
4191     /**
4192      * Returns whether to persist this job across device reboots for async registration queue
4193      * fallback job.
4194      */
getMeasurementAsyncRegistrationFallbackJobPersisted()4195     default boolean getMeasurementAsyncRegistrationFallbackJobPersisted() {
4196         return MEASUREMENT_ASYNC_REGISTRATION_FALLBACK_JOB_PERSISTED;
4197     }
4198 
4199     boolean MEASUREMENT_AGGREGATE_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW = true;
4200 
4201     /** Returns whether to require battery not low for aggregate reporting job. */
getMeasurementAggregateReportingJobRequiredBatteryNotLow()4202     default boolean getMeasurementAggregateReportingJobRequiredBatteryNotLow() {
4203         return MEASUREMENT_AGGREGATE_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW;
4204     }
4205 
4206     int MEASUREMENT_AGGREGATE_REPORTING_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_UNMETERED;
4207 
4208     /** Returns the required network type for aggregate reporting job. */
getMeasurementAggregateReportingJobRequiredNetworkType()4209     default int getMeasurementAggregateReportingJobRequiredNetworkType() {
4210         return MEASUREMENT_AGGREGATE_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4211     }
4212 
4213     boolean MEASUREMENT_AGGREGATE_REPORTING_JOB_PERSISTED = true;
4214 
4215     /** Returns whether to persist this job across device reboots for aggregate reporting job. */
getMeasurementAggregateReportingJobPersisted()4216     default boolean getMeasurementAggregateReportingJobPersisted() {
4217         return MEASUREMENT_AGGREGATE_REPORTING_JOB_PERSISTED;
4218     }
4219 
4220     boolean MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW = true;
4221 
4222     /** Returns whether to require battery not low for aggregate fallback reporting job. */
getMeasurementAggregateFallbackReportingJobRequiredBatteryNotLow()4223     default boolean getMeasurementAggregateFallbackReportingJobRequiredBatteryNotLow() {
4224         return MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW;
4225     }
4226 
4227     int MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_REQUIRED_NETWORK_TYPE =
4228             JobInfo.NETWORK_TYPE_ANY;
4229 
4230     /** Returns the required network type for aggregate fallback reporting job . */
getMeasurementAggregateFallbackReportingJobRequiredNetworkType()4231     default int getMeasurementAggregateFallbackReportingJobRequiredNetworkType() {
4232         return MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4233     }
4234 
4235     boolean MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_PERSISTED = true;
4236 
4237     /**
4238      * Returns whether to persist this job across device reboots for aggregate fallback reporting
4239      * job.
4240      */
getMeasurementAggregateFallbackReportingJobPersisted()4241     default boolean getMeasurementAggregateFallbackReportingJobPersisted() {
4242         return MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_PERSISTED;
4243     }
4244 
4245     boolean MEASUREMENT_IMMEDIATE_AGGREGATE_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW = true;
4246 
4247     /** Returns whether to require battery not low for immediate aggregate reporting job. */
getMeasurementImmediateAggregateReportingJobRequiredBatteryNotLow()4248     default boolean getMeasurementImmediateAggregateReportingJobRequiredBatteryNotLow() {
4249         return MEASUREMENT_IMMEDIATE_AGGREGATE_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW;
4250     }
4251 
4252     int MEASUREMENT_IMMEDIATE_AGGREGATE_REPORTING_JOB_REQUIRED_NETWORK_TYPE =
4253             JobInfo.NETWORK_TYPE_ANY;
4254 
4255     /** Returns the required network type for immediate aggregate reporting job. */
getMeasurementImmediateAggregateReportingJobRequiredNetworkType()4256     default int getMeasurementImmediateAggregateReportingJobRequiredNetworkType() {
4257         return MEASUREMENT_IMMEDIATE_AGGREGATE_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4258     }
4259 
4260     boolean MEASUREMENT_IMMEDIATE_AGGREGATE_REPORTING_JOB_PERSISTED = true;
4261 
4262     /** Returns whether to persist immediate aggregate reporting job across device reboots. */
getMeasurementImmediateAggregateReportingJobPersisted()4263     default boolean getMeasurementImmediateAggregateReportingJobPersisted() {
4264         return MEASUREMENT_IMMEDIATE_AGGREGATE_REPORTING_JOB_PERSISTED;
4265     }
4266 
4267     /** Default value for Reporting Job feature flag */
4268     @FeatureFlag boolean MEASUREMENT_REPORTING_JOB_ENABLED = false;
4269 
4270     /** Feature flag for Reporting Job */
getMeasurementReportingJobServiceEnabled()4271     default boolean getMeasurementReportingJobServiceEnabled() {
4272         // The Measurement API should be enabled as a prerequisite.
4273         return getMeasurementEnabled() && MEASUREMENT_REPORTING_JOB_ENABLED;
4274     }
4275 
4276     @ConfigFlag boolean MEASUREMENT_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW = true;
4277 
4278     /** Returns whether to require battery not low for reporting job. */
getMeasurementReportingJobRequiredBatteryNotLow()4279     default boolean getMeasurementReportingJobRequiredBatteryNotLow() {
4280         return MEASUREMENT_REPORTING_JOB_REQUIRED_BATTERY_NOT_LOW;
4281     }
4282 
4283     @ConfigFlag int MEASUREMENT_REPORTING_JOB_REQUIRED_NETWORK_TYPE = JobInfo.NETWORK_TYPE_ANY;
4284 
4285     /** Returns the required network type for reporting job. */
getMeasurementReportingJobRequiredNetworkType()4286     default int getMeasurementReportingJobRequiredNetworkType() {
4287         return MEASUREMENT_REPORTING_JOB_REQUIRED_NETWORK_TYPE;
4288     }
4289 
4290     @ConfigFlag boolean MEASUREMENT_REPORTING_JOB_PERSISTED = true;
4291 
4292     /** Returns whether to persist this job across device reboots for reporting job. */
getMeasurementReportingJobPersisted()4293     default boolean getMeasurementReportingJobPersisted() {
4294         return MEASUREMENT_REPORTING_JOB_PERSISTED;
4295     }
4296 
4297     /**
4298      * Default value for delaying reporting job service so that reports can be batched. Values are
4299      * in milliseconds.
4300      */
4301     @ConfigFlag
4302     long MEASUREMENT_REPORTING_JOB_SERVICE_BATCH_WINDOW_MILLIS = TimeUnit.MINUTES.toMillis(30);
4303 
4304     /**
4305      * Returns ms to defer transmission of reports in {@link
4306      * com.android.adservices.service.measurement.reporting.ReportingJobService}
4307      */
getMeasurementReportingJobServiceBatchWindowMillis()4308     default long getMeasurementReportingJobServiceBatchWindowMillis() {
4309         return MEASUREMENT_REPORTING_JOB_SERVICE_BATCH_WINDOW_MILLIS;
4310     }
4311 
4312     /**
4313      * Default value for minimum amount of time to wait between executions of reporting job service.
4314      * This is to throttle the service. Values are in milliseconds.
4315      */
4316     @ConfigFlag
4317     long MEASUREMENT_REPORTING_JOB_SERVICE_MIN_EXECUTION_WINDOW_MILLIS =
4318             TimeUnit.MINUTES.toMillis(30);
4319 
4320     /**
4321      * Returns minimum ms to wait between invocations of {@link
4322      * com.android.adservices.service.measurement.reporting.ReportingJobService}
4323      */
getMeasurementReportingJobServiceMinExecutionWindowMillis()4324     default long getMeasurementReportingJobServiceMinExecutionWindowMillis() {
4325         return MEASUREMENT_REPORTING_JOB_SERVICE_MIN_EXECUTION_WINDOW_MILLIS;
4326     }
4327 
4328     /** Default value for Null Aggregate Report feature flag. */
4329     boolean MEASUREMENT_NULL_AGGREGATE_REPORT_ENABLED = false;
4330 
4331     /** Null Aggregate Report feature flag. */
getMeasurementNullAggregateReportEnabled()4332     default boolean getMeasurementNullAggregateReportEnabled() {
4333         return MEASUREMENT_NULL_AGGREGATE_REPORT_ENABLED;
4334     }
4335 
4336     /** Default value for null aggregate report rate including source registration time. */
4337     float MEASUREMENT_NULL_AGG_REPORT_RATE_INCL_SOURCE_REGISTRATION_TIME = .008f;
4338 
4339     /**
4340      * Returns the rate at which null aggregate reports are generated whenever an actual aggregate
4341      * report is successfully generated.
4342      */
getMeasurementNullAggReportRateInclSourceRegistrationTime()4343     default float getMeasurementNullAggReportRateInclSourceRegistrationTime() {
4344         return MEASUREMENT_NULL_AGG_REPORT_RATE_INCL_SOURCE_REGISTRATION_TIME;
4345     }
4346 
4347     /** Default value for null report rate excluding source registration time. */
4348     float MEASUREMENT_NULL_AGG_REPORT_RATE_EXCL_SOURCE_REGISTRATION_TIME = .05f;
4349 
4350     /**
4351      * Returns the rate at which null aggregate reports are generated whenever the trigger is
4352      * configured to exclude the source registration time and there is no matching source.
4353      */
getMeasurementNullAggReportRateExclSourceRegistrationTime()4354     default float getMeasurementNullAggReportRateExclSourceRegistrationTime() {
4355         return MEASUREMENT_NULL_AGG_REPORT_RATE_EXCL_SOURCE_REGISTRATION_TIME;
4356     }
4357 
4358     /** Default value for Optional Source Registration Time feature flag. */
4359     boolean MEASUREMENT_SOURCE_REGISTRATION_TIME_OPTIONAL_FOR_AGG_REPORTS_ENABLED = false;
4360 
4361     /** Returns true if source registration time is optional for aggregatable reports. */
getMeasurementSourceRegistrationTimeOptionalForAggReportsEnabled()4362     default boolean getMeasurementSourceRegistrationTimeOptionalForAggReportsEnabled() {
4363         return MEASUREMENT_SOURCE_REGISTRATION_TIME_OPTIONAL_FOR_AGG_REPORTS_ENABLED;
4364     }
4365 
4366     /** Default U18 UX feature flag. */
4367     boolean DEFAULT_U18_UX_ENABLED = false;
4368 
4369     /** U18 UX feature flag.. */
getU18UxEnabled()4370     default boolean getU18UxEnabled() {
4371         return DEFAULT_U18_UX_ENABLED;
4372     }
4373 
4374     /** Default RVC UX feature flag.. */
4375     boolean DEFAULT_RVC_UX_ENABLED = SDK_INT == Build.VERSION_CODES.R;
4376 
4377     /** RVC UX feature flag.. */
getEnableRvcUx()4378     default boolean getEnableRvcUx() {
4379         return DEFAULT_RVC_UX_ENABLED;
4380     }
4381 
4382     /** Default RVC NOTIFICATION feature flag.. */
4383     boolean DEFAULT_RVC_POST_OTA_NOTIFICATION_ENABLED = false;
4384 
4385     /** RVC Notification feature flag.. */
getEnableRvcPostOtaNotification()4386     default boolean getEnableRvcPostOtaNotification() {
4387         return DEFAULT_RVC_POST_OTA_NOTIFICATION_ENABLED;
4388     }
4389 
4390     /** Default enableAdServices system API feature flag.. */
4391     boolean DEFAULT_ENABLE_AD_SERVICES_SYSTEM_API = false;
4392 
4393     /** enableAdServices system API feature flag.. */
getEnableAdServicesSystemApi()4394     default boolean getEnableAdServicesSystemApi() {
4395         return DEFAULT_ENABLE_AD_SERVICES_SYSTEM_API;
4396     }
4397 
4398     /** Disables client error logging for the list of error codes. Default value is empty list. */
4399     ImmutableList<Integer> ERROR_CODE_LOGGING_DENY_LIST = ImmutableList.of();
4400 
4401     /** Returns a list of error codes for which we don't want to do error logging. */
getErrorCodeLoggingDenyList()4402     default ImmutableList<Integer> getErrorCodeLoggingDenyList() {
4403         return ERROR_CODE_LOGGING_DENY_LIST;
4404     }
4405 
4406     /** Returns the map of UX flags. */
getUxFlags()4407     default Map<String, Boolean> getUxFlags() {
4408         return new HashMap<>();
4409     }
4410 
4411     /** Enable feature to unify destinations for event reports by default. */
4412     boolean DEFAULT_MEASUREMENT_ENABLE_COARSE_EVENT_REPORT_DESTINATIONS = true;
4413 
4414     /**
4415      * Returns true if event reporting destinations are enabled to be reported in a coarse manner,
4416      * i.e. both app and web destinations are merged into a single array in the event report.
4417      */
getMeasurementEnableCoarseEventReportDestinations()4418     default boolean getMeasurementEnableCoarseEventReportDestinations() {
4419         return DEFAULT_MEASUREMENT_ENABLE_COARSE_EVENT_REPORT_DESTINATIONS;
4420     }
4421 
4422     /** Privacy Params */
4423     int MEASUREMENT_MAX_DISTINCT_WEB_DESTINATIONS_IN_SOURCE_REGISTRATION = 3;
4424 
4425     /** Max distinct web destinations in a source registration. */
getMeasurementMaxDistinctWebDestinationsInSourceRegistration()4426     default int getMeasurementMaxDistinctWebDestinationsInSourceRegistration() {
4427         return MEASUREMENT_MAX_DISTINCT_WEB_DESTINATIONS_IN_SOURCE_REGISTRATION;
4428     }
4429 
4430     long MEASUREMENT_MAX_REPORTING_REGISTER_SOURCE_EXPIRATION_IN_SECONDS =
4431             TimeUnit.DAYS.toSeconds(30);
4432 
4433     /**
4434      * Max expiration value in seconds for attribution reporting register source. This value is also
4435      * the default if no expiration was specified.
4436      */
getMeasurementMaxReportingRegisterSourceExpirationInSeconds()4437     default long getMeasurementMaxReportingRegisterSourceExpirationInSeconds() {
4438         return MEASUREMENT_MAX_REPORTING_REGISTER_SOURCE_EXPIRATION_IN_SECONDS;
4439     }
4440 
4441     long MEASUREMENT_MIN_REPORTING_REGISTER_SOURCE_EXPIRATION_IN_SECONDS =
4442             TimeUnit.DAYS.toSeconds(1);
4443 
4444     /** Min expiration value in seconds for attribution reporting register source. */
getMeasurementMinReportingRegisterSourceExpirationInSeconds()4445     default long getMeasurementMinReportingRegisterSourceExpirationInSeconds() {
4446         return MEASUREMENT_MIN_REPORTING_REGISTER_SOURCE_EXPIRATION_IN_SECONDS;
4447     }
4448 
4449     long MEASUREMENT_MAX_INSTALL_ATTRIBUTION_WINDOW = TimeUnit.DAYS.toSeconds(30);
4450 
4451     /** Maximum limit of duration to determine attribution for a verified installation. */
getMeasurementMaxInstallAttributionWindow()4452     default long getMeasurementMaxInstallAttributionWindow() {
4453         return MEASUREMENT_MAX_INSTALL_ATTRIBUTION_WINDOW;
4454     }
4455 
4456     long MEASUREMENT_MIN_INSTALL_ATTRIBUTION_WINDOW = TimeUnit.DAYS.toSeconds(1);
4457 
4458     /** Minimum limit of duration to determine attribution for a verified installation. */
getMeasurementMinInstallAttributionWindow()4459     default long getMeasurementMinInstallAttributionWindow() {
4460         return MEASUREMENT_MIN_INSTALL_ATTRIBUTION_WINDOW;
4461     }
4462 
4463     long MEASUREMENT_MAX_POST_INSTALL_EXCLUSIVITY_WINDOW = TimeUnit.DAYS.toSeconds(30);
4464 
4465     /** Maximum acceptable install cooldown period. */
getMeasurementMaxPostInstallExclusivityWindow()4466     default long getMeasurementMaxPostInstallExclusivityWindow() {
4467         return MEASUREMENT_MAX_POST_INSTALL_EXCLUSIVITY_WINDOW;
4468     }
4469 
4470     long MEASUREMENT_MIN_POST_INSTALL_EXCLUSIVITY_WINDOW = 0L;
4471 
4472     /** Default and minimum value for cooldown period of source which led to installation. */
getMeasurementMinPostInstallExclusivityWindow()4473     default long getMeasurementMinPostInstallExclusivityWindow() {
4474         return MEASUREMENT_MIN_POST_INSTALL_EXCLUSIVITY_WINDOW;
4475     }
4476 
4477     int MEASUREMENT_MAX_SUM_OF_AGGREGATE_VALUES_PER_SOURCE = 65536;
4478 
4479     /**
4480      * L1, the maximum sum of the contributions (values) across all buckets for a given source
4481      * event.
4482      */
getMeasurementMaxSumOfAggregateValuesPerSource()4483     default int getMeasurementMaxSumOfAggregateValuesPerSource() {
4484         return MEASUREMENT_MAX_SUM_OF_AGGREGATE_VALUES_PER_SOURCE;
4485     }
4486 
4487     long MEASUREMENT_RATE_LIMIT_WINDOW_MILLISECONDS = TimeUnit.DAYS.toMillis(30);
4488 
4489     /**
4490      * Rate limit window for (Source Site, Destination Site, Reporting Site, Window) privacy unit.
4491      * 30 days.
4492      */
getMeasurementRateLimitWindowMilliseconds()4493     default long getMeasurementRateLimitWindowMilliseconds() {
4494         return MEASUREMENT_RATE_LIMIT_WINDOW_MILLISECONDS;
4495     }
4496 
4497     long MEASUREMENT_MIN_REPORTING_ORIGIN_UPDATE_WINDOW = TimeUnit.DAYS.toMillis(1);
4498 
4499     /** Minimum time window after which reporting origin can be migrated */
getMeasurementMinReportingOriginUpdateWindow()4500     default long getMeasurementMinReportingOriginUpdateWindow() {
4501         return MEASUREMENT_MIN_REPORTING_ORIGIN_UPDATE_WINDOW;
4502     }
4503 
4504     boolean MEASUREMENT_ENABLE_PREINSTALL_CHECK = false;
4505 
4506     /** Returns true when pre-install check is enabled. */
getMeasurementEnablePreinstallCheck()4507     default boolean getMeasurementEnablePreinstallCheck() {
4508         return MEASUREMENT_ENABLE_PREINSTALL_CHECK;
4509     }
4510 
4511     /** Default value of flag for session stable kill switches. */
4512     boolean MEASUREMENT_ENABLE_SESSION_STABLE_KILL_SWITCHES = true;
4513 
4514     /** Returns true when session stable kill switches are enabled. */
getMeasurementEnableSessionStableKillSwitches()4515     default boolean getMeasurementEnableSessionStableKillSwitches() {
4516         return MEASUREMENT_ENABLE_SESSION_STABLE_KILL_SWITCHES;
4517     }
4518 
4519     boolean MEASUREMENT_ENABLE_ATTRIBUTION_SCOPE = false;
4520 
4521     /** Returns true when attribution scope is enabled. */
getMeasurementEnableAttributionScope()4522     default boolean getMeasurementEnableAttributionScope() {
4523         return MEASUREMENT_ENABLE_ATTRIBUTION_SCOPE;
4524     }
4525 
4526     boolean MEASUREMENT_ENABLE_NAVIGATION_REPORTING_ORIGIN_CHECK = false;
4527 
4528     /**
4529      * Returns true if validation is enabled for one navigation per reporting origin per
4530      * registration.
4531      */
getMeasurementEnableNavigationReportingOriginCheck()4532     default boolean getMeasurementEnableNavigationReportingOriginCheck() {
4533         return MEASUREMENT_ENABLE_NAVIGATION_REPORTING_ORIGIN_CHECK;
4534     }
4535 
4536     @FeatureFlag
4537     boolean MEASUREMENT_ENABLE_SEPARATE_REPORT_TYPES_FOR_ATTRIBUTION_RATE_LIMIT = false;
4538 
4539     /**
4540      * Enables separate debug report types for event and aggregate attribution rate limit
4541      * violations.
4542      */
getMeasurementEnableSeparateReportTypesForAttributionRateLimit()4543     default boolean getMeasurementEnableSeparateReportTypesForAttributionRateLimit() {
4544         return MEASUREMENT_ENABLE_SEPARATE_REPORT_TYPES_FOR_ATTRIBUTION_RATE_LIMIT;
4545     }
4546 
4547     int MEASUREMENT_MAX_ATTRIBUTION_SCOPES_PER_SOURCE = 20;
4548 
4549     /** Returns max number of attribution scopes per source. */
getMeasurementMaxAttributionScopesPerSource()4550     default int getMeasurementMaxAttributionScopesPerSource() {
4551         return MEASUREMENT_MAX_ATTRIBUTION_SCOPES_PER_SOURCE;
4552     }
4553 
4554     int MEASUREMENT_MAX_ATTRIBUTION_SCOPE_LENGTH = 50;
4555 
4556     /** Returns max length of attribution scope. */
getMeasurementMaxAttributionScopeLength()4557     default int getMeasurementMaxAttributionScopeLength() {
4558         return MEASUREMENT_MAX_ATTRIBUTION_SCOPE_LENGTH;
4559     }
4560 
4561     /** Default value of flag for logging consent migration metrics when OTA from S to T+. */
4562     boolean DEFAULT_ADSERVICES_CONSENT_MIGRATION_LOGGING_ENABLED = true;
4563 
4564     /***
4565      * Returns true when logging consent migration metrics is enabled when OTA from S to T+.
4566      */
getAdservicesConsentMigrationLoggingEnabled()4567     default boolean getAdservicesConsentMigrationLoggingEnabled() {
4568         return DEFAULT_ADSERVICES_CONSENT_MIGRATION_LOGGING_ENABLED;
4569     }
4570 
4571     /** The default token for resetting consent notificatio.. */
4572     String CONSENT_NOTIFICATION_RESET_TOKEN = "";
4573 
4574     /** Returns the consent notification reset token. */
getConsentNotificationResetToken()4575     default String getConsentNotificationResetToken() {
4576         return CONSENT_NOTIFICATION_RESET_TOKEN;
4577     }
4578 
4579     /** Default whether Enrollment Mdd Record Deletion feature is enabled. */
4580     boolean ENROLLMENT_MDD_RECORD_DELETION_ENABLED = false;
4581 
4582     /** Returns whether the {@code enrollmentMddRecordDeletion} feature is enabled. */
getEnrollmentMddRecordDeletionEnabled()4583     default boolean getEnrollmentMddRecordDeletionEnabled() {
4584         return ENROLLMENT_MDD_RECORD_DELETION_ENABLED;
4585     }
4586 
4587     /** Default value of whether topics cobalt logging feature is enabled. */
4588     boolean TOPICS_COBALT_LOGGING_ENABLED = false;
4589 
4590     /**
4591      * Returns whether the topics cobalt logging feature is enabled.
4592      *
4593      * <p>The topics cobalt logging will be disabled either the {@code getCobaltLoggingEnabled} or
4594      * {@code TOPICS_COBALT_LOGGING_ENABLED} is {@code false}.
4595      */
getTopicsCobaltLoggingEnabled()4596     default boolean getTopicsCobaltLoggingEnabled() {
4597         return getCobaltLoggingEnabled() && TOPICS_COBALT_LOGGING_ENABLED;
4598     }
4599 
4600     /**
4601      * Default value of whether cobalt logging feature is enabled for source and trigger
4602      * registrations in measurement service.
4603      */
4604     @FeatureFlag boolean MSMT_REGISTRATION_COBALT_LOGGING_ENABLED = false;
4605 
4606     /**
4607      * Returns whether the cobalt logging feature is enabled for source and trigger registration in
4608      * measurement service .
4609      *
4610      * <p>The cobalt logging for measurement registration will be disabled either the {@code
4611      * getCobaltLoggingEnabled} or {@code MSMT_REGISTRATION_COBALT_LOGGING_ENABLED} is {@code
4612      * false}.
4613      */
getMsmtRegistrationCobaltLoggingEnabled()4614     default boolean getMsmtRegistrationCobaltLoggingEnabled() {
4615         return getCobaltLoggingEnabled() && MSMT_REGISTRATION_COBALT_LOGGING_ENABLED;
4616     }
4617 
4618     /**
4619      * Default value of whether cobalt logging feature is enabled for attribution metrics in
4620      * measurement service.
4621      */
4622     @FeatureFlag boolean MSMT_ATTRIBUTION_COBALT_LOGGING_ENABLED = false;
4623 
4624     /**
4625      * Returns whether the cobalt logging feature is enabled for attribution metrics in measurement
4626      * service .
4627      *
4628      * <p>The cobalt logging for measurement registration will be disabled either the {@code
4629      * getCobaltLoggingEnabled} or {@code MSMT_ATTRIBUTION_COBALT_LOGGING_ENABLED} is {@code false}.
4630      */
getMsmtAttributionCobaltLoggingEnabled()4631     default boolean getMsmtAttributionCobaltLoggingEnabled() {
4632         return getCobaltLoggingEnabled() && MSMT_ATTRIBUTION_COBALT_LOGGING_ENABLED;
4633     }
4634 
4635     /**
4636      * Default value of whether cobalt logging feature is enabled for reporting metrics in
4637      * measurement service.
4638      */
4639     @FeatureFlag boolean MSMT_REPORTING_COBALT_LOGGING_ENABLED = false;
4640 
4641     /**
4642      * Returns whether the cobalt logging feature is enabled for reporting metrics in measurement
4643      * service .
4644      *
4645      * <p>The cobalt logging for measurement registration will be disabled either the {@code
4646      * getCobaltLoggingEnabled} or {@code MSMT_REPORTING_COBALT_LOGGING_ENABLED} is {@code false}.
4647      */
getMsmtReportingCobaltLoggingEnabled()4648     default boolean getMsmtReportingCobaltLoggingEnabled() {
4649         return getCobaltLoggingEnabled() && MSMT_REPORTING_COBALT_LOGGING_ENABLED;
4650     }
4651 
4652     /** Default value of whether app name and api error cobalt logging feature is enabled. */
4653     boolean APP_NAME_API_ERROR_COBALT_LOGGING_ENABLED = false;
4654 
4655     /**
4656      * Returns whether the app name and api error cobalt logging feature is enabled.
4657      *
4658      * <p>The app name and api error cobalt logging will be disabled either the {@code
4659      * getCobaltLoggingEnabled} or {@code APP_NAME_API_ERROR_COBALT_LOGGING_ENABLED} is {@code
4660      * false}.
4661      */
getAppNameApiErrorCobaltLoggingEnabled()4662     default boolean getAppNameApiErrorCobaltLoggingEnabled() {
4663         return getCobaltLoggingEnabled() && APP_NAME_API_ERROR_COBALT_LOGGING_ENABLED;
4664     }
4665 
4666     /**
4667      * Default value of {@link AppNameApiErrorLogger} logging sampling rate.
4668      *
4669      * <p>The value should be an integer in the range of {@code [0, 100]}, where {@code 100} is to
4670      * log all events and {@code 0} is to log no events.
4671      */
4672     int APP_NAME_API_ERROR_COBALT_LOGGING_SAMPLING_RATE = 100;
4673 
4674     /** Returns the {@link AppNameApiErrorLogger} logging sampling rate. */
getAppNameApiErrorCobaltLoggingSamplingRate()4675     default int getAppNameApiErrorCobaltLoggingSamplingRate() {
4676         return APP_NAME_API_ERROR_COBALT_LOGGING_SAMPLING_RATE;
4677     }
4678 
4679     /** Default value of Cobalt Adservices Api key. */
4680     String COBALT_ADSERVICES_API_KEY_HEX = CobaltConstants.DEFAULT_API_KEY;
4681 
getCobaltAdservicesApiKeyHex()4682     default String getCobaltAdservicesApiKeyHex() {
4683         return COBALT_ADSERVICES_API_KEY_HEX;
4684     }
4685 
4686     /**
4687      * Default value of Adservices release stage for Cobalt. The value should correspond to {@link
4688      * com.google.cobalt.ReleaseStage} enum.
4689      */
4690     String ADSERVICES_RELEASE_STAGE_FOR_COBALT = CobaltConstants.DEFAULT_RELEASE_STAGE;
4691 
4692     /** Returns the value of Adservices release stage for Cobalt. */
getAdservicesReleaseStageForCobalt()4693     default String getAdservicesReleaseStageForCobalt() {
4694         return ADSERVICES_RELEASE_STAGE_FOR_COBALT;
4695     }
4696 
4697     /**
4698      * A feature flag to enable DB schema change to version 8 in Topics API. Version 8 is to add
4699      * logged_topic column to ReturnedTopic table.
4700      *
4701      * <p>Default value is false, which means the feature is disabled by default and needs to be
4702      * ramped up.
4703      */
4704     boolean ENABLE_LOGGED_TOPIC = false;
4705 
4706     /** Returns if to enable logged_topic column in ReturnedTopic table. */
getEnableLoggedTopic()4707     default boolean getEnableLoggedTopic() {
4708         return ENABLE_LOGGED_TOPIC;
4709     }
4710 
4711     /** Whether to enable database schema version 8 */
4712     boolean ENABLE_DATABASE_SCHEMA_VERSION_8 = false;
4713 
4714     /** Returns if to enable database schema version 8. */
getEnableDatabaseSchemaVersion8()4715     default boolean getEnableDatabaseSchemaVersion8() {
4716         return ENABLE_DATABASE_SCHEMA_VERSION_8;
4717     }
4718 
4719     /** Whether to enable database schema version 9. */
4720     boolean ENABLE_DATABASE_SCHEMA_VERSION_9 = false;
4721 
4722     /** Returns if to enable database schema version 9. */
getEnableDatabaseSchemaVersion9()4723     default boolean getEnableDatabaseSchemaVersion9() {
4724         return ENABLE_DATABASE_SCHEMA_VERSION_9;
4725     }
4726 
4727     /** Flag to control which allow list in getMeasurementApiStatus. */
4728     boolean MEASUREMENT_ENABLE_API_STATUS_ALLOW_LIST_CHECK = false;
4729 
4730     /** Returns the flag to control which allow list to use in getMeasurementApiStatus. */
getMsmtEnableApiStatusAllowListCheck()4731     default boolean getMsmtEnableApiStatusAllowListCheck() {
4732         return MEASUREMENT_ENABLE_API_STATUS_ALLOW_LIST_CHECK;
4733     }
4734 
4735     /**
4736      * Flag to control whether redirect registration urls should be modified to prefix the path
4737      * string with .well-known
4738      */
4739     boolean MEASUREMENT_ENABLE_REDIRECT_TO_WELL_KNOWN_PATH = false;
4740 
getMeasurementEnableRedirectToWellKnownPath()4741     default boolean getMeasurementEnableRedirectToWellKnownPath() {
4742         return MEASUREMENT_ENABLE_REDIRECT_TO_WELL_KNOWN_PATH;
4743     }
4744 
4745     @ConfigFlag
4746     long MEASUREMENT_MAX_REINSTALL_REATTRIBUTION_WINDOW_SECONDS = TimeUnit.DAYS.toSeconds(90);
4747 
4748     /** Maximum limit of duration to determine reattribution for a verified installation. */
getMeasurementMaxReinstallReattributionWindowSeconds()4749     default long getMeasurementMaxReinstallReattributionWindowSeconds() {
4750         return MEASUREMENT_MAX_REINSTALL_REATTRIBUTION_WINDOW_SECONDS;
4751     }
4752 
4753     @FeatureFlag boolean MEASUREMENT_ENABLE_REINSTALL_REATTRIBUTION = false;
4754 
4755     /** Returns whether to enable reinstall reattribution. */
getMeasurementEnableReinstallReattribution()4756     default boolean getMeasurementEnableReinstallReattribution() {
4757         return MEASUREMENT_ENABLE_REINSTALL_REATTRIBUTION;
4758     }
4759 
4760     /** Flag to enable context id for triggers */
4761     boolean MEASUREMENT_ENABLE_TRIGGER_CONTEXT_ID = false;
4762 
4763     /** Returns true if trigger context id is enabled. */
getMeasurementEnableTriggerContextId()4764     default boolean getMeasurementEnableTriggerContextId() {
4765         return MEASUREMENT_ENABLE_TRIGGER_CONTEXT_ID;
4766     }
4767 
4768     /** The maximum allowable length of a trigger context id. */
4769     int MEASUREMENT_MAX_LENGTH_OF_TRIGGER_CONTEXT_ID = 64;
4770 
4771     /** Return the maximum allowable length of a trigger context id. */
getMeasurementMaxLengthOfTriggerContextId()4772     default int getMeasurementMaxLengthOfTriggerContextId() {
4773         return MEASUREMENT_MAX_LENGTH_OF_TRIGGER_CONTEXT_ID;
4774     }
4775 
4776     /** Flag for enabling measurement registrations using ODP */
4777     boolean MEASUREMENT_ENABLE_ODP_WEB_TRIGGER_REGISTRATION = false;
4778 
4779     /** Return true if measurement registrations through ODP is enabled */
getMeasurementEnableOdpWebTriggerRegistration()4780     default boolean getMeasurementEnableOdpWebTriggerRegistration() {
4781         return MEASUREMENT_ENABLE_ODP_WEB_TRIGGER_REGISTRATION;
4782     }
4783 
4784     float DEFAULT_MEASUREMENT_PRIVACY_EPSILON = 14f;
4785 
getMeasurementPrivacyEpsilon()4786     default float getMeasurementPrivacyEpsilon() {
4787         return DEFAULT_MEASUREMENT_PRIVACY_EPSILON;
4788     }
4789 
4790     /**
4791      * Default whether to limit logging for enrollment metrics to avoid performance issues. This
4792      * includes not logging data that requires database queries and downloading MDD files.
4793      */
4794     boolean ENROLLMENT_ENABLE_LIMITED_LOGGING = false;
4795 
4796     /** Returns whether enrollment logging should be limited. */
getEnrollmentEnableLimitedLogging()4797     default boolean getEnrollmentEnableLimitedLogging() {
4798         return ENROLLMENT_ENABLE_LIMITED_LOGGING;
4799     }
4800 
4801     /**
4802      * Default value for if events will be registered as a source of attribution in addition to
4803      * being reported.
4804      */
4805     boolean FLEDGE_MEASUREMENT_REPORT_AND_REGISTER_EVENT_API_ENABLED = false;
4806 
4807     /**
4808      * Returns if events will be registered as a source of attribution in addition to being
4809      * reported.
4810      *
4811      * <p>This, unlocked by the short-term integration between Protected Audience (PA) and
4812      * Measurement's ARA, enables the {@link
4813      * android.adservices.adselection.AdSelectionManager#reportEvent} API to report an event and
4814      * register it as source of attribution, using a single API call, unified under the hood.
4815      *
4816      * <ul>
4817      *   <li>When enabled, by default: ARA will report and register the event.
4818      *   <li>When enabled, with fallback: PA will report the event and ARA will register the event.
4819      *   <li>When disabled, when {@link
4820      *       android.adservices.adselection.AdSelectionManager#reportEvent} is called, only PA will
4821      *       report the event.
4822      * </ul>
4823      */
getFledgeMeasurementReportAndRegisterEventApiEnabled()4824     default boolean getFledgeMeasurementReportAndRegisterEventApiEnabled() {
4825         return FLEDGE_MEASUREMENT_REPORT_AND_REGISTER_EVENT_API_ENABLED;
4826     }
4827 
4828     /** Default value for if the fallback for event reporting and source registration is enabled. */
4829     boolean FLEDGE_MEASUREMENT_REPORT_AND_REGISTER_EVENT_API_FALLBACK_ENABLED = false;
4830 
4831     /**
4832      * Returns if the fallback for event reporting and source registration is enabled.
4833      *
4834      * <ul>
4835      *   <li>Only relevant if {@link #getFledgeMeasurementReportAndRegisterEventApiEnabled} is
4836      *       {@code true}.
4837      *   <li>When enabled, PA will report the event and ARA will register the event.
4838      *   <li>When disabled, ARA will report and register the event.
4839      * </ul>
4840      *
4841      * <p>If enabled
4842      */
getFledgeMeasurementReportAndRegisterEventApiFallbackEnabled()4843     default boolean getFledgeMeasurementReportAndRegisterEventApiFallbackEnabled() {
4844         return getFledgeMeasurementReportAndRegisterEventApiEnabled()
4845                 && FLEDGE_MEASUREMENT_REPORT_AND_REGISTER_EVENT_API_FALLBACK_ENABLED;
4846     }
4847 
4848     /** Cobalt logging job period in milliseconds. */
4849     long COBALT_LOGGING_JOB_PERIOD_MS = 6 * 60 * 60 * 1000; // 6 hours.
4850 
4851     /** Returns the max time period (in milliseconds) between each cobalt logging job run. */
getCobaltLoggingJobPeriodMs()4852     default long getCobaltLoggingJobPeriodMs() {
4853         return COBALT_LOGGING_JOB_PERIOD_MS;
4854     }
4855 
4856     long COBALT_UPLOAD_SERVICE_UNBIND_DELAY_MS = 10 * 1000; // 10 seconds
4857 
4858     /**
4859      * Returns the amount of time Cobalt should wait (in milliseconds) before unbinding from its
4860      * upload service.
4861      */
getCobaltUploadServiceUnbindDelayMs()4862     default long getCobaltUploadServiceUnbindDelayMs() {
4863         return COBALT_UPLOAD_SERVICE_UNBIND_DELAY_MS;
4864     }
4865 
4866     /** Cobalt logging feature flag. */
4867     @FeatureFlag boolean COBALT_LOGGING_ENABLED = false;
4868 
4869     /**
4870      * Returns the feature flag value for cobalt logging job. The cobalt logging feature will be
4871      * disabled if either the Global Kill Switch or the Cobalt Logging enabled flag is true.
4872      */
getCobaltLoggingEnabled()4873     default boolean getCobaltLoggingEnabled() {
4874         return !getGlobalKillSwitch() && COBALT_LOGGING_ENABLED;
4875     }
4876 
4877     /** U18 UX detention channel is enabled by default. */
4878     boolean IS_U18_UX_DETENTION_CHANNEL_ENABLED_DEFAULT = true;
4879 
4880     /** Returns whether the U18 UX detentional channel is enabled. */
isU18UxDetentionChannelEnabled()4881     default boolean isU18UxDetentionChannelEnabled() {
4882         return IS_U18_UX_DETENTION_CHANNEL_ENABLED_DEFAULT;
4883     }
4884 
4885     /** U18 supervised account flow is enabled by default. */
4886     boolean IS_U18_SUPERVISED_ACCOUNT_ENABLED_DEFAULT = true;
4887 
4888     /** Returns whether the U18 supervised account is enabled. */
isU18SupervisedAccountEnabled()4889     default boolean isU18SupervisedAccountEnabled() {
4890         return IS_U18_SUPERVISED_ACCOUNT_ENABLED_DEFAULT;
4891     }
4892 
4893     /**
4894      * Default value to determine whether {@link
4895      * com.android.adservices.service.adid.AdIdCacheManager} is enabled to read AdId from and for
4896      * AdIdProvider to update AdId to.
4897      */
4898     boolean DEFAULT_ADID_CACHE_ENABLED = false;
4899 
4900     /**
4901      * Returns if {@link com.android.adservices.service.adid.AdIdCacheManager} is enabled to read
4902      * AdId from and for AdIdProvider to update AdId to.
4903      *
4904      * <ul>
4905      *   <li>When enabled, AdIdCacheManager will read AdId from the cache and AdIdProvider will
4906      *       update the cache if AdId changes.
4907      *   <li>When disabled, AdIdCacheManager will call AdIdProvider to get the AdId.
4908      * </ul>
4909      *
4910      * Returns if {@link com.android.adservices.service.adid.AdIdCacheManager} is enabled.
4911      */
getAdIdCacheEnabled()4912     default boolean getAdIdCacheEnabled() {
4913         return DEFAULT_ADID_CACHE_ENABLED;
4914     }
4915 
4916     long DEFAULT_AD_ID_FETCHER_TIMEOUT_MS = 50;
4917 
4918     /**
4919      * Returns configured timeout value for {@link
4920      * com.android.adservices.service.adselection.AdIdFetcher} logic.
4921      *
4922      * <p>The intended goal is to override this value for tests.
4923      *
4924      * <p>Returns Timeout in mills.
4925      */
getAdIdFetcherTimeoutMs()4926     default long getAdIdFetcherTimeoutMs() {
4927         return DEFAULT_AD_ID_FETCHER_TIMEOUT_MS;
4928     }
4929 
4930     /**
4931      * Default value to determine whether {@link
4932      * android.adservices.common.AdServicesCommonManager#enableAdServices} is enabled.
4933      */
4934     boolean DEFAULT_ENABLE_ADSERVICES_API_ENABLED = true;
4935 
4936     /**
4937      * Returns whether {@link android.adservices.common.AdServicesCommonManager#enableAdServices} is
4938      * enabled.
4939      */
getEnableAdservicesApiEnabled()4940     default boolean getEnableAdservicesApiEnabled() {
4941         return DEFAULT_ENABLE_ADSERVICES_API_ENABLED;
4942     }
4943 
4944     /**
4945      * Default value to determine whether AdServicesExtDataStorageService related APIs are enabled.
4946      */
4947     boolean DEFAULT_ENABLE_ADEXT_DATA_SERVICE_APIS = true;
4948 
4949     /** Returns whether AdServicesExtDataStorageService related APIs are enabled. */
getEnableAdExtDataServiceApis()4950     default boolean getEnableAdExtDataServiceApis() {
4951         return DEFAULT_ENABLE_ADEXT_DATA_SERVICE_APIS;
4952     }
4953 
4954     /**
4955      * Default value to determine whether {@link
4956      * android.adservices.common.AdServicesCommonManager#isAdServicesEnabled} is enabled.
4957      */
4958     boolean DEFAULT_ADSERVICES_ENABLEMENT_CHECK_ENABLED = true;
4959 
4960     /**
4961      * Returns whether {@link android.adservices.common.AdServicesCommonManager#isAdServicesEnabled}
4962      * is enabled.
4963      */
getAdservicesEnablementCheckEnabled()4964     default boolean getAdservicesEnablementCheckEnabled() {
4965         return DEFAULT_ADSERVICES_ENABLEMENT_CHECK_ENABLED;
4966     }
4967 
4968     /**
4969      * Enable AdServicesExtDataStorageServiceProxy read for consent data feature flag. Its meant to
4970      * enable the proxy service for testing when the actual service is unavailable The default value
4971      * is false.
4972      */
4973     boolean DEFAULT_ENABLE_ADEXT_SERVICE_DEBUG_PROXY = false;
4974 
4975     /**
4976      * @return value of enable AdExt service proxy.
4977      */
getEnableAdExtServiceDebugProxy()4978     default boolean getEnableAdExtServiceDebugProxy() {
4979         return DEFAULT_ENABLE_ADEXT_SERVICE_DEBUG_PROXY;
4980     }
4981 
4982     /**
4983      * Default value to determine how many logging events {@link AdServicesJobServiceLogger} should
4984      * upload to the server.
4985      *
4986      * <p>The value should be an integer in the range of [0, 100], where 100 is to log all events
4987      * and 0 is to log no events.
4988      */
4989     int DEFAULT_BACKGROUND_JOB_SAMPLING_LOGGING_RATE = 5;
4990 
4991     /**
4992      * Returns the sampling logging rate for {@link AdServicesJobServiceLogger} for logging events.
4993      */
getBackgroundJobSamplingLoggingRate()4994     default int getBackgroundJobSamplingLoggingRate() {
4995         return DEFAULT_BACKGROUND_JOB_SAMPLING_LOGGING_RATE;
4996     }
4997 
4998     /** Default value of the timeout for AppSearch write operations */
4999     int DEFAULT_APPSEARCH_WRITE_TIMEOUT_MS = 3000;
5000 
5001     /**
5002      * Gets the value of the timeout for AppSearch write operations, in milliseconds.
5003      *
5004      * @return the timeout, in milliseconds, for AppSearch write operations
5005      */
getAppSearchWriteTimeout()5006     default int getAppSearchWriteTimeout() {
5007         return DEFAULT_APPSEARCH_WRITE_TIMEOUT_MS;
5008     }
5009 
5010     /** Default value of the timeout for AppSearch read operations */
5011     int DEFAULT_APPSEARCH_READ_TIMEOUT_MS = 750;
5012 
5013     /**
5014      * Gets the value of the timeout for AppSearch read operations, in milliseconds.
5015      *
5016      * @return the timeout, in milliseconds, for AppSearch read operations
5017      */
getAppSearchReadTimeout()5018     default int getAppSearchReadTimeout() {
5019         return DEFAULT_APPSEARCH_READ_TIMEOUT_MS;
5020     }
5021 
5022     /** Default value of the timeout for AdExtDataStorageService write operations */
5023     @ConfigFlag int DEFAULT_ADEXT_WRITE_TIMEOUT_MS = 3000;
5024 
5025     /**
5026      * Gets the value of the timeout for AdExtDataStorageService write operations, in milliseconds.
5027      * Note that this is the platform side timeout which awaits for the operation to be completed by
5028      * the chimera service, which does not reside in AdServices. Ensure timeout on platform side is
5029      * greater with ~100 ms buffer to take into account binder communication latency.
5030      *
5031      * @return the timeout, in milliseconds, for AdExtDataStorageService write operations
5032      */
getAdExtWriteTimeoutMs()5033     default int getAdExtWriteTimeoutMs() {
5034         return DEFAULT_ADEXT_WRITE_TIMEOUT_MS;
5035     }
5036 
5037     /** Default value of the timeout for AdExtDataStorageService read operations */
5038     @ConfigFlag int DEFAULT_ADEXT_READ_TIMEOUT_MS = 1000;
5039 
5040     /**
5041      * Gets the value of the timeout for AdExtDataStorageService read operations, in milliseconds.
5042      * Note that this is the platform side timeout which awaits for the operation to be completed by
5043      * the chimera service, which does not reside in AdServices. Ensure timeout on platform side is
5044      * greater with ~100 ms buffer to take into account binder communication latency.
5045      *
5046      * @return the timeout, in milliseconds, for AdExtDataStoreageService read operations
5047      */
getAdExtReadTimeoutMs()5048     default int getAdExtReadTimeoutMs() {
5049         return DEFAULT_ADEXT_READ_TIMEOUT_MS;
5050     }
5051 
5052     /** default value for get adservices common states enabled */
5053     boolean DEFAULT_IS_GET_ADSERVICES_COMMON_STATES_API_ENABLED = false;
5054 
5055     /** Returns if the get adservices common states service enabled. */
isGetAdServicesCommonStatesApiEnabled()5056     default boolean isGetAdServicesCommonStatesApiEnabled() {
5057         return DEFAULT_IS_GET_ADSERVICES_COMMON_STATES_API_ENABLED;
5058     }
5059 
5060     /** Default value to determine whether ux related to the PAS Ux are enabled. */
5061     boolean DEFAULT_PAS_UX_ENABLED = false;
5062 
5063     /**
5064      * Returns whether features related to the PAS Ux are enabled. This flag has dependencies on
5065      * {@link #getEeaPasUxEnabled}. This method is the master control for PAS UX. If either EEA or
5066      * original PAS UX flag is on, then this method will return true.
5067      */
getPasUxEnabled()5068     default boolean getPasUxEnabled() {
5069         return DEFAULT_PAS_UX_ENABLED;
5070     }
5071 
5072     /** Default value to determine whether ux related to EEA PAS Ux are enabled. */
5073     boolean DEFAULT_EEA_PAS_UX_ENABLED = false;
5074 
5075     /** Returns whether features related to EEA PAS Ux are enabled. */
getEeaPasUxEnabled()5076     default boolean getEeaPasUxEnabled() {
5077         return DEFAULT_EEA_PAS_UX_ENABLED;
5078     }
5079 
5080     /** Default value of the KAnon Sign/join feature flag */
5081     boolean FLEDGE_DEFAULT_KANON_SIGN_JOIN_FEATURE_ENABLED = false;
5082 
5083     /** Default value of KAnon Sign/Join feature in PersistAdSelection endpoint */
5084     boolean FLEDGE_DEFAULT_KANON_FEATURE_AUCTION_SERVER_ENABLED = false;
5085 
5086     /** Default value of KAnon sign/join feature in On Device AdSelection path */
5087     boolean FLEDGE_DEFAULT_KANON_FEATURE_ON_DEVICE_AUCTION_ENABLED = false;
5088 
5089     /** Default value of k-anon fetch server parameters url. */
5090     String FLEDGE_DEFAULT_KANON_FETCH_SERVER_PARAMS_URL = "";
5091 
5092     /** Default value of k-anon get challenge url. */
5093     String FLEDGE_DEFAULT_GET_CHALLENGE_URL = "";
5094 
5095     /** Default value of k-anon register client parameters url. */
5096     String FLEDGE_DEFAULT_KANON_REGISTER_CLIENT_PARAMETERS_URL = "";
5097 
5098     /** Default value of k-anon get tokens url. */
5099     String FLEDGE_DEFAULT_KANON_GET_TOKENS_URL = "";
5100 
5101     /** Default value of k-anon get tokens url. */
5102     String FLEDGE_DEFAULT_KANON_JOIN_URL = "";
5103 
5104     /** Default value of kanon join authority */
5105     String FLEDGE_DEFAULT_KANON_AUTHORIY_URL_JOIN = "";
5106 
5107     /** Default size of batch in a kanon sign call */
5108     int FLEDGE_DEFAULT_KANON_SIGN_BATCH_SIZE = 32;
5109 
5110     /** Default percentage of messages to be signed/joined immediately. */
5111     int FLEDGE_DEFAULT_KANON_PERCENTAGE_IMMEDIATE_SIGN_JOIN_CALLS = 10;
5112 
5113     /** Default ttl of kanon-messages stored in the database */
5114     long FLEDGE_DEFAULT_KANON_MESSAGE_TTL_SECONDS = 2 * 7 * 24 * 60 * 60; // 2 weeks
5115 
5116     /** Default time period of the KAnon Sign/Join background process */
5117     long FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_TIME_PERIOD_MS = TimeUnit.HOURS.toMillis(24);
5118 
5119     /** Default number of messages processed in a single background process */
5120     int FLEDGE_DEFAULT_KANON_NUMBER_OF_MESSAGES_PER_BACKGROUND_PROCESS = 100;
5121 
5122     /** Default value for kanon background process flag */
5123     boolean FLEDGE_DEFAULT_KANON_BACKGROUND_PROCESS_ENABLED = false;
5124 
5125     /** Default value for kanon logging flag */
5126     boolean FLEDGE_DEFAULT_KANON_SIGN_JOIN_LOGGING_ENABLED = false;
5127 
5128     /** Default value for kanon key attestation feature flag */
5129     boolean FLEDGE_DEFAULT_KANON_KEY_ATTESTATION_ENABLED = false;
5130 
5131     /** Default value for kanon sign join set type */
5132     String FLEDGE_DEFAULT_KANON_SET_TYPE_TO_SIGN_JOIN = "fledge";
5133 
5134     /**
5135      * Default boolean for the field determining whether to run background job when the device's
5136      * battery is low.
5137      */
5138     boolean FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_REQUIRES_BATTERY_NOT_LOW = true;
5139 
5140     /**
5141      * Default boolean for the field determining whether to run background job when the device is
5142      * not idle.
5143      */
5144     boolean FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_REQUIRES_DEVICE_IDLE = true;
5145 
5146     /**
5147      * Default value for connection type required field for kanon background job. See {@link
5148      * JobInfo#NETWORK_TYPE_UNMETERED}
5149      */
5150     int FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_CONNECTION_TYPE = 2;
5151 
5152     /** Default value for kanon http client connect timeout in milliseconds */
5153     int FLEDGE_DEFAULT_KANON_HTTP_CLIENT_TIMEOUT_IN_MS = 5000;
5154 
5155     /**
5156      * This is a feature flag for KAnon Sign/Join feature.
5157      *
5158      * @return {@code true} if the feature is enabled, otherwise returns {@code false}.
5159      */
getFledgeKAnonSignJoinFeatureEnabled()5160     default boolean getFledgeKAnonSignJoinFeatureEnabled() {
5161         return getFledgeAuctionServerEnabled() && FLEDGE_DEFAULT_KANON_SIGN_JOIN_FEATURE_ENABLED;
5162     }
5163 
5164     /**
5165      * This is a feature flag for KAnon Sign/Join feature on the on device ad selection path.
5166      *
5167      * @return {@code true} if it's enabled, otherwise returns {@code false}.
5168      */
getFledgeKAnonSignJoinFeatureOnDeviceAuctionEnabled()5169     default boolean getFledgeKAnonSignJoinFeatureOnDeviceAuctionEnabled() {
5170         return FLEDGE_DEFAULT_KANON_FEATURE_ON_DEVICE_AUCTION_ENABLED;
5171     }
5172 
5173     /**
5174      * This is a feature flag for KAnon Sign/Join feature on the server auction path.
5175      *
5176      * @return {@code true} if it's enabled, otherwise returns {@code false}.
5177      */
getFledgeKAnonSignJoinFeatureAuctionServerEnabled()5178     default boolean getFledgeKAnonSignJoinFeatureAuctionServerEnabled() {
5179         return FLEDGE_DEFAULT_KANON_FEATURE_AUCTION_SERVER_ENABLED;
5180     }
5181 
5182     /**
5183      * This method returns the url that needs to be used to fetch server parameters during k-anon
5184      * sign call
5185      *
5186      * @return kanon fetch server params url.
5187      */
getFledgeKAnonFetchServerParamsUrl()5188     default String getFledgeKAnonFetchServerParamsUrl() {
5189         return FLEDGE_DEFAULT_KANON_FETCH_SERVER_PARAMS_URL;
5190     }
5191 
5192     /**
5193      * This method returns the url that needs to be used to fetch server parameters during k-anon
5194      * sign call
5195      *
5196      * @return kanon fetch server params url.
5197      */
getFledgeKAnonGetChallengeUrl()5198     default String getFledgeKAnonGetChallengeUrl() {
5199         return FLEDGE_DEFAULT_GET_CHALLENGE_URL;
5200     }
5201 
5202     /**
5203      * This method returns the url that needs to be used to register client parameters during k-anon
5204      * sign call.
5205      *
5206      * @return register client params url
5207      */
getFledgeKAnonRegisterClientParametersUrl()5208     default String getFledgeKAnonRegisterClientParametersUrl() {
5209         return FLEDGE_DEFAULT_KANON_REGISTER_CLIENT_PARAMETERS_URL;
5210     }
5211 
5212     /**
5213      * This method returns the url that needs to be used to fetch Tokens during k-anon sign call.
5214      *
5215      * @return default value of get tokens url
5216      */
getFledgeKAnonGetTokensUrl()5217     default String getFledgeKAnonGetTokensUrl() {
5218         return FLEDGE_DEFAULT_KANON_GET_TOKENS_URL;
5219     }
5220 
5221     /**
5222      * This method returns the url that needs to be used to make k-anon join call.
5223      *
5224      * @return default value of get tokens url
5225      */
getFledgeKAnonJoinUrl()5226     default String getFledgeKAnonJoinUrl() {
5227         return FLEDGE_DEFAULT_KANON_JOIN_URL;
5228     }
5229 
5230     /**
5231      * This method returns the value of batch size in a batch kanon sign call
5232      *
5233      * @return k-anon sign batch size
5234      */
getFledgeKAnonSignBatchSize()5235     default int getFledgeKAnonSignBatchSize() {
5236         return FLEDGE_DEFAULT_KANON_SIGN_BATCH_SIZE;
5237     }
5238 
5239     /**
5240      * This method returns an integer tha represents the percentage of the messages that needs to be
5241      * signed/joined immediately.
5242      */
getFledgeKAnonPercentageImmediateSignJoinCalls()5243     default int getFledgeKAnonPercentageImmediateSignJoinCalls() {
5244         return FLEDGE_DEFAULT_KANON_PERCENTAGE_IMMEDIATE_SIGN_JOIN_CALLS;
5245     }
5246 
5247     /**
5248      * This method returns the max ttl of a KAnonMessage in the Database. This is used to determine
5249      * when to clean up the old KAnonMessages from the database
5250      *
5251      * @return kanon max ttl for a kano message
5252      */
getFledgeKAnonMessageTtlSeconds()5253     default long getFledgeKAnonMessageTtlSeconds() {
5254         return FLEDGE_DEFAULT_KANON_MESSAGE_TTL_SECONDS;
5255     }
5256 
5257     /** This method returns the number of k-anon sign/join background processes per day. */
getFledgeKAnonBackgroundProcessTimePeriodInMs()5258     default long getFledgeKAnonBackgroundProcessTimePeriodInMs() {
5259         return FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_TIME_PERIOD_MS;
5260     }
5261 
5262     /**
5263      * This method returns the number of k-anon messages to be processed per background process run.
5264      */
getFledgeKAnonMessagesPerBackgroundProcess()5265     default int getFledgeKAnonMessagesPerBackgroundProcess() {
5266         return FLEDGE_DEFAULT_KANON_NUMBER_OF_MESSAGES_PER_BACKGROUND_PROCESS;
5267     }
5268 
5269     /**
5270      * This method returns {@code true} if the kanon background process is enabled, {@code false}
5271      * otherwise.
5272      */
getFledgeKAnonBackgroundProcessEnabled()5273     default boolean getFledgeKAnonBackgroundProcessEnabled() {
5274         return getFledgeKAnonSignJoinFeatureEnabled()
5275                 && FLEDGE_DEFAULT_KANON_BACKGROUND_PROCESS_ENABLED;
5276     }
5277 
5278     /**
5279      * This method returns {@code true} if the telemetry logging for kanon is enabled, {@code false}
5280      * otherwise.
5281      */
getFledgeKAnonLoggingEnabled()5282     default boolean getFledgeKAnonLoggingEnabled() {
5283         return getFledgeKAnonSignJoinFeatureEnabled()
5284                 && FLEDGE_DEFAULT_KANON_SIGN_JOIN_LOGGING_ENABLED;
5285     }
5286 
5287     /**
5288      * This method return {@code true} if the KAnon Key attestaion is enabled, {@code false}
5289      * otherwise.
5290      */
getFledgeKAnonKeyAttestationEnabled()5291     default boolean getFledgeKAnonKeyAttestationEnabled() {
5292         return getFledgeKAnonSignJoinFeatureEnabled()
5293                 && FLEDGE_DEFAULT_KANON_KEY_ATTESTATION_ENABLED;
5294     }
5295 
5296     /**
5297      * This method returns the type of set we need to join during kanon sign join process. eg: In
5298      * the following example, fledge is the set type to join. "types/fledge/set/hashset"
5299      */
getFledgeKAnonSetTypeToSignJoin()5300     default String getFledgeKAnonSetTypeToSignJoin() {
5301         return FLEDGE_DEFAULT_KANON_SET_TYPE_TO_SIGN_JOIN;
5302     }
5303 
5304     /**
5305      * This method returns the url authority that will be used in the {@link
5306      * com.android.adservices.service.common.bhttp.BinaryHttpMessage}. This BinaryHttpMessage is
5307      * sent as part of kanon http join request.
5308      */
getFledgeKAnonUrlAuthorityToJoin()5309     default String getFledgeKAnonUrlAuthorityToJoin() {
5310         return FLEDGE_DEFAULT_KANON_AUTHORIY_URL_JOIN;
5311     }
5312 
5313     /** This method returns the value for kanon http client connect timeout in milliseconds. */
getFledgeKanonHttpClientTimeoutInMs()5314     default int getFledgeKanonHttpClientTimeoutInMs() {
5315         return FLEDGE_DEFAULT_KANON_HTTP_CLIENT_TIMEOUT_IN_MS;
5316     }
5317 
5318     /**
5319      * This method returns the boolean field determining whether to run background job when the
5320      * device's battery is low.
5321      */
getFledgeKAnonBackgroundJobRequiresBatteryNotLow()5322     default boolean getFledgeKAnonBackgroundJobRequiresBatteryNotLow() {
5323         return FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_REQUIRES_BATTERY_NOT_LOW;
5324     }
5325 
5326     /**
5327      * This method returns the boolean field determining whether to run background job when the
5328      * device is not idle.
5329      */
getFledgeKAnonBackgroundJobRequiresDeviceIdle()5330     default boolean getFledgeKAnonBackgroundJobRequiresDeviceIdle() {
5331         return FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_REQUIRES_DEVICE_IDLE;
5332     }
5333 
5334     /**
5335      * This method returns the value for connection type required field for kanon background job.
5336      * See {@link JobInfo#NETWORK_TYPE_UNMETERED}
5337      */
getFledgeKanonBackgroundJobConnectionType()5338     default int getFledgeKanonBackgroundJobConnectionType() {
5339         return FLEDGE_DEFAULT_KANON_BACKGROUND_JOB_CONNECTION_TYPE;
5340     }
5341 
5342     /*
5343      * The allow-list for PP APIs. This list has the list of app package names that we allow
5344      * using PP APIs.
5345      * App Package Name that does not belong to this allow-list will not be able to use PP APIs.
5346      * If this list has special value "*", then all package names are allowed.
5347      * There must be not any empty space between comma.
5348      */
5349     String GET_ADSERVICES_COMMON_STATES_ALLOW_LIST = "com.android.adservices.tests.ui.common";
5350 
5351     /**
5352      * Returns bypass List for Get AdServices Common States app signature check. Apps with package
5353      * name on this list will bypass the signature check
5354      */
getAdServicesCommonStatesAllowList()5355     default String getAdServicesCommonStatesAllowList() {
5356         return GET_ADSERVICES_COMMON_STATES_ALLOW_LIST;
5357     }
5358 
5359     /** Default value for the base64 encoded Job Policy proto for AdServices. */
5360     @ConfigFlag String AD_SERVICES_MODULE_JOB_POLICY = "";
5361 
5362     /** Returns the base64 encoded Job Policy proto for AdServices. */
getAdServicesModuleJobPolicy()5363     default String getAdServicesModuleJobPolicy() {
5364         return AD_SERVICES_MODULE_JOB_POLICY;
5365     }
5366 
5367     /**
5368      * Default value for the enabled status of the {@link
5369      * com.android.adservices.service.common.RetryStrategy}.
5370      */
5371     boolean DEFAULT_AD_SERVICES_RETRY_STRATEGY_ENABLED = false;
5372 
5373     /**
5374      * Returns the enabled status of the AdServices {@link
5375      * com.android.adservices.service.common.RetryStrategy}.
5376      */
getAdServicesRetryStrategyEnabled()5377     default boolean getAdServicesRetryStrategyEnabled() {
5378         return DEFAULT_AD_SERVICES_RETRY_STRATEGY_ENABLED;
5379     }
5380 
5381     /**
5382      * Default value for the max number of retry attempts for {@link
5383      * com.android.adservices.service.js.JSScriptEngine}
5384      */
5385     int DEFAULT_AD_SERVICES_JS_SCRIPT_ENGINE_MAX_RETRY_ATTEMPTS = 1;
5386 
5387     /**
5388      * Returns the max number of retry attempts for {@link
5389      * com.android.adservices.service.js.JSScriptEngine}.
5390      */
getAdServicesJsScriptEngineMaxRetryAttempts()5391     default int getAdServicesJsScriptEngineMaxRetryAttempts() {
5392         return DEFAULT_AD_SERVICES_JS_SCRIPT_ENGINE_MAX_RETRY_ATTEMPTS;
5393     }
5394 
5395     /** Default value for consent manager v2 flag */
5396     boolean DEFAULT_ENABLE_CONSENT_MANAGER_V2 = false;
5397 
5398     /** Gets the Consent Manager V2 enable flag. */
getEnableConsentManagerV2()5399     default boolean getEnableConsentManagerV2() {
5400         return DEFAULT_ENABLE_CONSENT_MANAGER_V2;
5401     }
5402 
5403     /** Protected app signals API extended metrics flag. */
5404     boolean PAS_EXTENDED_METRICS_ENABLED = false;
5405 
5406     /** Returns whether the PAS API extended metrics is enabled. */
getPasExtendedMetricsEnabled()5407     default boolean getPasExtendedMetricsEnabled() {
5408         return PAS_EXTENDED_METRICS_ENABLED;
5409     }
5410 
5411     /** Default enablement for applying SPE (Scheduling Policy Engine) to pilot jobs. */
5412     @FeatureFlag boolean DEFAULT_SPE_ON_PILOT_JOBS_ENABLED = false;
5413 
5414     /** Returns the default enablement of applying SPE (Scheduling Policy Engine) to pilot jobs. */
getSpeOnPilotJobsEnabled()5415     default boolean getSpeOnPilotJobsEnabled() {
5416         return DEFAULT_SPE_ON_PILOT_JOBS_ENABLED;
5417     }
5418 
5419     /** A feature flag to enable the use of Enrollment API Based Schema. */
5420     @FeatureFlag boolean ENROLLMENT_API_BASED_SCHEMA_ENABLED = false;
5421 
5422     /**
5423      * @return the enabled status for enrollment api based schema.
5424      */
getEnrollmentApiBasedSchemaEnabled()5425     default boolean getEnrollmentApiBasedSchemaEnabled() {
5426         return ENROLLMENT_API_BASED_SCHEMA_ENABLED;
5427     }
5428 
5429     /** Whether to enable shared database schema version 4 */
5430     @FeatureFlag boolean SHARED_DATABASE_SCHEMA_VERSION_4_ENABLED = false;
5431 
5432     /**
5433      * @return if to enable shared database schema version 4.
5434      */
getSharedDatabaseSchemaVersion4Enabled()5435     default boolean getSharedDatabaseSchemaVersion4Enabled() {
5436         return SHARED_DATABASE_SCHEMA_VERSION_4_ENABLED;
5437     }
5438 
5439     /** Default value for table region fix flag. */
5440     boolean DEFAULT_ENABLE_TABLET_REGION_FIX = false;
5441 
5442     /**
5443      * @return if to enable tablet region fix.
5444      */
getEnableTabletRegionFix()5445     default boolean getEnableTabletRegionFix() {
5446         return DEFAULT_ENABLE_TABLET_REGION_FIX;
5447     }
5448 
5449     /** Default value for custom error code sampling enabled. */
5450     @FeatureFlag boolean DEFAULT_CUSTOM_ERROR_CODE_SAMPLING_ENABLED = false;
5451 
5452     /** Returns {@code boolean} determining whether custom error code sampling is enabled. */
getCustomErrorCodeSamplingEnabled()5453     default boolean getCustomErrorCodeSamplingEnabled() {
5454         return DEFAULT_CUSTOM_ERROR_CODE_SAMPLING_ENABLED;
5455     }
5456 
5457     /** Read timeout for downloading PAS encoding scripts in milliseconds */
5458     int DEFAULT_PAS_SCRIPT_DOWNLOAD_READ_TIMEOUT_MS = 5000;
5459 
5460     /**
5461      * @return Read timeout for downloading PAS encoding scripts in milliseconds
5462      */
getPasScriptDownloadReadTimeoutMs()5463     default int getPasScriptDownloadReadTimeoutMs() {
5464         return DEFAULT_PAS_SCRIPT_DOWNLOAD_READ_TIMEOUT_MS;
5465     }
5466 
5467     /** Connection timeout for downloading PAS encoding scripts in milliseconds */
5468     int DEFAULT_PAS_SCRIPT_DOWNLOAD_CONNECTION_TIMEOUT_MS = 5000;
5469 
5470     /**
5471      * @return Connection timeout for downloading PAS encoding scripts in milliseconds
5472      */
getPasScriptDownloadConnectionTimeoutMs()5473     default int getPasScriptDownloadConnectionTimeoutMs() {
5474         return DEFAULT_PAS_SCRIPT_DOWNLOAD_CONNECTION_TIMEOUT_MS;
5475     }
5476 
5477     /** Read timeout for downloading PAS signals in milliseconds */
5478     int DEFAULT_PAS_SIGNALS_DOWNLOAD_READ_TIMEOUT_MS = 5000;
5479 
5480     /**
5481      * @return Read timeout for downloading PAS signals in milliseconds
5482      */
getPasSignalsDownloadReadTimeoutMs()5483     default int getPasSignalsDownloadReadTimeoutMs() {
5484         return DEFAULT_PAS_SIGNALS_DOWNLOAD_READ_TIMEOUT_MS;
5485     }
5486 
5487     /** Connection timeout for downloading PAS encoding signals in milliseconds */
5488     int DEFAULT_PAS_SIGNALS_DOWNLOAD_CONNECTION_TIMEOUT_MS = 5000;
5489 
5490     /**
5491      * @return Connection timeout for downloading PAS signals in milliseconds
5492      */
getPasSignalsDownloadConnectionTimeoutMs()5493     default int getPasSignalsDownloadConnectionTimeoutMs() {
5494         return DEFAULT_PAS_SIGNALS_DOWNLOAD_CONNECTION_TIMEOUT_MS;
5495     }
5496 
5497     /** Timeout for executing PAS encoding scripts in milliseconds */
5498     int DEFAULT_PAS_SCRIPT_EXECUTION_TIMEOUT_MS = 5000;
5499 
5500     /**
5501      * @return Timeout for executing PAS encoding scripts in milliseconds
5502      */
getPasScriptExecutionTimeoutMs()5503     default int getPasScriptExecutionTimeoutMs() {
5504         return DEFAULT_PAS_SCRIPT_EXECUTION_TIMEOUT_MS;
5505     }
5506 
5507     /** Default enablement for applying SPE (Scheduling Policy Engine) to the second pilot jobs. */
5508     @FeatureFlag boolean DEFAULT_SPE_ON_PILOT_JOBS_BATCH_2_ENABLED = false;
5509 
5510     /**
5511      * Returns the default enablement of applying SPE (Scheduling Policy Engine) to the second pilot
5512      * jobs.
5513      */
getSpeOnPilotJobsBatch2Enabled()5514     default boolean getSpeOnPilotJobsBatch2Enabled() {
5515         return DEFAULT_SPE_ON_PILOT_JOBS_BATCH_2_ENABLED;
5516     }
5517 
5518     /**
5519      * Default enablement for applying SPE (Scheduling Policy Engine) to {@code EpochJobService}.
5520      */
5521     @FeatureFlag boolean DEFAULT_SPE_ON_EPOCH_JOB_ENABLED = false;
5522 
5523     /**
5524      * Returns the default enablement of applying SPE (Scheduling Policy Engine) to {@code
5525      * EpochJobService}.
5526      */
getSpeOnEpochJobEnabled()5527     default boolean getSpeOnEpochJobEnabled() {
5528         return DEFAULT_SPE_ON_EPOCH_JOB_ENABLED;
5529     }
5530 
5531     /**
5532      * Default enablement for applying SPE (Scheduling Policy Engine) to {@code
5533      * BackgroundFetchJobService}.
5534      */
5535     @FeatureFlag boolean DEFAULT_SPE_ON_BACKGROUND_FETCH_JOB_ENABLED = false;
5536 
5537     /**
5538      * Returns the default enablement of applying SPE (Scheduling Policy Engine) to {@code
5539      * BackgroundFetchJobService}.
5540      */
getSpeOnBackgroundFetchJobEnabled()5541     default boolean getSpeOnBackgroundFetchJobEnabled() {
5542         return DEFAULT_SPE_ON_BACKGROUND_FETCH_JOB_ENABLED;
5543     }
5544 
5545     /**
5546      * Default enablement for applying SPE (Scheduling Policy Engine) to {@code
5547      * AsyncRegistrationFallbackJobService}.
5548      */
5549     @FeatureFlag boolean DEFAULT_SPE_ON_ASYNC_REGISTRATION_FALLBACK_JOB_ENABLED = false;
5550 
5551     /**
5552      * Returns the default enablement of applying SPE (Scheduling Policy Engine) to {@code
5553      * AsyncRegistrationFallbackJobService}.
5554      */
getSpeOnAsyncRegistrationFallbackJobEnabled()5555     default boolean getSpeOnAsyncRegistrationFallbackJobEnabled() {
5556         return DEFAULT_SPE_ON_ASYNC_REGISTRATION_FALLBACK_JOB_ENABLED;
5557     }
5558 
5559     /** Default value for the enablement the new apis for business logic migration. */
5560     @FeatureFlag boolean DEFAULT_ADSERVICES_CONSENT_BUSINESS_LOGIC_MIGRATION_ENABLED = false;
5561 
5562     /** Returns the default value of the enablement of adservices business logic migration. */
getAdServicesConsentBusinessLogicMigrationEnabled()5563     default boolean getAdServicesConsentBusinessLogicMigrationEnabled() {
5564         return DEFAULT_ADSERVICES_CONSENT_BUSINESS_LOGIC_MIGRATION_ENABLED;
5565     }
5566 
5567     /** Enrollment Manifest File URL, used to provide proto file for MDD download. */
5568     String MDD_DEFAULT_ENROLLMENT_MANIFEST_FILE_URL = "";
5569 
5570     /**
5571      * @return default Enrollment Manifest File URL
5572      */
getMddEnrollmentManifestFileUrl()5573     default String getMddEnrollmentManifestFileUrl() {
5574         return MDD_DEFAULT_ENROLLMENT_MANIFEST_FILE_URL;
5575     }
5576 
5577     /** Feature flag to ramp up use of enrollment proto file. */
5578     @FeatureFlag boolean DEFAULT_ENROLLMENT_PROTO_FILE_ENABLED = false;
5579 
5580     /**
5581      * @return whether to enable use of enrollment proto file.
5582      */
getEnrollmentProtoFileEnabled()5583     default boolean getEnrollmentProtoFileEnabled() {
5584         return DEFAULT_ENROLLMENT_PROTO_FILE_ENABLED;
5585     }
5586 
5587     /** Dump some debug info for the flags */
dump(PrintWriter writer, @Nullable String[] args)5588     default void dump(PrintWriter writer, @Nullable String[] args) {}
5589 }
5590