Allow test emergency call to remove all radio off reasons.
Bug: 189365436
Test: register a test emergency number with
https://sites.google.com/a/google.com/android-telecom/testing/test-emergency-call,
emulate radio off thermal mitigation with
https://docs.google.com/document/d/1mRsIPGdb-zajRhCJm5N1jEKtwZ0yMcQzVST4p0Afj7c/edit?resourcekey=0-AtIFNnN8wNLBkrBYkkWbgg#,
place test emergency call, observe call actually being placed.
Change-Id: Id050c4308919550922388069f9b7cb99e9b94993
Merged-In: Id050c4308919550922388069f9b7cb99e9b94993
diff --git a/src/com/android/services/telephony/RadioOnHelper.java b/src/com/android/services/telephony/RadioOnHelper.java
index 25ac220..be2ddb2 100644
--- a/src/com/android/services/telephony/RadioOnHelper.java
+++ b/src/com/android/services/telephony/RadioOnHelper.java
@@ -78,7 +78,7 @@
* serialized, and runs on the main looper.)
*/
public void triggerRadioOnAndListen(RadioOnStateListener.Callback callback,
- boolean forEmergencyCall, Phone phoneForEmergencyCall) {
+ boolean forEmergencyCall, Phone phoneForEmergencyCall, boolean isTestEmergencyNumber) {
setupListeners();
mCallback = callback;
mInProgressListeners.clear();
@@ -90,17 +90,17 @@
}
mInProgressListeners.add(mListeners.get(i));
- mListeners.get(i).waitForRadioOn(phone, this, forEmergencyCall,
- forEmergencyCall && phone == phoneForEmergencyCall);
+ mListeners.get(i).waitForRadioOn(phone, this, forEmergencyCall, forEmergencyCall
+ && phone == phoneForEmergencyCall);
}
-
- powerOnRadio(forEmergencyCall, phoneForEmergencyCall);
+ powerOnRadio(forEmergencyCall, phoneForEmergencyCall, isTestEmergencyNumber);
}
/**
* Attempt to power on the radio (i.e. take the device out of airplane mode). We'll eventually
* get an onServiceStateChanged() callback when the radio successfully comes up.
*/
- private void powerOnRadio(boolean forEmergencyCall, Phone phoneForEmergencyCall) {
+ private void powerOnRadio(boolean forEmergencyCall, Phone phoneForEmergencyCall,
+ boolean isTestEmergencyNumber) {
// If airplane mode is on, we turn it off the same way that the Settings activity turns it
// off.
@@ -114,7 +114,12 @@
for (Phone phone : PhoneFactory.getPhones()) {
Log.d(this, "powerOnRadio, enabling Radio");
- phone.setRadioPower(true, forEmergencyCall, phone == phoneForEmergencyCall, false);
+ if (isTestEmergencyNumber) {
+ phone.setRadioPowerOnForTestEmergencyCall(phone == phoneForEmergencyCall);
+ } else {
+ phone.setRadioPower(true, forEmergencyCall, phone == phoneForEmergencyCall,
+ false);
+ }
}
// Post the broadcast intend for change in airplane mode
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 581a23a..d2b0c50 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -842,7 +842,7 @@
|| serviceState == ServiceState.STATE_IN_SERVICE;
}
}
- }, isEmergencyNumber && !isTestEmergencyNumber, phone);
+ }, isEmergencyNumber && !isTestEmergencyNumber, phone, isTestEmergencyNumber);
// Return the still unconnected GsmConnection and wait for the Radios to boot before
// connecting it to the underlying Phone.
return resultConnection;
diff --git a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
index 07fe6a8..b761959 100644
--- a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
@@ -964,7 +964,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback =
ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
- eq(testPhone));
+ eq(testPhone), eq(false));
assertFalse(callback.getValue().isOkToCall(testPhone, ServiceState.STATE_OUT_OF_SERVICE));
when(mSST.isRadioOn()).thenReturn(true);
@@ -990,7 +990,7 @@
ArgumentCaptor<RadioOnStateListener.Callback> callback =
ArgumentCaptor.forClass(RadioOnStateListener.Callback.class);
verify(mRadioOnHelper).triggerRadioOnAndListen(callback.capture(), eq(true),
- eq(testPhone));
+ eq(testPhone), eq(false));
assertFalse(callback.getValue().isOkToCall(testPhone, ServiceState.STATE_OUT_OF_SERVICE));
when(mSST.isRadioOn()).thenReturn(true);