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.FlaggedApi; 20 import android.annotation.NonNull; 21 import android.annotation.Nullable; 22 23 import com.android.adservices.ondevicepersonalization.flags.Flags; 24 import com.android.ondevicepersonalization.internal.util.AnnotationValidations; 25 import com.android.ondevicepersonalization.internal.util.DataClass; 26 27 import java.util.Collections; 28 import java.util.List; 29 30 /** 31 * The result returned by 32 * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)} in response to a call to 33 * {@code OnDevicePersonalizationManager#execute(ComponentName, PersistableBundle, 34 * java.util.concurrent.Executor, OutcomeReceiver)} 35 * from a client app. 36 */ 37 @FlaggedApi(Flags.FLAG_ON_DEVICE_PERSONALIZATION_APIS_ENABLED) 38 @DataClass(genBuilder = true, genEqualsHashCode = true) 39 public final class ExecuteOutput { 40 /** 41 * Persistent data to be written to the REQUESTS table after 42 * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)} 43 * completes. If null, no persistent data will be written. 44 */ 45 @DataClass.MaySetToNull 46 @Nullable private RequestLogRecord mRequestLogRecord = null; 47 48 /** 49 * A {@link RenderingConfig} object that contains information about the content to be rendered 50 * in the client app view. Can be null if no content is to be rendered. 51 */ 52 @DataClass.MaySetToNull 53 @Nullable private RenderingConfig mRenderingConfig = null; 54 55 /** 56 * A list of {@link EventLogRecord} objects to be written to the EVENTS table. Each 57 * {@link EventLogRecord} must be associated with an existing {@link RequestLogRecord} in 58 * the REQUESTS table, specified using 59 * {@link EventLogRecord.Builder#setRequestLogRecord(RequestLogRecord)}. 60 * If the {@link RequestLogRecord} is not specified, the {@link EventLogRecord} will not be 61 * written. 62 */ 63 @DataClass.PluralOf("eventLogRecord") 64 @NonNull private List<EventLogRecord> mEventLogRecords = Collections.emptyList(); 65 66 /** 67 * A byte array that an {@link IsolatedService} may optionally return to to a calling app, 68 * by setting this field to a non-null value. 69 * The contents of this array will be returned to the caller of 70 * {@link OnDevicePersonalizationManager#execute(ComponentName, PersistableBundle, java.util.concurrent.Executor, OutcomeReceiver)} 71 * if returning data from isolated processes is allowed by policy and the 72 * (calling app package, isolated service package) pair is present in an allowlist that 73 * permits data to be returned. 74 */ 75 @DataClass.MaySetToNull 76 @Nullable private byte[] mOutputData = null; 77 78 79 80 // Code below generated by codegen v1.0.23. 81 // 82 // DO NOT MODIFY! 83 // CHECKSTYLE:OFF Generated code 84 // 85 // To regenerate run: 86 // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/ExecuteOutput.java 87 // 88 // To exclude the generated code from IntelliJ auto-formatting enable (one-time): 89 // Settings > Editor > Code Style > Formatter Control 90 //@formatter:off 91 92 93 @DataClass.Generated.Member ExecuteOutput( @ullable RequestLogRecord requestLogRecord, @Nullable RenderingConfig renderingConfig, @NonNull List<EventLogRecord> eventLogRecords, @Nullable byte[] outputData)94 /* package-private */ ExecuteOutput( 95 @Nullable RequestLogRecord requestLogRecord, 96 @Nullable RenderingConfig renderingConfig, 97 @NonNull List<EventLogRecord> eventLogRecords, 98 @Nullable byte[] outputData) { 99 this.mRequestLogRecord = requestLogRecord; 100 this.mRenderingConfig = renderingConfig; 101 this.mEventLogRecords = eventLogRecords; 102 AnnotationValidations.validate( 103 NonNull.class, null, mEventLogRecords); 104 this.mOutputData = outputData; 105 106 // onConstructed(); // You can define this method to get a callback 107 } 108 109 /** 110 * Persistent data to be written to the REQUESTS table after 111 * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)} 112 * completes. If null, no persistent data will be written. 113 */ 114 @DataClass.Generated.Member getRequestLogRecord()115 public @Nullable RequestLogRecord getRequestLogRecord() { 116 return mRequestLogRecord; 117 } 118 119 /** 120 * A {@link RenderingConfig} object that contains information about the content to be rendered 121 * in the client app view. Can be null if no content is to be rendered. 122 */ 123 @DataClass.Generated.Member getRenderingConfig()124 public @Nullable RenderingConfig getRenderingConfig() { 125 return mRenderingConfig; 126 } 127 128 /** 129 * A list of {@link EventLogRecord} objects to be written to the EVENTS table. Each 130 * {@link EventLogRecord} must be associated with an existing {@link RequestLogRecord} in 131 * the REQUESTS table, specified using 132 * {@link EventLogRecord.Builder#setRequestLogRecord(RequestLogRecord)}. 133 * If the {@link RequestLogRecord} is not specified, the {@link EventLogRecord} will not be 134 * written. 135 */ 136 @DataClass.Generated.Member getEventLogRecords()137 public @NonNull List<EventLogRecord> getEventLogRecords() { 138 return mEventLogRecords; 139 } 140 141 /** 142 * A byte array that an {@link IsolatedService} may optionally return to to a calling app, 143 * by setting this field to a non-null value. 144 * The contents of this array will be returned to the caller of 145 * {@link OnDevicePersonalizationManager#execute(ComponentName, PersistableBundle, java.util.concurrent.Executor, OutcomeReceiver)} 146 * if returning data from isolated processes is allowed by policy and the 147 * (calling app package, isolated service package) pair is present in an allowlist that 148 * permits data to be returned. 149 */ 150 @DataClass.Generated.Member getOutputData()151 public @Nullable byte[] getOutputData() { 152 return mOutputData; 153 } 154 155 @Override 156 @DataClass.Generated.Member equals(@ullable Object o)157 public boolean equals(@Nullable Object o) { 158 // You can override field equality logic by defining either of the methods like: 159 // boolean fieldNameEquals(ExecuteOutput other) { ... } 160 // boolean fieldNameEquals(FieldType otherValue) { ... } 161 162 if (this == o) return true; 163 if (o == null || getClass() != o.getClass()) return false; 164 @SuppressWarnings("unchecked") 165 ExecuteOutput that = (ExecuteOutput) o; 166 //noinspection PointlessBooleanExpression 167 return true 168 && java.util.Objects.equals(mRequestLogRecord, that.mRequestLogRecord) 169 && java.util.Objects.equals(mRenderingConfig, that.mRenderingConfig) 170 && java.util.Objects.equals(mEventLogRecords, that.mEventLogRecords) 171 && java.util.Arrays.equals(mOutputData, that.mOutputData); 172 } 173 174 @Override 175 @DataClass.Generated.Member hashCode()176 public int hashCode() { 177 // You can override field hashCode logic by defining methods like: 178 // int fieldNameHashCode() { ... } 179 180 int _hash = 1; 181 _hash = 31 * _hash + java.util.Objects.hashCode(mRequestLogRecord); 182 _hash = 31 * _hash + java.util.Objects.hashCode(mRenderingConfig); 183 _hash = 31 * _hash + java.util.Objects.hashCode(mEventLogRecords); 184 _hash = 31 * _hash + java.util.Arrays.hashCode(mOutputData); 185 return _hash; 186 } 187 188 /** 189 * A builder for {@link ExecuteOutput} 190 */ 191 @SuppressWarnings("WeakerAccess") 192 @DataClass.Generated.Member 193 public static final class Builder { 194 195 private @Nullable RequestLogRecord mRequestLogRecord; 196 private @Nullable RenderingConfig mRenderingConfig; 197 private @NonNull List<EventLogRecord> mEventLogRecords; 198 private @Nullable byte[] mOutputData; 199 200 private long mBuilderFieldsSet = 0L; 201 Builder()202 public Builder() { 203 } 204 205 /** 206 * Persistent data to be written to the REQUESTS table after 207 * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)} 208 * completes. If null, no persistent data will be written. 209 */ 210 @DataClass.Generated.Member setRequestLogRecord(@ullable RequestLogRecord value)211 public @NonNull Builder setRequestLogRecord(@Nullable RequestLogRecord value) { 212 checkNotUsed(); 213 mBuilderFieldsSet |= 0x1; 214 mRequestLogRecord = value; 215 return this; 216 } 217 218 /** 219 * A {@link RenderingConfig} object that contains information about the content to be rendered 220 * in the client app view. Can be null if no content is to be rendered. 221 */ 222 @DataClass.Generated.Member setRenderingConfig(@ullable RenderingConfig value)223 public @NonNull Builder setRenderingConfig(@Nullable RenderingConfig value) { 224 checkNotUsed(); 225 mBuilderFieldsSet |= 0x2; 226 mRenderingConfig = value; 227 return this; 228 } 229 230 /** 231 * A list of {@link EventLogRecord} objects to be written to the EVENTS table. Each 232 * {@link EventLogRecord} must be associated with an existing {@link RequestLogRecord} in 233 * the REQUESTS table, specified using 234 * {@link EventLogRecord.Builder#setRequestLogRecord(RequestLogRecord)}. 235 * If the {@link RequestLogRecord} is not specified, the {@link EventLogRecord} will not be 236 * written. 237 */ 238 @DataClass.Generated.Member setEventLogRecords(@onNull List<EventLogRecord> value)239 public @NonNull Builder setEventLogRecords(@NonNull List<EventLogRecord> value) { 240 checkNotUsed(); 241 mBuilderFieldsSet |= 0x4; 242 mEventLogRecords = value; 243 return this; 244 } 245 246 /** @see #setEventLogRecords */ 247 @DataClass.Generated.Member addEventLogRecord(@onNull EventLogRecord value)248 public @NonNull Builder addEventLogRecord(@NonNull EventLogRecord value) { 249 if (mEventLogRecords == null) setEventLogRecords(new java.util.ArrayList<>()); 250 mEventLogRecords.add(value); 251 return this; 252 } 253 254 /** 255 * A byte array that an {@link IsolatedService} may optionally return to to a calling app, 256 * by setting this field to a non-null value. 257 * The contents of this array will be returned to the caller of 258 * {@link OnDevicePersonalizationManager#execute(ComponentName, PersistableBundle, java.util.concurrent.Executor, OutcomeReceiver)} 259 * if returning data from isolated processes is allowed by policy and the 260 * (calling app package, isolated service package) pair is present in an allowlist that 261 * permits data to be returned. 262 */ 263 @DataClass.Generated.Member setOutputData(@ullable byte... value)264 public @NonNull Builder setOutputData(@Nullable byte... value) { 265 checkNotUsed(); 266 mBuilderFieldsSet |= 0x8; 267 mOutputData = value; 268 return this; 269 } 270 271 /** Builds the instance. This builder should not be touched after calling this! */ build()272 public @NonNull ExecuteOutput build() { 273 checkNotUsed(); 274 mBuilderFieldsSet |= 0x10; // Mark builder used 275 276 if ((mBuilderFieldsSet & 0x1) == 0) { 277 mRequestLogRecord = null; 278 } 279 if ((mBuilderFieldsSet & 0x2) == 0) { 280 mRenderingConfig = null; 281 } 282 if ((mBuilderFieldsSet & 0x4) == 0) { 283 mEventLogRecords = Collections.emptyList(); 284 } 285 if ((mBuilderFieldsSet & 0x8) == 0) { 286 mOutputData = null; 287 } 288 ExecuteOutput o = new ExecuteOutput( 289 mRequestLogRecord, 290 mRenderingConfig, 291 mEventLogRecords, 292 mOutputData); 293 return o; 294 } 295 checkNotUsed()296 private void checkNotUsed() { 297 if ((mBuilderFieldsSet & 0x10) != 0) { 298 throw new IllegalStateException( 299 "This Builder should not be reused. Use a new Builder instance instead"); 300 } 301 } 302 } 303 304 @DataClass.Generated( 305 time = 1707251143585L, 306 codegenVersion = "1.0.23", 307 sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/ExecuteOutput.java", 308 inputSignatures = "private @com.android.ondevicepersonalization.internal.util.DataClass.MaySetToNull @android.annotation.Nullable android.adservices.ondevicepersonalization.RequestLogRecord mRequestLogRecord\nprivate @com.android.ondevicepersonalization.internal.util.DataClass.MaySetToNull @android.annotation.Nullable android.adservices.ondevicepersonalization.RenderingConfig mRenderingConfig\nprivate @com.android.ondevicepersonalization.internal.util.DataClass.PluralOf(\"eventLogRecord\") @android.annotation.NonNull java.util.List<android.adservices.ondevicepersonalization.EventLogRecord> mEventLogRecords\nprivate @com.android.ondevicepersonalization.internal.util.DataClass.MaySetToNull @android.annotation.Nullable byte[] mOutputData\nclass ExecuteOutput extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 309 @Deprecated __metadata()310 private void __metadata() {} 311 312 313 //@formatter:on 314 // End of generated code 315 316 } 317