aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2011-02-14 23:54:04 -0500
committerMike Lockwood <lockwood@android.com>2011-02-15 10:01:37 -0500
commit11e72f25bfc05bef01ef1198dc9c9f5f7ee4ec52 (patch)
treeeef63dad0e44c25ca0e5c094a15cdbb218db804e /emulator
parent31337a90712cc431f56eda815b9a2e65afcce90b (diff)
downloadsdk-11e72f25bfc05bef01ef1198dc9c9f5f7ee4ec52.zip
sdk-11e72f25bfc05bef01ef1198dc9c9f5f7ee4ec52.tar.gz
sdk-11e72f25bfc05bef01ef1198dc9c9f5f7ee4ec52.tar.bz2
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: Ie7b2bd4bea519702d4238ba375bf83b059095b9e Signed-off-by: Mike Lockwood <lockwood@android.com>
Diffstat (limited to 'emulator')
-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 ce14fcb..a4699d3 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;
}