diff options
author | Vladimir Chtchetkine <vchtchetkine@google.com> | 2010-08-27 09:09:45 -0700 |
---|---|---|
committer | Vladimir Chtchetkine <vchtchetkine@google.com> | 2010-09-01 07:05:46 -0700 |
commit | 318f17a0050e729bce8545463b657c1d62835b5e (patch) | |
tree | 5bb39290ba092e29be8504c88264fb5159837b5d /android | |
parent | e13168648d5947955e0fd4fbf396f891ae53921f (diff) | |
download | external_qemu-318f17a0050e729bce8545463b657c1d62835b5e.zip external_qemu-318f17a0050e729bce8545463b657c1d62835b5e.tar.gz external_qemu-318f17a0050e729bce8545463b657c1d62835b5e.tar.bz2 |
Fixed dependency ob core data in android/help.c
Also moved along -tcpdump option
Change-Id: I9fc53e0dc6a86e9a880d6127bf2da3ac1d7ec58a
Diffstat (limited to 'android')
-rw-r--r-- | android/android.h | 2 | ||||
-rw-r--r-- | android/help.c | 36 | ||||
-rw-r--r-- | android/main.c | 12 | ||||
-rw-r--r-- | android/ui-core-protocol.c | 82 | ||||
-rw-r--r-- | android/ui-core-protocol.h | 34 |
5 files changed, 144 insertions, 22 deletions
diff --git a/android/android.h b/android/android.h index 62ef789..189b5c2 100644 --- a/android/android.h +++ b/android/android.h @@ -40,6 +40,7 @@ typedef struct { } NetworkSpeed; extern const NetworkSpeed android_netspeeds[]; +extern const size_t android_netspeeds_count; /* list of supported network latency names and min-max values in ms */ typedef struct { @@ -50,6 +51,7 @@ typedef struct { } NetworkLatency; extern const NetworkLatency android_netdelays[]; +extern const size_t android_netdelays_count; /* default network settings for emulator */ #define DEFAULT_NETSPEED "full" diff --git a/android/help.c b/android/help.c index 3527c34..ea419f3 100644 --- a/android/help.c +++ b/android/help.c @@ -10,6 +10,7 @@ #include "audio/audio.h" #include <string.h> #include <stdlib.h> +#include "android/ui-core-protocol.h" /* XXX: TODO: put most of the help stuff in auto-generated files */ @@ -653,7 +654,8 @@ static void help_shaper(stralloc_t* out) { int n; - + NetworkSpeed android_netspeed; + NetworkLatency android_netdelay; PRINTF( " the Android emulator supports network throttling, i.e. slower network\n" " bandwidth as well as higher connection latencies. this is done either through\n" @@ -661,22 +663,22 @@ help_shaper(stralloc_t* out) " the format of -netspeed is one of the following (numbers are kbits/s):\n\n" ); - for (n = 0; android_netspeeds[n].name != NULL; n++) { + for (n = 0; !android_core_get_android_netspeed(n, &android_netspeed); n++) { PRINTF( " -netspeed %-12s %-15s (up: %.1f, down: %.1f)\n", - android_netspeeds[n].name, - android_netspeeds[n].display, - android_netspeeds[n].upload/1000., - android_netspeeds[n].download/1000. ); + android_netspeed.name, + android_netspeed.display, + android_netspeed.upload/1000., + android_netspeed.download/1000. ); } PRINTF( "\n" ); PRINTF( " -netspeed %-12s %s", "<num>", "select both upload and download speed\n"); PRINTF( " -netspeed %-12s %s", "<up>:<down>", "select individual up and down speed\n"); PRINTF( "\n The format of -netdelay is one of the following (numbers are msec):\n\n" ); - for (n = 0; android_netdelays[n].name != NULL; n++) { + for (n = 0; !android_core_get_android_netdelay(n, &android_netdelay); n++) { PRINTF( " -netdelay %-10s %-15s (min %d, max %d)\n", - android_netdelays[n].name, android_netdelays[n].display, - android_netdelays[n].min_ms, android_netdelays[n].max_ms ); + android_netdelay.name, android_netdelay.display, + android_netdelay.min_ms, android_netdelay.max_ms ); } PRINTF( " -netdelay %-10s %s", "<num>", "select exact latency\n"); PRINTF( " -netdelay %-10s %s", "<min>:<max>", "select min and max latencies\n\n"); @@ -781,10 +783,12 @@ help_audio_out(stralloc_t* out) " on this system, output <backend> can be one of the following:\n\n" ); for ( nn = 0; ; nn++ ) { - const char* descr; - const char* name = audio_get_backend_name( 0, nn, &descr ); - if (name == NULL) + char name[512]; + char descr[4096]; + if (android_core_audio_get_backend_name(0, nn, name, sizeof(name), + descr, sizeof(descr))) { break; + } PRINTF( " %-10s %s\n", name, descr ); } PRINTF( "\n" ); @@ -809,10 +813,12 @@ help_audio_in(stralloc_t* out) " on this system, input <backend> can be one of:\n\n" ); for ( nn = 0; ; nn++ ) { - const char* descr; - const char* name = audio_get_backend_name( 1, nn, &descr ); - if (name == NULL) + char name[512]; + char descr[4096]; + if (android_core_audio_get_backend_name(1, nn, name, sizeof(name), + descr, sizeof(descr))) { break; + } PRINTF( " %-10s %s\n", name, descr ); } PRINTF( "\n" ); diff --git a/android/main.c b/android/main.c index 03d0ffd..c03280d 100644 --- a/android/main.c +++ b/android/main.c @@ -61,7 +61,6 @@ #include "hw/goldfish_nand.h" #include "android/globals.h" -#include "tcpdump.h" #include "android/qemulator.h" #include "android/display.h" @@ -1153,12 +1152,6 @@ int main(int argc, char **argv) opts->trace = tracePath; } - if (opts->tcpdump) { - if (qemu_tcpdump_start(opts->tcpdump) < 0) { - dwarning( "could not start packet capture: %s", strerror(errno)); - } - } - if (opts->no_cache) opts->cache = 0; @@ -1190,6 +1183,11 @@ int main(int argc, char **argv) } } + if (opts->tcpdump) { + args[n++] = "-tcpdump"; + args[n++] = opts->tcpdump; + } + #ifdef CONFIG_NAND_LIMITS if (opts->nand_limits) { args[n++] = "-nand-limits"; diff --git a/android/ui-core-protocol.c b/android/ui-core-protocol.c index a5caba0..7442c73 100644 --- a/android/ui-core-protocol.c +++ b/android/ui-core-protocol.c @@ -23,8 +23,11 @@ #include "android/globals.h" #include "android/hw-control.h" #include "android/ui-core-protocol.h" +#if !defined(CONFIG_STANDALONE_UI) #include "telephony/modem_driver.h" #include "trace.h" +#include "audio/audio.h" +#endif // CONFIG_STANDALONE_UI int android_core_get_hw_lcd_density(void) @@ -39,38 +42,117 @@ android_core_set_brightness_change_callback(AndroidHwLightBrightnessCallback cal AndroidHwControlFuncs funcs; funcs.light_brightness = callback; +#if !defined(CONFIG_STANDALONE_UI) android_hw_control_init( opaque, &funcs ); +#endif // CONFIG_STANDALONE_UI } int android_core_get_base_port(void) { +#if !defined(CONFIG_STANDALONE_UI) return android_base_port; +#else + return 5554; +#endif // CONFIG_STANDALONE_UI } void android_core_sensors_set_coarse_orientation( AndroidCoarseOrientation orient ) { +#if !defined(CONFIG_STANDALONE_UI) android_sensors_set_coarse_orientation(orient); +#endif // CONFIG_STANDALONE_UI } void android_core_set_network_enabled(int enabled) { +#if !defined(CONFIG_STANDALONE_UI) if (android_modem) { amodem_set_data_registration( android_modem, qemu_net_disable ? A_REGISTRATION_UNREGISTERED : A_REGISTRATION_HOME); } +#endif // CONFIG_STANDALONE_UI } void android_core_tracing_start(void) { +#if !defined(CONFIG_STANDALONE_UI) start_tracing(); +#endif // CONFIG_STANDALONE_UI } void android_core_tracing_stop(void) { +#if !defined(CONFIG_STANDALONE_UI) stop_tracing(); +#endif // CONFIG_STANDALONE_UI +} + +int +android_core_get_android_netspeed(int index, NetworkSpeed* netspeed) { + /* This is a temporary code used to support current behavior of the + *monolitic (core + ui in one executable) emulator executed with + * -help-netspeed option. In the future, when ui and core get separated, + * behavior of help may change, and this code should be reviewed. */ +#if !defined(CONFIG_STANDALONE_UI) + if (index >= android_netspeeds_count || + android_netspeeds[index].name == NULL) { + return -1; + } + *netspeed = android_netspeeds[index]; + return 0; +#else + return -1; +#endif // !CONFIG_STANDALONE_UI +} + +int +android_core_get_android_netdelay(int index, NetworkLatency* delay) { + /* This is a temporary code used to support current behavior of the + * monolitic (core + ui in one executable) emulator executed with + * -help-netdelays option. In the future, when ui and core get separated, + * behavior of help may change, and this code should be reviewed. */ +#if !defined(CONFIG_STANDALONE_UI) + if (index >= android_netdelays_count || + android_netdelays[index].name == NULL) { + return -1; + } + *delay = android_netdelays[index]; + return 0; +#else + return -1; +#endif // !CONFIG_STANDALONE_UI +} + +int +android_core_audio_get_backend_name(int is_input, int index, + char* name, size_t name_buf_size, + char* descr, size_t descr_buf_size) { + /* This is a temporary code used to support current behavior of the + * monolitic (core + ui in one executable) emulator executed with + * -help-audio-in, and -help-audio-in options. In the future, when ui and + * core get separated, behavior of help may change, and this code should + * be reviewed. */ +#if !defined(CONFIG_STANDALONE_UI) + const char* descr_ptr = NULL; + const char* name_ptr = audio_get_backend_name(is_input, index, &descr_ptr); + if (name_ptr == NULL) { + return -1; + } + if (name != NULL && name_buf_size) { + strncpy(name, name_ptr, name_buf_size); + name[name_buf_size - 1] = '\0'; + } + if (descr != NULL && descr_buf_size && descr_ptr != NULL) { + strncpy(descr, descr_ptr, descr_buf_size); + descr[descr_buf_size - 1] = '\0'; + } + return 0; +#else + return -1; +#endif // !CONFIG_STANDALONE_UI } diff --git a/android/ui-core-protocol.h b/android/ui-core-protocol.h index f461d21..16f49df 100644 --- a/android/ui-core-protocol.h +++ b/android/ui-core-protocol.h @@ -52,4 +52,38 @@ void android_core_set_network_enabled(int enabled); void android_core_tracing_start(void); void android_core_tracing_stop(void); +/* Gets an entry in android_netspeeds array defined in net-android.c + * Parameters: + * index - Index of the entry to get from the array. + * netspeed - Upon successful return contains copy of the requested entry. + * Return: + * 0 on success, or -1 if requested entry index is too large. + */ +int android_core_get_android_netspeed(int index, NetworkSpeed* netspeed); + +/* Gets an entry in android_netdelays array defined in net-android.c + * Parameters: + * index - Index of the entry to get from the array. + * netspeed - Upon successful return contains copy of the requested entry. + * Return: + * 0 on success, or -1 if requested entry index is too large. + */ +int android_core_get_android_netdelay(int index, NetworkLatency* delay); + +/* Get name of a given audio backend. + * Parameters + * is_input - If 1, routine should lookup for input audio backend, if zero, + * routine should lookup for output audio backend. + * index - Index of the registered audio backend to lookup. + * name - Upon successful return contains backend name. + * name_buf_size - name buffer size (in characters). + * descr - Upon successful return contains backend description. + * descr_buf_size - descre buffer size (in characters). + * Return: + * 0 on success, or -1 if requested backend has not been found. + */ +int android_core_audio_get_backend_name(int is_input, int index, + char* name, size_t name_buf_size, + char* descr, size_t descr_buf_size); + #endif // QEMU_ANDROID_UI_CORE_PROTOCOL_H |