Merge "Import translations. DO NOT MERGE" into pi-dev
diff --git a/src/com/android/phone/NotificationMgr.java b/src/com/android/phone/NotificationMgr.java
index 9f4767a..4e69d34 100644
--- a/src/com/android/phone/NotificationMgr.java
+++ b/src/com/android/phone/NotificationMgr.java
@@ -616,24 +616,37 @@
                 PhoneFactory.getPhone(phoneId) : PhoneFactory.getDefaultPhone();
         if (TelephonyCapabilities.supportsNetworkSelection(phone)) {
             if (SubscriptionManager.isValidSubscriptionId(subId)) {
-                // get the shared preference of network_selection.
-                // empty is auto mode, otherwise it is the operator alpha name
-                // in case there is no operator name, check the operator numeric
-                SharedPreferences sp =
-                        PreferenceManager.getDefaultSharedPreferences(mContext);
-                String networkSelection =
-                        sp.getString(Phone.NETWORK_SELECTION_NAME_KEY + subId, "");
-                if (TextUtils.isEmpty(networkSelection)) {
-                    networkSelection =
-                            sp.getString(Phone.NETWORK_SELECTION_KEY + subId, "");
+                // if restoring manual selection is controlled by framework, then get network
+                // selection from shared preference, otherwise get from real network indicators.
+                boolean restoreSelection = !mContext.getResources().getBoolean(
+                        com.android.internal.R.bool.skip_restoring_network_selection);
+                String selectedNetworkOperatorName;
+                boolean isManualSelection;
+                if (restoreSelection) {
+                    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(mContext);
+                    selectedNetworkOperatorName =
+                            sp.getString(Phone.NETWORK_SELECTION_NAME_KEY + subId, "");
+                    // get the shared preference of network_selection.
+                    // empty is auto mode, otherwise it is the operator alpha name
+                    // in case there is no operator name, check the operator numeric
+                    if (TextUtils.isEmpty(selectedNetworkOperatorName)) {
+                        selectedNetworkOperatorName =
+                                sp.getString(Phone.NETWORK_SELECTION_KEY + subId, "");
+                    }
+                    isManualSelection = !TextUtils.isEmpty(selectedNetworkOperatorName);
+                } else {
+                    selectedNetworkOperatorName = phone.getServiceStateTracker().mSS
+                            .getOperatorAlpha();
+                    isManualSelection = phone.getServiceStateTracker().mSS.getIsManualSelection();
                 }
 
-                if (DBG) log("updateNetworkSelection()..." + "state = " +
-                        serviceState + " new network " + networkSelection);
+                if (DBG) {
+                    log("updateNetworkSelection()..." + "state = " + serviceState + " new network "
+                            + (isManualSelection ? selectedNetworkOperatorName : ""));
+                }
 
-                if (serviceState == ServiceState.STATE_OUT_OF_SERVICE
-                        && !TextUtils.isEmpty(networkSelection)) {
-                    showNetworkSelection(networkSelection, subId);
+                if (serviceState == ServiceState.STATE_OUT_OF_SERVICE && isManualSelection) {
+                    showNetworkSelection(selectedNetworkOperatorName, subId);
                     mSelectedUnavailableNotify = true;
                 } else {
                     if (mSelectedUnavailableNotify) {
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 9813ad4..f9aeb7a 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -740,6 +740,9 @@
             return;
         }
 
+        Log.i(this, "Setting RTT stream on ImsPhoneConnection in case we need it later");
+        imsOriginalConnection.setCurrentRttTextStream(request.getRttTextStream());
+
         if (!imsOriginalConnection.isRttEnabledForCall()) {
             if (request.isRequestingRtt()) {
                 Log.w(this, "Incoming call processed as RTT but did not come in as one. Ignoring");
@@ -747,8 +750,7 @@
             return;
         }
 
-        Log.i(this, "Setting RTT stream on ImsPhoneConnection");
-        imsOriginalConnection.setCurrentRttTextStream(request.getRttTextStream());
+        Log.i(this, "Setting the call to be answered with RTT on.");
         imsOriginalConnection.getImsCall().setAnswerWithRtt();
     }