summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Piotr Wilczyński <wilczynskip@google.com> 2023-07-04 14:33:41 +0000
committer Piotr Wilczyński <wilczynskip@google.com> 2023-07-04 14:33:41 +0000
commit5884a2e8dd68743a063f451228c14fa3402e876a (patch)
treef490655bd74319fba69446701e9e543bd3abee01
parent6560ff1e95f1bb82907eda61c34e0e6a291b8faf (diff)
IntDef for DisplayMetrics.DENSITY_*
Bug: 281755142 Test: It builds without errors. Change-Id: I77f0a1ff426229f60e95a7e7ff1353973d8019e0
-rwxr-xr-xcore/java/android/util/DisplayMetrics.java34
1 files changed, 34 insertions, 0 deletions
diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java
index 795500aef103..9148c4a101d7 100755
--- a/core/java/android/util/DisplayMetrics.java
+++ b/core/java/android/util/DisplayMetrics.java
@@ -16,12 +16,16 @@
package android.util;
+import android.annotation.IntDef;
import android.annotation.Nullable;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.res.FontScaleConverter;
import android.os.SystemProperties;
import android.view.WindowManager;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
/**
* A structure describing general information about a display, such as its
* size, density, and font scaling.
@@ -39,6 +43,35 @@ import android.view.WindowManager;
*
*/
public class DisplayMetrics {
+
+ @IntDef(prefix = { "DENSITY_" }, value = {
+ DENSITY_LOW,
+ DENSITY_140,
+ DENSITY_MEDIUM,
+ DENSITY_180,
+ DENSITY_200,
+ DENSITY_TV,
+ DENSITY_220,
+ DENSITY_HIGH,
+ DENSITY_260,
+ DENSITY_280,
+ DENSITY_300,
+ DENSITY_XHIGH,
+ DENSITY_340,
+ DENSITY_360,
+ DENSITY_400,
+ DENSITY_420,
+ DENSITY_440,
+ DENSITY_450,
+ DENSITY_XXHIGH,
+ DENSITY_520,
+ DENSITY_560,
+ DENSITY_600,
+ DENSITY_XXXHIGH,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @interface DensityDpi{}
+
/**
* Standard quantized DPI for low-density screens.
*/
@@ -282,6 +315,7 @@ public class DisplayMetrics {
* versions may be backported to previous Android versions, so applications
* should not strongly rely on density matching one of the enum constants.
*/
+ @DensityDpi
public int densityDpi;
/**
* A scaling factor for fonts displayed on the display. This is the same