Use mapped IDs for calls
With this CL each client gets a unique ID to represent calls.
This has a couple of benefits:
- avoids one client from modifying another clients call
- allows for stricter validation of input
- allows a call to handed off to a different call service
(with a different call ID)
Bug: 13643568
Change-Id: I6e2039aead5723d01f9442a4e54f5e616711a3b3
diff --git a/src/com/android/telecomm/RingbackPlayer.java b/src/com/android/telecomm/RingbackPlayer.java
index 5e0834f..df4d861 100644
--- a/src/com/android/telecomm/RingbackPlayer.java
+++ b/src/com/android/telecomm/RingbackPlayer.java
@@ -33,9 +33,9 @@
private final InCallTonePlayer.Factory mPlayerFactory;
/**
- * The ID of the current call for which the ringback tone is being played.
+ * The current call for which the ringback tone is being played.
*/
- private String mCallId;
+ private Call mCall;
/**
* The currently active player.
@@ -83,13 +83,13 @@
Preconditions.checkState(call.getState() == CallState.DIALING);
ThreadUtil.checkOnMainThread();
- if (mCallId != null) {
+ if (mCall != null) {
// We only get here for the foreground call so, there's no reason why there should
- // exist a current dialing call ID.
+ // exist a current dialing call.
Log.wtf(this, "Ringback player thinks there are two foreground-dialing calls.");
}
- mCallId = call.getId();
+ mCall = call;
if (mTonePlayer == null) {
Log.d(this, "Playing the ringback tone.");
mTonePlayer = mPlayerFactory.createPlayer(InCallTonePlayer.TONE_RING_BACK);
@@ -105,10 +105,10 @@
private void stopRingbackForCall(Call call) {
ThreadUtil.checkOnMainThread();
- if (mCallId != null && mCallId.equals(call.getId())) {
+ if (mCall == call) {
// The foreground call is no longer dialing or is no longer the foreground call. In
// either case, stop the ringback tone.
- mCallId = null;
+ mCall = null;
if (mTonePlayer == null) {
Log.w(this, "No player found to stop.");