Expose a meta-data value to allow dialer ringing
This CL exposes a new meta-data, IN_CALL_SERVICE_RINGING. If this is set
to true then ringing is played by the dialer instead of Telecom.
This CL also adds a new silenceRinger() API to InCallService. This is
needed to implement ringer silence on volume key down.
BUG: 22857261
Change-Id: I498538282eddbb727104f5b879f25adbef4e6cf6
diff --git a/telecomm/java/android/telecom/InCallService.java b/telecomm/java/android/telecom/InCallService.java
index 426b240..671399b 100644
--- a/telecomm/java/android/telecom/InCallService.java
+++ b/telecomm/java/android/telecom/InCallService.java
@@ -73,6 +73,7 @@
private static final int MSG_ON_CALL_AUDIO_STATE_CHANGED = 5;
private static final int MSG_BRING_TO_FOREGROUND = 6;
private static final int MSG_ON_CAN_ADD_CALL_CHANGED = 7;
+ private static final int MSG_SILENCE_RINGER = 8;
/** Default Handler used to consolidate binder method calls onto a single thread. */
private final Handler mHandler = new Handler(Looper.getMainLooper()) {
@@ -114,6 +115,9 @@
case MSG_ON_CAN_ADD_CALL_CHANGED:
mPhone.internalSetCanAddCall(msg.arg1 == 1);
break;
+ case MSG_SILENCE_RINGER:
+ mPhone.internalSilenceRinger();
+ break;
default:
break;
}
@@ -165,6 +169,11 @@
mHandler.obtainMessage(MSG_ON_CAN_ADD_CALL_CHANGED, canAddCall ? 1 : 0, 0)
.sendToTarget();
}
+
+ @Override
+ public void silenceRinger() {
+ mHandler.obtainMessage(MSG_SILENCE_RINGER).sendToTarget();
+ }
}
private Phone.Listener mPhoneListener = new Phone.Listener() {
@@ -202,6 +211,12 @@
InCallService.this.onCanAddCallChanged(canAddCall);
}
+ /** ${inheritDoc} */
+ @Override
+ public void onSilenceRinger(Phone phone) {
+ InCallService.this.onSilenceRinger();
+ }
+
};
private Phone mPhone;
@@ -405,6 +420,12 @@
}
/**
+ * Called to silence the ringer if a ringing call exists.
+ */
+ public void onSilenceRinger() {
+ }
+
+ /**
* Used to issue commands to the {@link Connection.VideoProvider} associated with a
* {@link Call}.
*/
diff --git a/telecomm/java/android/telecom/Phone.java b/telecomm/java/android/telecom/Phone.java
index 47154da..56eb7ec 100644
--- a/telecomm/java/android/telecom/Phone.java
+++ b/telecomm/java/android/telecom/Phone.java
@@ -97,6 +97,13 @@
* @param canAddCall Indicates whether an additional call can be added.
*/
public void onCanAddCallChanged(Phone phone, boolean canAddCall) { }
+
+ /**
+ * Called to silence the ringer if a ringing call exists.
+ *
+ * @param phone The {@code Phone} calling this method.
+ */
+ public void onSilenceRinger(Phone phone) { }
}
// A Map allows us to track each Call by its Telecom-specified call ID
@@ -179,6 +186,10 @@
}
}
+ final void internalSilenceRinger() {
+ fireSilenceRinger();
+ }
+
/**
* Called to destroy the phone and cleanup any lingering calls.
*/
@@ -330,6 +341,12 @@
}
}
+ private void fireSilenceRinger() {
+ for (Listener listener : mListeners) {
+ listener.onSilenceRinger(this);
+ }
+ }
+
private void checkCallTree(ParcelableCall parcelableCall) {
if (parcelableCall.getParentCallId() != null &&
!mCallByTelecomCallId.containsKey(parcelableCall.getParentCallId())) {
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 497864e8..72ff272 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -308,6 +308,15 @@
"android.telecom.IN_CALL_SERVICE_CAR_MODE_UI";
/**
+ * A boolean meta-data value indicating whether an {@link InCallService} implements ringing.
+ * Dialer implementations (see {@link #getDefaultDialerPackage()}) which would also like to
+ * override the system provided ringing should set this meta-data to {@code true} in the
+ * manifest registration of their {@link InCallService}.
+ */
+ public static final String METADATA_IN_CALL_SERVICE_RINGING =
+ "android.telecom.IN_CALL_SERVICE_RINGING";
+
+ /**
* The dual tone multi-frequency signaling character sent to indicate the dialing system should
* pause for a predefined period.
*/