AudioDeviceInventory: better error handling in clearDevicesRole

Return an error when no role has been set for a given device
to match the API documentation.

Test: atest AudioServiceHostTest#testPreferredDeviceRouting
Test: atet AudioServiceHostTest#testPreferredDeviceRoutingForCapturePres
Bug: 280929860
Change-Id: I462eb3a1ad0eb9d606279b6b62ce2cfb6b059b7f
This commit is contained in:
Eric Laurent
2023-05-12 15:39:01 +02:00
parent e38a303dc4
commit f83103ed8b

View File

@@ -1100,7 +1100,8 @@ public class AudioDeviceInventory {
synchronized (rolesMap) {
Pair<Integer, Integer> key = new Pair<>(useCase, role);
if (!rolesMap.containsKey(key)) {
return AudioSystem.SUCCESS;
// trying to clear a role for a device that wasn't set
return AudioSystem.BAD_VALUE;
}
final int status = asi.deviceRoleAction(useCase, role, null);
if (status == AudioSystem.SUCCESS) {