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 android.adservices.adselection; 18 19 import android.adservices.common.AdSelectionSignals; 20 import android.annotation.NonNull; 21 22 import java.util.Objects; 23 24 /** 25 * This POJO represents the {@link 26 * TestAdSelectionManager#overrideAdSelectionFromOutcomesConfigRemoteInfo} ( 27 * AddAdSelectionOverrideRequest, Executor, OutcomeReceiver)} request 28 * 29 * <p>It contains, a {@link AdSelectionFromOutcomesConfig} which will serve as the identifier for 30 * the specific override, a {@code String} selectionLogicJs and {@code String} selectionSignals 31 * field representing the override value 32 * 33 */ 34 public class AddAdSelectionFromOutcomesOverrideRequest { 35 @NonNull private final AdSelectionFromOutcomesConfig mAdSelectionFromOutcomesConfig; 36 37 @NonNull private final String mOutcomeSelectionLogicJs; 38 39 @NonNull private final AdSelectionSignals mOutcomeSelectionTrustedSignals; 40 41 /** Builds a {@link AddAdSelectionFromOutcomesOverrideRequest} instance. */ AddAdSelectionFromOutcomesOverrideRequest( @onNull AdSelectionFromOutcomesConfig adSelectionFromOutcomesConfig, @NonNull String outcomeSelectionLogicJs, @NonNull AdSelectionSignals outcomeSelectionTrustedSignals)42 public AddAdSelectionFromOutcomesOverrideRequest( 43 @NonNull AdSelectionFromOutcomesConfig adSelectionFromOutcomesConfig, 44 @NonNull String outcomeSelectionLogicJs, 45 @NonNull AdSelectionSignals outcomeSelectionTrustedSignals) { 46 Objects.requireNonNull(adSelectionFromOutcomesConfig); 47 Objects.requireNonNull(outcomeSelectionLogicJs); 48 Objects.requireNonNull(outcomeSelectionTrustedSignals); 49 50 mAdSelectionFromOutcomesConfig = adSelectionFromOutcomesConfig; 51 mOutcomeSelectionLogicJs = outcomeSelectionLogicJs; 52 mOutcomeSelectionTrustedSignals = outcomeSelectionTrustedSignals; 53 } 54 55 /** 56 * @return an instance of {@link AdSelectionFromOutcomesConfig}, the configuration of the ad 57 * selection process. This configuration provides the data necessary to run Ad Selection 58 * flow that generates bids and scores to find a wining ad for rendering. 59 */ 60 @NonNull getAdSelectionFromOutcomesConfig()61 public AdSelectionFromOutcomesConfig getAdSelectionFromOutcomesConfig() { 62 return mAdSelectionFromOutcomesConfig; 63 } 64 65 /** 66 * @return The override javascript result, should be a string that contains valid JS code. The 67 * code should contain the outcome selection logic that will be executed during ad outcome 68 * selection. 69 */ 70 @NonNull getOutcomeSelectionLogicJs()71 public String getOutcomeSelectionLogicJs() { 72 return mOutcomeSelectionLogicJs; 73 } 74 75 /** 76 * @return The override trusted scoring signals, should be a valid json string. The trusted 77 * signals would be fed into the outcome selection logic during ad outcome selection. 78 */ 79 @NonNull getOutcomeSelectionTrustedSignals()80 public AdSelectionSignals getOutcomeSelectionTrustedSignals() { 81 return mOutcomeSelectionTrustedSignals; 82 } 83 } 84