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 * Device metrics class for static values per device. 27 * 28 * @hide 29 */ 30 @DataClass(genBuilder = true, genEqualsHashCode = true) 31 public final class DeviceMetrics implements Parcelable { 32 /** Device manufacturer. See full list {@link Make}. */ 33 @NonNull int mMake; 34 35 /** Device model. See full list {@link Model}. */ 36 @NonNull int mModel; 37 38 /** Screen height of the device in dp units. */ 39 @NonNull int mScreenHeights; 40 41 /** Screen width of the device in dp units. */ 42 @NonNull int mScreenWidth; 43 44 /** Device x dpi. */ 45 @NonNull float mXdpi; 46 47 /** Device y dpi. */ 48 @NonNull float mYdpi; 49 50 /** Device pixel ratio. */ 51 @NonNull float mPxRatio; 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/ondevicepersonalization/DeviceMetrics.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 @DataClass.Generated.Member DeviceMetrics( @onNull int make, @NonNull int model, @NonNull int screenHeights, @NonNull int screenWidth, @NonNull float xdpi, @NonNull float ydpi, @NonNull float pxRatio)69 /* package-private */ DeviceMetrics( 70 @NonNull int make, 71 @NonNull int model, 72 @NonNull int screenHeights, 73 @NonNull int screenWidth, 74 @NonNull float xdpi, 75 @NonNull float ydpi, 76 @NonNull float pxRatio) { 77 this.mMake = make; 78 AnnotationValidations.validate( 79 NonNull.class, null, mMake); 80 this.mModel = model; 81 AnnotationValidations.validate( 82 NonNull.class, null, mModel); 83 this.mScreenHeights = screenHeights; 84 AnnotationValidations.validate( 85 NonNull.class, null, mScreenHeights); 86 this.mScreenWidth = screenWidth; 87 AnnotationValidations.validate( 88 NonNull.class, null, mScreenWidth); 89 this.mXdpi = xdpi; 90 AnnotationValidations.validate( 91 NonNull.class, null, mXdpi); 92 this.mYdpi = ydpi; 93 AnnotationValidations.validate( 94 NonNull.class, null, mYdpi); 95 this.mPxRatio = pxRatio; 96 AnnotationValidations.validate( 97 NonNull.class, null, mPxRatio); 98 99 // onConstructed(); // You can define this method to get a callback 100 } 101 102 /** 103 * Device manufacturer. See full list {@link Make}. 104 */ 105 @DataClass.Generated.Member getMake()106 public @NonNull int getMake() { 107 return mMake; 108 } 109 110 /** 111 * Device model. See full list {@link Model}. 112 */ 113 @DataClass.Generated.Member getModel()114 public @NonNull int getModel() { 115 return mModel; 116 } 117 118 /** 119 * Screen height of the device in dp units. 120 */ 121 @DataClass.Generated.Member getScreenHeights()122 public @NonNull int getScreenHeights() { 123 return mScreenHeights; 124 } 125 126 /** 127 * Screen width of the device in dp units. 128 */ 129 @DataClass.Generated.Member getScreenWidth()130 public @NonNull int getScreenWidth() { 131 return mScreenWidth; 132 } 133 134 /** 135 * Device x dpi. 136 */ 137 @DataClass.Generated.Member getXdpi()138 public @NonNull float getXdpi() { 139 return mXdpi; 140 } 141 142 /** 143 * Device y dpi. 144 */ 145 @DataClass.Generated.Member getYdpi()146 public @NonNull float getYdpi() { 147 return mYdpi; 148 } 149 150 /** 151 * Device pixel ratio. 152 */ 153 @DataClass.Generated.Member getPxRatio()154 public @NonNull float getPxRatio() { 155 return mPxRatio; 156 } 157 158 @Override 159 @DataClass.Generated.Member equals(@ndroid.annotation.Nullable Object o)160 public boolean equals(@android.annotation.Nullable Object o) { 161 // You can override field equality logic by defining either of the methods like: 162 // boolean fieldNameEquals(DeviceMetrics other) { ... } 163 // boolean fieldNameEquals(FieldType otherValue) { ... } 164 165 if (this == o) return true; 166 if (o == null || getClass() != o.getClass()) return false; 167 @SuppressWarnings("unchecked") 168 DeviceMetrics that = (DeviceMetrics) o; 169 //noinspection PointlessBooleanExpression 170 return true 171 && mMake == that.mMake 172 && mModel == that.mModel 173 && mScreenHeights == that.mScreenHeights 174 && mScreenWidth == that.mScreenWidth 175 && mXdpi == that.mXdpi 176 && mYdpi == that.mYdpi 177 && mPxRatio == that.mPxRatio; 178 } 179 180 @Override 181 @DataClass.Generated.Member hashCode()182 public int hashCode() { 183 // You can override field hashCode logic by defining methods like: 184 // int fieldNameHashCode() { ... } 185 186 int _hash = 1; 187 _hash = 31 * _hash + mMake; 188 _hash = 31 * _hash + mModel; 189 _hash = 31 * _hash + mScreenHeights; 190 _hash = 31 * _hash + mScreenWidth; 191 _hash = 31 * _hash + Float.hashCode(mXdpi); 192 _hash = 31 * _hash + Float.hashCode(mYdpi); 193 _hash = 31 * _hash + Float.hashCode(mPxRatio); 194 return _hash; 195 } 196 197 @Override 198 @DataClass.Generated.Member writeToParcel(@onNull android.os.Parcel dest, int flags)199 public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { 200 // You can override field parcelling by defining methods like: 201 // void parcelFieldName(Parcel dest, int flags) { ... } 202 203 dest.writeInt(mMake); 204 dest.writeInt(mModel); 205 dest.writeInt(mScreenHeights); 206 dest.writeInt(mScreenWidth); 207 dest.writeFloat(mXdpi); 208 dest.writeFloat(mYdpi); 209 dest.writeFloat(mPxRatio); 210 } 211 212 @Override 213 @DataClass.Generated.Member describeContents()214 public int describeContents() { return 0; } 215 216 /** @hide */ 217 @SuppressWarnings({"unchecked", "RedundantCast"}) 218 @DataClass.Generated.Member DeviceMetrics(@onNull android.os.Parcel in)219 /* package-private */ DeviceMetrics(@NonNull android.os.Parcel in) { 220 // You can override field unparcelling by defining methods like: 221 // static FieldType unparcelFieldName(Parcel in) { ... } 222 223 int make = in.readInt(); 224 int model = in.readInt(); 225 int screenHeights = in.readInt(); 226 int screenWidth = in.readInt(); 227 float xdpi = in.readFloat(); 228 float ydpi = in.readFloat(); 229 float pxRatio = in.readFloat(); 230 231 this.mMake = make; 232 AnnotationValidations.validate( 233 NonNull.class, null, mMake); 234 this.mModel = model; 235 AnnotationValidations.validate( 236 NonNull.class, null, mModel); 237 this.mScreenHeights = screenHeights; 238 AnnotationValidations.validate( 239 NonNull.class, null, mScreenHeights); 240 this.mScreenWidth = screenWidth; 241 AnnotationValidations.validate( 242 NonNull.class, null, mScreenWidth); 243 this.mXdpi = xdpi; 244 AnnotationValidations.validate( 245 NonNull.class, null, mXdpi); 246 this.mYdpi = ydpi; 247 AnnotationValidations.validate( 248 NonNull.class, null, mYdpi); 249 this.mPxRatio = pxRatio; 250 AnnotationValidations.validate( 251 NonNull.class, null, mPxRatio); 252 253 // onConstructed(); // You can define this method to get a callback 254 } 255 256 @DataClass.Generated.Member 257 public static final @NonNull Parcelable.Creator<DeviceMetrics> CREATOR 258 = new Parcelable.Creator<DeviceMetrics>() { 259 @Override 260 public DeviceMetrics[] newArray(int size) { 261 return new DeviceMetrics[size]; 262 } 263 264 @Override 265 public DeviceMetrics createFromParcel(@NonNull android.os.Parcel in) { 266 return new DeviceMetrics(in); 267 } 268 }; 269 270 /** 271 * A builder for {@link DeviceMetrics} 272 */ 273 @SuppressWarnings("WeakerAccess") 274 @DataClass.Generated.Member 275 public static final class Builder { 276 277 private @NonNull int mMake; 278 private @NonNull int mModel; 279 private @NonNull int mScreenHeights; 280 private @NonNull int mScreenWidth; 281 private @NonNull float mXdpi; 282 private @NonNull float mYdpi; 283 private @NonNull float mPxRatio; 284 285 private long mBuilderFieldsSet = 0L; 286 287 /** 288 * Creates a new Builder. 289 * 290 * @param make 291 * Device manufacturer. See full list {@link Make}. 292 * @param model 293 * Device model. See full list {@link Model}. 294 * @param screenHeights 295 * Screen height of the device in dp units. 296 * @param screenWidth 297 * Screen width of the device in dp units. 298 * @param xdpi 299 * Device x dpi. 300 * @param ydpi 301 * Device y dpi. 302 * @param pxRatio 303 * Device pixel ratio. 304 */ Builder( @onNull int make, @NonNull int model, @NonNull int screenHeights, @NonNull int screenWidth, @NonNull float xdpi, @NonNull float ydpi, @NonNull float pxRatio)305 public Builder( 306 @NonNull int make, 307 @NonNull int model, 308 @NonNull int screenHeights, 309 @NonNull int screenWidth, 310 @NonNull float xdpi, 311 @NonNull float ydpi, 312 @NonNull float pxRatio) { 313 mMake = make; 314 AnnotationValidations.validate( 315 NonNull.class, null, mMake); 316 mModel = model; 317 AnnotationValidations.validate( 318 NonNull.class, null, mModel); 319 mScreenHeights = screenHeights; 320 AnnotationValidations.validate( 321 NonNull.class, null, mScreenHeights); 322 mScreenWidth = screenWidth; 323 AnnotationValidations.validate( 324 NonNull.class, null, mScreenWidth); 325 mXdpi = xdpi; 326 AnnotationValidations.validate( 327 NonNull.class, null, mXdpi); 328 mYdpi = ydpi; 329 AnnotationValidations.validate( 330 NonNull.class, null, mYdpi); 331 mPxRatio = pxRatio; 332 AnnotationValidations.validate( 333 NonNull.class, null, mPxRatio); 334 } 335 Builder()336 public Builder() { 337 } 338 339 /** 340 * Device manufacturer. See full list {@link Make}. 341 */ 342 @DataClass.Generated.Member setMake(@onNull int value)343 public @NonNull Builder setMake(@NonNull int value) { 344 checkNotUsed(); 345 mBuilderFieldsSet |= 0x1; 346 mMake = value; 347 return this; 348 } 349 350 /** 351 * Device model. See full list {@link Model}. 352 */ 353 @DataClass.Generated.Member setModel(@onNull int value)354 public @NonNull Builder setModel(@NonNull int value) { 355 checkNotUsed(); 356 mBuilderFieldsSet |= 0x2; 357 mModel = value; 358 return this; 359 } 360 361 /** 362 * Screen height of the device in dp units. 363 */ 364 @DataClass.Generated.Member setScreenHeights(@onNull int value)365 public @NonNull Builder setScreenHeights(@NonNull int value) { 366 checkNotUsed(); 367 mBuilderFieldsSet |= 0x4; 368 mScreenHeights = value; 369 return this; 370 } 371 372 /** 373 * Screen width of the device in dp units. 374 */ 375 @DataClass.Generated.Member setScreenWidth(@onNull int value)376 public @NonNull Builder setScreenWidth(@NonNull int value) { 377 checkNotUsed(); 378 mBuilderFieldsSet |= 0x8; 379 mScreenWidth = value; 380 return this; 381 } 382 383 /** 384 * Device x dpi. 385 */ 386 @DataClass.Generated.Member setXdpi(@onNull float value)387 public @NonNull Builder setXdpi(@NonNull float value) { 388 checkNotUsed(); 389 mBuilderFieldsSet |= 0x10; 390 mXdpi = value; 391 return this; 392 } 393 394 /** 395 * Device y dpi. 396 */ 397 @DataClass.Generated.Member setYdpi(@onNull float value)398 public @NonNull Builder setYdpi(@NonNull float value) { 399 checkNotUsed(); 400 mBuilderFieldsSet |= 0x20; 401 mYdpi = value; 402 return this; 403 } 404 405 /** 406 * Device pixel ratio. 407 */ 408 @DataClass.Generated.Member setPxRatio(@onNull float value)409 public @NonNull Builder setPxRatio(@NonNull float value) { 410 checkNotUsed(); 411 mBuilderFieldsSet |= 0x40; 412 mPxRatio = value; 413 return this; 414 } 415 416 /** Builds the instance. This builder should not be touched after calling this! */ build()417 public @NonNull DeviceMetrics build() { 418 checkNotUsed(); 419 mBuilderFieldsSet |= 0x80; // Mark builder used 420 421 DeviceMetrics o = new DeviceMetrics( 422 mMake, 423 mModel, 424 mScreenHeights, 425 mScreenWidth, 426 mXdpi, 427 mYdpi, 428 mPxRatio); 429 return o; 430 } 431 checkNotUsed()432 private void checkNotUsed() { 433 if ((mBuilderFieldsSet & 0x80) != 0) { 434 throw new IllegalStateException( 435 "This Builder should not be reused. Use a new Builder instance instead"); 436 } 437 } 438 } 439 440 @DataClass.Generated( 441 time = 1676499956776L, 442 codegenVersion = "1.0.23", 443 sourceFile = "packages/modules/OnDevicePersonalization/framework/java/android/ondevicepersonalization/DeviceMetrics.java", 444 inputSignatures = " @android.annotation.NonNull int mMake\n @android.annotation.NonNull int mModel\n @android.annotation.NonNull int mScreenHeights\n @android.annotation.NonNull int mScreenWidth\n @android.annotation.NonNull float mXdpi\n @android.annotation.NonNull float mYdpi\n @android.annotation.NonNull float mPxRatio\nclass DeviceMetrics extends java.lang.Object implements [android.os.Parcelable]\n@com.android.ondevicepersonalization.internal.util.DataClass(genBuilder=true, genEqualsHashCode=true)") 445 @Deprecated __metadata()446 private void __metadata() {} 447 448 449 //@formatter:on 450 // End of generated code 451 452 } 453