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

Commit 934d29b8 authored by Stephen Bird's avatar Stephen Bird
Browse files

[2/4] Pass call extras to addcall

We use the bundle to write the origin that the application can pass us.
This data will be used to determine which parts of the application/os
are used to make calls most often.

Ticket: CD-517
Change-Id: I884ed6ce8f13610fe8ab24b9c389c9521f1a1588
parent 1db1b223
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
package com.android.server.telecom;

import com.android.internal.telephony.PhoneConstants;
import com.android.internal.telephony.TelephonyProperties;
import com.android.server.telecom.components.ErrorDialogActivity;

@@ -71,6 +72,7 @@ public class CallIntentProcessor {
        String scheme = handle.getScheme();
        String uriString = handle.getSchemeSpecificPart();
        Bundle clientExtras = null;
        String origin = null;

        if (clientExtras == null) {
            clientExtras = new Bundle();
@@ -96,6 +98,9 @@ public class CallIntentProcessor {
        if (intent.hasExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS)) {
            clientExtras = intent.getBundleExtra(TelecomManager.EXTRA_OUTGOING_CALL_EXTRAS);
        }
        if (intent.hasExtra(PhoneConstants.EXTRA_CALL_ORIGIN)) {
            origin = intent.getStringExtra(PhoneConstants.EXTRA_CALL_ORIGIN);
        }
        boolean isConferenceUri = intent.getBooleanExtra(
                TelephonyProperties.EXTRA_DIAL_CONFERENCE_URI, false);
        Log.d(CallIntentProcessor.class, "isConferenceUri = "+isConferenceUri);
@@ -139,7 +144,8 @@ public class CallIntentProcessor {
        final boolean isPrivilegedDialer = intent.getBooleanExtra(KEY_IS_PRIVILEGED_DIALER, false);

        // Send to CallsManager to ensure the InCallUI gets kicked off before the broadcast returns
        Call call = callsManager.startOutgoingCall(handle, phoneAccountHandle, clientExtras);
        Call call = callsManager.startOutgoingCall(handle, phoneAccountHandle, clientExtras,
                origin);

        if (call != null) {
            // Asynchronous calls should not usually be made inside a BroadcastReceiver because once
+10 −5
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.provider.CallLog.Calls;
import android.telecom.DisconnectCause;
import android.telecom.PhoneAccountHandle;
@@ -53,7 +54,7 @@ final class CallLogManager extends CallsManagerListenerBase {
         */
        public AddCallArgs(Context context, CallerInfo callerInfo, String number,
                int presentation, int callType, int features, PhoneAccountHandle accountHandle,
                long creationDate, long durationInMillis, Long dataUsage) {
                long creationDate, long durationInMillis, Long dataUsage, Bundle callExtras) {
            this.context = context;
            this.callerInfo = callerInfo;
            this.number = number;
@@ -64,6 +65,7 @@ final class CallLogManager extends CallsManagerListenerBase {
            this.timestamp = creationDate;
            this.durationInSec = (int)(durationInMillis / 1000);
            this.dataUsage = dataUsage;
            this.callExtras = callExtras;
        }
        // Since the members are accessed directly, we don't use the
        // mXxxx notation.
@@ -77,6 +79,7 @@ final class CallLogManager extends CallsManagerListenerBase {
        public final long timestamp;
        public final int durationInSec;
        public final Long dataUsage;
        public final Bundle callExtras;
    }

    private static final String TAG = CallLogManager.class.getSimpleName();
@@ -149,7 +152,7 @@ final class CallLogManager extends CallsManagerListenerBase {
        int callFeatures = getCallFeatures(call.getVideoStateHistory());
        logCall(call.getCallerInfo(), logNumber, call.getHandlePresentation(),
                callLogType, callFeatures, accountHandle, creationTime, age, null,
                call.isEmergencyCall());
                call.isEmergencyCall(), call.getIntentExtras());
    }

    /**
@@ -164,6 +167,7 @@ final class CallLogManager extends CallsManagerListenerBase {
     * @param duration The duration of the call, in milliseconds.
     * @param dataUsage The data usage for the call, null if not applicable.
     * @param isEmergency {@code true} if this is an emergency call, {@code false} otherwise.
     * @param callExtras if the call has extra data (eg: origin) it'll be here.
     */
    private void logCall(
            CallerInfo callerInfo,
@@ -175,7 +179,8 @@ final class CallLogManager extends CallsManagerListenerBase {
            long start,
            long duration,
            Long dataUsage,
            boolean isEmergency) {
            boolean isEmergency,
            Bundle callExtras) {

        // On some devices, to avoid accidental redialing of emergency numbers, we *never* log
        // emergency calls to the Call Log.  (This behavior is set on a per-product basis, based
@@ -193,7 +198,7 @@ final class CallLogManager extends CallsManagerListenerBase {
                    + Log.pii(number) + "," + presentation + ", " + callType
                    + ", " + start + ", " + duration);
            AddCallArgs args = new AddCallArgs(mContext, callerInfo, number, presentation,
                    callType, features, accountHandle, start, duration, dataUsage);
                    callType, features, accountHandle, start, duration, dataUsage, callExtras);
            logCallAsync(args);
        } else {
          Log.d(TAG, "Not adding emergency call to call log.");
@@ -262,7 +267,7 @@ final class CallLogManager extends CallsManagerListenerBase {
                    // May block.
                    result[i] = Calls.addCall(c.callerInfo, c.context, c.number, c.presentation,
                            c.callType, c.features, c.accountHandle, c.timestamp, c.durationInSec,
                            c.dataUsage, true /* addForAllUsers */);
                            c.dataUsage, true /* addForAllUsers */, c.callExtras);
                } catch (Exception e) {
                    // This is very rare but may happen in legitimate cases.
                    // E.g. If the phone is encrypted and thus write request fails, it may cause
+20 −0
Original line number Diff line number Diff line
@@ -653,6 +653,22 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
     * @param extras The optional extras Bundle passed with the intent used for the incoming call.
     */
    Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle, Bundle extras) {
        return startOutgoingCall(handle, phoneAccountHandle, extras, null);
    }


    /**
     * Kicks off the first steps to creating an outgoing call so that InCallUI can launch.
     *
     * @param handle Handle to connect the call with.
     * @param phoneAccountHandle The phone account which contains the component name of the
     *        connection service to use for this call.
     * @param extras The optional extras Bundle passed with the intent used for the incoming call.
     * @param origin The string that contains the origin on the system where the call was
     *               made.
     */
    Call startOutgoingCall(Uri handle, PhoneAccountHandle phoneAccountHandle, Bundle extras,
                           String origin) {
        Call call = getNewOutgoingCall(handle);

        if (extras!=null) {
@@ -751,6 +767,10 @@ public class CallsManager extends Call.ListenerBase implements VideoProviderProx
                    phoneAccountHandle == null ? "no-handle" : phoneAccountHandle.toString());
        }

        if (!TextUtils.isEmpty(origin)) {
            extras.putString(PhoneConstants.EXTRA_CALL_ORIGIN, origin);
        }

        call.setIntentExtras(extras);

        // Do not add the call if it is a potential MMI code.