aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Chtchetkine <vchtchetkine@google.com>2010-09-01 09:17:11 -0700
committerVladimir Chtchetkine <vchtchetkine@google.com>2010-09-01 09:44:01 -0700
commitcefa7443eb3d3e4bb134595f756145426d5613e3 (patch)
tree7ced288de1420463b18ce3f2d0ae36efaa46775e
parent2cb19c7efef5f194198aa84d6a9ffbdb4c740455 (diff)
downloadexternal_qemu-cefa7443eb3d3e4bb134595f756145426d5613e3.zip
external_qemu-cefa7443eb3d3e4bb134595f756145426d5613e3.tar.gz
external_qemu-cefa7443eb3d3e4bb134595f756145426d5613e3.tar.bz2
Add android_port initialization in the core.
Also some minor cleanups to the ui <-> core stuff. Change-Id: I7d64ec1aa694c027851b7e262b6e1b80bb6cef08
-rw-r--r--Makefile.android2
-rw-r--r--android/main.c8
-rw-r--r--android/qemu-setup.c3
-rw-r--r--android/qemulator.c10
-rw-r--r--android/ui-core-protocol.c52
-rw-r--r--android/ui-core-protocol.h26
-rw-r--r--keymaps.c25
7 files changed, 110 insertions, 16 deletions
diff --git a/Makefile.android b/Makefile.android
index 6cd1cec..8692115 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -664,6 +664,7 @@ CORE_MISC_SOURCES = vl-android.c \
android/hw-control.c \
android/console.c \
android/hw-sensors.c \
+ android/hw-qemud.c \
ifeq ($(HOST_ARCH),x86)
CORE_MISC_SOURCES += i386-dis.c
@@ -727,7 +728,6 @@ UI_AND_CORE_SOURCES = osdep.c \
qemu-malloc.c \
android/keycode-array.c \
android/charmap.c \
- android/hw-qemud.c \
android/utils/bufprint.c \
android/utils/debug.c \
android/utils/path.c \
diff --git a/android/main.c b/android/main.c
index c03280d..5b9475c 100644
--- a/android/main.c
+++ b/android/main.c
@@ -44,11 +44,7 @@
#include "android/skin/window.h"
#include "android/skin/keyset.h"
-#include "android/gps.h"
-#include "android/hw-qemud.h"
-#include "android/hw-kmsg.h"
#include "android/hw-lcd.h"
-#include "android/hw-sensors.h"
#include "android/boot-properties.h"
#include "android/user-config.h"
#include "android/utils/bufprint.h"
@@ -1389,14 +1385,10 @@ int main(int argc, char **argv)
/* we always send the kernel messages from ttyS0 to android_kmsg */
{
- AndroidKmsgFlags flags = 0;
-
if (opts->show_kernel) {
- flags |= ANDROID_KMSG_PRINT_MESSAGES;
args[n++] = "-show-kernel";
}
- android_kmsg_init( flags );
args[n++] = "-serial";
args[n++] = "android-kmsg";
serial++;
diff --git a/android/qemu-setup.c b/android/qemu-setup.c
index a790c37..6c3785c 100644
--- a/android/qemu-setup.c
+++ b/android/qemu-setup.c
@@ -23,6 +23,7 @@
#include "android/utils/path.h"
#include "android/utils/system.h"
#include "android/utils/bufprint.h"
+#include "android/core-ui-protocol.h"
#define D(...) do { if (VERBOSE_CHECK(init)) dprint(__VA_ARGS__); } while (0)
@@ -330,6 +331,8 @@ void android_emulation_setup( void )
android_modem_init( base_port );
+ /* Save base port and call back to UI so it can properly set up its window title. */
+ android_base_port = base_port;
android_ui_set_base_port(base_port);
/* send a simple message to the ADB host server to tell it we just started.
diff --git a/android/qemulator.c b/android/qemulator.c
index 4d6c771..32983be 100644
--- a/android/qemulator.c
+++ b/android/qemulator.c
@@ -375,9 +375,9 @@ handle_key_command( void* opaque, SkinKeyCommand command, int down )
{
case SKIN_KEY_COMMAND_TOGGLE_NETWORK:
{
- qemu_net_disable = !qemu_net_disable;
- android_core_set_network_enabled(!qemu_net_disable);
- D( "network is now %s", qemu_net_disable ? "disconnected" : "connected" );
+ android_core_toggle_network();
+ D( "network is now %s", android_core_is_network_disabled() ?
+ "disconnected" : "connected" );
}
break;
@@ -563,7 +563,7 @@ static void qemulator_refresh(QEmulator* emulator)
#endif
/* only save emulator config through clean exit */
qemulator_done(qemulator_get());
- qemu_system_shutdown_request();
+ android_core_system_shutdown_request();
return;
}
}
@@ -597,6 +597,6 @@ android_emulator_set_window_scale( double scale, int is_dpi )
void
android_emulator_set_base_port( int port )
{
- android_base_port = port;
+ /* Base port is already set in the emulator's core. */
qemulator_set_title(qemulator);
}
diff --git a/android/ui-core-protocol.c b/android/ui-core-protocol.c
index 7442c73..6782cf6 100644
--- a/android/ui-core-protocol.c
+++ b/android/ui-core-protocol.c
@@ -27,6 +27,8 @@
#include "telephony/modem_driver.h"
#include "trace.h"
#include "audio/audio.h"
+extern void qemu_system_shutdown_request(void);
+extern char* qemu_find_file(int type, const char* filename);
#endif // CONFIG_STANDALONE_UI
int
@@ -68,6 +70,7 @@ android_core_sensors_set_coarse_orientation( AndroidCoarseOrientation orient )
void
android_core_set_network_enabled(int enabled)
{
+ /* Temporary implementation for the monolitic (core + ui) builds. */
#if !defined(CONFIG_STANDALONE_UI)
if (android_modem) {
amodem_set_data_registration(
@@ -78,6 +81,27 @@ android_core_set_network_enabled(int enabled)
#endif // CONFIG_STANDALONE_UI
}
+void
+android_core_toggle_network(void)
+{
+ /* Temporary implementation for the monolitic (core + ui) builds. */
+#if !defined(CONFIG_STANDALONE_UI)
+ qemu_net_disable = !qemu_net_disable;
+ android_core_set_network_enabled(!qemu_net_disable);
+#endif // CONFIG_STANDALONE_UI
+}
+
+int
+android_core_is_network_disabled(void)
+{
+ /* Temporary implementation for the monolitic (core + ui) builds. */
+#if !defined(CONFIG_STANDALONE_UI)
+ return qemu_net_disable;
+#else
+ return 0;
+#endif // CONFIG_STANDALONE_UI
+}
+
void android_core_tracing_start(void)
{
#if !defined(CONFIG_STANDALONE_UI)
@@ -156,3 +180,31 @@ android_core_audio_get_backend_name(int is_input, int index,
return -1;
#endif // !CONFIG_STANDALONE_UI
}
+
+void
+android_core_system_shutdown_request(void)
+{
+ /* Temporary implementation for the monolitic (core + ui) builds. */
+#if !defined(CONFIG_STANDALONE_UI)
+ qemu_system_shutdown_request();
+#endif // !CONFIG_STANDALONE_UI
+}
+
+int
+android_core_qemu_find_file(int type, const char *filename,
+ char* path, size_t path_buf_size)
+{
+ /* Temporary implementation for the monolitic (core + ui) builds. */
+#if !defined(CONFIG_STANDALONE_UI)
+ char* filepath = qemu_find_file(type, filename);
+ if (filepath == NULL) {
+ return -1;
+ }
+ strncpy(path, filepath, path_buf_size);
+ filepath[path_buf_size - 1] = '\0';
+ qemu_free(filepath);
+ return 0;
+#else
+ return -1;
+#endif // !CONFIG_STANDALONE_UI
+}
diff --git a/android/ui-core-protocol.h b/android/ui-core-protocol.h
index 16f49df..6930e62 100644
--- a/android/ui-core-protocol.h
+++ b/android/ui-core-protocol.h
@@ -45,9 +45,15 @@ int android_core_get_base_port(void);
/* change the coarse orientation value */
void android_core_sensors_set_coarse_orientation( AndroidCoarseOrientation orient );
-/* Sets/toggles the network state */
+/* Sets the network state */
void android_core_set_network_enabled(int enabled);
+/* Toggles the network state */
+void android_core_toggle_network(void);
+
+/* Gets the network state */
+int android_core_is_network_disabled(void);
+
/* Start/stop tracing in the guest system */
void android_core_tracing_start(void);
void android_core_tracing_stop(void);
@@ -86,4 +92,22 @@ 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);
+/* Notifies the core about system shutdown requested by the UI. */
+void android_core_system_shutdown_request(void);
+
+/* Builds a path to a file of the given type in the emulator's data directory.
+ * Param:
+ * type - Type of the file to find. Only QEMU_FILE_TYPE_BIOS, and
+ * QEMU_FILE_TYPE_KEYMAP are allowed for this value.
+ * filename - Name of the file to build path for.
+ * path - Upon success contains path to the requested file inside the
+ * emulator's data directory.
+ * path_buf_size Character size of the buffer addressed by the path parameter.
+ * Return:
+ * 0 on success, or -1 on an error.
+ */
+int
+android_core_qemu_find_file(int type, const char *filename,
+ char* path, size_t path_buf_size);
+
#endif // QEMU_ANDROID_UI_CORE_PROTOCOL_H
diff --git a/keymaps.c b/keymaps.c
index 6685562..661c2e6 100644
--- a/keymaps.c
+++ b/keymaps.c
@@ -64,20 +64,43 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
kbd_layout_t * k)
{
FILE *f;
+ /* This file is used by both, UI and core components. There are differences
+ * in the way how keymap file path is obtained for these two different
+ * configurations. */
+#if defined(CONFIG_STANDALONE_UI)
+ char filename[2048];
+#else
char * filename;
+#endif // CONFIG_STANDALONE_UI
char line[1024];
int len;
+#if defined(CONFIG_STANDALONE_UI)
+ if (android_core_qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language,
+ filename, sizeof(filename))) {
+ fprintf(stderr,
+ "Could not read keymap file: '%s'\n", language);
+ return NULL;
+ }
+#else
filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
+ if (!filename) {
+ fprintf(stderr,
+ "Could not read keymap file: '%s'\n", language);
+ return NULL;
+ }
+#endif // CONFIG_STANDALONE_UI
if (!k)
k = qemu_mallocz(sizeof(kbd_layout_t));
- if (!(filename && (f = fopen(filename, "r")))) {
+ if (!(f = fopen(filename, "r"))) {
fprintf(stderr,
"Could not read keymap file: '%s'\n", language);
return NULL;
}
+#if defined(CONFIG_STANDALONE_UI)
qemu_free(filename);
+#endif // CONFIG_STANDALONE_UI
for(;;) {
if (fgets(line, 1024, f) == NULL)
break;