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

Commit 61cdf8f5 authored by Grant Menke's avatar Grant Menke
Browse files

Prevent self managed calls from logging when not indicated by PhoneAccount.

Currently self managed calls are generally not logged to the call log. As part of the call sequencing refactor, a few logCall invocations were added that did not check if the call was self managed before logging it to the call log. This change adds a check before the invocations of logCall.

Test: manual
Bug: 405942024
Flag: com.android.server.telecom.flags.prevent_self_managed_call_logging
Change-Id: Ie215d25c94cd8e1a5635c4d9c4740861a9d2f962
parent 58d58a89
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -9,6 +9,17 @@ flag {
  bug: "327038818"
}

# OWNER=grantmenke TARGET=25Q3
flag {
  name: "prevent_self_managed_call_logging"
  namespace: "telecom"
  description: "Prevent self managed calls from logging to the call log"
  bug: "405942024"
  metadata {
    purpose: PURPOSE_BUGFIX
  }
}

# OWNER=pmadapurmath TARGET=25Q3
flag {
  name: "allow_call_on_same_connection_mgr"
+20 −2
Original line number Diff line number Diff line
@@ -172,6 +172,24 @@ public final class CallLogManager extends CallsManagerListenerBase {
        }
    }

    /**
     * Log call only if Call is NOT a self-managed call OR call is a self-managed call which has
     * indicated it should be logged in its PhoneAccount
     */
    void logCallIfNotSelfManaged (Call call, int type, boolean showNotificationForMissedCall,
            CallFilteringResult result) {
        boolean shouldCallSelfManagedLogged = call.isLoggedSelfManaged() &&
                (call.getHandoverState() == HandoverState.HANDOVER_NONE
                || call.getHandoverState() == HandoverState.HANDOVER_COMPLETE);
        if (!mFeatureFlags.preventSelfManagedCallLogging() || !call.isSelfManaged() ||
                shouldCallSelfManagedLogged) {
            logCall(call, type, showNotificationForMissedCall, result);
        } else {
            Log.d(TAG, "logCallIfNotSelfManaged: skipping call logging due to self managed "
                    + "for call = " + call);
        }
    }

    /**
     * Log newly disconnected calls only if all of below conditions are met:
     * Call was NOT in the "choose account" phase when disconnected
@@ -187,8 +205,8 @@ public final class CallLogManager extends CallsManagerListenerBase {
     */
    @VisibleForTesting
    public boolean shouldLogDisconnectedCall(Call call, int oldState, boolean isCallCanceled) {
        boolean shouldCallSelfManagedLogged = call.isLoggedSelfManaged()
                && (call.getHandoverState() == HandoverState.HANDOVER_NONE
        boolean shouldCallSelfManagedLogged = call.isLoggedSelfManaged() &&
                (call.getHandoverState() == HandoverState.HANDOVER_NONE
                || call.getHandoverState() == HandoverState.HANDOVER_COMPLETE);

        // "Choose account" phase when disconnected
+6 −6
Original line number Diff line number Diff line
@@ -1179,7 +1179,7 @@ public class CallsManager extends Call.ListenerBase
                if (result.shouldShowNotification) {
                    Log.w(this, "onCallScreeningCompleted: blocked call, showing notification.");
                }
                mCallLogManager.logCall(incomingCall, Calls.BLOCKED_TYPE,
                mCallLogManager.logCallIfNotSelfManaged(incomingCall, Calls.BLOCKED_TYPE,
                        result.shouldShowNotification, result);
            }
            if (result.shouldShowNotification) {
@@ -1823,7 +1823,7 @@ public class CallsManager extends Call.ListenerBase
                if (hasMaximumManagedRingingCalls(call)) {
                    call.setMissedReason(AUTO_MISSED_MAXIMUM_RINGING);
                    call.setStartFailCause(CallFailureCause.MAX_RINGING_CALLS);
                    mCallLogManager.logCall(call, Calls.MISSED_TYPE,
                    mCallLogManager.logCallIfNotSelfManaged(call, Calls.MISSED_TYPE,
                            true /*showNotificationForMissedCall*/, null /*CallFilteringResult*/);
                }
                call.setStartFailCause(startFailCause);
@@ -1836,7 +1836,7 @@ public class CallsManager extends Call.ListenerBase
            call.setMissedReason(AUTO_MISSED_EMERGENCY_CALL);
            call.getAnalytics().setMissedReason(call.getMissedReason());
            call.setStartFailCause(CallFailureCause.IN_EMERGENCY_CALL);
            mCallLogManager.logCall(call, Calls.MISSED_TYPE,
            mCallLogManager.logCallIfNotSelfManaged(call, Calls.MISSED_TYPE,
                    true /*showNotificationForMissedCall*/, null /*CallFilteringResult*/);
            if (isConference) {
                notifyCreateConferenceFailed(phoneAccountHandle, call);
@@ -1855,7 +1855,7 @@ public class CallsManager extends Call.ListenerBase
                call.setMissedReason(AUTO_MISSED_MAXIMUM_DIALING);
            }
            call.getAnalytics().setMissedReason(call.getMissedReason());
            mCallLogManager.logCall(call, Calls.MISSED_TYPE,
            mCallLogManager.logCallIfNotSelfManaged(call, Calls.MISSED_TYPE,
                    true /*showNotificationForMissedCall*/, null /*CallFilteringResult*/);
            if (isConference) {
                notifyCreateConferenceFailed(phoneAccountHandle, call);
@@ -4360,7 +4360,7 @@ public class CallsManager extends Call.ListenerBase

        if (oldState == CallState.NEW && disconnectCause.getCode() == DisconnectCause.MISSED) {
            Log.i(this, "markCallAsDisconnected: logging missed call ");
            mCallLogManager.logCall(call, Calls.MISSED_TYPE, true, null);
            mCallLogManager.logCallIfNotSelfManaged(call, Calls.MISSED_TYPE, true, null);
        }
    }

@@ -4879,7 +4879,7 @@ public class CallsManager extends Call.ListenerBase
        // Since the call was not added to the list of calls, we have to call the missed
        // call notifier and the call logger manually.
        // Do we need missed call notification for direct to Voicemail calls?
        mCallLogManager.logCall(incomingCall, Calls.MISSED_TYPE,
        mCallLogManager.logCallIfNotSelfManaged(incomingCall, Calls.MISSED_TYPE,
                true /*showNotificationForMissedCall*/, result);
    }