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.data.customaudience; 18 19 import android.adservices.common.AdData; 20 import android.adservices.common.AdFilters; 21 import android.adservices.common.FrequencyCapFilters; 22 23 import com.android.adservices.data.common.DBAdData; 24 25 import org.json.JSONException; 26 import org.json.JSONObject; 27 28 /** Strategy for doing optional feature-flagged parts of the frequency cap filters conversion */ 29 public interface FrequencyCapFiltersConversionStrategy { 30 /** 31 * Fills a part of the given {@link JSONObject} with the data from {@link 32 * DBAdData#getAdCounterKeys()}. 33 */ toJsonAdCounterKeys(DBAdData adData, JSONObject toReturn)34 void toJsonAdCounterKeys(DBAdData adData, JSONObject toReturn) throws JSONException; 35 36 /** 37 * Fills a part of the given {@link JSONObject} with the data from {@link 38 * AdFilters#getFrequencyCapFilters()}. 39 */ toJsonFilters(FrequencyCapFilters frequencyCapFilters, JSONObject toReturn)40 void toJsonFilters(FrequencyCapFilters frequencyCapFilters, JSONObject toReturn) 41 throws JSONException; 42 43 /** Deserialize {@link DBAdData#getAdCounterKeys()} from {@link JSONObject}. */ fromJsonAdCounterKeys(JSONObject json, DBAdData.Builder adDataBuilder)44 void fromJsonAdCounterKeys(JSONObject json, DBAdData.Builder adDataBuilder) 45 throws JSONException; 46 47 /** Deserialize {@link FrequencyCapFilters} from {@link JSONObject}. */ fromJsonFilters(JSONObject json, AdFilters.Builder builder)48 void fromJsonFilters(JSONObject json, AdFilters.Builder builder) throws JSONException; 49 50 /** 51 * Parse part of parcelable {@link AdData} to storage model {@link DBAdData} with the data from 52 * {@link AdData#getAdCounterKeys()} 53 */ fromServiceObjectAdCounterKeys(AdData parcelable, DBAdData.Builder adDataBuilder)54 void fromServiceObjectAdCounterKeys(AdData parcelable, DBAdData.Builder adDataBuilder); 55 56 /** 57 * Parse part of parcelable {@link AdData} to storage model {@link DBAdData} with the data from 58 * {@link AdFilters#getFrequencyCapFilters()} 59 */ fromServiceObjectFilters(AdData parcelable, AdFilters.Builder builder)60 void fromServiceObjectFilters(AdData parcelable, AdFilters.Builder builder); 61 } 62