1 /* 2 * Copyright (C) 2022 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.data.customaudience; 18 19 import android.adservices.common.AdTechIdentifier; 20 21 import androidx.annotation.NonNull; 22 import androidx.annotation.Nullable; 23 24 import com.google.auto.value.AutoValue; 25 26 /** This class represents the query result for custom audience stats. */ 27 @AutoValue 28 public abstract class CustomAudienceStats { 29 public static final long UNSET_COUNT = -1; 30 31 /** @return the queried owner app's package name, or {@code null} if not set */ 32 @Nullable getOwner()33 public abstract String getOwner(); 34 35 /** @return the queried buyer ad tech's {@link AdTechIdentifier}, or {@code null} if not set */ 36 @Nullable getBuyer()37 public abstract AdTechIdentifier getBuyer(); 38 39 /** 40 * @return the total number of custom audiences in the database, or {@link #UNSET_COUNT} if not 41 * set 42 */ getTotalCustomAudienceCount()43 public abstract long getTotalCustomAudienceCount(); 44 45 /** 46 * @return the number of custom audiences in the database owned by the queried owner app, or 47 * {@link #UNSET_COUNT} if not set 48 */ getPerOwnerCustomAudienceCount()49 public abstract long getPerOwnerCustomAudienceCount(); 50 51 /** 52 * @return the total number of distinct owner apps in the database, or {@link #UNSET_COUNT} if 53 * not set 54 */ getTotalOwnerCount()55 public abstract long getTotalOwnerCount(); 56 57 /** 58 * @return the number of custom audiences in the database associated with the queried buyer ad 59 * tech, or {@link #UNSET_COUNT} if not set 60 */ getPerBuyerCustomAudienceCount()61 public abstract long getPerBuyerCustomAudienceCount(); 62 63 /** 64 * @return the total number of distinct buyer ad techs in the database, or {@link #UNSET_COUNT} 65 * if not set 66 */ getTotalBuyerCount()67 public abstract long getTotalBuyerCount(); 68 69 /** @return a {@link Builder} for a {@link CustomAudienceStats} object */ 70 @NonNull builder()71 public static Builder builder() { 72 return new AutoValue_CustomAudienceStats.Builder() 73 .setTotalCustomAudienceCount(UNSET_COUNT) 74 .setPerOwnerCustomAudienceCount(UNSET_COUNT) 75 .setTotalOwnerCount(UNSET_COUNT) 76 .setPerBuyerCustomAudienceCount(UNSET_COUNT) 77 .setTotalBuyerCount(UNSET_COUNT); 78 } 79 80 /** Builder class for a {@link CustomAudienceStats} object. */ 81 @AutoValue.Builder 82 public abstract static class Builder { 83 /** 84 * Sets the owner app's package name which was queried on to create the {@link 85 * CustomAudienceStats} object. 86 */ 87 @NonNull setOwner(@ullable String value)88 public abstract Builder setOwner(@Nullable String value); 89 90 /** 91 * Sets the buyer ad tech's {@link AdTechIdentifier} which was queried to create the {@link 92 * CustomAudienceStats} object. 93 */ 94 @NonNull setBuyer(@ullable AdTechIdentifier value)95 public abstract Builder setBuyer(@Nullable AdTechIdentifier value); 96 97 /** Sets the total number of custom audiences in the database. */ 98 @NonNull setTotalCustomAudienceCount(long value)99 public abstract Builder setTotalCustomAudienceCount(long value); 100 101 /** Sets the number of custom audiences in the database owned by the queried owner. */ 102 @NonNull setPerOwnerCustomAudienceCount(long value)103 public abstract Builder setPerOwnerCustomAudienceCount(long value); 104 105 /** Sets the total number of distinct owner apps in the database. */ 106 @NonNull setTotalOwnerCount(long value)107 public abstract Builder setTotalOwnerCount(long value); 108 109 /** 110 * Sets the number of custom audiences in the database associated with the queried buyer ad 111 * tech. 112 */ 113 @NonNull setPerBuyerCustomAudienceCount(long value)114 public abstract Builder setPerBuyerCustomAudienceCount(long value); 115 116 /** Sets the total number of distinct buyer ad techs in the database. */ 117 @NonNull setTotalBuyerCount(long value)118 public abstract Builder setTotalBuyerCount(long value); 119 120 /** Builds the {@link CustomAudienceStats} object and returns it. */ 121 @NonNull build()122 public abstract CustomAudienceStats build(); 123 } 124 } 125