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

Commit 13791b92 authored by Wei Liu's avatar Wei Liu
Browse files

Allow (silence rather than reject) the incoming call if it has a

 different source (connection service) from the existing ringing call
 when reaching maximum ringing calls.

b/31911886

Change-Id: If01a31763c16d8835583c70cb9f297c0c189a80e
parent db47c5db
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -45,4 +45,9 @@

    <!-- Flag indicating whether audio should be routed to speaker when docked -->
    <bool name="use_speaker_when_docked">true</bool>

    <!-- Flag indicating whether allow (silence rather than reject) the incoming call if it has a
         different source (connection service) from the existing ringing call when reaching
         maximum ringing calls. -->
    <bool name="silence_incoming_when_different_service_and_maximum_ringing">false</bool>
</resources>
+38 −3
Original line number Diff line number Diff line
@@ -386,9 +386,13 @@ public class CallsManager extends Call.ListenerBase

        if (result.shouldAllowCall) {
            if (hasMaximumRingingCalls()) {
                Log.i(this, "onCallFilteringCompleted: Call rejected! Exceeds maximum number of " +
                        "ringing calls.");
                if (shouldSilenceInsteadOfReject(incomingCall)) {
                    incomingCall.silence();
                } else {
                    Log.i(this, "onCallFilteringCompleted: Call rejected! " +
                            "Exceeds maximum number of ringing calls.");
                    rejectCallAndLog(incomingCall);
                }
            } else if (hasMaximumDialingCalls()) {
                Log.i(this, "onCallFilteringCompleted: Call rejected! Exceeds maximum number of " +
                        "dialing calls.");
@@ -415,6 +419,37 @@ public class CallsManager extends Call.ListenerBase
        }
    }

    /**
     * Whether allow (silence rather than reject) the incoming call if it has a different source
     * (connection service) from the existing ringing call when reaching maximum ringing calls.
     */
    private boolean shouldSilenceInsteadOfReject(Call incomingCall) {
        if (!mContext.getResources().getBoolean(
                R.bool.silence_incoming_when_different_service_and_maximum_ringing)) {
            return false;
        }

        Call ringingCall = null;

        for (Call call : mCalls) {
            // Only operate on top-level calls
            if (call.getParentCall() != null) {
                continue;
            }

            if (call.isExternalCall()) {
                continue;
            }

            if (CallState.RINGING == call.getState() &&
                    call.getConnectionService() == incomingCall.getConnectionService()) {
                return false;
            }
        }

        return true;
    }

    @Override
    public void onFailedIncomingCall(Call call) {
        setCallState(call, CallState.DISCONNECTED, "failed incoming call");