aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android/avd/hardware-properties.ini2
-rw-r--r--android/avd/hw-config-defs.h2
-rw-r--r--android/main-ui.c30
-rw-r--r--android/main.c30
-rw-r--r--android/qemulator.c16
-rw-r--r--android/qemulator.h5
6 files changed, 81 insertions, 4 deletions
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini
index 68979de..8e5cc41 100644
--- a/android/avd/hardware-properties.ini
+++ b/android/avd/hardware-properties.ini
@@ -26,7 +26,7 @@
# Ram size
name = hw.ramSize
type = integer
-default = 96
+default = 0
abstract = Device ram size
description = The amount of physical RAM on the device, in megabytes.
diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h
index 9eb4335..9602a4a 100644
--- a/android/avd/hw-config-defs.h
+++ b/android/avd/hw-config-defs.h
@@ -20,7 +20,7 @@
HWCFG_INT(
hw_ramSize,
"hw.ramSize",
- 96,
+ 0,
"Device ram size",
"The amount of physical RAM on the device, in megabytes.")
diff --git a/android/main-ui.c b/android/main-ui.c
index 8b9e088..7a4d746 100644
--- a/android/main-ui.c
+++ b/android/main-ui.c
@@ -1756,7 +1756,35 @@ int main(int argc, char **argv)
}
}
if (!opts->memory) {
- bufprint(tmp, tmpend, "%d", hw->hw_ramSize);
+ int ramSize = hw->hw_ramSize;
+ if (ramSize <= 0) {
+ /* Compute the default RAM size based on the size of screen.
+ * This is only used when the skin doesn't provide the ram
+ * size through its hardware.ini (i.e. legacy ones) or when
+ * in the full Android build system.
+ */
+ int width, height, pixels;
+ qemulator_get_screen_size(qemulator_get(), &width, &height);
+ pixels = width*height;
+
+ /* The following thresholds are a bit liberal, but we
+ * essentially want to ensure the following mappings:
+ *
+ * 320x480 -> 96
+ * 800x600 -> 128
+ * 1024x768 -> 256
+ *
+ * These are just simple heuristics, they could change in
+ * the future.
+ */
+ if (pixels <= 250000)
+ ramSize = 96;
+ else if (pixels <= 500000)
+ ramSize = 128;
+ else
+ ramSize = 256;
+ }
+ bufprint(tmp, tmpend, "%d", ramSize);
opts->memory = android_strdup(tmp);
}
diff --git a/android/main.c b/android/main.c
index 5968249..793fa23 100644
--- a/android/main.c
+++ b/android/main.c
@@ -1520,7 +1520,35 @@ int main(int argc, char **argv)
}
}
if (!opts->memory) {
- bufprint(tmp, tmpend, "%d", hw->hw_ramSize);
+ int ramSize = hw->hw_ramSize;
+ if (ramSize <= 0) {
+ /* Compute the default RAM size based on the size of screen.
+ * This is only used when the skin doesn't provide the ram
+ * size through its hardware.ini (i.e. legacy ones) or when
+ * in the full Android build system.
+ */
+ int width, height, pixels;
+ qemulator_get_screen_size(qemulator_get(), &width, &height);
+ pixels = width*height;
+
+ /* The following thresholds are a bit liberal, but we
+ * essentially want to ensure the following mappings:
+ *
+ * 320x480 -> 96
+ * 800x600 -> 128
+ * 1024x768 -> 256
+ *
+ * These are just simple heuristics, they could change in
+ * the future.
+ */
+ if (pixels <= 250000)
+ ramSize = 96;
+ else if (pixels <= 500000)
+ ramSize = 128;
+ else
+ ramSize = 256;
+ }
+ bufprint(tmp, tmpend, "%d", ramSize);
opts->memory = android_strdup(tmp);
}
diff --git a/android/qemulator.c b/android/qemulator.c
index 3f427b8..35e7cc8 100644
--- a/android/qemulator.c
+++ b/android/qemulator.c
@@ -188,6 +188,22 @@ qemulator_done(QEmulator* emulator)
}
}
+void
+qemulator_get_screen_size( QEmulator* emulator,
+ int *width,
+ int *height )
+{
+ AConfig* root = emulator->aconfig;
+ AConfig* disp;
+
+ *width = *height = 0;
+ if (root == NULL || (disp = aconfig_find(root, "display")) == NULL)
+ return;
+
+ *width = aconfig_int(disp, "width", 0);
+ *height = aconfig_int(disp, "height", 0);
+}
+
SkinLayout*
qemulator_get_layout(QEmulator* emulator)
{
diff --git a/android/qemulator.h b/android/qemulator.h
index 189cc53..b343f98 100644
--- a/android/qemulator.h
+++ b/android/qemulator.h
@@ -50,6 +50,11 @@ qemulator_init( QEmulator* emulator,
int y,
AndroidOptions* opts );
+void
+qemulator_get_screen_size( QEmulator* emulator,
+ int *width,
+ int *height );
+
/* Uninitializes QEmulator structure instance on exit. */
void
qemulator_done( QEmulator* emulator );