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

Commit 80a09a11 authored by Tyler Gunn's avatar Tyler Gunn Committed by Android (Google) Code Review
Browse files

Merge "Support propagation of extras between InCallServices."

parents a0208c4d 3ab8d6a8
Loading
Loading
Loading
Loading
+40 −13
Original line number Diff line number Diff line
@@ -29,11 +29,9 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.OutcomeReceiver;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ResultReceiver;
import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
@@ -139,7 +137,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        void onCallerInfoChanged(Call call);
        void onIsVoipAudioModeChanged(Call call);
        void onStatusHintsChanged(Call call);
        void onExtrasChanged(Call c, int source, Bundle extras);
        void onExtrasChanged(Call c, int source, Bundle extras, String requestingPackageName);
        void onExtrasRemoved(Call c, int source, List<String> keys);
        void onHandleChanged(Call call);
        void onCallerDisplayNameChanged(Call call);
@@ -208,7 +206,8 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        @Override
        public void onStatusHintsChanged(Call call) {}
        @Override
        public void onExtrasChanged(Call c, int source, Bundle extras) {}
        public void onExtrasChanged(Call c, int source, Bundle extras,
                String requestingPackageName) {}
        @Override
        public void onExtrasRemoved(Call c, int source, List<String> keys) {}
        @Override
