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

Commit f648ebe6 authored by Sanket Agarwal's avatar Sanket Agarwal Committed by android-build-merger
Browse files

Merge "A2DP Sink:Audio Rendering patch and AutoConnect Functionality"

am: a22d9acc

* commit 'a22d9acc':
  A2DP Sink:Audio Rendering patch and AutoConnect Functionality
parents f54b7cfd a22d9acc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -62,6 +62,7 @@
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.DEVICE_POWER" />
    <uses-permission android:name="android.permission.REAL_GET_TASKS" />
    <uses-permission android:name="android.permission.MODIFY_AUDIO_ROUTING" />

    <!-- For PBAP Owner Vcard Info -->
    <uses-permission android:name="android.permission.READ_PROFILE"/>
+35 −1
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ namespace android {
static jmethodID method_onConnectionStateChanged;
static jmethodID method_onAudioStateChanged;
static jmethodID method_onAudioConfigChanged;
static jmethodID method_onAudioFocusRequested;

static const btav_interface_t *sBluetoothA2dpInterface = NULL;
static jobject mCallbacksObj = NULL;
@@ -116,11 +117,34 @@ static void bta2dp_audio_config_callback(bt_bdaddr_t *bd_addr, uint32_t sample_r
    sCallbackEnv->DeleteLocalRef(addr);
}

static void bta2dp_audio_focus_request_callback(bt_bdaddr_t *bd_addr) {
    jbyteArray addr;

    ALOGI("%s", __FUNCTION__);

    if (!checkCallbackThread()) {                                       \
        ALOGE("Callback: '%s' is not called on the correct thread", __FUNCTION__); \
        return;                                                         \
    }
    addr = sCallbackEnv->NewByteArray(sizeof(bt_bdaddr_t));
    if (!addr) {
        ALOGE("Fail to new jbyteArray bd addr for connection state");
        checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
        return;
    }

    sCallbackEnv->SetByteArrayRegion(addr, 0, sizeof(bt_bdaddr_t), (jbyte*) bd_addr);
    sCallbackEnv->CallVoidMethod(mCallbacksObj, method_onAudioFocusRequested, addr);
    checkAndClearExceptionFromCallback(sCallbackEnv, __FUNCTION__);
    sCallbackEnv->DeleteLocalRef(addr);
}

static btav_callbacks_t sBluetoothA2dpCallbacks = {
    sizeof(sBluetoothA2dpCallbacks),
    bta2dp_connection_state_callback,
    bta2dp_audio_state_callback,
    bta2dp_audio_config_callback
    bta2dp_audio_config_callback,
    bta2dp_audio_focus_request_callback
};

static void classInitNative(JNIEnv* env, jclass clazz) {
@@ -137,6 +161,9 @@ static void classInitNative(JNIEnv* env, jclass clazz) {
    method_onAudioConfigChanged =
        env->GetMethodID(clazz, "onAudioConfigChanged", "([BII)V");

    method_onAudioFocusRequested =
        env->GetMethodID(clazz, "onAudioFocusRequested", "([B)V");

    ALOGI("%s: succeeds", __FUNCTION__);
}

@@ -237,12 +264,19 @@ static jboolean disconnectA2dpNative(JNIEnv *env, jobject object, jbyteArray add
    return (status == BT_STATUS_SUCCESS) ? JNI_TRUE : JNI_FALSE;
}

static void informAudioFocusStateNative(JNIEnv *env, jobject object, jint focus_state) {
    if (!sBluetoothA2dpInterface) return;

    sBluetoothA2dpInterface->audio_focus_state((uint8_t)focus_state);

}
static JNINativeMethod sMethods[] = {
    {"classInitNative", "()V", (void *) classInitNative},
    {"initNative", "()V", (void *) initNative},
    {"cleanupNative", "()V", (void *) cleanupNative},
    {"connectA2dpNative", "([B)Z", (void *) connectA2dpNative},
    {"disconnectA2dpNative", "([B)Z", (void *) disconnectA2dpNative},
    {"informAudioFocusStateNative", "(I)V", (void *) informAudioFocusStateNative},
};

int register_com_android_bluetooth_a2dp_sink(JNIEnv* env)
+496 −3

File changed.

Preview size limit exceeded, changes collapsed.

+60 −0

File changed.

Preview size limit exceeded, changes collapsed.

+472 −4

File changed.

Preview size limit exceeded, changes collapsed.

Loading