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

Commit edbe5b24 authored by Sal Savage's avatar Sal Savage
Browse files

Add the BIP Server registration API to the JNI interface

In order to support the addition of a BIP OBEX server for cover art we
implemented a path for Java to pass the PSM through to the native layer.
These functions will update the SDP record's additional protocol lists
and supported features bits to contain the required cover art bits.

Tag: #feature
Bug: 153076316
Test: atest BluetoothInstrumentationTests
Test: Also enabled AVRCP 1.6, pair with a device and check the SDP
record results. Then disable AVRCP 1.6 (or the cover art feature) and
make sure the cover art SDP data is omitted.

Change-Id: Ifccde3bb61b2fe388c029a0645a956b07daea816
parent f60569d5
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -225,6 +225,27 @@ static void initNative(JNIEnv* env, jobject object) {
  sServiceInterface->Init(&mAvrcpInterface, &mVolumeInterface);
}

static void registerBipServerNative(JNIEnv* env, jobject object,
                                    jint l2cap_psm) {
  ALOGD("%s: l2cap_psm=%d", __func__, (int)l2cap_psm);
  std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex);
  if (sServiceInterface == nullptr) {
    ALOGW("%s: Service not loaded.", __func__);
    return;
  }
  sServiceInterface->RegisterBipServer((int)l2cap_psm);
}

static void unregisterBipServerNative(JNIEnv* env, jobject object) {
  ALOGD("%s", __func__);
  std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex);
  if (sServiceInterface == nullptr) {
    ALOGW("%s: Service not loaded.", __func__);
    return;
  }
  sServiceInterface->UnregisterBipServer();
}

static void sendMediaUpdateNative(JNIEnv* env, jobject object,
                                  jboolean metadata, jboolean state,
                                  jboolean queue) {
@@ -811,6 +832,8 @@ static void setVolume(int8_t volume) {
static JNINativeMethod sMethods[] = {
    {"classInitNative", "()V", (void*)classInitNative},
    {"initNative", "()V", (void*)initNative},
    {"registerBipServerNative", "(I)V", (void*)registerBipServerNative},
    {"unregisterBipServerNative", "()V", (void*)unregisterBipServerNative},
    {"sendMediaUpdateNative", "(ZZZ)V", (void*)sendMediaUpdateNative},
    {"sendFolderUpdateNative", "(ZZZ)V", (void*)sendFolderUpdateNative},
    {"setBrowsedPlayerResponseNative", "(IZLjava/lang/String;I)V",
+12 −0
Original line number Diff line number Diff line
@@ -62,6 +62,16 @@ public class AvrcpNativeInterface {
        cleanupNative();
    }

    void registerBipServer(int l2capPsm) {
        d("Register our BIP server at psm=" + l2capPsm);
        registerBipServerNative(l2capPsm);
    }

    void unregisterBipServer() {
        d("Unregister any BIP server");
        unregisterBipServerNative();
    }

    Metadata getCurrentSongInfo() {
        d("getCurrentSongInfo");
        if (mAvrcpService == null) {
@@ -240,6 +250,8 @@ public class AvrcpNativeInterface {

    private static native void classInitNative();
    private native void initNative();
    private native void registerBipServerNative(int l2capPsm);
    private native void unregisterBipServerNative();
    private native void sendMediaUpdateNative(
            boolean trackChanged, boolean playState, boolean playPos);
    private native void sendFolderUpdateNative(