Loading src/com/android/server/telecom/Call.java +44 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class Call implements CreateConnectionResponse { void onPhoneAccountChanged(Call call); void onConferenceableCallsChanged(Call call); boolean onCanceledViaNewOutgoingCallBroadcast(Call call); void onHoldToneRequested(Call call); } public abstract static class ListenerBase implements Listener { Loading Loading @@ -161,6 +162,9 @@ public class Call implements CreateConnectionResponse { public boolean onCanceledViaNewOutgoingCallBroadcast(Call call) { return false; } @Override public void onHoldToneRequested(Call call) {} } private final OnQueryCompleteListener mCallerInfoQueryListener = Loading Loading @@ -365,6 +369,14 @@ public class Call implements CreateConnectionResponse { // Set to true once the NewOutgoingCallIntentBroadcast comes back and is processed. private boolean mIsNewOutgoingCallIntentBroadcastDone = false; /** * Indicates whether the call is remotely held. A call is considered remotely held when * {@link #onConnectionEvent(String)} receives the {@link Connection#EVENT_ON_HOLD_TONE_START} * event. */ private boolean mIsRemotelyHeld = false; /** * Persists the specified parameters and initializes the new instance. * Loading Loading @@ -1921,4 +1933,36 @@ public class Call implements CreateConnectionResponse { public void setNewOutgoingCallIntentBroadcastIsDone() { mIsNewOutgoingCallIntentBroadcastDone = true; } /** * Determines if the call has been held by the remote party. * * @return {@code true} if the call is remotely held, {@code false} otherwise. */ public boolean isRemotelyHeld() { return mIsRemotelyHeld; } /** * Handles Connection events received from a {@link ConnectionService}. * * @param event The event. */ public void onConnectionEvent(String event) { if (Connection.EVENT_ON_HOLD_TONE_START.equals(event)) { mIsRemotelyHeld = true; Log.event(this, Log.Events.REMOTELY_HELD); // Inform listeners of the fact that a call hold tone was received. This will trigger // the CallAudioManager to play a tone via the InCallTonePlayer. for (Listener l : mListeners) { l.onHoldToneRequested(this); } } else if (Connection.EVENT_ON_HOLD_TONE_END.equals(event)) { mIsRemotelyHeld = false; Log.event(this, Log.Events.REMOTELY_UNHELD); for (Listener l : mListeners) { l.onHoldToneRequested(this); } } } } src/com/android/server/telecom/CallAudioManager.java +60 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public class CallAudioManager extends CallsManagerListenerBase { private Call mForegroundCall; private boolean mIsTonePlaying = false; private InCallTonePlayer mHoldTonePlayer; public CallAudioManager(CallAudioRouteStateMachine callAudioRouteStateMachine, CallsManager callsManager, Loading Loading @@ -213,6 +214,19 @@ public class CallAudioManager extends CallsManagerListenerBase { } } /** * Play or stop a call hold tone for a call. Triggered via * {@link Connection#sendConnectionEvent(String)} when the * {@link Connection#EVENT_ON_HOLD_TONE_START} event or * {@link Connection#EVENT_ON_HOLD_TONE_STOP} event is passed through to the * * @param call The call which requested the hold tone. */ @Override public void onHoldToneRequested(Call call) { maybePlayHoldTone(); } @Override public void onIsVoipAudioModeChanged(Call call) { if (call != mForegroundCall) { Loading Loading @@ -490,6 +504,7 @@ public class CallAudioManager extends CallsManagerListenerBase { if (mForegroundCall != oldForegroundCall) { mDtmfLocalTonePlayer.onForegroundCallChanged(oldForegroundCall, mForegroundCall); maybePlayHoldTone(); } } Loading Loading @@ -558,6 +573,51 @@ public class CallAudioManager extends CallsManagerListenerBase { mRingbackPlayer.stopRingbackForCall(call); } /** * Determines if a hold tone should be played and then starts or stops it accordingly. */ private void maybePlayHoldTone() { if (shouldPlayHoldTone()) { if (mHoldTonePlayer == null) { mHoldTonePlayer = mPlayerFactory.createPlayer(InCallTonePlayer.TONE_CALL_WAITING); mHoldTonePlayer.start(); } } else { if (mHoldTonePlayer != null) { mHoldTonePlayer.stopTone(); mHoldTonePlayer = null; } } } /** * Determines if a hold tone should be played. * A hold tone should be played only if foreground call is equals with call which is * remotely held. * * @return {@code true} if the the hold tone should be played, {@code false} otherwise. */ private boolean shouldPlayHoldTone() { Call foregroundCall = getForegroundCall(); // If there is no foreground call, no hold tone should play. if (foregroundCall == null) { return false; } // If another call is ringing, no hold tone should play. if (mCallsManager.hasRingingCall()) { return false; } // If the foreground call isn't active, no hold tone should play. This might happen, for // example, if the user puts a remotely held call on hold itself. if (!foregroundCall.isActive()) { return false; } return foregroundCall.isRemotelyHeld(); } private void dumpCallsInCollection(IndentingPrintWriter pw, Collection<Call> calls) { for (Call call : calls) { if (call != null) pw.println(call.getId()); Loading src/com/android/server/telecom/CallsManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ public class CallsManager extends Call.ListenerBase void onVideoStateChanged(Call call); void onCanAddCallChanged(boolean canAddCall); void onSessionModifyRequestReceived(Call call, VideoProfile videoProfile); void onHoldToneRequested(Call call); } private static final String TAG = "CallsManager"; Loading Loading @@ -524,11 +525,25 @@ public class CallsManager extends Call.ListenerBase } } @VisibleForTesting public Collection<Call> getCalls() { return Collections.unmodifiableCollection(mCalls); } /** * Play or stop a call hold tone for a call. Triggered via * {@link Connection#sendConnectionEvent(String)} when the * {@link Connection#EVENT_ON_HOLD_TONE_START} event or * {@link Connection#EVENT_ON_HOLD_TONE_STOP} event is passed through to the * * @param call The call which requested the hold tone. */ @Override public void onHoldToneRequested(Call call) { for (CallsManagerListener listener : mListeners) { listener.onHoldToneRequested(call); } } @VisibleForTesting public Call getForegroundCall() { if (mCallAudioManager == null) { Loading src/com/android/server/telecom/CallsManagerListenerBase.java +4 −0 Original line number Diff line number Diff line Loading @@ -80,4 +80,8 @@ public class CallsManagerListenerBase implements CallsManager.CallsManagerListen public void onSessionModifyRequestReceived(Call call, VideoProfile videoProfile) { } @Override public void onHoldToneRequested(Call call) { } } src/com/android/server/telecom/ConnectionServiceWrapper.java +17 −0 Original line number Diff line number Diff line Loading @@ -587,6 +587,23 @@ public class ConnectionServiceWrapper extends ServiceBinder { Log.endSession(); } } @Override public void onConnectionEvent(String callId, String event) { Log.startSession("CSW.oCE"); long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { Call call = mCallIdMapper.getCall(callId); if (call != null) { call.onConnectionEvent(event); } } } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } private final Adapter mAdapter = new Adapter(); Loading Loading
src/com/android/server/telecom/Call.java +44 −0 Original line number Diff line number Diff line Loading @@ -104,6 +104,7 @@ public class Call implements CreateConnectionResponse { void onPhoneAccountChanged(Call call); void onConferenceableCallsChanged(Call call); boolean onCanceledViaNewOutgoingCallBroadcast(Call call); void onHoldToneRequested(Call call); } public abstract static class ListenerBase implements Listener { Loading Loading @@ -161,6 +162,9 @@ public class Call implements CreateConnectionResponse { public boolean onCanceledViaNewOutgoingCallBroadcast(Call call) { return false; } @Override public void onHoldToneRequested(Call call) {} } private final OnQueryCompleteListener mCallerInfoQueryListener = Loading Loading @@ -365,6 +369,14 @@ public class Call implements CreateConnectionResponse { // Set to true once the NewOutgoingCallIntentBroadcast comes back and is processed. private boolean mIsNewOutgoingCallIntentBroadcastDone = false; /** * Indicates whether the call is remotely held. A call is considered remotely held when * {@link #onConnectionEvent(String)} receives the {@link Connection#EVENT_ON_HOLD_TONE_START} * event. */ private boolean mIsRemotelyHeld = false; /** * Persists the specified parameters and initializes the new instance. * Loading Loading @@ -1921,4 +1933,36 @@ public class Call implements CreateConnectionResponse { public void setNewOutgoingCallIntentBroadcastIsDone() { mIsNewOutgoingCallIntentBroadcastDone = true; } /** * Determines if the call has been held by the remote party. * * @return {@code true} if the call is remotely held, {@code false} otherwise. */ public boolean isRemotelyHeld() { return mIsRemotelyHeld; } /** * Handles Connection events received from a {@link ConnectionService}. * * @param event The event. */ public void onConnectionEvent(String event) { if (Connection.EVENT_ON_HOLD_TONE_START.equals(event)) { mIsRemotelyHeld = true; Log.event(this, Log.Events.REMOTELY_HELD); // Inform listeners of the fact that a call hold tone was received. This will trigger // the CallAudioManager to play a tone via the InCallTonePlayer. for (Listener l : mListeners) { l.onHoldToneRequested(this); } } else if (Connection.EVENT_ON_HOLD_TONE_END.equals(event)) { mIsRemotelyHeld = false; Log.event(this, Log.Events.REMOTELY_UNHELD); for (Listener l : mListeners) { l.onHoldToneRequested(this); } } } }
src/com/android/server/telecom/CallAudioManager.java +60 −0 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ public class CallAudioManager extends CallsManagerListenerBase { private Call mForegroundCall; private boolean mIsTonePlaying = false; private InCallTonePlayer mHoldTonePlayer; public CallAudioManager(CallAudioRouteStateMachine callAudioRouteStateMachine, CallsManager callsManager, Loading Loading @@ -213,6 +214,19 @@ public class CallAudioManager extends CallsManagerListenerBase { } } /** * Play or stop a call hold tone for a call. Triggered via * {@link Connection#sendConnectionEvent(String)} when the * {@link Connection#EVENT_ON_HOLD_TONE_START} event or * {@link Connection#EVENT_ON_HOLD_TONE_STOP} event is passed through to the * * @param call The call which requested the hold tone. */ @Override public void onHoldToneRequested(Call call) { maybePlayHoldTone(); } @Override public void onIsVoipAudioModeChanged(Call call) { if (call != mForegroundCall) { Loading Loading @@ -490,6 +504,7 @@ public class CallAudioManager extends CallsManagerListenerBase { if (mForegroundCall != oldForegroundCall) { mDtmfLocalTonePlayer.onForegroundCallChanged(oldForegroundCall, mForegroundCall); maybePlayHoldTone(); } } Loading Loading @@ -558,6 +573,51 @@ public class CallAudioManager extends CallsManagerListenerBase { mRingbackPlayer.stopRingbackForCall(call); } /** * Determines if a hold tone should be played and then starts or stops it accordingly. */ private void maybePlayHoldTone() { if (shouldPlayHoldTone()) { if (mHoldTonePlayer == null) { mHoldTonePlayer = mPlayerFactory.createPlayer(InCallTonePlayer.TONE_CALL_WAITING); mHoldTonePlayer.start(); } } else { if (mHoldTonePlayer != null) { mHoldTonePlayer.stopTone(); mHoldTonePlayer = null; } } } /** * Determines if a hold tone should be played. * A hold tone should be played only if foreground call is equals with call which is * remotely held. * * @return {@code true} if the the hold tone should be played, {@code false} otherwise. */ private boolean shouldPlayHoldTone() { Call foregroundCall = getForegroundCall(); // If there is no foreground call, no hold tone should play. if (foregroundCall == null) { return false; } // If another call is ringing, no hold tone should play. if (mCallsManager.hasRingingCall()) { return false; } // If the foreground call isn't active, no hold tone should play. This might happen, for // example, if the user puts a remotely held call on hold itself. if (!foregroundCall.isActive()) { return false; } return foregroundCall.isRemotelyHeld(); } private void dumpCallsInCollection(IndentingPrintWriter pw, Collection<Call> calls) { for (Call call : calls) { if (call != null) pw.println(call.getId()); Loading
src/com/android/server/telecom/CallsManager.java +16 −1 Original line number Diff line number Diff line Loading @@ -93,6 +93,7 @@ public class CallsManager extends Call.ListenerBase void onVideoStateChanged(Call call); void onCanAddCallChanged(boolean canAddCall); void onSessionModifyRequestReceived(Call call, VideoProfile videoProfile); void onHoldToneRequested(Call call); } private static final String TAG = "CallsManager"; Loading Loading @@ -524,11 +525,25 @@ public class CallsManager extends Call.ListenerBase } } @VisibleForTesting public Collection<Call> getCalls() { return Collections.unmodifiableCollection(mCalls); } /** * Play or stop a call hold tone for a call. Triggered via * {@link Connection#sendConnectionEvent(String)} when the * {@link Connection#EVENT_ON_HOLD_TONE_START} event or * {@link Connection#EVENT_ON_HOLD_TONE_STOP} event is passed through to the * * @param call The call which requested the hold tone. */ @Override public void onHoldToneRequested(Call call) { for (CallsManagerListener listener : mListeners) { listener.onHoldToneRequested(call); } } @VisibleForTesting public Call getForegroundCall() { if (mCallAudioManager == null) { Loading
src/com/android/server/telecom/CallsManagerListenerBase.java +4 −0 Original line number Diff line number Diff line Loading @@ -80,4 +80,8 @@ public class CallsManagerListenerBase implements CallsManager.CallsManagerListen public void onSessionModifyRequestReceived(Call call, VideoProfile videoProfile) { } @Override public void onHoldToneRequested(Call call) { } }
src/com/android/server/telecom/ConnectionServiceWrapper.java +17 −0 Original line number Diff line number Diff line Loading @@ -587,6 +587,23 @@ public class ConnectionServiceWrapper extends ServiceBinder { Log.endSession(); } } @Override public void onConnectionEvent(String callId, String event) { Log.startSession("CSW.oCE"); long token = Binder.clearCallingIdentity(); try { synchronized (mLock) { Call call = mCallIdMapper.getCall(callId); if (call != null) { call.onConnectionEvent(event); } } } finally { Binder.restoreCallingIdentity(token); Log.endSession(); } } } private final Adapter mAdapter = new Adapter(); Loading