From 777eb68eb60cac18f4b62e2e1b14a906875cbe7a Mon Sep 17 00:00:00 2001 From: Vladimir Chtchetkine Date: Wed, 26 Jan 2011 11:19:19 -0800 Subject: Refactored ui-core-control and core-ui-control protocols Also cleaned the code up from obsolete ui-core-protocol.* and core-ui-protocol.* Change-Id: I194bec669d25b68a10c32b2be50bc9da50c52ebb --- android/protocol/core-commands-qemu.c | 108 ++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 android/protocol/core-commands-qemu.c (limited to 'android/protocol/core-commands-qemu.c') diff --git a/android/protocol/core-commands-qemu.c b/android/protocol/core-commands-qemu.c new file mode 100644 index 0000000..03fef64 --- /dev/null +++ b/android/protocol/core-commands-qemu.c @@ -0,0 +1,108 @@ +/* Copyright (C) 2010 The Android Open Source Project +** +** This software is licensed under the terms of the GNU General Public +** License version 2, as published by the Free Software Foundation, and +** may be copied, distributed, and modified under those terms. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +*/ + +/* + * Contains implementation of the API for calling into the Core with the UI + * control commands for standalone (monolithic) emulator. + */ + +#include "android/android.h" +#include "android/globals.h" +#include "android/hw-sensors.h" +#include "telephony/modem_driver.h" +#include "trace.h" +#include "audio/audio.h" +#include "android/protocol/core-commands-api.h" + +/* Implemented in vl-android.c */ +extern char* qemu_find_file(int type, const char* filename); + +int +corecmd_set_coarse_orientation(AndroidCoarseOrientation orient) +{ + android_sensors_set_coarse_orientation(orient); + return 0; +} + +int +corecmd_toggle_network() +{ + qemu_net_disable = !qemu_net_disable; + if (android_modem) { + amodem_set_data_registration( + android_modem, + qemu_net_disable ? A_REGISTRATION_UNREGISTERED + : A_REGISTRATION_HOME); + } + return 0; +} + +int corecmd_trace_control(int start) +{ + if (start) { + start_tracing(); + } else { + stop_tracing(); + } + return 0; +} + +int corecmd_is_network_disabled() +{ + return qemu_net_disable; +} + +int +corecmd_get_netspeed(int index, NetworkSpeed** netspeed) +{ + if (index >= android_netspeeds_count || + android_netspeeds[index].name == NULL) { + return -1; + } + *netspeed = (NetworkSpeed*)malloc(sizeof(NetworkSpeed)); + memcpy(*netspeed, &android_netspeeds[index], sizeof(NetworkSpeed)); + return 0; +} + +int +corecmd_get_netdelay(int index, NetworkLatency** netdelay) +{ + if (index >= android_netdelays_count || + android_netdelays[index].name == NULL) { + return -1; + } + *netdelay = (NetworkLatency*)malloc(sizeof(NetworkLatency)); + memcpy(*netdelay, &android_netdelays[index], sizeof(NetworkLatency)); + return 0; +} + +int +corecmd_get_qemu_path(int type, + const char* filename, + char* path, + size_t path_buf_size) +{ + char* filepath = qemu_find_file(type, filename); + if (filepath == NULL) { + return -1; + } + strncpy(path, filepath, path_buf_size); + path[path_buf_size - 1] = '\0'; + qemu_free(filepath); + return 0; +} + +int +corecmd_get_hw_lcd_density(void) +{ + return android_hw->hw_lcd_density; +} -- cgit v1.1