Provide error message when no available account to place a call. am: 5ee82e0a9f am: 3d5716b154
am: 215e11ca76
Change-Id: I88ef742a2b143d1cfdc55d772e342bfb2f0502ff
diff --git a/res/values/strings.xml b/res/values/strings.xml
index de86f01..0644a65 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -249,6 +249,12 @@
<!-- The "decline" button for an incoming call. [CHAR LIMIT=60] -->
<string name="decline_incoming_call">Decline</string>
+ <!-- Error message shown to the user when an outgoing call cannot be placed because there no
+ calling service is present on the device which supports this call type.
+ This is typically encountered when the user tries to dial a SIP/VOIP call, but there are
+ no calling services present which support SIP calling. [CHAR LIMIT=none] -->
+ <string name="cant_call_due_to_no_supported_service">Call cannot be placed because there are no calling accounts which support calls of this type.</string>
+
<!-- Error message shown to the user when an outgoing call cannot be placed due to an ongoing
phone call in a third-party app. For example:
Call cannot be placed due to your Duo call. [CHAR LIMIT=none] -->
diff --git a/src/com/android/server/telecom/CallsManager.java b/src/com/android/server/telecom/CallsManager.java
index 63aa156..5705fdf 100644
--- a/src/com/android/server/telecom/CallsManager.java
+++ b/src/com/android/server/telecom/CallsManager.java
@@ -1432,6 +1432,7 @@
if (accountSuggestions == null || accountSuggestions.isEmpty()) {
Log.i(CallsManager.this, "Aborting call since there are no"
+ " available accounts.");
+ showErrorMessage(R.string.cant_call_due_to_no_supported_service);
return CompletableFuture.completedFuture(null);
}
boolean needsAccountSelection = accountSuggestions.size() > 1
@@ -4553,4 +4554,16 @@
return mCalls.stream().filter(c -> c.isEmergencyCall()
|| c.isNetworkIdentifiedEmergencyCall()).count() > 0;
}
+
+ /**
+ * Trigger display of an error message to the user; we do this outside of dialer for calls which
+ * fail to be created and added to Dialer.
+ * @param messageId The string resource id.
+ */
+ private void showErrorMessage(int messageId) {
+ final Intent errorIntent = new Intent(mContext, ErrorDialogActivity.class);
+ errorIntent.putExtra(ErrorDialogActivity.ERROR_MESSAGE_ID_EXTRA, messageId);
+ errorIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ mContext.startActivityAsUser(errorIntent, UserHandle.CURRENT);
+ }
}