/** * Handles the call to get the subscription source * * @param ar AsyncResult object that contains the result of get CDMA subscription source call */ private void handleGetCdmaSubscriptionSource(AsyncResult ar) { if ((ar.exception == null) && (ar.result != null)) { int newSubscriptionSource = ((int[]) ar.result)[0]; if (newSubscriptionSource != mCdmaSubscriptionSource.get()) { log( "Subscription Source Changed : " + mCdmaSubscriptionSource + " >> " + newSubscriptionSource); mCdmaSubscriptionSource.set(newSubscriptionSource); // Save CDMA subscription source saveCdmaSubscriptionSource(newSubscriptionSource); // Notify registrants of the new CDMA subscription source mCdmaSubscriptionSourceChangedRegistrants.notifyRegistrants( new AsyncResult(null, null, null)); } } else { // GET_CDMA_SUBSCRIPTION is returning Failure. Probably // because modem created GSM Phone. If modem created // GSMPhone, then PhoneProxy will trigger a change in // Phone objects and this object will be destroyed. logw( "Unable to get CDMA Subscription Source, Exception: " + ar.exception + ", result: " + ar.result); } }
/* * (non-Javadoc) * @see android.os.Handler#handleMessage(android.os.Message) */ @Override public void handleMessage(Message msg) { AsyncResult ar; switch (msg.what) { case EVENT_CDMA_SUBSCRIPTION_SOURCE_CHANGED: case EVENT_GET_CDMA_SUBSCRIPTION_SOURCE: { log("CDMA_SUBSCRIPTION_SOURCE event = " + msg.what); ar = (AsyncResult) msg.obj; handleGetCdmaSubscriptionSource(ar); } break; case EVENT_RADIO_ON: { mCM.getCdmaSubscriptionSource(obtainMessage(EVENT_GET_CDMA_SUBSCRIPTION_SOURCE)); } break; case EVENT_SUBSCRIPTION_STATUS_CHANGED: { Log.d(LOG_TAG, "EVENT_SUBSCRIPTION_STATUS_CHANGED"); ar = (AsyncResult) msg.obj; if (ar.exception == null) { int actStatus = ((int[]) ar.result)[0]; Log.d(LOG_TAG, "actStatus = " + actStatus); if (actStatus == SUBSCRIPTION_ACTIVATED) { // Subscription Activated // In case of multi-SIM, framework should wait for the subscription ready // to send any request to RIL. Otherwise it will return failure. Log.d(LOG_TAG, "get Cdma Subscription Source"); mCM.getCdmaSubscriptionSource(obtainMessage(EVENT_GET_CDMA_SUBSCRIPTION_SOURCE)); } } } break; default: super.handleMessage(msg); } }
/** * Save current source of cdma subscription * * @param source - 1 for NV, 0 for RUIM */ private void saveCdmaSubscriptionSource(int source) { log("Storing cdma subscription source: " + source); Settings.Secure.putInt( mContext.getContentResolver(), Settings.Secure.CDMA_SUBSCRIPTION_MODE, source); }