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

Commit 2c7fc938 authored by Danny Baumann's avatar Danny Baumann Committed by Gerrit Code Review
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
parent 3ac4922a
Loading
Loading
Loading
Loading
+0 −15
Original line number Original line Diff line number Diff line
@@ -387,8 +387,6 @@ public final class Call {
    private String mRemainingPostDialSequence;
    private String mRemainingPostDialSequence;
    private InCallService.VideoCall mVideoCall;
    private InCallService.VideoCall mVideoCall;
    private Details mDetails;
    private Details mDetails;
    private int mNotificationType;
    private int mNotificationCode;


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


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

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

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


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

        boolean cannedTextResponsesChanged = false;
        boolean cannedTextResponsesChanged = false;
        if (mCannedTextResponses == null && parcelableCall.getCannedSmsResponses() != null
        if (mCannedTextResponses == null && parcelableCall.getCannedSmsResponses() != null
                && !parcelableCall.getCannedSmsResponses().isEmpty()) {
                && !parcelableCall.getCannedSmsResponses().isEmpty()) {
+10 −0
Original line number Original line Diff line number Diff line
@@ -23,4 +23,14 @@ package android.telecom;
public class CallProperties {
public class CallProperties {
    /** Call is currently in a conference call. */
    /** Call is currently in a conference call. */
    public static final int CONFERENCE                      = 0x00000001;
    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 Original line Diff line number Diff line
@@ -74,11 +74,11 @@ public abstract class Connection {
                Connection c, String callerDisplayName, int presentation) {}
                Connection c, String callerDisplayName, int presentation) {}
        public void onVideoStateChanged(Connection c, int videoState) {}
        public void onVideoStateChanged(Connection c, int videoState) {}
        public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
        public void onDisconnected(Connection c, DisconnectCause disconnectCause) {}
        public void onSsNotificationData(int type, int code) {}
        public void onPostDialWait(Connection c, String remaining) {}
        public void onPostDialWait(Connection c, String remaining) {}
        public void onRingbackRequested(Connection c, boolean ringback) {}
        public void onRingbackRequested(Connection c, boolean ringback) {}
        public void onDestroyed(Connection c) {}
        public void onDestroyed(Connection c) {}
        public void onCallCapabilitiesChanged(Connection c, int callCapabilities) {}
        public void onCallCapabilitiesChanged(Connection c, int callCapabilities) {}
        public void onCallPropertiesChanged(Connection c, int callProperties) {}
        public void onVideoProviderChanged(
        public void onVideoProviderChanged(
                Connection c, VideoProvider videoProvider) {}
                Connection c, VideoProvider videoProvider) {}
        public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
        public void onAudioModeIsVoipChanged(Connection c, boolean isVoip) {}
@@ -493,6 +493,7 @@ public abstract class Connection {
    private int mCallerDisplayNamePresentation;
    private int mCallerDisplayNamePresentation;
    private boolean mRingbackRequested = false;
    private boolean mRingbackRequested = false;
    private int mCallCapabilities;
    private int mCallCapabilities;
    private int mCallProperties;
    private VideoProvider mVideoProvider;
    private VideoProvider mVideoProvider;
    private boolean mAudioModeIsVoip;
    private boolean mAudioModeIsVoip;
    private StatusHints mStatusHints;
    private StatusHints mStatusHints;
@@ -677,6 +678,13 @@ public abstract class Connection {
        return mCallCapabilities;
        return mCallCapabilities;
    }
    }


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

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


    /** @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.
     * TODO: Needs documentation.
     */
     */
@@ -849,6 +849,20 @@ public abstract class Connection {
        }
        }
    }
    }


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


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


        @Override
        @Override
@@ -527,6 +517,13 @@ public abstract class ConnectionService extends Service {
            mAdapter.setCallCapabilities(id, capabilities);
            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
        @Override
        public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) {
        public void onVideoProviderChanged(Connection c, Connection.VideoProvider videoProvider) {
            String id = mIdByConnection.get(c);
            String id = mIdByConnection.get(c);
@@ -565,12 +562,6 @@ public abstract class ConnectionService extends Service {
            }
            }
        }
        }


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

        @Override
        @Override
        public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {
        public void onPhoneAccountChanged(Connection c, PhoneAccountHandle pHandle) {
            String id = mIdByConnection.get(c);
            String id = mIdByConnection.get(c);
@@ -622,10 +613,11 @@ public abstract class ConnectionService extends Service {


        Uri address = connection.getAddress();
        Uri address = connection.getAddress();
        String number = address == null ? "null" : address.getSchemeSpecificPart();
        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.toLogSafePhoneNumber(number),
                Connection.stateToString(connection.getState()),
                Connection.stateToString(connection.getState()),
                PhoneCapabilities.toString(connection.getCallCapabilities()));
                PhoneCapabilities.toString(connection.getCallCapabilities()),
                connection.getCallProperties());


        Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId);
        Log.d(this, "createConnection, calling handleCreateConnectionSuccessful %s", callId);
        mAdapter.handleCreateConnectionComplete(
        mAdapter.handleCreateConnectionComplete(
@@ -635,6 +627,7 @@ public abstract class ConnectionService extends Service {
                        getAccountHandle(request, connection),
                        getAccountHandle(request, connection),
                        connection.getState(),
                        connection.getState(),
                        connection.getCallCapabilities(),
                        connection.getCallCapabilities(),
                        connection.getCallProperties(),
                        connection.getAddress(),
                        connection.getAddress(),
                        connection.getAddressPresentation(),
                        connection.getAddressPresentation(),
                        connection.getCallerDisplayName(),
                        connection.getCallerDisplayName(),
+9 −21
Original line number Original line Diff line number Diff line
@@ -146,27 +146,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.
     * Sets a call's state to be on hold.
     *
     *
@@ -205,6 +184,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
     * Indicates whether or not the specified call is currently conferenced into the specified
     * conference call.
     * conference call.
Loading