Loading android/app/jni/com_android_bluetooth_hfp.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -363,7 +363,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { 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"); Loading @@ -389,8 +390,8 @@ static void initializeNative(JNIEnv* env, jobject object, jint max_hf_clients) { 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; Loading Loading @@ -746,7 +747,7 @@ static jboolean configureWBSNative(JNIEnv* env, jobject object, 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}, Loading android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +15 −6 Original line number Diff line number Diff line Loading @@ -234,7 +234,9 @@ final class HeadsetStateMachine extends StateMachine { 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(); Loading Loading @@ -840,7 +842,8 @@ final class HeadsetStateMachine extends StateMachine { 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 Loading Loading @@ -3264,10 +3267,16 @@ final class HeadsetStateMachine extends StateMachine { != 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() { Loading Loading @@ -3388,7 +3397,7 @@ final class HeadsetStateMachine extends StateMachine { /*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); Loading Loading
android/app/jni/com_android_bluetooth_hfp.cpp +5 −4 Original line number Diff line number Diff line Loading @@ -363,7 +363,8 @@ static void classInitNative(JNIEnv* env, jclass clazz) { 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"); Loading @@ -389,8 +390,8 @@ static void initializeNative(JNIEnv* env, jobject object, jint max_hf_clients) { 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; Loading Loading @@ -746,7 +747,7 @@ static jboolean configureWBSNative(JNIEnv* env, jobject object, 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}, Loading
android/app/src/com/android/bluetooth/hfp/HeadsetStateMachine.java +15 −6 Original line number Diff line number Diff line Loading @@ -234,7 +234,9 @@ final class HeadsetStateMachine extends StateMachine { 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(); Loading Loading @@ -840,7 +842,8 @@ final class HeadsetStateMachine extends StateMachine { 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 Loading Loading @@ -3264,10 +3267,16 @@ final class HeadsetStateMachine extends StateMachine { != 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() { Loading Loading @@ -3388,7 +3397,7 @@ final class HeadsetStateMachine extends StateMachine { /*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); Loading