aboutsummaryrefslogtreecommitdiffstats
path: root/android
diff options
context:
space:
mode:
authorDavid Turner <>2009-04-05 14:22:28 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2009-04-05 14:22:28 -0700
commitfff1ae51e389c25e2b19cd087c5e19cd27d40163 (patch)
tree0d6058c84618d7b2b30ef2b6a7d105f11dc01802 /android
parenta780727a390971e6cdc11cbe82c6a66052498212 (diff)
downloadexternal_qemu-fff1ae51e389c25e2b19cd087c5e19cd27d40163.zip
external_qemu-fff1ae51e389c25e2b19cd087c5e19cd27d40163.tar.gz
external_qemu-fff1ae51e389c25e2b19cd087c5e19cd27d40163.tar.bz2
AI 144596: am: CL 144595 Fix the AVD configuration code to support "sdcard.path" in config.ini to indicate an explicit SD Card image file (instead of using the one in the content directory)
Note that this also fix a bug where the SD Card image was not properly locked in the previous implementation. Allow the http-proxy support code to actually manage to receive chunked encoding data, instead of complaining needlessly. Introduce a new CharBuffer object that is used indirectly by "-radio <hostdevice>" and "-gps <hostdevice>" options Add new documentation for QEMUD and CharDriverState objects Update the Audio documentation with ASCII graphics (because I'm an artist too) Original author: digit Merged from: //branches/cupcake/... Automated import of CL 144596
Diffstat (limited to 'android')
-rw-r--r--android/avd/info.c34
-rw-r--r--android/hw-qemud.c41
-rw-r--r--android/hw-qemud.h41
3 files changed, 68 insertions, 48 deletions
diff --git a/android/avd/info.c b/android/avd/info.c
index 11c5d19..ec74249 100644
--- a/android/avd/info.c
+++ b/android/avd/info.c
@@ -86,6 +86,12 @@ AvdInfo* android_avdInfo;
/* default skin name */
#define SKIN_DEFAULT "HVGA"
+/* the config.ini key that is used to indicate the absolute path
+ * to the SD Card image file, if you don't want to place it in
+ * the content directory.
+ */
+#define SDCARD_PATH "sdcard.path"
+
/* 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
@@ -591,7 +597,12 @@ imageLoader_load( ImageLoader* l,
{
const char* path = NULL;
- /* first, check user-provided path */
+ /* set image state */
+ l->pState[0] = (flags & IMAGE_DONT_LOCK) == 0
+ ? IMAGE_STATE_MUSTLOCK
+ : IMAGE_STATE_READONLY;
+
+ /* check user-provided path */
path = l->params->forcePaths[l->id];
if (path != NULL) {
imageLoader_setPath(l, path);
@@ -696,7 +707,7 @@ _getImagePaths(AvdInfo* i, AvdInfoParams* params )
* and use it.
*/
imageLoader_set ( l, AVD_IMAGE_INITSYSTEM );
- imageLoader_load( l, IMAGE_REQUIRED | IMAGE_SEARCH_SDK );
+ imageLoader_load( l, IMAGE_REQUIRED | IMAGE_SEARCH_SDK | IMAGE_DONT_LOCK );
/* the data partition - this one is special because if it
* is missing, we need to copy the initial image file into it.
@@ -1031,6 +1042,24 @@ _getSkin( AvdInfo* i, AvdInfoParams* params )
return 0;
}
+/* If the user didn't explicitely provide an SD Card path,
+ * check the SDCARD_PATH key in config.ini and use that if
+ * available.
+ */
+static void
+_getSDCardPath( AvdInfo* i, AvdInfoParams* params )
+{
+ const char* path;
+
+ if (params->forcePaths[AVD_IMAGE_SDCARD] != NULL)
+ return;
+
+ path = iniFile_getString(i->configIni, SDCARD_PATH);
+ if (path == NULL)
+ return;
+
+ params->forcePaths[AVD_IMAGE_SDCARD] = path;
+}
AvdInfo*
avdInfo_new( const char* name, AvdInfoParams* params )
@@ -1058,6 +1087,7 @@ avdInfo_new( const char* name, AvdInfoParams* params )
* obsolete SDKs.
*/
_getSearchPaths(i);
+ _getSDCardPath(i, params);
/* don't need this anymore */
iniFile_free(i->rootIni);
diff --git a/android/hw-qemud.c b/android/hw-qemud.c
index bebf221..25d8717 100644
--- a/android/hw-qemud.c
+++ b/android/hw-qemud.c
@@ -99,26 +99,26 @@
* internal unique channel number > 0, then sends a connection
* initiation request to the emulator (i.e. through channel 0):
*
- * connect:<hxid>:<name>
+ * connect:<id>:<name>
*
- * where <name> is the service name, and <hxid> is a 4-hexchar
+ * where <name> is the service name, and <id> is a 2-hexchar
* number corresponding to the channel number.
*
* * in case of success, the emulator responds through channel 0
* with:
*
- * ok:connect:<hxid>
+ * ok:connect:<id>
*
* after this, all messages between the client and the emulator
* are passed in pass-through mode. If the client closes the
* connection, qemud sends the following to the emulator:
*
- * disconnect:<hxid>
+ * disconnect:<id>
*
* * if the emulator refuses the service connection, it will
* send the following through channel 0:
*
- * ko:connect:<hxid>:reason-for-failure
+ * ko:connect:<id>:reason-for-failure
*
* * any command sent through channel 0 to the emulator that is
* not properly recognized will be answered by:
@@ -562,7 +562,7 @@ qemud_client_disconnect( void* opaque )
/* send a disconnect command to the daemon */
if (c->channel > 0) {
char tmp[128], *p=tmp, *end=p+sizeof(tmp);
- p = bufprint(tmp, end, "disconnect:%04x", c->channel);
+ p = bufprint(tmp, end, "disconnect:%02x", c->channel);
qemud_serial_send(c->serial, 0, 0, (uint8_t*)tmp, p-tmp);
}
@@ -837,7 +837,7 @@ qemud_multiplexer_control_recv( void* opaque,
/* handle connection attempts.
* the client message must be "connect:<service-name>:<id>"
- * where <id> is a 4-char hexadecimal string, which must be > 0
+ * where <id> is a 2-char hexadecimal string, which must be > 0
*/
if (msglen > 8 && !memcmp(msg, "connect:", 8))
{
@@ -846,16 +846,16 @@ qemud_multiplexer_control_recv( void* opaque,
char* q;
q = strchr(service_name, ':');
- if (q == NULL || q+5 != (char*)msgend) {
+ if (q == NULL || q+3 != (char*)msgend) {
D("%s: malformed connect message: '%.*s' (offset=%d)",
__FUNCTION__, msglen, (const char*)msg, q ? q-(char*)msg : -1);
return;
}
*q++ = 0; /* zero-terminate service name */
- channel = hex2int((uint8_t*)q, 4);
+ channel = hex2int((uint8_t*)q, 2);
if (channel <= 0) {
D("%s: malformed channel id '%.*s",
- __FUNCTION__, 4, q);
+ __FUNCTION__, 2, q);
return;
}
@@ -867,13 +867,13 @@ qemud_multiplexer_control_recv( void* opaque,
if (ret < 0) {
if (ret == -1) {
/* could not connect */
- p = bufprint(tmp, end, "ko:connect:%04x:unknown service", channel);
+ p = bufprint(tmp, end, "ko:connect:%02x:unknown service", channel);
} else {
- p = bufprint(tmp, end, "ko:connect:%04x:service busy", channel);
+ p = bufprint(tmp, end, "ko:connect:%02x:service busy", channel);
}
}
else {
- p = bufprint(tmp, end, "ok:connect:%04x", channel);
+ p = bufprint(tmp, end, "ok:connect:%02x", channel);
}
qemud_serial_send(mult->serial, 0, 0, (uint8_t*)tmp, p-tmp);
return;
@@ -881,13 +881,13 @@ qemud_multiplexer_control_recv( void* opaque,
/* handle client disconnections,
* this message arrives when the client has closed the connection.
- * format: "disconnect:<id>" where <id> is a 4-hex channel id > 0
+ * format: "disconnect:<id>" where <id> is a 2-hex channel id > 0
*/
- if (msglen == 15 && !memcmp(msg, "disconnect:", 11)) {
- int channel_id = hex2int(msg+11, 4);
+ if (msglen == 13 && !memcmp(msg, "disconnect:", 11)) {
+ int channel_id = hex2int(msg+11, 2);
if (channel_id <= 0) {
D("%s: malformed disconnect channel id: '%.*s'",
- __FUNCTION__, 4, msg+11);
+ __FUNCTION__, 2, msg+11);
return;
}
qemud_multiplexer_disconnect(mult, channel_id);
@@ -1189,6 +1189,11 @@ android_qemud_get_channel( const char* name, CharDriverState* *pcs )
int
android_qemud_set_channel( const char* name, CharDriverState* peer_cs )
{
- qemud_service_register(name, 1, peer_cs, _qemud_char_service_connect);
+ CharDriverState* char_buffer = qemu_chr_open_buffer(peer_cs);
+
+ if (char_buffer == NULL)
+ return -1;
+
+ qemud_service_register(name, 1, char_buffer, _qemud_char_service_connect);
return 0;
}
diff --git a/android/hw-qemud.h b/android/hw-qemud.h
index 7101c2a..5b45a94 100644
--- a/android/hw-qemud.h
+++ b/android/hw-qemud.h
@@ -14,30 +14,8 @@
#include "qemu-common.h"
-/* recent versions of the emulated Android system contains a background
- * daemon, named 'qemud', which runs as root and opens /dev/ttyS0
- *
- * its purpose is to multiplex several communication channels between
- * the emulator and the system through a single serial port.
- *
- * each channel will be connected to a qemud-created unix socket on the
- * system, and to either a emulated character device or other facility in
- * the emulator.
- *
- * +--------> /dev/socket/qemud_gsm
- * emulated GSM <-----+ ______|_
- * | emulated | |
- * +====> /dev/ttyS0 <===>| qemud |------> /dev/socket/qemud_gps
- * | |________|
- * emulated GPS <-----+ |
- * | +---------> other
- * |
- * other <--------------+
- *
- *
- * this is done to overcome specific permission problems, as well as to add various
- * features that would require special kernel drivers otherwise even though they
- * only need a simple character channel.
+/* Support for the qemud-based 'services' in the emulator.
+ * Please read docs/ANDROID-QEMUD.TXT to understand what this is about.
*/
/* initialize the qemud support code in the emulator
@@ -50,14 +28,21 @@ extern void android_qemud_init( void );
*/
extern CharDriverState* android_qemud_get_cs( void );
-/* return the character driver state corresponding to a named qemud communication
- * channel. this can be used to send/data the channel.
+/* returns in '*pcs' a CharDriverState object that will be connected to
+ * a single client in the emulated system for a given named service.
+ *
+ * this is only used to connect GPS and GSM service clients to the
+ * implementation that requires a CharDriverState object for legacy
+ * reasons.
+ *
* returns 0 on success, or -1 in case of error
*/
extern int android_qemud_get_channel( const char* name, CharDriverState* *pcs );
-/* set the character driver state for a given qemud communication channel. this
- * is used to attach the channel to an external char driver device directly.
+/* set an explicit CharDriverState object for a given qemud communication channel. this
+ * is used to attach the channel to an external char driver device (e.g. one
+ * created with "-serial <device>") directly.
+ *
* returns 0 on success, -1 on error
*/
extern int android_qemud_set_channel( const char* name, CharDriverState* peer_cs );