diff options
author | David 'Digit' Turner <digit@google.com> | 2009-06-19 00:36:12 +0200 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2009-06-19 00:36:12 +0200 |
commit | c5b127050f2dbed015d6b01703a33062d6910d4a (patch) | |
tree | 03c81fd16aae63ceca713515a565c702aee35d60 | |
parent | 5998b8947d8c2788b62d38afdd571ddff78648a5 (diff) | |
download | external_qemu-c5b127050f2dbed015d6b01703a33062d6910d4a.zip external_qemu-c5b127050f2dbed015d6b01703a33062d6910d4a.tar.gz external_qemu-c5b127050f2dbed015d6b01703a33062d6910d4a.tar.bz2 |
Add a new hw.lcd.density hardware property to AVD configuration files.
This value can be overriden with the already existing -dpi-device <value> option.
The value is mapped to one of 120,160 and 240, then set to the boot-time property
named qemu.sf.lcd_density used by the framework to properly select assets and/or
resize them at runtime.
This means that "emulator -dpi-device 130" will select 120 lcd_density, or
"emulator -dpi-device 220" will select a 240 one.
-rw-r--r-- | Makefile.android | 1 | ||||
-rw-r--r-- | android/avd/hardware-properties.ini | 7 | ||||
-rw-r--r-- | android/avd/hw-config-defs.h | 7 | ||||
-rw-r--r-- | android/hw-lcd.c | 32 | ||||
-rw-r--r-- | android/hw-lcd.h | 23 | ||||
-rw-r--r-- | android/main.c | 5 |
6 files changed, 74 insertions, 1 deletions
diff --git a/Makefile.android b/Makefile.android index 5330959..2e146cc 100644 --- a/Makefile.android +++ b/Makefile.android @@ -454,6 +454,7 @@ VL_SOURCES := vl.c osdep.c cutils.c \ android/hw-control.c \ android/hw-events.c \ android/hw-kmsg.c \ + android/hw-lcd.c \ android/hw-qemud.c \ android/hw-sensors.c \ android/main.c \ diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini index 60a7493..c655100 100644 --- a/android/avd/hardware-properties.ini +++ b/android/avd/hardware-properties.ini @@ -135,3 +135,10 @@ name = disk.cachePartition.size type = diskSize abstract = Cache partition size default = 66MB + +# LCD density +name = hw.lcd.density +type = integer +default = 160 +abstract = Abstracted LCD density +description = Must be one of 120, 160 or 240. A value used to roughly describe the density of the LCD screen for automatic resource/asset selection. diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h index 3e7cec6..7fcf732 100644 --- a/android/avd/hw-config-defs.h +++ b/android/avd/hw-config-defs.h @@ -136,6 +136,13 @@ HWCFG_DISKSIZE( "Cache partition size", "") +HWCFG_INT( + hw_lcd_density, + "hw.lcd.density", + 160, + "Abstracted LCD density", + "Must be one of 120, 160 or 240. A value used to roughly describe the density of the LCD screen for automatic resource/asset selection.") + #undef HWCFG_INT #undef HWCFG_BOOL #undef HWCFG_DISKSIZE diff --git a/android/hw-lcd.c b/android/hw-lcd.c new file mode 100644 index 0000000..2c06d69 --- /dev/null +++ b/android/hw-lcd.c @@ -0,0 +1,32 @@ +/* Copyright (C) 2009 The Android Open Source Project +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +*/ +#include "android/hw-lcd.h" +#include "android/boot-properties.h" +#include <stdio.h> + +void +hwLcd_setBootProperty(int density) +{ + char temp[8]; + + /* map density to one of our three values for now */ + if (density < (LCD_DENSITY_MIN + LCD_DENSITY_DEFAULT)/2) + density = LCD_DENSITY_MIN; + else if (density < (LCD_DENSITY_DEFAULT + LCD_DENSITY_MAX)/2) + density = LCD_DENSITY_DEFAULT; + else + density = LCD_DENSITY_MAX; + + snprintf(temp, sizeof temp, "%d", density); + boot_property_add("qemu.sf.lcd_density", temp); +} + diff --git a/android/hw-lcd.h b/android/hw-lcd.h new file mode 100644 index 0000000..b9fdb72 --- /dev/null +++ b/android/hw-lcd.h @@ -0,0 +1,23 @@ +/* Copyright (C) 2009 The Android Open Source Project +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +*/ +#ifndef _ANDROID_HW_LCD_H +#define _ANDROID_HW_LCD_H + +#define LCD_DENSITY_MIN 120 +#define LCD_DENSITY_DEFAULT 160 +#define LCD_DENSITY_MAX 240 + +/* Sets the boot property corresponding to the emulated abstract LCD density */ +extern void hwLcd_setBootProperty(int density); + +#endif /* _ANDROID_HW_LCD_H */ + diff --git a/android/main.c b/android/main.c index e90beaa..f93bfa5 100644 --- a/android/main.c +++ b/android/main.c @@ -50,6 +50,7 @@ #include "android/gps.h" #include "android/hw-qemud.h" #include "android/hw-kmsg.h" +#include "android/hw-lcd.h" #include "android/hw-control.h" #include "android/hw-sensors.h" #include "android/boot-properties.h" @@ -393,7 +394,7 @@ qemulator_rotate_keycode( QEmulator* emulator, static int get_device_dpi( AndroidOptions* opts ) { - int dpi_device = DEFAULT_DEVICE_DPI; + int dpi_device = android_hw->hw_lcd_density; if (opts->dpi_device != NULL) { char* end; @@ -2498,6 +2499,8 @@ int main(int argc, char **argv) */ boot_property_init_service(); + hwLcd_setBootProperty(get_device_dpi(opts)); + if (opts->prop != NULL) { ParamList* pl = opts->prop; for ( ; pl != NULL; pl = pl->next ) { |