1 /*
2  * Copyright (C) 2024 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 com.android.federatedcompute.services.statsd;
18 
19 import android.annotation.NonNull;
20 
21 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
22 import com.android.ondevicepersonalization.internal.util.DataClass;
23 
24 /**
25  * Class holds FederatedComputeTrainingEventReported defined at
26  * frameworks/proto_logging/stats/atoms/federatedcompute/federatedcompute_extension_atoms.proto
27  */
28 @DataClass(genBuilder = true, genEqualsHashCode = true)
29 public class TrainingEventReported {
30     private long mClientVersion;
31     private int mEventKind;
32     private long mPopulationId;
33     private long mTaskId;
34     private long mDurationInMillis;
35 
36     private long mExampleCount = 0;
37     private long mExampleSize = 0;
38     private long mDataTransferDurationMillis = 0;
39     private long mBytesUploaded = 0;
40     private long mBytesDownloaded = 0;
41 
42     private long mKeyAttestationLatencyMillis = 0;
43     private long mExampleStoreBindLatencyNanos = 0;
44     private long mExampleStoreStartQueryLatencyNanos = 0;
45     @NonNull
46     private String mSdkPackageName = "";
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
55     // $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/federatedcompute/src/com/android/federatedcompute/services/statsd/TrainingEventReported.java
56     //
57     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
58     //   Settings > Editor > Code Style > Formatter Control
59     // @formatter:off
60 
61     @DataClass.Generated.Member
TrainingEventReported( long clientVersion, int eventKind, long populationId, long taskId, long durationInMillis, long exampleCount, long exampleSize, long dataTransferDurationMillis, long bytesUploaded, long bytesDownloaded, long keyAttestationLatencyMillis, long exampleStoreBindLatencyNanos, long exampleStoreStartQueryLatencyNanos, @NonNull String sdkPackageName)62     /* package-private */ TrainingEventReported(
63             long clientVersion,
64             int eventKind,
65             long populationId,
66             long taskId,
67             long durationInMillis,
68             long exampleCount,
69             long exampleSize,
70             long dataTransferDurationMillis,
71             long bytesUploaded,
72             long bytesDownloaded,
73             long keyAttestationLatencyMillis,
74             long exampleStoreBindLatencyNanos,
75             long exampleStoreStartQueryLatencyNanos,
76             @NonNull String sdkPackageName) {
77         this.mClientVersion = clientVersion;
78         this.mEventKind = eventKind;
79         this.mPopulationId = populationId;
80         this.mTaskId = taskId;
81         this.mDurationInMillis = durationInMillis;
82         this.mExampleCount = exampleCount;
83         this.mExampleSize = exampleSize;
84         this.mDataTransferDurationMillis = dataTransferDurationMillis;
85         this.mBytesUploaded = bytesUploaded;
86         this.mBytesDownloaded = bytesDownloaded;
87         this.mKeyAttestationLatencyMillis = keyAttestationLatencyMillis;
88         this.mExampleStoreBindLatencyNanos = exampleStoreBindLatencyNanos;
89         this.mExampleStoreStartQueryLatencyNanos = exampleStoreStartQueryLatencyNanos;
90         this.mSdkPackageName = sdkPackageName;
91         AnnotationValidations.validate(NonNull.class, null, mSdkPackageName);
92 
93         // onConstructed(); // You can define this method to get a callback
94     }
95 
96     @DataClass.Generated.Member
getClientVersion()97     public long getClientVersion() {
98         return mClientVersion;
99     }
100 
101     @DataClass.Generated.Member
getEventKind()102     public int getEventKind() {
103         return mEventKind;
104     }
105 
106     @DataClass.Generated.Member
getPopulationId()107     public long getPopulationId() {
108         return mPopulationId;
109     }
110 
111     @DataClass.Generated.Member
getTaskId()112     public long getTaskId() {
113         return mTaskId;
114     }
115 
116     @DataClass.Generated.Member
getDurationInMillis()117     public long getDurationInMillis() {
118         return mDurationInMillis;
119     }
120 
121     @DataClass.Generated.Member
getExampleCount()122     public long getExampleCount() {
123         return mExampleCount;
124     }
125 
126     @DataClass.Generated.Member
getExampleSize()127     public long getExampleSize() {
128         return mExampleSize;
129     }
130 
131     @DataClass.Generated.Member
getDataTransferDurationMillis()132     public long getDataTransferDurationMillis() {
133         return mDataTransferDurationMillis;
134     }
135 
136     @DataClass.Generated.Member
getBytesUploaded()137     public long getBytesUploaded() {
138         return mBytesUploaded;
139     }
140 
141     @DataClass.Generated.Member
getBytesDownloaded()142     public long getBytesDownloaded() {
143         return mBytesDownloaded;
144     }
145 
146     @DataClass.Generated.Member
getKeyAttestationLatencyMillis()147     public long getKeyAttestationLatencyMillis() {
148         return mKeyAttestationLatencyMillis;
149     }
150 
151     @DataClass.Generated.Member
getExampleStoreBindLatencyNanos()152     public long getExampleStoreBindLatencyNanos() {
153         return mExampleStoreBindLatencyNanos;
154     }
155 
156     @DataClass.Generated.Member
getExampleStoreStartQueryLatencyNanos()157     public long getExampleStoreStartQueryLatencyNanos() {
158         return mExampleStoreStartQueryLatencyNanos;
159     }
160 
161     @DataClass.Generated.Member
getSdkPackageName()162     public @NonNull String getSdkPackageName() {
163         return mSdkPackageName;
164     }
165 
166     @Override
167     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)168     public boolean equals(@android.annotation.Nullable Object o) {
169         // You can override field equality logic by defining either of the methods like:
170         // boolean fieldNameEquals(TrainingEventReported other) { ... }
171         // boolean fieldNameEquals(FieldType otherValue) { ... }
172 
173         if (this == o) return true;
174         if (o == null || getClass() != o.getClass()) return false;
175         @SuppressWarnings("unchecked")
176         TrainingEventReported that = (TrainingEventReported) o;
177         //noinspection PointlessBooleanExpression
178         return true
179                 && mClientVersion == that.mClientVersion
180                 && mEventKind == that.mEventKind
181                 && mPopulationId == that.mPopulationId
182                 && mTaskId == that.mTaskId
183                 && mDurationInMillis == that.mDurationInMillis
184                 && mExampleCount == that.mExampleCount
185                 && mExampleSize == that.mExampleSize
186                 && mDataTransferDurationMillis == that.mDataTransferDurationMillis
187                 && mBytesUploaded == that.mBytesUploaded
188                 && mBytesDownloaded == that.mBytesDownloaded
189                 && mKeyAttestationLatencyMillis == that.mKeyAttestationLatencyMillis
190                 && mExampleStoreBindLatencyNanos == that.mExampleStoreBindLatencyNanos
191                 && mExampleStoreStartQueryLatencyNanos == that.mExampleStoreStartQueryLatencyNanos
192                 && java.util.Objects.equals(mSdkPackageName, that.mSdkPackageName);
193     }
194 
195     @Override
196     @DataClass.Generated.Member
hashCode()197     public int hashCode() {
198         // You can override field hashCode logic by defining methods like:
199         // int fieldNameHashCode() { ... }
200 
201         int _hash = 1;
202         _hash = 31 * _hash + Long.hashCode(mClientVersion);
203         _hash = 31 * _hash + mEventKind;
204         _hash = 31 * _hash + Long.hashCode(mPopulationId);
205         _hash = 31 * _hash + Long.hashCode(mTaskId);
206         _hash = 31 * _hash + Long.hashCode(mDurationInMillis);
207         _hash = 31 * _hash + Long.hashCode(mExampleCount);
208         _hash = 31 * _hash + Long.hashCode(mExampleSize);
209         _hash = 31 * _hash + Long.hashCode(mDataTransferDurationMillis);
210         _hash = 31 * _hash + Long.hashCode(mBytesUploaded);
211         _hash = 31 * _hash + Long.hashCode(mBytesDownloaded);
212         _hash = 31 * _hash + Long.hashCode(mKeyAttestationLatencyMillis);
213         _hash = 31 * _hash + Long.hashCode(mExampleStoreBindLatencyNanos);
214         _hash = 31 * _hash + Long.hashCode(mExampleStoreStartQueryLatencyNanos);
215         _hash = 31 * _hash + java.util.Objects.hashCode(mSdkPackageName);
216         return _hash;
217     }
218 
219     /**
220      * A builder for {@link TrainingEventReported}
221      */
222     @SuppressWarnings("WeakerAccess")
223     @DataClass.Generated.Member
224     public static class Builder {
225 
226         private long mClientVersion;
227         private int mEventKind;
228         private long mPopulationId;
229         private long mTaskId;
230         private long mDurationInMillis;
231         private long mExampleCount;
232         private long mExampleSize;
233         private long mDataTransferDurationMillis;
234         private long mBytesUploaded;
235         private long mBytesDownloaded;
236         private long mKeyAttestationLatencyMillis;
237         private long mExampleStoreBindLatencyNanos;
238         private long mExampleStoreStartQueryLatencyNanos;
239         private @NonNull String mSdkPackageName;
240 
241         private long mBuilderFieldsSet = 0L;
242 
Builder()243         public Builder() {}
244 
245         @DataClass.Generated.Member
setClientVersion(long value)246         public @NonNull Builder setClientVersion(long value) {
247             checkNotUsed();
248             mBuilderFieldsSet |= 0x1;
249             mClientVersion = value;
250             return this;
251         }
252 
253         @DataClass.Generated.Member
setEventKind(int value)254         public @NonNull Builder setEventKind(int value) {
255             checkNotUsed();
256             mBuilderFieldsSet |= 0x2;
257             mEventKind = value;
258             return this;
259         }
260 
261         @DataClass.Generated.Member
setPopulationId(long value)262         public @NonNull Builder setPopulationId(long value) {
263             checkNotUsed();
264             mBuilderFieldsSet |= 0x4;
265             mPopulationId = value;
266             return this;
267         }
268 
269         @DataClass.Generated.Member
setTaskId(long value)270         public @NonNull Builder setTaskId(long value) {
271             checkNotUsed();
272             mBuilderFieldsSet |= 0x8;
273             mTaskId = value;
274             return this;
275         }
276 
277         @DataClass.Generated.Member
setDurationInMillis(long value)278         public @NonNull Builder setDurationInMillis(long value) {
279             checkNotUsed();
280             mBuilderFieldsSet |= 0x10;
281             mDurationInMillis = value;
282             return this;
283         }
284 
285         @DataClass.Generated.Member
setExampleCount(long value)286         public @NonNull Builder setExampleCount(long value) {
287             checkNotUsed();
288             mBuilderFieldsSet |= 0x20;
289             mExampleCount = value;
290             return this;
291         }
292 
293         @DataClass.Generated.Member
setExampleSize(long value)294         public @NonNull Builder setExampleSize(long value) {
295             checkNotUsed();
296             mBuilderFieldsSet |= 0x40;
297             mExampleSize = value;
298             return this;
299         }
300 
301         @DataClass.Generated.Member
setDataTransferDurationMillis(long value)302         public @NonNull Builder setDataTransferDurationMillis(long value) {
303             checkNotUsed();
304             mBuilderFieldsSet |= 0x80;
305             mDataTransferDurationMillis = value;
306             return this;
307         }
308 
309         @DataClass.Generated.Member
setBytesUploaded(long value)310         public @NonNull Builder setBytesUploaded(long value) {
311             checkNotUsed();
312             mBuilderFieldsSet |= 0x100;
313             mBytesUploaded = value;
314             return this;
315         }
316 
317         @DataClass.Generated.Member
setBytesDownloaded(long value)318         public @NonNull Builder setBytesDownloaded(long value) {
319             checkNotUsed();
320             mBuilderFieldsSet |= 0x200;
321             mBytesDownloaded = value;
322             return this;
323         }
324 
325         @DataClass.Generated.Member
setKeyAttestationLatencyMillis(long value)326         public @NonNull Builder setKeyAttestationLatencyMillis(long value) {
327             checkNotUsed();
328             mBuilderFieldsSet |= 0x400;
329             mKeyAttestationLatencyMillis = value;
330             return this;
331         }
332 
333         @DataClass.Generated.Member
setExampleStoreBindLatencyNanos(long value)334         public @NonNull Builder setExampleStoreBindLatencyNanos(long value) {
335             checkNotUsed();
336             mBuilderFieldsSet |= 0x800;
337             mExampleStoreBindLatencyNanos = value;
338             return this;
339         }
340 
341         @DataClass.Generated.Member
setExampleStoreStartQueryLatencyNanos(long value)342         public @NonNull Builder setExampleStoreStartQueryLatencyNanos(long value) {
343             checkNotUsed();
344             mBuilderFieldsSet |= 0x1000;
345             mExampleStoreStartQueryLatencyNanos = value;
346             return this;
347         }
348 
349         @DataClass.Generated.Member
setSdkPackageName(@onNull String value)350         public @NonNull Builder setSdkPackageName(@NonNull String value) {
351             checkNotUsed();
352             mBuilderFieldsSet |= 0x2000;
353             mSdkPackageName = value;
354             return this;
355         }
356 
357         /** Builds the instance. This builder should not be touched after calling this! */
build()358         public @NonNull TrainingEventReported build() {
359             checkNotUsed();
360             mBuilderFieldsSet |= 0x4000; // Mark builder used
361 
362             if ((mBuilderFieldsSet & 0x20) == 0) {
363                 mExampleCount = 0;
364             }
365             if ((mBuilderFieldsSet & 0x40) == 0) {
366                 mExampleSize = 0;
367             }
368             if ((mBuilderFieldsSet & 0x80) == 0) {
369                 mDataTransferDurationMillis = 0;
370             }
371             if ((mBuilderFieldsSet & 0x100) == 0) {
372                 mBytesUploaded = 0;
373             }
374             if ((mBuilderFieldsSet & 0x200) == 0) {
375                 mBytesDownloaded = 0;
376             }
377             if ((mBuilderFieldsSet & 0x400) == 0) {
378                 mKeyAttestationLatencyMillis = 0;
379             }
380             if ((mBuilderFieldsSet & 0x800) == 0) {
381                 mExampleStoreBindLatencyNanos = 0;
382             }
383             if ((mBuilderFieldsSet & 0x1000) == 0) {
384                 mExampleStoreStartQueryLatencyNanos = 0;
385             }
386             if ((mBuilderFieldsSet & 0x2000) == 0) {
387                 mSdkPackageName = "";
388             }
389             TrainingEventReported o = new TrainingEventReported(
390                     mClientVersion,
391                     mEventKind,
392                     mPopulationId,
393                     mTaskId,
394                     mDurationInMillis,
395                     mExampleCount,
396                     mExampleSize,
397                     mDataTransferDurationMillis,
398                     mBytesUploaded,
399                     mBytesDownloaded,
400                     mKeyAttestationLatencyMillis,
401                     mExampleStoreBindLatencyNanos,
402                     mExampleStoreStartQueryLatencyNanos,
403                     mSdkPackageName);
404             return o;
405         }
406 
checkNotUsed()407         private void checkNotUsed() {
408             if ((mBuilderFieldsSet & 0x4000) != 0) {
409                 throw new IllegalStateException(
410                         "This Builder should not be reused. Use a new Builder instance instead");
411             }
412         }
413     }
414 
415     @DataClass.Generated(
416             time = 1715996465220L,
417             codegenVersion = "1.0.23",
418             sourceFile = "packages/modules/OnDevicePersonalization/federatedcompute/src/com/android/federatedcompute/services/statsd/TrainingEventReported.java",
419             inputSignatures = "private  long mClientVersion\nprivate  int mEventKind\nprivate  long mPopulationId\nprivate  long mTaskId\nprivate  long mDurationInMillis\nprivate  long mExampleCount\nprivate  long mExampleSize\nprivate  long mDataTransferDurationMillis\nprivate  long mBytesUploaded\nprivate  long mBytesDownloaded\nprivate  long mKeyAttestationLatencyMillis\nprivate  long mExampleStoreBindLatencyNanos\nprivate  long mExampleStoreStartQueryLatencyNanos\nprivate @android.annotation.NonNull java.lang.String mSdkPackageName\nclass TrainingEventReported extends java.lang.Object implements []\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
420     @Deprecated
__metadata()421     private void __metadata() {}
422 
423 
424     //@formatter:on
425     // End of generated code
426 
427 }
428