From f721e3ac031f892af46f255a47d7f54a91317b30 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 18:28:35 -0800 Subject: auto import from //depot/cupcake/@135843 --- android/android.h | 100 - android/avd/hardware-properties.ini | 158 - android/avd/hw-config-defs.h | 165 - android/avd/hw-config.c | 39 - android/avd/hw-config.h | 46 - android/avd/info.c | 1585 ------- android/avd/info.h | 161 - android/build/binary.make | 34 - android/build/clear_vars.make | 30 - android/build/definitions.make | 109 - android/build/getdir.make | 19 - android/build/host_executable.make | 34 - android/build/host_static_library.make | 35 - android/build/mkdeps.sh | 51 - android/charmap.c | 148 - android/charmap.h | 133 - android/cmdline-option.c | 255 -- android/cmdline-option.h | 42 - android/cmdline-options.h | 131 - android/config.c | 467 -- android/config.h | 57 - android/config/Linux/config-host.h | 10 - android/config/check-alsa.c | 107 - android/config/check-esd.c | 67 - android/config/config.h | 14 - android/config/darwin-ppc/config-host.h | 13 - android/config/darwin-x86/config-host.h | 13 - android/config/linux-x86/config-host.h | 10 - android/config/windows/config-host.h | 10 - android/console.c | 2190 --------- android/globals.h | 33 - android/gps.c | 37 - android/gps.h | 23 - android/help.c | 1432 ------ android/help.h | 36 - android/hw-control.c | 204 - android/hw-control.h | 38 - android/hw-events.c | 223 - android/hw-events.h | 184 - android/hw-kmsg.c | 70 - android/hw-kmsg.h | 31 - android/icons.h | 984 ---- android/main.c | 2889 ------------ android/qemud.c | 456 -- android/qemud.h | 72 - android/resource.c | 64 - android/resource.h | 26 - android/skin/argb.h | 856 ---- android/skin/composer.c | 401 -- android/skin/composer.h | 102 - android/skin/default.h | 7414 ------------------------------- android/skin/file.c | 693 --- android/skin/file.h | 132 - android/skin/image.c | 742 ---- android/skin/image.h | 92 - android/skin/keyboard.c | 783 ---- android/skin/keyboard.h | 59 - android/skin/keyset.c | 542 --- android/skin/keyset.h | 122 - android/skin/rect.c | 241 - android/skin/rect.h | 71 - android/skin/region.c | 1448 ------ android/skin/region.h | 103 - android/skin/scaler.c | 135 - android/skin/scaler.h | 39 - android/skin/surface.c | 613 --- android/skin/surface.h | 101 - android/skin/trackball.c | 625 --- android/skin/trackball.h | 43 - android/skin/window.c | 1516 ------- android/skin/window.h | 65 - android/tools/gen-hw-config.py | 141 - android/utils/bufprint.c | 230 - android/utils/bufprint.h | 76 - android/utils/debug.c | 141 - android/utils/debug.h | 91 - android/utils/dirscanner.c | 203 - android/utils/dirscanner.h | 51 - android/utils/display-quartz.m | 111 - android/utils/display.c | 245 - android/utils/display.h | 31 - android/utils/filelock.c | 414 -- android/utils/filelock.h | 38 - android/utils/ini.c | 386 -- android/utils/ini.h | 126 - android/utils/misc.c | 193 - android/utils/misc.h | 67 - android/utils/path.c | 430 -- android/utils/path.h | 122 - android/utils/reflist.c | 203 - android/utils/reflist.h | 129 - android/utils/stralloc.c | 300 -- android/utils/stralloc.h | 60 - android/utils/system.c | 172 - android/utils/system.h | 161 - android/utils/tempfile.c | 198 - android/utils/tempfile.h | 52 - android/utils/timezone.c | 721 --- android/utils/timezone.h | 31 - 99 files changed, 35096 deletions(-) delete mode 100644 android/android.h delete mode 100644 android/avd/hardware-properties.ini delete mode 100644 android/avd/hw-config-defs.h delete mode 100644 android/avd/hw-config.c delete mode 100644 android/avd/hw-config.h delete mode 100644 android/avd/info.c delete mode 100644 android/avd/info.h delete mode 100644 android/build/binary.make delete mode 100644 android/build/clear_vars.make delete mode 100644 android/build/definitions.make delete mode 100644 android/build/getdir.make delete mode 100644 android/build/host_executable.make delete mode 100644 android/build/host_static_library.make delete mode 100755 android/build/mkdeps.sh delete mode 100644 android/charmap.c delete mode 100644 android/charmap.h delete mode 100644 android/cmdline-option.c delete mode 100644 android/cmdline-option.h delete mode 100644 android/cmdline-options.h delete mode 100644 android/config.c delete mode 100644 android/config.h delete mode 100644 android/config/Linux/config-host.h delete mode 100644 android/config/check-alsa.c delete mode 100644 android/config/check-esd.c delete mode 100644 android/config/config.h delete mode 100644 android/config/darwin-ppc/config-host.h delete mode 100644 android/config/darwin-x86/config-host.h delete mode 100644 android/config/linux-x86/config-host.h delete mode 100644 android/config/windows/config-host.h delete mode 100644 android/console.c delete mode 100644 android/globals.h delete mode 100644 android/gps.c delete mode 100644 android/gps.h delete mode 100644 android/help.c delete mode 100644 android/help.h delete mode 100644 android/hw-control.c delete mode 100644 android/hw-control.h delete mode 100644 android/hw-events.c delete mode 100644 android/hw-events.h delete mode 100644 android/hw-kmsg.c delete mode 100644 android/hw-kmsg.h delete mode 100644 android/icons.h delete mode 100644 android/main.c delete mode 100644 android/qemud.c delete mode 100644 android/qemud.h delete mode 100644 android/resource.c delete mode 100644 android/resource.h delete mode 100644 android/skin/argb.h delete mode 100644 android/skin/composer.c delete mode 100644 android/skin/composer.h delete mode 100644 android/skin/default.h delete mode 100644 android/skin/file.c delete mode 100644 android/skin/file.h delete mode 100644 android/skin/image.c delete mode 100644 android/skin/image.h delete mode 100644 android/skin/keyboard.c delete mode 100644 android/skin/keyboard.h delete mode 100644 android/skin/keyset.c delete mode 100644 android/skin/keyset.h delete mode 100644 android/skin/rect.c delete mode 100644 android/skin/rect.h delete mode 100644 android/skin/region.c delete mode 100644 android/skin/region.h delete mode 100644 android/skin/scaler.c delete mode 100644 android/skin/scaler.h delete mode 100644 android/skin/surface.c delete mode 100644 android/skin/surface.h delete mode 100644 android/skin/trackball.c delete mode 100644 android/skin/trackball.h delete mode 100644 android/skin/window.c delete mode 100644 android/skin/window.h delete mode 100755 android/tools/gen-hw-config.py delete mode 100644 android/utils/bufprint.c delete mode 100644 android/utils/bufprint.h delete mode 100644 android/utils/debug.c delete mode 100644 android/utils/debug.h delete mode 100644 android/utils/dirscanner.c delete mode 100644 android/utils/dirscanner.h delete mode 100644 android/utils/display-quartz.m delete mode 100644 android/utils/display.c delete mode 100644 android/utils/display.h delete mode 100644 android/utils/filelock.c delete mode 100644 android/utils/filelock.h delete mode 100644 android/utils/ini.c delete mode 100644 android/utils/ini.h delete mode 100644 android/utils/misc.c delete mode 100644 android/utils/misc.h delete mode 100644 android/utils/path.c delete mode 100644 android/utils/path.h delete mode 100644 android/utils/reflist.c delete mode 100644 android/utils/reflist.h delete mode 100644 android/utils/stralloc.c delete mode 100644 android/utils/stralloc.h delete mode 100644 android/utils/system.c delete mode 100644 android/utils/system.h delete mode 100644 android/utils/tempfile.c delete mode 100644 android/utils/tempfile.h delete mode 100644 android/utils/timezone.c delete mode 100644 android/utils/timezone.h (limited to 'android') diff --git a/android/android.h b/android/android.h deleted file mode 100644 index 71a20f6..0000000 --- a/android/android.h +++ /dev/null @@ -1,100 +0,0 @@ -/* Copyright (C) 2007 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. -*/ -#ifndef _qemu_android_h -#define _qemu_android_h - -#define ANDROID_VERSION_MAJOR 1 -#define ANDROID_VERSION_MINOR 9 - -#define CONFIG_SHAPER 1 - -#include -#include -#include - -/** in vl.c */ - -/* emulated network up/down speeds, expressed in bits/seconds */ -extern double qemu_net_upload_speed; -extern double qemu_net_download_speed; - -/* emulated network min-max latency, expressed in ms */ -extern int qemu_net_min_latency; -extern int qemu_net_max_latency; - -/* global flag, when true, network is disabled */ -extern int qemu_net_disable; - -/* list of supported network speed names and values in bits/seconds */ -typedef struct { - const char* name; - const char* display; - int upload; - int download; -} NetworkSpeed; - -extern const NetworkSpeed android_netspeeds[]; - -/* list of supported network latency names and min-max values in ms */ -typedef struct { - const char* name; - const char* display; - int min_ms; - int max_ms; -} NetworkLatency; - -extern const NetworkLatency android_netdelays[]; - -/* enable/disable interrupt polling mode. the emulator will always use 100% - * of host CPU time, but will get high-quality time measurments. this is - * required for the tracing mode unless you can bear 10ms granularities - */ -extern void qemu_polling_enable(void); -extern void qemu_polling_disable(void); - -/**in hw/goldfish_fb.c */ - -/* framebuffer dimensions in pixels, note these can change dynamically */ -extern int android_framebuffer_w; -extern int android_framebuffer_h; -/* framebuffer dimensions in mm */ -extern int android_framebuffer_phys_w; -extern int android_framebuffer_phys_h; - -/* framebuffer rotation, relative to device */ -typedef enum { - ANDROID_ROTATION_0 = 0, - ANDROID_ROTATION_90, - ANDROID_ROTATION_180, - ANDROID_ROTATION_270 -} AndroidRotation; - -extern AndroidRotation android_framebuffer_rotation; - -/** in android_main.c */ - -/* this is the port used for the control console in this emulator instance. - * starts at 5554, with increments of 2 */ -extern int android_base_port; - -/* parses a network speed parameter and sets qemu_net_upload_speed and - * qemu_net_download_speed accordingly. returns -1 on failure, 0 on success */ -extern int android_parse_network_speed(const char* speed); - -/* parse a network delay parameter and sets qemu_net_min/max_latency - * accordingly. returns -1 on error, 0 on success */ -extern int android_parse_network_latency(const char* delay); - -extern void android_emulation_setup( void ); -extern void android_emulation_teardown( void ); - -#endif /* _qemu_android_h */ diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini deleted file mode 100644 index f2293d1..0000000 --- a/android/avd/hardware-properties.ini +++ /dev/null @@ -1,158 +0,0 @@ -# This file describes the properties of a given virtual device configuration file. -# -# Note: Most top-level properties are boolean that control whether a feature is -# present or not. Sub-features that depend on it are ignored if their -# parent is set to 'false' or 'no' -# -# This file is parsed by 'android/tools/gen-hw-config.py' to generate -# 'android/avd/hw-config-defs.h'. The latter is a special header containing -# macro statements that is used several times: -# -# - once to define the fields of the AndroidHwConfig structure -# (see android/avd/hw-config.h) -# -# - once to implement the hardware configuration loader -# (see android/avd/hw-config.h) -# -# Hopefully, this file should also be read by a virtual device creation -# tool/wizard to provide a nice user interface (hence the presence of -# the 'abstract' and 'description' keys which are not currently used) -# -# -# NOTE: if you remove items from this file, be sure that you do not break -# the emulator build. -# - -# Ram size -name = hw.ramSize -type = integer -default = 96 -abstract = Device ram size -description = The amount of physical RAM on the device, in megabytes. - -# Touch screen support -name = hw.touchScreen -type = boolean -default = yes -abstract = Touch-screen support -description = Whether there is a touch screen or not on the device. - -# Trackball support -name = hw.trackBall -type = boolean -default = yes -abstract = Track-ball support -description = Whether there is a trackball on the device. - -# Keyboard support (qwerty/azerty) -name = hw.keyboard -type = boolean -default = yes -abstract = Keyboard support -description = Whether the device has a QWERTY keyboard. - -# DPad keys -name = hw.dPad -type = boolean -default = yes -abstract = DPad support -description = Whether the device has DPad keys - -# GSM Modem support -name = hw.gsmModem -type = boolean -default = yes -abstract = GSM modem support -description = Whether there is a GSM modem in the device. - -# Wifi support -name = hw.wifi -type = boolean -default = no -abstract = Wifi support -description = Whether the device has a Wifi chipset. - -# Bluetooth support -name = hw.bluetooth -type = boolean -default = no -abstract = Bluetooth support -description = Whether the device has a Bluetooth chipset. - -# Camera support -name = hw.camera -type = boolean -default = no -abstract = Camera support -description = Whether the device has a camera. - -name = hw.camera.maxHorizontalPixels -type = integer -default = 640 -abstract = Maximum horizontal camera pixels - -name = hw.camera.maxVerticalPixels -type = integer -default = 480 -abstract = Maximum vertical camera pixels - -# GPS support -name = hw.gps -type = boolean -default = no -abstract = GPS support -description = Whether there is a GPS in the device. - -# Accelerometer -name = hw.accelerometer -type = boolean -default = no -abstract = Accelerometer support -description = Whether there is an accelerometer in the device. - -# Battery -name = hw.battery -type = boolean -default = yes -abstract = Battery support -description = Whether the device can run on a battery. - -# Audio input -name = hw.audioInput -type = boolean -default = yes -abstract = Audio recording support -description = Whether the device can record audio - -# Audio output -name = hw.audioOutput -type = boolean -default = yes -abstract = Audio playback support -description = Whether the device can play audio - -# Compass -name = hw.compass -type = boolean -default = no -abstract = Compass support -description = Whether there is a compass in the device. - -# SDCard support -name = hw.sdCard -type = boolean -default = yes -abstract = SD Card support -description = Whether the device supports insertion/removal of virtual SD Cards. - -# Cache partition -name = disk.cachePartition -type = boolean -default = yes -abstract = Cache partition support -description = Whether we use a /cache partition on the device. - -name = disk.cachePartition.size -type = diskSize -abstract = Cache partition size -default = 66MB diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h deleted file mode 100644 index 5c3b9ab..0000000 --- a/android/avd/hw-config-defs.h +++ /dev/null @@ -1,165 +0,0 @@ -/* this file is automatically generated from 'hardware-properties.ini' - * DO NOT EDIT IT. To re-generate it, use android/tools/gen-hw-config.py' - */ -#ifndef HWCFG_INT -#error HWCFG_INT not defined -#endif -#ifndef HWCFG_BOOL -#error HWCFG_BOOL not defined -#endif -#ifndef HWCFG_DISKSIZE -#error HWCFG_DISKSIZE not defined -#endif -#ifndef HWCFG_STRING -#error HWCFG_STRING not defined -#endif -#ifndef HWCFG_DOUBLE -#error HWCFG_DOUBLE not defined -#endif - -HWCFG_INT( - hw_ramSize, - "hw.ramSize", - 96, - "Device ram size", - "The amount of physical RAM on the device, in megabytes.") - -HWCFG_BOOL( - hw_touchScreen, - "hw.touchScreen", - "yes", - "Touch-screen support", - "Whether there is a touch screen or not on the device.") - -HWCFG_BOOL( - hw_trackBall, - "hw.trackBall", - "yes", - "Track-ball support", - "Whether there is a trackball on the device.") - -HWCFG_BOOL( - hw_keyboard, - "hw.keyboard", - "yes", - "Keyboard support", - "Whether the device has a QWERTY keyboard.") - -HWCFG_BOOL( - hw_dPad, - "hw.dPad", - "yes", - "DPad support", - "Whether the device has DPad keys") - -HWCFG_BOOL( - hw_gsmModem, - "hw.gsmModem", - "yes", - "GSM modem support", - "Whether there is a GSM modem in the device.") - -HWCFG_BOOL( - hw_wifi, - "hw.wifi", - "no", - "Wifi support", - "Whether the device has a Wifi chipset.") - -HWCFG_BOOL( - hw_bluetooth, - "hw.bluetooth", - "no", - "Bluetooth support", - "Whether the device has a Bluetooth chipset.") - -HWCFG_BOOL( - hw_camera, - "hw.camera", - "no", - "Camera support", - "Whether the device has a camera.") - -HWCFG_INT( - hw_camera_maxHorizontalPixels, - "hw.camera.maxHorizontalPixels", - 640, - "Maximum horizontal camera pixels", - "") - -HWCFG_INT( - hw_camera_maxVerticalPixels, - "hw.camera.maxVerticalPixels", - 480, - "Maximum vertical camera pixels", - "") - -HWCFG_BOOL( - hw_gps, - "hw.gps", - "no", - "GPS support", - "Whether there is a GPS in the device.") - -HWCFG_BOOL( - hw_accelerometer, - "hw.accelerometer", - "no", - "Accelerometer support", - "Whether there is an accelerometer in the device.") - -HWCFG_BOOL( - hw_battery, - "hw.battery", - "yes", - "Battery support", - "Whether the device can run on a battery.") - -HWCFG_BOOL( - hw_audioInput, - "hw.audioInput", - "yes", - "Audio recording support", - "Whether the device can record audio") - -HWCFG_BOOL( - hw_audioOutput, - "hw.audioOutput", - "yes", - "Audio playback support", - "Whether the device can play audio") - -HWCFG_BOOL( - hw_compass, - "hw.compass", - "no", - "Compass support", - "Whether there is a compass in the device.") - -HWCFG_BOOL( - hw_sdCard, - "hw.sdCard", - "yes", - "SD Card support", - "Whether the device supports insertion/removal of virtual SD Cards.") - -HWCFG_BOOL( - disk_cachePartition, - "disk.cachePartition", - "yes", - "Cache partition support", - "Whether we use a /cache partition on the device.") - -HWCFG_DISKSIZE( - disk_cachePartition_size, - "disk.cachePartition.size", - "66MB", - "Cache partition size", - "") - -#undef HWCFG_INT -#undef HWCFG_BOOL -#undef HWCFG_DISKSIZE -#undef HWCFG_STRING -#undef HWCFG_DOUBLE -/* end of auto-generated file */ diff --git a/android/avd/hw-config.c b/android/avd/hw-config.c deleted file mode 100644 index 2362b59..0000000 --- a/android/avd/hw-config.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (C) 2008 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. -*/ -#include "android/avd/hw-config.h" -#include "android/utils/ini.h" -#include -#include - - -/* the global variable containing the hardware config for this device */ -AndroidHwConfig android_hw[1]; - -int -androidHwConfig_read( AndroidHwConfig* config, - IniFile* ini ) -{ - if (ini == NULL) - return -1; - - /* use the magic of macros to implement the hardware configuration loaded */ - -#define HWCFG_BOOL(n,s,d,a,t) config->n = iniFile_getBoolean(ini, s, d); -#define HWCFG_INT(n,s,d,a,t) config->n = iniFile_getInteger(ini, s, d); -#define HWCFG_STRING(n,s,d,a,t) config->n = iniFile_getString(ini, s, d); -#define HWCFG_DOUBLE(n,s,d,a,t) config->n = iniFile_getDouble(ini, s, d); -#define HWCFG_DISKSIZE(n,s,d,a,t) config->n = iniFile_getDiskSize(ini, s, d); - -#include "android/avd/hw-config-defs.h" - - return 0; -} diff --git a/android/avd/hw-config.h b/android/avd/hw-config.h deleted file mode 100644 index 05eb828..0000000 --- a/android/avd/hw-config.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (C) 2008 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. -*/ -#ifndef _ANDROID_AVD_HW_CONFIG_H -#define _ANDROID_AVD_HW_CONFIG_H - -#include -#include "android/utils/ini.h" - -typedef char hw_bool_t; -typedef int hw_int_t; -typedef int64_t hw_disksize_t; -typedef char* hw_string_t; -typedef double hw_double_t; - -/* these macros are used to define the fields of AndroidHwConfig - * declared below - */ -#define HWCFG_BOOL(n,s,d,a,t) hw_bool_t n; -#define HWCFG_INT(n,s,d,a,t) hw_int_t n; -#define HWCFG_STRING(n,s,d,a,t) hw_string_t n; -#define HWCFG_DOUBLE(n,s,d,a,t) hw_double_t n; -#define HWCFG_DISKSIZE(n,s,d,a,t) hw_disksize_t n; - -typedef struct { -#include "android/avd/hw-config-defs.h" -} AndroidHwConfig; - -/* reads a hardware configuration file from disk. - * returns -1 if the file could not be read, or 0 in case of success. - * - * note that default values are written to hwConfig if the configuration - * file doesn't have the corresponding hardware properties. - */ -int androidHwConfig_read( AndroidHwConfig* hwConfig, - IniFile* configFile ); - -#endif /* _ANDROID_AVD_HW_CONFIG_H */ diff --git a/android/avd/info.c b/android/avd/info.c deleted file mode 100644 index 432e279..0000000 --- a/android/avd/info.c +++ /dev/null @@ -1,1585 +0,0 @@ -/* Copyright (C) 2008 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. -*/ -#include "android/avd/info.h" -#include "android/utils/path.h" -#include "android/utils/bufprint.h" -#include "android/utils/filelock.h" -#include "android/utils/tempfile.h" -#include "android/utils/debug.h" -#include "android/utils/dirscanner.h" -#include "qemu-common.h" -#include -#include -#include -#include - -/* global variables - see android/globals.h */ -AvdInfoParams android_avdParams[1]; -AvdInfo* android_avdInfo; - -/* for debugging */ -#define D(...) VERBOSE_PRINT(init,__VA_ARGS__) -#define DD(...) VERBOSE_PRINT(avd_config,__VA_ARGS__) - -/* technical note on how all of this is supposed to work: - * - * we assume the following SDK layout: - * - * SDK/ - * tools/ - * emulator[.exe] - * libs/ - * hardware-properties.ini - * ... - * - * platforms/ - * / - * build.prop - * images/ - * - * skins/ - * default/ --> default skin - * layout - * - * / --> another skin - * layout - * - * / --> skin alias to - * alias- - * - * / - * build.prop - * images/ - * - * - * add-ons/ - * / - * manifest.ini - * images/ - * - * - * / - * manifest.ini - * - * hardware.ini - * skins/ - * default/ - * layout - * - * / - * layout - * - * - * - * we define a 'platform' as a directory that provides a complete - * set of disk/kernel images, some skins, as well as a build.prop - * file. - * - * we define an 'addon' as a directory that provides additionnal - * or replacement files related to a given existing platform. - * each add-on provides at the minimum a 'manifest.ini' file - * that describes it (see below). - * - * important notes: - * - * - the build.prop file of a given platform directory contains - * a line that reads 'ro.build.version.sdk=' where - * is an integer corresponding to the corresponding - * official API version number as defined by Android. - * - * each platform provided with the SDK must have a unique - * version number. - * - * - the manifest.ini of a given addon must contain lines - * that include: - * - * name= - * vendor= - * api= - * - * where is used to identify the platform the add-on - * refers to. Note that the platform's directory name is - * irrelevant to the matching algorithm. - * - * each addon available must have a unique - * :: triplet - * - * - an add-on can provide a hardware.ini file. If present, this - * is used to force the hardware setting of any virtual device - * built from the add-on. - * - * - the file in SDK/tools/lib/hardware-properties.ini declares which - * hardware properties are supported by the emulator binary. - * these can appear in the config.ini file of a given virtual - * device, or the hardware.ini of a given add-on. - * - * normally, a virtual device corresponds to: - * - * - a root configuration file, placed in ~/.android/avd/.ini - * where is the name of the virtual device. - * - * - a "content" directory, which contains disk images for the - * virtual device (e.g. at a minimum, the userdata.img file) - * plus some configuration information. - * - * - the root config file must have at least two lines like: - * - * path= - * target= - * - * the 'path' value must point to the location of - * the virtual device's content directory. By default, this - * should be ~/.android/avd//, though the user should be - * able to choose an alternative path at creation time. - * - * the 'target' value can be one of: - * - * android- - * :: - * - * the first form is used to refer to a given platform. - * the second form is used to refer to a unique add-on. - * in both forms, must be an integer that - * matches one of the available platforms. - * - * :: must match the triplet of one - * of the available add-ons - * - * if the target value is incorrect, or if the content path - * is invalid, the emulator will abort with an error. - * - * - the content directory shall contain a 'config.ini' that - * contains hardware properties for the virtual device - * (as defined by SDK/tools/lib/hardware-properties.ini), as - * well as additional lines like: - * - * sdcard= - * skin= - * options= - * - * - * Finally, to find the skin to be used with a given virtual - * device, the following logic is used: - * - * - if no skin name has been manually specified on - * the command line, or in the config.ini file, - * look in $CONTENT/skin/layout and use it if available. - * - * - otherwise, set SKINNAME to 'default' if not manually - * specified, and look for $ADDON/skins/$SKINNAME/layout - * and use it if available - * - * - otherwise, look for $PLATFORM/skins/$SKINNAME/layout - * and use it if available. - * - * - otherwise, look for $PLATFORM/skins/$SKINNAME/alias-. - * if a file exist by that name, look at $PLATFORM/skins//layout - * and use it if available. Aliases are not recursives :-) - */ - -/* now, things get a little bit more complicated when working - * within the Android build system. In this mode, which can be - * detected by looking at the definition of the ANDROID_PRODUCT_OUT - * environment variable, we're going to simply pick the image files - * from the out directory, or from $BUILDROOT/prebuilt - */ - -/* the name of the $SDKROOT subdirectory that contains all platforms */ -#define PLATFORMS_SUBDIR "platforms" - -/* the name of the $SDKROOT subdirectory that contains add-ons */ -#define ADDONS_SUBDIR "add-ons" - -/* this is the subdirectory of $HOME/.android where all - * root configuration files (and default content directories) - * are located. - */ -#define ANDROID_AVD_DIR "avd" - -/* certain disk image files are mounted read/write by the emulator - * to ensure that several emulators referencing the same files - * do not corrupt these files, we need to lock them and respond - * to collision depending on the image type. - * - * the enumeration below is used to record information about - * each image file path. - * - * READONLY means that the file will be mounted read-only - * and this doesn't need to be locked. must be first in list - * - * MUSTLOCK means that the file should be locked before - * being mounted by the emulator - * - * TEMPORARY means that the file has been copied to a - * temporary image, which can be mounted read/write - * but doesn't require locking. - */ -typedef enum { - IMAGE_STATE_READONLY, /* unlocked */ - IMAGE_STATE_MUSTLOCK, /* must be locked */ - IMAGE_STATE_LOCKED, /* locked */ - IMAGE_STATE_LOCKED_EMPTY, /* locked and empty */ - IMAGE_STATE_TEMPORARY, /* copied to temp file (no lock needed) */ -} AvdImageState; - -struct AvdInfo { - /* for the Android build system case */ - char inAndroidBuild; - char* androidOut; - char* androidBuildRoot; - - /* for the normal virtual device case */ - char* deviceName; - char* sdkRootPath; - int platformVersion; - char* platformPath; - char* addonTarget; - char* addonPath; - char* contentPath; - IniFile* rootIni; /* root .ini file */ - IniFile* configIni; /* virtual device's config.ini */ - - /* for both */ - char* skinName; /* skin name */ - char* skinDirPath; /* skin directory */ - - /* image files */ - char* imagePath [ AVD_IMAGE_MAX ]; - char imageState[ AVD_IMAGE_MAX ]; -}; - - -void -avdInfo_free( AvdInfo* i ) -{ - if (i) { - int nn; - - for (nn = 0; nn < AVD_IMAGE_MAX; nn++) - qemu_free(i->imagePath[nn]); - - qemu_free(i->skinName); - qemu_free(i->skinDirPath); - - if (i->configIni) { - iniFile_free(i->configIni); - i->configIni = NULL; - } - - if (i->rootIni) { - iniFile_free(i->rootIni); - i->rootIni = NULL; - } - - qemu_free(i->contentPath); - qemu_free(i->sdkRootPath); - - if (i->inAndroidBuild) { - qemu_free(i->androidOut); - qemu_free(i->androidBuildRoot); - } else { - qemu_free(i->platformPath); - qemu_free(i->addonTarget); - qemu_free(i->addonPath); - } - - qemu_free(i->deviceName); - qemu_free(i); - } -} - -/* list of default file names for each supported image file type */ -static const char* const _imageFileNames[ AVD_IMAGE_MAX ] = { -#define _AVD_IMG(x,y,z) y, - AVD_IMAGE_LIST -#undef _AVD_IMG -}; - -/* list of short text description for each supported image file type */ -static const char* const _imageFileText[ AVD_IMAGE_MAX ] = { -#define _AVD_IMG(x,y,z) z, - AVD_IMAGE_LIST -#undef _AVD_IMG -}; - -/*************************************************************** - *************************************************************** - ***** - ***** NORMAL VIRTUAL DEVICE SUPPORT - ***** - *****/ - -/* compute path to the root SDK directory - * assume we are in $SDKROOT/tools/emulator[.exe] - */ -static int -_getSdkRoot( AvdInfo* i ) -{ - const char* env; - char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); - -#define SDK_ROOT_ENV "ANDROID_SDK_ROOT" - - env = getenv(SDK_ROOT_ENV); - if (env != NULL && env[0] != 0) { - if (path_exists(env)) { - D("found " SDK_ROOT_ENV ": %s", env); - i->sdkRootPath = qemu_strdup(env); - return 0; - } - D(SDK_ROOT_ENV " points to unknown directory: %s", env); - } - - (void) bufprint_app_dir(temp, end); - - i->sdkRootPath = path_parent(temp, 1); - if (i->sdkRootPath == NULL) { - derror("can't find root of SDK directory"); - return -1; - } - D("found SDK root at %s", i->sdkRootPath); - return 0; -} - -/* returns the full path of the platform subdirectory - * corresponding to a given API version - */ -static char* -_findPlatformByVersion( const char* sdkRoot, int version ) -{ - char temp[PATH_MAX], *p=temp, *end=p+sizeof temp; - char* subdir = NULL; - DirScanner* scanner; - - DD("> %s(%s,%d)", __FUNCTION__, sdkRoot, version); - p = bufprint(temp, end, "%s/%s", sdkRoot, PLATFORMS_SUBDIR); - if (p >= end) { - DD("! path too long"); - return NULL; - } - - scanner = dirScanner_new(temp); - if (scanner == NULL) { - DD("! cannot scan path %s: %s", temp, strerror(errno)); - return NULL; - } - - for (;;) { - IniFile* ini; - int apiVersion; - - subdir = (char*) dirScanner_nextFull(scanner); - if (subdir == NULL) - break; - - /* look for a file named "build.prop */ - p = bufprint(temp, end, "%s/build.prop", subdir); - if (p >= end) - continue; - - if (!path_exists(temp)) { - DD("! no file at %s", temp); - continue; - } - - ini = iniFile_newFromFile(temp); - if (ini == NULL) - continue; - - apiVersion = iniFile_getInteger(ini, "ro.build.version.sdk", -1); - iniFile_free(ini); - - DD("! found %s (version %d)", temp, apiVersion); - - if (apiVersion == version) { - /* Bingo */ - subdir = qemu_strdup(subdir); - break; - } - } - - if (!subdir) { - DD("< didn't found anything"); - } - - dirScanner_free(scanner); - return subdir; -} - -/* returns the full path of the addon corresponding to a given target, - * or NULL if not found. on success, *pversion will contain the SDK - * version number - */ -static char* -_findAddonByTarget( const char* sdkRoot, const char* target, int *pversion ) -{ - char* targetCopy = qemu_strdup(target); - char* targetVendor = NULL; - char* targetName = NULL; - int targetVersion = -1; - - char temp[PATH_MAX]; - char* p; - char* end; - DirScanner* scanner; - char* subdir; - - DD("> %s(%s,%s)", __FUNCTION__, sdkRoot, target); - - /* extract triplet from target string */ - targetVendor = targetCopy; - - p = strchr(targetVendor, ':'); - if (p == NULL) { - DD("< missing first column separator"); - goto FAIL; - } - *p = 0; - targetName = p + 1; - p = strchr(targetName, ':'); - if (p == NULL) { - DD("< missing second column separator"); - goto FAIL; - } - *p++ = 0; - - targetVersion = atoi(p); - - if (targetVersion == 0) { - DD("< invalid version number"); - goto FAIL; - } - /* now scan addons directory */ - p = temp; - end = p + sizeof temp; - - p = bufprint(p, end, "%s/%s", sdkRoot, ADDONS_SUBDIR); - if (p >= end) { - DD("< add-on path too long"); - goto FAIL; - } - scanner = dirScanner_new(temp); - if (scanner == NULL) { - DD("< cannot scan add-on path %s: %s", temp, strerror(errno)); - goto FAIL; - } - for (;;) { - IniFile* ini; - const char* vendor; - const char* name; - int version; - int matches; - - subdir = (char*) dirScanner_nextFull(scanner); - if (subdir == NULL) - break; - - /* try to open the manifest.ini file */ - p = bufprint(temp, end, "%s/manifest.ini", subdir); - if (p >= end) - continue; - - ini = iniFile_newFromFile(temp); - if (ini == NULL) - continue; - - DD("! scanning manifest.ini in %s", temp); - - /* find the vendor, name and version */ - vendor = iniFile_getValue(ini, "vendor"); - name = iniFile_getValue(ini, "name"); - version = iniFile_getInteger(ini, "api", -1); - - matches = 0; - - matches += (version == targetVersion); - matches += (vendor && !strcmp(vendor, targetVendor)); - matches += (name && !strcmp(name, targetName)); - - DD("! matches=%d vendor=[%s] name=[%s] version=%d", - matches, - vendor ? vendor : "", - name ? name : "", - version); - - iniFile_free(ini); - - if (matches == 3) { - /* bingo */ - *pversion = version; - subdir = qemu_strdup(subdir); - break; - } - } - - dirScanner_free(scanner); - - DD("< returning %s", subdir ? subdir : ""); - return subdir; - -FAIL: - qemu_free(targetCopy); - return NULL; -} - -static int -_checkAvdName( const char* name ) -{ - int len = strlen(name); - int len2 = strspn(name, "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789_.-"); - return (len == len2); -} - -/* parse the root config .ini file. it is located in - * ~/.android/avd/.ini or Windows equivalent - */ -static int -_getRootIni( AvdInfo* i ) -{ - char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); - - p = bufprint_config_path(temp, end); - p = bufprint(p, end, "/" ANDROID_AVD_DIR "/%s.ini", i->deviceName); - if (p >= end) { - derror("device name too long"); - return -1; - } - - i->rootIni = iniFile_newFromFile(temp); - if (i->rootIni == NULL) { - derror("unknown virtual device name: '%s'", i->deviceName); - return -1; - } - D("root virtual device file at %s", temp); - return 0; -} - -/* the .ini variable name that points to the content directory - * in a root AVD ini file. This is required */ -# define ROOT_PATH_KEY "path" -# define ROOT_TARGET_KEY "target" - -/* retrieve the content path and target from the root .ini file */ -static int -_getTarget( AvdInfo* i ) -{ - i->contentPath = iniFile_getString(i->rootIni, ROOT_PATH_KEY); - i->addonTarget = iniFile_getString(i->rootIni, ROOT_TARGET_KEY); - - iniFile_free(i->rootIni); - i->rootIni = NULL; - - if (i->contentPath == NULL) { - derror("bad config: %s", - "virtual device file lacks a "ROOT_PATH_KEY" entry"); - return -1; - } - - if (i->addonTarget == NULL) { - derror("bad config: %s", - "virtual device file lacks a "ROOT_TARGET_KEY" entry"); - return -1; - } - - D("virtual device content at %s", i->contentPath); - D("virtual device target is %s", i->addonTarget); - - if (!strncmp(i->addonTarget, "android-", 8)) { /* target is platform */ - char* end; - const char* versionString = i->addonTarget+8; - int version = (int) strtol(versionString, &end, 10); - if (*end != 0 || version <= 0) { - derror("bad config: invalid platform version: '%s'", versionString); - return -1; - } - i->platformVersion = version; - i->platformPath = _findPlatformByVersion(i->sdkRootPath, - version); - if (i->platformPath == NULL) { - derror("bad config: unknown platform version: '%d'", version); - return -1; - } - } - else /* target is add-on */ - { - i->addonPath = _findAddonByTarget(i->sdkRootPath, i->addonTarget, - &i->platformVersion); - if (i->addonPath == NULL) { - derror("bad config: %s", - "unknown add-on target: '%s'", i->addonTarget); - return -1; - } - - i->platformPath = _findPlatformByVersion(i->sdkRootPath, - i->platformVersion); - if (i->platformPath == NULL) { - derror("bad config: %s", - "unknown add-on platform version: '%d'", i->platformVersion); - return -1; - } - D("virtual device add-on path: %s", i->addonPath); - } - D("virtual device platform path: %s", i->platformPath); - D("virtual device platform version %d", i->platformVersion); - return 0; -} - - -/* find and parse the config.ini file from the content directory */ -static int -_getConfigIni(AvdInfo* i) -{ - char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); - - p = bufprint(p, end, "%s/config.ini", i->contentPath); - if (p >= end) { - derror("can't access virtual device content directory"); - return -1; - } - -#if 1 /* XXX: TODO: remove this in the future */ - /* for now, allow a non-existing config.ini */ - if (!path_exists(temp)) { - D("virtual device has no config file - no problem"); - return 0; - } -#endif - - i->configIni = iniFile_newFromFile(temp); - if (i->configIni == NULL) { - derror("bad config: %s", - "virtual device directory lacks config.ini"); - return -1; - } - D("virtual device config file: %s", temp); - return 0; -} - -/*************************************************************** - *************************************************************** - ***** - ***** KERNEL/DISK IMAGE LOADER - ***** - *****/ - -/* a structure used to handle the loading of - * kernel/disk images. - */ -typedef struct { - AvdInfo* info; - AvdInfoParams* params; - AvdImageType id; - const char* imageFile; - const char* imageText; - char** pPath; - char* pState; - char temp[PATH_MAX]; -} ImageLoader; - -static void -imageLoader_init( ImageLoader* l, AvdInfo* info, AvdInfoParams* params ) -{ - memset(l, 0, sizeof(*l)); - l->info = info; - l->params = params; -} - -/* set the type of the image to load */ -static void -imageLoader_set( ImageLoader* l, AvdImageType id ) -{ - l->id = id; - l->imageFile = _imageFileNames[id]; - l->imageText = _imageFileText[id]; - l->pPath = &l->info->imagePath[id]; - l->pState = &l->info->imageState[id]; - - l->pState[0] = IMAGE_STATE_READONLY; -} - -/* change the image path */ -static char* -imageLoader_setPath( ImageLoader* l, const char* path ) -{ - path = path ? qemu_strdup(path) : NULL; - - qemu_free(l->pPath[0]); - l->pPath[0] = (char*) path; - - return (char*) path; -} - -static char* -imageLoader_extractPath( ImageLoader* l ) -{ - char* result = l->pPath[0]; - l->pPath[0] = NULL; - return result; -} - -/* flags used when loading images */ -enum { - IMAGE_REQUIRED = (1<<0), /* image is required */ - IMAGE_SEARCH_SDK = (1<<1), /* search image in SDK */ - IMAGE_EMPTY_IF_MISSING = (1<<2), /* create empty file if missing */ - IMAGE_DONT_LOCK = (1<<4), /* don't try to lock image */ - IMAGE_IGNORE_IF_LOCKED = (1<<5), /* ignore file if it's locked */ -}; - -#define IMAGE_OPTIONAL 0 - -/* find an image from the SDK add-on and/or platform - * directories. returns the full path or NULL if - * the file could not be found. - * - * note: this stores the result in the image's path as well - */ -static char* -imageLoader_lookupSdk( ImageLoader* l ) -{ - AvdInfo* i = l->info; - char* temp = l->temp, *p = temp, *end = p + sizeof(l->temp); - - do { - /* try the add-on directory, if any */ - if (i->addonPath != NULL) { - DD("searching %s in add-on directory: %s", - l->imageFile, i->addonPath); - - p = bufprint(temp, end, "%s/images/%s", - i->addonPath, l->imageFile); - - if (p < end && path_exists(temp)) - break; - } - - /* or try the platform directory */ - DD("searching %s in platform directory: %s", - l->imageFile, i->platformPath); - - p = bufprint(temp, end, "%s/images/%s", - i->platformPath, l->imageFile); - if (p < end && path_exists(temp)) - break; - - DD("could not find %s in SDK", l->imageFile); - return NULL; - - } while (0); - - l->pState[0] = IMAGE_STATE_READONLY; - - return imageLoader_setPath(l, temp); -} - -/* search for a file in the content directory. - * returns NULL if the file cannot be found. - * - * note that this formats l->temp with the file's path - * allowing you to retrieve it if the function returns NULL - */ -static char* -imageLoader_lookupContent( ImageLoader* l ) -{ - AvdInfo* i = l->info; - char* temp = l->temp, *p = temp, *end = p + sizeof(l->temp); - - DD("searching %s in content directory", l->imageFile); - p = bufprint(temp, end, "%s/%s", i->contentPath, l->imageFile); - if (p >= end) { - derror("content directory path too long"); - exit(2); - } - if (!path_exists(temp)) { - DD("not found %s in content directory", l->imageFile); - return NULL; - } - - /* assume content image files must be locked */ - l->pState[0] = IMAGE_STATE_MUSTLOCK; - - return imageLoader_setPath(l, temp); -} - -/* lock a file image depending on its state and user flags - * note that this clears l->pPath[0] if the lock could not - * be acquired and that IMAGE_IGNORE_IF_LOCKED is used. - */ -static void -imageLoader_lock( ImageLoader* l, unsigned flags ) -{ - const char* path = l->pPath[0]; - - if (flags & IMAGE_DONT_LOCK) - return; - - if (l->pState[0] != IMAGE_STATE_MUSTLOCK) - return; - - D("locking %s image at %s", l->imageText, path); - - if (filelock_create(path) != NULL) { - /* succesful lock */ - l->pState[0] = IMAGE_STATE_LOCKED; - return; - } - - if (flags & IMAGE_IGNORE_IF_LOCKED) { - dwarning("ignoring locked %s image at %s", l->imageText, path); - imageLoader_setPath(l, NULL); - return; - } - - derror("the %s image is used by another emulator. aborting", - l->imageText); - exit(2); -} - -/* make a file image empty, this may require locking */ -static void -imageLoader_empty( ImageLoader* l, unsigned flags ) -{ - const char* path; - - imageLoader_lock(l, flags); - - path = l->pPath[0]; - if (path == NULL) /* failed to lock, caller will handle it */ - return; - - if (path_empty_file(path) < 0) { - derror("could not create %s image at %s: %s", - l->imageText, path, strerror(errno)); - exit(2); - } - l->pState[0] = IMAGE_STATE_LOCKED_EMPTY; -} - - -/* copy image file from a given source - * assumes locking is needed. - */ -static void -imageLoader_copyFrom( ImageLoader* l, const char* srcPath ) -{ - const char* dstPath = NULL; - - /* find destination file */ - if (l->params) { - dstPath = l->params->forcePaths[l->id]; - } - if (!dstPath) { - imageLoader_lookupContent(l); - dstPath = l->temp; - } - - /* lock destination */ - imageLoader_setPath(l, dstPath); - l->pState[0] = IMAGE_STATE_MUSTLOCK; - imageLoader_lock(l, 0); - - /* make the copy */ - if (path_copy_file(dstPath, srcPath) < 0) { - derror("can't initialize %s image from SDK: %s: %s", - l->imageText, dstPath, strerror(errno)); - exit(2); - } -} - -/* this will load and eventually lock and image file, depending - * on the flags being used. on exit, this function udpates - * l->pState[0] and l->pPath[0] - * - * returns the path to the file. Note that it returns NULL - * only if the file was optional and could not be found. - * - * if the file is required and missing, the function aborts - * the program. - */ -static char* -imageLoader_load( ImageLoader* l, - unsigned flags ) -{ - const char* path = NULL; - - DD("looking for %s image (%s)", l->imageText, l->imageFile); - - /* first, check user-provided path */ - path = l->params->forcePaths[l->id]; - if (path != NULL) { - imageLoader_setPath(l, path); - if (path_exists(path)) - goto EXIT; - - D("user-provided %s image does not exist: %s", - l->imageText, path); - - /* if the file is required, abort */ - if (flags & IMAGE_REQUIRED) { - derror("user-provided %s image at %s doesn't exist", - l->imageText, path); - exit(2); - } - } - else { - const char* contentFile; - - /* second, look in the content directory */ - path = imageLoader_lookupContent(l); - if (path) goto EXIT; - - contentFile = qemu_strdup(l->temp); - - /* it's not there */ - if (flags & IMAGE_SEARCH_SDK) { - /* third, look in the SDK directory */ - path = imageLoader_lookupSdk(l); - if (path) { - qemu_free((char*)contentFile); - goto EXIT; - } - } - DD("found no %s image (%s)", l->imageText, l->imageFile); - - /* if the file is required, abort */ - if (flags & IMAGE_REQUIRED) { - derror("could not find required %s image (%s)", - l->imageText, l->imageFile); - exit(2); - } - - path = imageLoader_setPath(l, contentFile); - qemu_free((char*)contentFile); - } - - /* otherwise, do we need to create it ? */ - if (flags & IMAGE_EMPTY_IF_MISSING) { - imageLoader_empty(l, flags); - return l->pPath[0]; - } - return NULL; - -EXIT: - imageLoader_lock(l, flags); - return l->pPath[0]; -} - - - -/* find the correct path of all image files we're going to need - * and lock the files that need it. - */ -static int -_getImagePaths(AvdInfo* i, AvdInfoParams* params ) -{ - int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0; - int wipeCache = (params->flags & AVDINFO_WIPE_CACHE) != 0; - int noCache = (params->flags & AVDINFO_NO_CACHE) != 0; - int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0; - - ImageLoader l[1]; - - imageLoader_init(l, i, params); - - /* pick up the kernel and ramdisk image files - these don't - * need a specific handling. - */ - imageLoader_set ( l, AVD_IMAGE_KERNEL ); - imageLoader_load( l, IMAGE_REQUIRED | IMAGE_SEARCH_SDK | IMAGE_DONT_LOCK ); - - imageLoader_set ( l, AVD_IMAGE_RAMDISK ); - imageLoader_load( l, IMAGE_REQUIRED | IMAGE_SEARCH_SDK | IMAGE_DONT_LOCK ); - - /* the system image - * - * if there is one in the content directory just lock - * and use it. - */ - imageLoader_set ( l, AVD_IMAGE_SYSTEM ); - imageLoader_load( l, IMAGE_REQUIRED | IMAGE_SEARCH_SDK ); - - /* the data partition - this one is special because if it - * is missing, we need to copy the initial image file into it. - * - * first, try to see if it is in the content directory - * (or the user-provided path) - */ - imageLoader_set( l, AVD_IMAGE_USERDATA ); - if ( !imageLoader_load( l, IMAGE_OPTIONAL | - IMAGE_EMPTY_IF_MISSING | - IMAGE_DONT_LOCK ) ) - { - /* it's not, we're going to initialize it. simply - * forcing a data wipe should be enough */ - D("initializing new data partition image: %s", l->pPath[0]); - wipeData = 1; - } - - if (wipeData) { - /* find SDK source file */ - const char* srcPath; - - if (imageLoader_lookupSdk(l)) { - derror("can't locate initial %s image in SDK", - l->imageText); - exit(2); - } - srcPath = imageLoader_extractPath(l); - - imageLoader_copyFrom( l, srcPath ); - qemu_free((char*) srcPath); - } - else - { - /* lock the data partition image */ - l->pState[0] = IMAGE_STATE_MUSTLOCK; - imageLoader_lock( l, 0 ); - } - - /* the cache partition: unless the user doesn't want one, - * we're going to create it in the content directory - */ - if (!noCache) { - imageLoader_set (l, AVD_IMAGE_CACHE); - imageLoader_load(l, IMAGE_OPTIONAL | - IMAGE_EMPTY_IF_MISSING ); - - if (wipeCache) { - if (path_empty_file(l->pPath[0]) < 0) { - derror("cannot wipe %s image at %s: %s", - l->imageText, l->pPath[0], - strerror(errno)); - exit(2); - } - } - } - - /* the SD Card image. unless the user doesn't want to, we're - * going to mount it if available. Note that if the image is - * already used, we must ignore it. - */ - if (!noSdCard) { - imageLoader_set (l, AVD_IMAGE_SDCARD); - imageLoader_load(l, IMAGE_OPTIONAL | - IMAGE_IGNORE_IF_LOCKED); - - /* if the file was not found, ignore it */ - if (l->pPath[0] && !path_exists(l->pPath[0])) - { - D("ignoring non-existing %s at %s: %s", - l->imageText, l->pPath[0], strerror(errno)); - - /* if the user provided the SD Card path by hand, - * warn him. */ - if (params->forcePaths[AVD_IMAGE_SDCARD] != NULL) - dwarning("ignoring non-existing SD Card image"); - - imageLoader_setPath(l, NULL); - } - } - - return 0; -} - -/* check that there is a skin named 'skinName' listed from 'skinDirRoot' - * this returns 1 on success, 0 on failure - * on success, the 'temp' buffer will get the path containing the real - * skin directory (after alias expansion), including the skin name. - */ -static int -_checkSkinDir( char* temp, char* end, const char* skinDirRoot, const char* skinName ) -{ - DirScanner* scanner; - char *p, *q; - int result; - - p = bufprint(temp, end, "%s/skins/%s", - skinDirRoot, skinName); - - DD("probing skin content in %s", temp); - - if (p >= end || !path_exists(temp)) { - return 0; - } - - /* first, is this a normal skin directory ? */ - q = bufprint(p, end, "/layout"); - if (q < end && path_exists(temp)) { - /* yes */ - *p = 0; - return 1; - } - - /* second, is it an alias to another skin ? */ - *p = 0; - result = 0; - scanner = dirScanner_new(temp); - if (scanner != NULL) { - for (;;) { - const char* file = dirScanner_next(scanner); - - if (file == NULL) - break; - - if (strncmp(file, "alias-", 6) || file[6] == 0) - continue; - - p = bufprint(temp, end, "%s/skins/%s", - skinDirRoot, file+6); - - q = bufprint(p, end, "/layout"); - if (q < end && path_exists(temp)) { - /* yes, it's an alias */ - *p = 0; - result = 1; - break; - } - } - dirScanner_free(scanner); - } - return result; -} - -static int -_getSkin( AvdInfo* i, AvdInfoParams* params ) -{ - char* skinName; - char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); - char explicitSkin = 1; - - /* determine the skin name, the default is "HVGA" - * unless specified by the caller or in config.ini - */ - if (params->skinName) { - skinName = qemu_strdup(params->skinName); - } else { - skinName = iniFile_getString( i->configIni, "skin" ); - if (skinName == NULL) { - skinName = qemu_strdup("HVGA"); - explicitSkin = 0; - } - } - - i->skinName = skinName; - - /* if the skin name has the format 'NNNNxNNN' where - * NNN is a decimal value, then this is a 'magic' skin - * name that doesn't require a skin directory - */ - if (isdigit(skinName[0])) { - int width, height; - if (sscanf(skinName, "%dx%d", &width, &height) == 2) { - D("'magic' skin format detected: %s", skinName); - i->skinDirPath = NULL; - return 0; - } - } - - /* now try to find the skin directory for that name - - * first try the content directory */ - do { - /* if there is a single 'skin' directory in - * the content directory, assume that's what the - * user wants, unless an explicit name was given - */ - if (!explicitSkin) { - char* q; - - p = bufprint(temp, end, "%s/skin", i->contentPath); - q = bufprint(p, end, "/layout"); - if (q < end && path_exists(temp)) { - /* use this one - cheat a little */ - *p = 0; - D("using skin content from %s", temp); - qemu_free(i->skinName); - i->skinName = qemu_strdup("skin"); - i->skinDirPath = qemu_strdup(i->contentPath); - return 0; - } - } - - /* look in content directory */ - if (_checkSkinDir(temp, end, i->contentPath, skinName)) - break; - - /* look in the add-on directory, if any */ - if (i->addonPath && - _checkSkinDir(temp, end, i->addonPath, skinName)) - break; - - /* look in the platforms directory */ - if (_checkSkinDir(temp, end, i->platformPath, skinName)) - break; - - /* didn't find it */ - if (explicitSkin) - dwarning("could not find directory for skin '%s'", skinName); - - return -1; - - } while (0); - - /* separate skin name from parent directory. the skin name - * returned in 'temp' might be different from the original - * one due to alias expansion so strip it. - */ - p = strrchr(temp, '/'); - if (p == NULL) { - /* should not happen */ - DD("weird skin path: %s", temp); - return -1; - } - - *p = 0; - DD("found skin content in %s", temp); - i->skinDirPath = qemu_strdup(temp); - return 0; -} - - -AvdInfo* -avdInfo_new( const char* name, AvdInfoParams* params ) -{ - AvdInfo* i; - - if (name == NULL) - return NULL; - - if (!_checkAvdName(name)) { - derror("virtual device name contains invalid characters"); - exit(1); - } - - i = qemu_mallocz(sizeof *i); - i->deviceName = qemu_strdup(name); - - if ( _getSdkRoot(i) < 0 || - _getRootIni(i) < 0 || - _getTarget(i) < 0 || - _getConfigIni(i) < 0 ) - goto FAIL; - - if ( _getImagePaths(i, params) < 0 || - _getSkin (i, params) < 0 ) - goto FAIL; - - return i; - -FAIL: - avdInfo_free(i); - return NULL; -} - -/*************************************************************** - *************************************************************** - ***** - ***** ANDROID BUILD SUPPORT - ***** - ***** The code below corresponds to the case where we're - ***** starting the emulator inside the Android build - ***** system. The main differences are that: - ***** - ***** - the $ANDROID_PRODUCT_OUT directory is used as the - ***** content file. - ***** - ***** - built images must not be modified by the emulator, - ***** so system.img must be copied to a temporary file - ***** and userdata.img must be copied to userdata-qemu.img - ***** if the latter doesn't exist. - ***** - ***** - the kernel and default skin directory are taken from - ***** prebuilt - ***** - ***** - there is no root .ini file, or any config.ini in - ***** the content directory, no SDK platform version - ***** and no add-on to consider. - *****/ - -/* used to fake a config.ini located in the content directory */ -static int -_getBuildConfigIni( AvdInfo* i ) -{ - /* a blank file is ok at the moment */ - i->configIni = iniFile_newFromMemory( "", 0 ); - return 0; -} - -static int -_getBuildImagePaths( AvdInfo* i, AvdInfoParams* params ) -{ - int wipeData = (params->flags & AVDINFO_WIPE_DATA) != 0; - int noCache = (params->flags & AVDINFO_NO_CACHE) != 0; - int noSdCard = (params->flags & AVDINFO_NO_SDCARD) != 0; - - char temp[PATH_MAX], *p=temp, *end=p+sizeof temp; - char* srcData; - ImageLoader l[1]; - - imageLoader_init(l, i, params); - - /** load the kernel image - **/ - - /* if it is not in the out directory, get it from prebuilt - */ - imageLoader_set ( l, AVD_IMAGE_KERNEL ); - - if ( !imageLoader_load( l, IMAGE_OPTIONAL | - IMAGE_DONT_LOCK ) ) - { -#define PREBUILT_KERNEL_PATH "prebuilt/android-arm/kernel/kernel-qemu" - p = bufprint(temp, end, "%s/%s", i->androidBuildRoot, - PREBUILT_KERNEL_PATH); - if (p >= end || !path_exists(temp)) { - derror("bad workspace: cannot find prebuilt kernel in: %s", temp); - exit(1); - } - imageLoader_setPath(l, temp); - } - - /** load the data partition. note that we use userdata-qemu.img - ** since we don't want to modify userdata.img at all - **/ - imageLoader_set ( l, AVD_IMAGE_USERDATA ); - imageLoader_load( l, IMAGE_OPTIONAL | IMAGE_DONT_LOCK ); - - /* get the path of the source file, and check that it actually exists - * if the user didn't provide an explicit data file - */ - srcData = imageLoader_extractPath(l); - if (srcData == NULL && params->forcePaths[AVD_IMAGE_USERDATA] == NULL) { - derror("There is no %s image in your build directory. Please make a full build", - l->imageText, l->imageFile); - exit(2); - } - - /* get the path of the target file */ - l->imageFile = "userdata-qemu.img"; - imageLoader_load( l, IMAGE_OPTIONAL | - IMAGE_EMPTY_IF_MISSING | - IMAGE_IGNORE_IF_LOCKED ); - - /* force a data wipe if we just created the image */ - if (l->pState[0] == IMAGE_STATE_LOCKED_EMPTY) - wipeData = 1; - - /* if the image was already locked, create a temp file - * then force a data wipe. - */ - if (l->pPath[0] == NULL) { - TempFile* temp = tempfile_create(); - imageLoader_setPath(l, tempfile_path(temp)); - dwarning( "Another emulator is running. user data changes will *NOT* be saved"); - wipeData = 1; - } - - /* in the case of a data wipe, copy userdata.img into - * the destination */ - if (wipeData) { - if (srcData == NULL || !path_exists(srcData)) { - derror("There is no %s image in your build directory. Please make a full build", - l->imageText, _imageFileNames[l->id]); - exit(2); - } - if (path_copy_file( l->pPath[0], srcData ) < 0) { - derror("could not initialize %s image from %s: %s", - l->imageText, temp, strerror(errno)); - exit(2); - } - } - - qemu_free(srcData); - - /** load the ramdisk image - **/ - imageLoader_set ( l, AVD_IMAGE_RAMDISK ); - imageLoader_load( l, IMAGE_REQUIRED | - IMAGE_DONT_LOCK ); - - /** load the system image. read-only. the caller must - ** take care of checking the state - **/ - imageLoader_set ( l, AVD_IMAGE_SYSTEM ); - imageLoader_load( l, IMAGE_REQUIRED | IMAGE_DONT_LOCK ); - - /* force the system image to read-only status */ - l->pState[0] = IMAGE_STATE_READONLY; - - /** cache partition handling - **/ - if (!noCache) { - imageLoader_set (l, AVD_IMAGE_CACHE); - - /* if the user provided one cache image, lock & use it */ - if ( params->forcePaths[l->id] != NULL ) { - imageLoader_load(l, IMAGE_REQUIRED | - IMAGE_IGNORE_IF_LOCKED); - } - } - - /** SD Card image - **/ - if (!noSdCard) { - imageLoader_set (l, AVD_IMAGE_SDCARD); - imageLoader_load(l, IMAGE_OPTIONAL | IMAGE_IGNORE_IF_LOCKED); - } - - return 0; -} - -static int -_getBuildSkin( AvdInfo* i, AvdInfoParams* params ) -{ - /* the (current) default skin name for our build system */ - const char* skinName = params->skinName; - const char* skinDir = params->skinRootPath; - char temp[PATH_MAX], *p=temp, *end=p+sizeof(temp); - char* q; - - if (!skinName) { - /* the (current) default skin name for the build system */ - skinName = "HVGA"; - DD("selecting default skin name '%s'", skinName); - } - - i->skinName = qemu_strdup(skinName); - - if (!skinDir) { - -#define PREBUILT_SKINS_DIR "development/emulator/skins" - - /* the (current) default skin directory */ - p = bufprint( temp, end, "%s/%s", - i->androidBuildRoot, PREBUILT_SKINS_DIR ); - } else { - p = bufprint( temp, end, "%s", skinDir ); - } - - q = bufprint(p, end, "/%s/layout", skinName); - if (q >= end || !path_exists(temp)) { - DD("skin content directory does not exist: %s", temp); - if (skinDir) - dwarning("could not find valid skin '%s' in %s:\n", - skinName, temp); - return -1; - } - *p = 0; - DD("found skin path: %s", temp); - i->skinDirPath = qemu_strdup(temp); - - return 0; -} - -AvdInfo* -avdInfo_newForAndroidBuild( const char* androidBuildRoot, - const char* androidOut, - AvdInfoParams* params ) -{ - AvdInfo* i; - - i = qemu_mallocz(sizeof *i); - - i->inAndroidBuild = 1; - i->androidBuildRoot = qemu_strdup(androidBuildRoot); - i->androidOut = qemu_strdup(androidOut); - i->contentPath = qemu_strdup(androidOut); - - /* TODO: find a way to provide better information from the build files */ - i->deviceName = qemu_strdup(""); - - if (_getBuildConfigIni(i) < 0 || - _getBuildImagePaths(i, params) < 0 ) - goto FAIL; - - /* we don't need to fail if there is no valid skin */ - _getBuildSkin(i, params); - - return i; - -FAIL: - avdInfo_free(i); - return NULL; -} - -const char* -avdInfo_getName( AvdInfo* i ) -{ - return i ? i->deviceName : NULL; -} - -const char* -avdInfo_getImageFile( AvdInfo* i, AvdImageType imageType ) -{ - if (i == NULL || (unsigned)imageType >= AVD_IMAGE_MAX) - return NULL; - - return i->imagePath[imageType]; -} - -int -avdInfo_isImageReadOnly( AvdInfo* i, AvdImageType imageType ) -{ - if (i == NULL || (unsigned)imageType >= AVD_IMAGE_MAX) - return 1; - - return (i->imageState[imageType] == IMAGE_STATE_READONLY); -} - -const char* -avdInfo_getSkinName( AvdInfo* i ) -{ - return i->skinName; -} - -const char* -avdInfo_getSkinDir ( AvdInfo* i ) -{ - return i->skinDirPath; -} - -int -avdInfo_getHwConfig( AvdInfo* i, AndroidHwConfig* hw ) -{ - IniFile* ini = i->configIni; - int ret; - - if (ini == NULL) - ini = iniFile_newFromMemory("", 0); - - ret = androidHwConfig_read(hw, ini); - - if (ini != i->configIni) - iniFile_free(ini); - - return ret; -} - - -char* -avdInfo_getTracePath( AvdInfo* i, const char* traceName ) -{ - char tmp[MAX_PATH], *p=tmp, *end=p + sizeof(tmp); - - if (i == NULL || traceName == NULL || traceName[0] == 0) - return NULL; - - if (i->inAndroidBuild) { - p = bufprint( p, end, "%s" PATH_SEP "traces" PATH_SEP "%s", - i->androidOut, traceName ); - } else { - p = bufprint( p, end, "%s" PATH_SEP "traces" PATH_SEP "%s", - i->contentPath, traceName ); - } - return qemu_strdup(tmp); -} diff --git a/android/avd/info.h b/android/avd/info.h deleted file mode 100644 index ad8a138..0000000 --- a/android/avd/info.h +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (C) 2008 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. -*/ -#ifndef ANDROID_AVD_INFO_H -#define ANDROID_AVD_INFO_H - -#include "android/utils/ini.h" -#include "android/avd/hw-config.h" - -/* An Android Virtual Device (AVD for short) corresponds to a - * directory containing all kernel/disk images for a given virtual - * device, as well as information about its hardware capabilities, - * SDK version number, skin, etc... - * - * Each AVD has a human-readable name and is backed by a root - * configuration file and a content directory. For example, an - * AVD named 'foo' will correspond to the following: - * - * - a root configuration file named ~/.android/avd/foo.ini - * describing where the AVD's content can be found - * - * - a content directory like ~/.android/avd/foo/ containing all - * disk image and configuration files for the virtual device. - * - * the 'foo.ini' file should contain at least one line of the form: - * - * rootPath= - * - * it may also contain other lines that cache stuff found in the - * content directory, like hardware properties or SDK version number. - * - * it is possible to move the content directory by updating the foo.ini - * file to point to the new location. This can be interesting when your - * $HOME directory is located on a network share or in a roaming profile - * (Windows), given that the content directory of a single virtual device - * can easily use more than 100MB of data. - * - */ - -/* a macro used to define the list of disk images managed by the - * implementation. This macro will be expanded several times with - * varying definitions of _AVD_IMG - */ -#define AVD_IMAGE_LIST \ - _AVD_IMG(KERNEL,"kernel-qemu","kernel") \ - _AVD_IMG(RAMDISK,"ramdisk.img","ramdisk") \ - _AVD_IMG(SYSTEM,"system.img","system") \ - _AVD_IMG(USERDATA,"userdata.img","user data") \ - _AVD_IMG(CACHE,"cache.img","cache") \ - _AVD_IMG(SDCARD,"sdcard.img","SD Card") \ - -/* define the enumared values corresponding to each AVD image type - * examples are: AVD_IMAGE_KERNEL, AVD_IMAGE_SYSTEM, etc.. - */ -#define _AVD_IMG(x,y,z) AVD_IMAGE_##x , -typedef enum { - AVD_IMAGE_LIST - AVD_IMAGE_MAX /* do not remove */ -} AvdImageType; -#undef _AVD_IMG - -/* AvdInfo is an opaque structure used to model the information - * corresponding to a given AVD instance - */ -typedef struct AvdInfo AvdInfo; - -/* various flags used when creating an AvdInfo object */ -typedef enum { - /* use to force a data wipe */ - AVDINFO_WIPE_DATA = (1 << 0), - /* use to ignore the cache partition */ - AVDINFO_NO_CACHE = (1 << 1), - /* use to wipe cache partition, ignored if NO_CACHE is set */ - AVDINFO_WIPE_CACHE = (1 << 2), - /* use to ignore ignore SDCard image (default or provided) */ - AVDINFO_NO_SDCARD = (1 << 3), -} AvdFlags; - -typedef struct { - unsigned flags; - const char* skinName; - const char* skinRootPath; - const char* forcePaths[AVD_IMAGE_MAX]; -} AvdInfoParams; - -/* Creates a new AvdInfo object from a name. Returns NULL if name is NULL - * or contains characters that are not part of the following list: - * letters, digits, underscores, dashes and periods - */ -AvdInfo* avdInfo_new( const char* name, AvdInfoParams* params ); - -/* A special function used to setup an AvdInfo for use when starting - * the emulator from the Android build system. In this specific instance - * we're going to create temporary files to hold all writable image - * files, and activate all hardware features by default - * - * 'androidBuildRoot' must be the absolute path to the root of the - * Android build system (i.e. the 'android' directory) - * - * 'androidOut' must be the target-specific out directory where - * disk images will be looked for. - */ -AvdInfo* avdInfo_newForAndroidBuild( const char* androidBuildRoot, - const char* androidOut, - AvdInfoParams* params ); - -/* Frees an AvdInfo object and the corresponding strings that may be - * returned by its getXXX() methods - */ -void avdInfo_free( AvdInfo* i ); - -/* Return the name of the Android Virtual Device - */ -const char* avdInfo_getName( AvdInfo* i ); - -/* Try to find the path of a given image file, returns NULL - * if the corresponding file could not be found. the string - * belongs to the AvdInfo object. - */ -const char* avdInfo_getImageFile( AvdInfo* i, AvdImageType imageType ); - -/* Returns 1 if the corresponding image file is read-only - */ -int avdInfo_isImageReadOnly( AvdInfo* i, AvdImageType imageType ); - -/* lock an image file if it is writable. returns 0 on success, or -1 - * otherwise. note that if the file is read-only, it doesn't need to - * be locked and the function will return success. - */ -int avdInfo_lockImageFile( AvdInfo* i, AvdImageType imageType, int abortOnError); - -/* Manually set the path of a given image file. */ -void avdInfo_setImageFile( AvdInfo* i, AvdImageType imageType, const char* imagePath ); - -/* Returns the path of the skin directory */ -/* the string belongs to the AvdInfo object */ -const char* avdInfo_getSkinPath( AvdInfo* i ); - -/* Returns the name of the virtual device's skin */ -const char* avdInfo_getSkinName( AvdInfo* i ); - -/* Returns the root skin directory for this device */ -const char* avdInfo_getSkinDir ( AvdInfo* i ); - -/* Reads the AVD's hardware configuration into 'hw'. returns -1 on error, 0 otherwise */ -int avdInfo_getHwConfig( AvdInfo* i, AndroidHwConfig* hw ); - -/* Returns a *copy* of the path used to store trace 'foo'. result must be freed by caller */ -char* avdInfo_getTracePath( AvdInfo* i, const char* traceName ); - -/* */ - -#endif /* ANDROID_AVD_INFO_H */ diff --git a/android/build/binary.make b/android/build/binary.make deleted file mode 100644 index 1c75d52..0000000 --- a/android/build/binary.make +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# definitions shared by host_executable.make and host_static_library.make -# - -# the directory where we're going to place our object files -LOCAL_OBJS_DIR := $(call intermediates-dir-for,EXECUTABLES,$(LOCAL_MODULE)) -LOCAL_OBJECTS := -LOCAL_CC ?= $(CC) -LOCAL_C_SOURCES := $(filter %.c,$(LOCAL_SRC_FILES)) -LOCAL_OBJC_SOURCES := $(filter %.m,$(LOCAL_SRC_FILES)) - -$(foreach src,$(LOCAL_C_SOURCES), \ - $(eval $(call compile-c-source,$(src))) \ -) - -$(foreach src,$(LOCAL_OBJC_SOURCES), \ - $(eval $(call compile-objc-source,$(src))) \ -) - -CLEAN_OBJS_DIRS += $(LOCAL_OBJS_DIR) diff --git a/android/build/clear_vars.make b/android/build/clear_vars.make deleted file mode 100644 index a9289b0..0000000 --- a/android/build/clear_vars.make +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# called multiple times to clear variables used to define a given 'module' -# -LOCAL_NO_DEFAULT_COMPILER_FLAGS:= -LOCAL_CC := -LOCAL_CXX := -LOCAL_CFLAGS := -LOCAL_LDFLAGS := -LOCAL_LDLIBS := -LOCAL_SRC_FILES := -LOCAL_MODULE := -LOCAL_MODULE_PATH:= -LOCAL_STATIC_LIBRARIES := -LOCAL_BUILT_MODULE := -LOCAL_PREBUILT_OBJ_FILES := - diff --git a/android/build/definitions.make b/android/build/definitions.make deleted file mode 100644 index cd03f89..0000000 --- a/android/build/definitions.make +++ /dev/null @@ -1,109 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# shared definitions -ifeq ($(strip $(SHOW)),) -define pretty -@echo $1 -endef -hide := @ -else -define pretty -endef -hide := -endif - -define my-dir -. -endef - -# return the directory containing the intermediate files for a given -# kind of executable -# $1 = type (EXECUTABLES or STATIC_LIBRARIES) -# $2 = module name -# $3 = ignored -# -define intermediates-dir-for -$(OBJS_DIR)/intermediates/$(2) -endef - -# Generate the full path of a given static library -define library-path -$(OBJS_DIR)/$(1).a -endef - -define executable-path -$(OBJS_DIR)/$(1)$(EXE) -endef - -# Compile a C source file -# -define compile-c-source -SRC:=$(1) -OBJ:=$$(LOCAL_OBJS_DIR)/$$(SRC:%.c=%.o) -LOCAL_OBJECTS += $$(OBJ) -DEPENDENCY_DIRS += $$(dir $$(OBJ)) -$$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(OBJS_DIR) -$$(OBJ): PRIVATE_CC := $$(LOCAL_CC) -$$(OBJ): PRIVATE_OBJ := $$(OBJ) -$$(OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) -$$(OBJ): PRIVATE_SRC := $$(SRC_PATH)/$$(SRC) -$$(OBJ): PRIVATE_SRC0 := $$(SRC) -$$(OBJ): $$(SRC_PATH)/$$(SRC) - @mkdir -p $$(dir $$(PRIVATE_OBJ)) - @echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)" - $(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC) - $(hide) $$(SRC_PATH)/android/build/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d -endef - -# Compile an Objective-C source file -# -define compile-objc-source -SRC:=$(1) -OBJ:=$$(LOCAL_OBJS_DIR)/$$(SRC:%.m=%.o) -LOCAL_OBJECTS += $$(OBJ) -DEPENDENCY_DIRS += $$(dir $$(OBJ)) -$$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(OBJS_DIR) -$$(OBJ): PRIVATE_CC := $$(LOCAL_CC) -$$(OBJ): PRIVATE_OBJ := $$(OBJ) -$$(OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE) -$$(OBJ): PRIVATE_SRC := $$(SRC_PATH)/$$(SRC) -$$(OBJ): PRIVATE_SRC0 := $$(SRC) -$$(OBJ): $$(SRC_PATH)/$$(SRC) - @mkdir -p $$(dir $$(PRIVATE_OBJ)) - @echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)" - $(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC) - $(hide) $$(SRC_PATH)/android/build/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d -endef - -# for now, we only use prebuilt SDL libraries, so copy them -define copy-prebuilt-lib -_SRC := $(1) -_SRC1 := $$(notdir $$(_SRC)) -_DST := $$(OBJS_DIR)/$$(_SRC1) -LIBRARIES += $$(_DST) -$$(_DST): PRIVATE_DST := $$(_DST) -$$(_DST): PRIVATE_SRC := $$(_SRC) -$$(_DST): $$(_SRC) - @mkdir -p $$(dir $$(PRIVATE_DST)) - @echo "Prebuilt: $$(PRIVATE_DST)" - $(hide) cp -f $$(PRIVATE_SRC) $$(PRIVATE_DST) -endef - -define create-dir -$(1): - mkdir -p $(1) -endef - diff --git a/android/build/getdir.make b/android/build/getdir.make deleted file mode 100644 index a4dadd3..0000000 --- a/android/build/getdir.make +++ /dev/null @@ -1,19 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# used to return in 'dir' the name of the current operating system -# we really get the value from the configuration script -# -dir := $(HOST_OS) diff --git a/android/build/host_executable.make b/android/build/host_executable.make deleted file mode 100644 index 62f4762..0000000 --- a/android/build/host_executable.make +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# first, call a library containing all object files -LOCAL_BUILT_MODULE := $(call executable-path,$(LOCAL_MODULE)) -LOCAL_CC ?= $(CC) -include $(BUILD_SYSTEM)/binary.make - -LOCAL_LDLIBS := $(foreach lib,$(LOCAL_STATIC_LIBRARIES),$(call library-path,$(lib))) $(LOCAL_LDLIBS) - -$(LOCAL_BUILT_MODULE): PRIVATE_LDFLAGS := $(LDFLAGS) $(LOCAL_LDFLAGS) -$(LOCAL_BUILT_MODULE): PRIVATE_LDLIBS := $(LOCAL_LDLIBS) -$(LOCAL_BUILT_MODULE): PRIVATE_OBJS := $(LOCAL_OBJECTS) - -$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS) - @ mkdir -p $(dir $@) - @ echo "Executable: $@" - $(hide) $(LD) $(PRIVATE_LDFLAGS) -o $@ $(PRIVATE_LIBRARY) $(PRIVATE_OBJS) $(PRIVATE_LDLIBS) - -EXECUTABLES += $(LOCAL_BUILT_MODULE) -$(LOCAL_BUILT_MODULE): $(foreach lib,$(LOCAL_STATIC_LIBRARIES),$(call library-path,$(lib))) - diff --git a/android/build/host_static_library.make b/android/build/host_static_library.make deleted file mode 100644 index 3de5a99..0000000 --- a/android/build/host_static_library.make +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -# build a host executable, the name of the final executable should be -# put in LOCAL_BUILT_MODULE for use by the caller -# - -#$(info STATIC_LIBRARY SRCS=$(LOCAL_SRC_FILES)) -LOCAL_BUILT_MODULE := $(call library-path,$(LOCAL_MODULE)) -LOCAL_CC ?= $(CC) -include $(BUILD_SYSTEM)/binary.make - -LOCAL_AR ?= $(AR) -ARFLAGS := crs - -$(LOCAL_BUILT_MODULE): PRIVATE_AR := $(LOCAL_AR) -$(LOCAL_BUILT_MODULE): PRIVATE_OBJECTS := $(LOCAL_OBJECTS) -$(LOCAL_BUILT_MODULE): $(LOCAL_OBJECTS) - @mkdir -p $(dir $@) - @echo "Library: $@" - $(hide) $(PRIVATE_AR) $(ARFLAGS) $@ $(PRIVATE_OBJECTS) - -LIBRARIES += $(LOCAL_BUILT_MODULE) diff --git a/android/build/mkdeps.sh b/android/build/mkdeps.sh deleted file mode 100755 index abecec7..0000000 --- a/android/build/mkdeps.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# Copyright (C) 2008 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# This script is used to transform the dependency files generated by GCC -# For example, a typical .d file will have a line like: -# -# source.o: /full/path/to/source.c other.h headers.h -# ... -# -# the script is used to replace 'source.o' to a full path, as in -# -# objs/intermediates/emulator/source.o: /full/path/to/source.c other.h headers.h -# -# parameters -# -# $1: object file (full path) -# $2: source dependency file to modify (erased on success) -# $3: target source dependency file -# - -# quote the object path. we change a single '.' into -# a '\.' since this will be parsed by sed. -# -OBJECT=`echo $1 | sed -e s/\\\\./\\\\\\\\./g` -#echo OBJECT=$OBJECT - -OBJ_NAME=`basename $OBJECT` -#echo OBJ_NAME=$OBJ_NAME - -# we replace $OBJ_NAME with $OBJECT only if $OBJ_NAME starts the line -# that's because some versions of GCC (e.g. 4.2.3) already produce -# a correct dependency line with the full path to the object file. -# In this case, we don't want to touch anything -# -cat $2 | sed -e s%^$OBJ_NAME%$OBJECT%g > $3 && rm -f $2 - - - diff --git a/android/charmap.c b/android/charmap.c deleted file mode 100644 index c8ed2d6..0000000 --- a/android/charmap.c +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -#include "android/charmap.h" - -/* the following is automatically generated by the 'gen-charmap.py' script - * do not touch. the generation command was: - * gen-charmap.py qwerty.kcm qwerty2.kcm - */ - -static const AKeyEntry _qwerty_keys[] = -{ - /* keycode base caps fn caps+fn number */ - - { kKeyCodeA , 'a', 'A', '#', 0x00, '#' }, - { kKeyCodeB , 'b', 'B', '<', 0x00, '<' }, - { kKeyCodeC , 'c', 'C', '9', 0x00E7, '9' }, - { kKeyCodeD , 'd', 'D', '5', 0x00, '5' }, - { kKeyCodeE , 'e', 'E', '2', 0x0301, '2' }, - { kKeyCodeF , 'f', 'F', '6', 0x00A5, '6' }, - { kKeyCodeG , 'g', 'G', '-', '_', '-' }, - { kKeyCodeH , 'h', 'H', '[', '{', '[' }, - { kKeyCodeI , 'i', 'I', '$', 0x0302, '$' }, - { kKeyCodeJ , 'j', 'J', ']', '}', ']' }, - { kKeyCodeK , 'k', 'K', '"', '~', '"' }, - { kKeyCodeL , 'l', 'L', '\'', '`', '\'' }, - { kKeyCodeM , 'm', 'M', '!', 0x00, '!' }, - { kKeyCodeN , 'n', 'N', '>', 0x0303, '>' }, - { kKeyCodeO , 'o', 'O', '(', 0x00, '(' }, - { kKeyCodeP , 'p', 'P', ')', 0x00, ')' }, - { kKeyCodeQ , 'q', 'Q', '*', 0x0300, '*' }, - { kKeyCodeR , 'r', 'R', '3', 0x20AC, '3' }, - { kKeyCodeS , 's', 'S', '4', 0x00DF, '4' }, - { kKeyCodeT , 't', 'T', '+', 0x00A3, '+' }, - { kKeyCodeU , 'u', 'U', '&', 0x0308, '&' }, - { kKeyCodeV , 'v', 'V', '=', '^', '=' }, - { kKeyCodeW , 'w', 'W', '1', 0x00, '1' }, - { kKeyCodeX , 'x', 'X', '8', 0x00, '8' }, - { kKeyCodeY , 'y', 'Y', '%', 0x00A1, '%' }, - { kKeyCodeZ , 'z', 'Z', '7', 0x00, '7' }, - { kKeyCodeComma , ',', ';', ';', '|', ',' }, - { kKeyCodePeriod , '.', ':', ':', 0x2026, '.' }, - { kKeyCodeAt , '@', '0', '0', 0x2022, '0' }, - { kKeyCodeSlash , '/', '?', '?', '\\', '/' }, - { kKeyCodeSpace , 0x20, 0x20, 0x9, 0x9, 0x20 }, - { kKeyCodeNewline , 0xa, 0xa, 0xa, 0xa, 0xa }, - { kKeyCodeTab , 0x9, 0x9, 0x9, 0x9, 0x9 }, - { kKeyCode0 , '0', ')', '0', ')', '0' }, - { kKeyCode1 , '1', '!', '1', '!', '1' }, - { kKeyCode2 , '2', '@', '2', '@', '2' }, - { kKeyCode3 , '3', '#', '3', '#', '3' }, - { kKeyCode4 , '4', '$', '4', '$', '4' }, - { kKeyCode5 , '5', '%', '5', '%', '5' }, - { kKeyCode6 , '6', '^', '6', '^', '6' }, - { kKeyCode7 , '7', '&', '7', '&', '7' }, - { kKeyCode8 , '8', '*', '8', '*', '8' }, - { kKeyCode9 , '9', '(', '9', '(', '9' }, - { kKeyCodeGrave , '`', '~', '`', '~', '`' }, - { kKeyCodeMinus , '-', '_', '-', '_', '-' }, - { kKeyCodeEquals , '=', '+', '=', '+', '=' }, - { kKeyCodeLeftBracket , '[', '{', '[', '{', '[' }, - { kKeyCodeRightBracket , ']', '}', ']', '}', ']' }, - { kKeyCodeBackslash , '\\', '|', '\\', '|', '\\' }, - { kKeyCodeSemicolon , ';', ':', ';', ':', ';' }, - { kKeyCodeApostrophe , '\'', '"', '\'', '"', '\'' }, -}; - -static const AKeyCharmap _qwerty_charmap = -{ - _qwerty_keys, - 51, - "qwerty" -}; - -static const AKeyEntry _qwerty2_keys[] = -{ - /* keycode base caps fn caps+fn number */ - - { kKeyCodeA , 'a', 'A', 'a', 'A', 'a' }, - { kKeyCodeB , 'b', 'B', 'b', 'B', 'b' }, - { kKeyCodeC , 'c', 'C', 0x00e7, 0x00E7, 'c' }, - { kKeyCodeD , 'd', 'D', '\'', '\'', '\'' }, - { kKeyCodeE , 'e', 'E', '"', 0x0301, '"' }, - { kKeyCodeF , 'f', 'F', '[', '[', '[' }, - { kKeyCodeG , 'g', 'G', ']', ']', ']' }, - { kKeyCodeH , 'h', 'H', '<', '<', '<' }, - { kKeyCodeI , 'i', 'I', '-', 0x0302, '-' }, - { kKeyCodeJ , 'j', 'J', '>', '>', '>' }, - { kKeyCodeK , 'k', 'K', ';', '~', ';' }, - { kKeyCodeL , 'l', 'L', ':', '`', ':' }, - { kKeyCodeM , 'm', 'M', '%', 0x00, '%' }, - { kKeyCodeN , 'n', 'N', 0x00, 0x0303, 'n' }, - { kKeyCodeO , 'o', 'O', '+', '+', '+' }, - { kKeyCodeP , 'p', 'P', '=', 0x00A5, '=' }, - { kKeyCodeQ , 'q', 'Q', '|', 0x0300, '|' }, - { kKeyCodeR , 'r', 'R', '`', 0x20AC, '`' }, - { kKeyCodeS , 's', 'S', '\\', 0x00DF, '\\' }, - { kKeyCodeT , 't', 'T', '{', 0x00A3, '}' }, - { kKeyCodeU , 'u', 'U', '_', 0x0308, '_' }, - { kKeyCodeV , 'v', 'V', 'v', 'V', 'v' }, - { kKeyCodeW , 'w', 'W', '~', '~', '~' }, - { kKeyCodeX , 'x', 'X', 'x', 'X', 'x' }, - { kKeyCodeY , 'y', 'Y', '}', 0x00A1, '}' }, - { kKeyCodeZ , 'z', 'Z', 'z', 'Z', 'z' }, - { kKeyCodeComma , ',', '<', ',', ',', ',' }, - { kKeyCodePeriod , '.', '>', '.', 0x2026, '.' }, - { kKeyCodeAt , '@', '@', '@', 0x2022, '@' }, - { kKeyCodeSlash , '/', '?', '?', '?', '/' }, - { kKeyCodeSpace , 0x20, 0x20, 0x9, 0x9, 0x20 }, - { kKeyCodeNewline , 0xa, 0xa, 0xa, 0xa, 0xa }, - { kKeyCode0 , '0', ')', ')', ')', '0' }, - { kKeyCode1 , '1', '!', '!', '!', '1' }, - { kKeyCode2 , '2', '@', '@', '@', '2' }, - { kKeyCode3 , '3', '#', '#', '#', '3' }, - { kKeyCode4 , '4', '$', '$', '$', '4' }, - { kKeyCode5 , '5', '%', '%', '%', '5' }, - { kKeyCode6 , '6', '^', '^', '^', '6' }, - { kKeyCode7 , '7', '&', '&', '&', '7' }, - { kKeyCode8 , '8', '*', '*', '*', '8' }, - { kKeyCode9 , '9', '(', '(', '(', '9' }, - { kKeyCodeTab , 0x9, 0x9, 0x9, 0x9, 0x9 }, - { kKeyCodeGrave , '`', '~', '`', '~', '`' }, - { kKeyCodeMinus , '-', '_', '-', '_', '-' }, - { kKeyCodeEquals , '=', '+', '=', '+', '=' }, - { kKeyCodeLeftBracket , '[', '{', '[', '{', '[' }, - { kKeyCodeRightBracket , ']', '}', ']', '}', ']' }, - { kKeyCodeBackslash , '\\', '|', '\\', '|', '\\' }, - { kKeyCodeSemicolon , ';', ':', ';', ':', ';' }, - { kKeyCodeApostrophe , '\'', '"', '\'', '"', '\'' }, -}; - -static const AKeyCharmap _qwerty2_charmap = -{ - _qwerty2_keys, - 51, - "qwerty2" -}; - -const AKeyCharmap* android_charmaps[2] = { &_qwerty_charmap , &_qwerty2_charmap }; -const int android_charmap_count = 2; diff --git a/android/charmap.h b/android/charmap.h deleted file mode 100644 index f300e68..0000000 --- a/android/charmap.h +++ /dev/null @@ -1,133 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -#ifndef _android_charmap_h -#define _android_charmap_h - -#include "linux_keycodes.h" - -/* Keep it consistent with linux/input.h */ -typedef enum { - kKeyCodeSoftLeft = KEY_SOFT1, - kKeyCodeSoftRight = KEY_SOFT2, - kKeyCodeHome = KEY_HOME, - kKeyCodeBack = KEY_BACK, - kKeyCodeCall = KEY_SEND, - kKeyCodeEndCall = KEY_END, - kKeyCode0 = KEY_0, - kKeyCode1 = KEY_1, - kKeyCode2 = KEY_2, - kKeyCode3 = KEY_3, - kKeyCode4 = KEY_4, - kKeyCode5 = KEY_5, - kKeyCode6 = KEY_6, - kKeyCode7 = KEY_7, - kKeyCode8 = KEY_8, - kKeyCode9 = KEY_9, - kKeyCodeStar = KEY_STAR, - kKeyCodePound = KEY_SHARP, - kKeyCodeDpadUp = KEY_UP, - kKeyCodeDpadDown = KEY_DOWN, - kKeyCodeDpadLeft = KEY_LEFT, - kKeyCodeDpadRight = KEY_RIGHT, - kKeyCodeDpadCenter = KEY_CENTER, - kKeyCodeVolumeUp = KEY_VOLUMEUP, - kKeyCodeVolumeDown = KEY_VOLUMEDOWN, - kKeyCodePower = KEY_POWER, - kKeyCodeCamera = KEY_CAMERA, - kKeyCodeClear = KEY_CLEAR, - kKeyCodeA = KEY_A, - kKeyCodeB = KEY_B, - kKeyCodeC = KEY_C, - kKeyCodeD = KEY_D, - kKeyCodeE = KEY_E, - kKeyCodeF = KEY_F, - kKeyCodeG = KEY_G, - kKeyCodeH = KEY_H, - kKeyCodeI = KEY_I, - kKeyCodeJ = KEY_J, - kKeyCodeK = KEY_K, - kKeyCodeL = KEY_L, - kKeyCodeM = KEY_M, - kKeyCodeN = KEY_N, - kKeyCodeO = KEY_O, - kKeyCodeP = KEY_P, - kKeyCodeQ = KEY_Q, - kKeyCodeR = KEY_R, - kKeyCodeS = KEY_S, - kKeyCodeT = KEY_T, - kKeyCodeU = KEY_U, - kKeyCodeV = KEY_V, - kKeyCodeW = KEY_W, - kKeyCodeX = KEY_X, - kKeyCodeY = KEY_Y, - kKeyCodeZ = KEY_Z, - - kKeyCodeComma = KEY_COMMA, - kKeyCodePeriod = KEY_DOT, - kKeyCodeAltLeft = KEY_LEFTALT, - kKeyCodeAltRight = KEY_RIGHTALT, - kKeyCodeCapLeft = KEY_LEFTSHIFT, - kKeyCodeCapRight = KEY_RIGHTSHIFT, - kKeyCodeTab = KEY_TAB, - kKeyCodeSpace = KEY_SPACE, - kKeyCodeSym = KEY_COMPOSE, - kKeyCodeExplorer = KEY_WWW, - kKeyCodeEnvelope = KEY_MAIL, - kKeyCodeNewline = KEY_ENTER, - kKeyCodeDel = KEY_BACKSPACE, - kKeyCodeGrave = 399, - kKeyCodeMinus = KEY_MINUS, - kKeyCodeEquals = KEY_EQUAL, - kKeyCodeLeftBracket = KEY_LEFTBRACE, - kKeyCodeRightBracket = KEY_RIGHTBRACE, - kKeyCodeBackslash = KEY_BACKSLASH, - kKeyCodeSemicolon = KEY_SEMICOLON, - kKeyCodeApostrophe = KEY_APOSTROPHE, - kKeyCodeSlash = KEY_SLASH, - kKeyCodeAt = KEY_EMAIL, - kKeyCodeNum = KEY_NUM, - kKeyCodeHeadsetHook = KEY_HEADSETHOOK, - kKeyCodeFocus = KEY_FOCUS, - kKeyCodePlus = KEY_PLUS, - kKeyCodeMenu = KEY_MENU, - kKeyCodeNotification = KEY_NOTIFICATION, - kKeyCodeSearch = KEY_SEARCH, - - kKeyCodeBtnMouse = BTN_MOUSE, - - kKeyCodeOrientation0 = 77, - kKeyCodeOrientation90 = 78, - kKeyCodeOrientation180 = 79, - kKeyCodeOrientation270 = 80 -} AndroidKeyCode; - - -/* this defines a structure used to describe an Android keyboard charmap */ -typedef struct AKeyEntry { - unsigned short code; - unsigned short base; - unsigned short caps; - unsigned short fn; - unsigned short caps_fn; - unsigned short number; -} AKeyEntry; - -typedef struct { - const AKeyEntry* entries; - int num_entries; - char name[ 32 ]; -} AKeyCharmap; - -extern const int android_charmap_count; -extern const AKeyCharmap* android_charmaps[]; - -#endif /* _android_charmap_h */ diff --git a/android/cmdline-option.c b/android/cmdline-option.c deleted file mode 100644 index b773d9d..0000000 --- a/android/cmdline-option.c +++ /dev/null @@ -1,255 +0,0 @@ -#include "android/cmdline-option.h" -#include "android/utils/debug.h" -#include "android/utils/misc.h" -#include -#include -#include - -#define _VERBOSE_TAG(x,y) { #x, VERBOSE_##x, y }, -static const struct { const char* name; int flag; const char* text; } -debug_tags[] = { - VERBOSE_TAG_LIST - { 0, 0, 0 } -}; - -static void parse_debug_tags( const char* tags ); -void parse_env_debug_tags( void ); - - -typedef struct { - const char* name; - int var_offset; - int var_is_param; - int var_is_config; -} OptionInfo; - -#define OPTION(_name,_type,_config) \ - { #_name, offsetof(AndroidOptions,_name), _type, _config }, - - -static const OptionInfo option_keys[] = { -#define OPT_PARAM(_name,_template,_descr) OPTION(_name,1,0) -#define OPT_FLAG(_name,_descr) OPTION(_name,0,0) -#define CFG_PARAM(_name,_template,_descr) OPTION(_name,1,1) -#define CFG_FLAG(_name,_descr) OPTION(_name,0,1) -#include "android/cmdline-options.h" - { NULL, 0, 0, 0 } -}; - -int -android_parse_options( int *pargc, char** *pargv, AndroidOptions* opt ) -{ - int nargs = *pargc-1; - char** aread = *pargv+1; - char** awrite = aread; - - memset( opt, 0, sizeof *opt ); - - while (nargs > 0) { - char* arg; - char arg2_tab[64], *arg2 = arg2_tab; - int nn; - - /* process @ as a special exception meaning - * '-avd ' - */ - if (aread[0][0] == '@') { - opt->avd = aread[0]+1; - nargs--; - aread++; - continue; - } - - /* anything that isn't an option past this points - * exits the loop - */ - if (aread[0][0] != '-') { - break; - } - - arg = aread[0]+1; - - /* an option cannot contain an underscore */ - if (strchr(arg, '_') != NULL) { - break; - } - - nargs--; - aread++; - - /* for backwards compatibility with previous versions */ - if (!strcmp(arg, "verbose")) { - arg = "debug-init"; - } - - /* special handing for -debug */ - if (!strcmp(arg, "debug")) { - if (nargs == 0) { - derror( "-debug must be followed by tags (see -help-verbose)\n"); - exit(1); - } - nargs--; - parse_debug_tags(*aread++); - continue; - } - - /* NOTE: variable tables map option names to values - * (e.g. field offsets into the AndroidOptions structure). - * - * however, the names stored in the table used underscores - * instead of dashes. this means that the command-line option - * '-foo-bar' will be associated to the name 'foo_bar' in - * this table, and will point to the field 'foo_bar' or - * AndroidOptions. - * - * as such, before comparing the current option to the - * content of the table, we're going to translate dashes - * into underscores. - */ - arg2 = arg2_tab; - buffer_translate_char( arg2_tab, sizeof(arg2_tab), - arg, '-', '_'); - - /* special handling for -debug- and -debug-no- */ - if (!memcmp(arg2, "debug_", 6)) { - int remove = 0; - unsigned long mask = 0; - arg2 += 6; - if (!memcmp(arg2, "no_", 3)) { - arg2 += 3; - remove = 1; - } - if (!strcmp(arg2, "all")) { - mask = ~0; - } - for (nn = 0; debug_tags[nn].name; nn++) { - if (!strcmp(arg2, debug_tags[nn].name)) { - mask = (1UL << debug_tags[nn].flag); - break; - } - } - if (remove) - android_verbose &= ~mask; - else - android_verbose |= mask; - continue; - } - - /* look into our table of options - * - */ - { - const OptionInfo* oo = option_keys; - - for ( ; oo->name; oo++ ) { - if ( !strcmp( oo->name, arg2 ) ) { - void* field = (char*)opt + oo->var_offset; - - if (oo->var_is_param) { - /* parameter option */ - if (nargs == 0) { - derror( "-%s must be followed by parameter (see -help-%s)", - arg, arg ); - exit(1); - } - nargs--; - ((char**)field)[0] = *aread++; - } else { - /* flag option */ - ((int*)field)[0] = 1; - } - break; - } - } - - if (oo->name == NULL) { /* unknown option ? */ - nargs++; - aread--; - break; - } - } - } - - /* copy remaining parameters, if any, to command line */ - *pargc = nargs + 1; - - while (nargs > 0) { - awrite[0] = aread[0]; - awrite ++; - aread ++; - nargs --; - } - - awrite[0] = NULL; - - return 0; -} - - - -/* special handling of -debug option and tags */ -#define ENV_DEBUG "ANDROID_DEBUG" - -static void -parse_debug_tags( const char* tags ) -{ - char* x; - char* y; - char* x0; - - if (tags == NULL) - return; - - x = x0 = strdup(tags); - while (*x) { - y = strchr(x, ','); - if (y == NULL) - y = x + strlen(x); - else - *y++ = 0; - - if (y > x+1) { - int nn, remove = 0; - unsigned mask = 0; - - if (x[0] == '-') { - remove = 1; - x += 1; - } - - if (!strcmp( "all", x )) - mask = ~0; - else { - char temp[32]; - buffer_translate_char(temp, sizeof temp, x, '-', '_'); - - for (nn = 0; debug_tags[nn].name != NULL; nn++) { - if ( !strcmp( debug_tags[nn].name, temp ) ) { - mask |= (1 << debug_tags[nn].flag); - break; - } - } - } - - if (mask == 0) - dprint( "ignoring unknown " ENV_DEBUG " item '%s'", x ); - else { - if (remove) - android_verbose &= ~mask; - else - android_verbose |= mask; - } - } - x = y; - } - - free(x0); -} - -void -parse_env_debug_tags( void ) -{ - const char* env = getenv( ENV_DEBUG ); - parse_debug_tags( env ); -} - diff --git a/android/cmdline-option.h b/android/cmdline-option.h deleted file mode 100644 index b87144d..0000000 --- a/android/cmdline-option.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2008 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. -*/ -#ifndef _ANDROID_OPTION_H -#define _ANDROID_OPTION_H - -/* define a structure that will hold all option variables - */ -typedef struct { -#define OPT_PARAM(n,t,d) char* n; -#define OPT_FLAG(n,d) int n; -#include "android/cmdline-options.h" -} AndroidOptions; - - -/* parse command-line arguments options and remove them from (argc,argv) - * 'opt' will be set to the content of parsed options - * returns 0 on success, -1 on error (unknown option) - */ -extern int -android_parse_options( int *pargc, char** *pargv, AndroidOptions* opt ); - -/* name of default keyset file */ -#define KEYSET_FILE "default.keyset" - -/* the default device DPI if none is specified by the skin - */ -#define DEFAULT_DEVICE_DPI 165 - -/* default network settings for emulator */ -#define DEFAULT_NETSPEED "full" -#define DEFAULT_NETDELAY "none" - -#endif /* _ANDROID_OPTION_H */ diff --git a/android/cmdline-options.h b/android/cmdline-options.h deleted file mode 100644 index c0d121e..0000000 --- a/android/cmdline-options.h +++ /dev/null @@ -1,131 +0,0 @@ -/* this header file can be included several times by the same source code. - * it contains the list of support command-line options for the Android - * emulator program - */ -#ifndef OPT_PARAM -#error OPT_PARAM is not defined -#endif -#ifndef OPT_FLAG -#error OPT_FLAG is not defined -#endif -#ifndef CFG_PARAM -#define CFG_PARAM OPT_PARAM -#endif -#ifndef CFG_FLAG -#define CFG_FLAG OPT_FLAG -#endif - -/* required to ensure that the CONFIG_XXX macros are properly defined */ -//XXX#include "config.h" - -/* Some options acts like flags, while others must be followed by a parameter - * string. Nothing really new here. - * - * Some options correspond to AVD (Android Virtual Device) configuration - * and will be ignored if you start the emulator with the -avd flag. - * - * However, if you use them with -avd-create , these options will be - * recorded into the new AVD directory. Once an AVD is created, there is no - * way to change these options. - * - * Several macros are used to define options: - * - * OPT_FLAG( name, "description" ) - * used to define a non-config flag option. - * * 'name' is the option suffix that must follow the dash (-) - * as well as the name of an integer variable whose value will - * be 1 if the flag is used, or 0 otherwise. - * * "description" is a short description string that will be - * displayed by 'emulator -help'. - * - * OPT_PARAM( name, "", "description" ) - * used to define a non-config parameter option - * * 'name' will point to a char* variable (NULL if option is unused) - * * "" is a template for the parameter displayed by the help - * * 'varname' is the name of a char* variable that will point - * to the parameter string, if any, or will be NULL otherwise. - * - * CFG_FLAG( name, "description" ) - * used to define a configuration-specific flag option. - * - * CFG_PARAM( name, "", "description" ) - * used to define a configuration-specific parameter option. - * - * NOTE: Keep in mind that optio names are converted by translating - * dashes into underscore. - * - * This means that '-some-option' is equivalent to '-some_option' - * and will be backed by a variable name 'some_option' - * - */ - -CFG_PARAM( system, "", "read system image from " ) -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, "", "system image (default /system.img" ) -CFG_PARAM( initdata, "", "initial data image (default /userdata.img" ) -CFG_PARAM( data, "", "data image (default /userdata-qemu.img" ) -CFG_PARAM( cache, "", "cache partition image (default is temporary file)" ) -CFG_FLAG ( nocache, "disable the cache partition" ) -OPT_PARAM( sdcard, "", "SD card image (default /sdcard.img") -OPT_FLAG ( wipe_data, "reset the use data image (copy it from initdata)" ) -CFG_PARAM( avd, "", "use a specific android virtual device" ) -CFG_PARAM( skindir, "", "search skins in (default /skins)" ) -CFG_PARAM( skin, "", "select a given skin" ) -CFG_FLAG ( noskin, "don't use any emulator skin" ) -CFG_PARAM( memory, "", "physical RAM size in MBs" ) - -OPT_PARAM( netspeed, "", "maximum network download/upload speeds" ) -OPT_PARAM( netdelay, "", "network latency emulation" ) -OPT_FLAG ( netfast, "disable network shaping" ) - -OPT_PARAM( trace, "", "enable code profiling (F9 to start)" ) -OPT_FLAG ( show_kernel, "display kernel messages" ) -OPT_FLAG ( shell, "enable root shell on current terminal" ) -OPT_FLAG ( nojni, "disable JNI checks in the Dalvik runtime" ) -OPT_PARAM( logcat, "", "enable logcat output with given tags" ) - -OPT_FLAG ( noaudio, "disable audio support" ) -OPT_PARAM( audio, "", "use specific audio backend" ) -OPT_PARAM( audio_in, "", "use specific audio input backend" ) -OPT_PARAM( audio_out,"", "use specific audio output backend" ) - -OPT_FLAG ( raw_keys, "disable Unicode keyboard reverse-mapping" ) -OPT_PARAM( radio, "", "redirect radio modem interface to character device" ) -OPT_PARAM( port, "", "TCP port that will be used for the console" ) -OPT_PARAM( ports, ",", "TCP ports used for the console and adb bridge" ) -OPT_PARAM( onion, "", "use overlay PNG image over screen" ) -OPT_PARAM( onion_alpha, "<%age>", "specify onion-skin translucency" ) -OPT_PARAM( onion_rotation, "0|1|2|3", "specify onion-skin rotation" ) - -OPT_PARAM( scale, "", "scale emulator window" ) -OPT_PARAM( dpi_device, "", "specify device's resolution in dpi (default " - STRINGIFY(DEFAULT_DEVICE_DPI) ")" ) - -OPT_PARAM( http_proxy, "", "make TCP connections through a HTTP/HTTPS proxy" ) -OPT_PARAM( timezone, "", "use this timezone instead of the host's default" ) -OPT_PARAM( dns_server, "", "use this DNS server(s) in the emulated system" ) -OPT_PARAM( cpu_delay, "", "throttle CPU emulation" ) -OPT_FLAG ( no_boot_anim, "disable animation for faster boot" ) - -OPT_FLAG( no_window, "disable graphical window display" ) -OPT_FLAG( version, "display emulator version number" ) - -OPT_PARAM( report_console, "", "report console port to remote socket" ) -OPT_PARAM( gps, "", "redirect NMEA GPS to character device" ) -OPT_PARAM( keyset, "", "specify keyset file name" ) -OPT_PARAM( shell_serial, "", "specific character device for root shell" ) -OPT_FLAG ( old_system, "support old (pre 1.4) system images" ) -OPT_PARAM( tcpdump, "", "capture network packets to file" ) - -#ifdef CONFIG_NAND_LIMITS -OPT_PARAM( nand_limits, "", "enforce NAND/Flash read/write thresholds" ) -#endif - -OPT_PARAM( bootchart, "", "enable bootcharting") - -#undef CFG_FLAG -#undef CFG_PARAM -#undef OPT_FLAG -#undef OPT_PARAM diff --git a/android/config.c b/android/config.c deleted file mode 100644 index 36fab11..0000000 --- a/android/config.c +++ /dev/null @@ -1,467 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -#include -#include -#include -#include -#include - -#include "android/config.h" -#include "android/utils/path.h" - -AConfig* -aconfig_node(const char *name, const char *value) -{ - AConfig *n; - - n = (AConfig*) calloc(sizeof(AConfig), 1); - n->name = name ? name : ""; - n->value = value ? value : ""; - - return n; -} - -static AConfig* -_aconfig_find(AConfig *root, const char *name, int create) -{ - AConfig *node; - - for(node = root->first_child; node; node = node->next) { - if(!strcmp(node->name, name)) return node; - } - - if(create) { - node = (AConfig*) calloc(sizeof(AConfig), 1); - node->name = name; - node->value = ""; - - if(root->last_child) { - root->last_child->next = node; - } else { - root->first_child = node; - } - root->last_child = node; - } - - return node; -} - -AConfig* -aconfig_find(AConfig *root, const char *name) -{ - return _aconfig_find(root, name, 0); -} - -int -aconfig_bool(AConfig *root, const char *name, int _default) -{ - AConfig *n = _aconfig_find(root, name, 0); - if(n == 0) { - return _default; - } else { - switch(n->value[0]){ - case 'y': - case 'Y': - case '1': - return 1; - default: - return 0; - } - } -} - -unsigned -aconfig_unsigned(AConfig *root, const char *name, unsigned _default) -{ - AConfig *n = _aconfig_find(root, name, 0); - if(n == 0) { - return _default; - } else { - return strtoul(n->value, 0, 0); - } -} - -int -aconfig_int(AConfig *root, const char *name, int _default) -{ - AConfig *n = _aconfig_find(root, name, 0); - if(n == 0) { - return _default; - } else { - return strtol(n->value, 0, 0); - } -} - - -const char* -aconfig_str(AConfig *root, const char *name, const char *_default) -{ - AConfig *n = _aconfig_find(root, name, 0); - if(n == 0) { - return _default; - } else { - return n->value; - } -} - -void -aconfig_set(AConfig *root, const char *name, const char *value) -{ - AConfig *node = _aconfig_find(root, name, 1); - node->value = value; -} - -#define T_EOF 0 -#define T_TEXT 1 -#define T_DOT 2 -#define T_OBRACE 3 -#define T_CBRACE 4 - -typedef struct -{ - char *data; - char *text; - int len; - char next; -} cstate; - - -static int _lex(cstate *cs, int value) -{ - char c; - char *s; - char *data; - - data = cs->data; - - if(cs->next != 0) { - c = cs->next; - cs->next = 0; - goto got_c; - } - -restart: - for(;;) { - c = *data++; - got_c: - if(isspace(c)) continue; - - switch(c) { - case 0: - return T_EOF; - - /* a sharp sign (#) starts a line comment and everything - * behind that is ignored until the end of line - */ - case '#': - for(;;) { - switch(*data) { - case 0: - cs->data = data; - return T_EOF; - case '\n': - cs->data = data + 1; - goto restart; - default: - data++; - } - } - break; - - case '.': - cs->data = data; - return T_DOT; - - case '{': - cs->data = data; - return T_OBRACE; - - case '}': - cs->data = data; - return T_CBRACE; - - default: - s = data - 1; - - if(value) { - /* if we're looking for a value, then take anything - * until the end of line. note that sharp signs do - * not start comments then. the result will be stripped - * from trailing whitespace. - */ - for(;;) { - if(*data == 0) { - cs->data = data; - break; - } - if(*data == '\n') { - cs->data = data + 1; - *data-- = 0; - break; - } - data++; - } - - /* strip trailing whitespace */ - while(data > s){ - if(!isspace(*data)) break; - *data-- = 0; - } - - goto got_text; - } else { - /* looking for a key name. we stop at whitspace, - * EOF, of T_DOT/T_OBRACE/T_CBRACE characters. - * note that the name can include sharp signs - */ - for(;;) { - if(isspace(*data)) { - *data = 0; - cs->data = data + 1; - goto got_text; - } - switch(*data) { - case 0: - cs->data = data; - goto got_text; - case '.': - case '{': - case '}': - cs->next = *data; - *data = 0; - cs->data = data + 1; - goto got_text; - default: - data++; - } - } - } - } - } - -got_text: - cs->text = s; - return T_TEXT; -} - -#if 0 -char *TOKENNAMES[] = { "EOF", "TEXT", "DOT", "OBRACE", "CBRACE" }; - -static int lex(cstate *cs, int value) -{ - int tok = _lex(cs, value); - printf("TOKEN(%d) %s %s\n", value, TOKENNAMES[tok], - tok == T_TEXT ? cs->text : ""); - return tok; -} -#else -#define lex(cs,v) _lex(cs,v) -#endif - -static int parse_expr(cstate *cs, AConfig *node); - -static int -parse_block(cstate *cs, AConfig *node) -{ - for(;;){ - switch(lex(cs, 0)){ - case T_TEXT: - if(parse_expr(cs, node)) return -1; - continue; - - case T_CBRACE: - return 0; - - default: - return -1; - } - } -} - -static int -parse_expr(cstate *cs, AConfig *node) -{ - /* last token was T_TEXT */ - node = _aconfig_find(node, cs->text, 1); - - for(;;) { - switch(lex(cs, 1)) { - case T_DOT: - if(lex(cs, 0) != T_TEXT) return -1; - node = _aconfig_find(node, cs->text, 1); - continue; - - case T_TEXT: - node->value = cs->text; - return 0; - - case T_OBRACE: - return parse_block(cs, node); - - default: - return -1; - } - } -} - -void -aconfig_load(AConfig *root, char *data) -{ - if(data != 0) { - cstate cs; - cs.data = data; - cs.next = 0; - - for(;;) { - switch(lex(&cs, 0)){ - case T_TEXT: - if(parse_expr(&cs, root)) return; - break; - default: - return; - } - } - } -} - -int -aconfig_load_file(AConfig *root, const char *fn) -{ - char *data; - data = path_load_file(fn, NULL); - if (data == NULL) - return -1; - - aconfig_load(root, data); - return 0; -} - - -typedef struct -{ - char buff[1024]; - char* p; - char* end; - int fd; -} Writer; - -static int -writer_init( Writer* w, const char* fn ) -{ - w->p = w->buff; - w->end = w->buff + sizeof(w->buff); - - w->fd = creat( fn, 0755 ); - if (w->fd < 0) - return -1; - -#ifdef _WIN32 - _setmode( w->fd, _O_BINARY ); -#endif - return 0; -} - -static void -writer_write( Writer* w, const char* src, int len ) -{ - while (len > 0) { - int avail = w->end - w->p; - - if (avail > len) - avail = len; - - memcpy( w->p, src, avail ); - src += avail; - len -= avail; - - w->p += avail; - if (w->p == w->end) { - write( w->fd, w->buff, w->p - w->buff ); - w->p = w->buff; - } - } -} - -static void -writer_done( Writer* w ) -{ - if (w->p > w->buff) - write( w->fd, w->buff, w->p - w->buff ); - close( w->fd ); -} - -static void -writer_margin( Writer* w, int margin) -{ - static const char spaces[10] = " "; - while (margin >= 10) { - writer_write(w,spaces,10); - margin -= 10; - } - if (margin > 0) - writer_write(w,spaces,margin); -} - -static void -writer_c(Writer* w, char c) -{ - writer_write(w, &c, 1); -} - -static void -writer_str(Writer* w, const char* str) -{ - writer_write(w, str, strlen(str)); -} - -static void -writer_node(Writer* w, AConfig* node, int margin) -{ - writer_margin(w,margin); - writer_str(w, node->name); - writer_c(w,' '); - - if (node->value[0]) { - writer_str(w, node->value); - writer_c(w,'\n'); - } - else - { - AConfig* child; - - writer_c(w, '{'); - writer_c(w, '\n'); - - for (child = node->first_child; child; child = child->next) - writer_node(w,child,margin+4); - - writer_margin(w,margin); - writer_c(w,'}'); - writer_c(w,'\n'); - } -} - -int -aconfig_save_file(AConfig *root, const char *fn) -{ - AConfig* child; - Writer w[1]; - - if (writer_init(w,fn) < 0) - return -1; - - for (child = root->first_child; child; child = child->next) - writer_node(w,child,0); - - writer_done(w); - return 0; -} diff --git a/android/config.h b/android/config.h deleted file mode 100644 index 5e8b048..0000000 --- a/android/config.h +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -#ifndef ANDROID_CONFIG_H -#define ANDROID_CONFIG_H - -/** ANDROID CONFIGURATION FILE SUPPORT - ** - ** A configuration file is loaded as a simplre tree of (key,value) - ** pairs. keys and values are simple strings - **/ -typedef struct AConfig AConfig; - -struct AConfig -{ - AConfig* next; - AConfig* first_child; - AConfig* last_child; - const char* name; - const char* value; -}; - -/* parse a text string into a config node tree */ -extern void aconfig_load(AConfig* root, char* data); - -/* parse a file into a config node tree, return 0 in case of success, -1 otherwise */ -extern int aconfig_load_file(AConfig* root, const char* path); - -/* save a config node tree into a file, return 0 in case of success, -1 otherwise */ -extern int aconfig_save_file(AConfig* root, const char* path); - -/* create a single config node */ -extern AConfig* aconfig_node(const char *name, const char *value); - -/* locate a named child of a config node */ -extern AConfig* aconfig_find(AConfig *root, const char *name); - -/* add a named child to a config node (or modify it if it already exists) */ -extern void aconfig_set(AConfig *root, const char *name, const char *value); - - -/* look up a child by name and return its value, eventually converted - * into a boolean or integer */ -extern int aconfig_bool (AConfig *root, const char *name, int _default); -extern unsigned aconfig_unsigned(AConfig *root, const char *name, unsigned _default); -extern int aconfig_int (AConfig *root, const char *name, int _default); -extern const char* aconfig_str (AConfig *root, const char *name, const char *_default); - -#endif /* ANDROID_CONFIG_H */ diff --git a/android/config/Linux/config-host.h b/android/config/Linux/config-host.h deleted file mode 100644 index 90defbd..0000000 --- a/android/config/Linux/config-host.h +++ /dev/null @@ -1,10 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu" -#define HOST_I386 1 -#define HOST_LONG_BITS 32 -#define HAVE_BYTESWAP_H 1 -#define CONFIG_GDBSTUB 1 -#define CONFIG_SLIRP 1 -#define QEMU_VERSION "0.8.2" -#define CONFIG_SKINS 1 -#define CONFIG_UNAME_RELEASE "" diff --git a/android/config/check-alsa.c b/android/config/check-alsa.c deleted file mode 100644 index 4ab2945..0000000 --- a/android/config/check-alsa.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -#include -#include -#include - -#define D(...) fprintf(stderr,__VA_ARGS__) -#define STRINGIFY(x) _STRINGIFY(x) -#define _STRINGIFY(x) #x - -#define DYN_SYMBOLS \ - DYN_FUNCTION(size_t,snd_pcm_sw_params_sizeof,(void)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_current,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)) \ - DYN_FUNCTION(int,snd_pcm_sw_params_set_start_threshold,(snd_pcm_t *pcm, snd_pcm_sw_params_t *params, snd_pcm_uframes_t val)) \ - DYN_FUNCTION(int,snd_pcm_sw_params,(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)) \ - DYN_FUNCTION(int,snd_pcm_sw_params_current,(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)) \ - DYN_FUNCTION(size_t,snd_pcm_hw_params_sizeof,(void)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_any,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_access,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t _access)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_format,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_rate_near,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_channels_near,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_buffer_time_near,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)) \ - DYN_FUNCTION(int,snd_pcm_hw_params,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_get_buffer_size,(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)) \ - DYN_FUNCTION(int,snd_pcm_prepare,(snd_pcm_t *pcm)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_get_period_size,(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_get_period_size_min,(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *frames, int *dir)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_period_size,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val, int dir)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_get_buffer_size_min,(const snd_pcm_hw_params_t *params, snd_pcm_uframes_t *val)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_buffer_size,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_uframes_t val)) \ - DYN_FUNCTION(int,snd_pcm_hw_params_set_period_time_near,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)) \ - DYN_FUNCTION(snd_pcm_sframes_t,snd_pcm_avail_update,(snd_pcm_t *pcm)) \ - DYN_FUNCTION(int,snd_pcm_drop,(snd_pcm_t *pcm)) \ - DYN_FUNCTION(snd_pcm_sframes_t,snd_pcm_writei,(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)) \ - DYN_FUNCTION(snd_pcm_sframes_t,snd_pcm_readi,(snd_pcm_t *pcm, void *buffer, snd_pcm_uframes_t size)) \ - DYN_FUNCTION(snd_pcm_state_t,snd_pcm_state,(snd_pcm_t *pcm)) \ - DYN_FUNCTION(const char*,snd_strerror,(int errnum)) \ - DYN_FUNCTION(int,snd_pcm_open,(snd_pcm_t **pcm, const char *name,snd_pcm_stream_t stream, int mode)) \ - DYN_FUNCTION(int,snd_pcm_close,(snd_pcm_t *pcm)) \ - - - -/* define pointers to library functions we're going to use */ -#define DYN_FUNCTION(ret,name,sig) \ - static ret (*func_ ## name)sig; - -DYN_SYMBOLS - -#undef DYN_FUNCTION - -#define func_snd_pcm_hw_params_alloca(ptr) \ - do { assert(ptr); *ptr = (snd_pcm_hw_params_t *) alloca(func_snd_pcm_hw_params_sizeof()); memset(*ptr, 0, func_snd_pcm_hw_params_sizeof()); } while (0) - -#define func_snd_pcm_sw_params_alloca(ptr) \ - do { assert(ptr); *ptr = (snd_pcm_sw_params_t *) alloca(func_snd_pcm_sw_params_sizeof()); memset(*ptr, 0, func_snd_pcm_sw_params_sizeof()); } while (0) - -static void* alsa_lib; - -int main(void) -{ - int result = 1; - - alsa_lib = dlopen( "libasound.so", RTLD_NOW ); - if (alsa_lib == NULL) - alsa_lib = dlopen( "libasound.so.2", RTLD_NOW ); - - if (alsa_lib == NULL) { - D("could not find libasound on this system\n"); - return 1; - } - -#undef DYN_FUNCTION -#define DYN_FUNCTION(ret,name,sig) \ - do { \ - (func_ ##name) = dlsym( alsa_lib, STRINGIFY(name) ); \ - if ((func_##name) == NULL) { \ - D("could not find %s in libasound\n", STRINGIFY(name)); \ - goto Fail; \ - } \ - } while (0); - - DYN_SYMBOLS - - result = 0; - goto Exit; - -Fail: - D("failed to open library\n"); - -Exit: - dlclose(alsa_lib); - return result; -} diff --git a/android/config/check-esd.c b/android/config/check-esd.c deleted file mode 100644 index a8eb11b..0000000 --- a/android/config/check-esd.c +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* this file is used to test that we can use libesd with lazy dynamic linking */ - -#include -#include -#include - -#define D(...) fprintf(stderr,__VA_ARGS__) -#define STRINGIFY(x) _STRINGIFY(x) -#define _STRINGIFY(x) #x - -#define ESD_SYMBOLS \ - ESD_FUNCTION(int,esd_play_stream,(esd_format_t,int,const char*,const char*)) \ - ESD_FUNCTION(int,esd_record_stream,(esd_format_t,int,const char*,const char*)) \ - ESD_FUNCTION(int,esd_open_sound,( const char *host )) \ - ESD_FUNCTION(int,esd_close,(int)) \ - -/* define pointers to library functions we're going to use */ -#define ESD_FUNCTION(ret,name,sig) \ - static ret (*func_ ## name)sig; - -ESD_SYMBOLS - -#undef ESD_FUNCTION -static void* esd_lib; - -int main( void ) -{ - int fd; - - esd_lib = dlopen( "libesd.so", RTLD_NOW ); - if (esd_lib == NULL) - esd_lib = dlopen( "libesd.so.0", RTLD_NOW ); - - if (esd_lib == NULL) { - D("could not find libesd on this system"); - return 1; - } - -#undef ESD_FUNCTION -#define ESD_FUNCTION(ret,name,sig) \ - do { \ - (func_ ##name) = dlsym( esd_lib, STRINGIFY(name) ); \ - if ((func_##name) == NULL) { \ - D("could not find %s in libesd\n", STRINGIFY(name)); \ - return 1; \ - } \ - } while (0); - - ESD_SYMBOLS - - return 0; -} diff --git a/android/config/config.h b/android/config/config.h deleted file mode 100644 index be83607..0000000 --- a/android/config/config.h +++ /dev/null @@ -1,14 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#include "config-host.h" -#define CONFIG_QEMU_PREFIX "/usr/gnemul/qemu-arm" -#define TARGET_ARCH "arm" -#define TARGET_ARM 1 -#define CONFIG_TRACE 1 -#define CONFIG_NAND 1 -#define CONFIG_SHAPER 1 -#define CONFIG_SOFTMMU 1 -#define CONFIG_SOFTFLOAT 1 -#define CONFIG_SDL 1 -#ifndef _WIN32 -#define CONFIG_NAND_LIMITS 1 -#endif diff --git a/android/config/darwin-ppc/config-host.h b/android/config/darwin-ppc/config-host.h deleted file mode 100644 index cbd43d1..0000000 --- a/android/config/darwin-ppc/config-host.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu" -#define HOST_PPC 1 -#define HOST_LONG_BITS 32 -#define CONFIG_DARWIN 1 -#define CONFIG_GDBSTUB 1 -#define CONFIG_SLIRP 1 -#define QEMU_VERSION "0.8.2" -#define O_LARGEFILE 0 -#define MAP_ANONYMOUS MAP_ANON -#define _BSD 1 -#define CONFIG_SKINS 1 -#define CONFIG_UNAME_RELEASE "" diff --git a/android/config/darwin-x86/config-host.h b/android/config/darwin-x86/config-host.h deleted file mode 100644 index aaf0195..0000000 --- a/android/config/darwin-x86/config-host.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu" -#define HOST_I386 1 -#define HOST_LONG_BITS 32 -#define CONFIG_DARWIN 1 -#define CONFIG_GDBSTUB 1 -#define CONFIG_SLIRP 1 -#define QEMU_VERSION "0.8.2" -#define O_LARGEFILE 0 -#define MAP_ANONYMOUS MAP_ANON -#define _BSD 1 -#define CONFIG_SKINS 1 -#define CONFIG_UNAME_RELEASE "" diff --git a/android/config/linux-x86/config-host.h b/android/config/linux-x86/config-host.h deleted file mode 100644 index 90defbd..0000000 --- a/android/config/linux-x86/config-host.h +++ /dev/null @@ -1,10 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu" -#define HOST_I386 1 -#define HOST_LONG_BITS 32 -#define HAVE_BYTESWAP_H 1 -#define CONFIG_GDBSTUB 1 -#define CONFIG_SLIRP 1 -#define QEMU_VERSION "0.8.2" -#define CONFIG_SKINS 1 -#define CONFIG_UNAME_RELEASE "" diff --git a/android/config/windows/config-host.h b/android/config/windows/config-host.h deleted file mode 100644 index 8f9e0d9..0000000 --- a/android/config/windows/config-host.h +++ /dev/null @@ -1,10 +0,0 @@ -/* Automatically generated by configure - do not modify */ -#define CONFIG_QEMU_SHAREDIR "/usr/local/share/qemu" -#define HOST_I386 1 -#define HOST_LONG_BITS 32 -#define CONFIG_WIN32 1 -#define CONFIG_GDBSTUB 1 -#define CONFIG_SLIRP 1 -#define QEMU_VERSION "0.8.2" -#define CONFIG_SKINS 1 -#define CONFIG_UNAME_RELEASE "" diff --git a/android/console.c b/android/console.c deleted file mode 100644 index 3a769c1..0000000 --- a/android/console.c +++ /dev/null @@ -1,2190 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -/* - * Android emulator control console - * - * this console is enabled automatically at emulator startup, on port 5554 by default, - * unless some other emulator is already running. See (android_emulation_start in android_sdl.c - * for details) - * - * you can telnet to the console, then use commands like 'help' or others to dynamically - * change emulator settings. - * - */ - -#include "sockets.h" -#include "qemu-char.h" -#include "sysemu.h" -#include "android/android.h" -#include "sockets.h" -#include "cpu.h" -#include "hw/goldfish_device.h" -#include "hw/power_supply.h" -#include "shaper.h" -#include "modem_driver.h" -#include "android/gps.h" -#include "android/globals.h" -#include "android/utils/bufprint.h" -#include "android/utils/debug.h" -#include "android/utils/stralloc.h" -#include "tcpdump.h" - -#include -#include -#include -#include -#include -#include -#include "android/hw-events.h" -#include "android/skin/keyboard.h" - -#if defined(CONFIG_SLIRP) -#include "libslirp.h" -#endif - -/* set to 1 to use the i/o and event functions - * defined in "telephony/sysdeps.h" - */ -#define USE_SYSDEPS 0 - -#include "sysdeps.h" - -#define DEBUG 1 - -#if 1 -# define D_ACTIVE VERBOSE_CHECK(console) -#else -# define D_ACTIVE DEBUG -#endif - -#if DEBUG -# define D(x) do { if (D_ACTIVE) ( printf x , fflush(stdout) ); } while (0) -#else -# define D(x) do{}while(0) -#endif - -extern int slirp_inited; /* in vl.c */ - -typedef struct ControlGlobalRec_* ControlGlobal; - -typedef struct ControlClientRec_* ControlClient; - -typedef struct { - int host_port; - int host_udp; - unsigned int guest_ip; - int guest_port; -} RedirRec, *Redir; - - -#if USE_SYSDEPS -typedef SysChannel Socket; -#else /* !USE_SYSDEPS */ -typedef int Socket; -#endif /* !USE_SYSDEPS */ - - -typedef struct ControlClientRec_ -{ - struct ControlClientRec_* next; /* next client in list */ - Socket sock; /* socket used for communication */ - ControlGlobal global; - char finished; - char buff[ 4096 ]; - int buff_len; - -} ControlClientRec; - - -typedef struct ControlGlobalRec_ -{ - /* listening socket */ - Socket listen_fd; - - /* the list of current clients */ - ControlClient clients; - - /* the list of redirections currently active */ - Redir redirs; - int num_redirs; - int max_redirs; - -} ControlGlobalRec; - - -static int -control_global_add_redir( ControlGlobal global, - int host_port, - int host_udp, - unsigned int guest_ip, - int guest_port ) -{ - Redir redir; - - if (global->num_redirs >= global->max_redirs) - { - int old_max = global->max_redirs; - int new_max = old_max + (old_max >> 1) + 4; - - Redir new_redirs = realloc( global->redirs, new_max*sizeof(global->redirs[0]) ); - if (new_redirs == NULL) - return -1; - - global->redirs = new_redirs; - global->max_redirs = new_max; - } - - redir = &global->redirs[ global->num_redirs++ ]; - - redir->host_port = host_port; - redir->host_udp = host_udp; - redir->guest_ip = guest_ip; - redir->guest_port = guest_port; - - return 0; -} - -static int -control_global_del_redir( ControlGlobal global, - int host_port, - int host_udp ) -{ - int nn; - - for (nn = 0; nn < global->num_redirs; nn++) - { - Redir redir = &global->redirs[nn]; - - if ( redir->host_port == host_port && - redir->host_udp == host_udp ) - { - memmove( redir, redir + 1, ((global->num_redirs - nn)-1)*sizeof(*redir) ); - global->num_redirs -= 1; - return 0; - } - } - /* we didn't find it */ - return -1; -} - -static void -control_client_destroy( ControlClient client ) -{ - ControlGlobal global = client->global; - ControlClient *pnode = &global->clients; - - D(( "destroying control client %p\n", client )); - -#if USE_SYSDEPS - sys_channel_on( client->sock, 0, NULL, NULL ); -#else - qemu_set_fd_handler( client->sock, NULL, NULL, NULL ); -#endif - - for ( ;; ) { - ControlClient node = *pnode; - if ( node == NULL ) - break; - if ( node == client ) { - *pnode = node->next; - node->next = NULL; - break; - } - pnode = &node->next; - } - -#if USE_SYSDEPS - sys_channel_close( client->sock ); - client->sock = NULL; -#else - socket_close( client->sock ); - client->sock = -1; -#endif - - free( client ); -} - -static void control_client_read( void* _client ); /* forward */ - - -static void control_control_write( ControlClient client, const char* buff, int len ) -{ - int ret; - - if (len < 0) - len = strlen(buff); - - while (len > 0) { -#if USE_SYSDEPS - ret = sys_channel_write( client->sock, buff, len ); -#else - ret = socket_send( client->sock, buff, len); -#endif - if (ret < 0) { - if (errno != EINTR && errno != EWOULDBLOCK) - return; - } else { - buff += ret; - len -= ret; - } - } -} - -static void control_write( ControlClient client, const char* format, ... ) -{ - static char temp[1024]; - va_list args; - - va_start(args, format); - vsnprintf( temp, sizeof(temp), format, args ); - va_end(args); - - temp[ sizeof(temp)-1 ] = 0; - - control_control_write( client, temp, -1 ); -} - - -static ControlClient -control_client_create( Socket socket, - ControlGlobal global ) -{ - ControlClient client = calloc( sizeof(*client), 1 ); - - if (client) { -#if !USE_SYSDEPS - socket_set_nodelay( socket ); - socket_set_nonblock( socket ); -#endif - client->finished = 0; - client->global = global; - client->sock = socket; - client->next = global->clients; - global->clients = client; - -#if USE_SYSDEPS - sys_channel_on( socket, SYS_EVENT_READ, - (SysChannelCallback) control_client_read, - client ); -#else - qemu_set_fd_handler( socket, control_client_read, NULL, client ); -#endif - } - return client; -} - -typedef const struct CommandDefRec_ *CommandDef; - -typedef struct CommandDefRec_ { - const char* names; - const char* abstract; - const char* description; - void (*descriptor)( ControlClient client ); - int (*handler)( ControlClient client, char* args ); - CommandDef subcommands; /* if handler is NULL */ - -} CommandDefRec; - -static const CommandDefRec main_commands[]; /* forward */ - -static CommandDef -find_command( char* input, CommandDef commands, char* *pend, char* *pargs ) -{ - int nn; - char* args = strchr(input, ' '); - - if (args != NULL) { - while (*args == ' ') - args++; - - if (args[0] == 0) - args = NULL; - } - - for (nn = 0; commands[nn].names != NULL; nn++) - { - const char* name = commands[nn].names; - const char* sep; - - do { - int len, c; - - sep = strchr( name, '|' ); - if (sep) - len = sep - name; - else - len = strlen(name); - - c = input[len]; - if ( !memcmp( name, input, len ) && (c == ' ' || c == 0) ) { - *pend = input + len; - *pargs = args; - return &commands[nn]; - } - - if (sep) - name = sep + 1; - - } while (sep != NULL && *name); - } - /* NOTE: don't touch *pend and *pargs if no command is found */ - return NULL; -} - -static void -dump_help( ControlClient client, - CommandDef cmd, - const char* prefix ) -{ - if (cmd->description) { - control_write( client, "%s", cmd->description ); - } else if (cmd->descriptor) { - cmd->descriptor( client ); - } else - control_write( client, "%s\r\n", cmd->abstract ); - - if (cmd->subcommands) { - cmd = cmd->subcommands; - control_write( client, "\r\navailable sub-commands:\r\n" ); - for ( ; cmd->names != NULL; cmd++ ) { - control_write( client, " %s %-15s %s\r\n", prefix, cmd->names, cmd->abstract ); - } - control_write( client, "\r\n" ); - } -} - -static void -control_client_do_command( ControlClient client ) -{ - char* line = client->buff; - char* args = NULL; - CommandDef commands = main_commands; - char* cmdend = client->buff; - CommandDef cmd = find_command( line, commands, &cmdend, &args ); - - if (cmd == NULL) { - control_write( client, "KO: unknown command, try 'help'\r\n" ); - return; - } - - for (;;) { - CommandDef subcmd; - - if (cmd->handler) { - if ( !cmd->handler( client, args ) ) - control_write( client, "OK\r\n" ); - break; - } - - /* no handler means we should have sub-commands */ - if (cmd->subcommands == NULL) { - control_write( client, "KO: internal error: buggy command table for '%.*s'\r\n", - cmdend - client->buff, client->buff ); - break; - } - - /* we need a sub-command here */ - if ( !args ) { - dump_help( client, cmd, "" ); - control_write( client, "KO: missing sub-command\r\n" ); - break; - } - - line = args; - commands = cmd->subcommands; - subcmd = find_command( line, commands, &cmdend, &args ); - if (subcmd == NULL) { - dump_help( client, cmd, "" ); - control_write( client, "KO: bad sub-command\r\n" ); - break; - } - cmd = subcmd; - } -} - -/* implement the 'help' command */ -static int -do_help( ControlClient client, char* args ) -{ - char* line; - char* start = args; - char* end = start; - CommandDef cmd = main_commands; - - /* without arguments, simply dump all commands */ - if (args == NULL) { - control_write( client, "Android console command help:\r\n\r\n" ); - for ( ; cmd->names != NULL; cmd++ ) { - control_write( client, " %-15s %s\r\n", cmd->names, cmd->abstract ); - } - control_write( client, "\r\ntry 'help ' for command-specific help\r\n" ); - return 0; - } - - /* with an argument, find the corresponding command */ - for (;;) { - CommandDef subcmd; - - line = args; - subcmd = find_command( line, cmd, &end, &args ); - if (subcmd == NULL) { - control_write( client, "try one of these instead:\r\n\r\n" ); - for ( ; cmd->names != NULL; cmd++ ) { - control_write( client, " %.*s %s\r\n", - end - start, start, cmd->names ); - } - control_write( client, "\r\nKO: unknown command\r\n" ); - return -1; - } - - if ( !args || !subcmd->subcommands ) { - dump_help( client, subcmd, start ); - return 0; - } - cmd = subcmd->subcommands; - } -} - - -static void -control_client_read_byte( ControlClient client, unsigned char ch ) -{ - if (ch == '\r') - { - /* filter them out */ - } - else if (ch == '\n') - { - client->buff[ client->buff_len ] = 0; - control_client_do_command( client ); - if (client->finished) - return; - - client->buff_len = 0; - } - else - { - if (client->buff_len >= sizeof(client->buff)-1) - client->buff_len = 0; - - client->buff[ client->buff_len++ ] = ch; - } -} - -static void -control_client_read( void* _client ) -{ - ControlClient client = _client; - unsigned char buf[4096]; - int size; - - D(( "in control_client read: " )); -#if USE_SYSDEPS - size = sys_channel_read( client->sock, buf, sizeof(buf) ); -#else - size = socket_recv( client->sock, buf, sizeof(buf) ); -#endif - if (size < 0) { - D(( "size < 0, exiting with %d: %s\n", errno, errno_str )); - if (errno != EWOULDBLOCK && errno != EINTR) - control_client_destroy( client ); - return; - } - - if (size == 0) { - /* end of connection */ - D(( "end of connection detected !!\n" )); - control_client_destroy( client ); - } - else { - int nn; -#ifdef _WIN32 -# if DEBUG - char temp[16]; - int count = size > sizeof(temp)-1 ? sizeof(temp)-1 : size; - for (nn = 0; nn < count; nn++) { - int c = buf[nn]; - if (c == '\n') - temp[nn] = '!'; - else if (c < 32) - temp[nn] = '.'; - else - temp[nn] = (char)c; - } - temp[nn] = 0; - D(( "received %d bytes: %s\n", size, temp )); -# endif -#else - D(( "received %.*s\n", size, buf )); -#endif - for (nn = 0; nn < size; nn++) { - control_client_read_byte( client, buf[nn] ); - if (client->finished) { - control_client_destroy(client); - return; - } - } - } -} - - -/* this function is called on each new client connection */ -static void -control_global_accept( void* _global ) -{ - ControlGlobal global = _global; - ControlClient client; - Socket fd; - - D(( "control_global_accept: just in (fd=%p)\n", (void*)global->listen_fd )); - -#if USE_SYSDEPS - fd = sys_channel_create_tcp_handler( global->listen_fd ); - if (fd == NULL) { - perror("accept"); - return; - } -#else - for(;;) { - fd = socket_accept( global->listen_fd, NULL ); - if (fd < 0 && errno != EINTR) { - D(( "problem in accept: %d: %s\n", errno, errno_str )); - perror("accept"); - return; - } else if (fd >= 0) { - break; - } - D(( "relooping in accept()\n" )); - } - - socket_set_xreuseaddr( fd ); -#endif - - D(( "control_global_accept: creating new client\n" )); - client = control_client_create( fd, global ); - if (client) { - D(( "control_global_accept: new client %p\n", client )); - control_write( client, "Android Console: type 'help' for a list of commands\r\n" ); - control_write( client, "OK\r\n" ); - } -} - - -static int -control_global_init( ControlGlobal global, - int control_port ) -{ - Socket fd; -#if !USE_SYSDEPS - int ret; - SockAddress sockaddr; -#endif - - memset( global, 0, sizeof(*global) ); - - sys_main_init(); - -#if USE_SYSDEPS - fd = sys_channel_create_tcp_server( control_port ); - if (fd == NULL) { - return -1; - } - - D(("global fd=%p\n", fd)); - - global->listen_fd = fd; - sys_channel_on( fd, SYS_EVENT_READ, - (SysChannelCallback) control_global_accept, - global ); -#else - fd = socket_create_inet( SOCKET_STREAM ); - if (fd < 0) { - perror("socket"); - return -1; - } - - socket_set_xreuseaddr( fd ); - - sock_address_init_inet( &sockaddr, SOCK_ADDRESS_INET_LOOPBACK, control_port ); - - ret = socket_bind(fd, &sockaddr ); - if (ret < 0) { - perror("bind"); - socket_close( fd ); - return -1; - } - - ret = socket_listen(fd, 0); - if (ret < 0) { - perror("listen"); - socket_close( fd ); - return -1; - } - - socket_set_nonblock(fd); - - global->listen_fd = fd; - - qemu_set_fd_handler( fd, control_global_accept, NULL, global ); -#endif - return 0; -} - - - -static int -do_quit( ControlClient client, char* args ) -{ - client->finished = 1; - return -1; -} - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** N E T W O R K S E T T I N G S ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -static int -do_network_status( ControlClient client, char* args ) -{ - control_write( client, "Current network status:\r\n" ); - - control_write( client, " download speed: %8d bits/s (%.1f KB/s)\r\n", - (long)qemu_net_download_speed, qemu_net_download_speed/8192. ); - - control_write( client, " upload speed: %8d bits/s (%.1f KB/s)\r\n", - (long)qemu_net_upload_speed, qemu_net_upload_speed/8192. ); - - control_write( client, " minimum latency: %ld ms\r\n", qemu_net_min_latency ); - control_write( client, " maximum latency: %ld ms\r\n", qemu_net_max_latency ); - return 0; -} - -static void -dump_network_speeds( ControlClient client ) -{ - const NetworkSpeed* speed = android_netspeeds; - const char* const format = " %-8s %s\r\n"; - for ( ; speed->name; speed++ ) { - control_write( client, format, speed->name, speed->display ); - } - control_write( client, format, "", "selects both upload and download speed" ); - control_write( client, format, ":", "select individual upload/download speeds" ); -} - - -static int -do_network_speed( ControlClient client, char* args ) -{ - if ( !args ) { - control_write( client, "KO: missing argument, see 'help network speed'\r\n" ); - return -1; - } - if ( android_parse_network_speed( args ) < 0 ) { - control_write( client, "KO: invalid argument, see 'help network speed' for valid values\r\n" ); - return -1; - } - - netshaper_set_rate( slirp_shaper_in, qemu_net_download_speed ); - netshaper_set_rate( slirp_shaper_out, qemu_net_upload_speed ); - - if (android_modem) { - amodem_set_data_network_type( android_modem, - android_parse_network_type( args ) ); - } - return 0; -} - -static void -describe_network_speed( ControlClient client ) -{ - control_write( client, - "'network speed ' allows you to dynamically change the speed of the emulated\r\n" - "network on the device, where is one of the following:\r\n\r\n" ); - dump_network_speeds( client ); -} - -static int -do_network_delay( ControlClient client, char* args ) -{ - if ( !args ) { - control_write( client, "KO: missing argument, see 'help network delay'\r\n" ); - return -1; - } - if ( android_parse_network_latency( args ) < 0 ) { - control_write( client, "KO: invalid argument, see 'help network delay' for valid values\r\n" ); - return -1; - } - netdelay_set_latency( slirp_delay_in, qemu_net_min_latency, qemu_net_max_latency ); - return 0; -} - -static void -describe_network_delay( ControlClient client ) -{ - control_write( client, - "'network delay ' allows you to dynamically change the latency of the emulated\r\n" - "network on the device, where is one of the following:\r\n\r\n" ); - /* XXX: TODO */ -} - -static int -do_network_capture_start( ControlClient client, char* args ) -{ - if ( !args ) { - control_write( client, "KO: missing argument, see 'help network capture start'\r\n" ); - return -1; - } - if ( qemu_tcpdump_start(args) < 0) { - control_write( client, "KO: could not start capture: %s", strerror(errno) ); - return -1; - } - return 0; -} - -static int -do_network_capture_stop( ControlClient client, char* args ) -{ - /* no need to return an error here */ - qemu_tcpdump_stop(); - return 0; -} - -static const CommandDefRec network_capture_commands[] = -{ - { "start", "start network capture", - "'network capture start ' starts a new capture of network packets\r\n" - "into a specific . This will stop any capture already in progress.\r\n" - "the capture file can later be analyzed by tools like WireShark. It uses\r\n" - "the libpcap file format.\r\n\r\n" - "you can stop the capture anytime with 'network capture stop'\r\n", NULL, - do_network_capture_start, NULL }, - - { "stop", "stop network capture", - "'network capture stop' stops a currently running packet capture, if any.\r\n" - "you can start one with 'network capture start '\r\n", NULL, - do_network_capture_stop, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - -static const CommandDefRec network_commands[] = -{ - { "status", "dump network status", NULL, NULL, - do_network_status, NULL }, - - { "speed", "change network speed", NULL, describe_network_speed, - do_network_speed, NULL }, - - { "delay", "change network latency", NULL, describe_network_delay, - do_network_delay, NULL }, - - { "capture", "dump network packets to file", - "allows to start/stop capture of network packets to a file for later analysis\r\n", NULL, - NULL, network_capture_commands }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** P O R T R E D I R E C T I O N S ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -static int -do_redir_list( ControlClient client, char* args ) -{ - ControlGlobal global = client->global; - - if (global->num_redirs == 0) - control_write( client, "no active redirections\r\n" ); - else { - int nn; - for (nn = 0; nn < global->num_redirs; nn++) { - Redir redir = &global->redirs[nn]; - control_write( client, "%s:%-5d => %-5d\r\n", - redir->host_udp ? "udp" : "tcp", - redir->host_port, - redir->guest_port ); - } - } - return 0; -} - -/* parse a protocol:port specification */ -static int -redir_parse_proto_port( char* args, int *pport, int *pproto ) -{ - int proto = -1; - int len = 0; - char* end; - - if ( !memcmp( args, "tcp:", 4 ) ) { - proto = 0; - len = 4; - } - else if ( !memcmp( args, "udp:", 4 ) ) { - proto = 1; - len = 4; - } - else - return 0; - - args += len; - *pproto = proto; - *pport = strtol( args, &end, 10 ); - if (end == args) - return 0; - - len += end - args; - return len; -} - -static int -redir_parse_guest_port( char* arg, int *pport ) -{ - char* end; - - *pport = strtoul( arg, &end, 10 ); - if (end == arg) - return 0; - - return end - arg; -} - -static Redir -redir_find( ControlGlobal global, int port, int isudp ) -{ - int nn; - - for (nn = 0; nn < global->num_redirs; nn++) { - Redir redir = &global->redirs[nn]; - - if (redir->host_port == port && redir->host_udp == isudp) - return redir; - } - return NULL; -} - - -static int -do_redir_add( ControlClient client, char* args ) -{ - int len, host_proto, host_port, guest_port; - uint32_t guest_ip; - Redir redir; - - if ( !args ) - goto BadFormat; - - if (!slirp_inited) { - slirp_inited = 1; - slirp_init(); - } - - len = redir_parse_proto_port( args, &host_port, &host_proto ); - if (len == 0 || args[len] != ':') - goto BadFormat; - - args += len + 1; - len = redir_parse_guest_port( args, &guest_port ); - if (len == 0 || args[len] != 0) - goto BadFormat; - - redir = redir_find( client->global, host_port, host_proto ); - if ( redir != NULL ) { - control_write( client, "KO: host port already active, use 'redir del' to remove first\r\n" ); - return -1; - } - - if (!inet_strtoip("10.0.2.15", &guest_ip)) { - control_write( client, "KO: unexpected internal failure when resolving 10.0.2.15\r\n" ); - return -1; - } - - D(("pattern hport=%d gport=%d proto=%d\n", host_port, guest_port, host_proto )); - if ( control_global_add_redir( client->global, host_port, host_proto, - guest_ip, guest_port ) < 0 ) - { - control_write( client, "KO: not enough memory to allocate redirection\r\n" ); - return -1; - } - - if (slirp_redir(host_proto, host_port, guest_ip, guest_port) < 0) { - control_write( client, "KO: can't setup redirection, port probably used by another program on host\r\n" ); - control_global_del_redir( client->global, host_port, host_proto ); - return -1; - } - - return 0; - -BadFormat: - control_write( client, "KO: bad redirection format, try (tcp|udp):hostport:guestport\r\n", -1 ); - return -1; -} - - -static int -do_redir_del( ControlClient client, char* args ) -{ - int len, proto, port; - Redir redir; - - if ( !args ) - goto BadFormat; - len = redir_parse_proto_port( args, &port, &proto ); - if ( len == 0 || args[len] != 0 ) - goto BadFormat; - - redir = redir_find( client->global, port, proto ); - if (redir == NULL) { - control_write( client, "KO: can't remove unknown redirection (%s:%d)\r\n", - proto ? "udp" : "tcp", port ); - return -1; - } - - slirp_unredir( redir->host_udp, redir->host_port ); - control_global_del_redir( client->global, port, proto );\ - - return 0; - -BadFormat: - control_write( client, "KO: bad redirection format, try (tcp|udp):hostport\r\n" ); - return -1; -} - -static const CommandDefRec redir_commands[] = -{ - { "list", "list current redirections", - "list current port redirections. use 'redir add' and 'redir del' to add and remove them\r\n", NULL, - do_redir_list, NULL }, - - { "add", "add new redirection", - "add a new port redirection, arguments must be:\r\n\r\n" - " redir add ::\r\n\r\n" - "where: is either 'tcp' or 'udp'\r\n" - " a number indicating which port on the host to open\r\n" - " a number indicating which port to route to on the device\r\n" - "\r\nas an example, 'redir tcp:5000:6000' will allow any packets sent to\r\n" - "the host's TCP port 5000 to be routed to TCP port 6000 of the emulated device\r\n", NULL, - do_redir_add, NULL }, - - { "del", "remove existing redirection", - "remove a port redirecion that was created with 'redir add', arguments must be:\r\n\r\n" - " redir del :\r\n\r\n" - "see the 'help redir add' for the meaning of and \r\n", NULL, - do_redir_del, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - - - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** G S M M O D E M ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -static const struct { - const char* name; - const char* display; - ARegistrationState state; -} _gsm_states[] = { - { "unregistered", "no network available", A_REGISTRATION_UNREGISTERED }, - { "home", "on local network, non-roaming", A_REGISTRATION_HOME }, - { "roaming", "on roaming network", A_REGISTRATION_ROAMING }, - { "searching", "searching networks", A_REGISTRATION_SEARCHING }, - { "denied", "emergency calls only", A_REGISTRATION_DENIED }, - { "off", "same as 'unregistered'", A_REGISTRATION_UNREGISTERED }, - { "on", "same as 'home'", A_REGISTRATION_HOME }, - { NULL, NULL, A_REGISTRATION_UNREGISTERED } -}; - -static const char* -gsm_state_to_string( ARegistrationState state ) -{ - int nn; - for (nn = 0; _gsm_states[nn].name != NULL; nn++) { - if (state == _gsm_states[nn].state) - return _gsm_states[nn].name; - } - return ""; -} - -static int -do_gsm_status( ControlClient client, char* args ) -{ - if (args) { - control_write( client, "KO: no argument required\r\n" ); - return -1; - } - if (!android_modem) { - control_write( client, "KO: modem emulation not running\r\n" ); - return -1; - } - control_write( client, "gsm voice state: %s\r\n", - gsm_state_to_string( - amodem_get_voice_registration(android_modem) ) ); - control_write( client, "gsm data state: %s\r\n", - gsm_state_to_string( - amodem_get_data_registration(android_modem) ) ); - return 0; -} - - -static void -help_gsm_data( ControlClient client ) -{ - int nn; - control_write( client, - "the 'gsm data ' allows you to change the state of your GPRS connection\r\n" - "valid values for are the following:\r\n\r\n" ); - for (nn = 0; ; nn++) { - const char* name = _gsm_states[nn].name; - const char* display = _gsm_states[nn].display; - - if (!name) - break; - - control_write( client, " %-15s %s\r\n", name, display ); - } - control_write( client, "\r\n" ); -} - - -static int -do_gsm_data( ControlClient client, char* args ) -{ - int nn; - - if (!args) { - control_write( client, "KO: missing argument, try 'gsm data '\r\n" ); - return -1; - } - - for (nn = 0; ; nn++) { - const char* name = _gsm_states[nn].name; - ARegistrationState state = _gsm_states[nn].state; - - if (!name) - break; - - if ( !strcmp( args, name ) ) { - if (!android_modem) { - control_write( client, "KO: modem emulation not running\r\n" ); - return -1; - } - amodem_set_data_registration( android_modem, state ); - qemu_net_disable = (state != A_REGISTRATION_HOME && - state != A_REGISTRATION_ROAMING ); - return 0; - } - } - control_write( client, "KO: bad GSM data state name, try 'help gsm data' for list of valid values\r\n" ); - return -1; -} - -static void -help_gsm_voice( ControlClient client ) -{ - int nn; - control_write( client, - "the 'gsm voice ' allows you to change the state of your GPRS connection\r\n" - "valid values for are the following:\r\n\r\n" ); - for (nn = 0; ; nn++) { - const char* name = _gsm_states[nn].name; - const char* display = _gsm_states[nn].display; - - if (!name) - break; - - control_write( client, " %-15s %s\r\n", name, display ); - } - control_write( client, "\r\n" ); -} - - -static int -do_gsm_voice( ControlClient client, char* args ) -{ - int nn; - - if (!args) { - control_write( client, "KO: missing argument, try 'gsm voice '\r\n" ); - return -1; - } - - for (nn = 0; ; nn++) { - const char* name = _gsm_states[nn].name; - ARegistrationState state = _gsm_states[nn].state; - - if (!name) - break; - - if ( !strcmp( args, name ) ) { - if (!android_modem) { - control_write( client, "KO: modem emulation not running\r\n" ); - return -1; - } - amodem_set_voice_registration( android_modem, state ); - return 0; - } - } - control_write( client, "KO: bad GSM data state name, try 'help gsm voice' for list of valid values\r\n" ); - return -1; -} - - -static int -gsm_check_number( char* args ) -{ - int nn; - - for (nn = 0; args[nn] != 0; nn++) { - int c = args[nn]; - if ( !isdigit(c) && c != '+' && c != '#' ) { - return -1; - } - } - if (nn == 0) - return -1; - - return 0; -} - -static int -do_gsm_call( ControlClient client, char* args ) -{ - /* check that we have a phone number made of digits */ - if (!args) { - control_write( client, "KO: missing argument, try 'gsm call '\r\n" ); - return -1; - } - - if (gsm_check_number(args)) { - control_write( client, "KO: bad phone number format, use digits, # and + only\r\n" ); - return -1; - } - - if (!android_modem) { - control_write( client, "KO: modem emulation not running\r\n" ); - return -1; - } - amodem_add_inbound_call( android_modem, args ); - return 0; -} - -static int -do_gsm_cancel( ControlClient client, char* args ) -{ - if (!args) { - control_write( client, "KO: missing argument, try 'gsm call '\r\n" ); - return -1; - } - if (gsm_check_number(args)) { - control_write( client, "KO: bad phone number format, use digits, # and + only\r\n" ); - return -1; - } - if (!android_modem) { - control_write( client, "KO: modem emulation not running\r\n" ); - return -1; - } - if ( amodem_disconnect_call( android_modem, args ) < 0 ) { - control_write( client, "KO: could not cancel this number\r\n" ); - return -1; - } - return 0; -} - - -static const char* -call_state_to_string( ACallState state ) -{ - switch (state) { - case A_CALL_ACTIVE: return "active"; - case A_CALL_HELD: return "held"; - case A_CALL_ALERTING: return "ringing"; - case A_CALL_WAITING: return "waiting"; - case A_CALL_INCOMING: return "incoming"; - default: return "unknown"; - } -} - -static int -do_gsm_list( ControlClient client, char* args ) -{ - /* check that we have a phone number made of digits */ - int count = amodem_get_call_count( android_modem ); - int nn; - for (nn = 0; nn < count; nn++) { - ACall call = amodem_get_call( android_modem, nn ); - const char* dir; - - if (call == NULL) - continue; - - if (call->dir == A_CALL_OUTBOUND) - dir = "outbound to "; - else - dir = "inbound from"; - - control_write( client, "%s %-10s : %s\r\n", dir, - call->number, call_state_to_string(call->state) ); - } - return 0; -} - -static int -do_gsm_busy( ControlClient client, char* args ) -{ - ACall call; - - if (!args) { - control_write( client, "KO: missing argument, try 'gsm busy '\r\n" ); - return -1; - } - call = amodem_find_call_by_number( android_modem, args ); - if (call == NULL || call->dir != A_CALL_OUTBOUND) { - control_write( client, "KO: no current outbound call to number '%s' (call %p)\r\n", args, call ); - return -1; - } - if ( amodem_disconnect_call( android_modem, args ) < 0 ) { - control_write( client, "KO: could not cancel this number\r\n" ); - return -1; - } - return 0; -} - -static int -do_gsm_hold( ControlClient client, char* args ) -{ - ACall call; - - if (!args) { - control_write( client, "KO: missing argument, try 'gsm out hold '\r\n" ); - return -1; - } - call = amodem_find_call_by_number( android_modem, args ); - if (call == NULL) { - control_write( client, "KO: no current call to/from number '%s'\r\n", args ); - return -1; - } - if ( amodem_update_call( android_modem, args, A_CALL_HELD ) < 0 ) { - control_write( client, "KO: could put this call on hold\r\n" ); - return -1; - } - return 0; -} - - -static int -do_gsm_accept( ControlClient client, char* args ) -{ - ACall call; - - if (!args) { - control_write( client, "KO: missing argument, try 'gsm accept '\r\n" ); - return -1; - } - call = amodem_find_call_by_number( android_modem, args ); - if (call == NULL) { - control_write( client, "KO: no current call to/from number '%s'\r\n", args ); - return -1; - } - if ( amodem_update_call( android_modem, args, A_CALL_ACTIVE ) < 0 ) { - control_write( client, "KO: could not activate this call\r\n" ); - return -1; - } - return 0; -} - - -#if 0 -static const CommandDefRec gsm_in_commands[] = -{ - { "new", "create a new 'waiting' inbound call", - "'gsm in create ' creates a new inbound phone call, placed in\r\n" - "the 'waiting' state by default, until the system answers/holds/closes it\r\n", NULL - do_gsm_in_create, NULL }, - - { "hold", "change the state of an oubtound call to 'held'", - "change the state of an outbound call to 'held'. this is only possible\r\n" - "if the call in the 'waiting' or 'active' state\r\n", NULL, - do_gsm_out_hold, NULL }, - - { "accept", "change the state of an outbound call to 'active'", - "change the state of an outbound call to 'active'. this is only possible\r\n" - "if the call is in the 'waiting' or 'held' state\r\n", NULL, - do_gsm_out_accept, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; -#endif - - -static const CommandDefRec gsm_commands[] = -{ - { "list", "list current phone calls", - "'gsm list' lists all inbound and outbound calls and their state\r\n", NULL, - do_gsm_list, NULL }, - - { "call", "create inbound phone call", - "'gsm call ' allows you to simulate a new inbound call\r\n", NULL, - do_gsm_call, NULL }, - - { "busy", "close waiting outbound call as busy", - "'gsm busy ' closes an outbound call, reporting\r\n" - "the remote phone as busy. only possible if the call is 'waiting'.\r\n", NULL, - do_gsm_busy, NULL }, - - { "hold", "change the state of an oubtound call to 'held'", - "'gsm hold ' change the state of a call to 'held'. this is only possible\r\n" - "if the call in the 'waiting' or 'active' state\r\n", NULL, - do_gsm_hold, NULL }, - - { "accept", "change the state of an outbound call to 'active'", - "'gsm accept ' change the state of a call to 'active'. this is only possible\r\n" - "if the call is in the 'waiting' or 'held' state\r\n", NULL, - do_gsm_accept, NULL }, - - { "cancel", "disconnect an inbound or outbound phone call", - "'gsm cancel ' allows you to simulate the end of an inbound or outbound call\r\n", NULL, - do_gsm_cancel, NULL }, - - { "data", "modify data connection state", NULL, help_gsm_data, - do_gsm_data, NULL }, - - { "voice", "modify voice connection state", NULL, help_gsm_voice, - do_gsm_voice, NULL }, - - { "status", "display GSM status", - "'gsm status' displays the current state of the GSM emulation\r\n", NULL, - do_gsm_status, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** S M S C O M M A N D ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -static int -do_sms_send( ControlClient client, char* args ) -{ - char* p; - int textlen; - SmsAddressRec sender; - SmsPDU* pdus; - int nn; - - /* check that we have a phone number made of digits */ - if (!args) { - MissingArgument: - control_write( client, "KO: missing argument, try 'sms send '\r\n" ); - return -1; - } - p = strchr( args, ' ' ); - if (!p) { - goto MissingArgument; - } - - if ( sms_address_from_str( &sender, args, p - args ) < 0 ) { - control_write( client, "KO: bad phone number format, must be [+](0-9)*\r\n" ); - return -1; - } - - - /* un-secape message text into proper utf-8 (conversion happens in-site) */ - p += 1; - textlen = strlen(p); - textlen = sms_utf8_from_message_str( p, textlen, (unsigned char*)p, textlen ); - if (textlen < 0) { - control_write( client, "message must be utf8 and can use the following escapes:\r\n" - " \\n for a newline\r\n" - " \\xNN where NN are two hexadecimal numbers\r\n" - " \\uNNNN where NNNN are four hexadecimal numbers\r\n" - " \\\\ to send a '\\' character\r\n\r\n" - " anything else is an error\r\n" - "KO: badly formatted text\r\n" ); - return -1; - } - - if (!android_modem) { - control_write( client, "KO: modem emulation not running\r\n" ); - return -1; - } - - /* create a list of SMS PDUs, then send them */ - pdus = smspdu_create_deliver_utf8( (cbytes_t)p, textlen, &sender, NULL ); - if (pdus == NULL) { - control_write( client, "KO: internal error when creating SMS-DELIVER PDUs\n" ); - return -1; - } - - for (nn = 0; pdus[nn] != NULL; nn++) - amodem_receive_sms( android_modem, pdus[nn] ); - - smspdu_free_list( pdus ); - return 0; -} - -static int -do_sms_sendpdu( ControlClient client, char* args ) -{ - SmsPDU pdu; - - /* check that we have a phone number made of digits */ - if (!args) { - control_write( client, "KO: missing argument, try 'sms sendpdu '\r\n" ); - return -1; - } - - if (!android_modem) { - control_write( client, "KO: modem emulation not running\r\n" ); - return -1; - } - - pdu = smspdu_create_from_hex( args, strlen(args) ); - if (pdu == NULL) { - control_write( client, "KO: badly formatted \r\n" ); - return -1; - } - - amodem_receive_sms( android_modem, pdu ); - smspdu_free( pdu ); - return 0; -} - -static const CommandDefRec sms_commands[] = -{ - { "send", "send inbound SMS text message", - "'sms send ' allows you to simulate a new inbound sms message\r\n", NULL, - do_sms_send, NULL }, - - { "pdu", "send inbound SMS PDU", - "'sms pdu ' allows you to simulate a new inbound sms PDU\r\n" - "(used internally when one emulator sends SMS messages to another instance).\r\n" - "you probably don't want to play with this at all\r\n", NULL, - do_sms_sendpdu, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - -static void -do_control_write(void* data, const char* string) -{ - control_write((ControlClient)data, string); -} - -static int -do_power_display( ControlClient client, char* args ) -{ - goldfish_battery_display(do_control_write, client); - return 0; -} - -static int -do_ac_state( ControlClient client, char* args ) -{ - if (args) { - if (strcasecmp(args, "on") == 0) { - goldfish_battery_set_prop(1, POWER_SUPPLY_PROP_ONLINE, 1); - return 0; - } - if (strcasecmp(args, "off") == 0) { - goldfish_battery_set_prop(1, POWER_SUPPLY_PROP_ONLINE, 0); - return 0; - } - } - - control_write( client, "KO: Usage: \"ac on\" or \"ac off\"\n" ); - return -1; -} - -static int -do_battery_status( ControlClient client, char* args ) -{ - if (args) { - if (strcasecmp(args, "unknown") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_STATUS_UNKNOWN); - return 0; - } - if (strcasecmp(args, "charging") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_STATUS_CHARGING); - return 0; - } - if (strcasecmp(args, "discharging") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_STATUS_DISCHARGING); - return 0; - } - if (strcasecmp(args, "not-charging") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_STATUS_NOT_CHARGING); - return 0; - } - if (strcasecmp(args, "full") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_STATUS_FULL); - return 0; - } - } - - control_write( client, "KO: Usage: \"status unknown|charging|discharging|not-charging|full\"\n" ); - return -1; -} - -static int -do_battery_present( ControlClient client, char* args ) -{ - if (args) { - if (strcasecmp(args, "true") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_PRESENT, 1); - return 0; - } - if (strcasecmp(args, "false") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_PRESENT, 0); - return 0; - } - } - - control_write( client, "KO: Usage: \"present true\" or \"present false\"\n" ); - return -1; -} - -static int -do_battery_health( ControlClient client, char* args ) -{ - if (args) { - if (strcasecmp(args, "unknown") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_HEALTH_UNKNOWN); - return 0; - } - if (strcasecmp(args, "good") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_HEALTH_GOOD); - return 0; - } - if (strcasecmp(args, "overheat") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_HEALTH_OVERHEAT); - return 0; - } - if (strcasecmp(args, "dead") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_HEALTH_DEAD); - return 0; - } - if (strcasecmp(args, "overvoltage") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_HEALTH_OVERVOLTAGE); - return 0; - } - if (strcasecmp(args, "failure") == 0) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_HEALTH_UNSPEC_FAILURE); - return 0; - } - } - - control_write( client, "KO: Usage: \"health unknown|good|overheat|dead|overvoltage|failure\"\n" ); - return -1; -} - -static int -do_battery_capacity( ControlClient client, char* args ) -{ - if (args) { - int capacity; - - if (sscanf(args, "%d", &capacity) == 1 && capacity >= 0 && capacity <= 100) { - goldfish_battery_set_prop(0, POWER_SUPPLY_PROP_CAPACITY, capacity); - return 0; - } - } - - control_write( client, "KO: Usage: \"capacity \"\n" ); - return -1; -} - - -static const CommandDefRec power_commands[] = -{ - { "display", "display battery and charger state", - "display battery and charger state\r\n", NULL, - do_power_display, NULL }, - - { "ac", "set AC charging state", - "'ac on|off' allows you to set the AC charging state to on or off\r\n", NULL, - do_ac_state, NULL }, - - { "status", "set battery status", - "'status unknown|charging|discharging|not-charging|full' allows you to set battery status\r\n", NULL, - do_battery_status, NULL }, - - { "present", "set battery present state", - "'present true|false' allows you to set battery present state to true or false\r\n", NULL, - do_battery_present, NULL }, - - { "health", "set battery health state", - "'health unknown|good|overheat|dead|overvoltage|failure' allows you to set battery health state\r\n", NULL, - do_battery_health, NULL }, - - { "capacity", "set battery capacity state", - "'capacity ' allows you to set battery capacity to a value 0 - 100\r\n", NULL, - do_battery_capacity, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** E V E N T C O M M A N D S ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - - -static int -do_event_send( ControlClient client, char* args ) -{ - char* p; - - if (!args) { - control_write( client, "KO: Usage: event send :: ...\r\n" ); - return -1; - } - - p = args; - while (*p) { - char* q; - int type, code, value, ret; - - p += strspn( args, " \t" ); /* skip spaces */ - if (*p == 0) - break; - - q = p + strcspn( p, " \t" ); - - if (q == p) - break; - - ret = android_event_from_str( p, &type, &code, &value ); - if (ret < 0) { - if (ret == -1) { - control_write( client, - "KO: invalid event type in '%.*s', try 'event list types' for valid values\r\n", - q-p, p ); - } else if (ret == -2) { - control_write( client, - "KO: invalid event code in '%.*s', try 'event list codes ' for valid values\r\n", - q-p, p ); - } else { - control_write( client, - "KO: invalid event value in '%.*s', must be an integer\r\n", - q-p, p); - } - return -1; - } - - kbd_generic_event( type, code, value ); - p = q; - } - return 0; -} - -static int -do_event_types( ControlClient client, char* args ) -{ - int count = android_event_get_type_count(); - int nn; - - control_write( client, "event can be an integer or one of the following aliases\r\n" ); - for (nn = 0; nn < count; nn++) { - char tmp[16]; - char* p = tmp; - char* end = p + sizeof(tmp); - int count2 = android_event_get_code_count( nn );; - - p = android_event_bufprint_type_str( p, end, nn ); - - control_write( client, " %-8s", tmp ); - if (count2 > 0) - control_write( client, " (%d code aliases)", count2 ); - - control_write( client, "\r\n" ); - } - return 0; -} - -static int -do_event_codes( ControlClient client, char* args ) -{ - int count; - int nn, type, dummy; - - if (!args) { - control_write( client, "KO: argument missing, try 'event codes '\r\n" ); - return -1; - } - - if ( android_event_from_str( args, &type, &dummy, &dummy ) < 0 ) { - control_write( client, "KO: bad argument, see 'event types' for valid values\r\n" ); - return -1; - } - - count = android_event_get_code_count( type ); - if (count == 0) { - control_write( client, "no code aliases defined for this type\r\n" ); - } else { - control_write( client, "type '%s' accepts the following aliases:\r\n", - args ); - for (nn = 0; nn < count; nn++) { - char temp[20], *p = temp, *end = p + sizeof(temp); - android_event_bufprint_code_str( p, end, type, nn ); - control_write( client, " %-12s\r\n", temp ); - } - } - - return 0; -} - -static __inline__ int -utf8_next( unsigned char* *pp, unsigned char* end ) -{ - unsigned char* p = *pp; - int result = -1; - - if (p < end) { - int c= *p++; - if (c >= 128) { - if ((c & 0xe0) == 0xc0) - c &= 0x1f; - else if ((c & 0xf0) == 0xe0) - c &= 0x0f; - else - c &= 0x07; - - while (p < end && (p[0] & 0xc0) == 0x80) { - c = (c << 6) | (p[0] & 0x3f); - } - } - result = c; - *pp = p; - } - return result; -} - -static int -do_event_text( ControlClient client, char* args ) -{ - SkinKeyboard* keyboard; - unsigned char* p = (unsigned char*) args; - unsigned char* end = p + strlen(args); - int textlen; - - if (!args) { - control_write( client, "KO: argument missing, try 'event text '\r\n" ); - return -1; - } - keyboard = android_emulator_get_keyboard(); - if (keyboard == NULL) { - control_write( client, "KO: no keyboard active in current device layout/config\r\n" ); - return -1; - } - - /* un-secape message text into proper utf-8 (conversion happens in-site) */ - textlen = strlen((char*)p); - textlen = sms_utf8_from_message_str( args, textlen, (unsigned char*)p, textlen ); - if (textlen < 0) { - control_write( client, "message must be utf8 and can use the following escapes:\r\n" - " \\n for a newline\r\n" - " \\xNN where NN are two hexadecimal numbers\r\n" - " \\uNNNN where NNNN are four hexadecimal numbers\r\n" - " \\\\ to send a '\\' character\r\n\r\n" - " anything else is an error\r\n" - "KO: badly formatted text\r\n" ); - return -1; - } - - end = p + textlen; - while (p < end) { - int c = utf8_next( &p, end ); - if (c <= 0) - break; - - skin_keyboard_process_unicode_event( keyboard, (unsigned)c, 1 ); - skin_keyboard_process_unicode_event( keyboard, (unsigned)c, 0 ); - skin_keyboard_flush( keyboard ); - } - - return 0; -} - -static const CommandDefRec event_commands[] = -{ - { "send", "send a series of events to the kernel", - "'event send :: ...' allows your to send one or more hardware events\r\n" - "to the Android kernel. you can use text names or integers for and \r\n", NULL, - do_event_send, NULL }, - - { "types", "list all aliases", - "'event types' list all string aliases supported by the 'event' subcommands\r\n", - NULL, do_event_types, NULL }, - - { "codes", "list all aliases for a given ", - "'event codes ' lists all string aliases for a given event \r\n", - NULL, do_event_codes, NULL }, - - { "text", "simulate keystrokes from a given text", - "'event text ' allows you to simulate keypresses to generate a given text\r\n" - "message. must be an utf-8 string. Unicode points will be reverse-mapped\r\n" - "according to the current device keyboard. unsupported characters will be discarded\r\n" - "silently\r\n", NULL, do_event_text, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** V M C O M M A N D S ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -static int -do_avd_stop( ControlClient client, char* args ) -{ - if (!vm_running) { - control_write( client, "KO: virtual device already stopped\r\n" ); - return -1; - } - vm_stop(EXCP_INTERRUPT); - return 0; -} - -static int -do_avd_start( ControlClient client, char* args ) -{ - if (vm_running) { - control_write( client, "KO: virtual device already running\r\n" ); - return -1; - } - vm_start(); - return 0; -} - -static int -do_avd_status( ControlClient client, char* args ) -{ - control_write( client, "virtual device is %s\r\n", vm_running ? "running" : "stopped" ); - return 0; -} - -static int -do_avd_name( ControlClient client, char* args ) -{ - control_write( client, "%s\r\n", avdInfo_getName(android_avdInfo) ); - return 0; -} - -static const CommandDefRec vm_commands[] = -{ - { "stop", "stop the virtual device", - "'avd stop' stops the virtual device immediately, use 'avd start' to continue execution\r\n", - NULL, do_avd_stop, NULL }, - - { "start", "start/restart the virtual device", - "'avd start' will start or continue the virtual device, use 'avd stop' to stop it\r\n", - NULL, do_avd_start, NULL }, - - { "status", "query virtual device status", - "'avd status' will indicate wether the virtual device is running or not\r\n", - NULL, do_avd_status, NULL }, - - { "name", "query virtual device name", - "'avd name' will return the name of this virtual device\r\n", - NULL, do_avd_name, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** G E O C O M M A N D S ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -static int -do_geo_nmea( ControlClient client, char* args ) -{ - if (!args) { - control_write( client, "KO: NMEA sentence missing, try 'help geo nmea'\r\n" ); - return -1; - } - if (!android_gps_cs) { - control_write( client, "KO: no GPS emulation in this virtual device\r\n" ); - return -1; - } - android_gps_send_nmea( args ); - return 0; -} - -static int -do_geo_fix( ControlClient client, char* args ) -{ -#define MAX_GEO_PARAMS 3 - char* p = args; - int n_params = 0; - double params[ MAX_GEO_PARAMS ]; - - static int last_time = 0; - static double last_altitude = 0.; - - if (!p) - p = ""; - - /* tokenize */ - while (*p) { - char* end; - double val = strtod( p, &end ); - - if (end == p) { - control_write( client, "KO: argument '%s' is not a number\n", p ); - return -1; - } - - params[n_params++] = val; - if (n_params >= MAX_GEO_PARAMS) - break; - - p = end; - while (*p && (p[0] == ' ' || p[0] == '\t')) - p += 1; - } - - /* sanity check */ - if (n_params < 2) { - control_write( client, "KO: not enough arguments: see 'help geo fix' for details\r\n" ); - return -1; - } - - /* generate an NMEA sentence for this fix */ - { - STRALLOC_DEFINE(s); - double val; - int deg, min; - char hemi; - - /* first, the time */ - stralloc_add_format( s, "$GPGGA,%06d", last_time ); - last_time ++; - - /* then the latitude */ - hemi = 'N'; - val = params[1]; - if (val < 0) { - hemi = 'S'; - val = -val; - } - deg = (int) val; - min = 60*(val - deg); - val = val - min/60.; - stralloc_add_format( s, ",%02d%02d.%04d,%c", deg, min, (int)(val * 10000), hemi ); - - /* the longitude */ - hemi = 'E'; - val = params[0]; - if (val < 0) { - hemi = 'W'; - val = -val; - } - deg = (int) val; - min = 60*(val - deg); - val = val - min/60.; - stralloc_add_format( s, ",%02d%02d.%04d,%c", deg, min, (int)(val * 10000), hemi ); - - /* bogus fix quality, empty satellite count and dilutions */ - stralloc_add_str( s, ",1,,,," ); - - /* optional altitude */ - if (n_params >= 3) { - stralloc_add_format( s, "%.1g", params[2] ); - last_altitude = params[2]; - } else { - stralloc_add_str( s, "," ); - } - /* bogus rest and checksum */ - stralloc_add_str( s, ",,,*47" ); - - /* send it, then free */ - android_gps_send_nmea( stralloc_cstr(s) ); - stralloc_reset( s ); - } - return 0; -} - -static const CommandDefRec geo_commands[] = -{ - { "nmea", "send an GPS NMEA sentence", - "'geo nema ' sends a NMEA 0183 sentence to the emulated device, as\r\n" - "if it came from an emulated GPS modem. must begin with '$GP'. only\r\n" - "'$GPGGA' and '$GPRCM' sentences are supported at the moment.\r\n", - NULL, do_geo_nmea, NULL }, - - { "fix", "send a simple GPS fix", - "'geo fix []' allows you to send a\r\n" - "simple GPS fix to the emulated system. the parameters are:\r\n\r\n" - " longitude, in decimal degrees\r\n" - " latitude, in decimal degrees\r\n" - " optional altitude in meters\r\n" - "\r\n", - NULL, do_geo_fix, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** M A I N C O M M A N D S ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -extern void android_emulator_set_window_scale( double, int ); - -static int -do_window_scale( ControlClient client, char* args ) -{ - double scale; - int is_dpi = 0; - char* end; - - if (!args) { - control_write( client, "KO: argument missing, try 'window scale '\r\n" ); - return -1; - } - - scale = strtol( args, &end, 10 ); - if (end > args && !memcmp( end, "dpi", 4 )) { - is_dpi = 1; - } - else { - scale = strtod( args, &end ); - if (end == args || end[0]) { - control_write( client, "KO: argument must be a real number, or an integer followed by 'dpi'\r\n" ); - return -1; - } - } - - android_emulator_set_window_scale( scale, is_dpi ); - return 0; -} - -static const CommandDefRec window_commands[] = -{ - { "scale", "change the window scale", - "'window scale ' allows you to change the scale of the emulator window at runtime\r\n" - " must be either a real number between 0.1 and 3.0, or an integer followed by\r\n" - "the 'dpi' prefix (as in '120dpi')\r\n", - NULL, do_window_scale, NULL }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - -/********************************************************************************************/ -/********************************************************************************************/ -/***** ******/ -/***** M A I N C O M M A N D S ******/ -/***** ******/ -/********************************************************************************************/ -/********************************************************************************************/ - -static int -do_kill( ControlClient client, char* args ) -{ - control_write( client, "OK: killing emulator, bye bye\r\n" ); - exit(0); -} - -static const CommandDefRec main_commands[] = -{ - { "help|h|?", "print a list of commands", NULL, NULL, do_help, NULL }, - - { "event", "simulate hardware events", - "allows you to send fake hardware events to the kernel\r\n", NULL, - NULL, event_commands }, - - { "geo", "Geo-location commands", - "allows you to change Geo-related settings, or to send GPS NMEA sentences\r\n", NULL, - NULL, geo_commands }, - - { "gsm", "GSM related commands", - "allows you to change GSM-related settings, or to make a new inbound phone call\r\n", NULL, - NULL, gsm_commands }, - - { "kill", "kill the emulator instance", NULL, NULL, - do_kill, NULL }, - - { "network", "manage network settings", - "allows you to manage the settings related to the network data connection of the\r\n" - "emulated device.\r\n", NULL, - NULL, network_commands }, - - { "power", "power related commands", - "allows to change battery and AC power status\r\n", NULL, - NULL, power_commands }, - - { "quit|exit", "quit control session", NULL, NULL, - do_quit, NULL }, - - { "redir", "manage port redirections", - "allows you to add, list and remove UDP and/or PORT redirection from the host to the device\r\n" - "as an example, 'redir tcp:5000:6000' will route any packet sent to the host's TCP port 5000\r\n" - "to TCP port 6000 of the emulated device\r\n", NULL, - NULL, redir_commands }, - - { "sms", "SMS related commands", - "allows you to simulate an inbound SMS\r\n", NULL, - NULL, sms_commands }, - - { "avd", "manager virtual device state", - "allows to change (e.g. start/stop) the virtual device state\r\n", NULL, - NULL, vm_commands }, - - { "window", "manage emulator window", - "allows you to modify the emulator window\r\n", NULL, - NULL, window_commands }, - - { NULL, NULL, NULL, NULL, NULL, NULL } -}; - - -static ControlGlobalRec _g_global; - -int -control_console_start( int port ) -{ - return control_global_init( &_g_global, port ); -} diff --git a/android/globals.h b/android/globals.h deleted file mode 100644 index b26663d..0000000 --- a/android/globals.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -#ifndef _ANDROID_GLOBALS_H -#define _ANDROID_GLOBALS_H - -#include "android/avd/info.h" -#include "android/avd/hw-config.h" - -/* this structure is setup when loading the virtual device - * after that, you can read the 'flags' field to determine - * wether a data or cache wipe has been in effect. - */ -extern AvdInfoParams android_avdParams[1]; - -/* a pointer to the android virtual device information - * object, which can be queried for the paths of various - * image files or the skin - */ -extern AvdInfo* android_avdInfo; - -/* the hardware configuration for this specific virtual device */ -extern AndroidHwConfig android_hw[1]; - -#endif /* _ANDROID_GLOBALS_H */ diff --git a/android/gps.c b/android/gps.c deleted file mode 100644 index be68cfc..0000000 --- a/android/gps.c +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -#include "android/gps.h" -#include "android/utils/debug.h" -#include "qemu-char.h" - -CharDriverState* android_gps_cs; - -#define D(...) VERBOSE_PRINT(gps,__VA_ARGS__) - -void -android_gps_send_nmea( const char* sentence ) -{ - if (sentence == NULL) - return; - - D("sending '%s'", sentence); - - if (android_gps_cs == NULL) { - D("missing GPS channel, ignored"); - return; - } - - qemu_chr_write( android_gps_cs, (const void*)sentence, strlen(sentence) ); - qemu_chr_write( android_gps_cs, (const void*)"\n", 1 ); -} - - diff --git a/android/gps.h b/android/gps.h deleted file mode 100644 index 33ecece..0000000 --- a/android/gps.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright (C) 2007-2008 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. -*/ -#ifndef _android_gps_h -#define _android_gps_h - -#include "qemu-common.h" - -/* this is the internal character driver used to communicate with the - * emulated GPS unit. see qemu_chr_open() in vl.c */ -extern CharDriverState* android_gps_cs; - -extern void android_gps_send_nmea( const char* sentence ); - -#endif /* _android_gps_h */ diff --git a/android/help.c b/android/help.c deleted file mode 100644 index cd1b827..0000000 --- a/android/help.c +++ /dev/null @@ -1,1432 +0,0 @@ -#include "android/help.h" -#include "android/cmdline-option.h" -#include "android/utils/path.h" -#include "android/utils/bufprint.h" -#include "android/utils/debug.h" -#include "android/utils/misc.h" -#include "android/skin/keyset.h" -#include "android/android.h" -#include -#include "audio/audio.h" -#include -#include - -/* XXX: TODO: put most of the help stuff in auto-generated files */ - -#define PRINTF(...) stralloc_add_format(out,__VA_ARGS__) - -static void -help_virtual_device( stralloc_t* out ) -{ - PRINTF( - " An Android Virtual Device (AVD) models a single virtual\n" - " device running the Android platform that has, at least, its own\n" - " kernel, system image and data partition.\n\n" - - " Only one emulator process can run a given AVD at a time, but\n" - " you can create several AVDs and run them concurrently.\n\n" - - " You can invoke a given AVD at startup using either '-avd '\n" - " or '@', both forms being equivalent. For example, to launch\n" - " the AVD named 'foo', type:\n\n" - - " emulator @foo\n\n" - - " The 'android' helper tool can be used to manage virtual devices.\n" - " For example:\n\n" - - " android avd -- creates a new virtual device.\n" - " android list -- list all virtual devices available.\n\n" - - " Each AVD really corresponds to a content directory which stores\n" - " persistent and writable disk images as well as configuration files.\n" - - " Each AVD must be created against an existing SDK platform or add-on.\n" - " For more information on this topic, see -help-sdk-images.\n\n" - - " SPECIAL NOTE: in the case where you are *not* using the emulator\n" - " with the Android SDK, but with the Android build system, you will\n" - " need to define the ANDROID_PRODUCT_OUT variable in your environment.\n" - " See -help-build-images for the details.\n" - ); -} - - -static void -help_sdk_images( stralloc_t* out ) -{ - PRINTF( - " The Android SDK now supports multiple versions of the Android platform.\n" - " Each SDK 'platform' corresponds to:\n\n" - - " - a given version of the Android API.\n" - " - a set of corresponding system image files.\n" - " - build and configuration properties.\n" - " - an android.jar file used when building your application.\n" - " - skins.\n\n" - - " The Android SDK also supports the concept of 'add-ons'. Each add-on is\n" - " based on an existing platform, and provides replacement or additional\n" - " image files, android.jar, hardware configuration options and/or skins.\n\n" - - " The purpose of add-ons is to allow vendors to provide their own customized\n" - " system images and APIs without needing to package a complete SDK.\n\n" - - " Before using the SDK, you need to create an Android Virtual Device (AVD)\n" - " (see -help-virtual-device for details). Each AVD is created in reference\n" - " to a given SDK platform *or* add-on, and will search the corresponding\n" - " directories for system image files, in the following order:\n\n" - - " - in the AVD's content directory.\n" - " - in the AVD's SDK add-on directory, if any.\n" - " - in the AVD's SDK platform directory, if any.\n\n" - - " The image files are documented in -help-disk-images. By default, an AVD\n" - " content directory will contain the following persistent image files:\n\n" - - " userdata-qemu.img - the /data partition image file\n" - " cache.img - the /cache partition image file\n\n" - - " You can use -wipe-data to re-initialize the /data partition to its factory\n" - " defaults. This will erase all user settings for the virtual device.\n\n" - ); -} - -static void -help_build_images( stralloc_t* out ) -{ - PRINTF( - " The emulator detects that you are working from the Android build system\n" - " by looking at the ANDROID_PRODUCT_OUT variable in your environment.\n\n" - - " If it is defined, it should point to the product-specific directory that\n" - " contains the generated system images.\n" - - " In this case, the emulator will look by default for the following image\n" - " files there:\n\n" - - " - system.img : the *initial* system image.\n" - " - ramdisk.img : the ramdisk image used to boot the system.\n" - " - userdata.img : the *initial* user data image (see below).\n" - " - kernel-qemu : the emulator-specific Linux kernel image.\n\n" - - " If the kernel image is not found in the out directory, then it is searched\n" - " in /prebuilt/android-arm/kernel/.\n\n" - - " Skins will be looked in /development/emulator/skins/\n\n" - - " You can use the -system, -image, -kernel, -ramdisk, -datadir, -data options\n" - " to specify different search directories or specific image files. You can\n" - " also use the -cache and -sdcard options to indicate specific cache partition\n" - " and SD Card image files.\n\n" - - " For more details, see the corresponding -help-