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.data.adselection; 18 19 import android.adservices.common.AdTechIdentifier; 20 21 import androidx.annotation.NonNull; 22 import androidx.annotation.Nullable; 23 import androidx.room.ColumnInfo; 24 25 import com.android.adservices.data.common.FledgeRoomConverters; 26 import com.android.adservices.service.adselection.HistogramEvent; 27 28 import com.google.auto.value.AutoValue; 29 30 import java.util.Set; 31 32 /** 33 * A DB value class representing all the data used to generate a {@link HistogramEvent} that is 34 * associated with a single {@link com.android.adservices.data.adselection.DBAdSelection}. 35 */ 36 @AutoValue 37 public abstract class DBAdSelectionHistogramInfo { 38 /** Creates and returns a new {@link DBAdSelectionHistogramInfo} object. */ create( @onNull AdTechIdentifier buyer, @Nullable String serializedAdCounterKeys)39 public static DBAdSelectionHistogramInfo create( 40 @NonNull AdTechIdentifier buyer, @Nullable String serializedAdCounterKeys) { 41 return new AutoValue_DBAdSelectionHistogramInfo(buyer, serializedAdCounterKeys); 42 } 43 44 /** Returns the winning ad's buyer adtech's {@link AdTechIdentifier}. */ 45 @AutoValue.CopyAnnotations 46 @ColumnInfo(name = "custom_audience_signals_buyer") 47 @NonNull getBuyer()48 public abstract AdTechIdentifier getBuyer(); 49 50 /** 51 * Returns the arbitrary keys, serialized as a JSON array, representing groupings that a buyer 52 * adtech has assigned to the winning ad. 53 */ 54 @AutoValue.CopyAnnotations 55 @ColumnInfo(name = "ad_counter_int_keys") 56 @Nullable getSerializedAdCounterKeys()57 protected abstract String getSerializedAdCounterKeys(); 58 59 /** 60 * Returns the {@link Set} of arbitrary keys representing groupings that a buyer adtech has 61 * assigned to the winning ad. 62 */ 63 @Nullable getAdCounterKeys()64 public final Set<Integer> getAdCounterKeys() { 65 return FledgeRoomConverters.deserializeIntegerSet(getSerializedAdCounterKeys()); 66 } 67 } 68