[LE Audio] Add LE Audio Devices in Sound Settings

- When connected to the LE Audio Device, it will display "Play XXX on
    LEAduioDeviceName" in Sound Settings.

  - When connected to the LE Audio Device, it will display the LE Audio
    device name in the "Take call on" list for you having a active call(Hands Free).

  - Remove the @Ignore annotation for all the tests and make test
    cases pass.

Bug: 240911615
Bug: 243494881
Test: manual test
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AudioOutputSwitchPreferenceControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=HandsFreeProfileOutputPreferenceControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=MediaOutputPreferenceControllerTest
Change-Id: I10db59b33623495a9e9933556c78e20d81e405ea
This commit is contained in:
changbetty
2022-10-12 11:02:59 +00:00
parent 50c7cb834e
commit 1096417464
6 changed files with 279 additions and 33 deletions

View File

@@ -45,6 +45,7 @@ import com.android.settingslib.bluetooth.BluetoothCallback;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HeadsetProfile;
import com.android.settingslib.bluetooth.HearingAidProfile;
import com.android.settingslib.bluetooth.LeAudioProfile;
import com.android.settingslib.bluetooth.LocalBluetoothManager;
import com.android.settingslib.bluetooth.LocalBluetoothProfileManager;
import com.android.settingslib.core.lifecycle.LifecycleObserver;
@@ -214,6 +215,25 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
return a2dpProfile.getConnectedDevices();
}
/**
* Get LE Audio profile connected devices
*/
protected List<BluetoothDevice> getConnectedLeAudioDevices() {
final List<BluetoothDevice> connectedDevices = new ArrayList<>();
final LeAudioProfile leAudioProfile = mProfileManager.getLeAudioProfile();
if (leAudioProfile == null) {
Log.d(TAG, "LeAudioProfile is null");
return connectedDevices;
}
final List<BluetoothDevice> devices = leAudioProfile.getConnectedDevices();
for (BluetoothDevice device : devices) {
if (device.isConnected()) {
connectedDevices.add(device);
}
}
return connectedDevices;
}
/**
* get hearing aid profile connected device, exclude other devices with same hiSyncId.
*/
@@ -259,6 +279,24 @@ public abstract class AudioSwitchPreferenceController extends BasePreferenceCont
return null;
}
/**
* Find active LE Audio device
*/
protected BluetoothDevice findActiveLeAudioDevice() {
final LeAudioProfile leAudioProfile = mProfileManager.getLeAudioProfile();
if (leAudioProfile != null) {
List<BluetoothDevice> activeDevices = leAudioProfile.getActiveDevices();
for (BluetoothDevice leAudioDevice : activeDevices) {
if (leAudioDevice != null) {
return leAudioDevice;
}
}
}
Log.d(TAG, "There is no LE audio profile or no active LE audio device");
return null;
}
/**
* Find the active device from the corresponding profile.
*