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

Commit 4f8794bf authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "A2DP: Close audio socket when set active device to null"

parents 272369cc 0277c9cd
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -399,13 +399,11 @@ static jboolean setActiveDeviceNative(JNIEnv* env, jobject object,
  }

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

  RawAddress bd_addr;
  RawAddress bd_addr = RawAddress::kEmpty;
  if (addr) {
    bd_addr.FromOctets(reinterpret_cast<const uint8_t*>(addr));
  }
  bt_status_t status = sBluetoothA2dpInterface->set_active_device(bd_addr);
  if (status != BT_STATUS_SUCCESS) {
    ALOGE("%s: Failed A2DP set_active_device, status: %d", __func__, status);
+3 −0
Original line number Diff line number Diff line
@@ -133,6 +133,9 @@ public class A2dpNativeInterface {
    }

    private byte[] getByteAddress(BluetoothDevice device) {
        if (device == null) {
            return Utils.getBytesFromAddress("00:00:00:00:00:00");
        }
        return Utils.getBytesFromAddress(device.getAddress());
    }

+5 −0
Original line number Diff line number Diff line
@@ -421,6 +421,11 @@ public class A2dpService extends ProfileService {
                    mAudioManager.setBluetoothA2dpDeviceConnectionState(
                            previousActiveDevice, BluetoothProfile.STATE_DISCONNECTED,
                            BluetoothProfile.A2DP);
                    // Make sure the Active device in native layer is set to null and audio is off
                    if (!mA2dpNativeInterface.setActiveDevice(null)) {
                        Log.w(TAG, "setActiveDevice(null): Cannot remove active device in native "
                                + "layer");
                    }
                }
                return true;
            }