Add code to handle voice radio technology of LTE.
Wink Saville [Thu, 12 Sep 2013 06:56:00 +0000 (23:56 -0700)]
Sometimes the Voice Radio Technology is reported as LTE but Voice
over LTE (VoLte) is not currently supported and for Sprint we
should default to CDMAPhone in that case. Otherwise the could stay
as a GSMPhone and handling voice calls will fail.

Bug: 10673760
Change-Id: Ic77411b5da415c620fce5a185ca1d7542dfe3b7f

src/java/com/android/internal/telephony/Phone.java
src/java/com/android/internal/telephony/PhoneBase.java
src/java/com/android/internal/telephony/PhoneProxy.java
src/java/com/android/internal/telephony/ServiceStateTracker.java
src/java/com/android/internal/telephony/cdma/CdmaLteServiceStateTracker.java
src/java/com/android/internal/telephony/cdma/CdmaServiceStateTracker.java
src/java/com/android/internal/telephony/gsm/GsmServiceStateTracker.java

index 0e9dcc1..f0ee783 100644 (file)
@@ -1720,4 +1720,11 @@ public interface Phone {
      * Remove references to external object stored in this object.
      */
     void removeReferences();
+
+    /**
+     * Update the phone object if the voice radio technology has changed
+     *
+     * @param voiceRadioTech The new voice radio technology
+     */
+    void updatePhoneObject(int voiceRadioTech);
 }
index c78b6c2..2a047c2 100644 (file)
@@ -748,6 +748,12 @@ public abstract class PhoneBase extends Handler implements Phone {
         return this;
     }
 
+    @Override
+    public void updatePhoneObject(int voiceRadioTech) {
+        // Only the PhoneProxy can update the phone object.
+        PhoneFactory.getDefaultPhone().updatePhoneObject(voiceRadioTech);
+    }
+
     /**
     * Retrieves the ServiceStateTracker of the phone instance.
     */
