Merge "Add Explicit Call Transfer feature for IMS call"
diff --git a/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java b/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java
index a73b1ea..e5d0da0 100644
--- a/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java
+++ b/src/java/com/android/internal/telephony/CarrierKeyDownloadManager.java
@@ -539,6 +539,7 @@
             request.setAllowedOverMetered(mAllowedOverMeteredNetwork);
             request.setVisibleInDownloadsUi(false);
             request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN);
+            request.addRequestHeader("Accept-Encoding", "gzip");
             Long carrierKeyDownloadRequestId = mDownloadManager.enqueue(request);
             SharedPreferences.Editor editor = getDefaultSharedPreferences(mContext).edit();
 
diff --git a/src/java/com/android/internal/telephony/CommandsInterface.java b/src/java/com/android/internal/telephony/CommandsInterface.java
index cf6c38c..7a05fa1 100644
--- a/src/java/com/android/internal/telephony/CommandsInterface.java
+++ b/src/java/com/android/internal/telephony/CommandsInterface.java
@@ -1184,6 +1184,11 @@
      */
     void sendCdmaSms(byte[] pdu, Message response);
 
+    /**
+     * Identical to sendCdmaSms, except that more messages are expected to be sent soon
+     * @param pdu is CDMA-SMS in internal pseudo-PDU format
+     * @param response response sent when operation completed
+     */
     void sendCdmaSMSExpectMore(byte[] pdu, Message response);
 
     /**
diff --git a/src/java/com/android/internal/telephony/RIL.java b/src/java/com/android/internal/telephony/RIL.java
index b812432..9de0fe2 100644
--- a/src/java/com/android/internal/telephony/RIL.java
+++ b/src/java/com/android/internal/telephony/RIL.java
@@ -3213,7 +3213,7 @@
                     (android.hardware.radio.V1_5.IRadio) radioProxy;
             if (radioProxy15 != null) {
                 RILRequest rr = obtainRequest(RIL_REQUEST_CDMA_SEND_SMS_EXPECT_MORE, result,
-                    mRILDefaultWorkSource);
+                        mRILDefaultWorkSource);
 
                 // Do not log function arg for privacy
                 if (RILJ_LOGD) riljLog(rr.serialString() + "> " + requestToString(rr.mRequest));
@@ -3224,7 +3224,7 @@
                 try {
                     radioProxy15.sendCdmaSmsExpectMore(rr.mSerial, msg);
                     mMetrics.writeRilSendSms(mPhoneId, rr.mSerial, SmsSession.Event.Tech.SMS_CDMA,
-                        SmsSession.Event.Format.SMS_FORMAT_3GPP2);
+                            SmsSession.Event.Format.SMS_FORMAT_3GPP2);
                 } catch (RemoteException | RuntimeException e) {
                     handleRadioProxyExceptionForRR(rr, "sendCdmaSMSExpectMore", e);
                 }
diff --git a/src/java/com/android/internal/telephony/TelephonyTester.java b/src/java/com/android/internal/telephony/TelephonyTester.java
index b8288ae..a18911d 100644
--- a/src/java/com/android/internal/telephony/TelephonyTester.java
+++ b/src/java/com/android/internal/telephony/TelephonyTester.java
@@ -24,6 +24,7 @@
 import android.os.BadParcelableException;
 import android.os.Bundle;
 import android.telephony.AccessNetworkConstants;
+import android.telephony.NetworkRegistrationInfo;
 import android.telephony.ServiceState;
 import android.telephony.TelephonyManager;
 import android.telephony.ims.ImsCallProfile;
@@ -130,6 +131,8 @@
     private static final String EXTRA_DATA_REG_STATE = "data_reg_state";
     private static final String EXTRA_VOICE_ROAMING_TYPE = "voice_roaming_type";
     private static final String EXTRA_DATA_ROAMING_TYPE = "data_roaming_type";
+    private static final String EXTRA_NR_FREQUENCY_RANGE = "nr_frequency_range";
+    private static final String EXTRA_NR_STATE = "nr_state";
     private static final String EXTRA_OPERATOR = "operator";
 
     private static final String ACTION_RESET = "reset";
@@ -215,11 +218,13 @@
                 filter.addAction(ACTION_TEST_SUPP_SRVC_NOTIFICATION);
                 filter.addAction(ACTION_TEST_IMS_E_CALL);
                 mImsExternalCallStates = new ArrayList<ImsExternalCallState>();
-            } else {
-                filter.addAction(ACTION_TEST_SERVICE_STATE);
-                log("register for intent action=" + ACTION_TEST_SERVICE_STATE);
             }
+
+            filter.addAction(ACTION_TEST_SERVICE_STATE);
+            log("register for intent action=" + ACTION_TEST_SERVICE_STATE);
+
             filter.addAction(ACTION_TEST_CHANGE_NUMBER);
+            log("register for intent action=" + ACTION_TEST_CHANGE_NUMBER);
             phone.getContext().registerReceiver(mIntentReceiver, filter, null, mPhone.getHandler());
         }
     }
@@ -365,9 +370,7 @@
             return;
         }
 
-        // TODO: Fix this with modifing NetworkRegistrationInfo inside ServiceState. Do not call
-        // ServiceState's set methods directly.
-        /*if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_REG_STATE)) {
+        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_REG_STATE)) {
             ss.setVoiceRegState(mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_REG_STATE,
                     ServiceState.STATE_OUT_OF_SERVICE));
             log("Override voice service state with " + ss.getState());
@@ -377,31 +380,85 @@
                     ServiceState.STATE_OUT_OF_SERVICE));
             log("Override data service state with " + ss.getDataRegistrationState());
         }
-        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_RAT)) {
-            ss.setRilVoiceRadioTechnology(mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_RAT,
-                    ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
-            log("Override voice rat with " + ss.getRilVoiceRadioTechnology());
-        }
-        if (mServiceStateTestIntent.hasExtra(EXTRA_DATA_RAT)) {
-            ss.setRilDataRadioTechnology(mServiceStateTestIntent.getIntExtra(EXTRA_DATA_RAT,
-                    ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN));
-            log("Override data rat with " + ss.getRilDataRadioTechnology());
-        }*/
-        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_ROAMING_TYPE)) {
-            ss.setVoiceRoamingType(mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_ROAMING_TYPE,
-                    ServiceState.ROAMING_TYPE_UNKNOWN));
-            log("Override voice roaming type with " + ss.getVoiceRoamingType());
-        }
-        if (mServiceStateTestIntent.hasExtra(EXTRA_DATA_ROAMING_TYPE)) {
-            ss.setDataRoamingType(mServiceStateTestIntent.getIntExtra(EXTRA_DATA_ROAMING_TYPE,
-                    ServiceState.ROAMING_TYPE_UNKNOWN));
-            log("Override data roaming type with " + ss.getDataRoamingType());
-        }
         if (mServiceStateTestIntent.hasExtra(EXTRA_OPERATOR)) {
             String operator = mServiceStateTestIntent.getStringExtra(EXTRA_OPERATOR);
             ss.setOperatorName(operator, operator, "");
             log("Override operator with " + operator);
         }
