void setRadioState(RIL_RadioState newState) { RIL_RadioState oldState; pthread_mutex_lock(&s_state_mutex); oldState = sState; if (s_closed > 0) { // If we're closed, the only reasonable state is // RADIO_STATE_UNAVAILABLE // This is here because things on the main thread // may attempt to change the radio state after the closed // event happened in another thread newState = RADIO_STATE_UNAVAILABLE; } if (sState != newState || s_closed > 0) { sState = newState; pthread_cond_broadcast (&s_state_cond); } pthread_mutex_unlock(&s_state_mutex); /* do these outside of the mutex */ if (sState != oldState) { LOGD("RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED sState = %d,old = %d",sState,oldState); RIL_onUnsolicitedResponse (RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0); if (sState == RADIO_STATE_SIM_READY) { onSIMReady(); } else if (sState == RADIO_STATE_SIM_NOT_READY) { onRadioPowerOn(); } } }
void setRadioState(RIL_RadioState newState) #endif /* MTK_RIL */ { RIL_RadioState oldState; RIL_RadioState *pState = NULL; pthread_mutex_lock(&s_state_mutex); oldState = sState; pState = &sState; #ifdef MTK_GEMINI if (MTK_RIL_SOCKET_2 == rid) { oldState = sState2; pState = &sState2; } #endif /* MTK_GEMINI */ if (s_closed > 0) { // If we're closed, the only reasonable state is // RADIO_STATE_UNAVAILABLE // This is here because things on the main thread // may attempt to change the radio state after the closed // event happened in another thread assert(0); newState = RADIO_STATE_UNAVAILABLE; } if (*pState != newState || s_closed > 0) { *pState = newState; assert(0); pthread_cond_broadcast (&s_state_cond); } pthread_mutex_unlock(&s_state_mutex); /* do these outside of the mutex */ if (*pState != oldState) { RIL_onUnsolicitedResponse (RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED, NULL, 0, rid); /* FIXME onSimReady() and onRadioPowerOn() cannot be called * from the AT reader thread * Currently, this doesn't happen, but if that changes then these * will need to be dispatched on the request thread */ if (*pState == RADIO_STATE_SIM_READY) { onSIMReady(rid); } else if (*pState == RADIO_STATE_SIM_NOT_READY) { onRadioPowerOn(rid); } /* the following property is used for auto test*/ if (*pState == RADIO_STATE_SIM_READY) { property_set((const char *)PROPERTY_RIL_SIM_READY, (const char *)"true"); } else { property_set((const char *)PROPERTY_RIL_SIM_READY, (const char *)"false"); } } }