Merge change 4565 into donut
* changes: Allow the qemu.sf.lcd_density property to override the value of ro.sf.lcd_density
This commit is contained in:
@@ -37,8 +37,7 @@ public class DisplayMetrics {
|
|||||||
* The device's density.
|
* The device's density.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public static final int DEVICE_DENSITY = SystemProperties.getInt("ro.sf.lcd_density",
|
public static final int DEVICE_DENSITY = getDeviceDensity();
|
||||||
DEFAULT_DENSITY);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The absolute width of the display in pixels.
|
* The absolute width of the display in pixels.
|
||||||
@@ -161,4 +160,13 @@ public class DisplayMetrics {
|
|||||||
", height=" + heightPixels + ", scaledDensity=" + scaledDensity +
|
", height=" + heightPixels + ", scaledDensity=" + scaledDensity +
|
||||||
", xdpi=" + xdpi + ", ydpi=" + ydpi + "}";
|
", xdpi=" + xdpi + ", ydpi=" + ydpi + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static int getDeviceDensity() {
|
||||||
|
// qemu.sf.lcd_density can be used to override ro.sf.lcd_density
|
||||||
|
// when running in the emulator, allowing for dynamic configurations.
|
||||||
|
// The reason for this is that ro.sf.lcd_density is write-once and is
|
||||||
|
// set by the init process when it parses build.prop before anything else.
|
||||||
|
return SystemProperties.getInt("qemu.sf.lcd_density",
|
||||||
|
SystemProperties.getInt("ro.sf.lcd_density", DEFAULT_DENSITY));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -193,6 +193,14 @@ void DisplayHardware::init(uint32_t dpy)
|
|||||||
LOGW("ro.sf.lcd_density not defined, using 160 dpi by default.");
|
LOGW("ro.sf.lcd_density not defined, using 160 dpi by default.");
|
||||||
strcpy(property, "160");
|
strcpy(property, "160");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Override the property value if qemu.sf.lcd_density is defined. */
|
||||||
|
{
|
||||||
|
char qemu_property[PROPERTY_VALUE_MAX];
|
||||||
|
if (property_get("qemu.sf.lcd_density", qemu_property, NULL) > 0) {
|
||||||
|
strlcpy(property, qemu_property, sizeof property);
|
||||||
|
}
|
||||||
|
}
|
||||||
mDensity = atoi(property) * (1.0f/160.0f);
|
mDensity = atoi(property) * (1.0f/160.0f);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user