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

Commit 1087f6d0 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Pass the TelecomManager#placecall calling package through to TC logs.

Ensure the calling package is logged in the telecom dumpsys when an
outgoing call is placed.  Makes it easier to diagnose when a mysterious
call was placed but we don't know the origin.

Also add notification channel for test app so we can actually see the
notifications it posts.

Test: Ran unit tests for regression checking.
Test: Manual - inspection of logs.
Bug: 119185776
Change-Id: Id348aeeb5f55cc2da06101cc6ab8342a46fc3616
parent 8981d496
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -643,6 +643,10 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
    }

    public void initAnalytics() {
        initAnalytics(null);
    }

    public void initAnalytics(String callingPackage) {
        int analyticsDirection;
        switch (mCallDirection) {
            case CALL_DIRECTION_OUTGOING:
@@ -658,7 +662,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        }
        mAnalytics = Analytics.initiateCallAnalytics(mId, analyticsDirection);
        mAnalytics.setCallIsEmergency(mIsEmergencyCall);
        Log.addEvent(this, LogUtils.Events.CREATED);
        Log.addEvent(this, LogUtils.Events.CREATED, callingPackage);
    }

    public Analytics.CallInfo getAnalytics() {
+10 −7
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ import android.widget.Toast;
public class CallIntentProcessor {
    public interface Adapter {
        void processOutgoingCallIntent(Context context, CallsManager callsManager,
                Intent intent);
                Intent intent, String callingPackage);
        void processIncomingCallIntent(CallsManager callsManager, Intent intent);
        void processUnknownCallIntent(CallsManager callsManager, Intent intent);
    }
@@ -36,8 +36,9 @@ public class CallIntentProcessor {
    public static class AdapterImpl implements Adapter {
        @Override
        public void processOutgoingCallIntent(Context context, CallsManager callsManager,
                Intent intent) {
            CallIntentProcessor.processOutgoingCallIntent(context, callsManager, intent);
                Intent intent, String callingPackage) {
            CallIntentProcessor.processOutgoingCallIntent(context, callsManager, intent,
                    callingPackage);
        }

        @Override
@@ -73,7 +74,7 @@ public class CallIntentProcessor {
        this.mCallsManager = callsManager;
    }

    public void processIntent(Intent intent) {
    public void processIntent(Intent intent, String callingPackage) {
        final boolean isUnknownCall = intent.getBooleanExtra(KEY_IS_UNKNOWN_CALL, false);
        Log.i(this, "onReceive - isUnknownCall: %s", isUnknownCall);

@@ -81,7 +82,7 @@ public class CallIntentProcessor {
        if (isUnknownCall) {
            processUnknownCallIntent(mCallsManager, intent);
        } else {
            processOutgoingCallIntent(mContext, mCallsManager, intent);
            processOutgoingCallIntent(mContext, mCallsManager, intent, callingPackage);
        }
        Trace.endSection();
    }
@@ -91,11 +92,13 @@ public class CallIntentProcessor {
     * Processes CALL, CALL_PRIVILEGED, and CALL_EMERGENCY intents.
     *
     * @param intent Call intent containing data about the handle to call.
     * @param callingPackage The package which initiated the outgoing call (if known).
     */
    static void processOutgoingCallIntent(
            Context context,
            CallsManager callsManager,
            Intent intent) {
            Intent intent,
            String callingPackage) {

        Uri handle = intent.getData();
        String scheme = handle.getScheme();
@@ -145,7 +148,7 @@ public class CallIntentProcessor {
        // Send to CallsManager to ensure the InCallUI gets kicked off before the broadcast returns
        Call call = callsManager
                .startOutgoingCall(handle, phoneAccountHandle, clientExtras, initiatingUser,
                        intent);
                        intent, callingPackage);

        if (call != null) {
            sendNewOutgoingCallIntent(context, call, callsManager, intent);
+8 −6
Original line number Diff line number Diff line
@@ -1164,10 +1164,11 @@ public class CallsManager extends Call.ListenerBase
     * @param extras The optional extras Bundle passed with the intent used for the incoming call.
     * @param initiatingUser {@link UserHandle} of user that place the outgoing call.
     * @param originalIntent
     * @param callingPackage the package name of the app which initiated the outgoing call.
     */
    @VisibleForTesting
    public Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle, Bundle extras,
            UserHandle initiatingUser, Intent originalIntent) {
            UserHandle initiatingUser, Intent originalIntent, String callingPackage) {
        boolean isReusedCall = true;
        Call call = reuseOutgoingCall(handle);

@@ -1193,7 +1194,7 @@ public class CallsManager extends Call.ListenerBase
                    false /* forceAttachToExistingConnection */,
                    false, /* isConference */
                    mClockProxy);
            call.initAnalytics();
            call.initAnalytics(callingPackage);

            // Ensure new calls related to self-managed calls/connections are set as such.  This
            // will be overridden when the actual connection is returned in startCreateConnection,
@@ -3324,7 +3325,7 @@ public class CallsManager extends Call.ListenerBase

    /**
     * Used to confirm creation of an outgoing call which was marked as pending confirmation in
     * {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent)}.
     * {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent, String)}.
     * Called via {@link TelecomBroadcastIntentProcessor} for a call which was confirmed via
     * {@link ConfirmCallDialogActivity}.
     * @param callId The call ID of the call to confirm.
@@ -3349,7 +3350,7 @@ public class CallsManager extends Call.ListenerBase

    /**
     * Used to cancel an outgoing call which was marked as pending confirmation in
     * {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent)}.
     * {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent, String)}.
     * Called via {@link TelecomBroadcastIntentProcessor} for a call which was confirmed via
     * {@link ConfirmCallDialogActivity}.
     * @param callId The call ID of the call to cancel.
@@ -3365,7 +3366,7 @@ public class CallsManager extends Call.ListenerBase
    }

    /**
     * Called from {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent)} when
     * Called from {@link #startOutgoingCall(Uri, PhoneAccountHandle, Bundle, UserHandle, Intent, String)} when
     * a managed call is added while there are ongoing self-managed calls.  Starts
     * {@link ConfirmCallDialogActivity} to prompt the user to see if they wish to place the
     * outgoing call or not.
@@ -3596,7 +3597,8 @@ public class CallsManager extends Call.ListenerBase
        extras.putParcelable(TelecomManager.EXTRA_CALL_AUDIO_STATE,
                mCallAudioManager.getCallAudioState());
        Call handoverToCall = startOutgoingCall(handoverFromCall.getHandle(), handoverToHandle,
                extras, getCurrentUserHandle(), null /* originalIntent */);
                extras, getCurrentUserHandle(), null /* originalIntent */,
                null /* callingPackage */);
        if (handoverToCall == null) {
            handoverFromCall.sendCallEvent(android.telecom.Call.EVENT_HANDOVER_FAILED, null);
            return;
+1 −1
Original line number Diff line number Diff line
@@ -1657,7 +1657,7 @@ public class TelecomServiceImpl {
                    try {
                        Log.i(this, "handleCallIntent: handling call intent");
                        mCallIntentProcessorAdapter.processOutgoingCallIntent(mContext,
                                mCallsManager, intent);
                                mCallsManager, intent, null /* callingPackage */);
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
+5 −3
Original line number Diff line number Diff line
@@ -159,7 +159,7 @@ public class UserCallIntentProcessor {
        // Save the user handle of current user before forwarding the intent to primary user.
        intent.putExtra(CallIntentProcessor.KEY_INITIATING_USER, mUserHandle);

        sendIntentToDestination(intent, isLocalInvocation);
        sendIntentToDestination(intent, isLocalInvocation, callingPackageName);
    }

    private boolean isDefaultOrSystemDialer(String callingPackageName) {
@@ -193,7 +193,8 @@ public class UserCallIntentProcessor {
     * If the caller is local to the Telecom service, we send the intent to Telecom without
     * sending it through TelecomServiceImpl.
     */
    private boolean sendIntentToDestination(Intent intent, boolean isLocalInvocation) {
    private boolean sendIntentToDestination(Intent intent, boolean isLocalInvocation,
            String callingPackage) {
        intent.putExtra(CallIntentProcessor.KEY_IS_INCOMING_CALL, false);
        intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND);
        if (isLocalInvocation) {
@@ -202,7 +203,8 @@ public class UserCallIntentProcessor {
            // TODO: We should not be using an intent here; this whole flows needs cleanup.
            Log.i(this, "sendIntentToDestination: send intent to Telecom directly.");
            synchronized (TelecomSystem.getInstance().getLock()) {
                TelecomSystem.getInstance().getCallIntentProcessor().processIntent(intent);
                TelecomSystem.getInstance().getCallIntentProcessor().processIntent(intent,
                        callingPackage);
            }
        } else {
            // We're calling from the UserCallActivity, so the TelecomSystem is not in the same
Loading