Use callId for all call commands.
Change-Id: I988643cdaaffb1abf2689844d119d5e382b9791b
diff --git a/src/com/android/phone/CallModeler.java b/src/com/android/phone/CallModeler.java
index ee96dbf..01f571f 100644
--- a/src/com/android/phone/CallModeler.java
+++ b/src/com/android/phone/CallModeler.java
@@ -34,6 +34,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
+import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicInteger;
/**
@@ -116,6 +117,16 @@
return retval;
}
+ public CallResult getCallWithId(int callId) {
+ // max 8 connections, so this should be fast even through we are traversing the entire map.
+ for (Entry<Connection, Call> entry : mCallMap.entrySet()) {
+ if (entry.getValue().getCallId() == callId) {
+ return new CallResult(entry.getValue(), entry.getKey());
+ }
+ }
+ return null;
+ }
+
private void onNewRingingConnection(AsyncResult r) {
final Connection conn = (Connection) r.result;
final Call call = getCallFromConnection(conn, true);
@@ -249,4 +260,25 @@
void onDisconnect(Call call);
void onUpdate(List<Call> calls, boolean fullUpdate);
}
+
+ /**
+ * Result class for accessing a call by connection.
+ */
+ public static class CallResult {
+ public Call mCall;
+ public Connection mConnection;
+
+ private CallResult(Call call, Connection connection) {
+ mCall = call;
+ mConnection = connection;
+ }
+
+ public Call getCall() {
+ return mCall;
+ }
+
+ public Connection getConnection() {
+ return mConnection;
+ }
+ }
}