aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--android/main-common.c272
-rw-r--r--android/main-common.h17
-rw-r--r--android/main-ui.c102
-rw-r--r--android/main.c29
-rw-r--r--android/qemulator.c16
-rw-r--r--android/qemulator.h5
6 files changed, 227 insertions, 214 deletions
diff --git a/android/main-common.c b/android/main-common.c
index 189f10c..23ba5b9 100644
--- a/android/main-common.c
+++ b/android/main-common.c
@@ -335,12 +335,137 @@ static const struct {
/* this is used by hw/events_device.c to send the charmap name to the system */
const char* android_skin_keycharmap = NULL;
-void init_skinned_ui(const char *path, const char *name, AndroidOptions* opts)
+void
+parse_skin_files(const char* skinDirPath,
+ const char* skinName,
+ AndroidOptions* opts,
+ AConfig* *skinConfig,
+ char* *skinPath)
{
char tmp[1024];
AConfig* root;
+ const char* path = NULL;
AConfig* n;
- int win_x, win_y, flags;
+
+ root = aconfig_node("", "");
+
+ if (skinName == NULL)
+ goto DEFAULT_SKIN;
+
+ /* Support skin aliases like QVGA-H QVGA-P, etc...
+ But first we check if it's a directory that exist before applying
+ the alias */
+ int checkAlias = 1;
+
+ if (skinDirPath != NULL) {
+ bufprint(tmp, tmp+sizeof(tmp), "%s/%s", skinDirPath, skinName);
+ if (path_exists(tmp)) {
+ checkAlias = 0;
+ } else {
+ D("there is no '%s' skin in '%s'", skinName, skinDirPath);
+ }
+ }
+
+ if (checkAlias) {
+ int nn;
+
+ for (nn = 0; ; nn++ ) {
+ const char* skin_name = skin_aliases[nn].name;
+ const char* skin_alias = skin_aliases[nn].alias;
+
+ if (!skin_name)
+ break;
+
+ if (!strcasecmp( skin_name, skinName )) {
+ D("skin name '%s' aliased to '%s'", skinName, skin_alias);
+ skinName = skin_alias;
+ break;
+ }
+ }
+ }
+
+ /* Magically support skins like "320x240" or "320x240x16" */
+ if(isdigit(skinName[0])) {
+ char *x = strchr(skinName, 'x');
+ if(x && isdigit(x[1])) {
+ int width = atoi(skinName);
+ int height = atoi(x+1);
+ int bpp = 16;
+ char* y = strchr(x+1, 'x');
+ if (y && isdigit(y[1])) {
+ bpp = atoi(y+1);
+ }
+ snprintf(tmp, sizeof tmp,
+ "display {\n width %d\n height %d\n bpp %d}\n",
+ width, height,bpp);
+ aconfig_load(root, strdup(tmp));
+ path = ":";
+ D("found magic skin width=%d height=%d bpp=%d\n", width, height, bpp);
+ goto FOUND_SKIN;
+ }
+ }
+
+ if (skinDirPath == NULL) {
+ derror("unknown skin name '%s'", skinName);
+ exit(1);
+ }
+
+ snprintf(tmp, sizeof tmp, "%s/%s/layout", skinDirPath, skinName);
+ D("trying to load skin file '%s'", tmp);
+
+ if(aconfig_load_file(root, tmp) < 0) {
+ dwarning("could not load skin file '%s', using built-in one\n",
+ tmp);
+ goto DEFAULT_SKIN;
+ }
+
+ snprintf(tmp, sizeof tmp, "%s/%s/", skinDirPath, skinName);
+ path = tmp;
+ goto FOUND_SKIN;
+
+FOUND_SKIN:
+ /* the default network speed and latency can now be specified by the device skin */
+ n = aconfig_find(root, "network");
+ if (n != NULL) {
+ skin_network_speed = aconfig_str(n, "speed", 0);
+ skin_network_delay = aconfig_str(n, "delay", 0);
+ }
+
+ *skinConfig = root;
+ *skinPath = strdup(path);
+ return;
+
+DEFAULT_SKIN:
+ {
+ const unsigned char* layout_base;
+ size_t layout_size;
+ char* base;
+
+ skinName = "<builtin>";
+
+ layout_base = android_resource_find( "layout", &layout_size );
+ if (layout_base == NULL) {
+ fprintf(stderr, "Couldn't load builtin skin\n");
+ exit(1);
+ }
+ base = malloc( layout_size+1 );
+ memcpy( base, layout_base, layout_size );
+ base[layout_size] = 0;
+
+ D("parsing built-in skin layout file (%d bytes)", (int)layout_size);
+ aconfig_load(root, base);
+ path = ":";
+ }
+ goto FOUND_SKIN;
+}
+
+
+void
+init_sdl_ui(AConfig* skinConfig,
+ const char* skinPath,
+ AndroidOptions* opts)
+{
+ int win_x, win_y, flags;
signal(SIGINT, SIG_DFL);
#ifndef _WIN32
@@ -380,136 +505,15 @@ void init_skinned_ui(const char *path, const char *name, AndroidOptions* opts)
}
atexit(sdl_at_exit);
- root = aconfig_node("", "");
-
- if(name) {
- /* Support skin aliases like QVGA-H QVGA-P, etc...
- But first we check if it's a directory that exist before applying
- the alias */
- int checkAlias = 1;
-
- if (path != NULL) {
- bufprint(tmp, tmp+sizeof(tmp), "%s/%s", path, name);
- if (path_exists(tmp)) {
- checkAlias = 0;
- } else {
- D("there is no '%s' skin in '%s'", name, path);
- }
- }
-
- if (checkAlias) {
- int nn;
-
- for (nn = 0; ; nn++ ) {
- const char* skin_name = skin_aliases[nn].name;
- const char* skin_alias = skin_aliases[nn].alias;
-
- if ( !skin_name )
- break;
-
- if ( !strcasecmp( skin_name, name ) ) {
- D("skin name '%s' aliased to '%s'", name, skin_alias);
- name = skin_alias;
- break;
- }
- }
- }
-
- /* Magically support skins like "320x240" or "320x240x16" */
- if(isdigit(name[0])) {
- char *x = strchr(name, 'x');
- if(x && isdigit(x[1])) {
- int width = atoi(name);
- int height = atoi(x+1);
- int bpp = 16;
- char* y = strchr(x+1, 'x');
- if (y && isdigit(y[1])) {
- bpp = atoi(y+1);
- }
- sprintf(tmp,"display {\n width %d\n height %d\n bpp %d}\n",
- width, height,bpp);
- aconfig_load(root, strdup(tmp));
- path = ":";
- goto found_a_skin;
- }
- }
-
- if (path == NULL) {
- derror("unknown skin name '%s'", name);
- exit(1);
- }
-
- sprintf(tmp, "%s/%s/layout", path, name);
- D("trying to load skin file '%s'", tmp);
-
- if(aconfig_load_file(root, tmp) >= 0) {
- sprintf(tmp, "%s/%s/", path, name);
- path = tmp;
- goto found_a_skin;
- } else {
- dwarning("could not load skin file '%s', using built-in one\n",
- tmp);
- }
- }
-
- {
- const unsigned char* layout_base;
- size_t layout_size;
-
- name = "<builtin>";
-
- layout_base = android_resource_find( "layout", &layout_size );
- if (layout_base != NULL) {
- char* base = malloc( layout_size+1 );
- memcpy( base, layout_base, layout_size );
- base[layout_size] = 0;
-
- D("parsing built-in skin layout file (size=%d)", (int)layout_size);
- aconfig_load(root, base);
- path = ":";
- } else {
- fprintf(stderr, "Couldn't load builtin skin\n");
- exit(1);
- }
- }
-
-found_a_skin:
emulator_config_get_window_pos(&win_x, &win_y);
- if ( qemulator_init(qemulator_get(), root, path, win_x, win_y, opts ) < 0 ) {
- fprintf(stderr, "### Error: could not load emulator skin '%s'\n", name);
+ if ( qemulator_init(qemulator_get(), skinConfig, skinPath, win_x, win_y, opts) < 0 ) {
+ fprintf(stderr, "### Error: could not load emulator skin from '%s'\n", skinPath);
exit(1);
}
android_skin_keycharmap = skin_keyboard_charmap_name(qemulator_get()->keyboard);
- /* the default network speed and latency can now be specified by the device skin */
- n = aconfig_find(root, "network");
- if (n != NULL) {
- skin_network_speed = aconfig_str(n, "speed", 0);
- skin_network_delay = aconfig_str(n, "delay", 0);
- }
-
-#if 0
- /* create a trackball if needed */
- n = aconfig_find(root, "trackball");
- if (n != NULL) {
- SkinTrackBallParameters params;
-
- params.x = aconfig_unsigned(n, "x", 0);
- params.y = aconfig_unsigned(n, "y", 0);
- params.diameter = aconfig_unsigned(n, "diameter", 20);
- params.ring = aconfig_unsigned(n, "ring", 1);
-
- params.ball_color = aconfig_unsigned(n, "ball-color", 0xffe0e0e0);
- params.dot_color = aconfig_unsigned(n, "dot-color", 0xff202020 );
- params.ring_color = aconfig_unsigned(n, "ring-color", 0xff000000 );
-
- qemu_disp->trackball = skin_trackball_create( &params );
- skin_trackball_refresh( qemu_disp->trackball );
- }
-#endif
-
/* add an onion overlay image if needed */
if (opts->onion) {
SkinImage* onion = skin_image_find_simple( opts->onion );
@@ -531,3 +535,21 @@ found_a_skin:
}
}
+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 0adc4a2..b797f6a 100644
--- a/android/main-common.h
+++ b/android/main-common.h
@@ -15,6 +15,7 @@
#include <stdint.h>
#include "android/cmdline-option.h"
#include "android/skin/keyset.h"
+#include "android/config.h"
/* Common routines used by both android/main.c and android/main-ui.c */
@@ -38,6 +39,20 @@ void write_default_keyset( void );
extern const char* skin_network_speed;
extern const char* skin_network_delay;
-void init_skinned_ui(const char *path, const char *name, AndroidOptions* opts);
+/* Find the skin corresponding to our options, and return an AConfig pointer
+ * and the base path to load skin data from
+ */
+void parse_skin_files(const char* skinDirPath,
+ const char* skinName,
+ AndroidOptions* opts,
+ AConfig* *skinConfig,
+ char* *skinPath);
+
+/* Returns the amount of pixels used by the default display. */
+int64_t get_screen_pixels(AConfig* skinConfig);
+
+void init_sdl_ui(AConfig* skinConfig,
+ const char* skinPath,
+ AndroidOptions* opts);
#endif /* ANDROID_MAIN_COMMON_H */
diff --git a/android/main-ui.c b/android/main-ui.c
index fdd1d58..0486ac1 100644
--- a/android/main-ui.c
+++ b/android/main-ui.c
@@ -33,17 +33,9 @@
#include "android/charmap.h"
#include "android/utils/debug.h"
-#include "android/resource.h"
#include "android/config.h"
#include "android/config/config.h"
-#include "android/skin/image.h"
-#include "android/skin/trackball.h"
-#include "android/skin/keyboard.h"
-#include "android/skin/file.h"
-#include "android/skin/window.h"
-#include "android/skin/keyset.h"
-
#include "android/user-config.h"
#include "android/utils/bufprint.h"
#include "android/utils/dirscanner.h"
@@ -81,9 +73,6 @@ AndroidRotation android_framebuffer_rotation;
# define VERSION_STRING "standalone"
#endif
-#define KEYSET_FILE "default.keyset"
-SkinKeyset* android_keyset;
-
#define D(...) do { if (VERBOSE_CHECK(init)) dprint(__VA_ARGS__); } while (0)
extern int control_console_start( int port ); /* in control.c */
@@ -493,6 +482,8 @@ int main(int argc, char **argv)
AndroidHwConfig* hw;
AvdInfo* avd;
+ AConfig* skinConfig;
+ char* skinPath;
//const char *appdir = get_app_dir();
char* android_build_root = NULL;
@@ -511,19 +502,11 @@ int main(int argc, char **argv)
exit(1);
}
- // Lets see if we're attaching to a running core process here.
- if (opts->attach_core) {
- if (attach_to_core(opts)) {
- return -1;
- }
- // Connect to the core's UI control services.
- if (coreCmdProxy_create(attachUiImpl_get_console_socket())) {
- return -1;
- }
- // Connect to the core's user events service.
- if (userEventsProxy_create(attachUiImpl_get_console_socket())) {
- return -1;
- }
+ // Lets see if user just wants to list core process.
+ if (opts->list_cores) {
+ fprintf(stdout, "Enumerating running core processes.\n");
+ list_running_cores(opts->list_cores);
+ exit(0);
}
while (argc-- > 1) {
@@ -574,13 +557,6 @@ int main(int argc, char **argv)
exit(1);
}
- // Lets see if user just wants to list core process.
- if (opts->list_cores) {
- fprintf(stdout, "Enumerating running core processes.\n");
- list_running_cores(opts->list_cores);
- exit(0);
- }
-
if (opts->version) {
printf("Android emulator version %s\n"
"Copyright (C) 2006-2008 The Android Open Source Project and many others.\n"
@@ -605,7 +581,7 @@ int main(int argc, char **argv)
* than initialization of UI that starts the core. In particular....
*/
- /* opts->charmap is incompatible with -attach-core, because particular
+ /* -charmap is incompatible with -attach-core, because particular
* charmap gets set up in the running core. */
if (android_charmap_setup(opts->charmap)) {
exit(1);
@@ -643,9 +619,15 @@ int main(int argc, char **argv)
opts->system = NULL;
}
+ if (opts->nojni)
+ opts->no_jni = opts->nojni;
+
if (opts->nocache)
opts->no_cache = opts->nocache;
+ if (opts->noaudio)
+ opts->no_audio = opts->noaudio;
+
if (opts->noskin)
opts->no_skin = opts->noskin;
@@ -890,18 +872,8 @@ int main(int argc, char **argv)
emulator_config_init();
- init_skinned_ui(opts->skindir, opts->skin, opts);
-
- // Connect to the core's framebuffer service
- if (implFb_create(attachUiImpl_get_console_socket(), "-raw",
- qemulator_get_first_framebuffer(qemulator_get()))) {
- return -1;
- }
-
- // Attach the recepient of UI commands.
- if (uiCmdImpl_create(attachUiImpl_get_console_socket())) {
- return -1;
- }
+ parse_skin_files(opts->skindir, opts->skin, opts,
+ &skinConfig, &skinPath);
if (!opts->netspeed) {
if (skin_network_speed)
@@ -933,12 +905,6 @@ int main(int argc, char **argv)
if (opts->no_cache)
opts->cache = 0;
- if (opts->nojni)
- opts->no_jni = opts->nojni;
-
- if (opts->noaudio)
- opts->no_audio = opts->noaudio;
-
n = 1;
/* generate arguments for the underlying qemu main() */
{
@@ -1296,9 +1262,7 @@ int main(int argc, char **argv)
* 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;
+ int64_t pixels = get_screen_pixels(skinConfig);
/* The following thresholds are a bit liberal, but we
* essentially want to ensure the following mappings:
@@ -1329,7 +1293,7 @@ int main(int argc, char **argv)
}
/* Pass LCD density value to the core. */
- snprintf(lcd_density, sizeof(lcd_density), "%d", get_device_dpi(opts));
+ snprintf(lcd_density, sizeof(lcd_density), "%d", hw->hw_lcd_density);
args[n++] = "-lcd-density";
args[n++] = lcd_density;
@@ -1524,5 +1488,35 @@ int main(int argc, char **argv)
}
printf("\n");
}
+
+ /* Setup SDL UI just before calling the code */
+ init_sdl_ui(skinConfig, skinPath, opts);
+
+ // Lets see if we're attaching to a running core process here.
+ if (opts->attach_core) {
+ if (attach_to_core(opts)) {
+ return -1;
+ }
+ // Connect to the core's UI control services.
+ if (coreCmdProxy_create(attachUiImpl_get_console_socket())) {
+ return -1;
+ }
+ // Connect to the core's user events service.
+ if (userEventsProxy_create(attachUiImpl_get_console_socket())) {
+ return -1;
+ }
+ }
+
+ // Connect to the core's framebuffer service
+ if (implFb_create(attachUiImpl_get_console_socket(), "-raw",
+ qemulator_get_first_framebuffer(qemulator_get()))) {
+ return -1;
+ }
+
+ // Attach the recepient of UI commands.
+ if (uiCmdImpl_create(attachUiImpl_get_console_socket())) {
+ return -1;
+ }
+
return qemu_main(n, args);
}
diff --git a/android/main.c b/android/main.c
index 078cfbb..64fe617 100644
--- a/android/main.c
+++ b/android/main.c
@@ -40,7 +40,6 @@
#include "android/utils/bufprint.h"
#include "android/utils/dirscanner.h"
#include "android/utils/path.h"
-#include "android/utils/timezone.h"
#include "android/utils/tempfile.h"
#include "android/main-common.h"
@@ -286,6 +285,8 @@ int main(int argc, char **argv)
AndroidHwConfig* hw;
AvdInfo* avd;
+ AConfig* skinConfig;
+ char* skinPath;
//const char *appdir = get_app_dir();
char* android_build_root = NULL;
@@ -352,10 +353,6 @@ int main(int argc, char **argv)
exit(1);
}
- if (android_charmap_setup(opts->charmap)) {
- exit(1);
- }
-
if (opts->version) {
printf("Android emulator version %s\n"
"Copyright (C) 2006-2008 The Android Open Source Project and many others.\n"
@@ -376,10 +373,8 @@ int main(int argc, char **argv)
exit(0);
}
- if (opts->timezone) {
- if ( timezone_set(opts->timezone) < 0 ) {
- fprintf(stderr, "emulator: it seems the timezone '%s' is not in zoneinfo format\n", opts->timezone);
- }
+ if (android_charmap_setup(opts->charmap)) {
+ exit(1);
}
/* legacy support: we used to use -system <dir> and -image <file>
@@ -667,7 +662,8 @@ int main(int argc, char **argv)
emulator_config_init();
- init_skinned_ui(opts->skindir, opts->skin, opts);
+ parse_skin_files(opts->skindir, opts->skin, opts,
+ &skinConfig, &skinPath);
if (!opts->netspeed) {
if (skin_network_speed)
@@ -744,6 +740,11 @@ int main(int argc, char **argv)
}
#endif
+ if (opts->timezone) {
+ args[n++] = "-timezone";
+ args[n++] = opts->timezone;
+ }
+
if (opts->netspeed) {
args[n++] = "-netspeed";
args[n++] = opts->netspeed;
@@ -1053,9 +1054,7 @@ int main(int argc, char **argv)
* 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;
+ int64_t pixels = get_screen_pixels(skinConfig);
/* The following thresholds are a bit liberal, but we
* essentially want to ensure the following mappings:
@@ -1281,5 +1280,9 @@ int main(int argc, char **argv)
}
printf("\n");
}
+
+ /* Setup SDL UI just before calling the code */
+ init_sdl_ui(skinConfig, skinPath, opts);
+
return qemu_main(n, args);
}
diff --git a/android/qemulator.c b/android/qemulator.c
index f1b2dbc..36a9ec8 100644
--- a/android/qemulator.c
+++ b/android/qemulator.c
@@ -190,22 +190,6 @@ 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 b343f98..189cc53 100644
--- a/android/qemulator.h
+++ b/android/qemulator.h
@@ -50,11 +50,6 @@ 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 );