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

Commit 44590f46 authored by Wei Liu's avatar Wei Liu Committed by android-build-merger
Browse files

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

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.
am: 13791b92

Change-Id: I40c72473937af3d9f6121a6bfe4be0bd70c0253d
parents 2747da64 13791b92
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -45,4 +45,9 @@


    <!-- Flag indicating whether audio should be routed to speaker when docked -->
    <!-- Flag indicating whether audio should be routed to speaker when docked -->
    <bool name="use_speaker_when_docked">true</bool>
    <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>
</resources>
+38 −3
Original line number Original line Diff line number Diff line
@@ -386,9 +386,13 @@ public class CallsManager extends Call.ListenerBase


        if (result.shouldAllowCall) {
        if (result.shouldAllowCall) {
            if (hasMaximumRingingCalls()) {
            if (hasMaximumRingingCalls()) {
                Log.i(this, "onCallFilteringCompleted: Call rejected! Exceeds maximum number of " +
                if (shouldSilenceInsteadOfReject(incomingCall)) {
                        "ringing calls.");
                    incomingCall.silence();
                } else {
                    Log.i(this, "onCallFilteringCompleted: Call rejected! " +
                            "Exceeds maximum number of ringing calls.");
                    rejectCallAndLog(incomingCall);
                    rejectCallAndLog(incomingCall);
                }
            } else if (hasMaximumDialingCalls()) {
            } else if (hasMaximumDialingCalls()) {
                Log.i(this, "onCallFilteringCompleted: Call rejected! Exceeds maximum number of " +
                Log.i(this, "onCallFilteringCompleted: Call rejected! Exceeds maximum number of " +
                        "dialing calls.");
                        "dialing calls.");
@@ -416,6 +420,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
    @Override
    public void onFailedIncomingCall(Call call) {
    public void onFailedIncomingCall(Call call) {
        setCallState(call, CallState.DISCONNECTED, "failed incoming call");
        setCallState(call, CallState.DISCONNECTED, "failed incoming call");