summaryrefslogtreecommitdiffstats
path: root/telecomm
diff options
context:
space:
mode:
authorIhab Awad <ihab@google.com>2014-05-28 16:46:42 -0700
committerIhab Awad <ihab@google.com>2014-05-30 21:10:43 +0000
commitf835897f9f799490de27653ae39141ba6bc14223 (patch)
tree54de09ea326afbf272e6e01aabcf6117aeffec8d /telecomm
parent8d1de048d7612ec86ba01abc9f8b5eb7d2a2d6e2 (diff)
downloadframeworks_base-f835897f9f799490de27653ae39141ba6bc14223.zip
frameworks_base-f835897f9f799490de27653ae39141ba6bc14223.tar.gz
frameworks_base-f835897f9f799490de27653ae39141ba6bc14223.tar.bz2
DO NOT MERGE. Allow ConnectionService to ask Telecomm for ringback
Provides a pass-through from the ConnectionService API to Telecomm allowing a ConnectionService to either play the ringbacks on its own, or ask Telecomm to play the ringbacks on its behalf. Bug: 15190301 Change-Id: Ib0f2ce9bf798ec0df0e6d33559174c82de059a94
Diffstat (limited to 'telecomm')
-rw-r--r--telecomm/java/android/telecomm/CallServiceAdapter.java12
-rw-r--r--telecomm/java/android/telecomm/Connection.java52
-rw-r--r--telecomm/java/android/telecomm/ConnectionService.java7
-rw-r--r--telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl2
4 files changed, 68 insertions, 5 deletions
diff --git a/telecomm/java/android/telecomm/CallServiceAdapter.java b/telecomm/java/android/telecomm/CallServiceAdapter.java
index d5bb989..dafc310 100644
--- a/telecomm/java/android/telecomm/CallServiceAdapter.java
+++ b/telecomm/java/android/telecomm/CallServiceAdapter.java
@@ -156,5 +156,17 @@ public final class CallServiceAdapter {
}
}
+ /**
+ * Asks Telecomm to start or stop a ringback tone for a call.
+ *
+ * @param callId The unique ID of the call whose ringback is being changed.
+ * @param ringback Whether Telecomm should start playing a ringback tone.
+ */
+ public void setRequestingRingback(String callId, boolean ringback) {
+ try {
+ mAdapter.setRequestingRingback(callId, ringback);
+ } catch (RemoteException e) {
+ }
+ }
}
diff --git a/telecomm/java/android/telecomm/Connection.java b/telecomm/java/android/telecomm/Connection.java
index 88de17a..8cce8e6 100644
--- a/telecomm/java/android/telecomm/Connection.java
+++ b/telecomm/java/android/telecomm/Connection.java
@@ -33,6 +33,7 @@ public abstract class Connection {
void onHandleChanged(Connection c, Uri newHandle);
void onSignalChanged(Connection c, Bundle details);
void onDisconnected(Connection c, int cause, String message);
+ void onRequestingRingback(Connection c, boolean ringback);
void onDestroyed(Connection c);
}
@@ -60,6 +61,10 @@ public abstract class Connection {
/** {@inheritDoc} */
@Override
public void onDestroyed(Connection c) {}
+
+ /** {@inheritDoc} */
+ @Override
+ public void onRequestingRingback(Connection c, boolean ringback) {}
}
public final class State {
@@ -77,6 +82,7 @@ public abstract class Connection {
private int mState = State.NEW;
private CallAudioState mCallAudioState;
private Uri mHandle;
+ private boolean mRequestingRingback = false;
/**
* Create a new Connection.
@@ -268,6 +274,14 @@ public abstract class Connection {
}
/**
+ * @return Whether this connection is requesting that the system play a ringback tone
+ * on its behalf.
+ */
+ public boolean isRequestingRingback() {
+ return mRequestingRingback;
+ }
+
+ /**
* Sets the value of the {@link #getHandle()} property and notifies listeners.
*
* @param handle The new handle.
@@ -286,6 +300,7 @@ public abstract class Connection {
* communicate).
*/
protected void setActive() {
+ setRequestingRingback(false);
setState(State.ACTIVE);
}
@@ -329,6 +344,21 @@ public abstract class Connection {
}
/**
+ * Requests that the framework play a ringback tone. This is to be invoked by implementations
+ * that do not play a ringback tone themselves in the call's audio stream.
+ *
+ * @param ringback Whether the ringback tone is to be played.
+ */
+ protected void setRequestingRingback(boolean ringback) {
+ if (mRequestingRingback != ringback) {
+ mRequestingRingback = ringback;
+ for (Listener l : mListeners) {
+ l.onRequestingRingback(this, ringback);
+ }
+ }
+ }
+
+ /**
* Notifies this Connection and listeners that the {@link #getCallAudioState()} property
* has a new value.
*
@@ -336,7 +366,7 @@ public abstract class Connection {
*/
protected void onSetAudioState(CallAudioState state) {
// TODO: Enforce super called
- this.mCallAudioState = state;
+ mCallAudioState = state;
for (Listener l : mListeners) {
l.onAudioStateChanged(this, state);
}
@@ -356,6 +386,21 @@ public abstract class Connection {
}
/**
+ * Notifies this Connection of an internal state change. This method is called before the
+ * state is actually changed. Overriding implementations must call
+ * {@code super.onSetState(state)}.
+ *
+ * @param state The new state, a {@link Connection.State} member.
+ */
+ protected void onSetState(int state) {
+ // TODO: Enforce super called
+ this.mState = state;
+ for (Listener l : mListeners) {
+ l.onStateChanged(this, state);
+ }
+ }
+
+ /**
* Notifies this Connection of a request to play a DTMF tone.
*
* @param c A DTMF character.
@@ -401,9 +446,6 @@ public abstract class Connection {
private void setState(int state) {
Log.d(this, "setState: %s", stateToString(state));
- this.mState = state;
- for (Listener l : mListeners) {
- l.onStateChanged(this, state);
- }
+ onSetState(state);
}
}
diff --git a/telecomm/java/android/telecomm/ConnectionService.java b/telecomm/java/android/telecomm/ConnectionService.java
index 492b08e..8d02842 100644
--- a/telecomm/java/android/telecomm/ConnectionService.java
+++ b/telecomm/java/android/telecomm/ConnectionService.java
@@ -89,6 +89,13 @@ public abstract class ConnectionService extends CallService {
public void onDestroyed(Connection c) {
removeConnection(c);
}
+
+ @Override
+ public void onRequestingRingback(Connection c, boolean ringback) {
+ String id = mIdByConnection.get(c);
+ Log.d(this, "Adapter onRingback %b", ringback);
+ getAdapter().setRequestingRingback(id, ringback);
+ }
};
@Override
diff --git a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl
index dfdaa75..6d36494 100644
--- a/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl
+++ b/telecomm/java/com/android/internal/telecomm/ICallServiceAdapter.aidl
@@ -43,4 +43,6 @@ oneway interface ICallServiceAdapter {
void setDisconnected(String callId, int disconnectCause, String disconnectMessage);
void setOnHold(String callId);
+
+ void setRequestingRingback(String callId, boolean ringing);
}