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

Commit 6fecc090 authored by Usman Abdullah's avatar Usman Abdullah Committed by Android (Google) Code Review
Browse files

Merge "Add silence support to Call via CallScreeningService"

parents c1ca1e21 f09f98c6
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -389,6 +389,9 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    /** Whether this call is requesting that Telecom play the ringback tone on its behalf. */
    private boolean mRingbackRequested = false;

    /** Whether this call is requesting to be silently ringing. */
    private boolean mSilentRingingRequested = false;

    /** Whether direct-to-voicemail query is pending. */
    private boolean mDirectToVoicemailQueryPending;

@@ -995,6 +998,18 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        return mRingbackRequested;
    }

    public void setSilentRingingRequested(boolean silentRingingRequested) {
        mSilentRingingRequested = silentRingingRequested;
        Bundle bundle = new Bundle();
        bundle.putBoolean(android.telecom.Call.EXTRA_SILENT_RINGING_REQUESTED,
                silentRingingRequested);
        putExtras(SOURCE_CONNECTION_SERVICE, bundle);
    }

    public boolean isSilentRingingRequested() {
        return mSilentRingingRequested;
    }

    @VisibleForTesting
    public boolean isConference() {
        return mIsConference;
+5 −0
Original line number Diff line number Diff line
@@ -64,6 +64,11 @@ public class CallScreeningServiceHelper {
            // no-op; we don't allow this on outgoing calls.
        }

        @Override
        public void silenceCall(String s) throws RemoteException {
            // no-op; we don't allow this on outgoing calls.
        }

        @Override
        public void disallowCall(String s, boolean b, boolean b1, boolean b2,
                ComponentName componentName) throws RemoteException {
+4 −0
Original line number Diff line number Diff line
@@ -663,6 +663,10 @@ public class CallsManager extends Call.ListenerBase
                            "dialing calls.");
                    rejectCallAndLog(incomingCall, result);
                }
            } else if (result.shouldSilence) {
                Log.i(this, "onCallFilteringCompleted: setting the call to silent ringing state");
                incomingCall.setSilentRingingRequested(true);
                addCall(incomingCall);
            } else {
                addCall(incomingCall);
            }
