private void deleteAndCreatePhone(int newVoiceRadioTech) { String outgoingPhoneName = "Unknown"; Phone oldPhone = mActivePhone; if (oldPhone != null) { outgoingPhoneName = ((PhoneBase) oldPhone).getPhoneName(); } logd( "Switching Voice Phone : " + outgoingPhoneName + " >>> " + (ServiceState.isGsm(newVoiceRadioTech) ? "GSM" : "CDMA")); if (oldPhone != null) { CallManager.getInstance().unregisterPhone(oldPhone); logd("Disposing old phone.."); oldPhone.dispose(); } // Give the garbage collector a hint to start the garbage collection // asap NOTE this has been disabled since radio technology change could // happen during e.g. a multimedia playing and could slow the system. // Tests needs to be done to see the effects of the GC call here when // system is busy. // System.gc(); if (ServiceState.isCdma(newVoiceRadioTech)) { mActivePhone = PhoneFactory.getCdmaPhone(); } else if (ServiceState.isGsm(newVoiceRadioTech)) { mActivePhone = PhoneFactory.getGsmPhone(); } if (oldPhone != null) { oldPhone.removeReferences(); } if (mActivePhone != null) { CallManager.getInstance().registerPhone(mActivePhone); } oldPhone = null; }