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

Commit 9427c1ab authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
Browse files

Proper supplementary service notification handling (1/5).

Change-Id: I4fa94d4ba68a1570d3f822be569ae124882c0e66
parent 39f4239d
Loading
Loading
Loading
Loading
+47 −1
Original line number Diff line number Diff line
@@ -260,8 +260,38 @@ public final class Call {
         */
        public static final int PROPERTY_HIGH_DEF_AUDIO = 0x00000010;

        /**
         * Whether the call was forwarded from another party (GSM only)
         * @hide
         */
        public static final int PROPERTY_WAS_FORWARDED = 0x00000020;

        /**
         * Whether the call is held remotely
         * @hide
         */
        public static final int PROPERTY_HELD_REMOTELY = 0x00000040;

        /**
         * Whether the dialing state is waiting for the busy remote side
         * @hide
         */
        public static final int PROPERTY_DIALING_IS_WAITING = 0x00000080;

        /**
         * Whether an additional call came in and was forwarded while the call was active
         * @hide
         */
        public static final int PROPERTY_ADDITIONAL_CALL_FORWARDED = 0x00000100;

        /**
         * Whether incoming calls are barred at the remote side
         * @hide
         */
        public static final int PROPERTY_REMOTE_INCOMING_CALLS_BARRED = 0x00000200;

        //******************************************************************************************
        // Next PROPERTY value: 0x00000020
        // Next PROPERTY value: 0x00000400
        //******************************************************************************************

        private final Uri mHandle;
@@ -419,6 +449,22 @@ public final class Call {
            if (hasProperty(properties, PROPERTY_EMERGENCY_CALLBACK_MODE)) {
                builder.append(" PROPERTY_EMERGENCY_CALLBACK_MODE");
            }
            if (hasProperty(properties, PROPERTY_WAS_FORWARDED)) {
                builder.append(" PROPERTY_WAS_FORWARDED");
            }
            if (hasProperty(properties, PROPERTY_HELD_REMOTELY)) {
                builder.append(" PROPERTY_HELD_REMOTELY");
            }
            if (hasProperty(properties, PROPERTY_DIALING_IS_WAITING)) {
                builder.append(" PROPERTY_DIALING_IS_WAITING");
            }
            if (hasProperty(properties, PROPERTY_ADDITIONAL_CALL_FORWARDED)) {
                builder.append(" PROPERTY_ADDITIONAL_CALL_FORWARDED");
            }
            if (hasProperty(properties, PROPERTY_REMOTE_INCOMING_CALLS_BARRED)) {
                builder.append(" PROPERTY_REMOTE_INCOMING_CALLS_BARRED");
            }

            builder.append("]");
            return builder.toString();
        }
+32 −1
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ public abstract class Conference extends Conferenceable {
        public void onDestroyed(Conference conference) {}
        public void onConnectionCapabilitiesChanged(
                Conference conference, int connectionCapabilities) {}
        public void onConnectionPropertiesChanged(
                Conference conference, int connectionProperties) {}
        public void onVideoStateChanged(Conference c, int videoState) { }
        public void onVideoProviderChanged(Conference c, Connection.VideoProvider videoProvider) {}
        public void onStatusHintsChanged(Conference conference, StatusHints statusHints) {}
@@ -70,6 +72,7 @@ public abstract class Conference extends Conferenceable {
    private int mState = Connection.STATE_NEW;
    private DisconnectCause mDisconnectCause;
    private int mConnectionCapabilities;
    private int mConnectionProperties;
    private String mDisconnectMessage;
    private long mConnectTimeMillis = CONNECT_TIME_NOT_SPECIFIED;
    private StatusHints mStatusHints;
@@ -179,6 +182,32 @@ public abstract class Conference extends Conferenceable {
        setConnectionCapabilities(newCapabilities);
    }

    /**
     * Returns a bit mask of this conference's properties. See the {@code PROPERTY_*} constants
     * in the {@link Connection} class.
     * @hide
     */
    public final int getConnectionProperties() {
        return mConnectionProperties;
    }


    /**
     * Sets this conference's properties as a bit mask of the {@code PROPERTY_*} constants
     * in the {@link Connection} class.
     *
     * @param connectionProperties The new connection properties.
     * @hide
     */
    public final void setConnectionProperties(int connectionProperties) {
        if (mConnectionProperties != connectionProperties) {
            mConnectionProperties = connectionProperties;
            for (Listener l : mListeners) {
                l.onConnectionPropertiesChanged(this, mConnectionProperties);
            }
        }
    }

    /**
     * @return The audio state of the conference, describing how its audio is currently
     *         being routed by the system. This is {@code null} if this Conference
@@ -600,9 +629,11 @@ public abstract class Conference extends Conferenceable {
    @Override
    public String toString() {
        return String.format(Locale.US,
                "[State: %s,Capabilites: %s, VideoState: %s, VideoProvider: %s, ThisObject %s]",
                "[State: %s, Capabilites: %s, Properties: %s, " +
                "VideoState: %s, VideoProvider: %s, ThisObject %s]",
                Connection.stateToString(mState),
                Call.Details.capabilitiesToString(mConnectionCapabilities),
                Call.Details.propertiesToString(mConnectionProperties),
                getVideoState(),
                getVideoProvider(),
                super.toString());
+126 −1
Original line number Diff line number Diff line
@@ -276,6 +276,40 @@ public abstract class Connection extends Conferenceable {
    // Next CAPABILITY value: 0x04000000
    //**********************************************************************************************

    /**
     * Whether the call was forwarded from another party (GSM only)
     * @hide
     */
    public static final int PROPERTY_WAS_FORWARDED = 0x00000001;

    /**
     * Whether the call is held remotely
     * @hide
     */
    public static final int PROPERTY_HELD_REMOTELY = 0x00000002;

    /**
     * Whether the dialing state is waiting for the busy remote side
     * @hide
     */
    public static final int PROPERTY_DIALING_IS_WAITING = 0x00000004;

    /**
     * Whether an additional call came in and was forwarded while the call was active
     * @hide
     */
    public static final int PROPERTY_ADDITIONAL_CALL_FORWARDED = 0x00000008;

    /**
     * Whether incoming calls are barred at the remote side
     * @hide
     */
    public static final int PROPERTY_REMOTE_INCOMING_CALLS_BARRED = 0x00000010;

    //******************************************************************************************
    // Next PROPERTY value: 0x00000020
    //******************************************************************************************

    /**
     * Connection extra key used to store the last forwarded number associated with the current
     * connection.  Used to communicate to the user interface that the connection was forwarded via
@@ -352,7 +386,6 @@ public abstract class Connection extends Conferenceable {
        mConnectionCapabilities |= capability;
    }


    public static String capabilitiesToString(int capabilities) {
        StringBuilder builder = new StringBuilder();
        builder.append("[Capabilities:");
@@ -429,6 +462,72 @@ public abstract class Connection extends Conferenceable {
        return builder.toString();
    }

    /**
     * Whether the given properties include the specified property.
     *
     * @param properties A property bit field.
     * @param property The property to check properties for.
     * @return Whether the specified property is present.
     * @hide
     */
    public static boolean hasProperty(int properties, int property) {
        return (properties & property) != 0;
    }

    /**
     * Whether the properties of this {@code Connection} include the specified property.
     *
     * @param property The property to look for.
     * @return Whether the specified property is present.
     * @hide
     */
    public boolean hasProperty(int property) {
        return hasProperty(mConnectionProperties, property);
    }

    /**
     * Removes the specified property from the set of properties of this {@code Connection}.
     *
     * @param property The property to remove from the set.
     * @hide
     */
    public void removeProperty(int property) {
        mConnectionProperties &= ~property;
    }

    /**
     * Adds the specified property to the set of propertes of this {@code Connection}.
     *
     * @param property The property to add to the set.
     * @hide
     */
    public void addProperty(int property) {
        mConnectionProperties |= property;
    }

    public static String propertiesToString(int properties) {
        StringBuilder builder = new StringBuilder();
        builder.append("[Properties:");

        if (hasProperty(properties, PROPERTY_WAS_FORWARDED)) {
            builder.append(" PROPERTY_WAS_FORWARDED");
        }
        if (hasProperty(properties, PROPERTY_HELD_REMOTELY)) {
            builder.append(" PROPERTY_HELD_REMOTELY");
        }
        if (hasProperty(properties, PROPERTY_DIALING_IS_WAITING)) {
            builder.append(" PROPERTY_DIALING_IS_WAITING");
        }
        if (hasProperty(properties, PROPERTY_ADDITIONAL_CALL_FORWARDED)) {
            builder.append(" PROPERTY_ADDITIONAL_CALL_FORWARDED");
        }
        if (hasProperty(properties, PROPERTY_REMOTE_INCOMING_CALLS_BARRED)) {
            builder.append(" PROPERTY_REMOTE_INCOMING_CALLS_BARRED");
        }
        builder.append("]");
        return builder.toString();
    }

    /** @hide */
    public abstract static class Listener {
        public void onStateChanged(Connection c, int state) {}
@@ -442,6 +541,7 @@ public abstract class Connection extends Conferenceable {
        public void onRingbackRequested(Connection c, boolean ringback) {}
        public void onDestroyed(Connection c) {}
        public void onConnectionCapabilitiesChanged(Connection c, int capabilities) {}
        public void onConnectionPropertiesChanged(Connection c, int properties) {}
        public void onVideoProviderChanged(
                Connection c, VideoProvider videoProvider) {}
        public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
@@ -1109,6 +1209,7 @@ public abstract class Connection extends Conferenceable {
    private int mCallerDisplayNamePresentation;
    private boolean mRingbackRequested = false;
    private int mConnectionCapabilities;
    private int mConnectionProperties;
    private VideoProvider mVideoProvider;
    private boolean mAudioModeIsVoip;
    private long mConnectTimeMillis = Conference.CONNECT_TIME_NOT_SPECIFIED;
@@ -1332,6 +1433,14 @@ public abstract class Connection extends Conferenceable {
        return mConnectionCapabilities;
    }

    /**
     * Returns the connection's properties, as a bit mask of the {@code PROPERTY_*} constants.
     * @hide
     */
    public final int getConnectionProperties() {
        return mConnectionProperties;
    }

    /**
     * Sets the value of the {@link #getAddress()} property.
     *
@@ -1528,6 +1637,22 @@ public abstract class Connection extends Conferenceable {
        }
    }

    /**
     * Sets the connection's properties as a bit mask of the {@code PROPERTY_*} constants.
     *
     * @param connectionProperties The new connection properties.
     * @hide
     */
    public final void setConnectionProperties(int connectionProperties) {
        checkImmutable();
        if (mConnectionProperties != connectionProperties) {
            mConnectionProperties = connectionProperties;
            for (Listener l : mListeners) {
                l.onConnectionPropertiesChanged(this, mConnectionProperties);
            }
        }
    }

    /**
     * Tears down the Connection object.
     */
+24 −2
Original line number Diff line number Diff line
@@ -454,6 +454,16 @@ public abstract class ConnectionService extends Service {
            mAdapter.setConnectionCapabilities(id, connectionCapabilities);
        }

        @Override
        public void onConnectionPropertiesChanged(
                Conference conference,
                int connectionProperties) {
            String id = mIdByConference.get(conference);
            Log.d(this, "call properties: conference: %s",
                    Connection.propertiesToString(connectionProperties));
            mAdapter.setConnectionProperties(id, connectionProperties);
        }

        @Override
        public void onVideoStateChanged(Conference c, int videoState) {
            String id = mIdByConference.get(c);
@@ -570,6 +580,14 @@ public abstract class ConnectionService extends Service {
            mAdapter.setConnectionCapabilities(id, capabilities);
        }

        @Override
        public void onConnectionPropertiesChanged(Connection c, int properties) {
            String id = mIdByConnection.get(c);
            Log.d(this, "properties: parcelableconnection: %s",
                    Connection.propertiesToString(properties));
            mAdapter.setConnectionProperties(id, properties);
        }

        @Override
        public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) {
            String id = mIdByConnection.get(c);
@@ -676,10 +694,11 @@ public abstract class ConnectionService extends Service {

        Uri address = connection.getAddress();
        String number = address == null ? "null" : address.getSchemeSpecificPart();
        Log.v(this, "createConnection, number: %s, state: %s, capabilities: %s",
        Log.v(this, "createConnection, number: %s, state: %s, capabilities: %s, properties: %s",
                Connection.toLogSafePhoneNumber(number),
                Connection.stateToString(connection.getState()),
                Connection.capabilitiesToString(connection.getConnectionCapabilities()));
                Connection.capabilitiesToString(connection.getConnectionCapabilities()),
                Connection.propertiesToString(connection.getConnectionProperties()));

        Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId);
        mAdapter.handleCreateConnectionComplete(
@@ -689,6 +708,7 @@ public abstract class ConnectionService extends Service {
                        request.getAccountHandle(),
                        connection.getState(),
                        connection.getConnectionCapabilities(),
                        connection.getConnectionProperties(),
                        connection.getAddress(),
                        connection.getAddressPresentation(),
                        connection.getCallerDisplayName(),
@@ -997,6 +1017,7 @@ public abstract class ConnectionService extends Service {
                    conference.getPhoneAccountHandle(),
                    conference.getState(),
                    conference.getConnectionCapabilities(),
                    conference.getConnectionProperties(),
                    connectionIds,
                    conference.getVideoProvider() == null ?
                            null : conference.getVideoProvider().getInterface(),
@@ -1037,6 +1058,7 @@ public abstract class ConnectionService extends Service {
                    phoneAccountHandle,
                    connection.getState(),
                    connection.getConnectionCapabilities(),
                    connection.getConnectionProperties(),
                    connection.getAddress(),
                    connection.getAddressPresentation(),
                    connection.getCallerDisplayName(),
+9 −0
Original line number Diff line number Diff line
@@ -196,6 +196,15 @@ final class ConnectionServiceAdapter implements DeathRecipient {
        }
    }

    void setConnectionProperties(String callId, int properties) {
        for (IConnectionServiceAdapter adapter : mAdapters) {
            try {
                adapter.setConnectionProperties(callId, properties);
            } catch (RemoteException ignored) {
            }
        }
    }

    /**
     * Indicates whether or not the specified call is currently conferenced into the specified
     * conference call.
Loading