Return different disconnect reason and error strings
for oem and carrier satellite
Bug: 331222808
Manual Test: b/331222808#comment4
Test: atest TelephonyConnectionServiceTest
Change-Id: Iac091a2e152f0128b1d8e6a97baf9b61053ba572
Merged-In: Iac091a2e152f0128b1d8e6a97baf9b61053ba572
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 61143c9..3c43dad 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1240,7 +1240,9 @@
<!-- In-call screen: call failure message displayed in an error dialog when the user is connected to a wireless network, but wifi calling is turned off. [CHAR_LIMIT=NONE] -->
<string name="incall_error_promote_wfc">Enable Wi-Fi calling to make a call.</string>
<!-- In-call screen: call failure message displayed in an error dialog when the satellite modem is on. [CHAR_LIMIT=NONE] -->
- <string name="incall_error_satellite_enabled">Disable satellite mode to make a call.</string>
+ <string name="incall_error_satellite_enabled">To make a call, first end the satellite connection.</string>
+ <!-- In-call screen: call failure message displayed in an error dialog when device is connected to carrier roaming satellite network [CHAR_LIMIT=NONE] -->
+ <string name="incall_error_carrier_roaming_satellite_mode">You can send and receive messages without a mobile or Wi-Fi network.</string>
<!-- Hint for the button of emergency information -->
<string name="emergency_information_hint">Emergency information</string>
diff --git a/src/com/android/services/telephony/DisconnectCauseUtil.java b/src/com/android/services/telephony/DisconnectCauseUtil.java
index c00adef..55d4a49 100644
--- a/src/com/android/services/telephony/DisconnectCauseUtil.java
+++ b/src/com/android/services/telephony/DisconnectCauseUtil.java
@@ -29,6 +29,7 @@
import com.android.internal.telephony.CallFailCause;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;
+import com.android.internal.telephony.satellite.SatelliteController;
import com.android.phone.ImsUtil;
import com.android.phone.PhoneGlobals;
import com.android.phone.R;
@@ -434,7 +435,7 @@
resourceId = R.string.callFailed_wfc_service_not_available_in_this_location;
break;
case android.telephony.DisconnectCause.SATELLITE_ENABLED:
- resourceId = R.string.incall_error_satellite_enabled;
+ resourceId = getSatelliteErrorString();
break;
default:
break;
@@ -618,7 +619,7 @@
resourceId = R.string.clh_incall_error_out_of_service_txt;
break;
case android.telephony.DisconnectCause.SATELLITE_ENABLED:
- resourceId = R.string.clh_callFailed_satelliteEnabled_txt;
+ resourceId = getSatelliteErrorString();
break;
default:
resourceId = R.string.clh_card_title_call_ended_txt;
@@ -844,7 +845,7 @@
resourceId = R.string.callFailed_wfc_service_not_available_in_this_location;
break;
case android.telephony.DisconnectCause.SATELLITE_ENABLED:
- resourceId = R.string.incall_error_satellite_enabled;
+ resourceId = getSatelliteErrorString();
break;
default:
break;
@@ -888,6 +889,8 @@
return DisconnectCause.REASON_IMS_ACCESS_BLOCKED;
case android.telephony.DisconnectCause.OUTGOING_EMERGENCY_CALL_PLACED:
return DisconnectCause.REASON_EMERGENCY_CALL_PLACED;
+ case android.telephony.DisconnectCause.SATELLITE_ENABLED:
+ return reason;
}
// If no specific code-mapping found, then fall back to using the reason.
@@ -986,4 +989,10 @@
return config;
}
+ private static Integer getSatelliteErrorString() {
+ if (SatelliteController.getInstance().isSatelliteEnabled()) {
+ return R.string.incall_error_satellite_enabled;
+ }
+ return R.string.incall_error_carrier_roaming_satellite_mode;
+ }
}
diff --git a/src/com/android/services/telephony/TelephonyConnectionService.java b/src/com/android/services/telephony/TelephonyConnectionService.java
index 92f7eab..f656d21 100644
--- a/src/com/android/services/telephony/TelephonyConnectionService.java
+++ b/src/com/android/services/telephony/TelephonyConnectionService.java
@@ -148,6 +148,10 @@
private static final Pattern CDMA_ACTIVATION_CODE_REGEX_PATTERN =
Pattern.compile("\\*228[0-9]{0,2}");
+ private static final String DISCONNECT_REASON_SATELLITE_ENABLED = "SATELLITE_ENABLED";
+ private static final String DISCONNECT_REASON_CARRIER_ROAMING_SATELLITE_MODE =
+ "CARRIER_ROAMING_SATELLITE_MODE";
+
private final TelephonyConnectionServiceProxy mTelephonyConnectionServiceProxy =
new TelephonyConnectionServiceProxy() {
@Override
@@ -1244,15 +1248,23 @@
}
if (!isEmergencyNumber) {
- if ((mSatelliteController.isSatelliteEnabled()
- || isCallDisallowedDueToSatellite(phone))
- && (imsPhone == null || !imsPhone.canMakeWifiCall())) {
- Log.d(this, "onCreateOutgoingConnection, cannot make call in satellite mode.");
+ if (mSatelliteController.isSatelliteEnabled()) {
+ Log.d(this, "onCreateOutgoingConnection, cannot make call in "
+ + "satellite mode.");
return Connection.createFailedConnection(
mDisconnectCauseFactory.toTelecomDisconnectCause(
android.telephony.DisconnectCause.SATELLITE_ENABLED,
- "Call failed because satellite modem is enabled."));
+ DISCONNECT_REASON_SATELLITE_ENABLED));
+ } else if (isCallDisallowedDueToSatellite(phone)
+ && (imsPhone == null || !imsPhone.canMakeWifiCall())) {
+ Log.d(this, "onCreateOutgoingConnection, cannot make call "
+ + "when device is connected to carrier roaming satellite network");
+ return Connection.createFailedConnection(
+ mDisconnectCauseFactory.toTelecomDisconnectCause(
+ android.telephony.DisconnectCause.SATELLITE_ENABLED,
+ DISCONNECT_REASON_CARRIER_ROAMING_SATELLITE_MODE));
}
+
final Connection resultConnection = getTelephonyConnection(request, numberToDial,
false, handle, phone);
if (isAdhocConference) {
diff --git a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
index bad3b4e..e87c14d 100644
--- a/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
+++ b/tests/src/com/android/services/telephony/TelephonyConnectionServiceTest.java
@@ -224,6 +224,9 @@
private static final Uri TEST_ADDRESS = Uri.parse("tel:+16505551212");
private static final String TELECOM_CALL_ID1 = "TC1";
private static final String TEST_EMERGENCY_NUMBER = "911";
+ private static final String DISCONNECT_REASON_SATELLITE_ENABLED = "SATELLITE_ENABLED";
+ private static final String DISCONNECT_REASON_CARRIER_ROAMING_SATELLITE_MODE =
+ "CARRIER_ROAMING_SATELLITE_MODE";
private android.telecom.Connection mConnection;
@Mock TelephonyConnectionService.TelephonyManagerProxy mTelephonyManagerProxy;
@@ -3475,6 +3478,7 @@
DisconnectCause disconnectCause = mConnection.getDisconnectCause();
assertEquals(android.telephony.DisconnectCause.SATELLITE_ENABLED,
disconnectCause.getTelephonyDisconnectCause());
+ assertEquals(DISCONNECT_REASON_SATELLITE_ENABLED, disconnectCause.getReason());
}
@Test
@@ -3492,6 +3496,7 @@
DisconnectCause disconnectCause = mConnection.getDisconnectCause();
assertEquals(android.telephony.DisconnectCause.SATELLITE_ENABLED,
disconnectCause.getTelephonyDisconnectCause());
+ assertEquals(DISCONNECT_REASON_CARRIER_ROAMING_SATELLITE_MODE, disconnectCause.getReason());
// Call is supported while using satellite
when(mSatelliteController.getCapabilitiesForCarrierRoamingSatelliteMode(any()))
@@ -3518,6 +3523,7 @@
DisconnectCause disconnectCause = mConnection.getDisconnectCause();
assertEquals(android.telephony.DisconnectCause.SATELLITE_ENABLED,
disconnectCause.getTelephonyDisconnectCause());
+ assertEquals(DISCONNECT_REASON_CARRIER_ROAMING_SATELLITE_MODE, disconnectCause.getReason());
// Call is supported when device is connected to satellite within hysteresis time
setupForCallTest();