Merge "Don't disable radio from thermal if in emergency call only."
diff --git a/src/com/android/phone/PhoneInterfaceManager.java b/src/com/android/phone/PhoneInterfaceManager.java
index d7cdbc2..b03d6f3 100755
--- a/src/com/android/phone/PhoneInterfaceManager.java
+++ b/src/com/android/phone/PhoneInterfaceManager.java
@@ -9519,6 +9519,24 @@
return sThermalMitigationAllowlistedPackages;
}
+ private boolean isAnyPhoneInEmergencyState() {
+ TelecomManager tm = mApp.getSystemService(TelecomManager.class);
+ if (tm.isInEmergencyCall()) {
+ Log.e(LOG_TAG , "Phone state is not valid. One of the phones is in an emergency call");
+ return true;
+ }
+ for (Phone phone : PhoneFactory.getPhones()) {
+ if (phone.isInEmergencySmsMode() || phone.isInEcm()) {
+ Log.e(LOG_TAG, "Phone state is not valid. isInEmergencySmsMode = "
+ + phone.isInEmergencySmsMode() + " isInEmergencyCallbackMode = "
+ + phone.isInEcm());
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Used by shell commands to add an authorized package name for thermal mitigation.
* @param packageName name of package to be allowlisted
@@ -9601,8 +9619,6 @@
TelecomAccountRegistry registry = TelecomAccountRegistry.getInstance(null);
if (registry != null) {
- TelephonyConnectionService service =
- registry.getTelephonyConnectionService();
Phone phone = getPhone(subId);
if (phone == null) {
thermalMitigationResult =
@@ -9610,19 +9626,20 @@
break;
}
- if (PhoneConstantConversions.convertCallState(phone.getState())
- != TelephonyManager.CALL_STATE_IDLE
- || phone.isInEmergencySmsMode() || phone.isInEcm()
- || (service != null && service.isEmergencyCallPending())) {
- String errorMessage = "Phone state is not valid. call state = "
- + PhoneConstantConversions.convertCallState(phone.getState())
- + " isInEmergencySmsMode = " + phone.isInEmergencySmsMode()
- + " isInEmergencyCallbackMode = " + phone.isInEcm();
- errorMessage += service == null
- ? " TelephonyConnectionService is null"
- : " isEmergencyCallPending = "
- + service.isEmergencyCallPending();
- Log.e(LOG_TAG, errorMessage);
+ TelephonyConnectionService service =
+ registry.getTelephonyConnectionService();
+ if (service == null) {
+ Log.e(LOG_TAG, "TelephonyConnectionService is null");
+ thermalMitigationResult =
+ TelephonyManager.THERMAL_MITIGATION_RESULT_INVALID_STATE;
+ break;
+
+ } else if (service.isEmergencyCallPending()) {
+ Log.e(LOG_TAG, "An emergency call is pending");
+ thermalMitigationResult =
+ TelephonyManager.THERMAL_MITIGATION_RESULT_INVALID_STATE;
+ break;
+ } else if (isAnyPhoneInEmergencyState()) {
thermalMitigationResult =
TelephonyManager.THERMAL_MITIGATION_RESULT_INVALID_STATE;
break;