Merge "Update all phones about radio state"
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index 722c2f3..e4f71ba 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -9470,22 +9470,28 @@
     }
 
     /**
-     * Attempts to set the radio power state for thermal reason. This does not guarantee that the
+     * Attempts to set the radio power state for all phones for thermal reason.
+     * This does not guarantee that the
      * requested radio power state will actually be set. See {@link
      * PhoneInternalInterface#setRadioPowerForReason} for more details.
      *
-     * @param subId the subscription ID of the phone requesting to set the radio power state.
      * @param enable {@code true} if trying to turn radio on.
      * @return {@code true} if phone setRadioPowerForReason was called. Otherwise, returns {@code
      * false}.
      */
-    private boolean setRadioPowerForThermal(int subId, boolean enable) {
-        Phone phone = getPhone(subId);
-        if (phone != null) {
-            phone.setRadioPowerForReason(enable, Phone.RADIO_POWER_REASON_THERMAL);
-            return true;
+    private boolean setRadioPowerForThermal(boolean enable) {
+        boolean isPhoneAvailable = false;
+        for (int i = 0; i < TelephonyManager.getDefault().getActiveModemCount(); i++) {
+            Phone phone = PhoneFactory.getPhone(i);
+            if (phone != null) {
+                phone.setRadioPowerForReason(enable, Phone.RADIO_POWER_REASON_THERMAL);
+                isPhoneAvailable = true;
+            }
         }
-        return false;
+
+        // return true if successfully informed the phone object about the thermal radio power
+        // request.
+        return isPhoneAvailable;
     }
 
     private int handleDataThrottlingRequest(int subId,
@@ -9499,7 +9505,7 @@
 
         // Ensure that radio is on. If not able to power on due to phone being unavailable, return
         // THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE.
-        if (!setRadioPowerForThermal(subId, true)) {
+        if (!setRadioPowerForThermal(true)) {
             return TelephonyManager.THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE;
         }
 
@@ -9615,7 +9621,7 @@
 
                     // Ensure that radio is on. If not able to power on due to phone being
                     // unavailable, return THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE.
-                    if (!setRadioPowerForThermal(subId, true)) {
+                    if (!setRadioPowerForThermal(true)) {
                         thermalMitigationResult =
                                 TelephonyManager.THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE;
                         break;
@@ -9660,7 +9666,7 @@
 
                     // Turn radio off. If not able to power off due to phone being unavailable,
                     // return THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE.
-                    if (!setRadioPowerForThermal(subId, false)) {
+                    if (!setRadioPowerForThermal(false)) {
                         thermalMitigationResult =
                                 TelephonyManager.THERMAL_MITIGATION_RESULT_MODEM_NOT_AVAILABLE;
                         break;