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

Commit 724a6c52 authored by Danny Baumann's avatar Danny Baumann Committed by Matt Garnes
Browse files

Proper supplementary service notification handling (1/5).

Remove CAF's passing of implementation details from the base classes,
and replace it by well-defined call properties.

Change-Id: I4fa94d4ba68a1570d3f822be569ae124882c0e66
(cherry picked from commit 2c7fc938)
parent add893a0
Loading
Loading
Loading
Loading
+0 −15
Original line number Diff line number Diff line
@@ -399,8 +399,6 @@ public final class Call {
    private String mRemainingPostDialSequence;
    private InCallService.VideoCall mVideoCall;
    private Details mDetails;
    private int mNotificationType;
    private int mNotificationCode;

    /** {@hide} */
    public boolean mIsActiveSub = false;
@@ -415,16 +413,6 @@ public final class Call {
        return mRemainingPostDialSequence;
    }

    /** @hide */
    public int getNotificationType() {
        return mNotificationType;
    }

    /** @hide */
    public int getNotificationCode() {
        return mNotificationCode;
    }

    /**
     * Instructs this {@link #STATE_RINGING} {@code Call} to answer.
     * @param videoState The video state in which to answer the call.
@@ -705,9 +693,6 @@ public final class Call {
            mDetails = details;
        }

        mNotificationType = parcelableCall.getNotificationType();
        mNotificationCode = parcelableCall.getNotificationCode();

        boolean cannedTextResponsesChanged = false;
        if (mCannedTextResponses == null && parcelableCall.getCannedSmsResponses() != null
                && !parcelableCall.getCannedSmsResponses().isEmpty()) {
+10 −0
Original line number Diff line number Diff line
@@ -23,4 +23,14 @@ package android.telecom;
public class CallProperties {
    /** Call is currently in a conference call. */
    public static final int CONFERENCE                      = 0x00000001;
    /** Whether the call was forwarded from another party (GSM only) */
    public static final int WAS_FORWARDED                   = 0x00000002;
    /** Whether the call is held remotely */
    public static final int HELD_REMOTELY                   = 0x00000004;
    /** Whether the dialing state is waiting for the busy remote side */
    public static final int DIALING_IS_WAITING              = 0x00000008;
    /** Whether an additional call came in and was forwarded while the call was active */
    public static final int ADDITIONAL_CALL_FORWARDED       = 0x00000010;
    /** Whether incoming calls are barred at the remote side */
    public static final int REMOTE_INCOMING_CALLS_BARRED    = 0x00000020;
}
+23 −9
Original line number Diff line number Diff line
@@ -97,11 +97,11 @@ public abstract class Connection implements IConferenceable {
                Connection c, String callerDisplayName, int presentation) {}
        public void onVideoStateChanged(Connection c, int videoState) {}
        public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
        public void onSsNotificationData(int type, int code) {}
        public void onPostDialWait(Connection c, String remaining) {}
        public void onRingbackRequested(Connection c, boolean ringback) {}
        public void onDestroyed(Connection c) {}
        public void onCallCapabilitiesChanged(Connection c, int callCapabilities) {}
        public void onCallPropertiesChanged(Connection c, int callProperties) {}
        public void onVideoProviderChanged(
                Connection c, VideoProvider videoProvider) {}
        public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
@@ -529,6 +529,7 @@ public abstract class Connection implements IConferenceable {
    private int mCallerDisplayNamePresentation;
    private boolean mRingbackRequested = false;
    private int mCallCapabilities;
    private int mCallProperties;
    private VideoProvider mVideoProvider;
    private boolean mAudioModeIsVoip;
    private StatusHints mStatusHints;
@@ -729,6 +730,13 @@ public abstract class Connection implements IConferenceable {
        return mCallCapabilities;
    }

    /**
     * Returns the connection's {@link CallProperties}
     */
    public final int getCallProperties() {
        return mCallProperties;
    }

    /**
     * Sets the value of the {@link #getAddress()} property.
     *
@@ -887,14 +895,6 @@ public abstract class Connection implements IConferenceable {
        }
    }

    /** @hide */
    public final void setSsNotificationData(int type, int code) {
        Log.d(this, "setSsNotificationData = "+ type +" "+ code);
        for (Listener l : mListeners) {
            l.onSsNotificationData(type, code);
        }
    }

    /**
     * TODO: Needs documentation.
     */
@@ -933,6 +933,20 @@ public abstract class Connection implements IConferenceable {
        }
    }

    /**
     * Sets the connection's {@link CallProperties}.
     *
     * @param callProperties The new call properties.
     */
    public final void setCallProperties(int callProperties) {
        if (mCallProperties != callProperties) {
            mCallProperties = callProperties;
            for (Listener l : mListeners) {
                l.onCallPropertiesChanged(this, mCallProperties);
            }
        }
    }

    /**
     * Tears down the Connection object.
     */
