Merge "Save call forwarding flag in SharedPreference." into mnc-dr-dev
diff --git a/src/java/com/android/internal/telephony/Connection.java b/src/java/com/android/internal/telephony/Connection.java
index e727de5..51dfe60 100644
--- a/src/java/com/android/internal/telephony/Connection.java
+++ b/src/java/com/android/internal/telephony/Connection.java
@@ -129,6 +129,7 @@
     private int mCallSubstate;
     private android.telecom.Connection.VideoProvider mVideoProvider;
     public Call.State mPreHandoverState = Call.State.IDLE;
+    private Bundle mExtras;
 
     /* Instance Methods */
 
@@ -632,12 +633,21 @@
      * @param extras New connection extras.
      */
     public void setConnectionExtras(Bundle extras) {
+        mExtras = extras;
         for (Listener l : mListeners) {
             l.onExtrasChanged(extras);
         }
     }
 
     /**
+     * Retrieves the current connection extras.
+     * @return the connection extras.
+     */
+    public Bundle getConnectionExtras() {
+        return mExtras;
+    }
+
+    /**
      * Sets the call substate for the current connection and reports the changes to all listeners.
      * Valid call substates are defined in {@link android.telecom.Connection}.
      *
diff --git a/src/java/com/android/internal/telephony/dataconnection/DctController.java b/src/java/com/android/internal/telephony/dataconnection/DctController.java
index 165d031..b071e6e 100644
--- a/src/java/com/android/internal/telephony/dataconnection/DctController.java
+++ b/src/java/com/android/internal/telephony/dataconnection/DctController.java
@@ -316,12 +316,15 @@
         logd("requestNetwork request=" + request + ", priority=" + priority);
         l.log("Dctc.requestNetwork, priority=" + priority);
 
-        if (mRequestInfos.containsKey(request.requestId) == false) {
-            RequestInfo requestInfo = new RequestInfo(request, priority, l);
-            mRequestInfos.put(request.requestId, requestInfo);
-            processRequests();
+        if (mRequestInfos.containsKey(request.requestId)) {
+            logd("requestNetwork replacing " + mRequestInfos.get(request.requestId));
+            // NOTE: executedPhoneId might be reset
         }
 
+        RequestInfo requestInfo = new RequestInfo(request, priority, l);
+        mRequestInfos.put(request.requestId, requestInfo);
+        processRequests();
+
         return PhoneConstants.APN_REQUEST_STARTED;
     }
 
@@ -389,7 +392,12 @@
                 + ", activePhoneId=" + activePhoneId);
 
         if (requestedPhoneId == INVALID_PHONE_INDEX) {
-            // we have no network request - don't bother with this
+            // either we have no network request
+            // or there is no valid subscription at the moment
+            if (activePhoneId != INVALID_PHONE_INDEX) {
+                // detatch so we can try connecting later
+                mDcSwitchAsyncChannel[activePhoneId].disconnectAll();
+            }
             return;
         }
 
diff --git a/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java b/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
index 4280c27..8b72a63 100644
--- a/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
+++ b/src/java/com/android/internal/telephony/imsphone/ImsPhoneConnection.java
@@ -165,6 +165,11 @@
 
         updateWifiState();
 
+        // Ensure any extras set on the ImsCallProfile at the start of the call are cached locally
+        // in the ImsPhoneConnection.  This isn't going to inform any listeners (since the original
+        // connection is not likely to be associated with a TelephonyConnection yet).
+        updateExtras(imsCall);
+
         mParent = parent;
         mParent.attach(this,
                 (mIsIncoming? ImsPhoneCall.State.INCOMING: ImsPhoneCall.State.DIALING));