From 7efe08a2fac5de0c3e140de4a1f97e21355f150c Mon Sep 17 00:00:00 2001 From: Kriti Dang Date: Wed, 31 Mar 2021 17:33:32 +0200 Subject: [PATCH] add int range on #getManufactureYear and #getManufactureWeek in DeviceProductInfo Bug: 182914930 Test: N/A Change-Id: I1988690c135d8357f6ed55958d2977836006d12f --- core/api/current.txt | 6 +++--- core/java/android/hardware/display/DeviceProductInfo.java | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/api/current.txt b/core/api/current.txt index a30191ce63a76..cf5fc41f959f9 100644 --- a/core/api/current.txt +++ b/core/api/current.txt @@ -18823,10 +18823,10 @@ package android.hardware.display { public final class DeviceProductInfo implements android.os.Parcelable { method public int describeContents(); method public int getConnectionToSinkType(); - method public int getManufactureWeek(); - method public int getManufactureYear(); + method @IntRange(from=0xffffffff, to=53) public int getManufactureWeek(); + method @IntRange(from=0xffffffff) public int getManufactureYear(); method @NonNull public String getManufacturerPnpId(); - method public int getModelYear(); + method @IntRange(from=0xffffffff) public int getModelYear(); method @Nullable public String getName(); method @NonNull public String getProductId(); method public void writeToParcel(@NonNull android.os.Parcel, int); diff --git a/core/java/android/hardware/display/DeviceProductInfo.java b/core/java/android/hardware/display/DeviceProductInfo.java index 9457d8f1aac47..11c426aa6734e 100644 --- a/core/java/android/hardware/display/DeviceProductInfo.java +++ b/core/java/android/hardware/display/DeviceProductInfo.java @@ -17,6 +17,7 @@ package android.hardware.display; import android.annotation.IntDef; +import android.annotation.IntRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.os.Parcel; @@ -118,6 +119,7 @@ public final class DeviceProductInfo implements Parcelable { * @return Model year of the device. Return -1 if not available. Typically, * one of model year or manufacture year is available. */ + @IntRange(from = -1) public int getModelYear() { return mModelYear != null ? mModelYear : -1; } @@ -126,6 +128,7 @@ public final class DeviceProductInfo implements Parcelable { * @return The year of manufacture, or -1 it is not available. Typically, * one of model year or manufacture year is available. */ + @IntRange(from = -1) public int getManufactureYear() { if (mManufactureDate == null) { return -1; @@ -134,9 +137,10 @@ public final class DeviceProductInfo implements Parcelable { } /** - * @return The week of manufacture, or -1 it is not available. Typically, - * not present if model year is available. + * @return The week of manufacture which ranges from 1 to 53, or -1 it is not available. + * Typically, it is not present if model year is available. */ + @IntRange(from = -1, to = 53) public int getManufactureWeek() { if (mManufactureDate == null) { return -1;