• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.ondevicepersonalization;
18 
19 import android.annotation.NonNull;
20 import android.os.Parcelable;
21 
22 import com.android.ondevicepersonalization.internal.util.AnnotationValidations;
23 import com.android.ondevicepersonalization.internal.util.DataClass;
24 
25 import java.util.List;
26 
27 /**
28  * User data for personalized ads targeting.
29  *
30  * @hide
31  */
32 // This class should be updated with the Kotlin mirror
33 // {@link com.android.ondevicepersonalization.services.policyengine.data.UserData}.
34 @DataClass(genBuilder = true, genEqualsHashCode = true)
35 public final class UserData implements Parcelable {
36     /** The current timestamp in second. */
37     @NonNull long mTimeSec;
38 
39     /** The device timezone +/- minutes offset from UTC. */
40     @NonNull int mTimezone;
41 
42     /** The device orientation. */
43     @NonNull int mOrientation;
44 
45     /** The available space on device in MB. */
46     @NonNull int mAvailableBytesMB;
47 
48     /** Battery percentage. */
49     @NonNull int mBatteryPct;
50 
51     /** Country. See the full list {@link Country}. */
52     @NonNull int mCountry;
53 
54     /** Language. See the full list {@link Language}. */
55     @NonNull int mLanguage;
56 
57     /** Carrier. See the full list {@link Carrier}. */
58     @NonNull int mCarrier;
59 
60     /** OS versions. */
61     @NonNull OSVersion mOsVersions;
62 
63     /** Network connection types. See full list {@link RawUserData.ConnectionType}. */
64     @NonNull int mConnectionType;
65 
66     /** Connection speed in kbps. */
67     @NonNull int mConnectionSpeedKbps;
68 
69     /** Status if network is metered. False - not metered. True - metered. */
70     @NonNull boolean mNetworkMetered;
71 
72     /** Device metrics value. */
73     @NonNull DeviceMetrics mDeviceMetrics;
74 
75     /** The history of installed/uninstalled packages. */
76     @NonNull List<AppInstallStatus> mAppInstalledHistory;
77 
78     /** The app usage history in the last 30 days, sorted by total time spent. */
79     @NonNull List<AppUsageStatus> mAppUsageHistory;
80 
81     /** The most recently known location. */
82     @NonNull Location mCurrentLocation;
83 
84     /** The location history in last 30 days, sorted by the stay duration. */
85     @NonNull List<LocationStatus> mLocationHistory;
86 
87 
88 
89     // Code below generated by codegen v1.0.23.
90     //
91     // DO NOT MODIFY!
92     // CHECKSTYLE:OFF Generated code
93     //
94     // To regenerate run:
95     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/UserData.java
96     //
97     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
98     //   Settings > Editor > Code Style > Formatter Control
99     //@formatter:off
100 
101 
102     @DataClass.Generated.Member
UserData( @onNull long timeSec, @NonNull int timezone, @NonNull int orientation, @NonNull int availableBytesMB, @NonNull int batteryPct, @NonNull int country, @NonNull int language, @NonNull int carrier, @NonNull OSVersion osVersions, @NonNull int connectionType, @NonNull int connectionSpeedKbps, @NonNull boolean networkMetered, @NonNull DeviceMetrics deviceMetrics, @NonNull List<AppInstallStatus> appInstalledHistory, @NonNull List<AppUsageStatus> appUsageHistory, @NonNull Location currentLocation, @NonNull List<LocationStatus> locationHistory)103     /* package-private */ UserData(
104             @NonNull long timeSec,
105             @NonNull int timezone,
106             @NonNull int orientation,
107             @NonNull int availableBytesMB,
108             @NonNull int batteryPct,
109             @NonNull int country,
110             @NonNull int language,
111             @NonNull int carrier,
112             @NonNull OSVersion osVersions,
113             @NonNull int connectionType,
114             @NonNull int connectionSpeedKbps,
115             @NonNull boolean networkMetered,
116             @NonNull DeviceMetrics deviceMetrics,
117             @NonNull List<AppInstallStatus> appInstalledHistory,
118             @NonNull List<AppUsageStatus> appUsageHistory,
119             @NonNull Location currentLocation,
120             @NonNull List<LocationStatus> locationHistory) {
121         this.mTimeSec = timeSec;
122         AnnotationValidations.validate(
123                 NonNull.class, null, mTimeSec);
124         this.mTimezone = timezone;
125         AnnotationValidations.validate(
126                 NonNull.class, null, mTimezone);
127         this.mOrientation = orientation;
128         AnnotationValidations.validate(
129                 NonNull.class, null, mOrientation);
130         this.mAvailableBytesMB = availableBytesMB;
131         AnnotationValidations.validate(
132                 NonNull.class, null, mAvailableBytesMB);
133         this.mBatteryPct = batteryPct;
134         AnnotationValidations.validate(
135                 NonNull.class, null, mBatteryPct);
136         this.mCountry = country;
137         AnnotationValidations.validate(
138                 NonNull.class, null, mCountry);
139         this.mLanguage = language;
140         AnnotationValidations.validate(
141                 NonNull.class, null, mLanguage);
142         this.mCarrier = carrier;
143         AnnotationValidations.validate(
144                 NonNull.class, null, mCarrier);
145         this.mOsVersions = osVersions;
146         AnnotationValidations.validate(
147                 NonNull.class, null, mOsVersions);
148         this.mConnectionType = connectionType;
149         AnnotationValidations.validate(
150                 NonNull.class, null, mConnectionType);
151         this.mConnectionSpeedKbps = connectionSpeedKbps;
152         AnnotationValidations.validate(
153                 NonNull.class, null, mConnectionSpeedKbps);
154         this.mNetworkMetered = networkMetered;
155         AnnotationValidations.validate(
156                 NonNull.class, null, mNetworkMetered);
157         this.mDeviceMetrics = deviceMetrics;
158         AnnotationValidations.validate(
159                 NonNull.class, null, mDeviceMetrics);
160         this.mAppInstalledHistory = appInstalledHistory;
161         AnnotationValidations.validate(
162                 NonNull.class, null, mAppInstalledHistory);
163         this.mAppUsageHistory = appUsageHistory;
164         AnnotationValidations.validate(
165                 NonNull.class, null, mAppUsageHistory);
166         this.mCurrentLocation = currentLocation;
167         AnnotationValidations.validate(
168                 NonNull.class, null, mCurrentLocation);
169         this.mLocationHistory = locationHistory;
170         AnnotationValidations.validate(
171                 NonNull.class, null, mLocationHistory);
172 
173         // onConstructed(); // You can define this method to get a callback
174     }
175 
176     /**
177      * The current timestamp in second.
178      */
179     @DataClass.Generated.Member
getTimeSec()180     public @NonNull long getTimeSec() {
181         return mTimeSec;
182     }
183 
184     /**
185      * The device timezone +/- minutes offset from UTC.
186      */
187     @DataClass.Generated.Member
getTimezone()188     public @NonNull int getTimezone() {
189         return mTimezone;
190     }
191 
192     /**
193      * The device orientation.
194      */
195     @DataClass.Generated.Member
getOrientation()196     public @NonNull int getOrientation() {
197         return mOrientation;
198     }
199 
200     /**
201      * The available space on device in MB.
202      */
203     @DataClass.Generated.Member
getAvailableBytesMB()204     public @NonNull int getAvailableBytesMB() {
205         return mAvailableBytesMB;
206     }
207 
208     /**
209      * Battery percentage.
210      */
211     @DataClass.Generated.Member
getBatteryPct()212     public @NonNull int getBatteryPct() {
213         return mBatteryPct;
214     }
215 
216     /**
217      * Country. See the full list {@link Country}.
218      */
219     @DataClass.Generated.Member
getCountry()220     public @NonNull int getCountry() {
221         return mCountry;
222     }
223 
224     /**
225      * Language. See the full list {@link Language}.
226      */
227     @DataClass.Generated.Member
getLanguage()228     public @NonNull int getLanguage() {
229         return mLanguage;
230     }
231 
232     /**
233      * Carrier. See the full list {@link Carrier}.
234      */
235     @DataClass.Generated.Member
getCarrier()236     public @NonNull int getCarrier() {
237         return mCarrier;
238     }
239 
240     /**
241      * OS versions.
242      */
243     @DataClass.Generated.Member
getOsVersions()244     public @NonNull OSVersion getOsVersions() {
245         return mOsVersions;
246     }
247 
248     /**
249      * Network connection types. See full list {@link RawUserData.ConnectionType}.
250      */
251     @DataClass.Generated.Member
getConnectionType()252     public @NonNull int getConnectionType() {
253         return mConnectionType;
254     }
255 
256     /**
257      * Connection speed in kbps.
258      */
259     @DataClass.Generated.Member
getConnectionSpeedKbps()260     public @NonNull int getConnectionSpeedKbps() {
261         return mConnectionSpeedKbps;
262     }
263 
264     /**
265      * Status if network is metered. False - not metered. True - metered.
266      */
267     @DataClass.Generated.Member
isNetworkMetered()268     public @NonNull boolean isNetworkMetered() {
269         return mNetworkMetered;
270     }
271 
272     /**
273      * Device metrics value.
274      */
275     @DataClass.Generated.Member
getDeviceMetrics()276     public @NonNull DeviceMetrics getDeviceMetrics() {
277         return mDeviceMetrics;
278     }
279 
280     /**
281      * The history of installed/uninstalled packages.
282      */
283     @DataClass.Generated.Member
getAppInstalledHistory()284     public @NonNull List<AppInstallStatus> getAppInstalledHistory() {
285         return mAppInstalledHistory;
286     }
287 
288     /**
289      * The app usage history in the last 30 days, sorted by total time spent.
290      */
291     @DataClass.Generated.Member
getAppUsageHistory()292     public @NonNull List<AppUsageStatus> getAppUsageHistory() {
293         return mAppUsageHistory;
294     }
295 
296     /**
297      * The most recently known location.
298      */
299     @DataClass.Generated.Member
getCurrentLocation()300     public @NonNull Location getCurrentLocation() {
301         return mCurrentLocation;
302     }
303 
304     /**
305      * The location history in last 30 days, sorted by the stay duration.
306      */
307     @DataClass.Generated.Member
getLocationHistory()308     public @NonNull List<LocationStatus> getLocationHistory() {
309         return mLocationHistory;
310     }
311 
312     @Override
313     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)314     public boolean equals(@android.annotation.Nullable Object o) {
315         // You can override field equality logic by defining either of the methods like:
316         // boolean fieldNameEquals(UserData other) { ... }
317         // boolean fieldNameEquals(FieldType otherValue) { ... }
318 
319         if (this == o) return true;
320         if (o == null || getClass() != o.getClass()) return false;
321         @SuppressWarnings("unchecked")
322         UserData that = (UserData) o;
323         //noinspection PointlessBooleanExpression
324         return true
325                 && mTimeSec == that.mTimeSec
326                 && mTimezone == that.mTimezone
327                 && mOrientation == that.mOrientation
328                 && mAvailableBytesMB == that.mAvailableBytesMB
329                 && mBatteryPct == that.mBatteryPct
330                 && mCountry == that.mCountry
331                 && mLanguage == that.mLanguage
332                 && mCarrier == that.mCarrier
333                 && java.util.Objects.equals(mOsVersions, that.mOsVersions)
334                 && mConnectionType == that.mConnectionType
335                 && mConnectionSpeedKbps == that.mConnectionSpeedKbps
336                 && mNetworkMetered == that.mNetworkMetered
337                 && java.util.Objects.equals(mDeviceMetrics, that.mDeviceMetrics)
338                 && java.util.Objects.equals(mAppInstalledHistory, that.mAppInstalledHistory)
339                 && java.util.Objects.equals(mAppUsageHistory, that.mAppUsageHistory)
340                 && java.util.Objects.equals(mCurrentLocation, that.mCurrentLocation)
341                 && java.util.Objects.equals(mLocationHistory, that.mLocationHistory);
342     }
343 
344     @Override
345     @DataClass.Generated.Member
hashCode()346     public int hashCode() {
347         // You can override field hashCode logic by defining methods like:
348         // int fieldNameHashCode() { ... }
349 
350         int _hash = 1;
351         _hash = 31 * _hash + Long.hashCode(mTimeSec);
352         _hash = 31 * _hash + mTimezone;
353         _hash = 31 * _hash + mOrientation;
354         _hash = 31 * _hash + mAvailableBytesMB;
355         _hash = 31 * _hash + mBatteryPct;
356         _hash = 31 * _hash + mCountry;
357         _hash = 31 * _hash + mLanguage;
358         _hash = 31 * _hash + mCarrier;
359         _hash = 31 * _hash + java.util.Objects.hashCode(mOsVersions);
360         _hash = 31 * _hash + mConnectionType;
361         _hash = 31 * _hash + mConnectionSpeedKbps;
362         _hash = 31 * _hash + Boolean.hashCode(mNetworkMetered);
363         _hash = 31 * _hash + java.util.Objects.hashCode(mDeviceMetrics);
364         _hash = 31 * _hash + java.util.Objects.hashCode(mAppInstalledHistory);
365         _hash = 31 * _hash + java.util.Objects.hashCode(mAppUsageHistory);
366         _hash = 31 * _hash + java.util.Objects.hashCode(mCurrentLocation);
367         _hash = 31 * _hash + java.util.Objects.hashCode(mLocationHistory);
368         return _hash;
369     }
370 
371     @Override
372     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)373     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
374         // You can override field parcelling by defining methods like:
375         // void parcelFieldName(Parcel dest, int flags) { ... }
376 
377         long flg = 0;
378         if (mNetworkMetered) flg |= 0x800;
379         dest.writeLong(flg);
380         dest.writeLong(mTimeSec);
381         dest.writeInt(mTimezone);
382         dest.writeInt(mOrientation);
383         dest.writeInt(mAvailableBytesMB);
384         dest.writeInt(mBatteryPct);
385         dest.writeInt(mCountry);
386         dest.writeInt(mLanguage);
387         dest.writeInt(mCarrier);
388         dest.writeTypedObject(mOsVersions, flags);
389         dest.writeInt(mConnectionType);
390         dest.writeInt(mConnectionSpeedKbps);
391         dest.writeTypedObject(mDeviceMetrics, flags);
392         dest.writeParcelableList(mAppInstalledHistory, flags);
393         dest.writeParcelableList(mAppUsageHistory, flags);
394         dest.writeTypedObject(mCurrentLocation, flags);
395         dest.writeParcelableList(mLocationHistory, flags);
396     }
397 
398     @Override
399     @DataClass.Generated.Member
describeContents()400     public int describeContents() { return 0; }
401 
402     /** @hide */
403     @SuppressWarnings({"unchecked", "RedundantCast"})
404     @DataClass.Generated.Member
UserData(@onNull android.os.Parcel in)405     /* package-private */ UserData(@NonNull android.os.Parcel in) {
406         // You can override field unparcelling by defining methods like:
407         // static FieldType unparcelFieldName(Parcel in) { ... }
408 
409         long flg = in.readLong();
410         boolean networkMetered = (flg & 0x800) != 0;
411         long timeSec = in.readLong();
412         int timezone = in.readInt();
413         int orientation = in.readInt();
414         int availableBytesMB = in.readInt();
415         int batteryPct = in.readInt();
416         int country = in.readInt();
417         int language = in.readInt();
418         int carrier = in.readInt();
419         OSVersion osVersions = (OSVersion) in.readTypedObject(OSVersion.CREATOR);
420         int connectionType = in.readInt();
421         int connectionSpeedKbps = in.readInt();
422         DeviceMetrics deviceMetrics = (DeviceMetrics) in.readTypedObject(DeviceMetrics.CREATOR);
423         List<AppInstallStatus> appInstalledHistory = new java.util.ArrayList<>();
424         in.readParcelableList(appInstalledHistory, AppInstallStatus.class.getClassLoader());
425         List<AppUsageStatus> appUsageHistory = new java.util.ArrayList<>();
426         in.readParcelableList(appUsageHistory, AppUsageStatus.class.getClassLoader());
427         Location currentLocation = (Location) in.readTypedObject(Location.CREATOR);
428         List<LocationStatus> locationHistory = new java.util.ArrayList<>();
429         in.readParcelableList(locationHistory, LocationStatus.class.getClassLoader());
430 
431         this.mTimeSec = timeSec;
432         AnnotationValidations.validate(
433                 NonNull.class, null, mTimeSec);
434         this.mTimezone = timezone;
435         AnnotationValidations.validate(
436                 NonNull.class, null, mTimezone);
437         this.mOrientation = orientation;
438         AnnotationValidations.validate(
439                 NonNull.class, null, mOrientation);
440         this.mAvailableBytesMB = availableBytesMB;
441         AnnotationValidations.validate(
442                 NonNull.class, null, mAvailableBytesMB);
443         this.mBatteryPct = batteryPct;
444         AnnotationValidations.validate(
445                 NonNull.class, null, mBatteryPct);
446         this.mCountry = country;
447         AnnotationValidations.validate(
448                 NonNull.class, null, mCountry);
449         this.mLanguage = language;
450         AnnotationValidations.validate(
451                 NonNull.class, null, mLanguage);
452         this.mCarrier = carrier;
453         AnnotationValidations.validate(
454                 NonNull.class, null, mCarrier);
455         this.mOsVersions = osVersions;
456         AnnotationValidations.validate(
457                 NonNull.class, null, mOsVersions);
458         this.mConnectionType = connectionType;
459         AnnotationValidations.validate(
460                 NonNull.class, null, mConnectionType);
461         this.mConnectionSpeedKbps = connectionSpeedKbps;
462         AnnotationValidations.validate(
463                 NonNull.class, null, mConnectionSpeedKbps);
464         this.mNetworkMetered = networkMetered;
465         AnnotationValidations.validate(
466                 NonNull.class, null, mNetworkMetered);
467         this.mDeviceMetrics = deviceMetrics;
468         AnnotationValidations.validate(
469                 NonNull.class, null, mDeviceMetrics);
470         this.mAppInstalledHistory = appInstalledHistory;
471         AnnotationValidations.validate(
472                 NonNull.class, null, mAppInstalledHistory);
473         this.mAppUsageHistory = appUsageHistory;
474         AnnotationValidations.validate(
475                 NonNull.class, null, mAppUsageHistory);
476         this.mCurrentLocation = currentLocation;
477         AnnotationValidations.validate(
478                 NonNull.class, null, mCurrentLocation);
479         this.mLocationHistory = locationHistory;
480         AnnotationValidations.validate(
481                 NonNull.class, null, mLocationHistory);
482 
483         // onConstructed(); // You can define this method to get a callback
484     }
485 
486     @DataClass.Generated.Member
487     public static final @NonNull Parcelable.Creator<UserData> CREATOR
488             = new Parcelable.Creator<UserData>() {
489         @Override
490         public UserData[] newArray(int size) {
491             return new UserData[size];
492         }
493 
494         @Override
495         public UserData createFromParcel(@NonNull android.os.Parcel in) {
496             return new UserData(in);
497         }
498     };
499 
500     /**
501      * A builder for {@link UserData}
502      */
503     @SuppressWarnings("WeakerAccess")
504     @DataClass.Generated.Member
505     public static final class Builder {
506 
507         private @NonNull long mTimeSec;
508         private @NonNull int mTimezone;
509         private @NonNull int mOrientation;
510         private @NonNull int mAvailableBytesMB;
511         private @NonNull int mBatteryPct;
512         private @NonNull int mCountry;
513         private @NonNull int mLanguage;
514         private @NonNull int mCarrier;
515         private @NonNull OSVersion mOsVersions;
516         private @NonNull int mConnectionType;
517         private @NonNull int mConnectionSpeedKbps;
518         private @NonNull boolean mNetworkMetered;
519         private @NonNull DeviceMetrics mDeviceMetrics;
520         private @NonNull List<AppInstallStatus> mAppInstalledHistory;
521         private @NonNull List<AppUsageStatus> mAppUsageHistory;
522         private @NonNull Location mCurrentLocation;
523         private @NonNull List<LocationStatus> mLocationHistory;
524 
525         private long mBuilderFieldsSet = 0L;
526 
527         /**
528          * Creates a new Builder.
529          *
530          * @param timeSec
531          *   The current timestamp in second.
532          * @param timezone
533          *   The device timezone +/- minutes offset from UTC.
534          * @param orientation
535          *   The device orientation.
536          * @param availableBytesMB
537          *   The available space on device in MB.
538          * @param batteryPct
539          *   Battery percentage.
540          * @param country
541          *   Country. See the full list {@link Country}.
542          * @param language
543          *   Language. See the full list {@link Language}.
544          * @param carrier
545          *   Carrier. See the full list {@link Carrier}.
546          * @param osVersions
547          *   OS versions.
548          * @param connectionType
549          *   Network connection types. See full list {@link RawUserData.ConnectionType}.
550          * @param connectionSpeedKbps
551          *   Connection speed in kbps.
552          * @param networkMetered
553          *   Status if network is metered. False - not metered. True - metered.
554          * @param deviceMetrics
555          *   Device metrics value.
556          * @param appInstalledHistory
557          *   The history of installed/uninstalled packages.
558          * @param appUsageHistory
559          *   The app usage history in the last 30 days, sorted by total time spent.
560          * @param currentLocation
561          *   The most recently known location.
562          * @param locationHistory
563          *   The location history in last 30 days, sorted by the stay duration.
564          */
Builder( @onNull long timeSec, @NonNull int timezone, @NonNull int orientation, @NonNull int availableBytesMB, @NonNull int batteryPct, @NonNull int country, @NonNull int language, @NonNull int carrier, @NonNull OSVersion osVersions, @NonNull int connectionType, @NonNull int connectionSpeedKbps, @NonNull boolean networkMetered, @NonNull DeviceMetrics deviceMetrics, @NonNull List<AppInstallStatus> appInstalledHistory, @NonNull List<AppUsageStatus> appUsageHistory, @NonNull Location currentLocation, @NonNull List<LocationStatus> locationHistory)565         public Builder(
566                 @NonNull long timeSec,
567                 @NonNull int timezone,
568                 @NonNull int orientation,
569                 @NonNull int availableBytesMB,
570                 @NonNull int batteryPct,
571                 @NonNull int country,
572                 @NonNull int language,
573                 @NonNull int carrier,
574                 @NonNull OSVersion osVersions,
575                 @NonNull int connectionType,
576                 @NonNull int connectionSpeedKbps,
577                 @NonNull boolean networkMetered,
578                 @NonNull DeviceMetrics deviceMetrics,
579                 @NonNull List<AppInstallStatus> appInstalledHistory,
580                 @NonNull List<AppUsageStatus> appUsageHistory,
581                 @NonNull Location currentLocation,
582                 @NonNull List<LocationStatus> locationHistory) {
583             mTimeSec = timeSec;
584             AnnotationValidations.validate(
585                     NonNull.class, null, mTimeSec);
586             mTimezone = timezone;
587             AnnotationValidations.validate(
588                     NonNull.class, null, mTimezone);
589             mOrientation = orientation;
590             AnnotationValidations.validate(
591                     NonNull.class, null, mOrientation);
592             mAvailableBytesMB = availableBytesMB;
593             AnnotationValidations.validate(
594                     NonNull.class, null, mAvailableBytesMB);
595             mBatteryPct = batteryPct;
596             AnnotationValidations.validate(
597                     NonNull.class, null, mBatteryPct);
598             mCountry = country;
599             AnnotationValidations.validate(
600                     NonNull.class, null, mCountry);
601             mLanguage = language;
602             AnnotationValidations.validate(
603                     NonNull.class, null, mLanguage);
604             mCarrier = carrier;
605             AnnotationValidations.validate(
606                     NonNull.class, null, mCarrier);
607             mOsVersions = osVersions;
608             AnnotationValidations.validate(
609                     NonNull.class, null, mOsVersions);
610             mConnectionType = connectionType;
611             AnnotationValidations.validate(
612                     NonNull.class, null, mConnectionType);
613             mConnectionSpeedKbps = connectionSpeedKbps;
614             AnnotationValidations.validate(
615                     NonNull.class, null, mConnectionSpeedKbps);
616             mNetworkMetered = networkMetered;
617             AnnotationValidations.validate(
618                     NonNull.class, null, mNetworkMetered);
619             mDeviceMetrics = deviceMetrics;
620             AnnotationValidations.validate(
621                     NonNull.class, null, mDeviceMetrics);
622             mAppInstalledHistory = appInstalledHistory;
623             AnnotationValidations.validate(
624                     NonNull.class, null, mAppInstalledHistory);
625             mAppUsageHistory = appUsageHistory;
626             AnnotationValidations.validate(
627                     NonNull.class, null, mAppUsageHistory);
628             mCurrentLocation = currentLocation;
629             AnnotationValidations.validate(
630                     NonNull.class, null, mCurrentLocation);
631             mLocationHistory = locationHistory;
632             AnnotationValidations.validate(
633                     NonNull.class, null, mLocationHistory);
634         }
635 
Builder()636         public Builder() {
637         }
638 
639         /**
640          * The current timestamp in second.
641          */
642         @DataClass.Generated.Member
setTimeSec(@onNull long value)643         public @NonNull Builder setTimeSec(@NonNull long value) {
644             checkNotUsed();
645             mBuilderFieldsSet |= 0x1;
646             mTimeSec = value;
647             return this;
648         }
649 
650         /**
651          * The device timezone +/- minutes offset from UTC.
652          */
653         @DataClass.Generated.Member
setTimezone(@onNull int value)654         public @NonNull Builder setTimezone(@NonNull int value) {
655             checkNotUsed();
656             mBuilderFieldsSet |= 0x2;
657             mTimezone = value;
658             return this;
659         }
660 
661         /**
662          * The device orientation.
663          */
664         @DataClass.Generated.Member
setOrientation(@onNull int value)665         public @NonNull Builder setOrientation(@NonNull int value) {
666             checkNotUsed();
667             mBuilderFieldsSet |= 0x4;
668             mOrientation = value;
669             return this;
670         }
671 
672         /**
673          * The available space on device in MB.
674          */
675         @DataClass.Generated.Member
setAvailableBytesMB(@onNull int value)676         public @NonNull Builder setAvailableBytesMB(@NonNull int value) {
677             checkNotUsed();
678             mBuilderFieldsSet |= 0x8;
679             mAvailableBytesMB = value;
680             return this;
681         }
682 
683         /**
684          * Battery percentage.
685          */
686         @DataClass.Generated.Member
setBatteryPct(@onNull int value)687         public @NonNull Builder setBatteryPct(@NonNull int value) {
688             checkNotUsed();
689             mBuilderFieldsSet |= 0x10;
690             mBatteryPct = value;
691             return this;
692         }
693 
694         /**
695          * Country. See the full list {@link Country}.
696          */
697         @DataClass.Generated.Member
setCountry(@onNull int value)698         public @NonNull Builder setCountry(@NonNull int value) {
699             checkNotUsed();
700             mBuilderFieldsSet |= 0x20;
701             mCountry = value;
702             return this;
703         }
704 
705         /**
706          * Language. See the full list {@link Language}.
707          */
708         @DataClass.Generated.Member
setLanguage(@onNull int value)709         public @NonNull Builder setLanguage(@NonNull int value) {
710             checkNotUsed();
711             mBuilderFieldsSet |= 0x40;
712             mLanguage = value;
713             return this;
714         }
715 
716         /**
717          * Carrier. See the full list {@link Carrier}.
718          */
719         @DataClass.Generated.Member
setCarrier(@onNull int value)720         public @NonNull Builder setCarrier(@NonNull int value) {
721             checkNotUsed();
722             mBuilderFieldsSet |= 0x80;
723             mCarrier = value;
724             return this;
725         }
726 
727         /**
728          * OS versions.
729          */
730         @DataClass.Generated.Member
setOsVersions(@onNull OSVersion value)731         public @NonNull Builder setOsVersions(@NonNull OSVersion value) {
732             checkNotUsed();
733             mBuilderFieldsSet |= 0x100;
734             mOsVersions = value;
735             return this;
736         }
737 
738         /**
739          * Network connection types. See full list {@link RawUserData.ConnectionType}.
740          */
741         @DataClass.Generated.Member
setConnectionType(@onNull int value)742         public @NonNull Builder setConnectionType(@NonNull int value) {
743             checkNotUsed();
744             mBuilderFieldsSet |= 0x200;
745             mConnectionType = value;
746             return this;
747         }
748 
749         /**
750          * Connection speed in kbps.
751          */
752         @DataClass.Generated.Member
setConnectionSpeedKbps(@onNull int value)753         public @NonNull Builder setConnectionSpeedKbps(@NonNull int value) {
754             checkNotUsed();
755             mBuilderFieldsSet |= 0x400;
756             mConnectionSpeedKbps = value;
757             return this;
758         }
759 
760         /**
761          * Status if network is metered. False - not metered. True - metered.
762          */
763         @DataClass.Generated.Member
setNetworkMetered(@onNull boolean value)764         public @NonNull Builder setNetworkMetered(@NonNull boolean value) {
765             checkNotUsed();
766             mBuilderFieldsSet |= 0x800;
767             mNetworkMetered = value;
768             return this;
769         }
770 
771         /**
772          * Device metrics value.
773          */
774         @DataClass.Generated.Member
setDeviceMetrics(@onNull DeviceMetrics value)775         public @NonNull Builder setDeviceMetrics(@NonNull DeviceMetrics value) {
776             checkNotUsed();
777             mBuilderFieldsSet |= 0x1000;
778             mDeviceMetrics = value;
779             return this;
780         }
781 
782         /**
783          * The history of installed/uninstalled packages.
784          */
785         @DataClass.Generated.Member
setAppInstalledHistory(@onNull List<AppInstallStatus> value)786         public @NonNull Builder setAppInstalledHistory(@NonNull List<AppInstallStatus> value) {
787             checkNotUsed();
788             mBuilderFieldsSet |= 0x2000;
789             mAppInstalledHistory = value;
790             return this;
791         }
792 
793         /** @see #setAppInstalledHistory */
794         @DataClass.Generated.Member
addAppInstalledHistory(@onNull AppInstallStatus value)795         public @NonNull Builder addAppInstalledHistory(@NonNull AppInstallStatus value) {
796             // You can refine this method's name by providing item's singular name, e.g.:
797             // @DataClass.PluralOf("item")) mItems = ...
798 
799             if (mAppInstalledHistory == null) setAppInstalledHistory(new java.util.ArrayList<>());
800             mAppInstalledHistory.add(value);
801             return this;
802         }
803 
804         /**
805          * The app usage history in the last 30 days, sorted by total time spent.
806          */
807         @DataClass.Generated.Member
setAppUsageHistory(@onNull List<AppUsageStatus> value)808         public @NonNull Builder setAppUsageHistory(@NonNull List<AppUsageStatus> value) {
809             checkNotUsed();
810             mBuilderFieldsSet |= 0x4000;
811             mAppUsageHistory = value;
812             return this;
813         }
814 
815         /** @see #setAppUsageHistory */
816         @DataClass.Generated.Member
addAppUsageHistory(@onNull AppUsageStatus value)817         public @NonNull Builder addAppUsageHistory(@NonNull AppUsageStatus value) {
818             // You can refine this method's name by providing item's singular name, e.g.:
819             // @DataClass.PluralOf("item")) mItems = ...
820 
821             if (mAppUsageHistory == null) setAppUsageHistory(new java.util.ArrayList<>());
822             mAppUsageHistory.add(value);
823             return this;
824         }
825 
826         /**
827          * The most recently known location.
828          */
829         @DataClass.Generated.Member
setCurrentLocation(@onNull Location value)830         public @NonNull Builder setCurrentLocation(@NonNull Location value) {
831             checkNotUsed();
832             mBuilderFieldsSet |= 0x8000;
833             mCurrentLocation = value;
834             return this;
835         }
836 
837         /**
838          * The location history in last 30 days, sorted by the stay duration.
839          */
840         @DataClass.Generated.Member
setLocationHistory(@onNull List<LocationStatus> value)841         public @NonNull Builder setLocationHistory(@NonNull List<LocationStatus> value) {
842             checkNotUsed();
843             mBuilderFieldsSet |= 0x10000;
844             mLocationHistory = value;
845             return this;
846         }
847 
848         /** @see #setLocationHistory */
849         @DataClass.Generated.Member
addLocationHistory(@onNull LocationStatus value)850         public @NonNull Builder addLocationHistory(@NonNull LocationStatus value) {
851             // You can refine this method's name by providing item's singular name, e.g.:
852             // @DataClass.PluralOf("item")) mItems = ...
853 
854             if (mLocationHistory == null) setLocationHistory(new java.util.ArrayList<>());
855             mLocationHistory.add(value);
856             return this;
857         }
858 
859         /** Builds the instance. This builder should not be touched after calling this! */
build()860         public @NonNull UserData build() {
861             checkNotUsed();
862             mBuilderFieldsSet |= 0x20000; // Mark builder used
863 
864             UserData o = new UserData(
865                     mTimeSec,
866                     mTimezone,
867                     mOrientation,
868                     mAvailableBytesMB,
869                     mBatteryPct,
870                     mCountry,
871                     mLanguage,
872                     mCarrier,
873                     mOsVersions,
874                     mConnectionType,
875                     mConnectionSpeedKbps,
876                     mNetworkMetered,
877                     mDeviceMetrics,
878                     mAppInstalledHistory,
879                     mAppUsageHistory,
880                     mCurrentLocation,
881                     mLocationHistory);
882             return o;
883         }
884 
checkNotUsed()885         private void checkNotUsed() {
886             if ((mBuilderFieldsSet & 0x20000) != 0) {
887                 throw new IllegalStateException(
888                         "This Builder should not be reused. Use a new Builder instance instead");
889             }
890         }
891     }
892 
893     @DataClass.Generated(
894             time = 1676499729336L,
895             codegenVersion = "1.0.23",
896             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/UserData.java",
897             inputSignatures = " @android.annotation.NonNull long mTimeSec\n @android.annotation.NonNull int mTimezone\n @android.annotation.NonNull int mOrientation\n @android.annotation.NonNull int mAvailableBytesMB\n @android.annotation.NonNull int mBatteryPct\n @android.annotation.NonNull int mCountry\n @android.annotation.NonNull int mLanguage\n @android.annotation.NonNull int mCarrier\n @android.annotation.NonNull android.ondevicepersonalization.OSVersion mOsVersions\n @android.annotation.NonNull int mConnectionType\n @android.annotation.NonNull int mConnectionSpeedKbps\n @android.annotation.NonNull boolean mNetworkMetered\n @android.annotation.NonNull android.ondevicepersonalization.DeviceMetrics mDeviceMetrics\n @android.annotation.NonNull java.util.List<android.ondevicepersonalization.AppInstallStatus> mAppInstalledHistory\n @android.annotation.NonNull java.util.List<android.ondevicepersonalization.AppUsageStatus> mAppUsageHistory\n @android.annotation.NonNull android.ondevicepersonalization.Location mCurrentLocation\n @android.annotation.NonNull java.util.List<android.ondevicepersonalization.LocationStatus> mLocationHistory\nclass UserData extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
898     @Deprecated
__metadata()899     private void __metadata() {}
900 
901 
902     //@formatter:on
903     // End of generated code
904 
905 }
906