Merge "Check to ensure an ImsService can handle an IMS request" into sc-dev
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 47d571e..2077530 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1195,6 +1195,8 @@
     <string name="incall_error_power_off" product="default">Turn off airplane mode to make a call.</string>
     <!-- In-call screen: call failure message displayed in an error dialog when in airplane mode, WFC is enabled, not wifi-only, and not connected to wireless networks. [CHAR_LIMIT=NONE] -->
     <string name="incall_error_power_off_wfc">Turn off airplane mode or connect to a wireless network to make a call.</string>
+    <!-- In-call screen: call failure message displayed in an error dialog when radio off due to thermal mitigation. [CHAR_LIMIT=NONE] -->
+    <string name="incall_error_power_off_thermal" product="default"><b>Phone too hot</b>\n\nCan\'t complete this call. Try again when your phone cools down.\n\nYou can still make emergency calls.</string>
     <!-- In-call screen: call failure message displayed when the user attempts to make a non-emergency call while the phone is in emergency callback mode. -->
     <string name="incall_error_ecm_emergency_only">Exit emergency callback mode to make a non-emergency call.</string>
     <!-- In-call screen: call failure message displayed in an error dialog.
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index f9742b4..9c89e9e 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -658,12 +658,14 @@
                 break;
 
             case android.telephony.DisconnectCause.POWER_OFF:
-                // Radio is explictly powered off because the device is in airplane mode.
+                // Radio is explicitly powered off because the device's radio is off.
 
                 // TODO: Offer the option to turn the radio on, and automatically retry the call
                 // once network registration is complete.
 
-                if (ImsUtil.shouldPromoteWfc(context, phoneId)) {
+                if (isRadioOffForThermalMitigation(phoneId)) {
+                    resourceId = R.string.incall_error_power_off_thermal;
+                } else if (ImsUtil.shouldPromoteWfc(context, phoneId)) {
                     resourceId = R.string.incall_error_promote_wfc;
                 } else if (ImsUtil.isWfcModeWifiOnly(context, phoneId)) {
                     resourceId = R.string.incall_error_wfc_only_no_wireless_network;
@@ -785,7 +787,12 @@
             default:
                 break;
         }
-        return resourceId == null ? "" : context.getResources().getString(resourceId);
+        return resourceId == null ? "" : context.getResources().getText(resourceId);
+    }
+
+    private static boolean isRadioOffForThermalMitigation(int phoneId) {
+        Phone phone = PhoneFactory.getPhone(phoneId);
+        return phone.isRadioOffForThermalMitigation();
     }
 
     /**