+9 −3
Original line number Diff line number Diff line
@@ -199,6 +199,7 @@ public class Ringer {
        boolean shouldRingForContact = shouldRingForContact(foregroundCall.getContactUri());
        boolean isRingtonePresent = !(mRingtoneFactory.getRingtone(foregroundCall) == null);
        boolean isSelfManaged = foregroundCall.isSelfManaged();
        boolean isSilentRingingRequested = foregroundCall.isSilentRingingRequested();

        boolean isRingerAudible = isVolumeOverZero && shouldRingForContact && isRingtonePresent;
        boolean hasExternalRinger = hasExternalRinger(foregroundCall);
@@ -214,15 +215,20 @@ public class Ringer {
        boolean isTheaterModeOn = mSystemSettingsUtil.isTheaterModeOn(mContext);
        boolean letDialerHandleRinging = mInCallController.doesConnectedDialerSupportRinging();
        boolean endEarly = isTheaterModeOn || letDialerHandleRinging || isSelfManaged ||
                hasExternalRinger;
                hasExternalRinger || isSilentRingingRequested;

        if (endEarly) {
            if (letDialerHandleRinging) {
                Log.addEvent(foregroundCall, LogUtils.Events.SKIP_RINGING, "Dialer handles");
            }
            if (isSilentRingingRequested) {
                Log.addEvent(foregroundCall, LogUtils.Events.SKIP_RINGING, "Silent ringing "
                        + "requested");
            }
            Log.i(this, "Ending early -- isTheaterModeOn=%s, letDialerHandleRinging=%s, " +
                    "isSelfManaged=%s, hasExternalRinger=%s", isTheaterModeOn,
                    letDialerHandleRinging, isSelfManaged, hasExternalRinger);
                            "isSelfManaged=%s, hasExternalRinger=%s, silentRingingRequested=%s",
                    isTheaterModeOn, letDialerHandleRinging, isSelfManaged, hasExternalRinger,
                    isSilentRingingRequested);
            return shouldAcquireAudioFocus;
        }

+31 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.text.TextUtils;
public class CallFilteringResult {
    public boolean shouldAllowCall;
    public boolean shouldReject;
    public boolean shouldSilence;
    public boolean shouldAddToCallLog;
    public boolean shouldShowNotification;
    public int mCallBlockReason = CallLog.Calls.BLOCK_REASON_NOT_BLOCKED;
@@ -33,6 +34,7 @@ public class CallFilteringResult {
            shouldAddToCallLog, boolean shouldShowNotification) {
        this.shouldAllowCall = shouldAllowCall;
        this.shouldReject = shouldReject;
        this.shouldSilence = false;
        this.shouldAddToCallLog = shouldAddToCallLog;
        this.shouldShowNotification = shouldShowNotification;
    }
@@ -42,6 +44,29 @@ public class CallFilteringResult {
            CharSequence callScreeningAppName, String callScreeningComponentName) {
        this.shouldAllowCall = shouldAllowCall;
        this.shouldReject = shouldReject;
        this.shouldSilence = false;
        this.shouldAddToCallLog = shouldAddToCallLog;
        this.shouldShowNotification = shouldShowNotification;
        this.mCallBlockReason = callBlockReason;
        this.mCallScreeningAppName = callScreeningAppName;
        this.mCallScreeningComponentName = callScreeningComponentName;
    }

    public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
            shouldSilence, boolean shouldAddToCallLog, boolean shouldShowNotification) {
        this.shouldAllowCall = shouldAllowCall;
        this.shouldReject = shouldReject;
        this.shouldSilence = shouldSilence;
        this.shouldAddToCallLog = shouldAddToCallLog;
        this.shouldShowNotification = shouldShowNotification;
    }

    public CallFilteringResult(boolean shouldAllowCall, boolean shouldReject, boolean
            shouldSilence, boolean shouldAddToCallLog, boolean shouldShowNotification, int
            callBlockReason, CharSequence callScreeningAppName, String callScreeningComponentName) {
        this.shouldAllowCall = shouldAllowCall;
        this.shouldReject = shouldReject;
        this.shouldSilence = shouldSilence;
        this.shouldAddToCallLog = shouldAddToCallLog;
        this.shouldShowNotification = shouldShowNotification;
        this.mCallBlockReason = callBlockReason;
@@ -87,6 +112,7 @@ public class CallFilteringResult {
        return new CallFilteringResult(
            shouldAllowCall && other.shouldAllowCall,
            shouldReject || other.shouldReject,
            shouldSilence || other.shouldSilence,
            shouldAddToCallLog && other.shouldAddToCallLog,
            shouldShowNotification && other.shouldShowNotification);
    }
@@ -108,6 +134,7 @@ public class CallFilteringResult {
        return new CallFilteringResult(
            shouldAllowCall && other.shouldAllowCall,
            shouldReject || other.shouldReject,
            shouldSilence|| other.shouldSilence,
            shouldAddToCallLog && other.shouldAddToCallLog,
            shouldShowNotification && other.shouldShowNotification,
            callBlockReason,
@@ -125,6 +152,7 @@ public class CallFilteringResult {

        if (shouldAllowCall != that.shouldAllowCall) return false;
        if (shouldReject != that.shouldReject) return false;
        if (shouldSilence != that.shouldSilence) return false;
        if (shouldAddToCallLog != that.shouldAddToCallLog) return false;
        if (shouldShowNotification != that.shouldShowNotification) return false;
        if (mCallBlockReason != that.mCallBlockReason) return false;
@@ -150,6 +178,7 @@ public class CallFilteringResult {
    public int hashCode() {
        int result = (shouldAllowCall ? 1 : 0);
        result = 31 * result + (shouldReject ? 1 : 0);
        result = 31 * result + (shouldSilence ? 1 : 0);
        result = 31 * result + (shouldAddToCallLog ? 1 : 0);
        result = 31 * result + (shouldShowNotification ? 1 : 0);
        return result;
@@ -163,6 +192,8 @@ public class CallFilteringResult {
            sb.append("Allow");
        } else if (shouldReject) {
            sb.append("Reject");
        } else if (shouldSilence) {
            sb.append("Silence");
        } else {
            sb.append("Ignore");
        }
Loading