Informs telecomm when the Phone object requests ringback
Cherry picked from branch lmp-preview-dev because checking the changes into master required an API update, whereas the relevant APIs are @hide-ed in the source branch.
Adds support so that, if the Phone object requests that ringback be played
by the application layer on its behalf, we pass that on to Telecomm.
Bug: 15190301
Change-Id: I33b65b55dc4176250dd7ae40f27f3522c5f2e86f
(cherry picked from commit 277011fcc6e34236718c1ebb04c2e0f11e9d857e)
diff --git a/src/com/android/phone/CallNotifier.java b/src/com/android/phone/CallNotifier.java
index 7fca845..dcb5567 100644
--- a/src/com/android/phone/CallNotifier.java
+++ b/src/com/android/phone/CallNotifier.java
@@ -345,7 +345,8 @@
break;
case CallStateMonitor.PHONE_RINGBACK_TONE:
- onRingbackTone((AsyncResult) msg.obj);
+ // DISABLED. The Telecomm and new ConnectionService layers are now responsible.
+ // onRingbackTone((AsyncResult) msg.obj);
break;
case CallStateMonitor.PHONE_RESEND_MUTE:
diff --git a/src/com/android/services/telephony/PstnConnection.java b/src/com/android/services/telephony/PstnConnection.java
index 1ad9b48..6f2c07f 100644
--- a/src/com/android/services/telephony/PstnConnection.java
+++ b/src/com/android/services/telephony/PstnConnection.java
@@ -16,6 +16,10 @@
package com.android.services.telephony;
+import android.os.AsyncResult;
+import android.os.Handler;
+import android.os.Message;
+
import android.telephony.DisconnectCause;
import com.android.internal.telephony.Call;
@@ -28,11 +32,33 @@
*/
public abstract class PstnConnection extends TelephonyConnection {
+ private static final int EVENT_RINGBACK_TONE = 1;
+
+ private final Handler mHandler = new Handler() {
+ private Connection getForegroundConnection() {
+ return mPhone.getForegroundCall().getEarliestConnection();
+ }
+
+ public void handleMessage(Message msg) {
+ // TODO: This code assumes that there is only one connection in the foreground call,
+ // in other words, it punts on network-mediated conference calling.
+ if (getOriginalConnection() != getForegroundConnection()) {
+ return;
+ }
+ switch (msg.what) {
+ case EVENT_RINGBACK_TONE:
+ setRequestingRingback((Boolean) ((AsyncResult) msg.obj).result);
+ break;
+ }
+ }
+ };
+
private final Phone mPhone;
public PstnConnection(Phone phone, Connection connection) {
super(connection);
mPhone = phone;
+ phone.registerForRingbackTone(mHandler, EVENT_RINGBACK_TONE, null);
}
/** {@inheritDoc} */
@@ -62,6 +88,13 @@
super.onReject();
}
+ /** {@inheritDoc} */
+ @Override
+ protected void onDisconnect() {
+ mPhone.unregisterForRingbackTone(mHandler);
+ super.onDisconnect();
+ }
+
protected Phone getPhone() {
return mPhone;
}