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 21 import android.annotation.IntDef; 22 import android.annotation.NonNull; 23 24 import androidx.annotation.Nullable; 25 26 import com.android.adservices.data.adselection.DBRegisteredAdInteraction; 27 import com.android.adservices.service.adselection.AdOutcomeSelectorImpl; 28 import com.android.adservices.service.common.cache.FledgeHttpCache; 29 import com.android.adservices.service.measurement.PrivacyParams; 30 import com.android.modules.utils.build.SdkLevel; 31 32 import com.google.common.collect.ImmutableList; 33 34 import java.io.PrintWriter; 35 import java.lang.annotation.Retention; 36 import java.lang.annotation.RetentionPolicy; 37 import java.util.HashMap; 38 import java.util.Map; 39 import java.util.concurrent.TimeUnit; 40 41 /** 42 * AdServices Feature Flags interface. This Flags interface hold the default values of Ad Services 43 * Flags. The default values in this class must match with the default values in PH since we will 44 * migrate to Flag Codegen in the future. With that migration, the Flags.java file will be generated 45 * from the GCL. 46 */ 47 public interface Flags { 48 /** Topics Epoch Job Period. */ 49 long TOPICS_EPOCH_JOB_PERIOD_MS = 7 * 86_400_000; // 7 days. 50 51 /** Returns the max time period (in millis) between each epoch computation job run. */ getTopicsEpochJobPeriodMs()52 default long getTopicsEpochJobPeriodMs() { 53 return TOPICS_EPOCH_JOB_PERIOD_MS; 54 } 55 56 /** Topics Epoch Job Flex. Note the minimum value system allows is +8h24m0s0ms */ 57 long TOPICS_EPOCH_JOB_FLEX_MS = 9 * 60 * 60 * 1000; // 5 hours. 58 59 /** Returns flex for the Epoch computation job in Millisecond. */ getTopicsEpochJobFlexMs()60 default long getTopicsEpochJobFlexMs() { 61 return TOPICS_EPOCH_JOB_FLEX_MS; 62 } 63 64 /* The percentage that we will return a random topic from the Taxonomy. */ 65 int TOPICS_PERCENTAGE_FOR_RANDOM_TOPIC = 5; 66 67 /** Returns the percentage that we will return a random topic from the Taxonomy. */ getTopicsPercentageForRandomTopic()68 default int getTopicsPercentageForRandomTopic() { 69 return TOPICS_PERCENTAGE_FOR_RANDOM_TOPIC; 70 } 71 72 /** The number of top Topics for each epoch. */ 73 int TOPICS_NUMBER_OF_TOP_TOPICS = 5; 74 75 /** Returns the number of top topics. */ getTopicsNumberOfTopTopics()76 default int getTopicsNumberOfTopTopics() { 77 return TOPICS_NUMBER_OF_TOP_TOPICS; 78 } 79 80 /** The number of random Topics for each epoch. */ 81 int TOPICS_NUMBER_OF_RANDOM_TOPICS = 1; 82 83 /** Returns the number of top topics. */ getTopicsNumberOfRandomTopics()84 default int getTopicsNumberOfRandomTopics() { 85 return TOPICS_NUMBER_OF_RANDOM_TOPICS; 86 } 87 88 /** Global blocked Topics. Default value is empty list. */ 89 ImmutableList<Integer> TOPICS_GLOBAL_BLOCKED_TOPIC_IDS = ImmutableList.of(); 90 91 /** Returns a list of global blocked topics. */ getGlobalBlockedTopicIds()92 default ImmutableList<Integer> getGlobalBlockedTopicIds() { 93 return TOPICS_GLOBAL_BLOCKED_TOPIC_IDS; 94 } 95 96 /** How many epochs to look back when deciding if a caller has observed a topic before. */ 97 int TOPICS_NUMBER_OF_LOOK_BACK_EPOCHS = 3; 98 99 /** 100 * Returns the number of epochs to look back when deciding if a caller has observed a topic 101 * before. 102 */ getTopicsNumberOfLookBackEpochs()103 default int getTopicsNumberOfLookBackEpochs() { 104 return TOPICS_NUMBER_OF_LOOK_BACK_EPOCHS; 105 } 106 107 /** Available types of classifier behaviours for the Topics API. */ 108 @IntDef( 109 flag = true, 110 value = { 111 UNKNOWN_CLASSIFIER, 112 ON_DEVICE_CLASSIFIER, 113 PRECOMPUTED_CLASSIFIER, 114 PRECOMPUTED_THEN_ON_DEVICE_CLASSIFIER 115 }) 116 @Retention(RetentionPolicy.SOURCE) 117 @interface ClassifierType {} 118 119 /** Unknown classifier option. */ 120 int UNKNOWN_CLASSIFIER = 0; 121 /** Only on-device classification. */ 122 int ON_DEVICE_CLASSIFIER = 1; 123 /** Only Precomputed classification. */ 124 int PRECOMPUTED_CLASSIFIER = 2; 125 /** Precomputed classification values are preferred over on-device classification values. */ 126 int PRECOMPUTED_THEN_ON_DEVICE_CLASSIFIER = 3; 127 128 /* Type of classifier intended to be used by default. */ 129 @ClassifierType int DEFAULT_CLASSIFIER_TYPE = PRECOMPUTED_THEN_ON_DEVICE_CLASSIFIER; 130 131 /** Returns the type of classifier currently used by Topics. */ 132 @ClassifierType getClassifierType()133 default int getClassifierType() { 134 return DEFAULT_CLASSIFIER_TYPE; 135 } 136 137 /** Number of top labels allowed for every app. */ 138 int CLASSIFIER_NUMBER_OF_TOP_LABELS = 3; 139 140 /** Returns the number of top labels allowed for every app after the classification process. */ getClassifierNumberOfTopLabels()141 default int getClassifierNumberOfTopLabels() { 142 return CLASSIFIER_NUMBER_OF_TOP_LABELS; 143 } 144 145 /** Threshold value for classification values. */ 146 float CLASSIFIER_THRESHOLD = 0.2f; 147 148 /** Returns the threshold value for classification values. */ getClassifierThreshold()149 default float getClassifierThreshold() { 150 return CLASSIFIER_THRESHOLD; 151 } 152 153 /** Number of max words allowed in the description for topics classifier. */ 154 int CLASSIFIER_DESCRIPTION_MAX_WORDS = 500; 155 156 /** Returns the number of max words allowed in the description for topics classifier. */ getClassifierDescriptionMaxWords()157 default int getClassifierDescriptionMaxWords() { 158 return CLASSIFIER_DESCRIPTION_MAX_WORDS; 159 } 160 161 /** Number of max characters allowed in the description for topics classifier. */ 162 int CLASSIFIER_DESCRIPTION_MAX_LENGTH = 2500; 163 164 /** Returns the number of max characters allowed in the description for topics classifier. */ getClassifierDescriptionMaxLength()165 default int getClassifierDescriptionMaxLength() { 166 return CLASSIFIER_DESCRIPTION_MAX_LENGTH; 167 } 168 169 // TODO(b/243829477): Remove this flag when flow of pushing models is refined. 170 /** 171 * Whether classifier should force using bundled files. This flag is mainly used in CTS tests to 172 * force using precomputed_app_list to avoid model mismatch due to update. Default value is 173 * false which means to use downloaded files. 174 */ 175 boolean CLASSIFIER_FORCE_USE_BUNDLED_FILES = false; 176 177 /** Returns whether to force using bundled files */ getClassifierForceUseBundledFiles()178 default boolean getClassifierForceUseBundledFiles() { 179 return CLASSIFIER_FORCE_USE_BUNDLED_FILES; 180 } 181 182 /* The default period for the Maintenance job. */ 183 long MAINTENANCE_JOB_PERIOD_MS = 86_400_000; // 1 day. 184 185 /** Returns the max time period (in millis) between each idle maintenance job run. */ getMaintenanceJobPeriodMs()186 default long getMaintenanceJobPeriodMs() { 187 return MAINTENANCE_JOB_PERIOD_MS; 188 } 189 190 /* The default flex for Maintenance Job. */ 191 long MAINTENANCE_JOB_FLEX_MS = 3 * 60 * 60 * 1000; // 3 hours. 192 193 /** Returns flex for the Daily Maintenance job in Millisecond. */ getMaintenanceJobFlexMs()194 default long getMaintenanceJobFlexMs() { 195 return MAINTENANCE_JOB_FLEX_MS; 196 } 197 198 /* The default min time period (in millis) between each event main reporting job run. */ 199 long MEASUREMENT_EVENT_MAIN_REPORTING_JOB_PERIOD_MS = 4 * 60 * 60 * 1000; // 4 hours. 200 201 /** Returns min time period (in millis) between each event main reporting job run. */ getMeasurementEventMainReportingJobPeriodMs()202 default long getMeasurementEventMainReportingJobPeriodMs() { 203 return MEASUREMENT_EVENT_MAIN_REPORTING_JOB_PERIOD_MS; 204 } 205 206 /* The default min time period (in millis) between each event fallback reporting job run. */ 207 long MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_PERIOD_MS = 24 * 60 * 60 * 1000; // 24 hours. 208 209 /** Returns min time period (in millis) between each event fallback reporting job run. */ getMeasurementEventFallbackReportingJobPeriodMs()210 default long getMeasurementEventFallbackReportingJobPeriodMs() { 211 return MEASUREMENT_EVENT_FALLBACK_REPORTING_JOB_PERIOD_MS; 212 } 213 214 /* The default URL for fetching public encryption keys for aggregatable reports. */ 215 String MEASUREMENT_AGGREGATE_ENCRYPTION_KEY_COORDINATOR_URL = 216 "https://publickeyservice.aws.privacysandboxservices.com/v1alpha/publicKeys"; 217 218 /** Returns the URL for fetching public encryption keys for aggregatable reports. */ getMeasurementAggregateEncryptionKeyCoordinatorUrl()219 default String getMeasurementAggregateEncryptionKeyCoordinatorUrl() { 220 return MEASUREMENT_AGGREGATE_ENCRYPTION_KEY_COORDINATOR_URL; 221 } 222 223 /* The default min time period (in millis) between each aggregate main reporting job run. */ 224 long MEASUREMENT_AGGREGATE_MAIN_REPORTING_JOB_PERIOD_MS = 4 * 60 * 60 * 1000; // 4 hours. 225 226 /** Returns min time period (in millis) between each aggregate main reporting job run. */ getMeasurementAggregateMainReportingJobPeriodMs()227 default long getMeasurementAggregateMainReportingJobPeriodMs() { 228 return MEASUREMENT_AGGREGATE_MAIN_REPORTING_JOB_PERIOD_MS; 229 } 230 231 /* The default min time period (in millis) between each aggregate fallback reporting job run. */ 232 long MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_PERIOD_MS = 24 * 60 * 60 * 1000; // 24 hours. 233 234 /** Returns min time period (in millis) between each aggregate fallback job run. */ getMeasurementAggregateFallbackReportingJobPeriodMs()235 default long getMeasurementAggregateFallbackReportingJobPeriodMs() { 236 return MEASUREMENT_AGGREGATE_FALLBACK_REPORTING_JOB_PERIOD_MS; 237 } 238 239 /** 240 * Returns the maximum time in milliseconds allowed for a network call to open its initial 241 * connection during Measurement API calls. 242 */ getMeasurementNetworkConnectTimeoutMs()243 default int getMeasurementNetworkConnectTimeoutMs() { 244 return MEASUREMENT_NETWORK_CONNECT_TIMEOUT_MS; 245 } 246 247 /** 248 * Returns the maximum time in milliseconds allowed for a network call to read a response from a 249 * target server during Measurement API calls. 250 */ getMeasurementNetworkReadTimeoutMs()251 default int getMeasurementNetworkReadTimeoutMs() { 252 return MEASUREMENT_NETWORK_READ_TIMEOUT_MS; 253 } 254 255 long MEASUREMENT_DB_SIZE_LIMIT = (1024 * 1024) * 10; // 10 MBs 256 int MEASUREMENT_NETWORK_CONNECT_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(5); 257 int MEASUREMENT_NETWORK_READ_TIMEOUT_MS = (int) TimeUnit.SECONDS.toMillis(30); 258 259 /** 260 * Returns the window that an InputEvent has to be within for the system to register it as a 261 * click. 262 */ 263 long MEASUREMENT_REGISTRATION_INPUT_EVENT_VALID_WINDOW_MS = 60 * 1000; // 1 minute. 264 getMeasurementRegistrationInputEventValidWindowMs()265 default long getMeasurementRegistrationInputEventValidWindowMs() { 266 return MEASUREMENT_REGISTRATION_INPUT_EVENT_VALID_WINDOW_MS; 267 } 268 269 /** Returns whether a click event should be verified before a registration request. */ 270 boolean MEASUREMENT_IS_CLICK_VERIFICATION_ENABLED = true; 271 getMeasurementIsClickVerificationEnabled()272 default boolean getMeasurementIsClickVerificationEnabled() { 273 return MEASUREMENT_IS_CLICK_VERIFICATION_ENABLED; 274 } 275 276 /** Returns whether a click is verified by Input Event. */ 277 boolean MEASUREMENT_IS_CLICK_VERIFIED_BY_INPUT_EVENT = false; 278 getMeasurementIsClickVerifiedByInputEvent()279 default boolean getMeasurementIsClickVerifiedByInputEvent() { 280 return MEASUREMENT_IS_CLICK_VERIFIED_BY_INPUT_EVENT; 281 } 282 283 /** Returns the DB size limit for measurement. */ getMeasurementDbSizeLimit()284 default long getMeasurementDbSizeLimit() { 285 return MEASUREMENT_DB_SIZE_LIMIT; 286 } 287 288 /** Measurement manifest file url, used for MDD download. */ 289 String MEASUREMENT_MANIFEST_FILE_URL = 290 "https://dl.google.com/mdi-serving/adservices/adtech_enrollment/manifest_configs/1" 291 + "/manifest_config_1658790241927.binaryproto"; 292 293 /** Measurement manifest file url. */ getMeasurementManifestFileUrl()294 default String getMeasurementManifestFileUrl() { 295 return MEASUREMENT_MANIFEST_FILE_URL; 296 } 297 298 boolean MEASUREMENT_ENABLE_XNA = false; 299 300 /** Returns whether XNA should be used for eligible sources. */ getMeasurementEnableXNA()301 default boolean getMeasurementEnableXNA() { 302 return MEASUREMENT_ENABLE_XNA; 303 } 304 305 boolean MEASUREMENT_ENABLE_DEBUG_REPORT = true; 306 307 /** Returns whether verbose debug report generation is enabled. */ getMeasurementEnableDebugReport()308 default boolean getMeasurementEnableDebugReport() { 309 return MEASUREMENT_ENABLE_DEBUG_REPORT; 310 } 311 312 boolean MEASUREMENT_ENABLE_SOURCE_DEBUG_REPORT = true; 313 314 /** Returns whether source debug report generation is enabled. */ getMeasurementEnableSourceDebugReport()315 default boolean getMeasurementEnableSourceDebugReport() { 316 return MEASUREMENT_ENABLE_SOURCE_DEBUG_REPORT; 317 } 318 319 boolean MEASUREMENT_ENABLE_TRIGGER_DEBUG_REPORT = true; 320 321 /** Returns whether trigger debug report generation is enabled. */ getMeasurementEnableTriggerDebugReport()322 default boolean getMeasurementEnableTriggerDebugReport() { 323 return MEASUREMENT_ENABLE_TRIGGER_DEBUG_REPORT; 324 } 325 326 long MEASUREMENT_DATA_EXPIRY_WINDOW_MS = TimeUnit.DAYS.toMillis(37); 327 328 /** Returns the data expiry window in milliseconds. */ getMeasurementDataExpiryWindowMs()329 default long getMeasurementDataExpiryWindowMs() { 330 return MEASUREMENT_DATA_EXPIRY_WINDOW_MS; 331 } 332 333 int MEASUREMENT_MAX_REGISTRATION_REDIRECTS = 20; 334 335 /** Returns the number of maximum registration redirects allowed. */ getMeasurementMaxRegistrationRedirects()336 default int getMeasurementMaxRegistrationRedirects() { 337 return MEASUREMENT_MAX_REGISTRATION_REDIRECTS; 338 } 339 340 int MEASUREMENT_MAX_REGISTRATIONS_PER_JOB_INVOCATION = 100; 341 342 /** Returns the number of maximum registration per job invocation. */ getMeasurementMaxRegistrationsPerJobInvocation()343 default int getMeasurementMaxRegistrationsPerJobInvocation() { 344 return MEASUREMENT_MAX_REGISTRATIONS_PER_JOB_INVOCATION; 345 } 346 347 int MEASUREMENT_MAX_RETRIES_PER_REGISTRATION_REQUEST = 5; 348 349 /** Returns the number of maximum retires per registration request. */ getMeasurementMaxRetriesPerRegistrationRequest()350 default int getMeasurementMaxRetriesPerRegistrationRequest() { 351 return MEASUREMENT_MAX_RETRIES_PER_REGISTRATION_REQUEST; 352 } 353 354 long MEASUREMENT_REGISTRATION_JOB_TRIGGER_DELAY_MS = TimeUnit.MINUTES.toMillis(2); 355 356 /** 357 * Returns the delay (in milliseconds) in job triggering after a registration request is 358 * received. 359 */ getMeasurementRegistrationJobTriggerDelayMs()360 default long getMeasurementRegistrationJobTriggerDelayMs() { 361 return MEASUREMENT_REGISTRATION_JOB_TRIGGER_DELAY_MS; 362 } 363 364 long MEASUREMENT_REGISTRATION_JOB_TRIGGER_MAX_DELAY_MS = TimeUnit.MINUTES.toMillis(5); 365 366 /** 367 * Returns the maximum delay (in milliseconds) in job triggering after a registration request is 368 * received. 369 */ getMeasurementRegistrationJobTriggerMaxDelayMs()370 default long getMeasurementRegistrationJobTriggerMaxDelayMs() { 371 return MEASUREMENT_REGISTRATION_JOB_TRIGGER_MAX_DELAY_MS; 372 } 373 374 boolean MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_KILL_SWITCH = false; 375 376 /** Returns the kill switch for Attribution Fallback Job . */ getMeasurementAttributionFallbackJobKillSwitch()377 default boolean getMeasurementAttributionFallbackJobKillSwitch() { 378 return getGlobalKillSwitch() 379 || getMeasurementKillSwitch() 380 || MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_KILL_SWITCH; 381 } 382 383 long MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_PERIOD_MS = TimeUnit.HOURS.toMillis(1); 384 385 /** Returns the job period in millis for Attribution Fallback Job . */ getMeasurementAttributionFallbackJobPeriodMs()386 default long getMeasurementAttributionFallbackJobPeriodMs() { 387 return MEASUREMENT_ATTRIBUTION_FALLBACK_JOB_PERIOD_MS; 388 } 389 390 int MEASUREMENT_MAX_ATTRIBUTION_PER_RATE_LIMIT_WINDOW = 100; 391 392 /** 393 * Returns maximum attributions per rate limit window. Rate limit unit: (Source Site, 394 * Destination Site, Reporting Site, Window). 395 */ getMeasurementMaxAttributionPerRateLimitWindow()396 default int getMeasurementMaxAttributionPerRateLimitWindow() { 397 return MEASUREMENT_MAX_ATTRIBUTION_PER_RATE_LIMIT_WINDOW; 398 } 399 400 int MEASUREMENT_MAX_DISTINCT_ENROLLMENTS_IN_ATTRIBUTION = 10; 401 402 /** 403 * Returns max distinct enrollments for attribution per { Advertiser X Publisher X TimePeriod }. 404 */ getMeasurementMaxDistinctEnrollmentsInAttribution()405 default int getMeasurementMaxDistinctEnrollmentsInAttribution() { 406 return MEASUREMENT_MAX_DISTINCT_ENROLLMENTS_IN_ATTRIBUTION; 407 } 408 409 int MEASUREMENT_MAX_DISTINCT_DESTINATIONS_IN_ACTIVE_SOURCE = 100; 410 411 /** 412 * Returns max distinct advertisers with pending impressions per { Publisher X Enrollment X 413 * TimePeriod }. 414 */ getMeasurementMaxDistinctDestinationsInActiveSource()415 default int getMeasurementMaxDistinctDestinationsInActiveSource() { 416 return MEASUREMENT_MAX_DISTINCT_DESTINATIONS_IN_ACTIVE_SOURCE; 417 } 418 419 long FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT = 4000L; 420 long FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT = 1000L; 421 long FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT = 1000L; 422 long FLEDGE_CUSTOM_AUDIENCE_DEFAULT_EXPIRE_IN_MS = 60L * 24L * 60L * 60L * 1000L; // 60 days 423 long FLEDGE_CUSTOM_AUDIENCE_MAX_ACTIVATION_DELAY_IN_MS = 424 60L * 24L * 60L * 60L * 1000L; // 60 days 425 long FLEDGE_CUSTOM_AUDIENCE_MAX_EXPIRE_IN_MS = 60L * 24L * 60L * 60L * 1000L; // 60 days 426 int FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B = 200; 427 int FLEDGE_CUSTOM_AUDIENCE_MAX_DAILY_UPDATE_URI_SIZE_B = 400; 428 int FLEDGE_CUSTOM_AUDIENCE_MAX_BIDDING_LOGIC_URI_SIZE_B = 400; 429 int FLEDGE_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B = 10 * 1024; // 10 KiB 430 int FLEDGE_CUSTOM_AUDIENCE_MAX_TRUSTED_BIDDING_DATA_SIZE_B = 10 * 1024; // 10 KiB 431 int FLEDGE_CUSTOM_AUDIENCE_MAX_ADS_SIZE_B = 10 * 1024; // 10 KiB 432 int FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS = 100; 433 // Keeping TTL as long as expiry, could be reduced later as we get more fresh CAs with adoption 434 long FLEDGE_CUSTOM_AUDIENCE_ACTIVE_TIME_WINDOW_MS = 60 * 24 * 60L * 60L * 1000; // 60 days 435 436 /** Returns the maximum number of custom audience can stay in the storage. */ getFledgeCustomAudienceMaxCount()437 default long getFledgeCustomAudienceMaxCount() { 438 return FLEDGE_CUSTOM_AUDIENCE_MAX_COUNT; 439 } 440 441 /** Returns the maximum number of custom audience an app can create. */ getFledgeCustomAudiencePerAppMaxCount()442 default long getFledgeCustomAudiencePerAppMaxCount() { 443 return FLEDGE_CUSTOM_AUDIENCE_PER_APP_MAX_COUNT; 444 } 445 446 /** Returns the maximum number of apps can have access to custom audience. */ getFledgeCustomAudienceMaxOwnerCount()447 default long getFledgeCustomAudienceMaxOwnerCount() { 448 return FLEDGE_CUSTOM_AUDIENCE_MAX_OWNER_COUNT; 449 } 450 451 /** 452 * Returns the default amount of time in milliseconds a custom audience object will live before 453 * being expiring and being removed 454 */ getFledgeCustomAudienceDefaultExpireInMs()455 default long getFledgeCustomAudienceDefaultExpireInMs() { 456 return FLEDGE_CUSTOM_AUDIENCE_DEFAULT_EXPIRE_IN_MS; 457 } 458 459 /** 460 * Returns the maximum permitted difference in milliseconds between the custom audience object's 461 * creation time and its activation time 462 */ getFledgeCustomAudienceMaxActivationDelayInMs()463 default long getFledgeCustomAudienceMaxActivationDelayInMs() { 464 return FLEDGE_CUSTOM_AUDIENCE_MAX_ACTIVATION_DELAY_IN_MS; 465 } 466 467 /** 468 * Returns the maximum permitted difference in milliseconds between the custom audience object's 469 * activation time and its expiration time 470 */ getFledgeCustomAudienceMaxExpireInMs()471 default long getFledgeCustomAudienceMaxExpireInMs() { 472 return FLEDGE_CUSTOM_AUDIENCE_MAX_EXPIRE_IN_MS; 473 } 474 475 /** Returns the maximum size in bytes allowed for name in each FLEDGE custom audience. */ getFledgeCustomAudienceMaxNameSizeB()476 default int getFledgeCustomAudienceMaxNameSizeB() { 477 return FLEDGE_CUSTOM_AUDIENCE_MAX_NAME_SIZE_B; 478 } 479 480 /** 481 * Returns the maximum size in bytes allowed for daily update uri in each FLEDGE custom 482 * audience. 483 */ getFledgeCustomAudienceMaxDailyUpdateUriSizeB()484 default int getFledgeCustomAudienceMaxDailyUpdateUriSizeB() { 485 return FLEDGE_CUSTOM_AUDIENCE_MAX_DAILY_UPDATE_URI_SIZE_B; 486 } 487 488 /** 489 * Returns the maximum size in bytes allowed for bidding logic uri in each FLEDGE custom 490 * audience. 491 */ getFledgeCustomAudienceMaxBiddingLogicUriSizeB()492 default int getFledgeCustomAudienceMaxBiddingLogicUriSizeB() { 493 return FLEDGE_CUSTOM_AUDIENCE_MAX_BIDDING_LOGIC_URI_SIZE_B; 494 } 495 496 /** 497 * Returns the maximum size in bytes allowed for user bidding signals in each FLEDGE custom 498 * audience. 499 */ getFledgeCustomAudienceMaxUserBiddingSignalsSizeB()500 default int getFledgeCustomAudienceMaxUserBiddingSignalsSizeB() { 501 return FLEDGE_CUSTOM_AUDIENCE_MAX_USER_BIDDING_SIGNALS_SIZE_B; 502 } 503 504 /** 505 * Returns the maximum size in bytes allowed for trusted bidding data in each FLEDGE custom 506 * audience. 507 */ getFledgeCustomAudienceMaxTrustedBiddingDataSizeB()508 default int getFledgeCustomAudienceMaxTrustedBiddingDataSizeB() { 509 return FLEDGE_CUSTOM_AUDIENCE_MAX_TRUSTED_BIDDING_DATA_SIZE_B; 510 } 511 512 /** Returns the maximum size in bytes allowed for ads in each FLEDGE custom audience. */ getFledgeCustomAudienceMaxAdsSizeB()513 default int getFledgeCustomAudienceMaxAdsSizeB() { 514 return FLEDGE_CUSTOM_AUDIENCE_MAX_ADS_SIZE_B; 515 } 516 517 /** Returns the maximum allowed number of ads per FLEDGE custom audience. */ getFledgeCustomAudienceMaxNumAds()518 default int getFledgeCustomAudienceMaxNumAds() { 519 return FLEDGE_CUSTOM_AUDIENCE_MAX_NUM_ADS; 520 } 521 522 /** 523 * Returns the time window that defines how long after a successful update a custom audience can 524 * participate in ad selection. 525 */ getFledgeCustomAudienceActiveTimeWindowInMs()526 default long getFledgeCustomAudienceActiveTimeWindowInMs() { 527 return FLEDGE_CUSTOM_AUDIENCE_ACTIVE_TIME_WINDOW_MS; 528 } 529 530 boolean FLEDGE_BACKGROUND_FETCH_ENABLED = true; 531 long FLEDGE_BACKGROUND_FETCH_JOB_PERIOD_MS = 4L * 60L * 60L * 1000L; // 4 hours 532 long FLEDGE_BACKGROUND_FETCH_JOB_FLEX_MS = 30L * 60L * 1000L; // 30 minutes 533 long FLEDGE_BACKGROUND_FETCH_JOB_MAX_RUNTIME_MS = 10L * 60L * 1000L; // 5 minutes 534 long FLEDGE_BACKGROUND_FETCH_MAX_NUM_UPDATED = 1000; 535 int FLEDGE_BACKGROUND_FETCH_THREAD_POOL_SIZE = 8; 536 long FLEDGE_BACKGROUND_FETCH_ELIGIBLE_UPDATE_BASE_INTERVAL_S = 24L * 60L * 60L; // 24 hours 537 int FLEDGE_BACKGROUND_FETCH_NETWORK_CONNECT_TIMEOUT_MS = 5 * 1000; // 5 seconds 538 int FLEDGE_BACKGROUND_FETCH_NETWORK_READ_TIMEOUT_MS = 30 * 1000; // 30 seconds 539 int FLEDGE_BACKGROUND_FETCH_MAX_RESPONSE_SIZE_B = 10 * 1024; // 10 KiB 540 boolean FLEDGE_HTTP_CACHE_ENABLE = true; 541 boolean FLEDGE_HTTP_CACHE_ENABLE_JS_CACHING = true; 542 long FLEDGE_HTTP_CACHE_DEFAULT_MAX_AGE_SECONDS = 2 * 24 * 60 * 60; // 2 days 543 long FLEDGE_HTTP_CACHE_MAX_ENTRIES = 100; 544 545 /** Returns {@code true} if the FLEDGE Background Fetch is enabled. */ getFledgeBackgroundFetchEnabled()546 default boolean getFledgeBackgroundFetchEnabled() { 547 return FLEDGE_BACKGROUND_FETCH_ENABLED; 548 } 549 550 /** 551 * Returns the best effort max time (in milliseconds) between each FLEDGE Background Fetch job 552 * run. 553 */ getFledgeBackgroundFetchJobPeriodMs()554 default long getFledgeBackgroundFetchJobPeriodMs() { 555 return FLEDGE_BACKGROUND_FETCH_JOB_PERIOD_MS; 556 } 557 558 /** 559 * Returns the amount of flex (in milliseconds) around the end of each period to run each FLEDGE 560 * Background Fetch job. 561 */ getFledgeBackgroundFetchJobFlexMs()562 default long getFledgeBackgroundFetchJobFlexMs() { 563 return FLEDGE_BACKGROUND_FETCH_JOB_FLEX_MS; 564 } 565 566 /** 567 * Returns the maximum amount of time (in milliseconds) each FLEDGE Background Fetch job is 568 * allowed to run. 569 */ getFledgeBackgroundFetchJobMaxRuntimeMs()570 default long getFledgeBackgroundFetchJobMaxRuntimeMs() { 571 return FLEDGE_BACKGROUND_FETCH_JOB_MAX_RUNTIME_MS; 572 } 573 574 /** 575 * Returns the maximum number of custom audiences updated in a single FLEDGE background fetch 576 * job. 577 */ getFledgeBackgroundFetchMaxNumUpdated()578 default long getFledgeBackgroundFetchMaxNumUpdated() { 579 return FLEDGE_BACKGROUND_FETCH_MAX_NUM_UPDATED; 580 } 581 582 /** 583 * Returns the maximum thread pool size to draw workers from in a single FLEDGE background fetch 584 * job. 585 */ getFledgeBackgroundFetchThreadPoolSize()586 default int getFledgeBackgroundFetchThreadPoolSize() { 587 return FLEDGE_BACKGROUND_FETCH_THREAD_POOL_SIZE; 588 } 589 590 /** 591 * Returns the base interval in seconds after a successful FLEDGE background fetch job after 592 * which a custom audience is next eligible to be updated. 593 */ getFledgeBackgroundFetchEligibleUpdateBaseIntervalS()594 default long getFledgeBackgroundFetchEligibleUpdateBaseIntervalS() { 595 return FLEDGE_BACKGROUND_FETCH_ELIGIBLE_UPDATE_BASE_INTERVAL_S; 596 } 597 598 /** 599 * Returns the maximum time in milliseconds allowed for a network call to open its initial 600 * connection during the FLEDGE background fetch. 601 */ getFledgeBackgroundFetchNetworkConnectTimeoutMs()602 default int getFledgeBackgroundFetchNetworkConnectTimeoutMs() { 603 return FLEDGE_BACKGROUND_FETCH_NETWORK_CONNECT_TIMEOUT_MS; 604 } 605 606 /** 607 * Returns the maximum time in milliseconds allowed for a network call to read a response from a 608 * target server during the FLEDGE background fetch. 609 */ getFledgeBackgroundFetchNetworkReadTimeoutMs()610 default int getFledgeBackgroundFetchNetworkReadTimeoutMs() { 611 return FLEDGE_BACKGROUND_FETCH_NETWORK_READ_TIMEOUT_MS; 612 } 613 614 /** 615 * Returns the maximum size in bytes of a single custom audience update response during the 616 * FLEDGE background fetch. 617 */ getFledgeBackgroundFetchMaxResponseSizeB()618 default int getFledgeBackgroundFetchMaxResponseSizeB() { 619 return FLEDGE_BACKGROUND_FETCH_MAX_RESPONSE_SIZE_B; 620 } 621 622 /** Returns boolean, if the caching is enabled for {@link FledgeHttpCache} */ getFledgeHttpCachingEnabled()623 default boolean getFledgeHttpCachingEnabled() { 624 return FLEDGE_HTTP_CACHE_ENABLE; 625 } 626 627 /** Returns boolean, if the caching is enabled for JS for bidding and scoring */ getFledgeHttpJsCachingEnabled()628 default boolean getFledgeHttpJsCachingEnabled() { 629 return FLEDGE_HTTP_CACHE_ENABLE_JS_CACHING; 630 } 631 632 /** Returns max number of entries that should be persisted in cache */ getFledgeHttpCacheMaxEntries()633 default long getFledgeHttpCacheMaxEntries() { 634 return FLEDGE_HTTP_CACHE_MAX_ENTRIES; 635 } 636 637 /** Returns the default max age of entries in cache */ getFledgeHttpCacheMaxAgeSeconds()638 default long getFledgeHttpCacheMaxAgeSeconds() { 639 return FLEDGE_HTTP_CACHE_DEFAULT_MAX_AGE_SECONDS; 640 } 641 642 int FLEDGE_AD_COUNTER_HISTOGRAM_ABSOLUTE_MAX_EVENT_COUNT = 1000; 643 int FLEDGE_AD_COUNTER_HISTOGRAM_LOWER_MAX_EVENT_COUNT = 950; 644 645 /** Returns the maximum allowed number of events in the frequency cap histogram table. */ getFledgeAdCounterHistogramAbsoluteMaxEventCount()646 default int getFledgeAdCounterHistogramAbsoluteMaxEventCount() { 647 return FLEDGE_AD_COUNTER_HISTOGRAM_ABSOLUTE_MAX_EVENT_COUNT; 648 } 649 650 /** 651 * Returns the number of events that the frequency cap histogram table should be trimmed to, if 652 * there are too many entries. 653 */ getFledgeAdCounterHistogramLowerMaxEventCount()654 default int getFledgeAdCounterHistogramLowerMaxEventCount() { 655 return FLEDGE_AD_COUNTER_HISTOGRAM_LOWER_MAX_EVENT_COUNT; 656 } 657 658 int FLEDGE_AD_SELECTION_MAX_CONCURRENT_BIDDING_COUNT = 6; 659 660 /** Returns the number of CA that can be bid in parallel for one Ad Selection */ getAdSelectionMaxConcurrentBiddingCount()661 default int getAdSelectionMaxConcurrentBiddingCount() { 662 return FLEDGE_AD_SELECTION_MAX_CONCURRENT_BIDDING_COUNT; 663 } 664 665 // TODO(b/240647148): Limits are increased temporarily, re-evaluate these numbers after 666 // getting real world data from telemetry & set accurately scoped timeout 667 long FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_CA_MS = 5000; 668 long FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_BUYER_MS = 10000; 669 long FLEDGE_AD_SELECTION_SCORING_TIMEOUT_MS = 5000; 670 long FLEDGE_AD_SELECTION_SELECTING_OUTCOME_TIMEOUT_MS = 5000; 671 // For *on device* ad selection. 672 long FLEDGE_AD_SELECTION_OVERALL_TIMEOUT_MS = 10000; 673 long FLEDGE_AD_SELECTION_FROM_OUTCOMES_OVERALL_TIMEOUT_MS = 20_000; 674 long FLEDGE_AD_SELECTION_OFF_DEVICE_OVERALL_TIMEOUT_MS = 10_000; 675 long FLEDGE_AD_SELECTION_BIDDING_LOGIC_JS_VERSION = 2L; 676 677 long FLEDGE_REPORT_IMPRESSION_OVERALL_TIMEOUT_MS = 2000; 678 679 // RegisterAdBeacon Constants 680 long FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_TOTAL_COUNT = 1000; // Num entries 681 long FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_PER_AD_TECH_COUNT = 10; // Num entries 682 long FLEDGE_REPORT_IMPRESSION_REGISTERED_AD_BEACONS_MAX_INTERACTION_KEY_SIZE_B = 683 20 * 2; // Num characters * 2 bytes per char in UTF-8 684 685 /** Returns the timeout constant in milliseconds that limits the bidding per CA */ getAdSelectionBiddingTimeoutPerCaMs()686 default long getAdSelectionBiddingTimeoutPerCaMs() { 687 return FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_CA_MS; 688 } 689 690 /** Returns the timeout constant in milliseconds that limits the bidding per Buyer */ getAdSelectionBiddingTimeoutPerBuyerMs()691 default long getAdSelectionBiddingTimeoutPerBuyerMs() { 692 return FLEDGE_AD_SELECTION_BIDDING_TIMEOUT_PER_BUYER_MS; 693 } 694 695 /** Returns the timeout constant in milliseconds that limits the scoring */ getAdSelectionScoringTimeoutMs()696 default long getAdSelectionScoringTimeoutMs() { 697 return FLEDGE_AD_SELECTION_SCORING_TIMEOUT_MS; 698 } 699 700 /** 701 * Returns the timeout constant in milliseconds that limits the {@link 702 * AdOutcomeSelectorImpl#runAdOutcomeSelector} 703 */ getAdSelectionSelectingOutcomeTimeoutMs()704 default long getAdSelectionSelectingOutcomeTimeoutMs() { 705 return FLEDGE_AD_SELECTION_SELECTING_OUTCOME_TIMEOUT_MS; 706 } 707 708 /** 709 * Returns the timeout constant in milliseconds that limits the overall *on device* ad selection 710 * orchestration. 711 */ getAdSelectionOverallTimeoutMs()712 default long getAdSelectionOverallTimeoutMs() { 713 return FLEDGE_AD_SELECTION_OVERALL_TIMEOUT_MS; 714 } 715 716 /** 717 * Returns the timeout constant in milliseconds that limits the overall *on device* ad selection 718 * from outcomes orchestration. 719 */ getAdSelectionFromOutcomesOverallTimeoutMs()720 default long getAdSelectionFromOutcomesOverallTimeoutMs() { 721 return FLEDGE_AD_SELECTION_FROM_OUTCOMES_OVERALL_TIMEOUT_MS; 722 } 723 724 /** 725 * Returns the timeout constant in milliseconds that limits the overall off device ad selection 726 * orchestration. 727 */ getAdSelectionOffDeviceOverallTimeoutMs()728 default long getAdSelectionOffDeviceOverallTimeoutMs() { 729 return FLEDGE_AD_SELECTION_OFF_DEVICE_OVERALL_TIMEOUT_MS; 730 } 731 732 /** Returns the default JS version for running bidding. */ getFledgeAdSelectionBiddingLogicJsVersion()733 default long getFledgeAdSelectionBiddingLogicJsVersion() { 734 return FLEDGE_AD_SELECTION_BIDDING_LOGIC_JS_VERSION; 735 } 736 737 /** 738 * Returns the time out constant in milliseconds that limits the overall impression reporting 739 * execution 740 */ getReportImpressionOverallTimeoutMs()741 default long getReportImpressionOverallTimeoutMs() { 742 return FLEDGE_REPORT_IMPRESSION_OVERALL_TIMEOUT_MS; 743 } 744 745 /** 746 * Returns the maximum number of {@link DBRegisteredAdInteraction} that can be in the {@code 747 * registered_ad_interactions} database at any one time. 748 */ getFledgeReportImpressionMaxRegisteredAdBeaconsTotalCount()749 default long getFledgeReportImpressionMaxRegisteredAdBeaconsTotalCount() { 750 return FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_TOTAL_COUNT; 751 } 752 753 /** 754 * Returns the maximum number of {@link DBRegisteredAdInteraction} that an ad-tech can register 755 * in one call to {@code reportImpression}. 756 */ getFledgeReportImpressionMaxRegisteredAdBeaconsPerAdTechCount()757 default long getFledgeReportImpressionMaxRegisteredAdBeaconsPerAdTechCount() { 758 return FLEDGE_REPORT_IMPRESSION_MAX_REGISTERED_AD_BEACONS_PER_AD_TECH_COUNT; 759 } 760 761 /** 762 * Returns the maximum size in bytes of {@link DBRegisteredAdInteraction#getInteractionKey()} 763 */ getFledgeReportImpressionRegisteredAdBeaconsMaxInteractionKeySizeB()764 default long getFledgeReportImpressionRegisteredAdBeaconsMaxInteractionKeySizeB() { 765 return FLEDGE_REPORT_IMPRESSION_REGISTERED_AD_BEACONS_MAX_INTERACTION_KEY_SIZE_B; 766 } 767 768 // 24 hours in seconds 769 long FLEDGE_AD_SELECTION_EXPIRATION_WINDOW_S = 60 * 60 * 24; 770 771 /** 772 * Returns the amount of time in seconds after which ad selection data is considered expired. 773 */ getAdSelectionExpirationWindowS()774 default long getAdSelectionExpirationWindowS() { 775 return FLEDGE_AD_SELECTION_EXPIRATION_WINDOW_S; 776 } 777 778 // Filtering feature flag disabled by default 779 boolean FLEDGE_AD_SELECTION_FILTERING_ENABLED = false; 780 781 /** Returns {@code true} if negative filtering of ads during ad selection is enabled. */ getFledgeAdSelectionFilteringEnabled()782 default boolean getFledgeAdSelectionFilteringEnabled() { 783 return FLEDGE_AD_SELECTION_FILTERING_ENABLED; 784 } 785 786 // Enable contextual Ads feature, based on Filtering feature enabled or not 787 boolean FLEDGE_AD_SELECTION_CONTEXTUAL_ADS_ENABLED = FLEDGE_AD_SELECTION_FILTERING_ENABLED; 788 789 /** Returns {@code true} if negative filtering of ads during ad selection is enabled. */ getFledgeAdSelectionContextualAdsEnabled()790 default boolean getFledgeAdSelectionContextualAdsEnabled() { 791 return FLEDGE_AD_SELECTION_CONTEXTUAL_ADS_ENABLED; 792 } 793 794 boolean FLEDGE_AD_SELECTION_OFF_DEVICE_ENABLED = false; 795 796 /** @return whether to call trusted servers for off device ad selection. */ getAdSelectionOffDeviceEnabled()797 default boolean getAdSelectionOffDeviceEnabled() { 798 return FLEDGE_AD_SELECTION_OFF_DEVICE_ENABLED; 799 } 800 801 boolean FLEDGE_AD_SELECTION_PREBUILT_URI_ENABLED = false; 802 803 /** @return whether to call trusted servers for off device ad selection. */ getFledgeAdSelectionPrebuiltUriEnabled()804 default boolean getFledgeAdSelectionPrebuiltUriEnabled() { 805 return FLEDGE_AD_SELECTION_PREBUILT_URI_ENABLED; 806 } 807 808 boolean FLEDGE_AD_SELECTION_OFF_DEVICE_REQUEST_COMPRESSION_ENABLED = true; 809 810 /** Returns whether to compress requests sent off device for ad selection. */ getAdSelectionOffDeviceRequestCompressionEnabled()811 default boolean getAdSelectionOffDeviceRequestCompressionEnabled() { 812 return FLEDGE_AD_SELECTION_OFF_DEVICE_REQUEST_COMPRESSION_ENABLED; 813 } 814 815 boolean ADSERVICES_ENABLED = false; 816 getAdServicesEnabled()817 default boolean getAdServicesEnabled() { 818 return ADSERVICES_ENABLED; 819 } 820 821 boolean ADSERVICES_ERROR_LOGGING_ENABLED = false; 822 823 /** Return {@code true} if error logging is enabled */ getAdServicesErrorLoggingEnabled()824 default boolean getAdServicesErrorLoggingEnabled() { 825 return ADSERVICES_ERROR_LOGGING_ENABLED; 826 } 827 828 /** Dump some debug info for the flags */ dump(@onNull PrintWriter writer, @Nullable String[] args)829 default void dump(@NonNull PrintWriter writer, @Nullable String[] args) {} 830 831 /** 832 * The number of epoch to look back to do garbage collection for old epoch data. Assume current 833 * Epoch is T, then any epoch data of (T-NUMBER_OF_EPOCHS_TO_KEEP_IN_HISTORY-1) (inclusive) 834 * should be erased 835 */ 836 int NUMBER_OF_EPOCHS_TO_KEEP_IN_HISTORY = TOPICS_NUMBER_OF_LOOK_BACK_EPOCHS; 837 838 /* 839 * Return the number of epochs to keep in the history 840 */ getNumberOfEpochsToKeepInHistory()841 default int getNumberOfEpochsToKeepInHistory() { 842 return NUMBER_OF_EPOCHS_TO_KEEP_IN_HISTORY; 843 } 844 845 /** Downloader Connection Timeout in Milliseconds. */ 846 int DOWNLOADER_CONNECTION_TIMEOUT_MS = 10 * 1000; // 10 seconds. 847 848 /* 849 * Return the Downloader Connection Timeout in Milliseconds. 850 */ getDownloaderConnectionTimeoutMs()851 default int getDownloaderConnectionTimeoutMs() { 852 return DOWNLOADER_CONNECTION_TIMEOUT_MS; 853 } 854 855 /** Downloader Read Timeout in Milliseconds. */ 856 int DOWNLOADER_READ_TIMEOUT_MS = 10 * 1000; // 10 seconds. 857 858 /** Returns the Downloader Read Timeout in Milliseconds. */ getDownloaderReadTimeoutMs()859 default int getDownloaderReadTimeoutMs() { 860 return DOWNLOADER_READ_TIMEOUT_MS; 861 } 862 863 /** Downloader max download threads. */ 864 int DOWNLOADER_MAX_DOWNLOAD_THREADS = 2; 865 866 /** Returns the Downloader Read Timeout in Milliseconds. */ getDownloaderMaxDownloadThreads()867 default int getDownloaderMaxDownloadThreads() { 868 return DOWNLOADER_MAX_DOWNLOAD_THREADS; 869 } 870 871 /** MDD Topics API Classifier Manifest Url */ 872 // TODO(b/236761740): We use this for now for testing. We need to update to the correct one 873 // when we actually upload the models. 874 String MDD_TOPICS_CLASSIFIER_MANIFEST_FILE_URL = 875 "https://dl.google.com/mdi-serving/adservices/topics_classifier/manifest_configs/2" 876 + "/manifest_config_1661376643699.binaryproto"; 877 getMddTopicsClassifierManifestFileUrl()878 default String getMddTopicsClassifierManifestFileUrl() { 879 return MDD_TOPICS_CLASSIFIER_MANIFEST_FILE_URL; 880 } 881 882 long CONSENT_NOTIFICATION_INTERVAL_BEGIN_MS = 883 /* hours */ 9 * /* minutes */ 60 * /* seconds */ 60 * /* milliseconds */ 1000; // 9 AM 884 getConsentNotificationIntervalBeginMs()885 default long getConsentNotificationIntervalBeginMs() { 886 return CONSENT_NOTIFICATION_INTERVAL_BEGIN_MS; 887 } 888 889 long CONSENT_NOTIFICATION_INTERVAL_END_MS = 890 /* hours */ 17 * /* minutes */ 60 * /* seconds */ 60 * /* milliseconds */ 1000; // 5 PM 891 getConsentNotificationIntervalEndMs()892 default long getConsentNotificationIntervalEndMs() { 893 return CONSENT_NOTIFICATION_INTERVAL_END_MS; 894 } 895 896 long CONSENT_NOTIFICATION_MINIMAL_DELAY_BEFORE_INTERVAL_ENDS = 897 /* minutes */ 60 * /* seconds */ 60 * /* milliseconds */ 1000; // 1 hour 898 getConsentNotificationMinimalDelayBeforeIntervalEnds()899 default long getConsentNotificationMinimalDelayBeforeIntervalEnds() { 900 return CONSENT_NOTIFICATION_MINIMAL_DELAY_BEFORE_INTERVAL_ENDS; 901 } 902 903 boolean CONSENT_NOTIFICATION_DEBUG_MODE = false; 904 getConsentNotificationDebugMode()905 default boolean getConsentNotificationDebugMode() { 906 return CONSENT_NOTIFICATION_DEBUG_MODE; 907 } 908 909 boolean CONSENT_MANAGER_DEBUG_MODE = false; 910 getConsentManagerDebugMode()911 default boolean getConsentManagerDebugMode() { 912 return CONSENT_MANAGER_DEBUG_MODE; 913 } 914 915 /** Available sources of truth to get consent for PPAPI. */ 916 @IntDef( 917 flag = true, 918 value = { 919 SYSTEM_SERVER_ONLY, 920 PPAPI_ONLY, 921 PPAPI_AND_SYSTEM_SERVER, 922 APPSEARCH_ONLY, 923 }) 924 @Retention(RetentionPolicy.SOURCE) 925 @interface ConsentSourceOfTruth {} 926 927 /** Write and read consent from system server only. */ 928 int SYSTEM_SERVER_ONLY = 0; 929 /** Write and read consent from PPAPI only */ 930 int PPAPI_ONLY = 1; 931 /** Write consent to both PPAPI and system server. Read consent from system server only. */ 932 int PPAPI_AND_SYSTEM_SERVER = 2; 933 /** 934 * Write consent data to AppSearch only. To store consent data in AppSearch the flag 935 * enable_appsearch_consent_data must also be true. This ensures that both writes and reads can 936 * happen to/from AppSearch. The writes are done by code on S-, while reads are done from code 937 * running on S- for all consent requests and on T+ once after OTA. 938 */ 939 int APPSEARCH_ONLY = 3; 940 941 /** 942 * Consent source of truth intended to be used by default. On S- devices, there is no AdServices 943 * code running in the system server, so the default for those is PPAPI_ONLY. 944 */ 945 @ConsentSourceOfTruth 946 int DEFAULT_CONSENT_SOURCE_OF_TRUTH = 947 SdkLevel.isAtLeastT() ? PPAPI_AND_SYSTEM_SERVER : APPSEARCH_ONLY; 948 949 /** Returns the consent source of truth currently used for PPAPI. */ 950 @ConsentSourceOfTruth getConsentSourceOfTruth()951 default int getConsentSourceOfTruth() { 952 return DEFAULT_CONSENT_SOURCE_OF_TRUTH; 953 } 954 955 /** 956 * Blocked topics source of truth intended to be used by default. On S- devices, there is no 957 * AdServices code running in the system server, so the default for those is PPAPI_ONLY. 958 */ 959 @ConsentSourceOfTruth 960 int DEFAULT_BLOCKED_TOPICS_SOURCE_OF_TRUTH = 961 SdkLevel.isAtLeastT() ? PPAPI_AND_SYSTEM_SERVER : APPSEARCH_ONLY; 962 963 /** Returns the blocked topics source of truth currently used for PPAPI */ 964 @ConsentSourceOfTruth getBlockedTopicsSourceOfTruth()965 default int getBlockedTopicsSourceOfTruth() { 966 return DEFAULT_BLOCKED_TOPICS_SOURCE_OF_TRUTH; 967 } 968 969 /** 970 * The SHA certificates of the AdServices and the AdExtServices APKs. This is required when 971 * writing consent data to AppSearch in order to allow reads from T+ APK. This is a comma 972 * searpated list. 973 */ 974 // TODO: Add the release key signed cert. 975 String ADSERVICES_APK_SHA_CERTIFICATE = 976 "686d5c450e00ebe600f979300a29234644eade42f24ede07a073f2bc6b94a3a2"; 977 978 /** Only App signatures belonging to this Allow List can use PP APIs. */ getAdservicesApkShaCertificate()979 default String getAdservicesApkShaCertificate() { 980 return ADSERVICES_APK_SHA_CERTIFICATE; 981 } 982 983 // Group of All Killswitches 984 985 /** 986 * Global PP API Kill Switch. This overrides all other killswitches. The default value is false 987 * which means the PP API is enabled. This flag is used for emergency turning off the whole PP 988 * API. 989 */ 990 // Starting M-2023-05, global kill switch is enabled in the binary. Prior to this (namely in 991 // M-2022-11), the value of this flag in the binary was false. 992 boolean GLOBAL_KILL_SWITCH = true; 993 getGlobalKillSwitch()994 default boolean getGlobalKillSwitch() { 995 return GLOBAL_KILL_SWITCH; 996 } 997 998 // MEASUREMENT Killswitches 999 1000 /** 1001 * Measurement Kill Switch. This overrides all specific measurement kill switch. The default 1002 * value is false which means that Measurement is enabled. This flag is used for emergency 1003 * turning off the whole Measurement API. 1004 */ 1005 boolean MEASUREMENT_KILL_SWITCH = false; 1006 1007 /** 1008 * Returns the kill switch value for Global Measurement. Measurement will be disabled if either 1009 * the Global Kill Switch or the Measurement Kill Switch value is true. 1010 */ getMeasurementKillSwitch()1011 default boolean getMeasurementKillSwitch() { 1012 return MEASUREMENT_KILL_SWITCH; 1013 } 1014 1015 /** 1016 * Measurement API Delete Registrations Kill Switch. The default value is false which means 1017 * Delete Registrations API is enabled. This flag is used for emergency turning off the Delete 1018 * Registrations API. 1019 */ 1020 boolean MEASUREMENT_API_DELETE_REGISTRATIONS_KILL_SWITCH = false; 1021 1022 /** 1023 * Returns the kill switch value for Measurement API Delete Registrations. The API will be 1024 * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API 1025 * Delete Registration Kill Switch value is true. 1026 */ getMeasurementApiDeleteRegistrationsKillSwitch()1027 default boolean getMeasurementApiDeleteRegistrationsKillSwitch() { 1028 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1029 return getGlobalKillSwitch() 1030 || getMeasurementKillSwitch() 1031 || MEASUREMENT_API_DELETE_REGISTRATIONS_KILL_SWITCH; 1032 } 1033 1034 /** 1035 * Measurement API Status Kill Switch. The default value is false which means Status API is 1036 * enabled. This flag is used for emergency turning off the Status API. 1037 */ 1038 boolean MEASUREMENT_API_STATUS_KILL_SWITCH = false; 1039 1040 /** 1041 * Returns the kill switch value for Measurement API Status. The API will be disabled if either 1042 * the Global Kill Switch, Measurement Kill Switch, or the Measurement API Status Kill Switch 1043 * value is true. 1044 */ getMeasurementApiStatusKillSwitch()1045 default boolean getMeasurementApiStatusKillSwitch() { 1046 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1047 return getGlobalKillSwitch() 1048 || getMeasurementKillSwitch() 1049 || MEASUREMENT_API_STATUS_KILL_SWITCH; 1050 } 1051 1052 /** 1053 * Measurement API Register Source Kill Switch. The default value is false which means Register 1054 * Source API is enabled. This flag is used for emergency turning off the Register Source API. 1055 */ 1056 boolean MEASUREMENT_API_REGISTER_SOURCE_KILL_SWITCH = false; 1057 1058 /** 1059 * Returns the kill switch value for Measurement API Register Source. The API will be disabled 1060 * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API Register 1061 * Source Kill Switch value is true. 1062 */ getMeasurementApiRegisterSourceKillSwitch()1063 default boolean getMeasurementApiRegisterSourceKillSwitch() { 1064 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1065 return getGlobalKillSwitch() 1066 || getMeasurementKillSwitch() 1067 || MEASUREMENT_API_REGISTER_SOURCE_KILL_SWITCH; 1068 } 1069 1070 /** 1071 * Measurement API Register Trigger Kill Switch. The default value is false which means Register 1072 * Trigger API is enabled. This flag is used for emergency turning off the Register Trigger API. 1073 */ 1074 boolean MEASUREMENT_API_REGISTER_TRIGGER_KILL_SWITCH = false; 1075 1076 /** 1077 * Returns the kill switch value for Measurement API Register Trigger. The API will be disabled 1078 * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API Register 1079 * Trigger Kill Switch value is true. 1080 */ getMeasurementApiRegisterTriggerKillSwitch()1081 default boolean getMeasurementApiRegisterTriggerKillSwitch() { 1082 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1083 return getGlobalKillSwitch() 1084 || getMeasurementKillSwitch() 1085 || MEASUREMENT_API_REGISTER_TRIGGER_KILL_SWITCH; 1086 } 1087 1088 /** 1089 * Measurement API Register Web Source Kill Switch. The default value is false which means 1090 * Register Web Source API is enabled. This flag is used for emergency turning off the Register 1091 * Web Source API. 1092 */ 1093 boolean MEASUREMENT_API_REGISTER_WEB_SOURCE_KILL_SWITCH = false; 1094 1095 /** 1096 * Returns the kill switch value for Measurement API Register Web Source. The API will be 1097 * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API 1098 * Register Web Source Kill Switch value is true. 1099 */ getMeasurementApiRegisterWebSourceKillSwitch()1100 default boolean getMeasurementApiRegisterWebSourceKillSwitch() { 1101 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1102 return getGlobalKillSwitch() 1103 || getMeasurementKillSwitch() 1104 || MEASUREMENT_API_REGISTER_WEB_SOURCE_KILL_SWITCH; 1105 } 1106 1107 /** 1108 * Measurement API Register Web Trigger Kill Switch. The default value is false which means 1109 * Register Web Trigger API is enabled. This flag is used for emergency turning off the Register 1110 * Web Trigger API. 1111 */ 1112 boolean MEASUREMENT_API_REGISTER_WEB_TRIGGER_KILL_SWITCH = false; 1113 1114 /** 1115 * Returns the kill switch value for Measurement API Register Web Trigger. The API will be 1116 * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement API 1117 * Register Web Trigger Kill Switch value is true. 1118 */ getMeasurementApiRegisterWebTriggerKillSwitch()1119 default boolean getMeasurementApiRegisterWebTriggerKillSwitch() { 1120 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1121 return getGlobalKillSwitch() 1122 || getMeasurementKillSwitch() 1123 || MEASUREMENT_API_REGISTER_WEB_TRIGGER_KILL_SWITCH; 1124 } 1125 1126 /** 1127 * Measurement Job Aggregate Fallback Reporting Kill Switch. The default value is false which 1128 * means Aggregate Fallback Reporting Job is enabled. This flag is used for emergency turning 1129 * off the Aggregate Fallback Reporting Job. 1130 */ 1131 boolean MEASUREMENT_JOB_AGGREGATE_FALLBACK_REPORTING_KILL_SWITCH = false; 1132 1133 /** 1134 * Returns the kill switch value for Measurement Job Aggregate Fallback Reporting. The API will 1135 * be disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job 1136 * Aggregate Fallback Reporting Kill Switch value is true. 1137 */ getMeasurementJobAggregateFallbackReportingKillSwitch()1138 default boolean getMeasurementJobAggregateFallbackReportingKillSwitch() { 1139 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1140 return getGlobalKillSwitch() 1141 || getMeasurementKillSwitch() 1142 || MEASUREMENT_JOB_AGGREGATE_FALLBACK_REPORTING_KILL_SWITCH; 1143 } 1144 1145 /** 1146 * Measurement Job Aggregate Reporting Kill Switch. The default value is false which means 1147 * Aggregate Reporting Job is enabled. This flag is used for emergency turning off the Aggregate 1148 * Reporting Job. 1149 */ 1150 boolean MEASUREMENT_JOB_AGGREGATE_REPORTING_KILL_SWITCH = false; 1151 1152 /** 1153 * Returns the kill switch value for Measurement Job Aggregate Reporting. The API will be 1154 * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job 1155 * Aggregate Reporting Kill Switch value is true. 1156 */ getMeasurementJobAggregateReportingKillSwitch()1157 default boolean getMeasurementJobAggregateReportingKillSwitch() { 1158 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1159 return getGlobalKillSwitch() 1160 || getMeasurementKillSwitch() 1161 || MEASUREMENT_JOB_AGGREGATE_REPORTING_KILL_SWITCH; 1162 } 1163 1164 /** 1165 * Measurement Job Attribution Kill Switch. The default value is false which means Attribution 1166 * Job is enabled. This flag is used for emergency turning off the Attribution Job. 1167 */ 1168 boolean MEASUREMENT_JOB_ATTRIBUTION_KILL_SWITCH = false; 1169 1170 /** 1171 * Returns the kill switch value for Measurement Job Attribution. The API will be disabled if 1172 * either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Attribution 1173 * Kill Switch value is true. 1174 */ getMeasurementJobAttributionKillSwitch()1175 default boolean getMeasurementJobAttributionKillSwitch() { 1176 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1177 return getGlobalKillSwitch() 1178 || getMeasurementKillSwitch() 1179 || MEASUREMENT_JOB_ATTRIBUTION_KILL_SWITCH; 1180 } 1181 1182 /** 1183 * Measurement Job Delete Expired Kill Switch. The default value is false which means Delete 1184 * Expired Job is enabled. This flag is used for emergency turning off the Delete Expired Job. 1185 */ 1186 boolean MEASUREMENT_JOB_DELETE_EXPIRED_KILL_SWITCH = false; 1187 1188 /** 1189 * Returns the kill switch value for Measurement Job Delete Expired. The API will be disabled if 1190 * either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Delete Expired 1191 * Kill Switch value is true. 1192 */ getMeasurementJobDeleteExpiredKillSwitch()1193 default boolean getMeasurementJobDeleteExpiredKillSwitch() { 1194 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1195 return getGlobalKillSwitch() 1196 || getMeasurementKillSwitch() 1197 || MEASUREMENT_JOB_DELETE_EXPIRED_KILL_SWITCH; 1198 } 1199 1200 /** 1201 * Measurement Job Delete Uninstalled Kill Switch. The default value is false which means Delete 1202 * Uninstalled Job is enabled. This flag is used for emergency turning off the Delete 1203 * Uninstalled Job. 1204 */ 1205 boolean MEASUREMENT_JOB_DELETE_UNINSTALLED_KILL_SWITCH = false; 1206 1207 /** 1208 * Returns the kill switch value for Measurement Job Delete Uninstalled. The API will be 1209 * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job 1210 * Delete Uninstalled Kill Switch value is true. 1211 */ getMeasurementJobDeleteUninstalledKillSwitch()1212 default boolean getMeasurementJobDeleteUninstalledKillSwitch() { 1213 return getGlobalKillSwitch() 1214 || getMeasurementKillSwitch() 1215 || MEASUREMENT_JOB_DELETE_UNINSTALLED_KILL_SWITCH; 1216 } 1217 1218 /** 1219 * Measurement Job Event Fallback Reporting Kill Switch. The default value is false which means 1220 * Event Fallback Reporting Job is enabled. This flag is used for emergency turning off the 1221 * Event Fallback Reporting Job. 1222 */ 1223 boolean MEASUREMENT_JOB_EVENT_FALLBACK_REPORTING_KILL_SWITCH = false; 1224 1225 /** 1226 * Returns the kill switch value for Measurement Job Event Fallback Reporting. The API will be 1227 * disabled if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job 1228 * Event Fallback Reporting Kill Switch value is true. 1229 */ getMeasurementJobEventFallbackReportingKillSwitch()1230 default boolean getMeasurementJobEventFallbackReportingKillSwitch() { 1231 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1232 return getGlobalKillSwitch() 1233 || getMeasurementKillSwitch() 1234 || MEASUREMENT_JOB_EVENT_FALLBACK_REPORTING_KILL_SWITCH; 1235 } 1236 1237 /** 1238 * Measurement Job Event Reporting Kill Switch. The default value is false which means Event 1239 * Reporting Job is enabled. This flag is used for emergency turning off the Event Reporting 1240 * Job. 1241 */ 1242 boolean MEASUREMENT_JOB_EVENT_REPORTING_KILL_SWITCH = false; 1243 1244 /** 1245 * Returns the kill switch value for Measurement Job Event Reporting. The API will be disabled 1246 * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Event 1247 * Reporting Kill Switch value is true. 1248 */ getMeasurementJobEventReportingKillSwitch()1249 default boolean getMeasurementJobEventReportingKillSwitch() { 1250 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1251 return getGlobalKillSwitch() 1252 || getMeasurementKillSwitch() 1253 || MEASUREMENT_JOB_EVENT_REPORTING_KILL_SWITCH; 1254 } 1255 1256 /** 1257 * Measurement Job Debug Reporting Kill Switch. The default value is false which means Debug 1258 * Reporting Job is enabled. This flag is used for emergency turning off the Debug Reporting 1259 * Job. 1260 */ 1261 boolean MEASUREMENT_JOB_DEBUG_REPORTING_KILL_SWITCH = false; 1262 1263 /** 1264 * Returns the kill switch value for Measurement Job Debug Reporting. The API will be disabled 1265 * if either the Global Kill Switch, Measurement Kill Switch, or the Measurement Job Debug 1266 * Reporting Kill Switch value is true. 1267 */ getMeasurementJobDebugReportingKillSwitch()1268 default boolean getMeasurementJobDebugReportingKillSwitch() { 1269 // We check the Global Kill Switch first. As a result, it overrides all other kill Switches. 1270 return getGlobalKillSwitch() 1271 || getMeasurementKillSwitch() 1272 || MEASUREMENT_JOB_DEBUG_REPORTING_KILL_SWITCH; 1273 } 1274 1275 /** 1276 * Measurement Broadcast Receiver Install Attribution Kill Switch. The default value is false 1277 * which means Install Attribution is enabled. This flag is used for emergency turning off 1278 * Install Attribution Broadcast Receiver. 1279 */ 1280 boolean MEASUREMENT_RECEIVER_INSTALL_ATTRIBUTION_KILL_SWITCH = false; 1281 1282 /** 1283 * Returns the kill switch value for Measurement Broadcast Receiver Install Attribution. The 1284 * Broadcast Receiver will be disabled if either the Global Kill Switch, Measurement Kill Switch 1285 * or the Measurement Kill Switch value is true. 1286 */ getMeasurementReceiverInstallAttributionKillSwitch()1287 default boolean getMeasurementReceiverInstallAttributionKillSwitch() { 1288 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1289 return getGlobalKillSwitch() 1290 || getMeasurementKillSwitch() 1291 || MEASUREMENT_RECEIVER_INSTALL_ATTRIBUTION_KILL_SWITCH; 1292 } 1293 1294 /** 1295 * Measurement Broadcast Receiver Delete Packages Kill Switch. The default value is false which 1296 * means Delete Packages is enabled. This flag is used for emergency turning off Delete Packages 1297 * Broadcast Receiver. 1298 */ 1299 boolean MEASUREMENT_RECEIVER_DELETE_PACKAGES_KILL_SWITCH = false; 1300 1301 /** 1302 * Returns the kill switch value for Measurement Broadcast Receiver Delete Packages. The 1303 * Broadcast Receiver will be disabled if either the Global Kill Switch, Measurement Kill Switch 1304 * or the Measurement Kill Switch value is true. 1305 */ getMeasurementReceiverDeletePackagesKillSwitch()1306 default boolean getMeasurementReceiverDeletePackagesKillSwitch() { 1307 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1308 return getGlobalKillSwitch() 1309 || getMeasurementKillSwitch() 1310 || MEASUREMENT_RECEIVER_DELETE_PACKAGES_KILL_SWITCH; 1311 } 1312 1313 /** 1314 * Measurement Rollback Kill Switch. The default value is false which means the rollback 1315 * handling on measurement service start is enabled. This flag is used for emergency turning off 1316 * measurement rollback data deletion handling. 1317 */ 1318 boolean MEASUREMENT_ROLLBACK_DELETION_KILL_SWITCH = false; 1319 1320 /** 1321 * Returns the kill switch value for Measurement rollback deletion handling. The rollback 1322 * deletion handling will be disabled if the Global Kill Switch, Measurement Kill Switch or the 1323 * Measurement rollback deletion Kill Switch value is true. 1324 */ getMeasurementRollbackDeletionKillSwitch()1325 default boolean getMeasurementRollbackDeletionKillSwitch() { 1326 return getGlobalKillSwitch() 1327 || getMeasurementKillSwitch() 1328 || MEASUREMENT_ROLLBACK_DELETION_KILL_SWITCH; 1329 } 1330 1331 /** 1332 * Kill Switch for storing Measurement Rollback data in App Search for Android S. The default 1333 * value is false which means storing the rollback handling data in App Search is enabled. This 1334 * flag is used for emergency turning off measurement rollback data deletion handling on Android 1335 * S. 1336 */ 1337 boolean MEASUREMENT_ROLLBACK_DELETION_APP_SEARCH_KILL_SWITCH = false; 1338 1339 /** 1340 * Returns the kill switch value for storing Measurement rollback deletion handling data in App 1341 * Search. The rollback deletion handling on Android S will be disabled if this kill switch 1342 * value is true. 1343 */ getMeasurementRollbackDeletionAppSearchKillSwitch()1344 default boolean getMeasurementRollbackDeletionAppSearchKillSwitch() { 1345 return MEASUREMENT_ROLLBACK_DELETION_APP_SEARCH_KILL_SWITCH; 1346 } 1347 1348 // ADID Killswitch. 1349 /** 1350 * AdId API Kill Switch. The default value is false which means the AdId API is enabled. This 1351 * flag is used for emergency turning off the AdId API. 1352 */ 1353 boolean ADID_KILL_SWITCH = false; // By default, the AdId API is enabled. 1354 1355 /** Gets the state of adId kill switch. */ getAdIdKillSwitch()1356 default boolean getAdIdKillSwitch() { 1357 return ADID_KILL_SWITCH; 1358 } 1359 1360 // APPSETID Killswitch. 1361 /** 1362 * AppSetId API Kill Switch. The default value is false which means the AppSetId API is enabled. 1363 * This flag is used for emergency turning off the AppSetId API. 1364 */ 1365 boolean APPSETID_KILL_SWITCH = false; // By default, the AppSetId API is enabled. 1366 1367 /** Gets the state of the global and appSetId kill switch. */ getAppSetIdKillSwitch()1368 default boolean getAppSetIdKillSwitch() { 1369 return APPSETID_KILL_SWITCH; 1370 } 1371 1372 // TOPICS Killswitches 1373 1374 /** 1375 * Topics API Kill Switch. The default value is false which means the Topics API is enabled. 1376 * This flag is used for emergency turning off the Topics API. 1377 */ 1378 boolean TOPICS_KILL_SWITCH = false; // By default, the Topics API is enabled. 1379 1380 /** @return value of Topics API kill switch */ getTopicsKillSwitch()1381 default boolean getTopicsKillSwitch() { 1382 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1383 return getGlobalKillSwitch() || TOPICS_KILL_SWITCH; 1384 } 1385 1386 /** 1387 * Topics on-device classifier Kill Switch. The default value is false which means the on-device 1388 * classifier in enabled. This flag is used for emergency turning off the on-device classifier. 1389 */ 1390 boolean TOPICS_ON_DEVICE_CLASSIFIER_KILL_SWITCH = false; 1391 1392 /** @return value of Topics on-device classifier kill switch. */ getTopicsOnDeviceClassifierKillSwitch()1393 default boolean getTopicsOnDeviceClassifierKillSwitch() { 1394 return TOPICS_ON_DEVICE_CLASSIFIER_KILL_SWITCH; 1395 } 1396 1397 // MDD Killswitches 1398 1399 /** 1400 * MDD Background Task Kill Switch. The default value is false which means the MDD background 1401 * task is enabled. This flag is used for emergency turning off the MDD background tasks. 1402 */ 1403 boolean MDD_BACKGROUND_TASK_KILL_SWITCH = false; 1404 1405 /** @return value of Mdd Background Task kill switch */ getMddBackgroundTaskKillSwitch()1406 default boolean getMddBackgroundTaskKillSwitch() { 1407 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 1408 return getGlobalKillSwitch() || MDD_BACKGROUND_TASK_KILL_SWITCH; 1409 } 1410 1411 /** 1412 * MDD Logger Kill Switch. The default value is false which means the MDD Logger is enabled. 1413 * This flag is used for emergency turning off the MDD Logger. 1414 */ 1415 boolean MDD_LOGGER_KILL_SWITCH = false; 1416 1417 /** @return value of MDD Logger Kill Switch */ getMddLoggerKillSwitch()1418 default boolean getMddLoggerKillSwitch() { 1419 return getGlobalKillSwitch() || MDD_LOGGER_KILL_SWITCH; 1420 } 1421 1422 // FLEDGE Kill switches 1423 1424 /** 1425 * Fledge Ad Selection API kill switch. The default value is false which means that Select Ads 1426 * API is enabled by default. This flag should be should as emergency andon cord. 1427 */ 1428 boolean FLEDGE_SELECT_ADS_KILL_SWITCH = false; 1429 1430 /** @return value of Fledge Ad Selection API kill switch */ getFledgeSelectAdsKillSwitch()1431 default boolean getFledgeSelectAdsKillSwitch() { 1432 // Check for global kill switch first, as it should override all other kill switches 1433 return getGlobalKillSwitch() || FLEDGE_SELECT_ADS_KILL_SWITCH; 1434 } 1435 1436 /** 1437 * Fledge Join Custom Audience API kill switch. The default value is false which means that Join 1438 * Custom Audience API is enabled by default. This flag should be should as emergency andon 1439 * cord. 1440 */ 1441 boolean FLEDGE_CUSTOM_AUDIENCE_SERVICE_KILL_SWITCH = false; 1442 1443 /** @return value of Fledge Join Custom Audience API kill switch */ getFledgeCustomAudienceServiceKillSwitch()1444 default boolean getFledgeCustomAudienceServiceKillSwitch() { 1445 // Check for global kill switch first, as it should override all other kill switches 1446 return getGlobalKillSwitch() || FLEDGE_CUSTOM_AUDIENCE_SERVICE_KILL_SWITCH; 1447 } 1448 1449 /** 1450 * Enable Back Compat feature flag. The default value is false which means that all back compat 1451 * related features are disabled by default. This flag would be enabled for R/S during rollout. 1452 */ 1453 boolean ENABLE_BACK_COMPAT = false; 1454 1455 /** @return value of enable Back Compat */ getEnableBackCompat()1456 default boolean getEnableBackCompat() { 1457 return ENABLE_BACK_COMPAT; 1458 } 1459 1460 /** 1461 * Enable AppSearch read for consent data feature flag. The default value is false which means 1462 * AppSearch is not considered as source of truth after OTA. This flag should be enabled for OTA 1463 * support of consent data on T+ devices. 1464 */ 1465 boolean ENABLE_APPSEARCH_CONSENT_DATA = !SdkLevel.isAtLeastT(); 1466 1467 /** @return value of enable appsearch consent data flag */ getEnableAppsearchConsentData()1468 default boolean getEnableAppsearchConsentData() { 1469 return ENABLE_APPSEARCH_CONSENT_DATA; 1470 } 1471 1472 /* 1473 * The allow-list for PP APIs. This list has the list of app package names that we allow 1474 * using PP APIs. 1475 * App Package Name that does not belong to this allow-list will not be able to use PP APIs. 1476 * If this list has special value "*", then all package names are allowed. 1477 * There must be not any empty space between comma. 1478 */ 1479 String PPAPI_APP_ALLOW_LIST = 1480 "android.platform.test.scenario," 1481 + "android.adservices.crystalball," 1482 + "android.adservices.cts," 1483 + "android.adservices.debuggablects," 1484 + "com.android.adservices.endtoendtest," 1485 + "com.android.adservices.servicecoretest," 1486 + "com.android.adservices.tests.permissions.appoptout," 1487 + "com.android.adservices.tests.permissions.valid," 1488 + "com.android.adservices.tests.adid," 1489 + "com.android.adservices.tests.appsetid," 1490 + "com.android.sdksandboxclient," 1491 + "com.android.tests.sandbox.adid," 1492 + "com.android.tests.sandbox.appsetid," 1493 + "com.android.tests.sandbox.fledge," 1494 + "com.android.tests.sandbox.measurement," 1495 + "com.example.adservices.samples.adid.app," 1496 + "com.example.adservices.samples.appsetid.app," 1497 + "com.example.adservices.samples.fledge.sampleapp," 1498 + "com.example.adservices.samples.fledge.sampleapp1," 1499 + "com.example.adservices.samples.fledge.sampleapp2," 1500 + "com.example.adservices.samples.fledge.sampleapp3," 1501 + "com.example.adservices.samples.fledge.sampleapp4," 1502 + "com.example.measurement.sampleapp," 1503 + "com.example.measurement.sampleapp2," 1504 + "com.android.adservices.tests.cts.endtoendtest.measurement"; 1505 1506 /** 1507 * Returns bypass List for PPAPI app signature check. Apps with package name on this list will 1508 * bypass the signature check 1509 */ getPpapiAppAllowList()1510 default String getPpapiAppAllowList() { 1511 return PPAPI_APP_ALLOW_LIST; 1512 } 1513 1514 /* 1515 * The allow-list for PP APIs. This list has the list of app signatures that we allow 1516 * using PP APIs. App Package signatures that do not belong to this allow-list will not be 1517 * able to use PP APIs, unless the package name of this app is in the bypass list. 1518 * 1519 * If this list has special value "*", then all package signatures are allowed. 1520 * 1521 * There must be not any empty space between comma. 1522 */ 1523 String PPAPI_APP_SIGNATURE_ALLOW_LIST = 1524 // com.android.adservices.tests.cts.endtoendtest 1525 "6cecc50e34ae31bfb5678986d6d6d3736c571ded2f2459527793e1f054eb0c9b," 1526 // com.android.tests.sandbox.topics 1527 + "a40da80a59d170caa950cf15c18c454d47a39b26989d8b640ecd745ba71bf5dc," 1528 // Topics Sample Apps 1529 // For example, com.example.adservices.samples.topics.sampleapp1 1530 + "301aa3cb081134501c45f1422abc66c24224fd5ded5fdc8f17e697176fd866aa," 1531 // com.android.adservices.tests.cts.topics.testapp1 1532 // android.platform.test.scenario.adservices.GetTopicsApiCall 1533 // Both have [certificate: "platform"] in .bp file 1534 + "c8a2e9bccf597c2fb6dc66bee293fc13f2fc47ec77bc6b2b0d52c11f51192ab8"; 1535 1536 /** Only App signatures belonging to this Allow List can use PP APIs. */ getPpapiAppSignatureAllowList()1537 default String getPpapiAppSignatureAllowList() { 1538 return PPAPI_APP_SIGNATURE_ALLOW_LIST; 1539 } 1540 1541 /** 1542 * The client app packages that are allowed to invoke web context APIs, i.e. {@link 1543 * android.adservices.measurement.MeasurementManager#registerWebSource} and {@link 1544 * android.adservices.measurement.MeasurementManager#deleteRegistrations}. App packages that do 1545 * not belong to the list will be responded back with an error response. 1546 */ 1547 String WEB_CONTEXT_CLIENT_ALLOW_LIST = ""; 1548 1549 // Rate Limit Flags. 1550 1551 /** 1552 * PP API Rate Limit for each SDK. This is the max allowed QPS for one SDK to one PP API. 1553 * Negative Value means skipping the rate limiting checking. 1554 */ 1555 float SDK_REQUEST_PERMITS_PER_SECOND = 1; // allow max 1 request to any PP API per second. 1556 1557 /** 1558 * PP API Rate Limit for ad id. This is the max allowed QPS for one API client to one PP API. 1559 * Negative Value means skipping the rate limiting checking. 1560 */ 1561 float ADID_REQUEST_PERMITS_PER_SECOND = 5; 1562 1563 /** 1564 * PP API Rate Limit for app set id. This is the max allowed QPS for one API client to one PP 1565 * API. Negative Value means skipping the rate limiting checking. 1566 */ 1567 float APPSETID_REQUEST_PERMITS_PER_SECOND = 5; 1568 1569 /** 1570 * PP API Rate Limit for measurement register source. This is the max allowed QPS for one API 1571 * client to one PP API. Negative Value means skipping the rate limiting checking. 1572 */ 1573 float MEASUREMENT_REGISTER_SOURCE_REQUEST_PERMITS_PER_SECOND = 5; 1574 1575 /** 1576 * PP API Rate Limit for measurement register web source. This is the max allowed QPS for one 1577 * API client to one PP API. Negative Value means skipping the rate limiting checking. 1578 */ 1579 float MEASUREMENT_REGISTER_WEB_SOURCE_REQUEST_PERMITS_PER_SECOND = 5; 1580 1581 /** 1582 * PP API Rate Limit for Topics API based on App Package name. This is the max allowed QPS for 1583 * one API client to one PP API. Negative Value means skipping the rate limiting checking. 1584 */ 1585 float TOPICS_API_APP_REQUEST_PERMITS_PER_SECOND = 1; 1586 1587 /** 1588 * PP API Rate Limit for Topics API based on Sdk Name. This is the max allowed QPS for one API 1589 * client to one PP API. Negative Value means skipping the rate limiting checking. 1590 */ 1591 float TOPICS_API_SDK_REQUEST_PERMITS_PER_SECOND = 1; 1592 1593 /** 1594 * PP API Rate Limit for Fledge Report Interaction API. This is the max allowed QPS for one SDK 1595 * to one the Report Interaction API. Negative Value means skipping the rate limiting checking. 1596 */ 1597 float FLEDGE_REPORT_INTERACTION_REQUEST_PERMITS_PER_SECOND = 1; 1598 1599 /** Returns the Sdk Request Permits Per Second. */ getSdkRequestPermitsPerSecond()1600 default float getSdkRequestPermitsPerSecond() { 1601 return SDK_REQUEST_PERMITS_PER_SECOND; 1602 } 1603 1604 /** Returns the Ad id Request Permits Per Second. */ getAdIdRequestPermitsPerSecond()1605 default float getAdIdRequestPermitsPerSecond() { 1606 return ADID_REQUEST_PERMITS_PER_SECOND; 1607 } 1608 1609 /** Returns the App Set Ad Request Permits Per Second. */ getAppSetIdRequestPermitsPerSecond()1610 default float getAppSetIdRequestPermitsPerSecond() { 1611 return APPSETID_REQUEST_PERMITS_PER_SECOND; 1612 } 1613 1614 /** Returns the Topics API Based On App Package Name Request Permits Per Second. */ getTopicsApiAppRequestPermitsPerSecond()1615 default float getTopicsApiAppRequestPermitsPerSecond() { 1616 return TOPICS_API_APP_REQUEST_PERMITS_PER_SECOND; 1617 } 1618 1619 /** Returns the Topics API Based On Sdk Name Request Permits Per Second. */ getTopicsApiSdkRequestPermitsPerSecond()1620 default float getTopicsApiSdkRequestPermitsPerSecond() { 1621 return TOPICS_API_SDK_REQUEST_PERMITS_PER_SECOND; 1622 } 1623 1624 /** Returns the Measurement Register Source Request Permits Per Second. */ getMeasurementRegisterSourceRequestPermitsPerSecond()1625 default float getMeasurementRegisterSourceRequestPermitsPerSecond() { 1626 return MEASUREMENT_REGISTER_SOURCE_REQUEST_PERMITS_PER_SECOND; 1627 } 1628 1629 /** Returns the Measurement Register Web Source Request Permits Per Second. */ getMeasurementRegisterWebSourceRequestPermitsPerSecond()1630 default float getMeasurementRegisterWebSourceRequestPermitsPerSecond() { 1631 return MEASUREMENT_REGISTER_WEB_SOURCE_REQUEST_PERMITS_PER_SECOND; 1632 } 1633 1634 /** Returns the Fledge Report Interaction API Request Permits Per Second. */ getFledgeReportInteractionRequestPermitsPerSecond()1635 default float getFledgeReportInteractionRequestPermitsPerSecond() { 1636 return FLEDGE_REPORT_INTERACTION_REQUEST_PERMITS_PER_SECOND; 1637 } 1638 1639 // Flags for ad tech enrollment enforcement 1640 1641 boolean DISABLE_TOPICS_ENROLLMENT_CHECK = false; 1642 boolean DISABLE_FLEDGE_ENROLLMENT_CHECK = false; 1643 boolean DISABLE_MEASUREMENT_ENROLLMENT_CHECK = false; 1644 boolean ENABLE_ENROLLMENT_TEST_SEED = false; 1645 1646 /** @return {@code true} if the Topics API should disable the ad tech enrollment check */ isDisableTopicsEnrollmentCheck()1647 default boolean isDisableTopicsEnrollmentCheck() { 1648 return DISABLE_TOPICS_ENROLLMENT_CHECK; 1649 } 1650 1651 /** @return {@code true} if the FLEDGE APIs should disable the ad tech enrollment check */ getDisableFledgeEnrollmentCheck()1652 default boolean getDisableFledgeEnrollmentCheck() { 1653 return DISABLE_FLEDGE_ENROLLMENT_CHECK; 1654 } 1655 1656 /** @return {@code true} if the Measurement APIs should disable the ad tech enrollment check */ isDisableMeasurementEnrollmentCheck()1657 default boolean isDisableMeasurementEnrollmentCheck() { 1658 return DISABLE_MEASUREMENT_ENROLLMENT_CHECK; 1659 } 1660 1661 /** 1662 * @return {@code true} if the Enrollment seed is disabled. (Enrollment seed is only needed for 1663 * testing) 1664 */ isEnableEnrollmentTestSeed()1665 default boolean isEnableEnrollmentTestSeed() { 1666 return ENABLE_ENROLLMENT_TEST_SEED; 1667 } 1668 1669 boolean ENFORCE_FOREGROUND_STATUS_ADID = true; 1670 boolean ENFORCE_FOREGROUND_STATUS_APPSETID = true; 1671 boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_RUN_AD_SELECTION = true; 1672 boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_IMPRESSION = true; 1673 boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_INTERACTION = true; 1674 boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_OVERRIDES = true; 1675 boolean ENFORCE_FOREGROUND_STATUS_FLEDGE_CUSTOM_AUDIENCE = true; 1676 boolean ENFORCE_FOREGROUND_STATUS_TOPICS = true; 1677 1678 /** 1679 * @return true if FLEDGE runAdSelection API should require that the calling API is running in 1680 * foreground. 1681 */ getEnforceForegroundStatusForFledgeRunAdSelection()1682 default boolean getEnforceForegroundStatusForFledgeRunAdSelection() { 1683 return ENFORCE_FOREGROUND_STATUS_FLEDGE_RUN_AD_SELECTION; 1684 } 1685 1686 /** 1687 * @return true if FLEDGE reportImpression API should require that the calling API is running in 1688 * foreground. 1689 */ getEnforceForegroundStatusForFledgeReportImpression()1690 default boolean getEnforceForegroundStatusForFledgeReportImpression() { 1691 return ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_IMPRESSION; 1692 } 1693 1694 /** 1695 * @return true if FLEDGE reportInteraction API should require that the calling API is running 1696 * in foreground. 1697 */ getEnforceForegroundStatusForFledgeReportInteraction()1698 default boolean getEnforceForegroundStatusForFledgeReportInteraction() { 1699 return ENFORCE_FOREGROUND_STATUS_FLEDGE_REPORT_INTERACTION; 1700 } 1701 1702 /** 1703 * @return true if FLEDGE override API methods (for Custom Audience and Ad Selection) should 1704 * require that the calling API is running in foreground. 1705 */ getEnforceForegroundStatusForFledgeOverrides()1706 default boolean getEnforceForegroundStatusForFledgeOverrides() { 1707 return ENFORCE_FOREGROUND_STATUS_FLEDGE_OVERRIDES; 1708 } 1709 1710 /** 1711 * @return true if FLEDGE Custom Audience API methods should require that the calling API is 1712 * running in foreground. 1713 */ getEnforceForegroundStatusForFledgeCustomAudience()1714 default boolean getEnforceForegroundStatusForFledgeCustomAudience() { 1715 return ENFORCE_FOREGROUND_STATUS_FLEDGE_CUSTOM_AUDIENCE; 1716 } 1717 1718 boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_DELETE_REGISTRATIONS = true; 1719 boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_SOURCE = true; 1720 boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_TRIGGER = true; 1721 boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_SOURCE = true; 1722 boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_TRIGGER = true; 1723 boolean MEASUREMENT_ENFORCE_FOREGROUND_STATUS_GET_STATUS = true; 1724 boolean MEASUREMENT_ENFORCE_ENROLLMENT_ORIGIN_MATCH = true; 1725 1726 /** 1727 * @return true if Measurement Delete Registrations API should require that the calling API is 1728 * running in foreground. 1729 */ getEnforceForegroundStatusForMeasurementDeleteRegistrations()1730 default boolean getEnforceForegroundStatusForMeasurementDeleteRegistrations() { 1731 return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_DELETE_REGISTRATIONS; 1732 } 1733 1734 /** 1735 * @return true if Measurement Register Source API should require that the calling API is 1736 * running in foreground. 1737 */ getEnforceForegroundStatusForMeasurementRegisterSource()1738 default boolean getEnforceForegroundStatusForMeasurementRegisterSource() { 1739 return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_SOURCE; 1740 } 1741 1742 /** 1743 * @return true if Measurement Register Trigger API should require that the calling API is 1744 * running in foreground. 1745 */ getEnforceForegroundStatusForMeasurementRegisterTrigger()1746 default boolean getEnforceForegroundStatusForMeasurementRegisterTrigger() { 1747 return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_TRIGGER; 1748 } 1749 1750 /** 1751 * @return true if Measurement Register Web Source API should require that the calling API is 1752 * running in foreground. 1753 */ getEnforceForegroundStatusForMeasurementRegisterWebSource()1754 default boolean getEnforceForegroundStatusForMeasurementRegisterWebSource() { 1755 return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_SOURCE; 1756 } 1757 1758 /** 1759 * @return true if Measurement Register Web Trigger API should require that the calling API is 1760 * running in foreground. 1761 */ getEnforceForegroundStatusForMeasurementRegisterWebTrigger()1762 default boolean getEnforceForegroundStatusForMeasurementRegisterWebTrigger() { 1763 return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_REGISTER_WEB_TRIGGER; 1764 } 1765 1766 /** 1767 * @return true if Measurement Get Status API should require that the calling API is running in 1768 * foreground. 1769 */ getEnforceForegroundStatusForMeasurementStatus()1770 default boolean getEnforceForegroundStatusForMeasurementStatus() { 1771 return MEASUREMENT_ENFORCE_FOREGROUND_STATUS_GET_STATUS; 1772 } 1773 1774 /** @return true if the Enrollment match is based on url origin matching */ getEnforceEnrollmentOriginMatch()1775 default boolean getEnforceEnrollmentOriginMatch() { 1776 return MEASUREMENT_ENFORCE_ENROLLMENT_ORIGIN_MATCH; 1777 } 1778 1779 /** @return true if Topics API should require that the calling API is running in foreground. */ getEnforceForegroundStatusForTopics()1780 default boolean getEnforceForegroundStatusForTopics() { 1781 return ENFORCE_FOREGROUND_STATUS_TOPICS; 1782 } 1783 1784 /** @return true if AdId API should require that the calling API is running in foreground. */ getEnforceForegroundStatusForAdId()1785 default boolean getEnforceForegroundStatusForAdId() { 1786 return ENFORCE_FOREGROUND_STATUS_ADID; 1787 } 1788 1789 int FOREGROUND_STATUS_LEVEL = IMPORTANCE_FOREGROUND_SERVICE; 1790 1791 /** 1792 * @return true if AppSetId API should require that the calling API is running in foreground. 1793 */ getEnforceForegroundStatusForAppSetId()1794 default boolean getEnforceForegroundStatusForAppSetId() { 1795 return ENFORCE_FOREGROUND_STATUS_APPSETID; 1796 } 1797 1798 /** @return the importance level to use to check if an application is in foreground. */ getForegroundStatuslLevelForValidation()1799 default int getForegroundStatuslLevelForValidation() { 1800 return FOREGROUND_STATUS_LEVEL; 1801 } 1802 getWebContextClientAppAllowList()1803 default String getWebContextClientAppAllowList() { 1804 return WEB_CONTEXT_CLIENT_ALLOW_LIST; 1805 } 1806 1807 boolean ENFORCE_ISOLATE_MAX_HEAP_SIZE = true; 1808 long ISOLATE_MAX_HEAP_SIZE_BYTES = 10 * 1024 * 1024L; // 10 MB 1809 long MAX_RESPONSE_BASED_REGISTRATION_SIZE_BYTES = 16 * 1024; // 16 kB 1810 1811 /** 1812 * @return true if we enforce to check that JavaScriptIsolate supports limiting the max heap 1813 * size 1814 */ getEnforceIsolateMaxHeapSize()1815 default boolean getEnforceIsolateMaxHeapSize() { 1816 return ENFORCE_ISOLATE_MAX_HEAP_SIZE; 1817 } 1818 1819 /** @return size in bytes we bound the heap memory for JavaScript isolate */ getIsolateMaxHeapSizeBytes()1820 default long getIsolateMaxHeapSizeBytes() { 1821 return ISOLATE_MAX_HEAP_SIZE_BYTES; 1822 } 1823 1824 /** 1825 * @return max allowed size in bytes for response based registrations payload of an individual 1826 * source/trigger registration. 1827 */ getMaxResponseBasedRegistrationPayloadSizeBytes()1828 default long getMaxResponseBasedRegistrationPayloadSizeBytes() { 1829 return MAX_RESPONSE_BASED_REGISTRATION_SIZE_BYTES; 1830 } 1831 1832 /** Ui OTA strings group name, used for MDD download. */ 1833 String UI_OTA_STRINGS_GROUP_NAME = "ui-ota-strings"; 1834 1835 /** UI OTA strings group name. */ getUiOtaStringsGroupName()1836 default String getUiOtaStringsGroupName() { 1837 return UI_OTA_STRINGS_GROUP_NAME; 1838 } 1839 1840 /** Ui OTA strings manifest file url, used for MDD download. */ 1841 String UI_OTA_STRINGS_MANIFEST_FILE_URL = ""; 1842 1843 /** UI OTA strings manifest file url. */ getUiOtaStringsManifestFileUrl()1844 default String getUiOtaStringsManifestFileUrl() { 1845 return UI_OTA_STRINGS_MANIFEST_FILE_URL; 1846 } 1847 1848 /** Ui OTA strings feature flag. */ 1849 boolean UI_OTA_STRINGS_FEATURE_ENABLED = false; 1850 1851 /** Returns if UI OTA strings feature is enabled. */ getUiOtaStringsFeatureEnabled()1852 default boolean getUiOtaStringsFeatureEnabled() { 1853 return UI_OTA_STRINGS_FEATURE_ENABLED; 1854 } 1855 1856 /** Deadline for downloading UI OTA strings. */ 1857 long UI_OTA_STRINGS_DOWNLOAD_DEADLINE = 86700000; /* 1 day */ 1858 1859 /** Returns the deadline for downloading UI OTA strings. */ getUiOtaStringsDownloadDeadline()1860 default long getUiOtaStringsDownloadDeadline() { 1861 return UI_OTA_STRINGS_DOWNLOAD_DEADLINE; 1862 } 1863 1864 /** UI Dialogs feature enabled. */ 1865 boolean UI_DIALOGS_FEATURE_ENABLED = false; 1866 1867 /** Returns if the UI Dialogs feature is enabled. */ getUIDialogsFeatureEnabled()1868 default boolean getUIDialogsFeatureEnabled() { 1869 return UI_DIALOGS_FEATURE_ENABLED; 1870 } 1871 1872 /** UI Dialog Fragment feature enabled. */ 1873 boolean UI_DIALOG_FRAGMENT = false; 1874 /** Returns if the UI Dialog Fragment is enabled. */ getUiDialogFragmentEnabled()1875 default boolean getUiDialogFragmentEnabled() { 1876 return UI_DIALOG_FRAGMENT; 1877 } 1878 1879 /** The EEA device region feature is off by default. */ 1880 boolean IS_EEA_DEVICE_FEATURE_ENABLED = false; 1881 1882 /** Returns if the EEA device region feature has been enabled. */ isEeaDeviceFeatureEnabled()1883 default boolean isEeaDeviceFeatureEnabled() { 1884 return IS_EEA_DEVICE_FEATURE_ENABLED; 1885 } 1886 1887 /** Default is that the device is in the EEA region. */ 1888 boolean IS_EEA_DEVICE = true; 1889 1890 /** Returns if device is in the EEA region. */ isEeaDevice()1891 default boolean isEeaDevice() { 1892 return IS_EEA_DEVICE; 1893 } 1894 1895 /** Default is that the ui feature type logging is enabled. */ 1896 boolean UI_FEATURE_TYPE_LOGGING_ENABLED = true; 1897 1898 /** Returns if device is in the EEA region. */ isUiFeatureTypeLoggingEnabled()1899 default boolean isUiFeatureTypeLoggingEnabled() { 1900 return UI_FEATURE_TYPE_LOGGING_ENABLED; 1901 } 1902 1903 /** Default is that the manual interaction feature is enabled. */ 1904 boolean RECORD_MANUAL_INTERACTION_ENABLED = true; 1905 1906 /** Returns if the manual interaction feature is enabled. */ getRecordManualInteractionEnabled()1907 default boolean getRecordManualInteractionEnabled() { 1908 return RECORD_MANUAL_INTERACTION_ENABLED; 1909 } 1910 1911 /** Default is that the notification should be dismissed on click. */ 1912 boolean DEFAULT_NOTIFICATION_DISMISSED_ON_CLICK = true; 1913 1914 /** Determines whether the notification should be dismissed on click. */ getNotificationDismissedOnClick()1915 default boolean getNotificationDismissedOnClick() { 1916 return DEFAULT_NOTIFICATION_DISMISSED_ON_CLICK; 1917 } 1918 1919 /** 1920 * The check activity feature is off by default. When enabled, we check whether all Rubidium 1921 * activities are enabled when we determine whether AdServices is enabled 1922 */ 1923 boolean IS_BACK_COMPACT_ACTIVITY_FEATURE_ENABLED = false; 1924 1925 /** Returns if the check activity feature has been enabled. */ isBackCompatActivityFeatureEnabled()1926 default boolean isBackCompatActivityFeatureEnabled() { 1927 return IS_BACK_COMPACT_ACTIVITY_FEATURE_ENABLED; 1928 } 1929 1930 String UI_EEA_COUNTRIES = 1931 "AT," // Austria 1932 + "BE," // Belgium 1933 + "BG," // Bulgaria 1934 + "HR," // Croatia 1935 + "CY," // Republic of Cyprus 1936 + "CZ," // Czech Republic 1937 + "DK," // Denmark 1938 + "EE," // Estonia 1939 + "FI," // Finland 1940 + "FR," // France 1941 + "DE," // Germany 1942 + "GR," // Greece 1943 + "HU," // Hungary 1944 + "IE," // Ireland 1945 + "IT," // Italy 1946 + "LV," // Latvia 1947 + "LT," // Lithuania 1948 + "LU," // Luxembourg 1949 + "MT," // Malta 1950 + "NL," // Netherlands 1951 + "PL," // Poland 1952 + "PT," // Portugal 1953 + "RO," // Romania 1954 + "SK," // Slovakia 1955 + "SI," // Slovenia 1956 + "ES," // Spain 1957 + "SE," // Sweden 1958 + "IS," // Iceland 1959 + "LI," // Liechtenstein 1960 + "NO," // Norway 1961 + "CH," // Switzerland 1962 + "GB," // Great Britain 1963 + "GI," // Gibraltar 1964 + "GP," // Guadeloupe 1965 + "GG," // Guernsey 1966 + "JE," // Jersey 1967 + "VA," // Vatican City 1968 + "AX," // Åland Islands 1969 + "IC," // Canary Islands 1970 + "EA," // Ceuta & Melilla 1971 + "GF," // French Guiana 1972 + "PF," // French Polynesia 1973 + "TF," // French Southern Territories 1974 + "MQ," // Martinique 1975 + "YT," // Mayotte 1976 + "NC," // New Caledonia 1977 + "RE," // Réunion 1978 + "BL," // St. Barthélemy 1979 + "MF," // St. Martin 1980 + "PM," // St. Pierre & Miquelon 1981 + "SJ," // Svalbard & Jan Mayen 1982 + "WF"; // Wallis & Futuna 1983 1984 /** Returns the list of EEA countries in a String separated by comma */ getUiEeaCountries()1985 default String getUiEeaCountries() { 1986 return UI_EEA_COUNTRIES; 1987 } 1988 1989 /** 1990 * GA UX enabled. It contains features that have to be enabled at the same time: 1991 * 1992 * <ul> 1993 * <li>Updated consent landing page 1994 * <li>Consent per API (instead of aggregated one) 1995 * <li>Separate page to control Measurement API 1996 * </ul> 1997 */ 1998 boolean GA_UX_FEATURE_ENABLED = false; 1999 2000 /** Returns if the GA UX feature is enabled. */ getGaUxFeatureEnabled()2001 default boolean getGaUxFeatureEnabled() { 2002 return GA_UX_FEATURE_ENABLED; 2003 } 2004 2005 long ASYNC_REGISTRATION_JOB_QUEUE_INTERVAL_MS = (int) TimeUnit.HOURS.toMillis(1); 2006 2007 /** Returns the interval in which to run Registration Job Queue Service. */ getAsyncRegistrationJobQueueIntervalMs()2008 default long getAsyncRegistrationJobQueueIntervalMs() { 2009 return ASYNC_REGISTRATION_JOB_QUEUE_INTERVAL_MS; 2010 } 2011 2012 /** 2013 * Registration Job Queue Kill Switch. The default value is false which means Registration Job 2014 * Queue is enabled. This flag is used for emergency shutdown of the Registration Job Queue. 2015 */ 2016 boolean MEASUREMENT_REGISTRATION_JOB_QUEUE_KILL_SWITCH = false; 2017 2018 /** 2019 * Returns the kill switch value for Registration Job Queue. The job will be disabled if either 2020 * the Global Kill Switch, Measurement Kill Switch, or the Registration Job Queue Kill Switch 2021 * value is true. 2022 */ getAsyncRegistrationJobQueueKillSwitch()2023 default boolean getAsyncRegistrationJobQueueKillSwitch() { 2024 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 2025 return getGlobalKillSwitch() 2026 || getMeasurementKillSwitch() 2027 || MEASUREMENT_REGISTRATION_JOB_QUEUE_KILL_SWITCH; 2028 } 2029 2030 boolean MEASUREMENT_REGISTRATION_FALLBACK_JOB_KILL_SWITCH = false; 2031 2032 /** 2033 * Returns the kill switch value for Registration Fallback Job. The Job will be disabled if 2034 * either the Global Kill Switch, Measurement Kill Switch, or the Registration Fallback Job Kill 2035 * Switch value is true. 2036 */ getAsyncRegistrationFallbackJobKillSwitch()2037 default boolean getAsyncRegistrationFallbackJobKillSwitch() { 2038 // We check the Global Killswitch first. As a result, it overrides all other killswitches. 2039 return getGlobalKillSwitch() 2040 || getMeasurementKillSwitch() 2041 || MEASUREMENT_REGISTRATION_FALLBACK_JOB_KILL_SWITCH; 2042 } 2043 2044 /** Returns true if the given enrollmentId is blocked from using PP-API. */ isEnrollmentBlocklisted(String enrollmentId)2045 default boolean isEnrollmentBlocklisted(String enrollmentId) { 2046 return false; 2047 } 2048 2049 /** Returns a list of enrollmentId blocked from using PP-API. */ getEnrollmentBlocklist()2050 default ImmutableList<String> getEnrollmentBlocklist() { 2051 return ImmutableList.of(); 2052 } 2053 2054 long DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_HASH_LIMIT = 100L; 2055 2056 /** Returns debug keys hash limit. */ getMeasurementDebugJoinKeyHashLimit()2057 default long getMeasurementDebugJoinKeyHashLimit() { 2058 return DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_HASH_LIMIT; 2059 } 2060 2061 /** Returns the limit to the number of unique AdIDs attempted to match for debug keys. */ 2062 long DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_LIMIT = 5L; 2063 getMeasurementPlatformDebugAdIdMatchingLimit()2064 default long getMeasurementPlatformDebugAdIdMatchingLimit() { 2065 return DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_LIMIT; 2066 } 2067 2068 /** Kill switch to guard backward-compatible logging. See go/rbc-ww-logging */ 2069 boolean COMPAT_LOGGING_KILL_SWITCH = false; 2070 2071 /** Returns true if backward-compatible logging should be disabled; false otherwise. */ getCompatLoggingKillSwitch()2072 default boolean getCompatLoggingKillSwitch() { 2073 return COMPAT_LOGGING_KILL_SWITCH; 2074 } 2075 2076 /** Kill switch to guard background jobs logging. */ 2077 boolean BACKGROUND_JOBS_LOGGING_KILL_SWITCH = true; 2078 2079 /** Returns true if background jobs logging should be disabled; false otherwise */ getBackgroundJobsLoggingKillSwitch()2080 default boolean getBackgroundJobsLoggingKillSwitch() { 2081 return BACKGROUND_JOBS_LOGGING_KILL_SWITCH; 2082 } 2083 2084 // New Feature Flags 2085 boolean FLEDGE_REGISTER_AD_BEACON_ENABLED = false; 2086 2087 /** Returns whether the {@code registerAdBeacon} feature is enabled. */ getFledgeRegisterAdBeaconEnabled()2088 default boolean getFledgeRegisterAdBeaconEnabled() { 2089 return FLEDGE_REGISTER_AD_BEACON_ENABLED; 2090 } 2091 2092 /** 2093 * Default allowlist of the enrollments for whom debug key insertion based on join key matching 2094 * is allowed. 2095 */ 2096 String DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_ENROLLMENT_ALLOWLIST = ""; 2097 2098 /** 2099 * Allowlist of the enrollments for whom debug key insertion based on join key matching is 2100 * allowed. 2101 */ getMeasurementDebugJoinKeyEnrollmentAllowlist()2102 default String getMeasurementDebugJoinKeyEnrollmentAllowlist() { 2103 return DEFAULT_MEASUREMENT_DEBUG_JOIN_KEY_ENROLLMENT_ALLOWLIST; 2104 } 2105 2106 /** 2107 * Default blocklist of the enrollments for whom debug key insertion based on AdID matching is 2108 * blocked. 2109 */ 2110 String DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_BLOCKLIST = "*"; 2111 2112 /** 2113 * Blocklist of the enrollments for whom debug key insertion based on AdID matching is blocked. 2114 */ getMeasurementPlatformDebugAdIdMatchingEnrollmentBlocklist()2115 default String getMeasurementPlatformDebugAdIdMatchingEnrollmentBlocklist() { 2116 return DEFAULT_MEASUREMENT_PLATFORM_DEBUG_AD_ID_MATCHING_BLOCKLIST; 2117 } 2118 2119 /** Default Determines whether EU notification flow change is enabled. */ 2120 boolean DEFAULT_EU_NOTIF_FLOW_CHANGE_ENABLED = true; 2121 2122 /** Determines whether EU notification flow change is enabled. */ getEuNotifFlowChangeEnabled()2123 default boolean getEuNotifFlowChangeEnabled() { 2124 return DEFAULT_EU_NOTIF_FLOW_CHANGE_ENABLED; 2125 } 2126 2127 /** Default value for flexible event reporting API */ 2128 boolean MEASUREMENT_FLEXIBLE_EVENT_REPORTING_API_ENABLED = false; 2129 2130 /** Returns whether to enable flexible event reporting API */ getMeasurementFlexibleEventReportingAPIEnabled()2131 default boolean getMeasurementFlexibleEventReportingAPIEnabled() { 2132 return MEASUREMENT_FLEXIBLE_EVENT_REPORTING_API_ENABLED; 2133 } 2134 2135 /** Default maximum sources per publisher */ 2136 int MEASUREMENT_MAX_SOURCES_PER_PUBLISHER = 1024; 2137 2138 /** Returns maximum sources per publisher */ getMeasurementMaxSourcesPerPublisher()2139 default int getMeasurementMaxSourcesPerPublisher() { 2140 return MEASUREMENT_MAX_SOURCES_PER_PUBLISHER; 2141 } 2142 2143 /** Default maximum triggers per destination */ 2144 int MEASUREMENT_MAX_TRIGGERS_PER_DESTINATION = 1024; 2145 2146 /** Returns maximum triggers per destination */ getMeasurementMaxTriggersPerDestination()2147 default int getMeasurementMaxTriggersPerDestination() { 2148 return MEASUREMENT_MAX_TRIGGERS_PER_DESTINATION; 2149 } 2150 2151 /** Default maximum Aggregate Reports per destination */ 2152 int MEASUREMENT_MAX_AGGREGATE_REPORTS_PER_DESTINATION = 1024; 2153 2154 /** Returns maximum Aggregate Reports per publisher */ getMeasurementMaxAggregateReportsPerDestination()2155 default int getMeasurementMaxAggregateReportsPerDestination() { 2156 return MEASUREMENT_MAX_AGGREGATE_REPORTS_PER_DESTINATION; 2157 } 2158 2159 /** Default maximum Event Reports per destination */ 2160 int MEASUREMENT_MAX_EVENT_REPORTS_PER_DESTINATION = 1024; 2161 2162 /** Returns maximum Event Reports per destination */ getMeasurementMaxEventReportsPerDestination()2163 default int getMeasurementMaxEventReportsPerDestination() { 2164 return MEASUREMENT_MAX_EVENT_REPORTS_PER_DESTINATION; 2165 } 2166 2167 /** Disable early reporting windows configurability by default. */ 2168 boolean MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS = false; 2169 2170 /** Returns true if event reporting windows configurability is enabled, false otherwise. */ getMeasurementEnableConfigurableEventReportingWindows()2171 default boolean getMeasurementEnableConfigurableEventReportingWindows() { 2172 return MEASUREMENT_ENABLE_CONFIGURABLE_EVENT_REPORTING_WINDOWS; 2173 } 2174 2175 /** 2176 * Default early reporting windows for VTC type source. Derived from {@link 2177 * PrivacyParams#EVENT_EARLY_REPORTING_WINDOW_MILLISECONDS}. 2178 */ 2179 String MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS = ""; 2180 2181 /** 2182 * Returns configured comma separated early VTC based source's event reporting windows in 2183 * seconds. 2184 */ getMeasurementEventReportsVtcEarlyReportingWindows()2185 default String getMeasurementEventReportsVtcEarlyReportingWindows() { 2186 return MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS; 2187 } 2188 2189 /** 2190 * Default early reporting windows for CTC type source. Derived from {@link 2191 * PrivacyParams#NAVIGATION_EARLY_REPORTING_WINDOW_MILLISECONDS}. 2192 */ 2193 String MEASUREMENT_EVENT_REPORTS_CTC_EARLY_REPORTING_WINDOWS = 2194 String.join( 2195 ",", 2196 Long.toString(TimeUnit.DAYS.toSeconds(2)), 2197 Long.toString(TimeUnit.DAYS.toSeconds(7))); 2198 2199 /** 2200 * Returns configured comma separated early CTC based source's event reporting windows in 2201 * seconds. 2202 */ getMeasurementEventReportsCtcEarlyReportingWindows()2203 default String getMeasurementEventReportsCtcEarlyReportingWindows() { 2204 return MEASUREMENT_EVENT_REPORTS_VTC_EARLY_REPORTING_WINDOWS; 2205 } 2206 2207 /** Disable conversions configurability by default. */ 2208 boolean DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS = false; 2209 2210 /** 2211 * Returns true, if event reports max conversions configurability is enabled, false otherwise. 2212 */ getMeasurementEnableVtcConfigurableMaxEventReports()2213 default boolean getMeasurementEnableVtcConfigurableMaxEventReports() { 2214 return DEFAULT_MEASUREMENT_ENABLE_VTC_CONFIGURABLE_MAX_EVENT_REPORTS; 2215 } 2216 2217 /** Disable conversions configurability by default. */ 2218 int DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT = 2; 2219 2220 /** Returns the default max allowed number of event reports. */ getMeasurementVtcConfigurableMaxEventReportsCount()2221 default int getMeasurementVtcConfigurableMaxEventReportsCount() { 2222 return DEFAULT_MEASUREMENT_VTC_CONFIGURABLE_MAX_EVENT_REPORTS_COUNT; 2223 } 2224 2225 /** Default U18 UX feature flag.. */ 2226 boolean DEFAULT_U18_UX_ENABLED = false; 2227 2228 /** U18 UX feature flag.. */ getU18UxEnabled()2229 default boolean getU18UxEnabled() { 2230 return DEFAULT_U18_UX_ENABLED; 2231 } 2232 2233 /** Default enableAdServices system API feature flag.. */ 2234 boolean DEFAULT_ENABLE_AD_SERVICES_SYSTEM_API = false; 2235 2236 /** enableAdServices system API feature flag.. */ getEnableAdServicesSystemApi()2237 default boolean getEnableAdServicesSystemApi() { 2238 return DEFAULT_ENABLE_AD_SERVICES_SYSTEM_API; 2239 } 2240 2241 /** Disables client error logging for the list of error codes. Default value is empty list. */ 2242 ImmutableList<Integer> ERROR_CODE_LOGGING_DENY_LIST = ImmutableList.of(); 2243 2244 /** Returns a list of error codes for which we don't want to do error logging. */ getErrorCodeLoggingDenyList()2245 default ImmutableList<Integer> getErrorCodeLoggingDenyList() { 2246 return ERROR_CODE_LOGGING_DENY_LIST; 2247 } 2248 2249 /** Returns the map of UX flags. */ getUxFlags()2250 default Map<String, Boolean> getUxFlags() { 2251 return new HashMap<>(); 2252 } 2253 2254 /** Enable feature to unify destinations for event reports by default. */ 2255 boolean DEFAULT_MEASUREMENT_ENABLE_COARSE_EVENT_REPORT_DESTINATIONS = true; 2256 2257 /** 2258 * Returns true if event reporting destinations are enabled to be reported in a coarse manner, 2259 * i.e. both app and web destinations are merged into a single array in the event report. 2260 */ getMeasurementEnableCoarseEventReportDestinations()2261 default boolean getMeasurementEnableCoarseEventReportDestinations() { 2262 return DEFAULT_MEASUREMENT_ENABLE_COARSE_EVENT_REPORT_DESTINATIONS; 2263 } 2264 2265 /** Default value of flag for logging consent migration metrics when OTA from S to T+. */ 2266 boolean DEFAULT_ADSERVICES_CONSENT_MIGRATION_LOGGING_ENABLED = true; 2267 2268 /*** 2269 * Returns true when logging consent migration metrics is enabled when OTA from S to T+. 2270 */ getAdservicesConsentMigrationLoggingEnabled()2271 default boolean getAdservicesConsentMigrationLoggingEnabled() { 2272 return DEFAULT_ADSERVICES_CONSENT_MIGRATION_LOGGING_ENABLED; 2273 } 2274 } 2275