ALOGI("%s: succeeds", __func__);
}
-static void initializeNative(JNIEnv* env, jobject object, jint max_hf_clients) {
+static void initializeNative(JNIEnv* env, jobject object, jint max_hf_clients,
+ jboolean inband_ringing_support) {
const bt_interface_t* btInf = getBluetoothInterface();
if (btInf == NULL) {
ALOGE("Bluetooth module is not loaded");
return;
}
- bt_status_t status =
- sBluetoothHfpInterface->init(&sBluetoothHfpCallbacks, max_hf_clients);
+ bt_status_t status = sBluetoothHfpInterface->init(
+ &sBluetoothHfpCallbacks, max_hf_clients, inband_ringing_support);
if (status != BT_STATUS_SUCCESS) {
ALOGE("Failed to initialize Bluetooth HFP, status: %d", status);
sBluetoothHfpInterface = NULL;
static JNINativeMethod sMethods[] = {
{"classInitNative", "()V", (void*)classInitNative},
- {"initializeNative", "(I)V", (void*)initializeNative},
+ {"initializeNative", "(IZ)V", (void*)initializeNative},
{"cleanupNative", "()V", (void*)cleanupNative},
{"connectHfpNative", "([B)Z", (void*)connectHfpNative},
{"disconnectHfpNative", "([B)Z", (void*)disconnectHfpNative},
max_hf_connections = Integer.parseInt(max_hfp_clients);
}
Log.d(TAG, "max_hf_connections = " + max_hf_connections);
- initializeNative(max_hf_connections);
+ Log.d(TAG,
+ "in-band_ringing_support = " + BluetoothHeadset.isInbandRingingSupported(mService));
+ initializeNative(max_hf_connections, BluetoothHeadset.isInbandRingingSupported(mService));
mNativeAvailable = true;
mDisconnected = new Disconnected();
case CONNECT_AUDIO: {
BluetoothDevice device = mCurrentDevice;
if (!isScoAcceptable()) {
- Log.w(TAG,"No Active/Held call, MO call setup, not allowing SCO");
+ Log.w(TAG,
+ "No Active/Held call, no call setup, and no in-band ringing, not allowing SCO");
break;
}
// TODO(BT) when failure, broadcast audio connecting to disconnected intent
!= HeadsetHalConstants.CALL_STATE_INCOMING)));
}
- // Accept incoming SCO only when there is active call, VR activated,
- // active VOIP call
+ private boolean isRinging() {
+ return mPhoneState.getCallState() == HeadsetHalConstants.CALL_STATE_INCOMING;
+ }
+
+ // Accept incoming SCO only when there is in-band ringing, incoming call,
+ // active call, VR activated, active VOIP call
private boolean isScoAcceptable() {
- return mAudioRouteAllowed && (mVoiceRecognitionStarted || isInCall());
+ return mAudioRouteAllowed
+ && (mVoiceRecognitionStarted || isInCall()
+ || (BluetoothHeadset.isInbandRingingSupported(mService) && isRinging()));
}
boolean isConnected() {
/*package*/ native boolean atResponseStringNative(String responseString, byte[] address);
private native static void classInitNative();
- private native void initializeNative(int max_hf_clients);
+ private native void initializeNative(int max_hf_clients, boolean inband_ring_enable);
private native void cleanupNative();
private native boolean connectHfpNative(byte[] address);
private native boolean disconnectHfpNative(byte[] address);