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

Commit accd3176 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 4509671 from ee770df3 to pi-release

Change-Id: Ie0d26f637119d294fcf2397da7c24cd8e9763dbc
parents 7c553a80 ee770df3
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -763,6 +763,7 @@ static jboolean phoneStateChangeNative(JNIEnv* env, jobject object,

static jboolean setScoAllowedNative(JNIEnv* env, jobject object,
                                    jboolean value) {
  std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);
  if (!sBluetoothHfpInterface) return JNI_FALSE;

  bt_status_t status =
@@ -773,6 +774,25 @@ static jboolean setScoAllowedNative(JNIEnv* env, jobject object,
  return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

static jboolean sendBsirNative(JNIEnv* env, jobject object, jboolean value,
                               jbyteArray address) {
  std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);
  if (!sBluetoothHfpInterface) return JNI_FALSE;

  jbyte* addr = env->GetByteArrayElements(address, NULL);
  if (!addr) {
    jniThrowIOException(env, EINVAL);
    return JNI_FALSE;
  }

  bt_status_t status =
      sBluetoothHfpInterface->send_bsir(value == JNI_TRUE, (RawAddress*)addr);
  if (status != BT_STATUS_SUCCESS) {
    ALOGE("Failed sending BSIR, value=%d, status=%d", value, status);
  }
  return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

static JNINativeMethod sMethods[] = {
    {"classInitNative", "()V", (void*)classInitNative},
    {"initializeNative", "(IZ)V", (void*)initializeNative},
@@ -797,6 +817,7 @@ static JNINativeMethod sMethods[] = {
    {"phoneStateChangeNative", "(IIILjava/lang/String;I)Z",
     (void*)phoneStateChangeNative},
    {"setScoAllowedNative", "(Z)Z", (void*)setScoAllowedNative},
    {"sendBsirNative", "(Z[B)Z", (void*)sendBsirNative},
};

int register_com_android_bluetooth_hfp(JNIEnv* env) {
+14 −0
Original line number Diff line number Diff line
@@ -421,6 +421,18 @@ public class HeadsetNativeInterface {
        return setScoAllowedNative(value);
    }

    /**
     * Enable or disable in-band ringing for the current service level connection through sending
     * +BSIR AT command
     *
     * @param value True to enable, False to disable
     * @return True on success, False on failure
     */
    @VisibleForTesting
    public boolean sendBsir(BluetoothDevice device,  boolean value) {
        return sendBsirNative(value, Utils.getByteAddress(device));
    }

    /* Native methods */
    private static native void classInitNative();

@@ -461,4 +473,6 @@ public class HeadsetNativeInterface {
            String number, int type);

    private native boolean setScoAllowedNative(boolean value);

    private native boolean sendBsirNative(boolean value, byte[] address);
}