diff options
Diffstat (limited to 'android/main-ui.c')
-rw-r--r-- | android/main-ui.c | 55 |
1 files changed, 32 insertions, 23 deletions
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)) { |