Rename AudioDeviceAddress to AudioDevice
Bug: 148565943
Test: atest AudioServiceHostTest AudioServiceHostTest#testAudioDevice
Change-Id: If173c45df65315d6cdfccc74982ecc53837ea321
diff --git a/car-lib/src/android/car/media/CarAudioManager.java b/car-lib/src/android/car/media/CarAudioManager.java
index 16eaa07..80f3cd8 100644
--- a/car-lib/src/android/car/media/CarAudioManager.java
+++ b/car-lib/src/android/car/media/CarAudioManager.java
@@ -24,7 +24,7 @@
import android.car.CarLibLog;
import android.car.CarManagerBase;
import android.media.AudioAttributes;
-import android.media.AudioDeviceAddress;
+import android.media.AudioDevice;
import android.media.AudioDeviceInfo;
import android.media.AudioManager;
import android.media.AudioManager.AudioDeviceRole;
@@ -615,8 +615,8 @@
@RequiresPermission(Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS)
public @NonNull List<AudioDeviceInfo> getInputDevicesForZoneId(int zoneId) {
try {
- return convertInputDeviceAddressesToDeviceInfos(
- mService.getInputDevicesAddressesForZoneId(zoneId),
+ return convertInputDevicesToDeviceInfos(
+ mService.getInputDevicesForZoneId(zoneId),
AudioManager.GET_DEVICES_INPUTS);
} catch (RemoteException e) {
return handleRemoteExceptionFromCarService(e, new ArrayList<>());
@@ -664,15 +664,15 @@
mCarVolumeCallbacks.remove(callback);
}
- private List<AudioDeviceInfo> convertInputDeviceAddressesToDeviceInfos(
- List<AudioDeviceAddress> addresses, @AudioDeviceRole int flag) {
- int addressesSize = addresses.size();
+ private List<AudioDeviceInfo> convertInputDevicesToDeviceInfos(
+ List<AudioDevice> devices, @AudioDeviceRole int flag) {
+ int addressesSize = devices.size();
Set<String> deviceAddressMap = new HashSet<>(addressesSize);
for (int i = 0; i < addressesSize; ++i) {
- AudioDeviceAddress deviceAddress = addresses.get(i);
+ AudioDevice deviceAddress = devices.get(i);
deviceAddressMap.add(deviceAddress.getAddress());
}
- List<AudioDeviceInfo> deviceInfoList = new ArrayList<>(addresses.size());
+ List<AudioDeviceInfo> deviceInfoList = new ArrayList<>(devices.size());
AudioDeviceInfo[] inputDevices = mAudioManager.getDevices(flag);
for (int i = 0; i < inputDevices.length; ++i) {
AudioDeviceInfo info = inputDevices[i];
diff --git a/car-lib/src/android/car/media/ICarAudio.aidl b/car-lib/src/android/car/media/ICarAudio.aidl
index bc5c902..3ece9ee 100644
--- a/car-lib/src/android/car/media/ICarAudio.aidl
+++ b/car-lib/src/android/car/media/ICarAudio.aidl
@@ -17,7 +17,7 @@
package android.car.media;
import android.car.media.CarAudioPatchHandle;
-import android.media.AudioDeviceAddress;
+import android.media.AudioDevice;
/**
* Binder interface for {@link android.car.media.CarAudioManager}.
* Check {@link android.car.media.CarAudioManager} APIs for expected behavior of each call.
@@ -52,7 +52,7 @@
String getOutputDeviceAddressForUsage(int zoneId, int usage);
- List<AudioDeviceAddress> getInputDevicesAddressesForZoneId(int zoneId);
+ List<AudioDevice> getInputDevicesForZoneId(int zoneId);
/**
* IBinder is ICarVolumeCallback but passed as IBinder due to aidl hidden.
*/
diff --git a/service/src/com/android/car/audio/CarAudioService.java b/service/src/com/android/car/audio/CarAudioService.java
index 8c47105..23f503a 100644
--- a/service/src/com/android/car/audio/CarAudioService.java
+++ b/service/src/com/android/car/audio/CarAudioService.java
@@ -36,7 +36,7 @@
import android.hardware.automotive.audiocontrol.V1_0.IAudioControl;
import android.media.AudioAttributes;
import android.media.AudioAttributes.AttributeSystemUsage;
-import android.media.AudioDeviceAddress;
+import android.media.AudioDevice;
import android.media.AudioDeviceInfo;
import android.media.AudioDevicePort;
import android.media.AudioFocusInfo;
@@ -1033,13 +1033,13 @@
/**
* Gets the input devices for zone zoneId
*/
- public @NonNull List<AudioDeviceAddress> getInputDevicesAddressesForZoneId(int zoneId) {
+ public @NonNull List<AudioDevice> getInputDevicesForZoneId(int zoneId) {
enforcePermission(Car.PERMISSION_CAR_CONTROL_AUDIO_SETTINGS);
Preconditions.checkArgumentInRange(zoneId, 0, mCarAudioZones.length - 1,
"zoneId out of range: " + zoneId);
for (CarAudioZone zone : mCarAudioZones) {
if (zone.getId() == zoneId) {
- return zone.getInputAudioDeviceAddresses();
+ return zone.getInputAudioDevices();
}
}
throw new IllegalArgumentException("zoneId does not exist" + zoneId);
diff --git a/service/src/com/android/car/audio/CarAudioZone.java b/service/src/com/android/car/audio/CarAudioZone.java
index 63b0131..f9ed98e 100644
--- a/service/src/com/android/car/audio/CarAudioZone.java
+++ b/service/src/com/android/car/audio/CarAudioZone.java
@@ -16,7 +16,7 @@
package com.android.car.audio;
import android.car.media.CarAudioManager;
-import android.media.AudioDeviceAddress;
+import android.media.AudioDevice;
import android.media.AudioDeviceInfo;
import android.util.Log;
import android.view.DisplayAddress;
@@ -46,14 +46,14 @@
private final String mName;
private final List<CarVolumeGroup> mVolumeGroups;
private final List<DisplayAddress.Physical> mPhysicalDisplayAddresses;
- private List<AudioDeviceAddress> mInputAudioDeviceAddress;
+ private List<AudioDevice> mInputAudioDevice;
CarAudioZone(int id, String name) {
mId = id;
mName = name;
mVolumeGroups = new ArrayList<>();
mPhysicalDisplayAddresses = new ArrayList<>();
- mInputAudioDeviceAddress = new ArrayList<>();
+ mInputAudioDevice = new ArrayList<>();
}
int getId() {
@@ -186,9 +186,9 @@
writer.printf("%sInput Audio Device Addresses\n", internalIndent);
String devicesIndent = internalIndent + "\t";
- for (AudioDeviceAddress audioDeviceAddress : mInputAudioDeviceAddress) {
+ for (AudioDevice audioDevice : mInputAudioDevice) {
writer.printf("%sDevice Address(%s)\n", devicesIndent,
- audioDeviceAddress.getAddress());
+ audioDevice.getAddress());
}
writer.println();
}
@@ -218,11 +218,11 @@
}
}
- void addInputAudioDeviceAddress(AudioDeviceAddress address) {
- mInputAudioDeviceAddress.add(address);
+ void addInputAudioDevice(AudioDevice device) {
+ mInputAudioDevice.add(device);
}
- List<AudioDeviceAddress> getInputAudioDeviceAddresses() {
- return mInputAudioDeviceAddress;
+ List<AudioDevice> getInputAudioDevices() {
+ return mInputAudioDevice;
}
}
diff --git a/service/src/com/android/car/audio/CarAudioZonesHelper.java b/service/src/com/android/car/audio/CarAudioZonesHelper.java
index 3ffff14..a7864ce 100644
--- a/service/src/com/android/car/audio/CarAudioZonesHelper.java
+++ b/service/src/com/android/car/audio/CarAudioZonesHelper.java
@@ -19,7 +19,7 @@
import android.car.media.CarAudioManager;
import android.content.Context;
import android.hardware.automotive.audiocontrol.V1_0.ContextNumber;
-import android.media.AudioDeviceAddress;
+import android.media.AudioDevice;
import android.media.AudioDeviceInfo;
import android.text.TextUtils;
import android.util.SparseIntArray;
@@ -100,7 +100,7 @@
private final Set<Long> mPortIds;
private final SparseIntArray mZoneIdToOccupantZoneIdMapping;
private final Set<Integer> mAudioZoneIds;
- private final Set<String> mInputAudioDeviceAddresses;
+ private final Set<String> mInputAudioDevices;
private boolean mHasPrimaryZone;
private int mNextSecondaryZoneId;
@@ -125,7 +125,7 @@
mPortIds = new HashSet<>();
mZoneIdToOccupantZoneIdMapping = new SparseIntArray();
mAudioZoneIds = new HashSet<>();
- mInputAudioDeviceAddresses = new HashSet<>();
+ mInputAudioDevices = new HashSet<>();
}
SparseIntArray getCarAudioZoneIdToOccupantZoneIdMapping() {
@@ -308,7 +308,7 @@
"%s %s of %s does not exist, add input device to"
+ " audio_policy_configuration.xml.",
ATTR_DEVICE_ADDRESS, audioDeviceAddress, TAG_INPUT_DEVICE);
- zone.addInputAudioDeviceAddress(new AudioDeviceAddress(info));
+ zone.addInputAudioDevice(new AudioDevice(info));
}
skip(parser);
}
@@ -320,11 +320,11 @@
Preconditions.checkArgument(!audioDeviceAddress.isEmpty(),
"%s %s attribute can not be empty.",
TAG_INPUT_DEVICE, ATTR_DEVICE_ADDRESS);
- if (mInputAudioDeviceAddresses.contains(audioDeviceAddress)) {
+ if (mInputAudioDevices.contains(audioDeviceAddress)) {
throw new IllegalArgumentException(TAG_INPUT_DEVICE + " " + audioDeviceAddress
+ " repeats, " + TAG_INPUT_DEVICES + " can not repeat.");
}
- mInputAudioDeviceAddresses.add(audioDeviceAddress);
+ mInputAudioDevices.add(audioDeviceAddress);
}
private void parseDisplays(XmlPullParser parser, CarAudioZone zone)
diff --git a/tests/carservice_test/src/com/android/car/audio/CarAudioZonesHelperTest.java b/tests/carservice_test/src/com/android/car/audio/CarAudioZonesHelperTest.java
index 4840065..8767dc3 100644
--- a/tests/carservice_test/src/com/android/car/audio/CarAudioZonesHelperTest.java
+++ b/tests/carservice_test/src/com/android/car/audio/CarAudioZonesHelperTest.java
@@ -30,7 +30,7 @@
import android.car.media.CarAudioManager;
import android.content.Context;
import android.hardware.automotive.audiocontrol.V1_0.ContextNumber;
-import android.media.AudioDeviceAddress;
+import android.media.AudioDevice;
import android.media.AudioDeviceInfo;
import android.util.SparseIntArray;
import android.view.DisplayAddress;
@@ -368,8 +368,8 @@
CarAudioZone[] zones = cazh.loadAudioZones();
CarAudioZone primaryZone = zones[0];
- List<AudioDeviceAddress> primaryZoneInputDevices =
- primaryZone.getInputAudioDeviceAddresses();
+ List<AudioDevice> primaryZoneInputDevices =
+ primaryZone.getInputAudioDevices();
assertThat(primaryZoneInputDevices).hasSize(2);
List<String> primaryZoneInputAddresses =
@@ -379,8 +379,8 @@
PRIMARY_ZONE_MICROPHONE_ADDRESS).inOrder();
CarAudioZone secondaryZone = zones[1];
- List<AudioDeviceAddress> secondaryZoneInputDevices =
- secondaryZone.getInputAudioDeviceAddresses();
+ List<AudioDevice> secondaryZoneInputDevices =
+ secondaryZone.getInputAudioDevices();
List<String> secondaryZoneInputAddresses =
secondaryZoneInputDevices.stream().map(a ->a.getAddress()).collect(
Collectors.toList());