android的工程里查看这个文件,hw-lcd.c,代码如下:
hwLcd_setBootProperty(int density)
{
char temp[8];
/* Map density to one of our five bucket values.
The TV density is a bit particular (and not actually a bucket
value) so we do only exact match on it.
*/
if (density != LCD_DENSITY_TVDPI) {
if (density < (LCD_DENSITY_LDPI + LCD_DENSITY_MDPI)/2)
density = LCD_DENSITY_LDPI;
else if (density < (LCD_DENSITY_MDPI + LCD_DENSITY_HDPI)/2)
density = LCD_DENSITY_MDPI;
else if (density < (LCD_DENSITY_HDPI + LCD_DENSITY_XHDPI)/2)
density = LCD_DENSITY_HDPI;
else
density = LCD_DENSITY_XHDPI;
}
snprintf(temp, sizeof temp, "%d", density);
boot_property_add("qemu.sf.lcd_density", temp);
}
其中对应的头文件标记如下:
#ifndef _ANDROID_HW_LCD_H
#define _ANDROID_HW_LCD_H
#define LCD_DENSITY_LDPI 120
#define LCD_DENSITY_MDPI 160
#define LCD_DENSITY_TVDPI 213
#define LCD_DENSITY_HDPI 240
#define LCD_DENSITY_XHDPI 320
/* Sets the boot property corresponding to the emulated abstract LCD density */
extern void hwLcd_setBootProperty(int density);
#endif /* _ANDROID_HW_LCD_H */
也就是说给出的密度值如果不在这个范围,系统会强制给你修改为可定义的值里面。