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.ondevicepersonalization;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcelable;
22 import android.os.PersistableBundle;
23 
24 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
25 import com.android.ondevicepersonalization.internal.util.DataClass;
26 
27 /**
28  * Parcelable version of {@link EventInput}.
29  * @hide
30  */
31 @DataClass(genAidl = false, genHiddenBuilder = true)
32 public final class EventInputParcel implements Parcelable {
33     /**
34      * The {@link RequestLogRecord} that was returned as a result of
35      * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)}.
36      */
37     @Nullable private RequestLogRecord mRequestLogRecord = null;
38 
39     /**
40      * The Event URL parameters that the service passed to {@link
41      * EventUrlProvider#createEventTrackingUrlWithResponse(PersistableBundle, byte[], String)}
42      * or {@link EventUrlProvider#createEventTrackingUrlWithRedirect(PersistableBundle, Uri)}.
43      */
44     @NonNull private PersistableBundle mParameters = PersistableBundle.EMPTY;
45 
46 
47 
48     // Code below generated by codegen v1.0.23.
49     //
50     // DO NOT MODIFY!
51     // CHECKSTYLE:OFF Generated code
52     //
53     // To regenerate run:
54     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/EventInputParcel.java
55     //
56     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
57     //   Settings > Editor > Code Style > Formatter Control
58     //@formatter:off
59 
60 
61     @DataClass.Generated.Member
EventInputParcel( @ullable RequestLogRecord requestLogRecord, @NonNull PersistableBundle parameters)62     /* package-private */ EventInputParcel(
63             @Nullable RequestLogRecord requestLogRecord,
64             @NonNull PersistableBundle parameters) {
65         this.mRequestLogRecord = requestLogRecord;
66         this.mParameters = parameters;
67         AnnotationValidations.validate(
68                 NonNull.class, null, mParameters);
69 
70         // onConstructed(); // You can define this method to get a callback
71     }
72 
73     /**
74      * The {@link RequestLogRecord} that was returned as a result of
75      * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)}.
76      */
77     @DataClass.Generated.Member
getRequestLogRecord()78     public @Nullable RequestLogRecord getRequestLogRecord() {
79         return mRequestLogRecord;
80     }
81 
82     /**
83      * The Event URL parameters that the service passed to {@link
84      * EventUrlProvider#createEventTrackingUrlWithResponse(PersistableBundle, byte[], String)}
85      * or {@link EventUrlProvider#createEventTrackingUrlWithRedirect(PersistableBundle, Uri)}.
86      */
87     @DataClass.Generated.Member
getParameters()88     public @NonNull PersistableBundle getParameters() {
89         return mParameters;
90     }
91 
92     @Override
93     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)94     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
95         // You can override field parcelling by defining methods like:
96         // void parcelFieldName(Parcel dest, int flags) { ... }
97 
98         byte flg = 0;
99         if (mRequestLogRecord != null) flg |= 0x1;
100         dest.writeByte(flg);
101         if (mRequestLogRecord != null) dest.writeTypedObject(mRequestLogRecord, flags);
102         dest.writeTypedObject(mParameters, flags);
103     }
104 
105     @Override
106     @DataClass.Generated.Member
describeContents()107     public int describeContents() { return 0; }
108 
109     /** @hide */
110     @SuppressWarnings({"unchecked", "RedundantCast"})
111     @DataClass.Generated.Member
EventInputParcel(@onNull android.os.Parcel in)112     /* package-private */ EventInputParcel(@NonNull android.os.Parcel in) {
113         // You can override field unparcelling by defining methods like:
114         // static FieldType unparcelFieldName(Parcel in) { ... }
115 
116         byte flg = in.readByte();
117         RequestLogRecord requestLogRecord = (flg & 0x1) == 0 ? null : (RequestLogRecord) in.readTypedObject(RequestLogRecord.CREATOR);
118         PersistableBundle parameters = (PersistableBundle) in.readTypedObject(PersistableBundle.CREATOR);
119 
120         this.mRequestLogRecord = requestLogRecord;
121         this.mParameters = parameters;
122         AnnotationValidations.validate(
123                 NonNull.class, null, mParameters);
124 
125         // onConstructed(); // You can define this method to get a callback
126     }
127 
128     @DataClass.Generated.Member
129     public static final @NonNull Parcelable.Creator<EventInputParcel> CREATOR
130             = new Parcelable.Creator<EventInputParcel>() {
131         @Override
132         public EventInputParcel[] newArray(int size) {
133             return new EventInputParcel[size];
134         }
135 
136         @Override
137         public EventInputParcel createFromParcel(@NonNull android.os.Parcel in) {
138             return new EventInputParcel(in);
139         }
140     };
141 
142     /**
143      * A builder for {@link EventInputParcel}
144      * @hide
145      */
146     @SuppressWarnings("WeakerAccess")
147     @DataClass.Generated.Member
148     public static final class Builder {
149 
150         private @Nullable RequestLogRecord mRequestLogRecord;
151         private @NonNull PersistableBundle mParameters;
152 
153         private long mBuilderFieldsSet = 0L;
154 
Builder()155         public Builder() {
156         }
157 
158         /**
159          * The {@link RequestLogRecord} that was returned as a result of
160          * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)}.
161          */
162         @DataClass.Generated.Member
setRequestLogRecord(@onNull RequestLogRecord value)163         public @NonNull Builder setRequestLogRecord(@NonNull RequestLogRecord value) {
164             checkNotUsed();
165             mBuilderFieldsSet |= 0x1;
166             mRequestLogRecord = value;
167             return this;
168         }
169 
170         /**
171          * The Event URL parameters that the service passed to {@link
172          * EventUrlProvider#createEventTrackingUrlWithResponse(PersistableBundle, byte[], String)}
173          * or {@link EventUrlProvider#createEventTrackingUrlWithRedirect(PersistableBundle, Uri)}.
174          */
175         @DataClass.Generated.Member
setParameters(@onNull PersistableBundle value)176         public @NonNull Builder setParameters(@NonNull PersistableBundle value) {
177             checkNotUsed();
178             mBuilderFieldsSet |= 0x2;
179             mParameters = value;
180             return this;
181         }
182 
183         /** Builds the instance. This builder should not be touched after calling this! */
build()184         public @NonNull EventInputParcel build() {
185             checkNotUsed();
186             mBuilderFieldsSet |= 0x4; // Mark builder used
187 
188             if ((mBuilderFieldsSet & 0x1) == 0) {
189                 mRequestLogRecord = null;
190             }
191             if ((mBuilderFieldsSet & 0x2) == 0) {
192                 mParameters = PersistableBundle.EMPTY;
193             }
194             EventInputParcel o = new EventInputParcel(
195                     mRequestLogRecord,
196                     mParameters);
197             return o;
198         }
199 
checkNotUsed()200         private void checkNotUsed() {
201             if ((mBuilderFieldsSet & 0x4) != 0) {
202                 throw new IllegalStateException(
203                         "This Builder should not be reused. Use a new Builder instance instead");
204             }
205         }
206     }
207 
208     @DataClass.Generated(
209             time = 1698875208124L,
210             codegenVersion = "1.0.23",
211             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/EventInputParcel.java",
212             inputSignatures = "private @android.annotation.Nullable android.adservices.ondevicepersonalization.RequestLogRecord mRequestLogRecord\nprivate @android.annotation.NonNull android.os.PersistableBundle mParameters\nclass EventInputParcel extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genAidl=false, genHiddenBuilder=true)")
213     @Deprecated
__metadata()214     private void __metadata() {}
215 
216 
217     //@formatter:on
218     // End of generated code
219 
220 }
221