From 90c6235ce7bdc6f7afbcfe56ea6f2c3d2b128447 Mon Sep 17 00:00:00 2001 From: Vladimir Chtchetkine Date: Thu, 13 Jan 2011 11:24:07 -0800 Subject: Refining main-ui.c to better separate UI and core related initialization The main reason for this is to clarify initialization for UI that starts core, and UI that attaches to an existing core. In this CL I did: - Removed -initdata option that seems obsolete (doesn't affect anything in the code) - Passed through -timezone option that doesn't affect anything in the UI, and is needed only in the core. - Removed dependency on AVD info from the core (core needed only virtual device name) Change-Id: Ie631249848a1b5b8d837c0c7b201a40ee7e4a367 --- Makefile.android | 4 ++-- android/cmdline-options.h | 1 - android/console.c | 5 ++++- android/help.c | 13 ------------- android/main-ui.c | 40 +++++++++++++++++++--------------------- android/main.c | 7 +------ console.c | 10 +++++----- qemu-options.hx | 6 ++++++ vl-android.c | 15 +++++++++++++++ 9 files changed, 52 insertions(+), 49 deletions(-) diff --git a/Makefile.android b/Makefile.android index 8bd9b65..b502344 100644 --- a/Makefile.android +++ b/Makefile.android @@ -702,6 +702,7 @@ CORE_MISC_SOURCES = vl-android.c \ android/core-init-utils.c \ android/config.c \ android/snapshot.c \ + android/utils/timezone.c \ ifeq ($(HOST_ARCH),x86) CORE_MISC_SOURCES += i386-dis.c @@ -757,6 +758,7 @@ UI_SOURCES = loadpng.c \ android/qemulator.c \ android/keycode.c \ android/help.c \ + android/avd/info.c \ ############################################################################## # lists of source files used by both, emulator UI and emulator core @@ -783,10 +785,8 @@ UI_AND_CORE_SOURCES = \ android/utils/stralloc.c \ android/utils/system.c \ android/utils/tempfile.c \ - android/utils/timezone.c \ android/utils/vector.c \ android/avd/hw-config.c \ - android/avd/info.c \ android/utils/ini.c \ # include the Zlib sources diff --git a/android/cmdline-options.h b/android/cmdline-options.h index 104de7e..273d151 100644 --- a/android/cmdline-options.h +++ b/android/cmdline-options.h @@ -68,7 +68,6 @@ CFG_PARAM( datadir, "", "write user data into " ) CFG_PARAM( kernel, "", "use specific emulated kernel" ) CFG_PARAM( ramdisk, "", "ramdisk image (default /ramdisk.img" ) CFG_PARAM( image, "", "obsolete, use -system instead" ) -CFG_PARAM( init_data, "", "initial data image (default /userdata.img" ) CFG_PARAM( initdata, "", "same as '-init-data '" ) CFG_PARAM( data, "", "data image (default /userdata-qemu.img" ) CFG_PARAM( partition_size, "", "system/data partition size in MBs" ) diff --git a/android/console.c b/android/console.c index a89d0e1..a44d831 100644 --- a/android/console.c +++ b/android/console.c @@ -121,6 +121,9 @@ ControlClient attached_ui_client = NULL; ControlClient framebuffer_client = NULL; #endif // CONFIG_STANDALONE_CORE +/* -android-avdname option value. Defined in vl-android.c */ +extern char* android_op_avd_name; + static int control_global_add_redir( ControlGlobal global, int host_port, @@ -2170,7 +2173,7 @@ do_avd_status( ControlClient client, char* args ) static int do_avd_name( ControlClient client, char* args ) { - control_write( client, "%s\r\n", avdInfo_getName(android_avdInfo) ); + control_write( client, "%s\r\n", android_op_avd_name); return 0; } diff --git a/android/help.c b/android/help.c index c49f3ff..f400bca 100644 --- a/android/help.c +++ b/android/help.c @@ -557,19 +557,6 @@ help_image(stralloc_t* out) } static void -help_init_data(stralloc_t* out) -{ - PRINTF( - " use '-init-data ' to specify an *init* /data partition file.\n" - " it is only used when creating a new writable /data image file, or\n" - " when you use '-wipe-data' to reset it. the default is 'userdata.img'\n" - " from the system directory.\n\n" - - " see '-help-disk-images' for more information about disk image files\n\n" - ); -} - -static void help_data(stralloc_t* out) { PRINTF( diff --git a/android/main-ui.c b/android/main-ui.c index 8cf3de7..927debb 100644 --- a/android/main-ui.c +++ b/android/main-ui.c @@ -48,7 +48,6 @@ #include "android/utils/bufprint.h" #include "android/utils/dirscanner.h" #include "android/utils/path.h" -#include "android/utils/timezone.h" #include "android/cmdline-option.h" #include "android/help.h" @@ -1047,11 +1046,6 @@ int main(int argc, char **argv) exit(0); } - - 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" @@ -1072,10 +1066,14 @@ 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); - } + /* Initialization of UI started with -attach-core should work differently + * than initialization of UI that starts the core. In particular.... + */ + + /* opts->charmap is incompatible with -attach-core, because particular + * charmap gets set up in the running core. */ + if (android_charmap_setup(opts->charmap)) { + exit(1); } /* legacy support: we used to use -system and -image @@ -1110,23 +1108,12 @@ 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; - if (opts->initdata) { - opts->init_data = opts->initdata; - opts->initdata = NULL; - } - /* If no AVD name was given, try to find the top of the * Android build tree */ @@ -1409,6 +1396,12 @@ 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() */ { @@ -1454,6 +1447,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; diff --git a/android/main.c b/android/main.c index 1244c13..840c764 100644 --- a/android/main.c +++ b/android/main.c @@ -201,7 +201,7 @@ sdl_set_window_icon( void ) SDL_FreeSurface(icon); free( icon_pixels ); } -#endif /* !_WIN32 */ +#endif /* !_WIN32 */ } } @@ -895,11 +895,6 @@ int main(int argc, char **argv) if (opts->noskin) opts->no_skin = opts->noskin; - if (opts->initdata) { - opts->init_data = opts->initdata; - opts->initdata = NULL; - } - /* If no AVD name was given, try to find the top of the * Android build tree */ diff --git a/console.c b/console.c index 6125894..6cadb73 100644 --- a/console.c +++ b/console.c @@ -312,10 +312,10 @@ static void vga_bitblt(DisplayState *ds, int xs, int ys, int xd, int yd, int w, #define cbswap_32(__x) \ ((uint32_t)( \ - (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ - (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ - (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ - (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )) + (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \ + (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \ + (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \ + (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )) #ifdef HOST_WORDS_BIGENDIAN #define PAT(x) x @@ -1395,7 +1395,7 @@ DisplayState *graphic_console_init(vga_hw_update_ptr update, DisplayState *ds; ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState)); - ds->allocator = &default_allocator; + ds->allocator = &default_allocator; #ifdef CONFIG_ANDROID ds->surface = qemu_create_displaysurface(ds, android_display_width, android_display_height); #else diff --git a/qemu-options.hx b/qemu-options.hx index db3dfbb..baae81b 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1644,6 +1644,12 @@ DEF("android-memcheck", HAS_ARG, QEMU_OPTION_android_memcheck, \ DEF("dns-server", HAS_ARG, QEMU_OPTION_dns_server, \ "-dns-server use this DNS server(s) in the emulated system\n") +DEF("timezone", HAS_ARG, QEMU_OPTION_timezone, \ + "-timezone use this timezone instead of the host's default\n") + +DEF("android-avdname", HAS_ARG, QEMU_OPTION_android_avdname, \ + "-android-avdname names the virtual device\n") + DEF("radio", HAS_ARG, QEMU_OPTION_radio, \ "-radio redirect radio modem interface to character device\n") diff --git a/vl-android.c b/vl-android.c index 444461b..75b1bce 100644 --- a/vl-android.c +++ b/vl-android.c @@ -57,6 +57,7 @@ #include "android/globals.h" #include "android/utils/bufprint.h" #include "android/display-core.h" +#include "android/utils/timezone.h" #include "targphys.h" #include "tcpdump.h" @@ -387,6 +388,9 @@ char* android_op_ui_port = NULL; */ char* android_op_ui_settings = NULL; +/* -android-avdname option value. */ +char* android_op_avd_name = "unknown"; + extern int android_display_width; extern int android_display_height; extern int android_display_bpp; @@ -4572,6 +4576,17 @@ int main(int argc, char **argv, char **envp) android_audio_test_start_out(); break; + case QEMU_OPTION_android_avdname: + android_op_avd_name = (char*)optarg; + break; + + case QEMU_OPTION_timezone: + if (timezone_set((char*)optarg)) { + fprintf(stderr, "emulator: it seems the timezone '%s' is not in zoneinfo format\n", + (char*)optarg); + } + break; + #ifdef CONFIG_MEMCHECK case QEMU_OPTION_android_memcheck: android_op_memcheck = (char*)optarg; -- cgit v1.1