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

Commit 1b31e7d7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Initialize max number of connected A2DP devices in the native stack via JNI"

parents 2a1b62e2 6b426900
Loading
Loading
Loading
Loading
+4 −3
Original line number Original line Diff line number Diff line
@@ -259,6 +259,7 @@ static std::vector<btav_a2dp_codec_config_t> prepareCodecPreferences(
}
}


static void initNative(JNIEnv* env, jobject object,
static void initNative(JNIEnv* env, jobject object,
                       jint maxConnectedAudioDevices,
                       jobjectArray codecConfigArray) {
                       jobjectArray codecConfigArray) {
  std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex);
  std::unique_lock<std::shared_timed_mutex> interface_lock(interface_mutex);
  std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex);
  std::unique_lock<std::shared_timed_mutex> callbacks_lock(callbacks_mutex);
@@ -305,8 +306,8 @@ static void initNative(JNIEnv* env, jobject object,
  std::vector<btav_a2dp_codec_config_t> codec_priorities =
  std::vector<btav_a2dp_codec_config_t> codec_priorities =
      prepareCodecPreferences(env, object, codecConfigArray);
      prepareCodecPreferences(env, object, codecConfigArray);


  bt_status_t status =
  bt_status_t status = sBluetoothA2dpInterface->init(
      sBluetoothA2dpInterface->init(&sBluetoothA2dpCallbacks, codec_priorities);
      &sBluetoothA2dpCallbacks, maxConnectedAudioDevices, codec_priorities);
  if (status != BT_STATUS_SUCCESS) {
  if (status != BT_STATUS_SUCCESS) {
    ALOGE("%s: Failed to initialize Bluetooth A2DP, status: %d", __func__,
    ALOGE("%s: Failed to initialize Bluetooth A2DP, status: %d", __func__,
          status);
          status);
@@ -444,7 +445,7 @@ static jboolean setCodecConfigPreferenceNative(JNIEnv* env, jobject object,


static JNINativeMethod sMethods[] = {
static JNINativeMethod sMethods[] = {
    {"classInitNative", "()V", (void*)classInitNative},
    {"classInitNative", "()V", (void*)classInitNative},
    {"initNative", "([Landroid/bluetooth/BluetoothCodecConfig;)V",
    {"initNative", "(I[Landroid/bluetooth/BluetoothCodecConfig;)V",
     (void*)initNative},
     (void*)initNative},
    {"cleanupNative", "()V", (void*)cleanupNative},
    {"cleanupNative", "()V", (void*)cleanupNative},
    {"connectA2dpNative", "([B)Z", (void*)connectA2dpNative},
    {"connectA2dpNative", "([B)Z", (void*)connectA2dpNative},
+6 −3
Original line number Original line Diff line number Diff line
@@ -70,11 +70,13 @@ public class A2dpNativeInterface {
    /**
    /**
     * Initializes the native interface.
     * Initializes the native interface.
     *
     *
     * @param maxConnectedAudioDevices maximum number of A2DP Sink devices that can be connected
     * simultaneously
     * @param codecConfigPriorities an array with the codec configuration
     * @param codecConfigPriorities an array with the codec configuration
     * priorities to configure.
     * priorities to configure.
     */
     */
    public void init(BluetoothCodecConfig[] codecConfigPriorities) {
    public void init(int maxConnectedAudioDevices, BluetoothCodecConfig[] codecConfigPriorities) {
        initNative(codecConfigPriorities);
        initNative(maxConnectedAudioDevices, codecConfigPriorities);
    }
    }


    /**
    /**
@@ -192,7 +194,8 @@ public class A2dpNativeInterface {


    // Native methods that call into the JNI interface
    // Native methods that call into the JNI interface
    private static native void classInitNative();
    private static native void classInitNative();
    private native void initNative(BluetoothCodecConfig[] codecConfigPriorities);
    private native void initNative(int maxConnectedAudioDevices,
                                   BluetoothCodecConfig[] codecConfigPriorities);
    private native void cleanupNative();
    private native void cleanupNative();
    private native boolean connectA2dpNative(byte[] address);
    private native boolean connectA2dpNative(byte[] address);
    private native boolean disconnectA2dpNative(byte[] address);
    private native boolean disconnectA2dpNative(byte[] address);
+2 −1
Original line number Original line Diff line number Diff line
@@ -125,7 +125,8 @@ public class A2dpService extends ProfileService {
        mA2dpCodecConfig = new A2dpCodecConfig(this, mA2dpNativeInterface);
        mA2dpCodecConfig = new A2dpCodecConfig(this, mA2dpNativeInterface);


        // Step 6: Initialize native interface
        // Step 6: Initialize native interface
        mA2dpNativeInterface.init(mA2dpCodecConfig.codecConfigPriorities());
        mA2dpNativeInterface.init(mMaxConnectedAudioDevices,
                                  mA2dpCodecConfig.codecConfigPriorities());


        // Step 7: Setup broadcast receivers
        // Step 7: Setup broadcast receivers
        IntentFilter filter = new IntentFilter();
        IntentFilter filter = new IntentFilter();