diff options
Diffstat (limited to 'android')
-rw-r--r-- | android/avd/hardware-properties.ini | 22 | ||||
-rw-r--r-- | android/avd/hw-config-defs.h | 23 | ||||
-rw-r--r-- | android/avd/info.c | 65 | ||||
-rw-r--r-- | android/avd/info.h | 6 | ||||
-rw-r--r-- | android/main-common.c | 67 | ||||
-rw-r--r-- | android/main-common.h | 2 | ||||
-rw-r--r-- | android/main-ui.c | 55 | ||||
-rw-r--r-- | android/main.c | 59 | ||||
-rw-r--r-- | android/qemulator.c | 2 | ||||
-rw-r--r-- | android/qemulator.h | 4 |
10 files changed, 213 insertions, 92 deletions
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini index 6b106f4..89acf9f 100644 --- a/android/avd/hardware-properties.ini +++ b/android/avd/hardware-properties.ini @@ -24,6 +24,8 @@ # # Ram size +# Default value will be computed based on screen pixels +# or skin version name = hw.ramSize type = integer default = 0 @@ -146,6 +148,23 @@ type = diskSize abstract = Cache partition size default = 66MB +# LCD width +name = hw.lcd.width +type = integer +default = 320 +abstract = LCD pixel width + +name = hw.lcd.height +type = integer +default = 640 +abstract = LCD pixel height + +name = hw.lcd.depth +type = integer +default = 16 +abstract = LCD color depth +description = Must be 16 or 32. Color bit depth of emulated framebuffer. + # LCD density name = hw.lcd.density type = integer @@ -155,9 +174,10 @@ description = Must be one of 120, 160 or 240. A value used to roughly describe t # Maximum VM heap size # Higher values are required for high-dpi devices +# Default will depend on RAM size. name = vm.heapSize type = integer -default = 16 +default = 0 abstract = Max VM application heap size description = The maximum heap size a Dalvik application might allocate before being killed by the system. Value is in megabytes. diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h index 0c87bdb..4afc4d7 100644 --- a/android/avd/hw-config-defs.h +++ b/android/avd/hw-config-defs.h @@ -144,6 +144,27 @@ HWCFG_DISKSIZE( "") HWCFG_INT( + hw_lcd_width, + "hw.lcd.width", + 320, + "LCD pixel width", + "") + +HWCFG_INT( + hw_lcd_height, + "hw.lcd.height", + 640, + "LCD pixel height", + "") + +HWCFG_INT( + hw_lcd_depth, + "hw.lcd.depth", + 16, + "LCD color depth", + "Must be 16 or 32. Color bit depth of emulated framebuffer.") + +HWCFG_INT( hw_lcd_density, "hw.lcd.density", 160, @@ -153,7 +174,7 @@ HWCFG_INT( HWCFG_INT( vm_heapSize, "vm.heapSize", - 16, + 0, "Max VM application heap size", "The maximum heap size a Dalvik application might allocate before being killed by the system. Value is in megabytes.") diff --git a/android/avd/info.c b/android/avd/info.c index 058226c..e3d38bb 100644 --- a/android/avd/info.c +++ b/android/avd/info.c @@ -93,6 +93,12 @@ AvdInfo* android_avdInfo; */ #define SDCARD_PATH "sdcard.path" +/* the name of the .ini file that will contain the complete hardware + * properties for the AVD. This will be used to launch the corresponding + * core from the UI. + */ +#define CORE_HARDWARE_INI "qemu-hardware.ini" + /* certain disk image files are mounted read/write by the emulator * to ensure that several emulators referencing the same files * do not corrupt these files, we need to lock them and respond @@ -134,11 +140,12 @@ struct AvdInfo { char* contentPath; IniFile* rootIni; /* root <foo>.ini file */ IniFile* configIni; /* virtual device's config.ini */ - IniFile* hardwareIni; /* skin-specific hardware.ini */ + IniFile* skinHardwareIni; /* skin-specific hardware.ini */ /* for both */ char* skinName; /* skin name */ char* skinDirPath; /* skin directory */ + char* coreHardwareIniPath; /* core hardware.ini path */ /* image files */ char* imagePath [ AVD_IMAGE_MAX ]; @@ -157,6 +164,7 @@ avdInfo_free( AvdInfo* i ) AFREE(i->skinName); AFREE(i->skinDirPath); + AFREE(i->coreHardwareIniPath); for (nn = 0; nn < i->numSearchPaths; nn++) AFREE(i->searchPaths[nn]); @@ -168,9 +176,9 @@ avdInfo_free( AvdInfo* i ) i->configIni = NULL; } - if (i->hardwareIni) { - iniFile_free(i->hardwareIni); - i->hardwareIni = NULL; + if (i->skinHardwareIni) { + iniFile_free(i->skinHardwareIni); + i->skinHardwareIni = NULL; } if (i->rootIni) { @@ -558,7 +566,7 @@ imageLoader_empty( ImageLoader* l, unsigned flags ) } -/* copy image file from a given source +/* copy image file from a given source * assumes locking is needed. */ static void @@ -606,7 +614,7 @@ imageLoader_load( ImageLoader* l, /* set image state */ l->pState[0] = (flags & IMAGE_DONT_LOCK) == 0 - ? IMAGE_STATE_MUSTLOCK + ? IMAGE_STATE_MUSTLOCK : IMAGE_STATE_READONLY; /* check user-provided path */ @@ -651,7 +659,7 @@ imageLoader_load( ImageLoader* l, if (flags & IMAGE_REQUIRED) { AvdInfo* i = l->info; - derror("could not find required %s image (%s).", + derror("could not find required %s image (%s).", l->imageText, l->imageFile); if (i->inAndroidBuild) { @@ -1088,6 +1096,22 @@ _getSDCardPath( AvdInfo* i, AvdInfoParams* params ) params->forcePaths[AVD_IMAGE_SDCARD] = path; } +static int +_getCoreHwIniPath( AvdInfo* i, const char* basePath ) +{ + char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); + + p = bufprint(temp, end, "%s/%s", basePath, CORE_HARDWARE_INI); + if (p >= end) { + DD("Path too long for %s:", CORE_HARDWARE_INI, basePath); + return -1; + } + + D("using core hw config path: %s", temp); + i->coreHardwareIniPath = ASTRDUP(temp); + return 0; +} + AvdInfo* avdInfo_new( const char* name, AvdInfoParams* params ) { @@ -1107,7 +1131,8 @@ avdInfo_new( const char* name, AvdInfoParams* params ) if ( _getSdkRoot(i) < 0 || _getRootIni(i) < 0 || _getContentPath(i) < 0 || - _getConfigIni(i) < 0 ) + _getConfigIni(i) < 0 || + _getCoreHwIniPath(i, i->contentPath) < 0 ) goto FAIL; /* look for image search paths. handle post 1.1/pre cupcake @@ -1280,7 +1305,7 @@ _getBuildImagePaths( AvdInfo* i, AvdInfoParams* params ) /* if the user provided one cache image, lock & use it */ if ( params->forcePaths[l->id] != NULL ) { - imageLoader_load(l, IMAGE_REQUIRED | + imageLoader_load(l, IMAGE_REQUIRED | IMAGE_IGNORE_IF_LOCKED); } } @@ -1373,7 +1398,7 @@ _getBuildSkin( AvdInfo* i, AvdInfoParams* params ) /* Read a hardware.ini if it is located in the skin directory */ static int -_getBuildHardwareIni( AvdInfo* i ) +_getBuildSkinHardwareIni( AvdInfo* i ) { char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); @@ -1387,14 +1412,13 @@ _getBuildHardwareIni( AvdInfo* i ) } D("found skin-specific hardware.ini: %s", temp); - i->hardwareIni = iniFile_newFromFile(temp); - if (i->hardwareIni == NULL) + i->skinHardwareIni = iniFile_newFromFile(temp); + if (i->skinHardwareIni == NULL) return -1; return 0; } - AvdInfo* avdInfo_newForAndroidBuild( const char* androidBuildRoot, const char* androidOut, @@ -1413,12 +1437,13 @@ avdInfo_newForAndroidBuild( const char* androidBuildRoot, i->deviceName = ASTRDUP("<build>"); if (_getBuildConfigIni(i) < 0 || - _getBuildImagePaths(i, params) < 0 ) + _getBuildImagePaths(i, params) < 0 || + _getCoreHwIniPath(i, i->androidOut) < 0 ) goto FAIL; /* we don't need to fail if there is no valid skin */ _getBuildSkin(i, params); - _getBuildHardwareIni(i); + _getBuildSkinHardwareIni(i); return i; @@ -1492,8 +1517,8 @@ avdInfo_getHwConfig( AvdInfo* i, AndroidHwConfig* hw ) if (ini != i->configIni) iniFile_free(ini); - if (ret == 0 && i->hardwareIni != NULL) { - ret = androidHwConfig_read(hw, i->hardwareIni); + if (ret == 0 && i->skinHardwareIni != NULL) { + ret = androidHwConfig_read(hw, i->skinHardwareIni); } /* special product-specific hardware configuration */ @@ -1539,3 +1564,9 @@ avdInfo_getTracePath( AvdInfo* i, const char* traceName ) } return ASTRDUP(tmp); } + +const char* +avdInfo_getCoreHwIniPath( AvdInfo* i ) +{ + return i->coreHardwareIniPath; +} diff --git a/android/avd/info.h b/android/avd/info.h index 2b2899f..9ccee30 100644 --- a/android/avd/info.h +++ b/android/avd/info.h @@ -183,6 +183,12 @@ int avdInfo_getHwConfig( AvdInfo* i, AndroidHwConfig* hw ); /* Returns a *copy* of the path used to store trace 'foo'. result must be freed by caller */ char* avdInfo_getTracePath( AvdInfo* i, const char* traceName ); +/* Returns the path of the hardware.ini where we will write the AVD's + * complete hardware configuration before launching the corresponding + * core. + */ +const char* avdInfo_getCoreHwIniPath( AvdInfo* i ); + /* */ #endif /* ANDROID_AVD_INFO_H */ diff --git a/android/main-common.c b/android/main-common.c index bb07943..a63983b 100644 --- a/android/main-common.c +++ b/android/main-common.c @@ -341,6 +341,7 @@ void parse_skin_files(const char* skinDirPath, const char* skinName, AndroidOptions* opts, + AndroidHwConfig* hwConfig, AConfig* *skinConfig, char* *skinPath) { @@ -433,6 +434,53 @@ FOUND_SKIN: skin_network_delay = aconfig_str(n, "delay", 0); } + /* extract framebuffer information from the skin. + * + * for version 1 of the skin format, they are in the top-level + * 'display' element. + * + * for version 2 of the skin format, they are under parts.device.display + */ + n = aconfig_find(root, "display"); + if (n == NULL) { + n = aconfig_find(root, "parts"); + if (n != NULL) { + n = aconfig_find(root, "device"); + if (n != NULL) { + n = aconfig_find(root, "display"); + } + } + } + + if (n != NULL) { + int width = aconfig_int(n, "width", hwConfig->hw_lcd_width); + int height = aconfig_int(n, "height", hwConfig->hw_lcd_height); + int depth = aconfig_int(n, "bpp", hwConfig->hw_lcd_depth); + + if (width > 0 && height > 0) { + /* The emulated framebuffer wants sizes that are multiples of 4 */ + if (((width|height) & 3) != 0) { + width = (width+3) & ~3; + height = (height+3) & ~3; + D("adjusting LCD dimensions to (%dx%dx)", width, height); + } + + /* only depth values of 16 and 32 are correct. 16 is the default. */ + if (depth != 32 && depth != 16) { + depth = 16; + D("adjusting LCD bit depth to %d", depth); + } + + hwConfig->hw_lcd_width = width; + hwConfig->hw_lcd_height = height; + hwConfig->hw_lcd_depth = depth; + } + else { + D("ignoring invalid skin LCD dimensions (%dx%dx%d)", + width, height, depth); + } + } + *skinConfig = root; *skinPath = strdup(path); return; @@ -536,22 +584,3 @@ init_sdl_ui(AConfig* skinConfig, qemulator_get()->onion_rotation = rotate; } } - -int64_t get_screen_pixels(AConfig* skinConfig) -{ - int64_t pixels = 0; - AConfig* disp; - - if (skinConfig != NULL) { - disp = aconfig_find(skinConfig, "display"); - if (disp != NULL) { - int width = aconfig_int(disp, "width", 0); - int height = aconfig_int(disp, "height", 0); - pixels = (int64_t)width*height; - } - } - if (pixels == 0) - pixels = 320*240; - - return pixels; -} diff --git a/android/main-common.h b/android/main-common.h index c5131df..88ebb70 100644 --- a/android/main-common.h +++ b/android/main-common.h @@ -16,6 +16,7 @@ #include "android/cmdline-option.h" #include "android/skin/keyset.h" #include "android/config.h" +#include "android/avd/hw-config.h" /* Common routines used by both android/main.c and android/main-ui.c */ @@ -45,6 +46,7 @@ extern const char* skin_network_delay; void parse_skin_files(const char* skinDirPath, const char* skinName, AndroidOptions* opts, + AndroidHwConfig* hwConfig, AConfig* *skinConfig, char* *skinPath); diff --git a/android/main-ui.c b/android/main-ui.c index 273f402..f1f8539 100644 --- a/android/main-ui.c +++ b/android/main-ui.c @@ -490,8 +490,6 @@ int main(int argc, char **argv) char* android_build_out = NULL; AndroidOptions opts[1]; - /* LCD density value to pass to the core. */ - char lcd_density[16]; /* net.shared_net_ip boot property value. */ char boot_prop_ip[64]; boot_prop_ip[0] = '\0'; @@ -876,7 +874,7 @@ int main(int argc, char **argv) user_config_init(); - parse_skin_files(opts->skindir, opts->skin, opts, + parse_skin_files(opts->skindir, opts->skin, opts, hw, &skinConfig, &skinPath); if (!opts->netspeed) { @@ -1257,6 +1255,7 @@ int main(int argc, char **argv) derror( "physical memory size must be between 32 and 4096 MB" ); exit(1); } + hw->hw_ramSize = ramSize; } if (!opts->memory) { int ramSize = hw->hw_ramSize; @@ -1266,8 +1265,7 @@ int main(int argc, char **argv) * size through its hardware.ini (i.e. legacy ones) or when * in the full Android build system. */ - int64_t pixels = get_screen_pixels(skinConfig); - + int64_t pixels = hw->hw_lcd_width * hw->hw_lcd_height; /* The following thresholds are a bit liberal, but we * essentially want to ensure the following mappings: * @@ -1285,8 +1283,30 @@ int main(int argc, char **argv) else ramSize = 256; } - bufprint(tmp, tmpend, "%d", ramSize); - opts->memory = android_strdup(tmp); + hw->hw_ramSize = ramSize; + } + + D("Physical RAM size: %dMB\n", hw->hw_ramSize); + + if (hw->vm_heapSize == 0) { + /* Compute the default heap size based on the RAM size. + * Essentially, we want to ensure the following liberal mappings: + * + * 96MB RAM -> 16MB heap + * 128MB RAM -> 24MB heap + * 256MB RAM -> 48MB heap + */ + int ramSize = hw->hw_ramSize; + int heapSize; + + if (ramSize < 100) + heapSize = 16; + else if (ramSize < 192) + heapSize = 24; + else + heapSize = 48; + + hw->vm_heapSize = heapSize; } if (opts->trace) { @@ -1296,11 +1316,6 @@ int main(int argc, char **argv) args[n++] = "off"; } - /* Pass LCD density value to the core. */ - snprintf(lcd_density, sizeof(lcd_density), "%d", hw->hw_lcd_density); - args[n++] = "-lcd-density"; - args[n++] = lcd_density; - /* Pass boot properties to the core. */ if (opts->prop != NULL) { ParamList* pl = opts->prop; @@ -1465,21 +1480,15 @@ int main(int argc, char **argv) * launch the core with the -android-hw <file> option. */ { - TempFile* tempHw = tempfile_create(); - if (tempHw == NULL) { - derror("Could not create temporary hardware.ini: %s", strerror(errno)); - exit(2); - } - - const char* tempHwPath = tempfile_path(tempHw); - IniFile* hwIni = iniFile_newFromMemory("", NULL); + const char* coreHwIniPath = avdInfo_getCoreHwIniPath(avd); + IniFile* hwIni = iniFile_newFromMemory("", NULL); androidHwConfig_write(hw, hwIni); - if (iniFile_saveToFile(hwIni, tempHwPath) < 0) { - derror("Could not write temporary hardware.ini: %s", tempHwPath); + if (iniFile_saveToFile(hwIni, coreHwIniPath) < 0) { + derror("Could not write hardware.ini to %s: %s", coreHwIniPath, strerror(errno)); exit(2); } args[n++] = "-android-hw"; - args[n++] = strdup(tempHwPath); + args[n++] = strdup(coreHwIniPath); } if(VERBOSE_CHECK(init)) { diff --git a/android/main.c b/android/main.c index 51ef6d7..7a228f0 100644 --- a/android/main.c +++ b/android/main.c @@ -298,8 +298,6 @@ int main(int argc, char **argv) char* android_build_out = NULL; AndroidOptions opts[1]; - /* LCD density value to pass to the core. */ - char lcd_density[16]; /* net.shared_net_ip boot property value. */ char boot_prop_ip[64]; boot_prop_ip[0] = '\0'; @@ -667,7 +665,7 @@ int main(int argc, char **argv) user_config_init(); - parse_skin_files(opts->skindir, opts->skin, opts, + parse_skin_files(opts->skindir, opts->skin, opts, hw, &skinConfig, &skinPath); if (!opts->netspeed) { @@ -1050,6 +1048,7 @@ int main(int argc, char **argv) derror( "physical memory size must be between 32 and 4096 MB" ); exit(1); } + hw->hw_ramSize = ramSize; } if (!opts->memory) { int ramSize = hw->hw_ramSize; @@ -1059,8 +1058,7 @@ int main(int argc, char **argv) * size through its hardware.ini (i.e. legacy ones) or when * in the full Android build system. */ - int64_t pixels = get_screen_pixels(skinConfig); - + int64_t pixels = hw->hw_lcd_width * hw->hw_lcd_height; /* The following thresholds are a bit liberal, but we * essentially want to ensure the following mappings: * @@ -1078,8 +1076,30 @@ int main(int argc, char **argv) else ramSize = 256; } - bufprint(tmp, tmpend, "%d", ramSize); - opts->memory = android_strdup(tmp); + hw->hw_ramSize = ramSize; + } + + D("Physical RAM size: %dMB\n", hw->hw_ramSize); + + if (hw->vm_heapSize == 0) { + /* Compute the default heap size based on the RAM size. + * Essentially, we want to ensure the following liberal mappings: + * + * 96MB RAM -> 16MB heap + * 128MB RAM -> 24MB heap + * 256MB RAM -> 48MB heap + */ + int ramSize = hw->hw_ramSize; + int heapSize; + + if (ramSize < 100) + heapSize = 16; + else if (ramSize < 192) + heapSize = 24; + else + heapSize = 48; + + hw->vm_heapSize = heapSize; } if (opts->trace) { @@ -1089,11 +1109,6 @@ int main(int argc, char **argv) args[n++] = "off"; } - /* Pass LCD density value to the core. */ - snprintf(lcd_density, sizeof(lcd_density), "%d", get_device_dpi(opts)); - args[n++] = "-lcd-density"; - args[n++] = lcd_density; - /* Pass boot properties to the core. */ if (opts->prop != NULL) { ParamList* pl = opts->prop; @@ -1216,9 +1231,7 @@ int main(int argc, char **argv) args[n++] = opts->memcheck; } - /* physical memory */ - args[n++] = "-m"; - args[n++] = opts->memory; + /* physical memory is now in hw->hw_ramSize */ /* on Linux, the 'dynticks' clock sometimes doesn't work * properly. this results in the UI freezing while emulation @@ -1262,21 +1275,15 @@ int main(int argc, char **argv) * launch the core with the -android-hw <file> option. */ { - TempFile* tempHw = tempfile_create(); - if (tempHw == NULL) { - derror("Could not create temporary hardware.ini: %s", strerror(errno)); - exit(2); - } - - const char* tempHwPath = tempfile_path(tempHw); - IniFile* hwIni = iniFile_newFromMemory("", NULL); + const char* coreHwIniPath = avdInfo_getCoreHwIniPath(avd); + IniFile* hwIni = iniFile_newFromMemory("", NULL); androidHwConfig_write(hw, hwIni); - if (iniFile_saveToFile(hwIni, tempHwPath) < 0) { - derror("Could not write temporary hardware.ini: %s", tempHwPath); + if (iniFile_saveToFile(hwIni, coreHwIniPath) < 0) { + derror("Could not write hardware.ini to %s: %s", coreHwIniPath, strerror(errno)); exit(2); } args[n++] = "-android-hw"; - args[n++] = strdup(tempHwPath); + args[n++] = strdup(coreHwIniPath); } if(VERBOSE_CHECK(init)) { diff --git a/android/qemulator.c b/android/qemulator.c index ee9ccbb..b15d751 100644 --- a/android/qemulator.c +++ b/android/qemulator.c @@ -258,7 +258,7 @@ qemulator_set_title(QEmulator* emulator) * Helper routines */ -int +static int get_device_dpi( AndroidOptions* opts ) { int dpi_device = corecmd_get_hw_lcd_density(); diff --git a/android/qemulator.h b/android/qemulator.h index 189cc53..bd77ae1 100644 --- a/android/qemulator.h +++ b/android/qemulator.h @@ -66,8 +66,4 @@ qemulator_get_layout( QEmulator* emulator ); QFrameBuffer* qemulator_get_first_framebuffer(QEmulator* emulator); -/* A helper routine for getting device DPI. */ -int -get_device_dpi( AndroidOptions* opts ); - #endif // QEMU_ANDROID_QEMULATOR_H |