summaryrefslogtreecommitdiff
path: root/InCallUI
diff options
context:
space:
mode:
authorSantos Cordon <santoscordon@google.com>2014-01-30 05:51:06 -0800
committerBaligh Uddin <baligh@google.com>2014-02-20 15:06:55 -0800
commitdd81d5dcff06d1ea940051fd535adeecae63a746 (patch)
tree256d1a63cfc700c8d829107a97cbbf10be816714 /InCallUI
parentc07366f82b7a38f48f1f17c3f7b9b274e4d36b34 (diff)
OutgoingCalls(4/6) - Connecting the in-call disconnect button with Telecomm.
In-call app now sends appropriate disconnect command when user clicks the end-call button. Change-Id: I3da99827ce068566ca9e72d69c0375f0409a8014
Diffstat (limited to 'InCallUI')
-rw-r--r--InCallUI/src/com/android/incallui/CallButtonPresenter.java16
-rw-r--r--InCallUI/src/com/android/incallui/CallInfoTranslator.java36
-rw-r--r--InCallUI/src/com/android/incallui/InCallPresenter.java12
-rw-r--r--InCallUI/src/com/android/incallui/InCallService.java21
4 files changed, 65 insertions, 20 deletions
diff --git a/InCallUI/src/com/android/incallui/CallButtonPresenter.java b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
index 104da6d94..3f3e0fad3 100644
--- a/InCallUI/src/com/android/incallui/CallButtonPresenter.java
+++ b/InCallUI/src/com/android/incallui/CallButtonPresenter.java
@@ -32,6 +32,8 @@ import com.android.services.telephony.common.Call;
import com.android.services.telephony.common.Call.Capabilities;
import android.app.Fragment;
+import android.os.RemoteException;
+import android.telecomm.IInCallAdapter;
/**
* Logic for call buttons.
@@ -195,6 +197,20 @@ public class CallButtonPresenter extends Presenter<CallButtonPresenter.CallButto
}
CallCommandClient.getInstance().disconnectCall(mCall.getCallId());
+
+ // Notify Telecomm that the user hit end-call.
+ IInCallAdapter telecommAdapter = InCallPresenter.getInstance().getTelecommAdapter();
+ if (telecommAdapter != null) {
+ String callId = CallInfoTranslator.getTelecommCallId(mCall);
+ if (callId != null) {
+ try {
+ Log.i(this, "Disconnecting the call: " + callId);
+ telecommAdapter.disconnectCall(callId);
+ } catch (RemoteException e) {
+ Log.e(this, "Failed to send disconnect command.", e);
+ }
+ }
+ }
}
public void manageConferenceButtonClicked() {
diff --git a/InCallUI/src/com/android/incallui/CallInfoTranslator.java b/InCallUI/src/com/android/incallui/CallInfoTranslator.java
index be68c0237..ba44c450b 100644
--- a/InCallUI/src/com/android/incallui/CallInfoTranslator.java
+++ b/InCallUI/src/com/android/incallui/CallInfoTranslator.java
@@ -21,7 +21,8 @@ import android.telecomm.CallInfo;
import com.android.services.telephony.common.Call;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
-import com.google.common.collect.Maps;
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
import java.util.Map;
@@ -29,17 +30,17 @@ import java.util.Map;
* Translates {@link CallInfo} objects into {@link Call} objects so that call-infos received from
* Telecomm can be used easily with {@link CallList}. Manages Telecomm call ID to {@link Call}
* mappings. This class uses IDs for both {@link Call} objects and {@link CallInfo} objects which
- * are both normally referred to as "call id". To distinguish the two, the code and comments refer
+ * are both normally referred to as "call ID". To distinguish the two, the code and comments refer
* to them as "call ID" and "Telecomm call ID" respectively.
* TODO(santoscordon): This class is a temporary solution until all calls are coming in through
* Telecomm at which point we can rewrite the standard Call object format.
*/
final class CallInfoTranslator {
/**
- * Maps String-based Telecomm call IDs to call objects. Entries are added with calls to
+ * Maps String-based Telecomm call IDs to call objects and back. Entries are added with calls to
* {@link #getCall} and removed with explicit calls to {@link #removeCall}.
*/
- private static final Map<String, Call> sCallsById = Maps.newHashMap();
+ private static final BiMap<String, Call> sCallsByTelecommId = HashBiMap.create();
/**
* Stores the next available ID usable by Call objects. IDs start at 100000 and increase by one
@@ -58,9 +59,11 @@ final class CallInfoTranslator {
* @param callInfo The call-info object from which to create a Call.
*/
static Call getCall(CallInfo callInfo) {
- Call call = getCall(callInfo.getId());
+ String telecommCallId = callInfo.getId();
+ Call call = getCall(telecommCallId);
if (call == null) {
call = new Call(sNextAvailableCallId++);
+ sCallsByTelecommId.put(telecommCallId, call);
}
// TODO(santoscordon): Remove assumption that all calls are dialing by default once
@@ -72,20 +75,25 @@ final class CallInfoTranslator {
}
/**
- * Returns the call which maps from the specified Telecomm call ID. If no call was previously
- * associated with the specified ID then return null.
+ * Returns the call which maps from the specified Telecomm call ID.
*
* @param telecommCallId The Telecomm call ID to map.
- * @return The call associated with the specified Telecomm call ID.
+ * @return The call associated with the specified Telecomm call ID, or null if no association
+ * exists.
*/
static Call getCall(String telecommCallId) {
Preconditions.checkState(!Strings.isNullOrEmpty(telecommCallId));
+ return sCallsByTelecommId.get(telecommCallId);
+ }
- if (sCallsById.containsKey(telecommCallId)) {
- return sCallsById.get(telecommCallId);
- }
-
- return null;
+ /**
+ * Returns the Telecomm call ID for the given call object.
+ *
+ * @param call The call object associated with the Telecomm call ID.
+ * @return The telecomm call ID or null if it cannot be found.
+ */
+ static String getTelecommCallId(Call call) {
+ return sCallsByTelecommId.inverse().get(call);
}
/**
@@ -94,6 +102,6 @@ final class CallInfoTranslator {
* @param telecommCallId The Telecomm call ID to remove.
*/
static void removeCall(String telecommCallId) {
- sCallsById.remove(telecommCallId);
+ sCallsByTelecommId.remove(telecommCallId);
}
}
diff --git a/InCallUI/src/com/android/incallui/InCallPresenter.java b/InCallUI/src/com/android/incallui/InCallPresenter.java
index 98393cf90..16d22ed14 100644
--- a/InCallUI/src/com/android/incallui/InCallPresenter.java
+++ b/InCallUI/src/com/android/incallui/InCallPresenter.java
@@ -58,7 +58,7 @@ public class InCallPresenter implements CallList.Listener {
private boolean mServiceConnected = false;
/** Used to send call-related commands and updates back to Telecomm. */
- private IInCallAdapter mInCallAdapter;
+ private IInCallAdapter mTelecommAdapter;
/**
* Is true when the activity has been previously started. Some code needs to know not just if
@@ -528,10 +528,14 @@ public class InCallPresenter implements CallList.Listener {
/**
* Persists the current instance of IInCallAdapter.
*
- * @param inCallAdapter The adapter to Telecomm system used to send call-related commands.
+ * @param telecommAdapter The adapter to the Telecomm system used to send call-related commands.
*/
- void setInCallAdapter(IInCallAdapter inCallAdapter) {
- mInCallAdapter = inCallAdapter;
+ void setTelecommAdapter(IInCallAdapter telecommAdapter) {
+ mTelecommAdapter = telecommAdapter;
+ }
+
+ IInCallAdapter getTelecommAdapter() {
+ return mTelecommAdapter;
}
/**
diff --git a/InCallUI/src/com/android/incallui/InCallService.java b/InCallUI/src/com/android/incallui/InCallService.java
index 5a975b075..113072d61 100644
--- a/InCallUI/src/com/android/incallui/InCallService.java
+++ b/InCallUI/src/com/android/incallui/InCallService.java
@@ -41,11 +41,14 @@ public class InCallService extends Service {
* {@link CallList} which in turn will trigger UI activity.
*/
private class InCallServiceBinder extends IInCallService.Stub {
- /** {@inheritDoc} */
+ /**
+ * TODO(santoscordon): Rename this to setTelecommAdapter.
+ * {@inheritDoc}
+ */
@Override public void setInCallAdapter(final IInCallAdapter inCallAdapter) {
mHandler.post(new Runnable() {
@Override public void run() {
- InCallPresenter.getInstance().setInCallAdapter(inCallAdapter);
+ InCallPresenter.getInstance().setTelecommAdapter(inCallAdapter);
}
});
}
@@ -100,4 +103,18 @@ public class InCallService extends Service {
@Override public IBinder onBind(Intent intent) {
return mBinder;
}
+
+ /** {@inheritDoc} */
+ @Override public void onCreate() {
+ InCallPresenter inCallPresenter = InCallPresenter.getInstance();
+ inCallPresenter.setUp(
+ getApplicationContext(), CallList.getInstance(), AudioModeProvider.getInstance());
+ }
+
+ /** {@inheritDoc} */
+ @Override public void onDestroy() {
+ // Tear down the InCall system
+ CallList.getInstance().clearOnDisconnect();
+ InCallPresenter.getInstance().tearDown();
+ }
}