1777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine/* Copyright (C) 2010 The Android Open Source Project 2777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** 3777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** This software is licensed under the terms of the GNU General Public 4777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** License version 2, as published by the Free Software Foundation, and 5777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** may be copied, distributed, and modified under those terms. 6777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** 7777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** This program is distributed in the hope that it will be useful, 8777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** but WITHOUT ANY WARRANTY; without even the implied warranty of 9777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine** GNU General Public License for more details. 11777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine*/ 12777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 13777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine/* 14777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine * Contains implementation of the API for calling into the Core with the UI 15777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine * control commands for standalone (monolithic) emulator. 16777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine */ 17777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 18777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine#include "android/android.h" 19777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine#include "android/globals.h" 20777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine#include "android/hw-sensors.h" 21777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine#include "telephony/modem_driver.h" 22406a59bd0a2e7a38cd840a5c08602e3a36bd2df8David 'Digit' Turner#include "android-trace.h" 23777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine#include "audio/audio.h" 24777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine#include "android/protocol/core-commands-api.h" 25777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 26777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine/* Implemented in vl-android.c */ 27777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineextern char* qemu_find_file(int type, const char* filename); 28777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 29777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint 30777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkinecorecmd_set_coarse_orientation(AndroidCoarseOrientation orient) 31777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 32777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine android_sensors_set_coarse_orientation(orient); 33777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return 0; 34777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 35777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 36777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint 37777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkinecorecmd_toggle_network() 38777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 39777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine qemu_net_disable = !qemu_net_disable; 40777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine if (android_modem) { 41777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine amodem_set_data_registration( 42777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine android_modem, 43777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine qemu_net_disable ? A_REGISTRATION_UNREGISTERED 44777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine : A_REGISTRATION_HOME); 45777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine } 46777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return 0; 47777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 48777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 49777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint corecmd_trace_control(int start) 50777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 51777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine if (start) { 52777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine start_tracing(); 53777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine } else { 54777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine stop_tracing(); 55777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine } 56777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return 0; 57777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 58777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 59777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint corecmd_is_network_disabled() 60777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 61777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return qemu_net_disable; 62777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 63777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 64777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint 65777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkinecorecmd_get_netspeed(int index, NetworkSpeed** netspeed) 66777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 67777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine if (index >= android_netspeeds_count || 68777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine android_netspeeds[index].name == NULL) { 69777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return -1; 70777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine } 71777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine *netspeed = (NetworkSpeed*)malloc(sizeof(NetworkSpeed)); 72777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine memcpy(*netspeed, &android_netspeeds[index], sizeof(NetworkSpeed)); 73777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return 0; 74777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 75777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 76777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint 77777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkinecorecmd_get_netdelay(int index, NetworkLatency** netdelay) 78777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 79777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine if (index >= android_netdelays_count || 80777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine android_netdelays[index].name == NULL) { 81777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return -1; 82777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine } 83777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine *netdelay = (NetworkLatency*)malloc(sizeof(NetworkLatency)); 84777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine memcpy(*netdelay, &android_netdelays[index], sizeof(NetworkLatency)); 85777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return 0; 86777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 87777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 88777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint 89777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkinecorecmd_get_qemu_path(int type, 90777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine const char* filename, 91777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine char* path, 92777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine size_t path_buf_size) 93777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 94777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine char* filepath = qemu_find_file(type, filename); 95777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine if (filepath == NULL) { 96777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return -1; 97777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine } 98777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine strncpy(path, filepath, path_buf_size); 99777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine path[path_buf_size - 1] = '\0'; 100777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine qemu_free(filepath); 101777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return 0; 102777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 103777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine 104777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkineint 105777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkinecorecmd_get_hw_lcd_density(void) 106777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine{ 107777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine return android_hw->hw_lcd_density; 108777eb68eb60cac18f4b62e2e1b14a906875cbe7aVladimir Chtchetkine} 109