1 /* 2 * Copyright (C) 2023 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.adservices.service.measurement; 18 19 import com.android.adservices.service.Flags; 20 21 /** Class for cached Phenotype flags. */ 22 public class CachedFlags { 23 private final boolean mEnableSessionStableKillSwitches; 24 private final boolean mApiRegisterSourceKillSwitch; 25 private final boolean mApiRegisterSourcesKillSwitch; 26 private final boolean mApiRegisterWebSourceKillSwitch; 27 private final boolean mApiRegisterTriggerKillSwitch; 28 private final boolean mApiRegisterWebTriggerKillSwitch; 29 private final boolean mApiDeleteRegistrationsKillSwitch; 30 private final boolean mApiStatusKillSwitch; 31 private final boolean mEnforceForegroundStatusForMeasurementRegisterWebSource; 32 private final boolean mEnforceForegroundStatusForMeasurementRegisterWebTrigger; 33 private final boolean mEnforceForegroundStatusForMeasurementRegisterSource; 34 private final boolean mEnforceForegroundStatusForMeasurementRegisterTrigger; 35 private final boolean mEnforceForegroundStatusForMeasurementRegisterSources; 36 private final boolean mEnforceForegroundStatusForMeasurementDeleteRegistrations; 37 private final boolean mEnforceForegroundStatusForMeasurementStatus; 38 private final boolean mEnableApiStatusAllowListCheck; 39 private final boolean mConsentNotifiedDebugMode; 40 private final String mApiAppAllowList; 41 private final String mApiAppBlockList; 42 private final String mWebContextClientAppAllowList; 43 private final Flags mFlags; 44 CachedFlags(Flags flags)45 public CachedFlags(Flags flags) { 46 mFlags = flags; 47 mEnableSessionStableKillSwitches = flags.getMeasurementEnableSessionStableKillSwitches(); 48 mApiRegisterSourceKillSwitch = flags.getMeasurementApiRegisterSourceKillSwitch(); 49 mApiRegisterSourcesKillSwitch = flags.getMeasurementApiRegisterSourcesKillSwitch(); 50 mApiRegisterWebSourceKillSwitch = flags.getMeasurementApiRegisterWebSourceKillSwitch(); 51 mApiRegisterTriggerKillSwitch = flags.getMeasurementApiRegisterTriggerKillSwitch(); 52 mApiRegisterWebTriggerKillSwitch = flags.getMeasurementApiRegisterWebTriggerKillSwitch(); 53 mApiDeleteRegistrationsKillSwitch = flags.getMeasurementApiDeleteRegistrationsKillSwitch(); 54 mApiStatusKillSwitch = flags.getMeasurementApiStatusKillSwitch(); 55 mEnforceForegroundStatusForMeasurementRegisterWebTrigger = 56 flags.getEnforceForegroundStatusForMeasurementRegisterWebTrigger(); 57 mEnforceForegroundStatusForMeasurementRegisterWebSource = 58 flags.getEnforceForegroundStatusForMeasurementRegisterWebSource(); 59 mEnforceForegroundStatusForMeasurementRegisterTrigger = 60 flags.getEnforceForegroundStatusForMeasurementRegisterTrigger(); 61 mEnforceForegroundStatusForMeasurementRegisterSource = 62 flags.getEnforceForegroundStatusForMeasurementRegisterSource(); 63 mEnforceForegroundStatusForMeasurementRegisterSources = 64 flags.getEnforceForegroundStatusForMeasurementRegisterSources(); 65 mEnforceForegroundStatusForMeasurementDeleteRegistrations = 66 flags.getEnforceForegroundStatusForMeasurementDeleteRegistrations(); 67 mEnforceForegroundStatusForMeasurementStatus = 68 flags.getEnforceForegroundStatusForMeasurementStatus(); 69 mApiAppAllowList = flags.getMsmtApiAppAllowList(); 70 mApiAppBlockList = flags.getMsmtApiAppBlockList(); 71 mWebContextClientAppAllowList = flags.getWebContextClientAppAllowList(); 72 mEnableApiStatusAllowListCheck = flags.getMsmtEnableApiStatusAllowListCheck(); 73 mConsentNotifiedDebugMode = flags.getConsentNotifiedDebugMode(); 74 } 75 getMeasurementApiRegisterSourceKillSwitch()76 public boolean getMeasurementApiRegisterSourceKillSwitch() { 77 return mEnableSessionStableKillSwitches 78 ? mApiRegisterSourceKillSwitch 79 : mFlags.getMeasurementApiRegisterSourceKillSwitch(); 80 } 81 getMeasurementApiRegisterSourcesKillSwitch()82 public boolean getMeasurementApiRegisterSourcesKillSwitch() { 83 return mEnableSessionStableKillSwitches 84 ? mApiRegisterSourcesKillSwitch 85 : mFlags.getMeasurementApiRegisterSourcesKillSwitch(); 86 } 87 getMeasurementApiRegisterWebSourceKillSwitch()88 public boolean getMeasurementApiRegisterWebSourceKillSwitch() { 89 return mEnableSessionStableKillSwitches 90 ? mApiRegisterWebSourceKillSwitch 91 : mFlags.getMeasurementApiRegisterWebSourceKillSwitch(); 92 } 93 getMeasurementApiRegisterTriggerKillSwitch()94 public boolean getMeasurementApiRegisterTriggerKillSwitch() { 95 return mEnableSessionStableKillSwitches 96 ? mApiRegisterTriggerKillSwitch 97 : mFlags.getMeasurementApiRegisterTriggerKillSwitch(); 98 } 99 getMeasurementApiRegisterWebTriggerKillSwitch()100 public boolean getMeasurementApiRegisterWebTriggerKillSwitch() { 101 return mEnableSessionStableKillSwitches 102 ? mApiRegisterWebTriggerKillSwitch 103 : mFlags.getMeasurementApiRegisterWebTriggerKillSwitch(); 104 } 105 getMeasurementApiDeleteRegistrationsKillSwitch()106 public boolean getMeasurementApiDeleteRegistrationsKillSwitch() { 107 return mEnableSessionStableKillSwitches 108 ? mApiDeleteRegistrationsKillSwitch 109 : mFlags.getMeasurementApiDeleteRegistrationsKillSwitch(); 110 } 111 getMeasurementApiStatusKillSwitch()112 public boolean getMeasurementApiStatusKillSwitch() { 113 return mEnableSessionStableKillSwitches 114 ? mApiStatusKillSwitch 115 : mFlags.getMeasurementApiStatusKillSwitch(); 116 } 117 getEnforceForegroundStatusForMeasurementRegisterSource()118 public boolean getEnforceForegroundStatusForMeasurementRegisterSource() { 119 return mEnableSessionStableKillSwitches 120 ? mEnforceForegroundStatusForMeasurementRegisterSource 121 : mFlags.getEnforceForegroundStatusForMeasurementRegisterSource(); 122 } 123 getEnforceForegroundStatusForMeasurementRegisterTrigger()124 public boolean getEnforceForegroundStatusForMeasurementRegisterTrigger() { 125 return mEnableSessionStableKillSwitches 126 ? mEnforceForegroundStatusForMeasurementRegisterTrigger 127 : mFlags.getEnforceForegroundStatusForMeasurementRegisterTrigger(); 128 } 129 getEnforceForegroundStatusForMeasurementRegisterSources()130 public boolean getEnforceForegroundStatusForMeasurementRegisterSources() { 131 return mEnableSessionStableKillSwitches 132 ? mEnforceForegroundStatusForMeasurementRegisterSources 133 : mFlags.getEnforceForegroundStatusForMeasurementRegisterSources(); 134 } 135 getEnforceForegroundStatusForMeasurementRegisterWebSource()136 public boolean getEnforceForegroundStatusForMeasurementRegisterWebSource() { 137 return mEnableSessionStableKillSwitches 138 ? mEnforceForegroundStatusForMeasurementRegisterWebSource 139 : mFlags.getEnforceForegroundStatusForMeasurementRegisterWebSource(); 140 } 141 getEnforceForegroundStatusForMeasurementRegisterWebTrigger()142 public boolean getEnforceForegroundStatusForMeasurementRegisterWebTrigger() { 143 return mEnableSessionStableKillSwitches 144 ? mEnforceForegroundStatusForMeasurementRegisterWebTrigger 145 : mFlags.getEnforceForegroundStatusForMeasurementRegisterWebTrigger(); 146 } 147 getEnforceForegroundStatusForMeasurementDeleteRegistrations()148 public boolean getEnforceForegroundStatusForMeasurementDeleteRegistrations() { 149 return mEnableSessionStableKillSwitches 150 ? mEnforceForegroundStatusForMeasurementDeleteRegistrations 151 : mFlags.getEnforceForegroundStatusForMeasurementDeleteRegistrations(); 152 } 153 getMsmtEnableApiStatusAllowListCheck()154 public boolean getMsmtEnableApiStatusAllowListCheck() { 155 return mEnableSessionStableKillSwitches 156 ? mEnableApiStatusAllowListCheck 157 : mFlags.getMsmtEnableApiStatusAllowListCheck(); 158 } 159 getConsentNotifiedDebugMode()160 public boolean getConsentNotifiedDebugMode() { 161 return mEnableSessionStableKillSwitches 162 ? mConsentNotifiedDebugMode 163 : mFlags.getConsentNotifiedDebugMode(); 164 } 165 getEnforceForegroundStatusForMeasurementStatus()166 public boolean getEnforceForegroundStatusForMeasurementStatus() { 167 return mEnableSessionStableKillSwitches 168 ? mEnforceForegroundStatusForMeasurementStatus 169 : mFlags.getEnforceForegroundStatusForMeasurementStatus(); 170 } 171 getMsmtApiAppAllowList()172 public String getMsmtApiAppAllowList() { 173 return mEnableSessionStableKillSwitches 174 ? mApiAppAllowList 175 : mFlags.getMsmtApiAppAllowList(); 176 } 177 getMsmtApiAppBlockList()178 public String getMsmtApiAppBlockList() { 179 return mEnableSessionStableKillSwitches 180 ? mApiAppBlockList 181 : mFlags.getMsmtApiAppBlockList(); 182 } 183 getWebContextClientAppAllowList()184 public String getWebContextClientAppAllowList() { 185 return mEnableSessionStableKillSwitches 186 ? mWebContextClientAppAllowList 187 : mFlags.getWebContextClientAppAllowList(); 188 } 189 } 190