Make Loc Init Asynchronous

GPS-enable gets too heavy at powerup, when loc_init is
synchronous, where loc goes to get the hardware handle
if AP init happens faster than the GPS hardware. The
loc init calling thread is from Android framework, and
it locks a mutex that in turn could lock up system server
main thread upon race conditions.

The second half of loc init, i.e. the reinit, is now moved
to loc worker thread. This should help release some of the
powerup timing pressure on the framework threads.

Add a message just for asynchrous Loc Init so as to execute
init specifically.

Change-Id: I369e461ca4ca61cea3a9729c84d24af4ffa8e51d
CRs-fixed: 472843
This commit is contained in:
Kevin Tang 2013-06-07 13:39:24 -07:00
parent 8b386d2988
commit b05358920c
4 changed files with 28 additions and 12 deletions

View file

@ -62,6 +62,9 @@
/* Logging Improvement */
#include "log_util.h"
/*Maximum number of Modem init*/
#define RPC_TRY_NUM 10
/* Uncomment to force ALOGD messages */
// #define ALOGD ALOGI
@ -308,6 +311,7 @@ rpc_loc_client_handle_type loc_open (
void* userData
)
{
int try_num = RPC_TRY_NUM;
ENTRY_LOG();
LOC_GLUE_CHECK_INIT(rpc_loc_client_handle_type);
@ -352,14 +356,22 @@ rpc_loc_client_handle_type loc_open (
enum clnt_stat stat = RPC_SUCCESS;
EXIT_LOG_CALLFLOW(%s, "loc client open");
stat = RPC_FUNC_VERSION(rpc_loc_open_, RPC_LOC_OPEN_VERSION)(&args, &rets, loc_api_clnt);
/*try more for rpc_loc_open_xx()*/
do
{
stat = RPC_FUNC_VERSION(rpc_loc_open_, RPC_LOC_OPEN_VERSION)(&args, &rets, loc_api_clnt);
ret_val = (rpc_loc_client_handle_type) rets.loc_open_result;
try_num--;
}while( (RPC_SUCCESS != stat||0 > ret_val) && 0 != try_num );
LOC_GLUE_CHECK_RESULT(stat, int32);
/* save the handle in the table */
loc_glue_callback_table[i].handle = (rpc_loc_client_handle_type) rets.loc_open_result;
ret_val = (rpc_loc_client_handle_type) rets.loc_open_result;
return ret_val;
}

View file

@ -348,14 +348,9 @@ int loc_eng_init(loc_eng_data_s_type &loc_eng_data, LocCallbacks* callbacks,
} else {
LOC_LOGD("loc_eng_init created client, id = %p\n", loc_eng_data.client_handle);
// call reinit to send initialization messages
int tries = 30;
while (tries > 0 &&
LOC_API_ADAPTER_ERR_SUCCESS != (ret_val = loc_eng_reinit(loc_eng_data))) {
tries--;
LOC_LOGD("loc_eng_init client open failed, %d more tries", tries);
sleep(1);
}
/*send reinit event to QMI instead of call reinit directly*/
loc_eng_msg *msg(new loc_eng_msg(locEngHandle.owner, LOC_ENG_MSG_LOC_INIT));
locEngHandle.sendMsge(locEngHandle.owner, msg);
}
EXIT_LOG(%d, ret_val);
@ -1942,6 +1937,11 @@ static void loc_eng_deferred_action_thread(void* arg)
}
break;
case LOC_ENG_MSG_LOC_INIT:
{
loc_eng_reinit(*loc_eng_data_p);
}
default:
LOC_LOGE("unsupported msgid = %d\n", msg->msgid);
break;

View file

@ -107,7 +107,8 @@ static loc_name_val_s_type loc_eng_msgs[] =
NAME_VAL( ULP_MSG_MONITOR ),
NAME_VAL( LOC_ENG_MSG_LPP_CONFIG ),
NAME_VAL( ULP_MSG_INJECT_RAW_COMMAND ),
NAME_VAL( LOC_ENG_MSG_A_GLONASS_PROTOCOL )
NAME_VAL( LOC_ENG_MSG_A_GLONASS_PROTOCOL ),
NAME_VAL( LOC_ENG_MSG_LOC_INIT )
};
static int loc_eng_msgs_num = sizeof(loc_eng_msgs) / sizeof(loc_name_val_s_type);

View file

@ -131,6 +131,9 @@ enum loc_eng_msg_ids_t {
/* Message is sent by HAL to LOC API to select A-GLONASS protocol */
LOC_ENG_MSG_A_GLONASS_PROTOCOL,
//Message is sent by LOC to do LOC INIT
LOC_ENG_MSG_LOC_INIT,
};
#ifdef __cplusplus