Remove handoff implementation
This CL removes the old handoff implementation. It also
plumbs the phoneAccountClicked event from InCallUI to the
call's ConnectionService.
Change-Id: Iab1595faaadcdfe428d97891d314babea21e9633
diff --git a/src/com/android/telecomm/Call.java b/src/com/android/telecomm/Call.java
index cb9353f..2be3355 100644
--- a/src/com/android/telecomm/Call.java
+++ b/src/com/android/telecomm/Call.java
@@ -194,21 +194,6 @@
/** Info used by the call services. */
private Bundle mExtras = Bundle.EMPTY;
- /** The Uri to dial to perform the handoff. If this is null then handoff is not supported. */
- private Uri mHandoffHandle;
-
- /**
- * References the call that is being handed off. This value is non-null for untracked calls
- * that are being used to perform a handoff.
- */
- private Call mOriginalCall;
-
- /**
- * The descriptor for the call service that this call is being switched to, null if handoff is
- * not in progress.
- */
- private CallServiceDescriptor mHandoffCallServiceDescriptor;
-
/** Set of listeners on this call. */
private Set<Listener> mListeners = Sets.newHashSet();
@@ -749,8 +734,6 @@
CallServiceDescriptor descriptor = null;
if (mCallService != null) {
descriptor = mCallService.getDescriptor();
- } else if (mOriginalCall != null && mOriginalCall.mCallService != null) {
- descriptor = mOriginalCall.mCallService.getDescriptor();
}
Bundle extras = mExtras;
if (mGatewayInfo != null && mGatewayInfo.getGatewayProviderPackageName() != null &&
@@ -800,30 +783,6 @@
mExtras = extras;
}
- Uri getHandoffHandle() {
- return mHandoffHandle;
- }
-
- void setHandoffHandle(Uri handoffHandle) {
- mHandoffHandle = handoffHandle;
- }
-
- Call getOriginalCall() {
- return mOriginalCall;
- }
-
- void setOriginalCall(Call originalCall) {
- mOriginalCall = originalCall;
- }
-
- CallServiceDescriptor getHandoffCallServiceDescriptor() {
- return mHandoffCallServiceDescriptor;
- }
-
- void setHandoffCallServiceDescriptor(CallServiceDescriptor descriptor) {
- mHandoffCallServiceDescriptor = descriptor;
- }
-
Uri getRingtone() {
return mCallerInfo == null ? null : mCallerInfo.contactRingtoneUri;
}
@@ -838,6 +797,10 @@
getCallService().onPostDialContinue(this, proceed);
}
+ void phoneAccountClicked() {
+ getCallService().onPhoneAccountClicked(this);
+ }
+
void conferenceInto(Call conferenceCall) {
if (mCallService == null) {
Log.w(this, "conference requested on a call without a call service.");
diff --git a/src/com/android/telecomm/CallServiceWrapper.java b/src/com/android/telecomm/CallServiceWrapper.java
index 5e0d9a8..1414e0a 100644
--- a/src/com/android/telecomm/CallServiceWrapper.java
+++ b/src/com/android/telecomm/CallServiceWrapper.java
@@ -74,10 +74,9 @@
private static final int MSG_CAN_CONFERENCE = 12;
private static final int MSG_SET_IS_CONFERENCED = 13;
private static final int MSG_ADD_CONFERENCE_CALL = 14;
- private static final int MSG_HANDOFF_CALL = 15;
- private static final int MSG_QUERY_REMOTE_CALL_SERVICES = 16;
- private static final int MSG_SET_CALL_VIDEO_PROVIDER = 17;
- private static final int MSG_SET_FEATURES = 18;
+ private static final int MSG_QUERY_REMOTE_CALL_SERVICES = 15;
+ private static final int MSG_SET_CALL_VIDEO_PROVIDER = 16;
+ private static final int MSG_SET_FEATURES = 17;
private final Handler mHandler = new Handler() {
@Override
@@ -219,14 +218,6 @@
}
break;
}
- case MSG_HANDOFF_CALL:
- call = mCallIdMapper.getCall(msg.obj);
- if (call != null) {
- mCallsManager.startHandoffForCall(call);
- } else {
- //Log.w(this, "handoffCall, unknown call id: %s", msg.obj);
- }
- break;
case MSG_CAN_CONFERENCE: {
call = mCallIdMapper.getCall(msg.obj);
if (call != null) {
@@ -465,14 +456,6 @@
mHandler.obtainMessage(MSG_ON_POST_DIAL_WAIT, args).sendToTarget();
}
- /** {@inheritDoc} */
- @Override
- public void handoffCall(String callId) {
- logIncoming("handoffCall %s", callId);
- mCallIdMapper.checkValidCallId(callId);
- mHandler.obtainMessage(MSG_HANDOFF_CALL, callId).sendToTarget();
- }
-
/** ${inheritDoc} */
@Override
public void queryRemoteConnectionServices(RemoteServiceCallback callback) {
@@ -750,6 +733,16 @@
}
}
+ void onPhoneAccountClicked(Call call) {
+ if (isServiceValid("onPhoneAccountClicked")) {
+ try {
+ logOutgoing("onPhoneAccountClicked %s", mCallIdMapper.getCallId(call));
+ mServiceInterface.onPhoneAccountClicked(mCallIdMapper.getCallId(call));
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
+
void conference(final Call conferenceCall, Call call) {
if (isServiceValid("conference")) {
try {
diff --git a/src/com/android/telecomm/CallsManager.java b/src/com/android/telecomm/CallsManager.java
index 0446f43..28e264a 100644
--- a/src/com/android/telecomm/CallsManager.java
+++ b/src/com/android/telecomm/CallsManager.java
@@ -51,15 +51,10 @@
void onCallAdded(Call call);
void onCallRemoved(Call call);
void onCallStateChanged(Call call, CallState oldState, CallState newState);
- void onCallHandoffHandleChanged(Call call, Uri oldHandle, Uri newHandle);
void onCallServiceChanged(
Call call,
CallServiceWrapper oldCallService,
CallServiceWrapper newCallService);
- void onCallHandoffCallServiceDescriptorChanged(
- Call call,
- CallServiceDescriptor oldDescriptor,
- CallServiceDescriptor newDescriptor);
void onIncomingCallAnswered(Call call);
void onIncomingCallRejected(Call call, boolean rejectWithMessage, String textMessage);
void onForegroundCallChanged(Call oldForegroundCall, Call newForegroundCall);
@@ -80,13 +75,6 @@
*/
private final Set<Call> mCalls = new LinkedHashSet<>();
- /**
- * Set of new calls created to perform a handoff. The calls are added when handoff is initiated
- * and removed when hadnoff is complete.
- */
- private final Set<Call> mPendingHandoffCalls = new LinkedHashSet<>();
-
-
private final DtmfLocalTonePlayer mDtmfLocalTonePlayer = new DtmfLocalTonePlayer();
private final InCallController mInCallController = new InCallController();
private final CallAudioManager mCallAudioManager;
@@ -139,9 +127,6 @@
for (CallsManagerListener listener : mListeners) {
listener.onCallServiceChanged(call, null, call.getCallService());
}
- } else if (mPendingHandoffCalls.contains(call)) {
- updateHandoffCallServiceDescriptor(call.getOriginalCall(),
- call.getCallService().getDescriptor());
} else {
Log.wtf(this, "unexpected successful call notification: %s", call);
return;
@@ -478,33 +463,12 @@
mCallAudioManager.setAudioRoute(route);
}
- void startHandoffForCall(Call originalCall) {
- if (!mCalls.contains(originalCall)) {
- Log.w(this, "Unknown call %s asked to be handed off", originalCall);
- return;
+ void phoneAccountClicked(Call call) {
+ if (!mCalls.contains(call)) {
+ Log.i(this, "phoneAccountClicked in a non-existent call %s", call);
+ } else {
+ call.phoneAccountClicked();
}
-
- for (Call handoffCall : mPendingHandoffCalls) {
- if (handoffCall.getOriginalCall() == originalCall) {
- Log.w(this, "Call %s is already being handed off, skipping", originalCall);
- return;
- }
- }
-
- // Create a new call to be placed in the background. If handoff is successful then the
- // original call will live on but its state will be updated to the new call's state. In
- // particular the original call's call service will be updated to the new call's call
- // service.
- Call tempCall = new Call(
- originalCall.getHandoffHandle(), originalCall.getGatewayInfo(),
- originalCall.getAccount(), false, false);
- tempCall.setOriginalCall(originalCall);
- tempCall.setExtras(originalCall.getExtras());
- mPendingHandoffCalls.add(tempCall);
- tempCall.addListener(this);
-
- Log.d(this, "Placing handoff call");
- tempCall.startOutgoing();
}
/** Called when the audio state changes. */
@@ -529,9 +493,6 @@
}
setCallState(call, CallState.ACTIVE);
- if (mPendingHandoffCalls.contains(call)) {
- completeHandoff(call, true);
- }
if (call.getStartWithSpeakerphoneOn()) {
setAudioRoute(CallAudioState.ROUTE_SPEAKER);
}
@@ -551,33 +512,7 @@
void markCallAsDisconnected(Call call, int disconnectCause, String disconnectMessage) {
call.setDisconnectCause(disconnectCause, disconnectMessage);
setCallState(call, CallState.DISCONNECTED);
-
- // Only remove the call if handoff is not pending.
- if (call.getHandoffCallServiceDescriptor() == null) {
- removeCall(call);
- }
- }
-
- void setHandoffInfo(Call call, Uri handle, Bundle extras) {
- if (!mCalls.contains(call)) {
- Log.w(this, "Unknown call (%s) asked to set handoff info", call);
- return;
- }
-
- if (extras == null) {
- call.setExtras(Bundle.EMPTY);
- } else {
- call.setExtras(extras);
- }
-
- Uri oldHandle = call.getHandoffHandle();
- Log.v(this, "set handoff handle %s -> %s, for call: %s", oldHandle, handle, call);
- if (!areUriEqual(oldHandle, handle)) {
- call.setHandoffHandle(handle);
- for (CallsManagerListener listener : mListeners) {
- listener.onCallHandoffHandleChanged(call, oldHandle, handle);
- }
- }
+ removeCall(call);
}
/**
@@ -692,8 +627,6 @@
}
private void removeCall(Call call) {
- // If a handoff is pending then the original call shouldn't be removed.
- Preconditions.checkState(call.getHandoffCallServiceDescriptor() == null);
Log.v(this, "removeCall(%s)", call);
call.removeListener(this);
@@ -703,9 +636,6 @@
if (mCalls.contains(call)) {
mCalls.remove(call);
shouldNotify = true;
- } else if (mPendingHandoffCalls.contains(call)) {
- Log.v(this, "removeCall, marking handoff call as failed");
- completeHandoff(call, false);
}
// Only broadcast changes for calls that are being tracked.
@@ -781,56 +711,6 @@
}
}
- private void completeHandoff(Call handoffCall, boolean wasSuccessful) {
- Call originalCall = handoffCall.getOriginalCall();
- Log.v(this, "complete handoff, %s -> %s, wasSuccessful: %b", handoffCall, originalCall,
- wasSuccessful);
-
- // Remove the transient handoff call object (don't disconnect because the call could still
- // be live).
- mPendingHandoffCalls.remove(handoffCall);
- handoffCall.removeListener(this);
-
- if (wasSuccessful) {
- if (TelephonyUtil.isCurrentlyPSTNCall(originalCall)) {
- originalCall.disconnect();
- }
-
- // Synchronize.
- originalCall.setCallService(handoffCall.getCallService(), handoffCall);
- setCallState(originalCall, handoffCall.getState());
-
- // Force the foreground call changed notification to be sent.
- for (CallsManagerListener listener : mListeners) {
- listener.onForegroundCallChanged(mForegroundCall, mForegroundCall);
- }
-
- updateHandoffCallServiceDescriptor(originalCall, null);
- } else {
- updateHandoffCallServiceDescriptor(originalCall, null);
- if (originalCall.getState() == CallState.DISCONNECTED ||
- originalCall.getState() == CallState.ABORTED) {
- removeCall(originalCall);
- }
- }
- }
-
- private void updateHandoffCallServiceDescriptor(
- Call originalCall,
- CallServiceDescriptor newDescriptor) {
- CallServiceDescriptor oldDescriptor = originalCall.getHandoffCallServiceDescriptor();
- Log.v(this, "updateHandoffCallServiceDescriptor, call: %s, pending descriptor: %s -> %s",
- originalCall, oldDescriptor, newDescriptor);
-
- if (!areDescriptorsEqual(oldDescriptor, newDescriptor)) {
- originalCall.setHandoffCallServiceDescriptor(newDescriptor);
- for (CallsManagerListener listener : mListeners) {
- listener.onCallHandoffCallServiceDescriptorChanged(originalCall, oldDescriptor,
- newDescriptor);
- }
- }
- }
-
private static boolean areDescriptorsEqual(
CallServiceDescriptor descriptor1,
CallServiceDescriptor descriptor2) {
diff --git a/src/com/android/telecomm/CallsManagerListenerBase.java b/src/com/android/telecomm/CallsManagerListenerBase.java
index 8b03eee..a5320a4 100644
--- a/src/com/android/telecomm/CallsManagerListenerBase.java
+++ b/src/com/android/telecomm/CallsManagerListenerBase.java
@@ -38,10 +38,6 @@
}
@Override
- public void onCallHandoffHandleChanged(Call call, Uri oldHandle, Uri newHandle) {
- }
-
- @Override
public void onCallServiceChanged(
Call call,
CallServiceWrapper oldCallServiceWrapper,
@@ -49,13 +45,6 @@
}
@Override
- public void onCallHandoffCallServiceDescriptorChanged(
- Call call,
- CallServiceDescriptor oldDescriptor,
- CallServiceDescriptor newDescriptor) {
- }
-
- @Override
public void onIncomingCallAnswered(Call call) {
}
diff --git a/src/com/android/telecomm/InCallAdapter.java b/src/com/android/telecomm/InCallAdapter.java
index 7937e95..40bb61d 100644
--- a/src/com/android/telecomm/InCallAdapter.java
+++ b/src/com/android/telecomm/InCallAdapter.java
@@ -36,7 +36,7 @@
private static final int MSG_DISCONNECT_CALL = 5;
private static final int MSG_HOLD_CALL = 6;
private static final int MSG_UNHOLD_CALL = 7;
- private static final int MSG_HANDOFF_CALL = 8;
+ private static final int MSG_PHONE_ACCOUNT_CLICKED = 8;
private static final int MSG_MUTE = 9;
private static final int MSG_SET_AUDIO_ROUTE = 10;
private static final int MSG_CONFERENCE = 11;
@@ -120,12 +120,12 @@
Log.w(this, "unholdCall, unknown call id: %s", msg.obj);
}
break;
- case MSG_HANDOFF_CALL:
+ case MSG_PHONE_ACCOUNT_CLICKED:
call = mCallIdMapper.getCall(msg.obj);
if (call != null) {
- mCallsManager.startHandoffForCall(call);
+ mCallsManager.phoneAccountClicked(call);
} else {
- Log.w(this, "startHandoffForCall, unknown call id: %s", msg.obj);
+ Log.w(this, "phoneAccountClicked, unknown call id: %s", msg.obj);
}
break;
case MSG_MUTE:
@@ -234,9 +234,9 @@
/** {@inheritDoc} */
@Override
- public void handoffCall(String callId) {
+ public void phoneAccountClicked(String callId) {
mCallIdMapper.checkValidCallId(callId);
- mHandler.obtainMessage(MSG_HANDOFF_CALL, callId).sendToTarget();
+ mHandler.obtainMessage(MSG_PHONE_ACCOUNT_CLICKED, callId).sendToTarget();
}
/** {@inheritDoc} */
diff --git a/src/com/android/telecomm/InCallController.java b/src/com/android/telecomm/InCallController.java
index 9b53609..c1c8eaf 100644
--- a/src/com/android/telecomm/InCallController.java
+++ b/src/com/android/telecomm/InCallController.java
@@ -103,11 +103,6 @@
}
@Override
- public void onCallHandoffHandleChanged(Call call, Uri oldHandle, Uri newHandle) {
- updateCall(call);
- }
-
- @Override
public void onCallServiceChanged(
Call call,
CallServiceWrapper oldCallServiceWrapper,
@@ -116,14 +111,6 @@
}
@Override
- public void onCallHandoffCallServiceDescriptorChanged(
- Call call,
- CallServiceDescriptor oldDescriptor,
- CallServiceDescriptor newDescriptor) {
- updateCall(call);
- }
-
- @Override
public void onAudioStateChanged(CallAudioState oldAudioState, CallAudioState newAudioState) {
if (mInCallService != null) {
Log.i(this, "Calling onAudioStateChanged, audioState: %s -> %s", oldAudioState,
@@ -277,11 +264,7 @@
CallServiceDescriptor descriptor =
call.getCallService() != null ? call.getCallService().getDescriptor() : null;
- boolean isHandoffCapable = call.getHandoffHandle() != null;
int capabilities = CallCapabilities.HOLD | CallCapabilities.MUTE;
- if (call.getHandoffHandle() != null) {
- capabilities |= CallCapabilities.CONNECTION_HANDOFF;
- }
if (CallsManager.getInstance().isAddCallCapable(call)) {
capabilities |= CallCapabilities.ADD_CALL;
}
@@ -292,10 +275,6 @@
if (state == CallState.ABORTED) {
state = CallState.DISCONNECTED;
}
- // TODO(sail): Remove this and replace with final reconnecting code.
- if (state == CallState.DISCONNECTED && call.getHandoffCallServiceDescriptor() != null) {
- state = CallState.ACTIVE;
- }
String parentCallId = null;
Call parentCall = call.getParentCall();
@@ -320,8 +299,7 @@
return new InCallCall(callId, state, call.getDisconnectCause(), call.getDisconnectMessage(),
call.getCannedSmsResponses(), capabilities, connectTimeMillis, call.getHandle(),
- call.getGatewayInfo(), call.getAccount(), descriptor,
- call.getHandoffCallServiceDescriptor(), call.getCallVideoProvider(),
+ call.getGatewayInfo(), call.getAccount(), descriptor, call.getCallVideoProvider(),
parentCallId, childCallIds, call.getFeatures());
}