summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2016-03-17 18:34:27 -0700
committerThe Android Automerger <android-build@google.com>2016-03-18 15:22:39 -0700
commit66c3e63ea0033b4cc3cd775d67898ae02432a029 (patch)
treec940de301c1cd3d699bbd0b57fca31ea157aeae5
parent6ccc5132c4d4cdece42a17133069b406296ddb80 (diff)
downloadbase-66c3e63ea0033b4cc3cd775d67898ae02432a029.tar.gz
DO NOT MERGE Add new ConnectionEvent API (hide) to send a notification to Telecom
Connection event used to inform Telecom that it should play or stop the on hold tone. This is used to play or stop a tone when the peer puts the current call on hold. BUG=25357778 Change-Id: I2669f8f5062449784a712b9dd28e576326fcc679
-rw-r--r--telecomm/java/android/telecom/Connection.java32
-rw-r--r--telecomm/java/android/telecom/ConnectionService.java8
-rw-r--r--telecomm/java/android/telecom/ConnectionServiceAdapter.java16
-rw-r--r--telecomm/java/android/telecom/ConnectionServiceAdapterServant.java20
-rw-r--r--telecomm/java/android/telecom/RemoteConnection.java23
-rw-r--r--telecomm/java/android/telecom/RemoteConnectionService.java7
-rw-r--r--telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl2
7 files changed, 108 insertions, 0 deletions
diff --git a/telecomm/java/android/telecom/Connection.java b/telecomm/java/android/telecom/Connection.java
index 520a1d7254e7..d59adbe9f9c9 100644
--- a/telecomm/java/android/telecom/Connection.java
+++ b/telecomm/java/android/telecom/Connection.java
@@ -282,6 +282,24 @@ public abstract class Connection extends Conferenceable {
*/
public static final String EXTRA_CALL_SUBJECT = "android.telecom.extra.CALL_SUBJECT";
+ /**
+ * Connection event used to inform Telecom that it should play the on hold tone. This is used
+ * to play a tone when the peer puts the current call on hold. Sent to Telecom via
+ * {@link #sendConnectionEvent(String)}.
+ * @hide
+ */
+ public static final String EVENT_ON_HOLD_TONE_START =
+ "android.telecom.event.ON_HOLD_TONE_START";
+
+ /**
+ * Connection event used to inform Telecom that it should stop the on hold tone. This is used
+ * to stop a tone when the peer puts the current call on hold. Sent to Telecom via
+ * {@link #sendConnectionEvent(String)}.
+ * @hide
+ */
+ public static final String EVENT_ON_HOLD_TONE_END =
+ "android.telecom.event.ON_HOLD_TONE_END";
+
// Flag controlling whether PII is emitted into the logs
private static final boolean PII_DEBUG = Log.isLoggable(android.util.Log.DEBUG);
@@ -429,6 +447,8 @@ public abstract class Connection extends Conferenceable {
public void onConferenceStarted() {}
public void onConferenceMergeFailed(Connection c) {}
public void onExtrasChanged(Connection c, Bundle extras) {}
+ /** @hide */
+ public void onConnectionEvent(Connection c, String event) {}
}
/**
@@ -1944,4 +1964,16 @@ public abstract class Connection extends Conferenceable {
l.onConferenceStarted();
}
}
+
+ /**
+ * Sends a connection event to Telecom.
+ *
+ * @param event The connection event.
+ * @hide
+ */
+ protected void sendConnectionEvent(String event) {
+ for (Listener l : mListeners) {
+ l.onConnectionEvent(this, event);
+ }
+ }
}
diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java
index ceaa1bfb2754..dfe2396a3013 100644
--- a/telecomm/java/android/telecom/ConnectionService.java
+++ b/telecomm/java/android/telecom/ConnectionService.java
@@ -611,6 +611,14 @@ public abstract class ConnectionService extends Service {
mAdapter.setExtras(id, extras);
}
}
+
+ @Override
+ public void onConnectionEvent(Connection connection, String event) {
+ String id = mIdByConnection.get(connection);
+ if (id != null) {
+ mAdapter.onConnectionEvent(id, event);
+ }
+ }
};
/** {@inheritDoc} */
diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapter.java b/telecomm/java/android/telecom/ConnectionServiceAdapter.java
index 456251476862..30fc5ad1e4b6 100644
--- a/telecomm/java/android/telecom/ConnectionServiceAdapter.java
+++ b/telecomm/java/android/telecom/ConnectionServiceAdapter.java
@@ -412,4 +412,20 @@ final class ConnectionServiceAdapter implements DeathRecipient {
}
}
}
+
+ /**
+ * Informs Telecom of a connection level event.
+ *
+ * @param callId The unique ID of the call.
+ * @param event The event.
+ */
+ void onConnectionEvent(String callId, String event) {
+ Log.v(this, "onConnectionEvent: %s", event);
+ for (IConnectionServiceAdapter adapter : mAdapters) {
+ try {
+ adapter.onConnectionEvent(callId, event);
+ } catch (RemoteException ignored) {
+ }
+ }
+ }
}
diff --git a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java
index 293dc1199923..e69ad8ec5df8 100644
--- a/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java
+++ b/telecomm/java/android/telecom/ConnectionServiceAdapterServant.java
@@ -62,6 +62,7 @@ final class ConnectionServiceAdapterServant {
private static final int MSG_ON_POST_DIAL_CHAR = 22;
private static final int MSG_SET_CONFERENCE_MERGE_FAILED = 23;
private static final int MSG_SET_EXTRAS = 24;
+ private static final int MSG_ON_CONNECTION_EVENT = 25;
private final IConnectionServiceAdapter mDelegate;
@@ -239,6 +240,17 @@ final class ConnectionServiceAdapterServant {
} finally {
args.recycle();
}
+ break;
+ }
+
+ case MSG_ON_CONNECTION_EVENT: {
+ SomeArgs args = (SomeArgs) msg.obj;
+ try {
+ mDelegate.onConnectionEvent((String) args.arg1, (String) args.arg2);
+ } finally {
+ args.recycle();
+ }
+ break;
}
}
}
@@ -419,6 +431,14 @@ final class ConnectionServiceAdapterServant {
args.arg2 = extras;
mHandler.obtainMessage(MSG_SET_EXTRAS, args).sendToTarget();
}
+
+ @Override
+ public final void onConnectionEvent(String connectionId, String event) {
+ SomeArgs args = SomeArgs.obtain();
+ args.arg1 = connectionId;
+ args.arg2 = event;
+ mHandler.obtainMessage(MSG_ON_CONNECTION_EVENT, args).sendToTarget();
+ }
};
public ConnectionServiceAdapterServant(IConnectionServiceAdapter delegate) {
diff --git a/telecomm/java/android/telecom/RemoteConnection.java b/telecomm/java/android/telecom/RemoteConnection.java
index f9609590a697..01858080d7d7 100644
--- a/telecomm/java/android/telecom/RemoteConnection.java
+++ b/telecomm/java/android/telecom/RemoteConnection.java
@@ -209,6 +209,15 @@ public final class RemoteConnection {
* @param extras The extras containing other information associated with the connection.
*/
public void onExtrasChanged(RemoteConnection connection, @Nullable Bundle extras) {}
+
+ /**
+ * Handles a connection event propagated to this {@link RemoteConnection}.
+ *
+ * @param connection The {@code RemoteConnection} invoking this method.
+ * @param event The connection event.
+ * @hide
+ */
+ public void onConnectionEvent(RemoteConnection connection, String event) {}
}
/**
@@ -1291,6 +1300,20 @@ public final class RemoteConnection {
}
}
+ /** @hide */
+ void onConnectionEvent(final String event) {
+ for (CallbackRecord record : mCallbackRecords) {
+ final RemoteConnection connection = this;
+ final Callback callback = record.getCallback();
+ record.getHandler().post(new Runnable() {
+ @Override
+ public void run() {
+ callback.onConnectionEvent(connection, event);
+ }
+ });
+ }
+ }
+
/**
* Create a RemoteConnection represents a failure, and which will be in
* {@link Connection#STATE_DISCONNECTED}. Attempting to use it for anything will almost
diff --git a/telecomm/java/android/telecom/RemoteConnectionService.java b/telecomm/java/android/telecom/RemoteConnectionService.java
index dc0de0c462cf..b85382feae60 100644
--- a/telecomm/java/android/telecom/RemoteConnectionService.java
+++ b/telecomm/java/android/telecom/RemoteConnectionService.java
@@ -330,6 +330,13 @@ final class RemoteConnectionService {
.setExtras(extras);
}
}
+
+ @Override
+ public void onConnectionEvent(String callId, String event) {
+ if (mConnectionById.containsKey(callId)) {
+ findConnectionForAction(callId, "onConnectionEvent").onConnectionEvent(event);
+ }
+ }
};
private final ConnectionServiceAdapterServant mServant =
diff --git a/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl b/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl
index 76474447d191..569c24469368 100644
--- a/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl
+++ b/telecomm/java/com/android/internal/telecom/IConnectionServiceAdapter.aidl
@@ -86,4 +86,6 @@ oneway interface IConnectionServiceAdapter {
void addExistingConnection(String callId, in ParcelableConnection connection);
void setExtras(String callId, in Bundle extras);
+
+ void onConnectionEvent(String callId, String event);
}