@@ -1285,7 +1284,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        Bundle bundle = new Bundle();
        bundle.putBoolean(android.telecom.Call.EXTRA_SILENT_RINGING_REQUESTED,
                silentRingingRequested);
        putExtras(SOURCE_CONNECTION_SERVICE, bundle);
        putConnectionServiceExtras(bundle);
    }

    public boolean isSilentRingingRequested() {
@@ -1296,7 +1295,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        Bundle bundle = new Bundle();
        bundle.putBoolean(android.telecom.Call.EXTRA_IS_SUPPRESSED_BY_DO_NOT_DISTURB,
                isCallSuppressed);
        putExtras(SOURCE_CONNECTION_SERVICE, bundle);
        putConnectionServiceExtras(bundle);
    }

    public boolean isCallSuppressedByDoNotDisturb() {
@@ -2285,7 +2284,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        setVideoState(conference.getVideoState());
        setRingbackRequested(conference.isRingbackRequested());
        setStatusHints(conference.getStatusHints());
        putExtras(SOURCE_CONNECTION_SERVICE, conference.getExtras());
        putConnectionServiceExtras(conference.getExtras());

        switch (mCallDirection) {
            case CALL_DIRECTION_INCOMING:
@@ -2322,7 +2321,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        setVideoState(connection.getVideoState());
        setRingbackRequested(connection.isRingbackRequested());
        setStatusHints(connection.getStatusHints());
        putExtras(SOURCE_CONNECTION_SERVICE, connection.getExtras());
        putConnectionServiceExtras(connection.getExtras());

        mConferenceableCalls.clear();
        for (String id : connection.getConferenceableConnectionIds()) {
@@ -2831,19 +2830,46 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        return mExtras;
    }

    /**
     * Adds extras to the extras bundle associated with this {@link Call}, as made by a
     * {@link ConnectionService} or other non {@link android.telecom.InCallService} source.
     *
     * @param extras The extras.
     */
    public void putConnectionServiceExtras(Bundle extras) {
        putExtras(SOURCE_CONNECTION_SERVICE, extras, null);
    }

    /**
     * Adds extras to the extras bundle associated with this {@link Call}, as made by a
     * {@link android.telecom.InCallService}.
     * @param extras the extras.
     * @param requestingPackageName the package name of the {@link android.telecom.InCallService}
     *                              which requested the extras changed; required so that when we
     *                              have {@link InCallController} notify other
     *                              {@link android.telecom.InCallService}s we don't notify the
     *                              originator of their own change.
     */
    public void putInCallServiceExtras(Bundle extras, String requestingPackageName) {
        putExtras(SOURCE_INCALL_SERVICE, extras, requestingPackageName);
    }

    /**
     * Adds extras to the extras bundle associated with this {@link Call}.
     *
     * Note: this method needs to know the source of the extras change (see
     * {@link #SOURCE_CONNECTION_SERVICE}, {@link #SOURCE_INCALL_SERVICE}).  Extras changes which
     * originate from a connection service will only be notified to incall services.  Likewise,
     * changes originating from the incall services will only notify the connection service of the
     * change.
     * originate from a connection service will only be notified to incall services.  Changes
     * originating from the InCallServices will notify the connection service of the
     * change, as well as other InCallServices other than the originator.
     *
     * @param source The source of the extras addition.
     * @param extras The extras.
     * @param requestingPackageName The package name which requested the extras change.  For
     *                              {@link #SOURCE_INCALL_SERVICE} will be populated with the
     *                              package name of the ICS that requested the change.
     */
    public void putExtras(int source, Bundle extras) {
    private void putExtras(int source, Bundle extras, String requestingPackageName) {
        if (extras == null) {
            return;
        }
@@ -2853,7 +2879,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,
        mExtras.putAll(extras);

        for (Listener l : mListeners) {
            l.onExtrasChanged(this, source, extras);
            l.onExtrasChanged(this, source, extras, requestingPackageName);
        }

        // If mExtra shows that the call using Volte, record it with mWasVolte
@@ -2887,6 +2913,7 @@ public class Call implements CreateConnectionResponse, EventManager.Loggable,

        // If the change originated from an InCallService, notify the connection service.
        if (source == SOURCE_INCALL_SERVICE) {
            Log.addEvent(this, LogUtils.Events.ICS_EXTRAS_CHANGED);
            if (mTransactionalService != null) {
                Log.i(this, "putExtras: called on TransactionalService. doing nothing");
            } else if (mConnectionService != null) {
+8 −7
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.Bundle;
import android.os.IBinder;
@@ -86,17 +85,19 @@ public class CallDiagnosticServiceController extends CallsManagerListenerBase {
         * Listens for changes to extras reported by a Telecom {@link Call}.
         *
         * Extras changes can originate from a {@link ConnectionService} or an {@link InCallService}
         * so we will only trigger an update of the call information if the source of the extras
         * change was a {@link ConnectionService}.
         * so we will only trigger an update of the call information if the source of the
         * extras change was a {@link ConnectionService}.
         *
         * @param call   The call.
         * @param source The source of the extras change ({@link Call#SOURCE_CONNECTION_SERVICE} or
         * @param source The source of the extras change
         *               ({@link Call#SOURCE_CONNECTION_SERVICE} or
         *               {@link Call#SOURCE_INCALL_SERVICE}).
         * @param extras The extras.
         */
        @Override
        public void onExtrasChanged(Call call, int source, Bundle extras) {
            // Do not inform InCallServices of changes which originated there.
        public void onExtrasChanged(Call call, int source, Bundle extras,
                String requestingPackageName) {
            // Do not inform of changes which originated from an InCallService to a CDS.
            if (source == Call.SOURCE_INCALL_SERVICE) {
                return;
            }
+4 −4
Original line number Diff line number Diff line
@@ -1365,7 +1365,7 @@ public class CallsManager extends Call.ListenerBase
                    dropCallExtras.putCharSequence(
                            Connection.EXTRA_ANSWERING_DROPS_FG_CALL_APP_NAME, droppedApp);
                    Log.i(this, "Incoming managed call will drop %s call.", droppedApp);
                    call.putExtras(Call.SOURCE_CONNECTION_SERVICE, dropCallExtras);
                    call.putConnectionServiceExtras(dropCallExtras);
                }
            }

@@ -2952,7 +2952,7 @@ public class CallsManager extends Call.ListenerBase
    }

    @Override
    public void onExtrasChanged(Call c, int source, Bundle extras) {
    public void onExtrasChanged(Call c, int source, Bundle extras, String requestingPackageName) {
        if (source != Call.SOURCE_CONNECTION_SERVICE) {
            return;
        }
@@ -3812,7 +3812,7 @@ public class CallsManager extends Call.ListenerBase
        call.setVideoState(parcelableConference.getVideoState());
        call.setVideoProvider(parcelableConference.getVideoProvider());
        call.setStatusHints(parcelableConference.getStatusHints());
        call.putExtras(Call.SOURCE_CONNECTION_SERVICE, parcelableConference.getExtras());
        call.putConnectionServiceExtras(parcelableConference.getExtras());
        // In case this Conference was added via a ConnectionManager, keep track of the original
        // Connection ID as created by the originating ConnectionService.
        Bundle extras = parcelableConference.getExtras();
@@ -4757,7 +4757,7 @@ public class CallsManager extends Call.ListenerBase
        call.setCallerDisplayName(connection.getCallerDisplayName(),
                connection.getCallerDisplayNamePresentation());
        call.addListener(this);
        call.putExtras(Call.SOURCE_CONNECTION_SERVICE, connection.getExtras());
        call.putConnectionServiceExtras(connection.getExtras());

        Log.i(this, "createCallForExistingConnection: %s", connection);
        Call parentCall = null;
+1 −2
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@ import android.os.ResultReceiver;
import android.os.UserHandle;
import android.telecom.CallAudioState;
import android.telecom.CallEndpoint;
import android.telecom.CallScreeningService;
import android.telecom.Connection;
import android.telecom.ConnectionRequest;
import android.telecom.ConnectionService;
@@ -775,7 +774,7 @@ public class ConnectionServiceWrapper extends ServiceBinder implements
                    Bundle.setDefusable(extras, true);
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        call.putExtras(Call.SOURCE_CONNECTION_SERVICE, extras);
                        call.putConnectionServiceExtras(extras);
                    }
                }
            } catch (Throwable t) {
+3 −1
Original line number Diff line number Diff line
@@ -621,7 +621,9 @@ class InCallAdapter extends IInCallAdapter.Stub {
                synchronized (mLock) {
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        call.putExtras(Call.SOURCE_INCALL_SERVICE, extras);
                        // Make sure to identify the ICS that originated the extras change so that
                        // InCallController can propagate these out to other ICSes.
                        call.putInCallServiceExtras(extras, mOwnerPackageName);
                    } else {
                        Log.w(this, "putExtras, unknown call id: %s", callId);
                    }
Loading