Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ee82e0a authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Provide error message when no available account to place a call.

When there is no available phone account to place a call, ensure call
generates an appropriate error message.

Test: Manual
Bug: 120441065
Change-Id: Id46ef60d808ebab03fcf01c27ff871e518a58f99
parent 53ab7297
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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] -->
+13 −0
Original line number Diff line number Diff line
@@ -1417,6 +1417,7 @@ public class CallsManager extends Call.ListenerBase
                            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
@@ -4469,4 +4470,16 @@ public class CallsManager extends Call.ListenerBase
        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);
    }
}