diff --git a/api/current.txt b/api/current.txt index 537ae8a7ec709..c2b0f220b0178 100644 --- a/api/current.txt +++ b/api/current.txt @@ -39885,6 +39885,7 @@ package android.util { field public static final int DENSITY_420 = 420; // 0x1a4 field public static final int DENSITY_560 = 560; // 0x230 field public static final int DENSITY_DEFAULT = 160; // 0xa0 + field public static final int DENSITY_DEVICE_STABLE; field public static final int DENSITY_HIGH = 240; // 0xf0 field public static final int DENSITY_LOW = 120; // 0x78 field public static final int DENSITY_MEDIUM = 160; // 0xa0 diff --git a/api/system-current.txt b/api/system-current.txt index 1091ff13c4356..7a79aa56a44cd 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -42302,6 +42302,7 @@ package android.util { field public static final int DENSITY_420 = 420; // 0x1a4 field public static final int DENSITY_560 = 560; // 0x230 field public static final int DENSITY_DEFAULT = 160; // 0xa0 + field public static final int DENSITY_DEVICE_STABLE; field public static final int DENSITY_HIGH = 240; // 0xf0 field public static final int DENSITY_LOW = 120; // 0x78 field public static final int DENSITY_MEDIUM = 160; // 0xa0 diff --git a/api/test-current.txt b/api/test-current.txt index 09a9ccac57792..a49d0f378d0bd 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -39902,6 +39902,7 @@ package android.util { field public static final int DENSITY_420 = 420; // 0x1a4 field public static final int DENSITY_560 = 560; // 0x230 field public static final int DENSITY_DEFAULT = 160; // 0xa0 + field public static final int DENSITY_DEVICE_STABLE; field public static final int DENSITY_HIGH = 240; // 0xf0 field public static final int DENSITY_LOW = 120; // 0x78 field public static final int DENSITY_MEDIUM = 160; // 0xa0 diff --git a/core/java/android/util/DisplayMetrics.java b/core/java/android/util/DisplayMetrics.java index 9a69600544db7..a747f163fdca7 100644 --- a/core/java/android/util/DisplayMetrics.java +++ b/core/java/android/util/DisplayMetrics.java @@ -131,15 +131,28 @@ public class DisplayMetrics { public static final float DENSITY_DEFAULT_SCALE = 1.0f / DENSITY_DEFAULT; /** - * The device's density. - * @hide because eventually this should be able to change while - * running, so shouldn't be a constant. - * @deprecated There is no longer a static density; you can find the - * density for a display in {@link #densityDpi}. + * The device's current density. + *
+ * This value reflects any changes made to the device density. To obtain + * the device's stable density, use {@link #DENSITY_DEVICE_STABLE}. + * + * @hide This value should not be used. + * @deprecated Use {@link #DENSITY_DEVICE_STABLE} to obtain the stable + * device density or {@link #densityDpi} to obtain the current + * density for a specific display. */ @Deprecated public static int DENSITY_DEVICE = getDeviceDensity(); + /** + * The device's stable density. + *
+ * This value is constant at run time and may not reflect the current + * display density. To obtain the current density for a specific display, + * use {@link #densityDpi}. + */ + public static final int DENSITY_DEVICE_STABLE = getDeviceDensity(); + /** * The absolute width of the display in pixels. */