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

Commit b37eab46 authored by Hansong Zhang's avatar Hansong Zhang Committed by android-build-merger
Browse files

Merge "A2DP: Close audio socket when set active device to null" am: 4f8794bf am: c3824e09

am: 1b4bed0b

Change-Id: I5f66a9e678686799e229ea327ac4996d5fa3b1c5
parents ca0d4ea7 1b4bed0b
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;
            }