Support for showing self-managed calls in IncallService.
Also added new isInManagedCall TelecomManager API, used to determine if
there are ongoing managed calls only.
Test: Manual, cts
Bug: 34159263
Change-Id: Ib8020617607ccb433c2eee9b9d5a2c929665214b
diff --git a/telecomm/java/android/telecom/Call.java b/telecomm/java/android/telecom/Call.java
index c69b7c2..f129c33 100644
--- a/telecomm/java/android/telecom/Call.java
+++ b/telecomm/java/android/telecom/Call.java
@@ -312,8 +312,15 @@
*/
public static final int PROPERTY_HAS_CDMA_VOICE_PRIVACY = 0x00000080;
+ /**
+ * Indicates that the call is from a self-managed {@link ConnectionService}.
+ * <p>
+ * See also {@link Connection#PROPERTY_SELF_MANAGED}
+ */
+ public static final int PROPERTY_SELF_MANAGED = 0x00000100;
+
//******************************************************************************************
- // Next PROPERTY value: 0x00000100
+ // Next PROPERTY value: 0x00000200
//******************************************************************************************
private final String mTelecomCallId;
diff --git a/telecomm/java/android/telecom/TelecomManager.java b/telecomm/java/android/telecom/TelecomManager.java
index 96070b8..5ce9c50 100644
--- a/telecomm/java/android/telecom/TelecomManager.java
+++ b/telecomm/java/android/telecom/TelecomManager.java
@@ -356,6 +356,24 @@
"android.telecom.INCLUDE_EXTERNAL_CALLS";
/**
+ * A boolean meta-data value indicating whether an {@link InCallService} wants to be informed of
+ * calls which have the {@link Call.Details#PROPERTY_SELF_MANAGED} property. A self-managed
+ * call is one which originates from a self-managed {@link ConnectionService} which has chosen
+ * to implement its own call user interface. An {@link InCallService} implementation which
+ * would like to be informed of external calls should set this meta-data to {@code true} in the
+ * manifest registration of their {@link InCallService}. By default, the {@link InCallService}
+ * will NOT be informed about self-managed calls.
+ * <p>
+ * An {@link InCallService} which receives self-managed calls is free to view and control the
+ * state of calls in the self-managed {@link ConnectionService}. An example use-case is
+ * exposing these calls to a wearable or automotive device via its companion app.
+ * <p>
+ * See also {@link Connection#PROPERTY_SELF_MANAGED}.
+ */
+ public static final String METADATA_INCLUDE_SELF_MANAGED_CALLS =
+ "android.telecom.INCLUDE_SELF_MANAGED_CALLS";
+
+ /**
* The dual tone multi-frequency signaling character sent to indicate the dialing system should
* pause for a predefined period.
*/
@@ -1034,10 +1052,12 @@
/**
* Returns whether there is an ongoing phone call (can be in dialing, ringing, active or holding
- * states).
+ * states) originating from either a manager or self-managed {@link ConnectionService}.
* <p>
* Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
- * </p>
+ *
+ * @return {@code true} if there is an ongoing call in either a managed or self-managed
+ * {@link ConnectionService}, {@code false} otherwise.
*/
@RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
public boolean isInCall() {
@@ -1052,6 +1072,31 @@
}
/**
+ * Returns whether there is an ongoing call originating from a managed
+ * {@link ConnectionService}. An ongoing call can be in dialing, ringing, active or holding
+ * states.
+ * <p>
+ * If you also need to know if there are ongoing self-managed calls, use {@link #isInCall()}
+ * instead.
+ * <p>
+ * Requires permission: {@link android.Manifest.permission#READ_PHONE_STATE}
+ *
+ * @return {@code true} if there is an ongoing call in a managed {@link ConnectionService},
+ * {@code false} otherwise.
+ */
+ @RequiresPermission(android.Manifest.permission.READ_PHONE_STATE)
+ public boolean isInManagedCall() {
+ try {
+ if (isServiceConnected()) {
+ return getTelecomService().isInManagedCall(mContext.getOpPackageName());
+ }
+ } catch (RemoteException e) {
+ Log.e(TAG, "RemoteException calling isInManagedCall().", e);
+ }
+ return false;
+ }
+
+ /**
* Returns one of the following constants that represents the current state of Telecom:
*
* {@link TelephonyManager#CALL_STATE_RINGING}
@@ -1062,6 +1107,9 @@
* {@link android.Manifest.permission#READ_PHONE_STATE} permission. This is intentional, to
* preserve the behavior of {@link TelephonyManager#getCallState()}, which also did not require
* the permission.
+ *
+ * Takes into consideration both managed and self-managed calls.
+ *
* @hide
*/
@SystemApi
@@ -1079,6 +1127,7 @@
/**
* Returns whether there currently exists is a ringing incoming-call.
*
+ * @return {@code true} if there is a managed or self-managed ringing call.
* @hide
*/
@SystemApi