Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36cad665 authored by Jack He's avatar Jack He
Browse files

Check support for in-band ringing during HFP init

* Check in-band ringing support for this platform during HFP init

Bug: 19171297
Test: mm -j 40, HFP regression testing, testplans/82144
Change-Id: I5a90b2218b0dc15eb92f32bf9b4ed3ff3b01980b
(cherry picked from commit 6eac09b725ed509b26e8f49d8442426f7816953a)
parent e97f8c4d
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -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");
@@ -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;
@@ -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},
+15 −6
Original line number Diff line number Diff line
@@ -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();
@@ -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
@@ -3266,10 +3269,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() {
@@ -3390,7 +3399,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);