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.stats; 18 19 import android.annotation.Nullable; 20 21 import com.google.auto.value.AutoValue; 22 23 /** Class for AdServicesEncryptionKeyFetched atom. */ 24 @AutoValue 25 public abstract class AdServicesEncryptionKeyFetchedStats { 26 27 /** 28 * @return encryption key fetch job type. 29 */ getFetchJobType()30 public abstract FetchJobType getFetchJobType(); 31 32 /** 33 * @return encryption key fetch status. 34 */ getFetchStatus()35 public abstract FetchStatus getFetchStatus(); 36 37 /** 38 * @return whether the key is fetched for the first time. 39 */ getIsFirstTimeFetch()40 public abstract boolean getIsFirstTimeFetch(); 41 42 /** 43 * @return enrollment id for the adtech corresponding to the encryption key. 44 */ getAdtechEnrollmentId()45 public abstract String getAdtechEnrollmentId(); 46 47 /** 48 * @return encryption key url. 49 */ 50 @Nullable getEncryptionKeyUrl()51 public abstract String getEncryptionKeyUrl(); 52 53 /** 54 * @return generic builder. 55 */ builder()56 public static AdServicesEncryptionKeyFetchedStats.Builder builder() { 57 return new AutoValue_AdServicesEncryptionKeyFetchedStats.Builder(); 58 } 59 60 // Encryption key fetch job type. 61 public enum FetchJobType { 62 UNKNOWN_JOB(0), 63 ENCRYPTION_KEY_DAILY_FETCH_JOB(1), 64 MDD_DOWNLOAD_JOB(2); 65 66 private final int mValue; 67 FetchJobType(int value)68 FetchJobType(int value) { 69 mValue = value; 70 } 71 getValue()72 public int getValue() { 73 return mValue; 74 } 75 } 76 77 // Encryption key fetch status. 78 public enum FetchStatus { 79 UNKNOWN(0), 80 NULL_ENDPOINT(1), 81 INVALID_ENDPOINT(2), 82 IO_EXCEPTION(3), 83 BAD_REQUEST_EXCEPTION(4), 84 KEY_NOT_MODIFIED(5), 85 SUCCESS(6); 86 87 private final int mValue; 88 FetchStatus(int value)89 FetchStatus(int value) { 90 mValue = value; 91 } 92 getValue()93 public int getValue() { 94 return mValue; 95 } 96 } 97 98 /** Builder class for {@link AdServicesEncryptionKeyFetchedStats} */ 99 @AutoValue.Builder 100 public abstract static class Builder { 101 /** Set encryption key fetch job type. */ setFetchJobType(FetchJobType value)102 public abstract Builder setFetchJobType(FetchJobType value); 103 104 /** Set encryption key fetch status. */ setFetchStatus(FetchStatus value)105 public abstract Builder setFetchStatus(FetchStatus value); 106 107 /** Set whether the key is fetched for the first time. */ setIsFirstTimeFetch(boolean value)108 public abstract Builder setIsFirstTimeFetch(boolean value); 109 110 /** Set enrollment id for the adtech corresponding to the encryption key. */ setAdtechEnrollmentId(String value)111 public abstract Builder setAdtechEnrollmentId(String value); 112 113 /** Set encryption key url. */ setEncryptionKeyUrl(@ullable String value)114 public abstract Builder setEncryptionKeyUrl(@Nullable String value); 115 116 /** Build for {@link AdServicesEncryptionKeyFetchedStats}. */ build()117 public abstract AdServicesEncryptionKeyFetchedStats build(); 118 } 119 } 120