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.FlaggedApi;
20 import android.annotation.NonNull;
21 import android.annotation.Nullable;
22 import android.os.PersistableBundle;
23 
24 import com.android.adservices.ondevicepersonalization.flags.Flags;
25 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
26 import com.android.ondevicepersonalization.internal.util.DataClass;
27 
28 /**
29  * The input data for {@link
30  * IsolatedWorker#onEvent(EventInput, android.os.OutcomeReceiver)}.
31  */
32 @FlaggedApi(Flags.FLAG_ON_DEVICE_PERSONALIZATION_APIS_ENABLED)
33 @DataClass(genBuilder = false, genHiddenConstructor = true, genEqualsHashCode = true)
34 public final class EventInput {
35     /**
36      * The {@link RequestLogRecord} that was returned as a result of
37      * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)}.
38      */
39     @Nullable private RequestLogRecord mRequestLogRecord = null;
40 
41     /**
42      * The Event URL parameters that the service passed to {@link
43      * EventUrlProvider#createEventTrackingUrlWithResponse(PersistableBundle, byte[], String)}
44      * or {@link EventUrlProvider#createEventTrackingUrlWithRedirect(PersistableBundle, Uri)}.
45      */
46     @NonNull private PersistableBundle mParameters = PersistableBundle.EMPTY;
47 
48     /** @hide */
EventInput(@onNull EventInputParcel parcel)49     public EventInput(@NonNull EventInputParcel parcel) {
50         this(parcel.getRequestLogRecord(), parcel.getParameters());
51     }
52 
53 
54 
55     // Code below generated by codegen v1.0.23.
56     //
57     // DO NOT MODIFY!
58     // CHECKSTYLE:OFF Generated code
59     //
60     // To regenerate run:
61     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/EventInput.java
62     //
63     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
64     //   Settings > Editor > Code Style > Formatter Control
65     //@formatter:off
66 
67 
68     /**
69      * Creates a new EventInput.
70      *
71      * @param requestLogRecord
72      *   The {@link RequestLogRecord} that was returned as a result of
73      *   {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)}.
74      * @param parameters
75      *   The Event URL parameters that the service passed to {@link
76      *   EventUrlProvider#createEventTrackingUrlWithResponse(PersistableBundle, byte[], String)}
77      *   or {@link EventUrlProvider#createEventTrackingUrlWithRedirect(PersistableBundle, Uri)}.
78      * @hide
79      */
80     @DataClass.Generated.Member
EventInput( @ullable RequestLogRecord requestLogRecord, @NonNull PersistableBundle parameters)81     public EventInput(
82             @Nullable RequestLogRecord requestLogRecord,
83             @NonNull PersistableBundle parameters) {
84         this.mRequestLogRecord = requestLogRecord;
85         this.mParameters = parameters;
86         AnnotationValidations.validate(
87                 NonNull.class, null, mParameters);
88 
89         // onConstructed(); // You can define this method to get a callback
90     }
91 
92     /**
93      * The {@link RequestLogRecord} that was returned as a result of
94      * {@link IsolatedWorker#onExecute(ExecuteInput, android.os.OutcomeReceiver)}.
95      */
96     @DataClass.Generated.Member
getRequestLogRecord()97     public @Nullable RequestLogRecord getRequestLogRecord() {
98         return mRequestLogRecord;
99     }
100 
101     /**
102      * The Event URL parameters that the service passed to {@link
103      * EventUrlProvider#createEventTrackingUrlWithResponse(PersistableBundle, byte[], String)}
104      * or {@link EventUrlProvider#createEventTrackingUrlWithRedirect(PersistableBundle, Uri)}.
105      */
106     @DataClass.Generated.Member
getParameters()107     public @NonNull PersistableBundle getParameters() {
108         return mParameters;
109     }
110 
111     @Override
112     @DataClass.Generated.Member
equals(@ullable Object o)113     public boolean equals(@Nullable Object o) {
114         // You can override field equality logic by defining either of the methods like:
115         // boolean fieldNameEquals(EventInput other) { ... }
116         // boolean fieldNameEquals(FieldType otherValue) { ... }
117 
118         if (this == o) return true;
119         if (o == null || getClass() != o.getClass()) return false;
120         @SuppressWarnings("unchecked")
121         EventInput that = (EventInput) o;
122         //noinspection PointlessBooleanExpression
123         return true
124                 && java.util.Objects.equals(mRequestLogRecord, that.mRequestLogRecord)
125                 && java.util.Objects.equals(mParameters, that.mParameters);
126     }
127 
128     @Override
129     @DataClass.Generated.Member
hashCode()130     public int hashCode() {
131         // You can override field hashCode logic by defining methods like:
132         // int fieldNameHashCode() { ... }
133 
134         int _hash = 1;
135         _hash = 31 * _hash + java.util.Objects.hashCode(mRequestLogRecord);
136         _hash = 31 * _hash + java.util.Objects.hashCode(mParameters);
137         return _hash;
138     }
139 
140     @DataClass.Generated(
141             time = 1698882321696L,
142             codegenVersion = "1.0.23",
143             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/adservices/ondevicepersonalization/EventInput.java",
144             inputSignatures = "private @android.annotation.Nullable android.adservices.ondevicepersonalization.RequestLogRecord mRequestLogRecord\nprivate @android.annotation.NonNull android.os.PersistableBundle mParameters\nclass EventInput extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=false, genHiddenConstructor=true, genEqualsHashCode=true)")
145     @Deprecated
__metadata()146     private void __metadata() {}
147 
148 
149     //@formatter:on
150     // End of generated code
151 
152 }
153