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

Commit 571d5e66 authored by Tyler Gunn's avatar Tyler Gunn
Browse files

Add connection properties to Connections.

- Per suggestion of API council, moving properties of a Connection from
CAPABILITIES_* to PROPERTIES_*.

Bug: 27458894
Change-Id: I484783727c840a56882bca79c35280a4a338256d
parent d9d8fb65
Loading
Loading
Loading
Loading
+32 −7
Original line number Diff line number Diff line
@@ -93,6 +93,7 @@ public class Call implements CreateConnectionResponse {
        void onPostDialWait(Call call, String remaining);
        void onPostDialChar(Call call, char nextChar);
        void onConnectionCapabilitiesChanged(Call call);
        void onConnectionPropertiesChanged(Call call);
        void onParentChanged(Call call);
        void onChildrenChanged(Call call);
        void onCannedSmsResponsesLoaded(Call call);
@@ -136,6 +137,8 @@ public class Call implements CreateConnectionResponse {
        @Override
        public void onConnectionCapabilitiesChanged(Call call) {}
        @Override
        public void onConnectionPropertiesChanged(Call call) {}
        @Override
        public void onParentChanged(Call call) {}
        @Override
        public void onChildrenChanged(Call call) {}
@@ -331,6 +334,8 @@ public class Call implements CreateConnectionResponse {

    private int mConnectionCapabilities;

    private int mConnectionProperties;

    private boolean mIsConference = false;

    private final boolean mShouldAttachToExistingConnection;
@@ -530,9 +535,7 @@ public class Call implements CreateConnectionResponse {
            component = mConnectionService.getComponentName().flattenToShortString();
        }



        return String.format(Locale.US, "[%s, %s, %s, %s, %s, childs(%d), has_parent(%b), [%s]]",
        return String.format(Locale.US, "[%s, %s, %s, %s, %s, childs(%d), has_parent(%b), %s, %s]",
                mId,
                CallState.toString(mState),
                component,
@@ -540,7 +543,8 @@ public class Call implements CreateConnectionResponse {
                getVideoStateDescription(getVideoState()),
                getChildCalls().size(),
                getParentCall() != null,
                Connection.capabilitiesToString(getConnectionCapabilities()));
                Connection.capabilitiesToString(getConnectionCapabilities()),
                Connection.propertiesToString(getConnectionProperties()));
    }

    /**
@@ -941,6 +945,10 @@ public class Call implements CreateConnectionResponse {
        return mConnectionCapabilities;
    }

    int getConnectionProperties() {
        return mConnectionProperties;
    }

    void setConnectionCapabilities(int connectionCapabilities) {
        setConnectionCapabilities(connectionCapabilities, false /* forceUpdate */);
    }
@@ -956,6 +964,17 @@ public class Call implements CreateConnectionResponse {
        }
    }

    void setConnectionProperties(int connectionProperties) {
        Log.v(this, "setConnectionProperties: %s", Connection.propertiesToString(
                connectionProperties));
        if (mConnectionProperties != connectionProperties) {
            mConnectionProperties = connectionProperties;
            for (Listener l : mListeners) {
                l.onConnectionPropertiesChanged(this);
            }
        }
    }

    @VisibleForTesting
    public Call getParentCall() {
        return mParentCall;
@@ -1072,6 +1091,7 @@ public class Call implements CreateConnectionResponse {
        setCallerDisplayName(
                connection.getCallerDisplayName(), connection.getCallerDisplayNamePresentation());
        setConnectionCapabilities(connection.getConnectionCapabilities());
        setConnectionProperties(connection.getConnectionProperties());
        setVideoProvider(connection.getVideoProvider());
        setVideoState(connection.getVideoState());
        setRingbackRequested(connection.isRingbackRequested());
@@ -1493,8 +1513,8 @@ public class Call implements CreateConnectionResponse {
     * Initiates a request to the connection service to pull this call.
     * <p>
     * This method can only be used for calls that have the
     * {@link android.telecom.Connection#CAPABILITY_CAN_PULL_CALL} and
     * {@link android.telecom.Connection#CAPABILITY_IS_EXTERNAL_CALL} capabilities set.
     * {@link android.telecom.Connection#CAPABILITY_CAN_PULL_CALL} capability and
     * {@link android.telecom.Connection#PROPERTY_IS_EXTERNAL_CALL} property set.
     * <p>
     * An external call is a representation of a call which is taking place on another device
     * associated with a PhoneAccount on this device.  Issuing a request to pull the external call 
@@ -1512,7 +1532,7 @@ public class Call implements CreateConnectionResponse {
            Log.w(this, "pulling a call without a connection service.");
        }

        if (!can(Connection.CAPABILITY_IS_EXTERNAL_CALL)) {
        if (!hasProperty(Connection.PROPERTY_IS_EXTERNAL_CALL)) {
            Log.w(this, "pullExternalCall - call %s is not an external call.", mId);
            return;
        }
@@ -1583,6 +1603,11 @@ public class Call implements CreateConnectionResponse {
        return (mConnectionCapabilities & capability) == capability;
    }

    @VisibleForTesting
    public boolean hasProperty(int property) {
        return (mConnectionProperties & property) == property;
    }

    private void addChildCall(Call call) {
        if (!mChildCalls.contains(call)) {
            // Set the pseudo-active call to the latest child added to the conference.
+2 −0
Original line number Diff line number Diff line
@@ -1465,6 +1465,7 @@ public class CallsManager extends Call.ListenerBase
        setCallState(call, Call.getStateFromConnectionState(parcelableConference.getState()),
                "new conference call");
        call.setConnectionCapabilities(parcelableConference.getConnectionCapabilities());
        call.setConnectionProperties(parcelableConference.getConnectionProperties());
        call.setVideoState(parcelableConference.getVideoState());
        call.setVideoProvider(parcelableConference.getVideoProvider());
        call.setStatusHints(parcelableConference.getStatusHints());
@@ -1853,6 +1854,7 @@ public class CallsManager extends Call.ListenerBase
        setCallState(call, Call.getStateFromConnectionState(connection.getState()),
                "existing connection");
        call.setConnectionCapabilities(connection.getConnectionCapabilities());
        call.setConnectionProperties(connection.getConnectionProperties());
        call.setCallerDisplayName(connection.getCallerDisplayName(),
                connection.getCallerDisplayNamePresentation());

+18 −0
Original line number Diff line number Diff line
@@ -263,6 +263,24 @@ public class ConnectionServiceWrapper extends ServiceBinder {
            }
        }

        @Override
        public void setConnectionProperties(String callId, int connectionProperties) {
            Log.startSession("CSW.sCP");
            long token = Binder.clearCallingIdentity();
            try {
                synchronized (mLock) {
                    logIncoming("setConnectionProperties %s %d", callId, connectionProperties);
                    Call call = mCallIdMapper.getCall(callId);
                    if (call != null) {
                        call.setConnectionProperties(connectionProperties);
                    }
                }
            } finally {
                Binder.restoreCallingIdentity(token);
                Log.endSession();
            }
        }

        @Override
        public void setIsConferenced(String callId, String conferenceCallId) {
            Log.startSession("CSW.sIC");
+5 −0
Original line number Diff line number Diff line
@@ -90,6 +90,11 @@ public final class InCallController extends CallsManagerListenerBase {
            updateCall(call);
        }

        @Override
        public void onConnectionPropertiesChanged(Call call) {
            updateCall(call);
        }

        @Override
        public void onCannedSmsResponsesLoaded(Call call) {
            updateCall(call);
+8 −8
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public class ParcelableCallUtils {
            PhoneAccountRegistrar phoneAccountRegistrar) {
        int state = getParcelableState(call);
        int capabilities = convertConnectionToCallCapabilities(call.getConnectionCapabilities());
        int properties = convertConnectionToCallProperties(call.getConnectionCapabilities());
        int properties = convertConnectionToCallProperties(call.getConnectionProperties());
        if (call.isConference()) {
            properties |= android.telecom.Call.Details.PROPERTY_CONFERENCE;
        }
@@ -250,26 +250,26 @@ public class ParcelableCallUtils {
    }

    private static final int[] CONNECTION_TO_CALL_PROPERTIES = new int[] {
        Connection.CAPABILITY_HIGH_DEF_AUDIO,
        Connection.PROPERTY_HIGH_DEF_AUDIO,
        android.telecom.Call.Details.PROPERTY_HIGH_DEF_AUDIO,

        Connection.CAPABILITY_WIFI,
        Connection.PROPERTY_WIFI,
        android.telecom.Call.Details.PROPERTY_WIFI,

        Connection.CAPABILITY_GENERIC_CONFERENCE,
        Connection.PROPERTY_GENERIC_CONFERENCE,
        android.telecom.Call.Details.PROPERTY_GENERIC_CONFERENCE,

        Connection.CAPABILITY_SHOW_CALLBACK_NUMBER,
        Connection.PROPERTY_SHOW_CALLBACK_NUMBER,
        android.telecom.Call.Details.PROPERTY_EMERGENCY_CALLBACK_MODE,

        Connection.CAPABILITY_IS_EXTERNAL_CALL,
        Connection.PROPERTY_IS_EXTERNAL_CALL,
        android.telecom.Call.Details.PROPERTY_IS_EXTERNAL_CALL
    };

    private static int convertConnectionToCallProperties(int connectionCapabilities) {
    private static int convertConnectionToCallProperties(int connectionProperties) {
        int callProperties = 0;
        for (int i = 0; i < CONNECTION_TO_CALL_PROPERTIES.length; i += 2) {
            if ((CONNECTION_TO_CALL_PROPERTIES[i] & connectionCapabilities) ==
            if ((CONNECTION_TO_CALL_PROPERTIES[i] & connectionProperties) ==
                    CONNECTION_TO_CALL_PROPERTIES[i]) {

                callProperties |= CONNECTION_TO_CALL_PROPERTIES[i + 1];
Loading