Loading android/app/jni/com_android_bluetooth_hfp.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -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 = Loading @@ -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}, Loading @@ -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) { Loading android/app/src/com/android/bluetooth/hfp/HeadsetNativeInterface.java +14 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); } Loading
android/app/jni/com_android_bluetooth_hfp.cpp +21 −0 Original line number Diff line number Diff line Loading @@ -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 = Loading @@ -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}, Loading @@ -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) { Loading
android/app/src/com/android/bluetooth/hfp/HeadsetNativeInterface.java +14 −0 Original line number Diff line number Diff line Loading @@ -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(); Loading Loading @@ -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); }