aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-02-14 23:54:04 -0500
committerXavier Ducrohet <xav@android.com>2011-02-16 17:46:11 -0800
commit39c4c560912be3758c37c257d17a82b8bbe87353 (patch)
treefacfb6313aee546595cb7427739928e76a796c9c
parent61ca5588c8f8d73de840a64dc3ad6f259faecc3c (diff)
downloadplatform_sdk-39c4c560912be3758c37c257d17a82b8bbe87353.tar.gz
platform_sdk-39c4c560912be3758c37c257d17a82b8bbe87353.tar.bz2
platform_sdk-39c4c560912be3758c37c257d17a82b8bbe87353.zip
Merge 11e72f25 into tools_r10. DO NOT MERGE.
Fix emulator GPS support Use create_thread_cb instead of pthread_create to create gps_state_thread so it can safely call into the Java framework. BUG: 3375089 Change-Id: I428534097852cfcc428aa93ba14c40558e35c8e8 Signed-off-by: Mike Lockwood <lockwood@android.com>
-rw-r--r--emulator/gps/gps_qemu.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/emulator/gps/gps_qemu.c b/emulator/gps/gps_qemu.c
index ce14fcb9b..a4699d3ee 100644
--- a/emulator/gps/gps_qemu.c
+++ b/emulator/gps/gps_qemu.c
@@ -660,7 +660,7 @@ epoll_deregister( int epoll_fd, int fd )
* when started, messages from the QEMU GPS daemon. these are simple NMEA sentences
* that must be parsed to be converted into GPS fixes sent to the framework
*/
-static void*
+static void
gps_state_thread( void* arg )
{
GpsState* state = (GpsState*) arg;
@@ -693,7 +693,7 @@ gps_state_thread( void* arg )
for (ne = 0; ne < nevents; ne++) {
if ((events[ne].events & (EPOLLERR|EPOLLHUP)) != 0) {
LOGE("EPOLLERR or EPOLLHUP after epoll_wait() !?");
- goto Exit;
+ return;
}
if ((events[ne].events & EPOLLIN) != 0) {
int fd = events[ne].data.fd;
@@ -709,7 +709,7 @@ gps_state_thread( void* arg )
if (cmd == CMD_QUIT) {
D("gps thread quitting on demand");
- goto Exit;
+ return;
}
else if (cmd == CMD_START) {
if (!started) {
@@ -754,13 +754,11 @@ gps_state_thread( void* arg )
}
}
}
-Exit:
- return NULL;
}
static void
-gps_state_init( GpsState* state )
+gps_state_init( GpsState* state, GpsCallbacks* callbacks )
{
state->init = 1;
state->control[0] = -1;
@@ -781,11 +779,15 @@ gps_state_init( GpsState* state )
goto Fail;
}
- if ( pthread_create( &state->thread, NULL, gps_state_thread, state ) != 0 ) {
+ state->thread = callbacks->create_thread_cb( "gps_state_thread", gps_state_thread, state );
+
+ if ( !state->thread ) {
LOGE("could not create gps thread: %s", strerror(errno));
goto Fail;
}
+ state->callbacks = *callbacks;
+
D("gps state initialized");
return;
@@ -809,13 +811,11 @@ qemu_gps_init(GpsCallbacks* callbacks)
GpsState* s = _gps_state;
if (!s->init)
- gps_state_init(s);
+ gps_state_init(s, callbacks);
if (s->fd < 0)
return -1;
- s->callbacks = *callbacks;
-
return 0;
}