• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.AdServicesLoggerUtil.FIELD_UNSET;
20 import static com.android.adservices.service.stats.AdsRelevanceStatusUtils.SERVER_AUCTION_COORDINATOR_SOURCE_UNSET;
21 
22 import android.adservices.common.AdServicesStatusUtils;
23 
24 import com.google.auto.value.AutoValue;
25 
26 /** Class for GetAdSelectionData API called stats */
27 @AutoValue
28 public abstract class GetAdSelectionDataApiCalledStats {
29     /** Returns the size of the payload in Kb after encryption and padding */
getPayloadSizeKb()30     public abstract int getPayloadSizeKb();
31 
32     /** Return number of buyers participating in this payload */
getNumBuyers()33     public abstract int getNumBuyers();
34 
35     /** The status response code of the GetAdSelectionData API in AdServices */
36     @AdServicesStatusUtils.StatusCode
getStatusCode()37     public abstract int getStatusCode();
38 
39     /** Return the coordinator source in this payload, i.e., DEFAULT or provided via API */
40     @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource
getServerAuctionCoordinatorSource()41     public abstract int getServerAuctionCoordinatorSource();
42 
43     /** Return the maximum size set by the seller. */
getSellerMaxSizeKb()44     public abstract int getSellerMaxSizeKb();
45 
46     /** Return the result of payload optimization. */
getPayloadOptimizationResult()47     public abstract PayloadOptimizationResult getPayloadOptimizationResult();
48 
49     /** Return the latency of buyer input generation. */
getInputGenerationLatencyMs()50     public abstract int getInputGenerationLatencyMs();
51 
52     /** Version of compressed buyer input creator. */
getCompressedBuyerInputCreatorVersion()53     public abstract int getCompressedBuyerInputCreatorVersion();
54 
55     /** Number of times the payload was re compressed to update the current size estimation. */
getNumReEstimations()56     public abstract int getNumReEstimations();
57 
58     // The result of the getAdSelectionDataPayload optimization
59     public enum PayloadOptimizationResult {
60         PAYLOAD_OPTIMIZATION_RESULT_UNKNOWN(0),
61         // there was still data available on the device but ran out of space.
62         PAYLOAD_TRUNCATED_FOR_REQUESTED_MAX(1),
63         // there was not enough data on the device so the max was not reached.
64         PAYLOAD_WITHIN_REQUESTED_MAX(2);
65 
66         private final int mValue;
67 
PayloadOptimizationResult(int value)68         PayloadOptimizationResult(int value) {
69             mValue = value;
70         }
71 
getValue()72         public int getValue() {
73             return mValue;
74         }
75     }
76 
77     /** Returns a generic builder. */
builder()78     public static Builder builder() {
79         return new AutoValue_GetAdSelectionDataApiCalledStats.Builder()
80                 .setServerAuctionCoordinatorSource(SERVER_AUCTION_COORDINATOR_SOURCE_UNSET)
81                 .setSellerMaxSizeKb(FIELD_UNSET)
82                 .setPayloadOptimizationResult(
83                         PayloadOptimizationResult.PAYLOAD_OPTIMIZATION_RESULT_UNKNOWN)
84                 .setInputGenerationLatencyMs(FIELD_UNSET)
85                 .setCompressedBuyerInputCreatorVersion(FIELD_UNSET)
86                 .setNumReEstimations(FIELD_UNSET);
87     }
88 
89     /** Builder class for GetAdSelectionDataApiCalledStats. */
90     @AutoValue.Builder
91     public abstract static class Builder {
92 
93         /** Sets the size of the payload in KB */
setPayloadSizeKb(int payloadSizeKb)94         public abstract Builder setPayloadSizeKb(int payloadSizeKb);
95 
96         /** Sets the number of buyers. */
setNumBuyers(int numBuyers)97         public abstract Builder setNumBuyers(int numBuyers);
98 
99         /** Sets the status code. */
setStatusCode(@dServicesStatusUtils.StatusCode int statusCode)100         public abstract Builder setStatusCode(@AdServicesStatusUtils.StatusCode int statusCode);
101 
102         /** Sets the coordinator source in this payload, i.e., DEFAULT or provided via API. */
setServerAuctionCoordinatorSource( @dsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource)103         public abstract Builder setServerAuctionCoordinatorSource(
104                 @AdsRelevanceStatusUtils.ServerAuctionCoordinatorSource int coordinatorSource);
105 
106         /** Sets the seller's maximum payload size in Kilobytes. */
setSellerMaxSizeKb(int sellerMaxSizeKb)107         public abstract Builder setSellerMaxSizeKb(int sellerMaxSizeKb);
108 
109         /** Sets the result of payload optimization. */
setPayloadOptimizationResult( PayloadOptimizationResult payloadOptimizationResult)110         public abstract Builder setPayloadOptimizationResult(
111                 PayloadOptimizationResult payloadOptimizationResult);
112 
113         /** Sets the latency of buyer input generation. */
setInputGenerationLatencyMs(int inputGenerationLatencyMs)114         public abstract Builder setInputGenerationLatencyMs(int inputGenerationLatencyMs);
115 
116         /** Sets the version of the compressed buyer input creator. */
setCompressedBuyerInputCreatorVersion( int compressedBuyerInputCreatorVersion)117         public abstract Builder setCompressedBuyerInputCreatorVersion(
118                 int compressedBuyerInputCreatorVersion);
119 
120         /**
121          * Sets the number of times the payload was re compressed to update the current size
122          * estimation.
123          */
setNumReEstimations(int numReEstimations)124         public abstract Builder setNumReEstimations(int numReEstimations);
125 
126         /** Builds the {@link GetAdSelectionDataApiCalledStats} object. */
build()127         public abstract GetAdSelectionDataApiCalledStats build();
128     }
129 }
130