index 7d36a9c..38f961a 100644 (file)
@@ -59,6 +59,7 @@ public class PhoneProxy extends Handler implements Phone {
     private static final int EVENT_RADIO_ON = 2;
     private static final int EVENT_REQUEST_VOICE_RADIO_TECH_DONE = 3;
     private static final int EVENT_RIL_CONNECTED = 4;
+    private static final int EVENT_UPDATE_PHONE_OBJECT = 5;
 
     private static final String LOG_TAG = "PhoneProxy";
 
@@ -108,19 +109,25 @@ public class PhoneProxy extends Handler implements Phone {
 
         case EVENT_VOICE_RADIO_TECH_CHANGED:
         case EVENT_REQUEST_VOICE_RADIO_TECH_DONE:
-
+            String what = (msg.what == EVENT_VOICE_RADIO_TECH_CHANGED) ?
+                    "EVENT_VOICE_RADIO_TECH_CHANGED" : "EVENT_REQUEST_VOICE_RADIO_TECH_DONE";
             if (ar.exception == null) {
                 if ((ar.result != null) && (((int[]) ar.result).length != 0)) {
                     int newVoiceTech = ((int[]) ar.result)[0];
-                    updatePhoneObject(newVoiceTech);
+                    logd(what + ": newVoiceTech=" + newVoiceTech);
+                    phoneObjectUpdater(newVoiceTech);
                 } else {
-                    loge("Voice Radio Technology event " + msg.what + " has no tech!");
+                    loge(what + ": has no tech!");
                 }
             } else {
-                loge("Voice Radio Technology event " + msg.what + " exception!" + ar.exception);
+                loge(what + ": exception=" + ar.exception);
             }
             break;
 
+        case EVENT_UPDATE_PHONE_OBJECT:
+            phoneObjectUpdater(msg.arg1);
+            break;
+
         default:
             loge("Error! This handler was not registered for this message type. Message: "
                     + msg.what);
@@ -137,23 +144,34 @@ public class PhoneProxy extends Handler implements Phone {
         Rlog.e(LOG_TAG, "[PhoneProxy] " + msg);
     }
 
-    private void updatePhoneObject(int newVoiceRadioTech) {
+    private void phoneObjectUpdater(int newVoiceRadioTech) {
+        logd("phoneObjectUpdater: newVoiceRadioTech=" + newVoiceRadioTech);
 
         if (mActivePhone != null) {
+            // Check for a voice over lte replacement
+            if ((newVoiceRadioTech == ServiceState.RIL_RADIO_TECHNOLOGY_LTE)) {
+                int volteReplacementRat = mActivePhone.getContext().getResources().getInteger(
+                        com.android.internal.R.integer.config_volte_replacement_rat);
+                logd("phoneObjectUpdater: volteReplacementRat=" + volteReplacementRat);
+                if (volteReplacementRat != ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN) {
+                    newVoiceRadioTech = volteReplacementRat;
+                }
+            }
+
             if(mRilVersion == 6 && getLteOnCdmaMode() == PhoneConstants.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() == PhoneConstants.PHONE_TYPE_CDMA) {
-                    logd("LTE ON CDMA property is set. Use CDMA Phone" +
-                            " newVoiceRadioTech = " + newVoiceRadioTech +
-                            " Active Phone = " + mActivePhone.getPhoneName());
+                    logd("phoneObjectUpdater: LTE ON CDMA property is set. Use CDMA Phone" +
+                            " newVoiceRadioTech=" + newVoiceRadioTech +
+                            " mActivePhone=" + mActivePhone.getPhoneName());
                     return;
                 } else {
-                    logd("LTE ON CDMA property is set. Switch to CDMALTEPhone" +
-                            " newVoiceRadioTech = " + newVoiceRadioTech +
-                            " Active Phone = " + mActivePhone.getPhoneName());
+                    logd("phoneObjectUpdater: LTE ON CDMA property is set. Switch to CDMALTEPhone" +
+                            " newVoiceRadioTech=" + newVoiceRadioTech +
+                            " mActivePhone=" + mActivePhone.getPhoneName());
                     newVoiceRadioTech = ServiceState.RIL_RADIO_TECHNOLOGY_1xRTT;
                 }
             } else {
@@ -162,9 +180,9 @@ public class PhoneProxy extends Handler implements Phone {
                         (ServiceState.isGsm(newVoiceRadioTech) &&
                                 mActivePhone.getPhoneType() == PhoneConstants.PHONE_TYPE_GSM)) {
                     // Nothing changed. Keep phone as it is.
-                    logd("Ignoring voice radio technology changed message." +
-                            " newVoiceRadioTech = " + newVoiceRadioTech +
-                            " Active Phone = " + mActivePhone.getPhoneName());
+                    logd("phoneObjectUpdater: No change ignore," +
+                            " newVoiceRadioTech=" + newVoiceRadioTech +
+                            " mActivePhone=" + mActivePhone.getPhoneName());
                     return;
                 }
             }
@@ -173,8 +191,8 @@ public class PhoneProxy extends Handler implements Phone {
         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());
+            logd("phoneObjectUpdater: Unknown rat ignore, "
+                    + " newVoiceRadioTech=Unknown. mActivePhone=" + mActivePhone.getPhoneName());
             return;
         }
 
@@ -182,7 +200,7 @@ public class PhoneProxy extends Handler implements Phone {
         if (mResetModemOnRadioTechnologyChange) {
             if (mCommandsInterface.getRadioState().isOn()) {
                 oldPowerState = true;
-                logd("Setting Radio Power to Off");
+                logd("phoneObjectUpdater: Setting Radio Power to Off");
                 mCommandsInterface.setRadioPower(false, null);
             }
         }
@@ -190,7 +208,7 @@ public class PhoneProxy extends Handler implements Phone {
         deleteAndCreatePhone(newVoiceRadioTech);
 
         if (mResetModemOnRadioTechnologyChange && oldPowerState) { // restore power state
-            logd("Resetting Radio");
+            logd("phoneObjectUpdater: Resetting Radio");
             mCommandsInterface.setRadioPower(oldPowerState, null);
         }
 
@@ -255,6 +273,12 @@ public class PhoneProxy extends Handler implements Phone {
     }
 
     @Override
+    public void updatePhoneObject(int voiceRadioTech) {
+        logd("updatePhoneObject: radioTechnology=" + voiceRadioTech);
+        sendMessage(obtainMessage(EVENT_UPDATE_PHONE_OBJECT, voiceRadioTech, 0, null));
+    }
+
+    @Override
     public ServiceState getServiceState() {
         return mActivePhone.getServiceState();
     }
index a85f55d..c4a93b9 100644 (file)
@@ -269,6 +269,9 @@ public abstract class ServiceStateTracker extends Handler {
         }
     }
 
+    protected void updatePhoneObject() {
+        mPhoneBase.updatePhoneObject(mSS.getRilVoiceRadioTechnology());
+    }
 
     /**
      * Registration point for combined roaming on
index 6d1084b..15889e4 100644 (file)
@@ -80,6 +80,7 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
             handlePollStateResult(msg.what, ar);
             break;
         case EVENT_RUIM_RECORDS_LOADED:
+            updatePhoneObject();
             RuimRecords ruim = (RuimRecords)mIccRecords;
             if ((ruim != null) && ruim.isProvisioned()) {
                 mMdn = ruim.getMdn();
@@ -345,6 +346,10 @@ public class CdmaLteServiceStateTracker extends CdmaServiceStateTracker {
 
         mNewSS.setStateOutOfService(); // clean slate for next time
 
+        if (hasVoiceRadioTechnologyChanged) {
+            updatePhoneObject();
+        }
+
         if (hasDataRadioTechnologyChanged) {
             mPhone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
                     ServiceState.rilRadioTechnologyToString(mSS.getRilDataRadioTechnology()));
index 1e08c37..42a3aa7 100644 (file)
@@ -295,6 +295,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
             break;
 
         case EVENT_NV_READY:
+            updatePhoneObject();
+
             // For Non-RUIM phones, the subscription information is stored in
             // Non Volatile. Here when Non-Volatile is ready, we can poll the CDMA
             // subscription info.
@@ -450,6 +452,8 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
             break;
 
         case EVENT_RUIM_RECORDS_LOADED:
+            log("EVENT_RUIM_RECORDS_LOADED: what=" + msg.what);
+            updatePhoneObject();
             updateSpnDisplay();
             break;
 
@@ -987,6 +991,9 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
         boolean hasCdmaDataConnectionChanged =
                        mSS.getDataRegState() != mNewSS.getDataRegState();
 
+        boolean hasRilVoiceRadioTechnologyChanged =
+                mSS.getRilVoiceRadioTechnology() != mNewSS.getRilVoiceRadioTechnology();
+
         boolean hasRilDataRadioTechnologyChanged =
                 mSS.getRilDataRadioTechnology() != mNewSS.getRilDataRadioTechnology();
 
@@ -1017,7 +1024,9 @@ public class CdmaServiceStateTracker extends ServiceStateTracker {
         mCellLoc = mNewCellLoc;
         mNewCellLoc = tcl;
 
-        mNewSS.setStateOutOfService(); // clean slate for next time
+        if (hasRilVoiceRadioTechnologyChanged) {
+            updatePhoneObject();
+        }
 
         if (hasRilDataRadioTechnologyChanged) {
             mPhone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
index aacd50a..ca1e08d 100644 (file)
@@ -394,6 +394,9 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
                 break;
 
             case EVENT_SIM_RECORDS_LOADED:
+                log("EVENT_SIM_RECORDS_LOADED: what=" + msg.what);
+
+                updatePhoneObject();
                 updateSpnDisplay();
                 break;
 
@@ -913,6 +916,10 @@ final class GsmServiceStateTracker extends ServiceStateTracker {
         mReasonDataDenied = mNewReasonDataDenied;
         mMaxDataCalls = mNewMaxDataCalls;
 
+        if (hasRilVoiceRadioTechnologyChanged) {
+            updatePhoneObject();
+        }
+
         if (hasRilDataRadioTechnologyChanged) {
             mPhone.setSystemProperty(TelephonyProperties.PROPERTY_DATA_NETWORK_TYPE,
                     ServiceState.rilRadioTechnologyToString(mSS.getRilVoiceRadioTechnology()));