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.reporting; 18 19 20 21 /** POJO for storing aggregate and event reporting status */ 22 public class ReportingStatus { 23 24 /** Enums are tied to the AdservicesMeasurementReportsUploaded atom */ 25 public enum ReportType { 26 UNKNOWN(0), 27 EVENT(1), 28 AGGREGATE(2), 29 DEBUG_EVENT(3), 30 DEBUG_AGGREGATE(4), 31 VERBOSE_DEBUG_SOURCE_DESTINATION_LIMIT(5), 32 VERBOSE_DEBUG_SOURCE_NOISED(6), 33 VERBOSE_DEBUG_SOURCE_STORAGE_LIMIT(7), 34 VERBOSE_DEBUG_SOURCE_SUCCESS(8), 35 VERBOSE_DEBUG_SOURCE_UNKNOWN_ERROR(9), 36 VERBOSE_DEBUG_SOURCE_FLEXIBLE_EVENT_REPORT_VALUE_ERROR(10), 37 VERBOSE_DEBUG_TRIGGER_AGGREGATE_DEDUPLICATED(11), 38 VERBOSE_DEBUG_TRIGGER_AGGREGATE_INSUFFICIENT_BUDGET(12), 39 VERBOSE_DEBUG_TRIGGER_AGGREGATE_NO_CONTRIBUTIONS(13), 40 VERBOSE_DEBUG_TRIGGER_AGGREGATE_REPORT_WINDOW_PASSED(14), 41 VERBOSE_DEBUG_TRIGGER_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT(15), 42 VERBOSE_DEBUG_TRIGGER_EVENT_DEDUPLICATED(16), 43 VERBOSE_DEBUG_TRIGGER_EVENT_EXCESSIVE_REPORTS(17), 44 VERBOSE_DEBUG_TRIGGER_EVENT_LOW_PRIORITY(18), 45 VERBOSE_DEBUG_TRIGGER_EVENT_NO_MATCHING_CONFIGURATIONS(19), 46 VERBOSE_DEBUG_TRIGGER_EVENT_NOISE(20), 47 VERBOSE_DEBUG_TRIGGER_EVENT_REPORT_WINDOW_PASSED(21), 48 VERBOSE_DEBUG_TRIGGER_NO_MATCHING_FILTER_DATA(22), 49 VERBOSE_DEBUG_TRIGGER_NO_MATCHING_SOURCE(23), 50 VERBOSE_DEBUG_TRIGGER_REPORTING_ORIGIN_LIMIT(24), 51 VERBOSE_DEBUG_TRIGGER_EVENT_STORAGE_LIMIT(25), 52 VERBOSE_DEBUG_TRIGGER_UNKNOWN_ERROR(26), 53 VERBOSE_DEBUG_TRIGGER_AGGREGATE_STORAGE_LIMIT(27), 54 VERBOSE_DEBUG_TRIGGER_AGGREGATE_EXCESSIVE_REPORTS(28), 55 VERBOSE_DEBUG_TRIGGER_EVENT_REPORT_WINDOW_NOT_STARTED(29), 56 VERBOSE_DEBUG_TRIGGER_EVENT_NO_MATCHING_TRIGGER_DATA(30), 57 VERBOSE_DEBUG_TRIGGER_EVENT_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT(31), 58 VERBOSE_DEBUG_TRIGGER_AGG_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT(32), 59 VERBOSE_DEBUG_HEADER_ERROR(33), 60 VERBOSE_DEBUG_UNKNOWN(9999), 61 AGGREGATE_DEBUG_REPORT(10000); 62 63 private final int mValue; 64 ReportType(int value)65 ReportType(int value) { 66 mValue = value; 67 } 68 getValue()69 public int getValue() { 70 return mValue; 71 } 72 73 @Override toString()74 public String toString() { 75 return name(); 76 } 77 } 78 79 public enum UploadStatus { 80 UNKNOWN(0), 81 SUCCESS(1), 82 FAILURE(2); 83 84 private final int mValue; 85 UploadStatus(int value)86 UploadStatus(int value) { 87 mValue = value; 88 } 89 getValue()90 public int getValue() { 91 return mValue; 92 } 93 } 94 95 public enum FailureStatus { 96 UNKNOWN(0), 97 ENROLLMENT_NOT_FOUND(1), 98 NETWORK(2), 99 DATASTORE(3), 100 REPORT_NOT_PENDING(4), 101 JOB_RETRY_LIMIT_REACHED(5), 102 SERIALIZATION_ERROR(6), 103 ENCRYPTION_ERROR(7), 104 UNSUCCESSFUL_HTTP_RESPONSE_CODE(8), 105 REPORT_NOT_FOUND(9), 106 APP_UNINSTALLED_OR_OUTSIDE_WINDOW(10); 107 private final int mValue; 108 FailureStatus(int value)109 FailureStatus(int value) { 110 mValue = value; 111 } 112 getValue()113 public int getValue() { 114 return mValue; 115 } 116 } 117 118 public enum UploadMethod { 119 UNKNOWN(0), 120 REGULAR(1), 121 FALLBACK(2); 122 private final int mValue; 123 UploadMethod(int value)124 UploadMethod(int value) { 125 mValue = value; 126 } 127 getValue()128 public int getValue() { 129 return mValue; 130 } 131 } 132 133 private ReportType mReportType; 134 private UploadStatus mUploadStatus; 135 136 private FailureStatus mFailureStatus; 137 138 private UploadMethod mUploadMethod; 139 140 private long mReportingDelay; 141 142 private String mSourceRegistrant; 143 144 private int mRetryCount; 145 146 private boolean mIsFakeReport; 147 ReportingStatus()148 public ReportingStatus() { 149 mReportType = ReportType.UNKNOWN; 150 mUploadStatus = UploadStatus.UNKNOWN; 151 mFailureStatus = FailureStatus.UNKNOWN; 152 mUploadMethod = UploadMethod.UNKNOWN; 153 mReportingDelay = 0L; 154 mSourceRegistrant = ""; 155 mIsFakeReport = false; 156 } 157 158 /** Get the type of report that is being uploaded. */ getReportType()159 public ReportType getReportType() { 160 return mReportType; 161 } 162 163 /** Set the type of report that is being uploaded. */ setReportType(ReportType reportType)164 public void setReportType(ReportType reportType) { 165 mReportType = reportType; 166 } 167 168 /** set the type of report that is being uploaded from debug report type string. */ setReportType(String reportType)169 public void setReportType(String reportType) { 170 if (reportType.equals(DebugReportApi.Type.SOURCE_DESTINATION_LIMIT)) { 171 mReportType = ReportType.VERBOSE_DEBUG_SOURCE_DESTINATION_LIMIT; 172 } else if (reportType.equals(DebugReportApi.Type.SOURCE_NOISED)) { 173 mReportType = ReportType.VERBOSE_DEBUG_SOURCE_NOISED; 174 } else if (reportType.equals(DebugReportApi.Type.SOURCE_STORAGE_LIMIT)) { 175 mReportType = ReportType.VERBOSE_DEBUG_SOURCE_STORAGE_LIMIT; 176 } else if (reportType.equals(DebugReportApi.Type.SOURCE_SUCCESS)) { 177 mReportType = ReportType.VERBOSE_DEBUG_SOURCE_SUCCESS; 178 } else if (reportType.equals(DebugReportApi.Type.SOURCE_UNKNOWN_ERROR)) { 179 mReportType = ReportType.VERBOSE_DEBUG_SOURCE_UNKNOWN_ERROR; 180 } else if (reportType.equals( 181 DebugReportApi.Type.SOURCE_FLEXIBLE_EVENT_REPORT_VALUE_ERROR)) { 182 mReportType = ReportType.VERBOSE_DEBUG_SOURCE_FLEXIBLE_EVENT_REPORT_VALUE_ERROR; 183 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_AGGREGATE_DEDUPLICATED)) { 184 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_AGGREGATE_DEDUPLICATED; 185 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_AGGREGATE_INSUFFICIENT_BUDGET)) { 186 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_AGGREGATE_INSUFFICIENT_BUDGET; 187 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_AGGREGATE_NO_CONTRIBUTIONS)) { 188 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_AGGREGATE_NO_CONTRIBUTIONS; 189 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_AGGREGATE_REPORT_WINDOW_PASSED)) { 190 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_AGGREGATE_REPORT_WINDOW_PASSED; 191 } else if (reportType.equals( 192 DebugReportApi.Type.TRIGGER_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT)) { 193 mReportType = 194 ReportType.VERBOSE_DEBUG_TRIGGER_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT; 195 } else if (reportType.equals( 196 DebugReportApi.Type.TRIGGER_EVENT_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT)) { 197 mReportType = 198 ReportType 199 .VERBOSE_DEBUG_TRIGGER_EVENT_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT; 200 } else if (reportType.equals( 201 DebugReportApi.Type.TRIGGER_AGGREGATE_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT)) { 202 mReportType = 203 ReportType.VERBOSE_DEBUG_TRIGGER_AGG_ATTRIBUTIONS_PER_SOURCE_DESTINATION_LIMIT; 204 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_DEDUPLICATED)) { 205 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_DEDUPLICATED; 206 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_EXCESSIVE_REPORTS)) { 207 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_EXCESSIVE_REPORTS; 208 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_LOW_PRIORITY)) { 209 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_LOW_PRIORITY; 210 } else if (reportType.equals( 211 DebugReportApi.Type.TRIGGER_EVENT_NO_MATCHING_CONFIGURATIONS)) { 212 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_NO_MATCHING_CONFIGURATIONS; 213 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_NOISE)) { 214 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_NOISE; 215 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_REPORT_WINDOW_PASSED)) { 216 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_REPORT_WINDOW_PASSED; 217 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_NO_MATCHING_FILTER_DATA)) { 218 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_NO_MATCHING_FILTER_DATA; 219 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_NO_MATCHING_SOURCE)) { 220 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_NO_MATCHING_SOURCE; 221 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_REPORTING_ORIGIN_LIMIT)) { 222 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_REPORTING_ORIGIN_LIMIT; 223 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_STORAGE_LIMIT)) { 224 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_STORAGE_LIMIT; 225 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_UNKNOWN_ERROR)) { 226 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_UNKNOWN_ERROR; 227 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_AGGREGATE_STORAGE_LIMIT)) { 228 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_AGGREGATE_STORAGE_LIMIT; 229 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_AGGREGATE_EXCESSIVE_REPORTS)) { 230 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_AGGREGATE_EXCESSIVE_REPORTS; 231 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_REPORT_WINDOW_NOT_STARTED)) { 232 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_REPORT_WINDOW_NOT_STARTED; 233 } else if (reportType.equals(DebugReportApi.Type.TRIGGER_EVENT_NO_MATCHING_TRIGGER_DATA)) { 234 mReportType = ReportType.VERBOSE_DEBUG_TRIGGER_EVENT_NO_MATCHING_TRIGGER_DATA; 235 } else if (reportType.equals(DebugReportApi.Type.HEADER_PARSING_ERROR)) { 236 mReportType = ReportType.VERBOSE_DEBUG_HEADER_ERROR; 237 } else { 238 mReportType = ReportType.VERBOSE_DEBUG_UNKNOWN; 239 } 240 } 241 242 /** Get the upload status of reporting. */ getUploadStatus()243 public UploadStatus getUploadStatus() { 244 return mUploadStatus; 245 } 246 247 /** Set upload status of reporting. */ setUploadStatus(UploadStatus status)248 public void setUploadStatus(UploadStatus status) { 249 mUploadStatus = status; 250 } 251 252 /** Get the failure status of reporting. */ getFailureStatus()253 public FailureStatus getFailureStatus() { 254 return mFailureStatus; 255 } 256 257 /** Set failure status of reporting. */ setFailureStatus(FailureStatus status)258 public void setFailureStatus(FailureStatus status) { 259 mFailureStatus = status; 260 } 261 262 /** Get the upload method of reporting. */ getUploadMethod()263 public UploadMethod getUploadMethod() { 264 return mUploadMethod; 265 } 266 267 /** Set upload method of reporting. */ setUploadMethod(UploadMethod method)268 public void setUploadMethod(UploadMethod method) { 269 mUploadMethod = method; 270 } 271 272 /** Get registration delay. */ getReportingDelay()273 public long getReportingDelay() { 274 return mReportingDelay; 275 } 276 277 /** Set registration delay. */ setReportingDelay(long reportingDelay)278 public void setReportingDelay(long reportingDelay) { 279 mReportingDelay = reportingDelay; 280 } 281 282 /** Get source registrant. */ getSourceRegistrant()283 public String getSourceRegistrant() { 284 return mSourceRegistrant; 285 } 286 287 /** Set source registrant. */ setSourceRegistrant(String sourceRegistrant)288 public void setSourceRegistrant(String sourceRegistrant) { 289 mSourceRegistrant = sourceRegistrant; 290 } 291 292 /** Get retry count. */ getRetryCount()293 public int getRetryCount() { 294 return mRetryCount; 295 } 296 297 /** Set retry count. */ setRetryCount(int retryCount)298 public void setRetryCount(int retryCount) { 299 mRetryCount = retryCount; 300 } 301 302 /** Gets if the report is fake. */ getIsFakeReport()303 public boolean getIsFakeReport() { 304 return mIsFakeReport; 305 } 306 307 /** Sets if the report is fake. */ setIsFakeReport(boolean isFakeReport)308 public void setIsFakeReport(boolean isFakeReport) { 309 mIsFakeReport = isFakeReport; 310 } 311 } 312