From bc9976e7497106c2b21321b8d4972faa98cf7bc0 Mon Sep 17 00:00:00 2001 From: Jack He Date: Fri, 5 Jan 2018 17:17:06 -0800 Subject: [PATCH] HFP: Add isInbandRingingEnabled() API (1/4) * Use BluetoothHeadset.isInbandRingingEnabled() API to check whether in-band ringing is currently enabled in the system when deciding on audio routes for ringtone * Add this as a hidden internal API for system components Bug: 71646213 Test: make, toggle in-band ringing from Development Settings and observe whether Telecom service tries to open SCO when there is an incoming call Change-Id: I1ef0dd2b54ace7649ddd1f043f0ef5847743a5c4 --- .../android/bluetooth/BluetoothHeadset.java | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/core/java/android/bluetooth/BluetoothHeadset.java b/core/java/android/bluetooth/BluetoothHeadset.java index 55a6b4c6b4d4e..c94540a48ec1b 100644 --- a/core/java/android/bluetooth/BluetoothHeadset.java +++ b/core/java/android/bluetooth/BluetoothHeadset.java @@ -1071,9 +1071,35 @@ public final class BluetoothHeadset implements BluetoothProfile { } /** - * check if in-band ringing is supported for this platform. + * Check if in-band ringing is currently enabled. In-band ringing could be disabled during an + * active connection. * - * @return true if in-band ringing is supported false if in-band ringing is not supported + * @return true if in-band ringing is enabled, false if in-band ringing is disabled + * @hide + */ + @RequiresPermission(android.Manifest.permission.BLUETOOTH) + public boolean isInbandRingingEnabled() { + if (DBG) { + log("isInbandRingingEnabled()"); + } + final IBluetoothHeadset service = mService; + if (service != null && isEnabled()) { + try { + return service.isInbandRingingEnabled(); + } catch (RemoteException e) { + Log.e(TAG, Log.getStackTraceString(new Throwable())); + } + } + if (service == null) { + Log.w(TAG, "Proxy not attached to service"); + } + return false; + } + + /** + * Check if in-band ringing is supported for this platform. + * + * @return true if in-band ringing is supported, false if in-band ringing is not supported * @hide */ public static boolean isInbandRingingSupported(Context context) {