• 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 /**
26  * Most recently known location info.
27  *
28  * @hide
29  */
30 @DataClass(genBuilder = true, genEqualsHashCode = true)
31 public final class Location implements Parcelable {
32     /** Timestamp of when this location is collected. */
33     @NonNull long mTimeSec;
34 
35     /** Location latitude with E4 precision. */
36     @NonNull double mLatitude;
37 
38     /** Location longitude with E4 precision. */
39     @NonNull double mLongitude;
40 
41     /** Location provider. See full list {@link LocationInfo.LocationProvider}. */
42     @NonNull int mLocationProvider;
43 
44     /** Whether the location source is precise. */
45     @NonNull boolean mPreciseLocation;
46 
47 
48 
49     // Code below generated by codegen v1.0.23.
50     //
51     // DO NOT MODIFY!
52     // CHECKSTYLE:OFF Generated code
53     //
54     // To regenerate run:
55     // $ codegen $ANDROID_BUILD_TOP/packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/Location.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 
62     @DataClass.Generated.Member
Location( @onNull long timeSec, @NonNull double latitude, @NonNull double longitude, @NonNull int locationProvider, @NonNull boolean preciseLocation)63     /* package-private */ Location(
64             @NonNull long timeSec,
65             @NonNull double latitude,
66             @NonNull double longitude,
67             @NonNull int locationProvider,
68             @NonNull boolean preciseLocation) {
69         this.mTimeSec = timeSec;
70         AnnotationValidations.validate(
71                 NonNull.class, null, mTimeSec);
72         this.mLatitude = latitude;
73         AnnotationValidations.validate(
74                 NonNull.class, null, mLatitude);
75         this.mLongitude = longitude;
76         AnnotationValidations.validate(
77                 NonNull.class, null, mLongitude);
78         this.mLocationProvider = locationProvider;
79         AnnotationValidations.validate(
80                 NonNull.class, null, mLocationProvider);
81         this.mPreciseLocation = preciseLocation;
82         AnnotationValidations.validate(
83                 NonNull.class, null, mPreciseLocation);
84 
85         // onConstructed(); // You can define this method to get a callback
86     }
87 
88     /**
89      * Timestamp of when this location is collected.
90      */
91     @DataClass.Generated.Member
getTimeSec()92     public @NonNull long getTimeSec() {
93         return mTimeSec;
94     }
95 
96     /**
97      * Location latitude with E4 precision.
98      */
99     @DataClass.Generated.Member
getLatitude()100     public @NonNull double getLatitude() {
101         return mLatitude;
102     }
103 
104     /**
105      * Location longitude with E4 precision.
106      */
107     @DataClass.Generated.Member
getLongitude()108     public @NonNull double getLongitude() {
109         return mLongitude;
110     }
111 
112     /**
113      * Location provider. See full list {@link LocationInfo.LocationProvider}.
114      */
115     @DataClass.Generated.Member
getLocationProvider()116     public @NonNull int getLocationProvider() {
117         return mLocationProvider;
118     }
119 
120     /**
121      * Whether the location source is precise.
122      */
123     @DataClass.Generated.Member
isPreciseLocation()124     public @NonNull boolean isPreciseLocation() {
125         return mPreciseLocation;
126     }
127 
128     @Override
129     @DataClass.Generated.Member
equals(@ndroid.annotation.Nullable Object o)130     public boolean equals(@android.annotation.Nullable Object o) {
131         // You can override field equality logic by defining either of the methods like:
132         // boolean fieldNameEquals(Location other) { ... }
133         // boolean fieldNameEquals(FieldType otherValue) { ... }
134 
135         if (this == o) return true;
136         if (o == null || getClass() != o.getClass()) return false;
137         @SuppressWarnings("unchecked")
138         Location that = (Location) o;
139         //noinspection PointlessBooleanExpression
140         return true
141                 && mTimeSec == that.mTimeSec
142                 && mLatitude == that.mLatitude
143                 && mLongitude == that.mLongitude
144                 && mLocationProvider == that.mLocationProvider
145                 && mPreciseLocation == that.mPreciseLocation;
146     }
147 
148     @Override
149     @DataClass.Generated.Member
hashCode()150     public int hashCode() {
151         // You can override field hashCode logic by defining methods like:
152         // int fieldNameHashCode() { ... }
153 
154         int _hash = 1;
155         _hash = 31 * _hash + Long.hashCode(mTimeSec);
156         _hash = 31 * _hash + Double.hashCode(mLatitude);
157         _hash = 31 * _hash + Double.hashCode(mLongitude);
158         _hash = 31 * _hash + mLocationProvider;
159         _hash = 31 * _hash + Boolean.hashCode(mPreciseLocation);
160         return _hash;
161     }
162 
163     @Override
164     @DataClass.Generated.Member
writeToParcel(@onNull android.os.Parcel dest, int flags)165     public void writeToParcel(@NonNull android.os.Parcel dest, int flags) {
166         // You can override field parcelling by defining methods like:
167         // void parcelFieldName(Parcel dest, int flags) { ... }
168 
169         byte flg = 0;
170         if (mPreciseLocation) flg |= 0x10;
171         dest.writeByte(flg);
172         dest.writeLong(mTimeSec);
173         dest.writeDouble(mLatitude);
174         dest.writeDouble(mLongitude);
175         dest.writeInt(mLocationProvider);
176     }
177 
178     @Override
179     @DataClass.Generated.Member
describeContents()180     public int describeContents() { return 0; }
181 
182     /** @hide */
183     @SuppressWarnings({"unchecked", "RedundantCast"})
184     @DataClass.Generated.Member
Location(@onNull android.os.Parcel in)185     /* package-private */ Location(@NonNull android.os.Parcel in) {
186         // You can override field unparcelling by defining methods like:
187         // static FieldType unparcelFieldName(Parcel in) { ... }
188 
189         byte flg = in.readByte();
190         boolean preciseLocation = (flg & 0x10) != 0;
191         long timeSec = in.readLong();
192         double latitude = in.readDouble();
193         double longitude = in.readDouble();
194         int locationProvider = in.readInt();
195 
196         this.mTimeSec = timeSec;
197         AnnotationValidations.validate(
198                 NonNull.class, null, mTimeSec);
199         this.mLatitude = latitude;
200         AnnotationValidations.validate(
201                 NonNull.class, null, mLatitude);
202         this.mLongitude = longitude;
203         AnnotationValidations.validate(
204                 NonNull.class, null, mLongitude);
205         this.mLocationProvider = locationProvider;
206         AnnotationValidations.validate(
207                 NonNull.class, null, mLocationProvider);
208         this.mPreciseLocation = preciseLocation;
209         AnnotationValidations.validate(
210                 NonNull.class, null, mPreciseLocation);
211 
212         // onConstructed(); // You can define this method to get a callback
213     }
214 
215     @DataClass.Generated.Member
216     public static final @NonNull Parcelable.Creator<Location> CREATOR
217             = new Parcelable.Creator<Location>() {
218         @Override
219         public Location[] newArray(int size) {
220             return new Location[size];
221         }
222 
223         @Override
224         public Location createFromParcel(@NonNull android.os.Parcel in) {
225             return new Location(in);
226         }
227     };
228 
229     /**
230      * A builder for {@link Location}
231      */
232     @SuppressWarnings("WeakerAccess")
233     @DataClass.Generated.Member
234     public static final class Builder {
235 
236         private @NonNull long mTimeSec;
237         private @NonNull double mLatitude;
238         private @NonNull double mLongitude;
239         private @NonNull int mLocationProvider;
240         private @NonNull boolean mPreciseLocation;
241 
242         private long mBuilderFieldsSet = 0L;
243 
244         /**
245          * Creates a new Builder.
246          *
247          * @param timeSec
248          *   Timestamp of when this location is collected.
249          * @param latitude
250          *   Location latitude with E4 precision.
251          * @param longitude
252          *   Location longitude with E4 precision.
253          * @param locationProvider
254          *   Location provider. See full list {@link LocationInfo.LocationProvider}.
255          * @param preciseLocation
256          *   Whether the location source is precise.
257          */
Builder( @onNull long timeSec, @NonNull double latitude, @NonNull double longitude, @NonNull int locationProvider, @NonNull boolean preciseLocation)258         public Builder(
259                 @NonNull long timeSec,
260                 @NonNull double latitude,
261                 @NonNull double longitude,
262                 @NonNull int locationProvider,
263                 @NonNull boolean preciseLocation) {
264             mTimeSec = timeSec;
265             AnnotationValidations.validate(
266                     NonNull.class, null, mTimeSec);
267             mLatitude = latitude;
268             AnnotationValidations.validate(
269                     NonNull.class, null, mLatitude);
270             mLongitude = longitude;
271             AnnotationValidations.validate(
272                     NonNull.class, null, mLongitude);
273             mLocationProvider = locationProvider;
274             AnnotationValidations.validate(
275                     NonNull.class, null, mLocationProvider);
276             mPreciseLocation = preciseLocation;
277             AnnotationValidations.validate(
278                     NonNull.class, null, mPreciseLocation);
279         }
280 
Builder()281         public Builder() {
282         }
283 
284         /**
285          * Timestamp of when this location is collected.
286          */
287         @DataClass.Generated.Member
setTimeSec(@onNull long value)288         public @NonNull Builder setTimeSec(@NonNull long value) {
289             checkNotUsed();
290             mBuilderFieldsSet |= 0x1;
291             mTimeSec = value;
292             return this;
293         }
294 
295         /**
296          * Location latitude with E4 precision.
297          */
298         @DataClass.Generated.Member
setLatitude(@onNull double value)299         public @NonNull Builder setLatitude(@NonNull double value) {
300             checkNotUsed();
301             mBuilderFieldsSet |= 0x2;
302             mLatitude = value;
303             return this;
304         }
305 
306         /**
307          * Location longitude with E4 precision.
308          */
309         @DataClass.Generated.Member
setLongitude(@onNull double value)310         public @NonNull Builder setLongitude(@NonNull double value) {
311             checkNotUsed();
312             mBuilderFieldsSet |= 0x4;
313             mLongitude = value;
314             return this;
315         }
316 
317         /**
318          * Location provider. See full list {@link LocationInfo.LocationProvider}.
319          */
320         @DataClass.Generated.Member
setLocationProvider(@onNull int value)321         public @NonNull Builder setLocationProvider(@NonNull int value) {
322             checkNotUsed();
323             mBuilderFieldsSet |= 0x8;
324             mLocationProvider = value;
325             return this;
326         }
327 
328         /**
329          * Whether the location source is precise.
330          */
331         @DataClass.Generated.Member
setPreciseLocation(@onNull boolean value)332         public @NonNull Builder setPreciseLocation(@NonNull boolean value) {
333             checkNotUsed();
334             mBuilderFieldsSet |= 0x10;
335             mPreciseLocation = value;
336             return this;
337         }
338 
339         /** Builds the instance. This builder should not be touched after calling this! */
build()340         public @NonNull Location build() {
341             checkNotUsed();
342             mBuilderFieldsSet |= 0x20; // Mark builder used
343 
344             Location o = new Location(
345                     mTimeSec,
346                     mLatitude,
347                     mLongitude,
348                     mLocationProvider,
349                     mPreciseLocation);
350             return o;
351         }
352 
checkNotUsed()353         private void checkNotUsed() {
354             if ((mBuilderFieldsSet & 0x20) != 0) {
355                 throw new IllegalStateException(
356                         "This Builder should not be reused. Use a new Builder instance instead");
357             }
358         }
359     }
360 
361     @DataClass.Generated(
362             time = 1676500006486L,
363             codegenVersion = "1.0.23",
364             sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/Location.java",
365             inputSignatures = " @android.annotation.NonNull long mTimeSec\n @android.annotation.NonNull double mLatitude\n @android.annotation.NonNull double mLongitude\n @android.annotation.NonNull int mLocationProvider\n @android.annotation.NonNull boolean mPreciseLocation\nclass Location extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)")
366     @Deprecated
__metadata()367     private void __metadata() {}
368 
369 
370     //@formatter:on
371     // End of generated code
372 
373 }
374