Loading src/java/com/android/internal/telephony/d2d/Communicator.java +17 −2 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ public class Communicator implements TransportProtocol.Callback { } private boolean mIsNegotiated; private boolean mIsNegotiationAttempted; private TransportProtocol mActiveTransport; private List<TransportProtocol> mTransportProtocols = new ArrayList<>(); private Callback mCallback; Loading Loading @@ -126,8 +127,10 @@ public class Communicator implements TransportProtocol.Callback { public void onStateChanged(Connection c, @Connection.ConnectionState int state) { if (state == Connection.STATE_ACTIVE) { // Protocol negotiation can start as we are active if (mActiveTransport == null) { if (mActiveTransport == null && !mIsNegotiationAttempted) { mIsNegotiated = false; mIsNegotiationAttempted = true; Log.i(this, "onStateChanged: call active; negotiate D2D."); negotiateNextProtocol(); } } Loading @@ -141,7 +144,13 @@ public class Communicator implements TransportProtocol.Callback { public void onNegotiationSuccess(@NonNull TransportProtocol protocol) { if (protocol != mActiveTransport) { // Uh oh, shouldn't happen. String activeTransportName = mActiveTransport == null ? "none" : mActiveTransport.getClass().getSimpleName(); Log.w(this, "onNegotiationSuccess: ignored - %s negotiated but active transport is %s.", protocol.getClass().getSimpleName(), activeTransportName); } Log.i(this, "onNegotiationSuccess: %s negotiated; setting active.", protocol.getClass().getSimpleName()); mIsNegotiated = true; } Loading @@ -154,6 +163,8 @@ public class Communicator implements TransportProtocol.Callback { if (protocol != mActiveTransport) { // Uh oh, shouldn't happen. } Log.i(this, "onNegotiationFailed: %s failed to negotiate.", protocol.getClass().getSimpleName()); mIsNegotiated = false; negotiateNextProtocol(); } Loading @@ -180,6 +191,8 @@ public class Communicator implements TransportProtocol.Callback { return; } Log.i(this, "sendMessages: msgs=%d, activeTransport=%s", messages.size(), mActiveTransport.getClass().getSimpleName()); mActiveTransport.sendMessages(messages); } Loading @@ -190,9 +203,11 @@ public class Communicator implements TransportProtocol.Callback { mActiveTransport = getNextCandidateProtocol(); if (mActiveTransport == null) { // No more protocols, exit. Log.i(this, "negotiateNextProtocol: no remaining transports."); return; } Log.i(this, "negotiateNextProtocol: trying %s", mActiveTransport.getClass().getSimpleName()); mActiveTransport.startNegotiation(); } Loading src/java/com/android/internal/telephony/d2d/DtmfAdapter.java +0 −10 Original line number Diff line number Diff line Loading @@ -22,16 +22,6 @@ import android.os.Message; * Abstracts interaction with DTMF communication APIs. */ public interface DtmfAdapter { /** * Called when a DTMF digit is received from the network. * <p> * In concrete implementations, should be linked to * {@link android.telephony.ims.ImsCallSessionListener#callSessionDtmfReceived(char)}. * * @param digit The received DTMF digit. */ void onDtmfReceived(char digit); /** * Called when a DTMF digit should be sent to the network. * <p> Loading src/java/com/android/internal/telephony/d2d/DtmfTransport.java +573 −3 File changed.Preview size limit exceeded, changes collapsed. Show changes src/java/com/android/internal/telephony/d2d/RtpTransport.java +2 −0 Original line number Diff line number Diff line Loading @@ -338,11 +338,13 @@ public class RtpTransport implements TransportProtocol, RtpAdapter.Callback { // Headers were negotiated during SDP, so we can assume negotiation is complete and // signal to the communicator that we can use this transport. mProtocolStatus = PROTOCOL_STATUS_NEGOTIATION_COMPLETE; Log.i(this, "startNegotiation: header extensions available, negotiation success"); notifyProtocolReady(); } else { // Headers failed to be negotiated during SDP. Assume protocol is not available. // TODO: Implement fallback logic where we still try an SDP probe/response. mProtocolStatus = PROTOCOL_STATUS_NEGOTIATION_FAILED; Log.i(this, "startNegotiation: header extensions not available; negotiation failed"); notifyProtocolUnavailable(); } } Loading src/java/com/android/internal/telephony/d2d/Timeouts.java +66 −3 Original line number Diff line number Diff line Loading @@ -25,12 +25,34 @@ import android.provider.Settings; public final class Timeouts { public static class Adapter { public Adapter() { private final ContentResolver mContentResolver; public Adapter(ContentResolver cr) { mContentResolver = cr; } public long getRtpMessageAckDurationMillis(ContentResolver cr) { return Timeouts.getRtpMessageAckDurationMillis(cr); public long getRtpMessageAckDurationMillis() { return Timeouts.getRtpMessageAckDurationMillis(mContentResolver); } /** * The minimum interval between DTMF digits. * @return minimum interval in millis. */ public long getDtmfMinimumIntervalMillis() { return Timeouts.getDtmfMinimumIntervalMillis(mContentResolver); } public long getMaxDurationOfDtmfMessageMillis() { return Timeouts.getMaxDurationOfDtmfMessageMillis(mContentResolver); } public long getDtmfDurationFuzzMillis() { return Timeouts.getDtmfDurationFuzzMillis(mContentResolver); } public long getDtmfNegotiationTimeoutMillis() { return Timeouts.getDtmfNegotiationTimeoutMillis(mContentResolver); } } Loading Loading @@ -59,4 +81,45 @@ public final class Timeouts { public static long getRtpMessageAckDurationMillis(ContentResolver cr) { return get(cr, "rtp_message_ack_duration_millis", 1000L); } /** * Determines the minimum duration between DTMF digits. Digits are sent with this much spacing * between them. * @param cr * @return */ public static long getDtmfMinimumIntervalMillis(ContentResolver cr) { return get(cr, "dtmf_minimum_interval_millis", 100L); } /** * Determines the maximum amount of time to wait for a single DTMF sequence. * @param cr * @return */ public static long getMaxDurationOfDtmfMessageMillis(ContentResolver cr) { return get(cr, "dtmf_max_message_duration_millis", 1000L); } /** * Determines the maximum amount of time to wait for negotiation of the DTMF protocol. * @param cr * @return */ public static long getDtmfNegotiationTimeoutMillis(ContentResolver cr) { return get(cr, "dtmf_negotiation_timeout_millis", 1000L); } /** * A random amount of time up to this amount will be added to * {@link #getMaxDurationOfDtmfMessageMillis(ContentResolver)} when determining how long to * wait before sending a DTMF message. This fuzz factor is used to account for timing * discrepancies between devices. * @param cr * @return */ public static long getDtmfDurationFuzzMillis(ContentResolver cr) { return get(cr, "dtmf_duration_fuzz_millis", 10L); } } Loading
src/java/com/android/internal/telephony/d2d/Communicator.java +17 −2 Original line number Diff line number Diff line Loading @@ -99,6 +99,7 @@ public class Communicator implements TransportProtocol.Callback { } private boolean mIsNegotiated; private boolean mIsNegotiationAttempted; private TransportProtocol mActiveTransport; private List<TransportProtocol> mTransportProtocols = new ArrayList<>(); private Callback mCallback; Loading Loading @@ -126,8 +127,10 @@ public class Communicator implements TransportProtocol.Callback { public void onStateChanged(Connection c, @Connection.ConnectionState int state) { if (state == Connection.STATE_ACTIVE) { // Protocol negotiation can start as we are active if (mActiveTransport == null) { if (mActiveTransport == null && !mIsNegotiationAttempted) { mIsNegotiated = false; mIsNegotiationAttempted = true; Log.i(this, "onStateChanged: call active; negotiate D2D."); negotiateNextProtocol(); } } Loading @@ -141,7 +144,13 @@ public class Communicator implements TransportProtocol.Callback { public void onNegotiationSuccess(@NonNull TransportProtocol protocol) { if (protocol != mActiveTransport) { // Uh oh, shouldn't happen. String activeTransportName = mActiveTransport == null ? "none" : mActiveTransport.getClass().getSimpleName(); Log.w(this, "onNegotiationSuccess: ignored - %s negotiated but active transport is %s.", protocol.getClass().getSimpleName(), activeTransportName); } Log.i(this, "onNegotiationSuccess: %s negotiated; setting active.", protocol.getClass().getSimpleName()); mIsNegotiated = true; } Loading @@ -154,6 +163,8 @@ public class Communicator implements TransportProtocol.Callback { if (protocol != mActiveTransport) { // Uh oh, shouldn't happen. } Log.i(this, "onNegotiationFailed: %s failed to negotiate.", protocol.getClass().getSimpleName()); mIsNegotiated = false; negotiateNextProtocol(); } Loading @@ -180,6 +191,8 @@ public class Communicator implements TransportProtocol.Callback { return; } Log.i(this, "sendMessages: msgs=%d, activeTransport=%s", messages.size(), mActiveTransport.getClass().getSimpleName()); mActiveTransport.sendMessages(messages); } Loading @@ -190,9 +203,11 @@ public class Communicator implements TransportProtocol.Callback { mActiveTransport = getNextCandidateProtocol(); if (mActiveTransport == null) { // No more protocols, exit. Log.i(this, "negotiateNextProtocol: no remaining transports."); return; } Log.i(this, "negotiateNextProtocol: trying %s", mActiveTransport.getClass().getSimpleName()); mActiveTransport.startNegotiation(); } Loading
src/java/com/android/internal/telephony/d2d/DtmfAdapter.java +0 −10 Original line number Diff line number Diff line Loading @@ -22,16 +22,6 @@ import android.os.Message; * Abstracts interaction with DTMF communication APIs. */ public interface DtmfAdapter { /** * Called when a DTMF digit is received from the network. * <p> * In concrete implementations, should be linked to * {@link android.telephony.ims.ImsCallSessionListener#callSessionDtmfReceived(char)}. * * @param digit The received DTMF digit. */ void onDtmfReceived(char digit); /** * Called when a DTMF digit should be sent to the network. * <p> Loading
src/java/com/android/internal/telephony/d2d/DtmfTransport.java +573 −3 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/java/com/android/internal/telephony/d2d/RtpTransport.java +2 −0 Original line number Diff line number Diff line Loading @@ -338,11 +338,13 @@ public class RtpTransport implements TransportProtocol, RtpAdapter.Callback { // Headers were negotiated during SDP, so we can assume negotiation is complete and // signal to the communicator that we can use this transport. mProtocolStatus = PROTOCOL_STATUS_NEGOTIATION_COMPLETE; Log.i(this, "startNegotiation: header extensions available, negotiation success"); notifyProtocolReady(); } else { // Headers failed to be negotiated during SDP. Assume protocol is not available. // TODO: Implement fallback logic where we still try an SDP probe/response. mProtocolStatus = PROTOCOL_STATUS_NEGOTIATION_FAILED; Log.i(this, "startNegotiation: header extensions not available; negotiation failed"); notifyProtocolUnavailable(); } } Loading
src/java/com/android/internal/telephony/d2d/Timeouts.java +66 −3 Original line number Diff line number Diff line Loading @@ -25,12 +25,34 @@ import android.provider.Settings; public final class Timeouts { public static class Adapter { public Adapter() { private final ContentResolver mContentResolver; public Adapter(ContentResolver cr) { mContentResolver = cr; } public long getRtpMessageAckDurationMillis(ContentResolver cr) { return Timeouts.getRtpMessageAckDurationMillis(cr); public long getRtpMessageAckDurationMillis() { return Timeouts.getRtpMessageAckDurationMillis(mContentResolver); } /** * The minimum interval between DTMF digits. * @return minimum interval in millis. */ public long getDtmfMinimumIntervalMillis() { return Timeouts.getDtmfMinimumIntervalMillis(mContentResolver); } public long getMaxDurationOfDtmfMessageMillis() { return Timeouts.getMaxDurationOfDtmfMessageMillis(mContentResolver); } public long getDtmfDurationFuzzMillis() { return Timeouts.getDtmfDurationFuzzMillis(mContentResolver); } public long getDtmfNegotiationTimeoutMillis() { return Timeouts.getDtmfNegotiationTimeoutMillis(mContentResolver); } } Loading Loading @@ -59,4 +81,45 @@ public final class Timeouts { public static long getRtpMessageAckDurationMillis(ContentResolver cr) { return get(cr, "rtp_message_ack_duration_millis", 1000L); } /** * Determines the minimum duration between DTMF digits. Digits are sent with this much spacing * between them. * @param cr * @return */ public static long getDtmfMinimumIntervalMillis(ContentResolver cr) { return get(cr, "dtmf_minimum_interval_millis", 100L); } /** * Determines the maximum amount of time to wait for a single DTMF sequence. * @param cr * @return */ public static long getMaxDurationOfDtmfMessageMillis(ContentResolver cr) { return get(cr, "dtmf_max_message_duration_millis", 1000L); } /** * Determines the maximum amount of time to wait for negotiation of the DTMF protocol. * @param cr * @return */ public static long getDtmfNegotiationTimeoutMillis(ContentResolver cr) { return get(cr, "dtmf_negotiation_timeout_millis", 1000L); } /** * A random amount of time up to this amount will be added to * {@link #getMaxDurationOfDtmfMessageMillis(ContentResolver)} when determining how long to * wait before sending a DTMF message. This fuzz factor is used to account for timing * discrepancies between devices. * @param cr * @return */ public static long getDtmfDurationFuzzMillis(ContentResolver cr) { return get(cr, "dtmf_duration_fuzz_millis", 10L); } }