+        if (mServiceStateTestIntent.hasExtra(EXTRA_NR_FREQUENCY_RANGE)) {
+            ss.setNrFrequencyRange(mServiceStateTestIntent.getIntExtra(EXTRA_NR_FREQUENCY_RANGE,
+                    ServiceState.FREQUENCY_RANGE_UNKNOWN));
+            log("Override NR frequency range with " + ss.getNrFrequencyRange());
+        }
+        if (mServiceStateTestIntent.hasExtra(EXTRA_NR_STATE)) {
+            NetworkRegistrationInfo nri = ss.getNetworkRegistrationInfo(
+                    NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+            if (nri == null) {
+                nri = new NetworkRegistrationInfo.Builder()
+                        .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
+                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
+                        .build();
+            }
+            nri.setNrState(mServiceStateTestIntent.getIntExtra(EXTRA_NR_STATE,
+                    NetworkRegistrationInfo.NR_STATE_NONE));
+            log("Override NR state with " + ss.getNrState());
+        }
+        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_RAT)) {
+            NetworkRegistrationInfo nri = ss.getNetworkRegistrationInfo(
+                    NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+            if (nri == null) {
+                nri = new NetworkRegistrationInfo.Builder()
+                        .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
+                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
+                        .build();
+            }
+            nri.setAccessNetworkTechnology(ServiceState.rilRadioTechnologyToNetworkType(
+                    mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_RAT,
+                    ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)));
+            ss.addNetworkRegistrationInfo(nri);
+            log("Override voice rat with " + ss.getRilVoiceRadioTechnology());
+        }
+        if (mServiceStateTestIntent.hasExtra(EXTRA_DATA_RAT)) {
+            NetworkRegistrationInfo nri = ss.getNetworkRegistrationInfo(
+                    NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+            if (nri == null) {
+                nri = new NetworkRegistrationInfo.Builder()
+                        .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
+                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
+                        .build();
+            }
+            nri.setAccessNetworkTechnology(ServiceState.rilRadioTechnologyToNetworkType(
+                    mServiceStateTestIntent.getIntExtra(EXTRA_DATA_RAT,
+                    ServiceState.RIL_RADIO_TECHNOLOGY_UNKNOWN)));
+            ss.addNetworkRegistrationInfo(nri);
+            log("Override data rat with " + ss.getRilDataRadioTechnology());
+        }
+        if (mServiceStateTestIntent.hasExtra(EXTRA_VOICE_ROAMING_TYPE)) {
+            NetworkRegistrationInfo nri = ss.getNetworkRegistrationInfo(
+                    NetworkRegistrationInfo.DOMAIN_CS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+            if (nri == null) {
+                nri = new NetworkRegistrationInfo.Builder()
+                        .setDomain(NetworkRegistrationInfo.DOMAIN_CS)
+                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
+                        .build();
+            }
+            nri.setRoamingType(mServiceStateTestIntent.getIntExtra(EXTRA_VOICE_ROAMING_TYPE,
+                    ServiceState.ROAMING_TYPE_UNKNOWN));
+            log("Override voice roaming type with " + ss.getVoiceRoamingType());
+        }
+        if (mServiceStateTestIntent.hasExtra(EXTRA_DATA_ROAMING_TYPE)) {
+            NetworkRegistrationInfo nri = ss.getNetworkRegistrationInfo(
+                    NetworkRegistrationInfo.DOMAIN_PS, AccessNetworkConstants.TRANSPORT_TYPE_WWAN);
+            if (nri == null) {
+                nri = new NetworkRegistrationInfo.Builder()
+                        .setDomain(NetworkRegistrationInfo.DOMAIN_PS)
+                        .setTransportType(AccessNetworkConstants.TRANSPORT_TYPE_WWAN)
+                        .build();
+            }
+            nri.setRoamingType(mServiceStateTestIntent.getIntExtra(EXTRA_DATA_ROAMING_TYPE,
+                    ServiceState.ROAMING_TYPE_UNKNOWN));
+            log("Override data roaming type with " + ss.getDataRoamingType());
+        }
     }
 
     void testImsECall() {
diff --git a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
index 3e60612..4877baf 100644
--- a/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
+++ b/src/java/com/android/internal/telephony/cdma/CdmaSMSDispatcher.java
@@ -163,7 +163,7 @@
         //   that the message should fall back to sending over CS.
         if (0 == tracker.mImsRetry && !isIms() || imsSmsDisabled || tracker.mUsesImsServiceForIms) {
             if (tracker.mRetryCount == 0 && tracker.mExpectMore) {
-                mCi.sendCdmaSMSExpectMore(pdu,reply);
+                mCi.sendCdmaSMSExpectMore(pdu, reply);
             } else {
                 mCi.sendCdmaSms(pdu, reply);
             }