+13 −19
Original line number Diff line number Diff line
@@ -89,8 +89,6 @@ public abstract class ConnectionService extends Service {
            new RemoteConnectionManager(this);
    private final List<Runnable> mPreInitializationConnectionRequests = new ArrayList<>();
    private final ConnectionServiceAdapter mAdapter = new ConnectionServiceAdapter();
    private int mSsNotificationType = 0xFF;
    private int mSsNotificationCode = 0xFF;

    private boolean mAreAccountsInitialized = false;
    private Conference sNullConference;
@@ -478,15 +476,7 @@ public abstract class ConnectionService extends Service {
        public void onDisconnected(Connection c, DisconnectCause disconnectCause) {
            String id = mIdByConnection.get(c);
            Log.d(this, "Adapter set disconnected %s", disconnectCause);
            if (mSsNotificationType == 0xFF && mSsNotificationCode == 0xFF) {
            mAdapter.setDisconnected(id, disconnectCause);
            } else {
                mAdapter.setDisconnectedWithSsNotification(id, disconnectCause.getCode(),
                        disconnectCause.getReason(),
                        mSsNotificationType, mSsNotificationCode);
                mSsNotificationType = 0xFF;
                mSsNotificationCode = 0xFF;
            }
        }

        @Override
@@ -536,6 +526,13 @@ public abstract class ConnectionService extends Service {
            mAdapter.setCallCapabilities(id, capabilities);
        }

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

        @Override
        public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) {
            String id = mIdByConnection.get(c);
@@ -574,12 +571,6 @@ public abstract class ConnectionService extends Service {
            }
        }

        @Override
        public void onSsNotificationData(int type, int code) {
            mSsNotificationType = type;
            mSsNotificationCode = code;
        }

        @Override
        public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {
            String id = mIdByConnection.get(c);
@@ -638,10 +629,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: 0x%x",
                Connection.toLogSafePhoneNumber(number),
                Connection.stateToString(connection.getState()),
                PhoneCapabilities.toString(connection.getCallCapabilities()));
                PhoneCapabilities.toString(connection.getCallCapabilities()),
                connection.getCallProperties());

        Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId);
        mAdapter.handleCreateConnectionComplete(
@@ -651,6 +643,7 @@ public abstract class ConnectionService extends Service {
                        getAccountHandle(request, connection),
                        connection.getState(),
                        connection.getCallCapabilities(),
                        connection.getCallProperties(),
                        connection.getAddress(),
                        connection.getAddressPresentation(),
                        connection.getCallerDisplayName(),
@@ -982,6 +975,7 @@ public abstract class ConnectionService extends Service {
                    phoneAccountHandle,
                    connection.getState(),
                    connection.getCallCapabilities(),
                    connection.getCallProperties(),
                    connection.getAddress(),
                    connection.getAddressPresentation(),
                    connection.getCallerDisplayName(),
+9 −21
Original line number Diff line number Diff line
@@ -162,27 +162,6 @@ final class ConnectionServiceAdapter implements DeathRecipient {
        }
    }

     /**
     * Sets a call's state to disconnected.
     *
     * @param callId The unique ID of the call whose state is changing to disconnected.
     * @param disconnectCause The reason for the disconnection, any of
     *            {@link android.telephony.DisconnectCause}.
     * @param disconnectMessage Optional call-service-provided message about the disconnect.
     * @param type Supplementary service notification type
     * @param code Supplementary service notification code
     */
    void setDisconnectedWithSsNotification(String callId, int disconnectCause,
            String disconnectMessage, int type, int code) {
        for (IConnectionServiceAdapter adapter : mAdapters) {
            try {
                adapter.setDisconnectedWithSsNotification(callId, disconnectCause,
                        disconnectMessage, type, code);
            } catch (RemoteException e) {
            }
        }
    }

    /**
     * Sets a call's state to be on hold.
     *
@@ -221,6 +200,15 @@ final class ConnectionServiceAdapter implements DeathRecipient {
        }
    }

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

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