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 android.adservices.adselection; 18 19 import static com.android.adservices.flags.Flags.FLAG_FLEDGE_GET_AD_SELECTION_DATA_SELLER_CONFIGURATION_ENABLED; 20 21 import android.adservices.common.AdTechIdentifier; 22 import android.annotation.FlaggedApi; 23 import android.annotation.NonNull; 24 import android.annotation.Nullable; 25 import android.net.Uri; 26 27 import com.android.adservices.flags.Flags; 28 29 /** 30 * Represents a request containing the information to get ad selection data. 31 * 32 * <p>Instances of this class are created by SDKs to be provided as arguments to the {@link 33 * AdSelectionManager#getAdSelectionData} methods in {@link AdSelectionManager}. 34 */ 35 public final class GetAdSelectionDataRequest { 36 @Nullable private final AdTechIdentifier mSeller; 37 38 @Nullable private final Uri mCoordinatorOriginUri; 39 40 @Nullable private final SellerConfiguration mSellerConfiguration; 41 GetAdSelectionDataRequest( @ullable AdTechIdentifier seller, @Nullable Uri coordinatorOriginUri, @Nullable SellerConfiguration sellerConfiguration)42 private GetAdSelectionDataRequest( 43 @Nullable AdTechIdentifier seller, 44 @Nullable Uri coordinatorOriginUri, 45 @Nullable SellerConfiguration sellerConfiguration) { 46 this.mSeller = seller; 47 this.mCoordinatorOriginUri = coordinatorOriginUri; 48 this.mSellerConfiguration = sellerConfiguration; 49 } 50 51 /** 52 * @return a AdTechIdentifier of the seller, for example "www.example-ssp.com" 53 */ 54 @Nullable getSeller()55 public AdTechIdentifier getSeller() { 56 return mSeller; 57 } 58 59 /** 60 * @return the coordinator origin Uri where the public keys for encryption are fetched from 61 * <p>See {@link Builder#setCoordinatorOriginUri(Uri)} for more details on the coordinator 62 * origin 63 */ 64 @Nullable 65 @FlaggedApi(Flags.FLAG_FLEDGE_SERVER_AUCTION_MULTI_CLOUD_ENABLED) getCoordinatorOriginUri()66 public Uri getCoordinatorOriginUri() { 67 return mCoordinatorOriginUri; 68 } 69 70 /** 71 * Returns the seller ad tech's requested payload configuration, set by the calling SDK, to 72 * optimize the payload. 73 * 74 * <p>If this is {@code null}, the service will send all data available. 75 */ 76 @FlaggedApi(FLAG_FLEDGE_GET_AD_SELECTION_DATA_SELLER_CONFIGURATION_ENABLED) 77 @Nullable getSellerConfiguration()78 public SellerConfiguration getSellerConfiguration() { 79 return mSellerConfiguration; 80 } 81 82 /** 83 * Builder for {@link GetAdSelectionDataRequest} objects. 84 */ 85 public static final class Builder { 86 @Nullable private AdTechIdentifier mSeller; 87 88 @Nullable private Uri mCoordinatorOriginUri; 89 90 @Nullable private SellerConfiguration mSellerConfiguration; 91 Builder()92 public Builder() {} 93 94 /** Sets the seller {@link AdTechIdentifier}. */ 95 @NonNull setSeller(@ullable AdTechIdentifier seller)96 public GetAdSelectionDataRequest.Builder setSeller(@Nullable AdTechIdentifier seller) { 97 this.mSeller = seller; 98 return this; 99 } 100 101 /** 102 * Sets the coordinator origin from which PPAPI should fetch the public key for payload 103 * encryption. The origin must use HTTPS URI. 104 * 105 * <p>The origin will only contain the scheme, hostname and port of the URL. If the origin 106 * is not provided or is null, PPAPI will use the default coordinator URI. 107 * 108 * <p>The origin must belong to a list of pre-approved coordinator origins. Otherwise, 109 * {@link AdSelectionManager#getAdSelectionData} will throw an IllegalArgumentException 110 */ 111 @NonNull 112 @FlaggedApi(Flags.FLAG_FLEDGE_SERVER_AUCTION_MULTI_CLOUD_ENABLED) setCoordinatorOriginUri( @ullable Uri coordinatorOriginUri)113 public GetAdSelectionDataRequest.Builder setCoordinatorOriginUri( 114 @Nullable Uri coordinatorOriginUri) { 115 this.mCoordinatorOriginUri = coordinatorOriginUri; 116 return this; 117 } 118 119 /** 120 * Builds a {@link GetAdSelectionDataRequest} instance. 121 */ 122 @NonNull build()123 public GetAdSelectionDataRequest build() { 124 return new GetAdSelectionDataRequest( 125 mSeller, mCoordinatorOriginUri, mSellerConfiguration); 126 } 127 128 /** 129 * Sets the {@link SellerConfiguration}. See {@link #getSellerConfiguration()} for more 130 * details. 131 */ 132 @FlaggedApi(FLAG_FLEDGE_GET_AD_SELECTION_DATA_SELLER_CONFIGURATION_ENABLED) 133 @NonNull setSellerConfiguration( @ullable SellerConfiguration sellerConfiguration)134 public GetAdSelectionDataRequest.Builder setSellerConfiguration( 135 @Nullable SellerConfiguration sellerConfiguration) { 136 this.mSellerConfiguration = sellerConfiguration; 137 return this; 138 } 139 } 140 } 141