@Override protected void onUpdateIccAvailability() { if (mUiccController == null) { return; } // Update IsimRecords UiccCardApplication newUiccApplication = mUiccController.getUiccCardApplication(UiccController.APP_FAM_IMS); IsimUiccRecords newIsimUiccRecords = null; if (newUiccApplication != null) { newIsimUiccRecords = (IsimUiccRecords) newUiccApplication.getIccRecords(); } mIsimUiccRecords = newIsimUiccRecords; // Update UsimRecords newUiccApplication = mUiccController.getUiccCardApplication(UiccController.APP_FAM_3GPP); SIMRecords newSimRecords = null; if (newUiccApplication != null) { newSimRecords = (SIMRecords) newUiccApplication.getIccRecords(); } if (mSimRecords != newSimRecords) { if (mSimRecords != null) { log("Removing stale SIMRecords object."); mSimRecords = null; } if (newSimRecords != null) { log("New SIMRecords found"); mSimRecords = newSimRecords; } } super.onUpdateIccAvailability(); }
private void onUpdateIccAvailability() { if (mUiccController == null) { return; } UiccCardApplication newUiccApplication = getUiccCardApplication(); UiccCardApplication app = mUiccApplication.get(); if (app != newUiccApplication) { if (app != null) { Rlog.d(TAG, "Removing stale icc objects."); if (mIccRecords.get() != null) { mIccRecords.get().unregisterForNewSms(this); } mIccRecords.set(null); mUiccApplication.set(null); } if (newUiccApplication != null) { Rlog.d(TAG, "New Uicc application found"); mUiccApplication.set(newUiccApplication); mIccRecords.set(newUiccApplication.getIccRecords()); if (mIccRecords.get() != null) { mIccRecords.get().registerForNewSms(this, EVENT_NEW_ICC_SMS, null); } } } }
/** * Used for instantiating/updating the Service from the GsmPhone or CdmaPhone constructor. * * @param ci CommandsInterface object * @param ir IccRecords object * @param context phone app context * @param fh Icc file handler * @param ic Icc card * @return The only Service object in the system */ public static CatService getInstance(CommandsInterface ci, Context context, UiccCard ic) { UiccCardApplication ca = null; IccFileHandler fh = null; IccRecords ir = null; if (ic != null) { /* Since Cat is not tied to any application, but rather is Uicc application * in itself - just get first FileHandler and IccRecords object */ ca = ic.getApplicationIndex(0); if (ca != null) { fh = ca.getIccFileHandler(); ir = ca.getIccRecords(); } } synchronized (sInstanceLock) { if (sInstance == null) { if (ci == null || ca == null || ir == null || context == null || fh == null || ic == null) { return null; } HandlerThread thread = new HandlerThread("Cat Telephony service"); thread.start(); sInstance = new CatService(ci, ca, ir, context, fh, ic); CatLog.d(sInstance, "NEW sInstance"); } else if ((ir != null) && (mIccRecords != ir)) { if (mIccRecords != null) { mIccRecords.unregisterForRecordsLoaded(sInstance); } if (mUiccApplication != null) { mUiccApplication.unregisterForReady(sInstance); } CatLog.d(sInstance, "Reinitialize the Service with SIMRecords and UiccCardApplication"); mIccRecords = ir; mUiccApplication = ca; // re-Register for SIM ready event. mIccRecords.registerForRecordsLoaded(sInstance, MSG_ID_ICC_RECORDS_LOADED, null); mUiccApplication.registerForReady(sInstance, MSG_ID_SIM_READY, null); CatLog.d(sInstance, "sr changed reinitialize and return current sInstance"); } else { CatLog.d(sInstance, "Return current sInstance"); } return sInstance; } }