1 /* 2 * Copyright (C) 2024 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 static com.android.adservices.service.stats.AdsRelevanceStatusUtils.SERVER_AUCTION_COORDINATOR_SOURCE_UNSET; 20 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.SERVER_AUCTION_ENCRYPTION_KEY_SOURCE_UNSET; 21 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.SERVER_AUCTION_KEY_FETCH_SOURCE_UNSET; 22 23 import com.google.auto.value.AutoValue; 24 25 /** Class for Server Auction Key Fetch called stats */ 26 @AutoValue 27 public abstract class ServerAuctionKeyFetchCalledStats { 28 29 /** The source of key fetch (e.g., during auction, background fetch) */ 30 @AdsRelevanceStatusUtils.ServerAuctionKeyFetchSource getSource()31 public abstract int getSource(); 32 33 /** Specifies whether the key was fetched over the network or the database */ 34 @AdsRelevanceStatusUtils.ServerAuctionEncryptionKeySource getEncryptionKeySource()35 public abstract int getEncryptionKeySource(); 36 37 /** Whether we used the default coordinator or adtech-provided coordinator via API call */ 38 @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource getCoordinatorSource()39 public abstract int getCoordinatorSource(); 40 41 /** The status code of the network call */ getNetworkStatusCode()42 public abstract int getNetworkStatusCode(); 43 44 /** The latency of network key fetch (in milliseconds) */ getNetworkLatencyMillis()45 public abstract int getNetworkLatencyMillis(); 46 47 /** Returns a generic builder. */ builder()48 public static Builder builder() { 49 return new AutoValue_ServerAuctionKeyFetchCalledStats.Builder() 50 .setSource(SERVER_AUCTION_KEY_FETCH_SOURCE_UNSET) 51 .setEncryptionKeySource(SERVER_AUCTION_ENCRYPTION_KEY_SOURCE_UNSET) 52 .setCoordinatorSource(SERVER_AUCTION_COORDINATOR_SOURCE_UNSET); 53 } 54 55 /** Builder class for ServerAuctionKeyFetchCalledStats. */ 56 @AutoValue.Builder 57 public abstract static class Builder { 58 /** Sets the source of key fetch (e.g., during auction, background fetch) */ setSource( @dsRelevanceStatusUtils.ServerAuctionKeyFetchSource int source)59 public abstract Builder setSource( 60 @AdsRelevanceStatusUtils.ServerAuctionKeyFetchSource int source); 61 62 /** Sets whether the key was fetched over the network or the database */ setEncryptionKeySource( @dsRelevanceStatusUtils.ServerAuctionEncryptionKeySource int encryptionKeySource)63 public abstract Builder setEncryptionKeySource( 64 @AdsRelevanceStatusUtils.ServerAuctionEncryptionKeySource int encryptionKeySource); 65 66 /** 67 * Sets whether we used the default coordinator or adtech-provided coordinator via API call 68 */ setCoordinatorSource( @dsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource)69 public abstract Builder setCoordinatorSource( 70 @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource); 71 72 /** Sets the status code of the network call */ setNetworkStatusCode(int networkStatusCode)73 public abstract Builder setNetworkStatusCode(int networkStatusCode); 74 75 /** Sets the latency of network key fetch (in milliseconds) */ setNetworkLatencyMillis(int networkLatencyMillis)76 public abstract Builder setNetworkLatencyMillis(int networkLatencyMillis); 77 78 /** Builds the {@link ServerAuctionKeyFetchCalledStats} object. */ build()79 public abstract ServerAuctionKeyFetchCalledStats build(); 80 } 81 } 82