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 com.google.auto.value.AutoValue; 20 21 /** Class for AdServicesEncryptionKeyDbTransactionEnded atom. */ 22 @AutoValue 23 public abstract class AdServicesEncryptionKeyDbTransactionEndedStats { 24 25 /** 26 * @return encryption key datastore transaction type. 27 */ getDbTransactionType()28 public abstract DbTransactionType getDbTransactionType(); 29 30 /** 31 * @return encryption key datastore transaction status. 32 */ getDbTransactionStatus()33 public abstract DbTransactionStatus getDbTransactionStatus(); 34 35 /** 36 * @return encryption key dao method name. 37 */ getMethodName()38 public abstract MethodName getMethodName(); 39 40 /** 41 * @return generic builder. 42 */ builder()43 public static AdServicesEncryptionKeyDbTransactionEndedStats.Builder builder() { 44 return new AutoValue_AdServicesEncryptionKeyDbTransactionEndedStats.Builder(); 45 } 46 47 // Encryption key datastore transaction type. 48 public enum DbTransactionType { 49 UNKNOWN(0), 50 READ_TRANSACTION_TYPE(1), 51 WRITE_TRANSACTION_TYPE(2); 52 53 private final int mValue; 54 DbTransactionType(int value)55 DbTransactionType(int value) { 56 mValue = value; 57 } 58 getValue()59 public int getValue() { 60 return mValue; 61 } 62 } 63 64 // Encryption key datastore transaction status. 65 public enum DbTransactionStatus { 66 UNKNOWN_EXCEPTION(0), 67 INVALID_KEY(1), 68 INSERT_EXCEPTION(2), 69 DELETE_EXCEPTION(3), 70 SEARCH_EXCEPTION(4), 71 SUCCESS(5); 72 73 private final int mValue; 74 DbTransactionStatus(int value)75 DbTransactionStatus(int value) { 76 mValue = value; 77 } 78 getValue()79 public int getValue() { 80 return mValue; 81 } 82 } 83 84 // Encryption key DAO method names. 85 public enum MethodName { 86 UNKNOWN_METHOD(0), 87 GET_KEY_FROM_ENROLLMENT_ID(1), 88 GET_KEY_FROM_ENROLLMENT_ID_AND_KEY_TYPE(2), 89 GET_KEY_FROM_ENROLLMENT_ID_AND_KEY_ID(3), 90 GET_KEY_FROM_REPORTING_ORIGIN(4), 91 GET_ALL_KEYS(5), 92 INSERT_KEY(6), 93 INSERT_KEYS(7), 94 DELETE_KEY(8); 95 96 private final int mValue; 97 MethodName(int value)98 MethodName(int value) { 99 mValue = value; 100 } 101 getValue()102 public int getValue() { 103 return mValue; 104 } 105 } 106 107 /** Builder class for {@link AdServicesEncryptionKeyDbTransactionEndedStats} */ 108 @AutoValue.Builder 109 public abstract static class Builder { 110 111 /** Set encryption key datastore transaction type. */ setDbTransactionType(DbTransactionType value)112 public abstract Builder setDbTransactionType(DbTransactionType value); 113 114 /** Set encryption key datastore transaction status. */ setDbTransactionStatus(DbTransactionStatus value)115 public abstract Builder setDbTransactionStatus(DbTransactionStatus value); 116 117 /** Set encryption key dao method name. */ setMethodName(MethodName value)118 public abstract Builder setMethodName(MethodName value); 119 120 /** Build for {@link AdServicesEncryptionKeyDbTransactionEndedStats}. */ build()121 public abstract AdServicesEncryptionKeyDbTransactionEndedStats build(); 122 } 123 } 124