Loading media/java/android/media/BluetoothProfileConnectionInfo.java +15 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,21 @@ public final class BluetoothProfileConnectionInfo implements Parcelable { -1, isLeOutput); } /** * @hide * Factory method for <code>BluetoothProfileConnectionInfo</code> for an LE output device * @param suppressNoisyIntent if true the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} * intent will not be sent. * @param volume the volume index of the device, -1 if unknown or to be ignored * @return an instance of BluetoothProfileConnectionInfo for the BLE output device that reflects * the given parameters */ public static @NonNull BluetoothProfileConnectionInfo createLeAudioOutputInfo( boolean suppressNoisyIntent, int volume) { return new BluetoothProfileConnectionInfo(BluetoothProfile.LE_AUDIO, suppressNoisyIntent, volume, /*isLeOutput*/ true); } /** * @return The profile connection */ Loading media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/BluetoothProfileConnectionInfoTest.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.mediaframeworktest.unit; import static org.junit.Assert.assertEquals; import android.bluetooth.BluetoothProfile; import android.media.BluetoothProfileConnectionInfo; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class BluetoothProfileConnectionInfoTest { @Test public void testCoverageLeAudioOutputVolume() { final boolean supprNoisy = false; final int volume = 1; final BluetoothProfileConnectionInfo info = BluetoothProfileConnectionInfo .createLeAudioOutputInfo(supprNoisy, volume); assertEquals(info.getProfile(), BluetoothProfile.LE_AUDIO); assertEquals(info.isSuppressNoisyIntent(), supprNoisy); assertEquals(info.isLeOutput(), true); assertEquals(info.getVolume(), volume); } } services/core/java/com/android/server/audio/AudioDeviceInventory.java +7 −4 Original line number Diff line number Diff line Loading @@ -376,7 +376,8 @@ public class AudioDeviceInventory { makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice); } else if (switchToAvailable) { makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice), streamType, btInfo.mAudioSystemDevice, "onSetBtActiveDevice"); streamType, btInfo.mVolume, btInfo.mAudioSystemDevice, "onSetBtActiveDevice"); } break; default: throw new IllegalArgumentException("Invalid profile " Loading Loading @@ -1160,8 +1161,8 @@ public class AudioDeviceInventory { } @GuardedBy("mDevicesLock") private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int device, String eventSource) { private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int volumeIndex, int device, String eventSource) { if (device != AudioSystem.DEVICE_NONE) { /* Audio Policy sees Le Audio similar to A2DP. Let's make sure * AUDIO_POLICY_FORCE_NO_BT_A2DP is not set Loading @@ -1182,7 +1183,9 @@ public class AudioDeviceInventory { return; } final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, device); final int leAudioVolIndex = (volumeIndex == -1) ? mDeviceBroker.getVssVolumeForDevice(streamType, device) : volumeIndex; final int maxIndex = mDeviceBroker.getMaxVssVolumeForStream(streamType); mDeviceBroker.postSetLeAudioVolumeIndex(leAudioVolIndex, maxIndex, streamType); mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "makeLeAudioDeviceAvailable"); Loading Loading
media/java/android/media/BluetoothProfileConnectionInfo.java +15 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,21 @@ public final class BluetoothProfileConnectionInfo implements Parcelable { -1, isLeOutput); } /** * @hide * Factory method for <code>BluetoothProfileConnectionInfo</code> for an LE output device * @param suppressNoisyIntent if true the {@link AudioManager.ACTION_AUDIO_BECOMING_NOISY} * intent will not be sent. * @param volume the volume index of the device, -1 if unknown or to be ignored * @return an instance of BluetoothProfileConnectionInfo for the BLE output device that reflects * the given parameters */ public static @NonNull BluetoothProfileConnectionInfo createLeAudioOutputInfo( boolean suppressNoisyIntent, int volume) { return new BluetoothProfileConnectionInfo(BluetoothProfile.LE_AUDIO, suppressNoisyIntent, volume, /*isLeOutput*/ true); } /** * @return The profile connection */ Loading
media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/unit/BluetoothProfileConnectionInfoTest.java 0 → 100644 +44 −0 Original line number Diff line number Diff line /* * Copyright (C) 2022 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.android.mediaframeworktest.unit; import static org.junit.Assert.assertEquals; import android.bluetooth.BluetoothProfile; import android.media.BluetoothProfileConnectionInfo; import androidx.test.runner.AndroidJUnit4; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(AndroidJUnit4.class) public class BluetoothProfileConnectionInfoTest { @Test public void testCoverageLeAudioOutputVolume() { final boolean supprNoisy = false; final int volume = 1; final BluetoothProfileConnectionInfo info = BluetoothProfileConnectionInfo .createLeAudioOutputInfo(supprNoisy, volume); assertEquals(info.getProfile(), BluetoothProfile.LE_AUDIO); assertEquals(info.isSuppressNoisyIntent(), supprNoisy); assertEquals(info.isLeOutput(), true); assertEquals(info.getVolume(), volume); } }
services/core/java/com/android/server/audio/AudioDeviceInventory.java +7 −4 Original line number Diff line number Diff line Loading @@ -376,7 +376,8 @@ public class AudioDeviceInventory { makeLeAudioDeviceUnavailable(address, btInfo.mAudioSystemDevice); } else if (switchToAvailable) { makeLeAudioDeviceAvailable(address, BtHelper.getName(btInfo.mDevice), streamType, btInfo.mAudioSystemDevice, "onSetBtActiveDevice"); streamType, btInfo.mVolume, btInfo.mAudioSystemDevice, "onSetBtActiveDevice"); } break; default: throw new IllegalArgumentException("Invalid profile " Loading Loading @@ -1160,8 +1161,8 @@ public class AudioDeviceInventory { } @GuardedBy("mDevicesLock") private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int device, String eventSource) { private void makeLeAudioDeviceAvailable(String address, String name, int streamType, int volumeIndex, int device, String eventSource) { if (device != AudioSystem.DEVICE_NONE) { /* Audio Policy sees Le Audio similar to A2DP. Let's make sure * AUDIO_POLICY_FORCE_NO_BT_A2DP is not set Loading @@ -1182,7 +1183,9 @@ public class AudioDeviceInventory { return; } final int leAudioVolIndex = mDeviceBroker.getVssVolumeForDevice(streamType, device); final int leAudioVolIndex = (volumeIndex == -1) ? mDeviceBroker.getVssVolumeForDevice(streamType, device) : volumeIndex; final int maxIndex = mDeviceBroker.getMaxVssVolumeForStream(streamType); mDeviceBroker.postSetLeAudioVolumeIndex(leAudioVolIndex, maxIndex, streamType); mDeviceBroker.postApplyVolumeOnDevice(streamType, device, "makeLeAudioDeviceAvailable"); Loading