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

Commit 765f9fe6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Implement call filters part of the missed call information."

parents ed42afc9 4c270f84
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.
@@ -3906,6 +3918,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mMissedReason = missedReason;
    }

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

    public long getStartRingTime() {
        return mStartRingTime;
    }
@@ -3913,4 +3929,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;
@@ -356,7 +357,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;
@@ -488,7 +488,6 @@ public class CallsManager extends Call.ListenerBase
            CallAudioModeStateMachine.Factory callAudioModeStateMachineFactory,
            InCallControllerFactory inCallControllerFactory,
            RoleManagerAdapter roleManagerAdapter,
            IncomingCallFilter.Factory incomingCallFilterFactory,
            ToastFactory toastFactory) {
        mContext = context;
        mLock = lock;
@@ -506,7 +505,6 @@ public class CallsManager extends Call.ListenerBase
        mTimeoutsAdapter = timeoutsAdapter;
        mEmergencyCallHelper = emergencyCallHelper;
        mCallerInfoLookupHelper = callerInfoLookupHelper;
        mIncomingCallFilterFactory = incomingCallFilterFactory;

        mDtmfLocalTonePlayer =
                new DtmfLocalTonePlayer(new DtmfLocalTonePlayer.ToneGeneratorProxy());
@@ -673,7 +671,7 @@ public class CallsManager extends Call.ListenerBase
                    .setShouldReject(false)
                    .setShouldAddToCallLog(true)
                    .setShouldShowNotification(true)
                    .build());
                    .build(), false);
            incomingCall.setIsUsingCallFiltering(false);
            return;
        }
@@ -739,13 +737,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,
@@ -759,6 +763,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();
@@ -767,6 +772,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)) {
@@ -776,6 +782,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");
@@ -784,6 +791,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);
@@ -1353,6 +1363,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) {
@@ -3017,7 +3028,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) {
@@ -3487,7 +3499,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);

@@ -3599,10 +3611,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");
@@ -4759,7 +4775,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;
@@ -202,7 +201,6 @@ public class TelecomSystem {
            CallAudioModeStateMachine.Factory callAudioModeStateMachineFactory,
            ClockProxy clockProxy,
            RoleManagerAdapter roleManagerAdapter,
            IncomingCallFilter.Factory incomingCallFilterFactory,
            ContactsAsyncHelper.Factory contactsAsyncHelperFactory,
            DeviceIdleControllerAdapter deviceIdleControllerAdapter) {
        mContext = context.getApplicationContext();
@@ -306,7 +304,6 @@ public class TelecomSystem {
                callAudioModeStateMachineFactory,
                inCallControllerFactory,
                roleManagerAdapter,
                incomingCallFilterFactory,
                toastFactory);

        mIncomingCallNotifier = incomingCallNotifier;
Loading