diff options
author | Stephen Li <stephenl@codeaurora.org> | 2011-01-27 17:45:41 -0800 |
---|---|---|
committer | Ricardo Cerqueira <cyanogenmod@cerqueira.org> | 2013-04-30 01:05:52 +0100 |
commit | ca269d72a988b1b564d5d90ef714e6aefb1c3d47 (patch) | |
tree | f461a0a8080a05fe7ff5f4ef5f7a9b2b22d776eb | |
parent | 48717e95502605574918272ef8782456d82ab027 (diff) | |
download | android_hardware_qcom_gps-cm-10.1.tar.gz android_hardware_qcom_gps-cm-10.1.tar.bz2 android_hardware_qcom_gps-cm-10.1.zip |
GPS: Fixes a problem stopping the engine while an AGPS data is activecm-10.2-M1cm-10.1.3-RC2cm-10.1.3-RC1cm-10.1.3cm-10.1.2cm-10.1.1cm-10.1.0-RC5cm-10.1.0-RC4cm-10.1.0-RC3cm-10.1.0-RC2cm-10.1.0-RC1cm-10.1.0cm-10.1
Sometimes the engine does not send the GPS_STATUS_ENGINE_OFF
message, so we end up blinking the GPS icon forever. Deferring
the loc_eng_stop call until the AGPS activity is done works around
this problem.
Change-Id: I54a911b028cc685b282661837f1317119713d64a
-rw-r--r-- | loc_api/libloc_api/loc_eng.cpp | 38 | ||||
-rw-r--r-- | loc_api/libloc_api/loc_eng.h | 4 |
2 files changed, 40 insertions, 2 deletions
diff --git a/loc_api/libloc_api/loc_eng.cpp b/loc_api/libloc_api/loc_eng.cpp index f44667e..bf17089 100644 --- a/loc_api/libloc_api/loc_eng.cpp +++ b/loc_api/libloc_api/loc_eng.cpp @@ -256,7 +256,7 @@ static int loc_eng_init(GpsCallbacks* callbacks) pthread_mutex_init(&loc_eng_data.mute_session_lock, NULL); pthread_mutex_init(&loc_eng_data.deferred_action_mutex, NULL); pthread_cond_init(&loc_eng_data.deferred_action_cond, NULL); - + pthread_mutex_init (&(loc_eng_data.deferred_stop_mutex), NULL); // Open client rpc_loc_event_mask_type event = RPC_LOC_EVENT_PARSED_POSITION_REPORT | @@ -370,8 +370,11 @@ static void loc_eng_cleanup() loc_eng_data.deferred_action_thread = NULL; } - pthread_mutex_destroy (&loc_eng_data.deferred_action_mutex); + pthread_mutex_destroy (&loc_eng_data.xtra_module_data.lock); + pthread_mutex_destroy (&loc_eng_data.deferred_stop_mutex); pthread_cond_destroy (&loc_eng_data.deferred_action_cond); + pthread_mutex_destroy (&loc_eng_data.deferred_action_mutex); + pthread_mutex_destroy (&loc_eng_data.mute_session_lock); } @@ -433,6 +436,17 @@ static int loc_eng_stop() int ret_val; LOC_LOGD("loc_eng_stop called"); + pthread_mutex_lock(&(loc_eng_data.deferred_stop_mutex)); + // work around problem with loc_eng_stop when AGPS requests are pending + // we defer stopping the engine until the AGPS request is done + if (loc_eng_data.agps_request_pending) + { + loc_eng_data.stop_request_pending = true; + LOC_LOGD("loc_eng_stop - deferring stop until AGPS data call is finished\n"); + pthread_mutex_unlock(&(loc_eng_data.deferred_stop_mutex)); + return 0; + } + pthread_mutex_unlock(&(loc_eng_data.deferred_stop_mutex)); ret_val = loc_stop_fix(loc_eng_data.client_handle); if (ret_val != RPC_LOC_API_SUCCESS) @@ -1342,11 +1356,13 @@ static void loc_eng_process_conn_request (const rpc_loc_server_request_s_type *s { loc_eng_data.agps_status = GPS_REQUEST_AGPS_DATA_CONN; loc_eng_data.conn_handle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.open_req.conn_handle; + loc_eng_data.agps_request_pending = true; } else { loc_eng_data.agps_status = GPS_RELEASE_AGPS_DATA_CONN; loc_eng_data.conn_handle = server_request_ptr->payload.rpc_loc_server_request_u_type_u.close_req.conn_handle; + loc_eng_data.agps_request_pending = false; } /* hold a wake lock while events are pending for deferred_action_thread */ loc_eng_data.acquire_wakelock_cb(); @@ -2203,6 +2219,24 @@ static void loc_eng_deferred_action_thread(void* arg) } loc_eng_data.data_connection_is_on = FALSE; } + if (flags & (DEFERRED_ACTION_AGPS_DATA_SUCCESS | + DEFERRED_ACTION_AGPS_DATA_CLOSED | + DEFERRED_ACTION_AGPS_DATA_FAILED)) + { + pthread_mutex_lock(&(loc_eng_data.deferred_stop_mutex)); + // work around problem with loc_eng_stop when AGPS requests are pending + // we defer stopping the engine until the AGPS request is done + loc_eng_data.agps_request_pending = false; + if (loc_eng_data.stop_request_pending) + { + LOC_LOGD ("handling deferred stop\n"); + if (loc_stop_fix(loc_eng_data.client_handle) != RPC_LOC_API_SUCCESS) + { + LOC_LOGD ("loc_stop_fix failed!\n"); + } + } + pthread_mutex_unlock(&(loc_eng_data.deferred_stop_mutex)); + } // ATL open/close actions if (status != 0 ) diff --git a/loc_api/libloc_api/loc_eng.h b/loc_api/libloc_api/loc_eng.h index f1a76ab..43975cb 100644 --- a/loc_api/libloc_api/loc_eng.h +++ b/loc_api/libloc_api/loc_eng.h @@ -91,6 +91,10 @@ typedef struct gps_acquire_wakelock acquire_wakelock_cb; gps_release_wakelock release_wakelock_cb; AGpsStatusValue agps_status; + // used to defer stopping the GPS engine until AGPS data calls are done + boolean agps_request_pending; + boolean stop_request_pending; + pthread_mutex_t deferred_stop_mutex; loc_eng_xtra_data_s_type xtra_module_data; // data from loc_event_cb rpc_loc_event_mask_type loc_event; |