Example #1
0
  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;
  }
Example #2
0
  private void updatePhoneObject(int newVoiceRadioTech) {

    if (mActivePhone != null) {
      if (mRilVersion == 6 && getLteOnCdmaMode() == Phone.LTE_ON_CDMA_TRUE) {
        /*
         * On v6 RIL, when LTE_ON_CDMA is TRUE, always create CDMALTEPhone
         * irrespective of the voice radio tech reported.
         */
        if (mActivePhone.getPhoneType() == PHONE_TYPE_CDMA) {
          logd(
              "LTE ON CDMA property is set. Use CDMA Phone"
                  + " newVoiceRadioTech = "
                  + newVoiceRadioTech
                  + " Active Phone = "
                  + mActivePhone.getPhoneName());
          return;
        } else {
          logd(
              "LTE ON CDMA property is set. Switch to CDMALTEPhone"
                  + " newVoiceRadioTech = "
                  + newVoiceRadioTech
                  + " Active Phone = "
                  + mActivePhone.getPhoneName());
          newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
        }
      } else {
        if ((ServiceState.isCdma(newVoiceRadioTech)
                && mActivePhone.getPhoneType() == PHONE_TYPE_CDMA)
            || (ServiceState.isGsm(newVoiceRadioTech)
                && mActivePhone.getPhoneType() == PHONE_TYPE_GSM)) {
          // Nothing changed. Keep phone as it is.
          logd(
              "Ignoring voice radio technology changed message."
                  + " newVoiceRadioTech = "
                  + newVoiceRadioTech
                  + " Active Phone = "
                  + mActivePhone.getPhoneName());
          return;
        }
      }
    }

    if (newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
      // We need some voice phone object to be active always, so never
      // delete the phone without anything to replace it with!
      logd(
          "Ignoring voice radio technology changed message. newVoiceRadioTech = Unknown."
              + " Active Phone = "
              + mActivePhone.getPhoneName());
      return;
    }

    boolean oldPowerState = false; // old power state to off
    if (mResetModemOnRadioTechnologyChange) {
      if (mCommandsInterface.getRadioState().isOn()) {
        oldPowerState = true;
        logd("Setting Radio Power to Off");
        mCommandsInterface.setRadioPower(false, null);
      }
    }

    deleteAndCreatePhone(newVoiceRadioTech);

    if (mResetModemOnRadioTechnologyChange && oldPowerState) { // restore power state
      logd("Resetting Radio");
      mCommandsInterface.setRadioPower(oldPowerState, null);
    }

    // Set the new interfaces in the proxy's
    mIccSmsInterfaceManagerProxy.setmIccSmsInterfaceManager(
        mActivePhone.getIccSmsInterfaceManager());
    mIccPhoneBookInterfaceManagerProxy.setmIccPhoneBookInterfaceManager(
        mActivePhone.getIccPhoneBookInterfaceManager());
    mPhoneSubInfoProxy.setmPhoneSubInfo(this.mActivePhone.getPhoneSubInfo());

    mCommandsInterface = ((PhoneBase) mActivePhone).mCM;

    // Send an Intent to the PhoneApp that we had a radio technology change
    Intent intent = new Intent(TelephonyIntents.ACTION_RADIO_TECHNOLOGY_CHANGED);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    intent.putExtra(Phone.PHONE_NAME_KEY, mActivePhone.getPhoneName());
    ActivityManagerNative.broadcastStickyIntent(intent, null);
  }