From 719f2bdd392c1947d46d1fc9ad5700733a1b764b Mon Sep 17 00:00:00 2001 From: Wootak Jung Date: Tue, 8 Mar 2016 11:18:21 +0900 Subject: [PATCH] Added @retval(SIM not available) in document Change-Id: Iffb013dec6410375d83d910fb8fd7e1de79d7f54 --- include/telephony_sim.h | 6 +++++ src/telephony_sim.c | 60 ++++++++++++++++++++++++++++++------------------- 2 files changed, 43 insertions(+), 23 deletions(-) diff --git a/include/telephony_sim.h b/include/telephony_sim.h index 9befb65..79d04fb 100644 --- a/include/telephony_sim.h +++ b/include/telephony_sim.h @@ -255,6 +255,11 @@ int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied * @retval #TELEPHONY_ERROR_NOT_SUPPORTED Not supported * @retval #TELEPHONY_ERROR_OPERATION_FAILED Invalid parameter + * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available + * + * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE. + * + * @see telephony_sim_get_state() */ int telephony_sim_get_application_list(telephony_h handle, unsigned int *app_list); @@ -391,6 +396,7 @@ int telephony_sim_get_group_id1(telephony_h handle, char **gid1); * @retval #TELEPHONY_ERROR_PERMISSION_DENIED Permission denied * @retval #TELEPHONY_ERROR_NOT_SUPPORTED Not supported * @retval #TELEPHONY_ERROR_OPERATION_FAILED Invalid parameter + * @retval #TELEPHONY_ERROR_SIM_NOT_AVAILABLE SIM is not available * * @pre The SIM state must be #TELEPHONY_SIM_STATE_AVAILABLE. * diff --git a/src/telephony_sim.c b/src/telephony_sim.c index df9ce18..a4bc792 100644 --- a/src/telephony_sim.c +++ b/src/telephony_sim.c @@ -336,28 +336,36 @@ int telephony_sim_get_state(telephony_h handle, telephony_sim_state_e *sim_state int telephony_sim_get_application_list(telephony_h handle, unsigned int *app_list) { + int error_code = TELEPHONY_ERROR_NONE; + TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN; TapiHandle *tapi_h; - unsigned char tapi_app_list; - int ret; CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE); CHECK_INPUT_PARAMETER(handle); tapi_h = ((telephony_data *)handle)->tapi_h; CHECK_INPUT_PARAMETER(tapi_h); CHECK_INPUT_PARAMETER(app_list); + GET_SIM_STATUS(tapi_h, sim_card_state); - ret = tel_get_sim_application_list(tapi_h, &tapi_app_list); - if (ret == TAPI_API_ACCESS_DENIED) { - LOGE("PERMISSION_DENIED"); - return TELEPHONY_ERROR_PERMISSION_DENIED; - } else if (ret != TAPI_API_SUCCESS) { - LOGE("OPERATION_FAILED"); - return TELEPHONY_ERROR_OPERATION_FAILED; + *app_list = 0x0; + if (sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) { + error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE; + } else { + unsigned char tapi_app_list; + int ret = tel_get_sim_application_list(tapi_h, &tapi_app_list); + if (ret == TAPI_API_SUCCESS) { + *app_list = (unsigned int)tapi_app_list; + } else if (ret == TAPI_API_ACCESS_DENIED) { + LOGE("PERMISSION_DENIED"); + error_code = TELEPHONY_ERROR_PERMISSION_DENIED; + } else if (ret != TAPI_API_SUCCESS) { + LOGE("OPERATION_FAILED"); + error_code = TELEPHONY_ERROR_OPERATION_FAILED; + } } - *app_list = (unsigned int)tapi_app_list; LOGI("SIM Application List: [0x%x]", *app_list); - return TELEPHONY_ERROR_NONE; + return error_code; } int telephony_sim_get_subscriber_number(telephony_h handle, char **subscriber_number) @@ -561,27 +569,33 @@ int telephony_sim_get_group_id1(telephony_h handle, char **gid1) int telephony_sim_get_call_forwarding_indicator_state(telephony_h handle, bool *state) { - int error_code; + int error_code = TELEPHONY_ERROR_NONE; + TelSimCardStatus_t sim_card_state = TAPI_SIM_STATUS_UNKNOWN; TapiHandle *tapi_h; - int tel_state; CHECK_TELEPHONY_SUPPORTED(TELEPHONY_FEATURE); CHECK_INPUT_PARAMETER(handle); tapi_h = ((telephony_data *)handle)->tapi_h; CHECK_INPUT_PARAMETER(tapi_h); CHECK_INPUT_PARAMETER(state); + GET_SIM_STATUS(tapi_h, sim_card_state); - error_code = tel_get_property_int(tapi_h, TAPI_PROP_SIM_CALL_FORWARD_STATE, &tel_state); - if (error_code == TAPI_API_SUCCESS) { - *state = (bool)tel_state; - LOGI("Call forwarding indicator state: [%s]", *state ? "ON" : "OFF"); - error_code = TELEPHONY_ERROR_NONE; - } else if (error_code == TAPI_API_ACCESS_DENIED) { - LOGE("PERMISSION_DENIED"); - error_code = TELEPHONY_ERROR_PERMISSION_DENIED; + *state = false; + if (sim_card_state != TAPI_SIM_STATUS_SIM_INIT_COMPLETED) { + error_code = TELEPHONY_ERROR_SIM_NOT_AVAILABLE; } else { - LOGE("OPERATION_FAILED"); - error_code = TELEPHONY_ERROR_OPERATION_FAILED; + int tel_state; + int ret = tel_get_property_int(tapi_h, TAPI_PROP_SIM_CALL_FORWARD_STATE, &tel_state); + if (ret == TAPI_API_SUCCESS) { + *state = (bool)tel_state; + LOGI("Call forwarding indicator state: [%s]", *state ? "ON" : "OFF"); + } else if (ret == TAPI_API_ACCESS_DENIED) { + LOGE("PERMISSION_DENIED"); + error_code = TELEPHONY_ERROR_PERMISSION_DENIED; + } else { + LOGE("OPERATION_FAILED"); + error_code = TELEPHONY_ERROR_OPERATION_FAILED; + } } return error_code; -- 2.7.4