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

Commit 4c270f84 authored by Grace Jia's avatar Grace Jia
Browse files

Implement call filters part of the missed call information.

Delete deprecated call filters.

Test: TelecomUnitTest
Bug: 144452099
Change-Id: Icec527490e01bc9b1470b22cb47be6e4405121f8
parent d4c58092
Loading
Loading
Loading
Loading
+14 −12
Original line number Diff line number Diff line
@@ -548,6 +548,7 @@ public class Analytics {
        private String getInCallServicesString() {
            StringBuilder s = new StringBuilder();
            s.append("[\n");
            if (inCallServiceInfos != null) {
                for (TelecomLogClass.InCallServiceInfo service : inCallServiceInfos) {
                    s.append("    ");
                    s.append("name: ");
@@ -560,6 +561,7 @@ public class Analytics {
                    s.append(service.getBoundDurationMillis());
                    s.append("\n");
                }
            }
            s.append("]");
            return s.toString();
        }
@@ -631,7 +633,7 @@ public class Analytics {
    }

    public static CallInfo initiateCallAnalytics(String callId, int direction) {
        Log.d(TAG, "Starting analytics for call " + callId);
        Log.i(TAG, "Starting analytics for call " + callId);
        CallInfoImpl callInfo = new CallInfoImpl(callId, direction);
        synchronized (sLock) {
            while (sActiveCallIds.size() >= MAX_NUM_CALLS_TO_STORE) {
+32 −0
Original line number Diff line number Diff line
@@ -623,6 +623,18 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
     */
    private long mStartRingTime;

    /**
     * The package name of the call screening service that silence this call. If the call is not
     * silenced, this field will be null.
     */
    private CharSequence mCallScreeningAppName;

    /**
     * The component name of the call screening service that silence this call. If the call is not
     * silenced, this field will be null.
     */
    private String mCallScreeningComponentName;

    /**
     * Persists the specified parameters and initializes the new instance.
     * @param context The context.
@@ -3894,6 +3906,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mMissedReason = missedReason;
    }

    public void setUserMissed(long code) {
        mMissedReason |= code;
    }

    public long getStartRingTime() {
        return mStartRingTime;
    }
@@ -3901,4 +3917,20 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    public void setStartRingTime(long startRingTime) {
        mStartRingTime = startRingTime;
    }

    public CharSequence getCallScreeningAppName() {
        return mCallScreeningAppName;
    }

    public void setCallScreeningAppName(CharSequence callScreeningAppName) {
        mCallScreeningAppName = callScreeningAppName;
    }

    public String getCallScreeningComponentName() {
        return mCallScreeningComponentName;
    }

    public void setCallScreeningComponentName(String callScreeningComponentName) {
        mCallScreeningComponentName = callScreeningComponentName;
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -358,8 +358,10 @@ public final class CallLogManager extends CallsManagerListenerBase {
                call.wasVolte());

        if (result == null) {
            // Call auto missed before filtered
            result = new CallFilteringResult.Builder().build();
            result = new CallFilteringResult.Builder()
                    .setCallScreeningAppName(call.getCallScreeningAppName())
                    .setCallScreeningComponentName(call.getCallScreeningComponentName())
                    .build();
        }

        if (callLogType == Calls.BLOCKED_TYPE || callLogType == Calls.MISSED_TYPE) {
+28 −13
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import static android.telecom.TelecomManager.VERY_SHORT_CALL_TIME_MS;
import static android.provider.CallLog.Calls.AUTO_MISSED_EMERGENCY_CALL;
import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_DIALING;
import static android.provider.CallLog.Calls.AUTO_MISSED_MAXIMUM_RINGING;
import static android.provider.CallLog.Calls.USER_MISSED_CALL_FILTERS_TIMEOUT;
import static android.provider.CallLog.Calls.USER_MISSED_CALL_SCREENING_SERVICE_SILENCED;

import android.Manifest;
import android.annotation.NonNull;
@@ -106,7 +108,6 @@ import com.android.server.telecom.callfiltering.CallFilteringResult;
import com.android.server.telecom.callfiltering.CallFilteringResult.Builder;
import com.android.server.telecom.callfiltering.CallScreeningServiceFilter;
import com.android.server.telecom.callfiltering.DirectToVoicemailFilter;
import com.android.server.telecom.callfiltering.IncomingCallFilter;
import com.android.server.telecom.callfiltering.IncomingCallFilterGraph;
import com.android.server.telecom.callredirection.CallRedirectionProcessor;
import com.android.server.telecom.components.ErrorDialogActivity;
@@ -355,7 +356,6 @@ public class CallsManager extends Call.ListenerBase
    private final DisconnectedCallNotifier mDisconnectedCallNotifier;
    private IncomingCallNotifier mIncomingCallNotifier;
    private final CallerInfoLookupHelper mCallerInfoLookupHelper;
    private final IncomingCallFilter.Factory mIncomingCallFilterFactory;
    private final DefaultDialerCache mDefaultDialerCache;
    private final Timeouts.Adapter mTimeoutsAdapter;
    private final PhoneNumberUtilsAdapter mPhoneNumberUtilsAdapter;
@@ -487,7 +487,6 @@ public class CallsManager extends Call.ListenerBase
            CallAudioModeStateMachine.Factory callAudioModeStateMachineFactory,
            InCallControllerFactory inCallControllerFactory,
            RoleManagerAdapter roleManagerAdapter,
            IncomingCallFilter.Factory incomingCallFilterFactory,
            ToastFactory toastFactory) {
        mContext = context;
        mLock = lock;
@@ -505,7 +504,6 @@ public class CallsManager extends Call.ListenerBase
        mTimeoutsAdapter = timeoutsAdapter;
        mEmergencyCallHelper = emergencyCallHelper;
        mCallerInfoLookupHelper = callerInfoLookupHelper;
        mIncomingCallFilterFactory = incomingCallFilterFactory;

        mDtmfLocalTonePlayer =
                new DtmfLocalTonePlayer(new DtmfLocalTonePlayer.ToneGeneratorProxy());
@@ -672,7 +670,7 @@ public class CallsManager extends Call.ListenerBase
                    .setShouldReject(false)
                    .setShouldAddToCallLog(true)
                    .setShouldShowNotification(true)
                    .build());
                    .build(), false);
            incomingCall.setIsUsingCallFiltering(false);
            return;
        }
@@ -738,13 +736,19 @@ public class CallsManager extends Call.ListenerBase
    }

    @Override
    public void onCallFilteringComplete(Call incomingCall, CallFilteringResult result) {
    public void onCallFilteringComplete(Call incomingCall, CallFilteringResult result,
            boolean timeout) {
        // Only set the incoming call as ringing if it isn't already disconnected. It is possible
        // that the connection service disconnected the call before it was even added to Telecom, in
        // which case it makes no sense to set it back to a ringing state.
        Log.i(this, "onCallFilteringComplete");
        mGraphHandlerThreads.clear();

        if (timeout) {
            Log.i(this, "onCallFilteringCompleted: Call filters timeout!");
            incomingCall.setUserMissed(USER_MISSED_CALL_FILTERS_TIMEOUT);
        }

        if (incomingCall.getState() != CallState.DISCONNECTED &&
                incomingCall.getState() != CallState.DISCONNECTING) {
            setCallState(incomingCall, CallState.RINGING,
@@ -758,6 +762,7 @@ public class CallsManager extends Call.ListenerBase
            incomingCall.setPostCallPackageName(
                    getRoleManagerAdapter().getDefaultCallScreeningApp());

            Log.i(this, "onCallFilteringComplete: allow call.");
            if (hasMaximumManagedRingingCalls(incomingCall)) {
                if (shouldSilenceInsteadOfReject(incomingCall)) {
                    incomingCall.silence();
@@ -766,6 +771,7 @@ public class CallsManager extends Call.ListenerBase
                            "Exceeds maximum number of ringing calls.");
                    incomingCall.setMissedReason(AUTO_MISSED_MAXIMUM_RINGING);
                    autoMissCallAndLog(incomingCall, result);
                    return;
                }
            } else if (hasMaximumManagedDialingCalls(incomingCall)) {
                if (shouldSilenceInsteadOfReject(incomingCall)) {
@@ -775,6 +781,7 @@ public class CallsManager extends Call.ListenerBase
                            "dialing calls.");
                    incomingCall.setMissedReason(AUTO_MISSED_MAXIMUM_DIALING);
                    autoMissCallAndLog(incomingCall, result);
                    return;
                }
            } else if (result.shouldScreenViaAudio) {
                Log.i(this, "onCallFilteringCompleted: starting background audio processing");
@@ -783,6 +790,9 @@ public class CallsManager extends Call.ListenerBase
            } else if (result.shouldSilence) {
                Log.i(this, "onCallFilteringCompleted: setting the call to silent ringing state");
                incomingCall.setSilentRingingRequested(true);
                incomingCall.setUserMissed(USER_MISSED_CALL_SCREENING_SERVICE_SILENCED);
                incomingCall.setCallScreeningAppName(result.mCallScreeningAppName);
                incomingCall.setCallScreeningComponentName(result.mCallScreeningComponentName);
                addCall(incomingCall);
            } else {
                addCall(incomingCall);
@@ -1340,6 +1350,7 @@ public class CallsManager extends Call.ListenerBase
            // call UI during an emergency call. In this case, log the call as missed instead of
            // rejected since the user did not explicitly reject.
            call.setMissedReason(AUTO_MISSED_EMERGENCY_CALL);
            call.getAnalytics().setMissedReason(call.getMissedReason());
            mCallLogManager.logCall(call, Calls.MISSED_TYPE,
                    true /*showNotificationForMissedCall*/, null /*CallFilteringResult*/);
            if (isConference) {
@@ -3004,7 +3015,8 @@ public class CallsManager extends Call.ListenerBase
     *
     * @param disconnectCause The disconnect cause, see {@link android.telecom.DisconnectCause}.
     */
    void markCallAsDisconnected(Call call, DisconnectCause disconnectCause) {
    @VisibleForTesting
    public void markCallAsDisconnected(Call call, DisconnectCause disconnectCause) {
        int oldState = call.getState();
        if (call.getState() == CallState.SIMULATED_RINGING
                && disconnectCause.getCode() == DisconnectCause.REMOTE) {
@@ -3474,7 +3486,7 @@ public class CallsManager extends Call.ListenerBase
    @VisibleForTesting
    public void addCall(Call call) {
        Trace.beginSection("addCall");
        Log.v(this, "addCall(%s)", call);
        Log.i(this, "addCall(%s)", call);
        call.addListener(this);
        mCalls.add(call);

@@ -3586,10 +3598,14 @@ public class CallsManager extends Call.ListenerBase
                        (newState == CallState.DISCONNECTED)) {
                    maybeSendPostCallScreenIntent(call);
                }
                if (((newState == CallState.ABORTED) || (newState == CallState.DISCONNECTED))
                        && (call.getDisconnectCause().getCode() != DisconnectCause.MISSED)) {
                int disconnectCode = call.getDisconnectCause().getCode();
                if ((newState == CallState.ABORTED || newState == CallState.DISCONNECTED)
                        && ((disconnectCode != DisconnectCause.MISSED)
                        && (disconnectCode != DisconnectCause.CANCELED))) {
                    call.setMissedReason(MISSED_REASON_NOT_MISSED);
                }
                call.getAnalytics().setMissedReason(call.getMissedReason());

                maybeShowErrorDialogOnDisconnect(call);

                Trace.beginSection("onCallStateChanged");
@@ -4746,7 +4762,6 @@ public class CallsManager extends Call.ListenerBase
     * @param call The {@link Call} which could not be added.
     */
    private void notifyCreateConnectionFailed(PhoneAccountHandle phoneAccountHandle, Call call) {
        call.getAnalytics().setMissedReason(call.getMissedReason());
        if (phoneAccountHandle == null) {
            return;
        }
+0 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.server.telecom.bluetooth.BluetoothDeviceManager;
import com.android.server.telecom.bluetooth.BluetoothRouteManager;
import com.android.server.telecom.bluetooth.BluetoothStateReceiver;
import com.android.server.telecom.callfiltering.IncomingCallFilter;
import com.android.server.telecom.components.UserCallIntentProcessor;
import com.android.server.telecom.components.UserCallIntentProcessorFactory;
import com.android.server.telecom.ui.AudioProcessingNotification;
@@ -206,7 +205,6 @@ public class TelecomSystem {
            CallAudioModeStateMachine.Factory callAudioModeStateMachineFactory,
            ClockProxy clockProxy,
            RoleManagerAdapter roleManagerAdapter,
            IncomingCallFilter.Factory incomingCallFilterFactory,
            ContactsAsyncHelper.Factory contactsAsyncHelperFactory,
            DeviceIdleControllerAdapter deviceIdleControllerAdapter) {
        mContext = context.getApplicationContext();
@@ -310,7 +308,6 @@ public class TelecomSystem {
                callAudioModeStateMachineFactory,
                inCallControllerFactory,
                roleManagerAdapter,
                incomingCallFilterFactory,
                toastFactory);

        mIncomingCallNotifier = incomingCallNotifier;
Loading