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.ondevicepersonalization; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.content.ComponentName; 22 import android.net.Uri; 23 import android.os.Parcelable; 24 25 import com.android.ondevicepersonalization.internal.util.AnnotationValidations; 26 import com.android.ondevicepersonalization.internal.util.DataClass; 27 28 /** 29 * A class that contains Web Trigger Event data sent from the Measurement API to the 30 * OnDevicePersonalization service when the browser registers a web trigger 31 * with the <a href="https://developer.android.com/design-for-safety/privacy-sandbox/guides/attribution"> 32 * Measurement API</a> and the web trigger data is intended to be processed by an 33 * {@link IsolatedService}. 34 * @hide 35 */ 36 @DataClass(genAidl = false, genBuilder = false) 37 public final class MeasurementWebTriggerEventParamsParcel implements Parcelable { 38 /** 39 * The URL of the web page where the web trigger event occurred. 40 */ 41 @NonNull private Uri mDestinationUrl; 42 43 /** 44 * The package name of the browser app where the web trigger event occurred. 45 */ 46 @NonNull private String mAppPackageName; 47 48 /** 49 * The package and class name of the {@link IsolatedService} that should process 50 * the web trigger event. 51 */ 52 @NonNull private ComponentName mIsolatedService; 53 54 /** 55 * An optional SHA-256 hash of the signing key of the package that contains 56 * the {@link IsolatedService}, to guard against package name spoofing via sideloading. 57 * If this field is present and does not match the signing key of the installed receiver 58 * service package, the web trigger event is discarded. 59 */ 60 @Nullable private String mCertDigest = null; 61 62 /** 63 * Additional data that the server may provide to the {@link IsolatedService}. This can be 64 * {@code null} if the server does not need to provide any data other than the required fields. 65 */ 66 @Nullable private byte[] mEventData = null; 67 MeasurementWebTriggerEventParamsParcel( @onNull MeasurementWebTriggerEventParams params)68 public MeasurementWebTriggerEventParamsParcel( 69 @NonNull MeasurementWebTriggerEventParams params) { 70 this(params.getDestinationUrl(), params.getAppPackageName(), params.getIsolatedService(), 71 params.getCertDigest(), params.getEventData()); 72 } 73 74 75 76 // Code below generated by codegen v1.0.23. 77 // 78 // DO NOT MODIFY! 79 // CHECKSTYLE:OFF Generated code 80 // 81 // To regenerate run: 82 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/MeasurementWebTriggerEventParamsParcel.java 83 // 84 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 85 // Settings > Editor > Code Style > Formatter Control 86 //@formatter:off 87 88 89 /** 90 * Creates a new MeasurementWebTriggerEventParamsParcel. 91 * 92 * @param destinationUrl 93 * The URL of the web page where the web trigger event occurred. 94 * @param appPackageName 95 * The package name of the browser app where the web trigger event occurred. 96 * @param isolatedService 97 * The package and class name of the {@link IsolatedService} that should process 98 * the web trigger event. 99 * @param certDigest 100 * An optional SHA-256 hash of the signing key of the package that contains 101 * the {@link IsolatedService}, to guard against package name spoofing via sideloading. 102 * If this field is present and does not match the signing key of the installed receiver 103 * service package, the web trigger event is discarded. 104 * @param eventData 105 * Additional data that the server may provide to the {@link IsolatedService}. This can be 106 * {@code null} if the server does not need to provide any data other than the required fields. 107 */ 108 @DataClass.Generated.Member MeasurementWebTriggerEventParamsParcel( @onNull Uri destinationUrl, @NonNull String appPackageName, @NonNull ComponentName isolatedService, @Nullable String certDigest, @Nullable byte[] eventData)109 public MeasurementWebTriggerEventParamsParcel( 110 @NonNull Uri destinationUrl, 111 @NonNull String appPackageName, 112 @NonNull ComponentName isolatedService, 113 @Nullable String certDigest, 114 @Nullable byte[] eventData) { 115 this.mDestinationUrl = destinationUrl; 116 AnnotationValidations.validate( 117 NonNull.class, null, mDestinationUrl); 118 this.mAppPackageName = appPackageName; 119 AnnotationValidations.validate( 120 NonNull.class, null, mAppPackageName); 121 this.mIsolatedService = isolatedService; 122 AnnotationValidations.validate( 123 NonNull.class, null, mIsolatedService); 124 this.mCertDigest = certDigest; 125 this.mEventData = eventData; 126 127 // onConstructed(); // You can define this method to get a callback 128 } 129 130 /** 131 * The URL of the web page where the web trigger event occurred. 132 */ 133 @DataClass.Generated.Member getDestinationUrl()134 public @NonNull Uri getDestinationUrl() { 135 return mDestinationUrl; 136 } 137 138 /** 139 * The package name of the browser app where the web trigger event occurred. 140 */ 141 @DataClass.Generated.Member getAppPackageName()142 public @NonNull String getAppPackageName() { 143 return mAppPackageName; 144 } 145 146 /** 147 * The package and class name of the {@link IsolatedService} that should process 148 * the web trigger event. 149 */ 150 @DataClass.Generated.Member getIsolatedService()151 public @NonNull ComponentName getIsolatedService() { 152 return mIsolatedService; 153 } 154 155 /** 156 * An optional SHA-256 hash of the signing key of the package that contains 157 * the {@link IsolatedService}, to guard against package name spoofing via sideloading. 158 * If this field is present and does not match the signing key of the installed receiver 159 * service package, the web trigger event is discarded. 160 */ 161 @DataClass.Generated.Member getCertDigest()162 public @Nullable String getCertDigest() { 163 return mCertDigest; 164 } 165 166 /** 167 * Additional data that the server may provide to the {@link IsolatedService}. This can be 168 * {@code null} if the server does not need to provide any data other than the required fields. 169 */ 170 @DataClass.Generated.Member getEventData()171 public @Nullable byte[] getEventData() { 172 return mEventData; 173 } 174 175 @Override 176 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)177 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 178 // You can override field parcelling by defining methods like: 179 // void parcelFieldName(Parcel dest, int flags) { ... } 180 181 byte flg = 0; 182 if (mCertDigest != null) flg |= 0x8; 183 dest.writeByte(flg); 184 dest.writeTypedObject(mDestinationUrl, flags); 185 dest.writeString(mAppPackageName); 186 dest.writeTypedObject(mIsolatedService, flags); 187 if (mCertDigest != null) dest.writeString(mCertDigest); 188 dest.writeByteArray(mEventData); 189 } 190 191 @Override 192 @DataClass.Generated.Member describeContents()193 public int describeContents() { return 0; } 194 195 /** @hide */ 196 @SuppressWarnings({"unchecked", "RedundantCast"}) 197 @DataClass.Generated.Member MeasurementWebTriggerEventParamsParcel(@onNull android.os.Parcel in)198 /* package-private */ MeasurementWebTriggerEventParamsParcel(@NonNull android.os.Parcel in) { 199 // You can override field unparcelling by defining methods like: 200 // static FieldType unparcelFieldName(Parcel in) { ... } 201 202 byte flg = in.readByte(); 203 Uri destinationUrl = (Uri) in.readTypedObject(Uri.CREATOR); 204 String appPackageName = in.readString(); 205 ComponentName isolatedService = (ComponentName) in.readTypedObject(ComponentName.CREATOR); 206 String certDigest = (flg & 0x8) == 0 ? null : in.readString(); 207 byte[] eventData = in.createByteArray(); 208 209 this.mDestinationUrl = destinationUrl; 210 AnnotationValidations.validate( 211 NonNull.class, null, mDestinationUrl); 212 this.mAppPackageName = appPackageName; 213 AnnotationValidations.validate( 214 NonNull.class, null, mAppPackageName); 215 this.mIsolatedService = isolatedService; 216 AnnotationValidations.validate( 217 NonNull.class, null, mIsolatedService); 218 this.mCertDigest = certDigest; 219 this.mEventData = eventData; 220 221 // onConstructed(); // You can define this method to get a callback 222 } 223 224 @DataClass.Generated.Member 225 public static final @NonNull Parcelable.Creator<MeasurementWebTriggerEventParamsParcel> CREATOR 226 = new Parcelable.Creator<MeasurementWebTriggerEventParamsParcel>() { 227 @Override 228 public MeasurementWebTriggerEventParamsParcel[] newArray(int size) { 229 return new MeasurementWebTriggerEventParamsParcel[size]; 230 } 231 232 @Override 233 public MeasurementWebTriggerEventParamsParcel createFromParcel(@NonNull android.os.Parcel in) { 234 return new MeasurementWebTriggerEventParamsParcel(in); 235 } 236 }; 237 238 @DataClass.Generated( 239 time = 1707510209072L, 240 codegenVersion = "1.0.23", 241 sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/MeasurementWebTriggerEventParamsParcel.java", 242 inputSignatures = "private @android.annotation.NonNull android.net.Uri mDestinationUrl\nprivate @android.annotation.NonNull java.lang.String mAppPackageName\nprivate @android.annotation.NonNull android.content.ComponentName mIsolatedService\nprivate @android.annotation.Nullable java.lang.String mCertDigest\nprivate @android.annotation.Nullable byte[] mEventData\nclass MeasurementWebTriggerEventParamsParcel extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genAidl=false, genBuilder=false)") 243 @Deprecated __metadata()244 private void __metadata() {} 245 246 247 //@formatter:on 248 // End of generated code 249 250 } 251