Make sure primary audio zone has highest priority
Did also code cleanup including
- Remove unused variable
- Prefer package private to public
Bug: 131090322
Test: dumpsys car_service | grep -A70 CarAudioService
Change-Id: I48b2e870cc9d259f84ee506fd6504985d5032534
diff --git a/service/src/com/android/car/audio/CarAudioZonesHelper.java b/service/src/com/android/car/audio/CarAudioZonesHelper.java
index 00cbb4b..17d9393 100644
--- a/service/src/com/android/car/audio/CarAudioZonesHelper.java
+++ b/service/src/com/android/car/audio/CarAudioZonesHelper.java
@@ -31,6 +31,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -59,7 +60,6 @@
private static final String ATTR_CONTEXT_NAME = "context";
private static final String ATTR_PHYSICAL_PORT = "port";
private static final int SUPPORTED_VERSION = 1;
- private static final int NO_XML_RESOURCE = 0;
private static final Map<String, Integer> CONTEXT_NAME_MAP;
@@ -93,7 +93,7 @@
mPortIds = new HashSet<>();
}
- public CarAudioZone[] loadAudioZones() throws IOException, XmlPullParserException {
+ CarAudioZone[] loadAudioZones() throws IOException, XmlPullParserException {
List<CarAudioZone> carAudioZones = new ArrayList<>();
parseCarAudioZones(carAudioZones, mInputStream);
return carAudioZones.toArray(new CarAudioZone[0]);
@@ -139,6 +139,7 @@
}
}
Preconditions.checkArgument(mHasPrimaryZone, "Requires one primary zone");
+ carAudioZones.sort(Comparator.comparing(CarAudioZone::getId));
}
private CarAudioZone parseAudioZone(XmlPullParser parser)
@@ -181,7 +182,7 @@
private DisplayAddress.Physical parsePhysicalDisplayAddress(XmlPullParser parser) {
String port = parser.getAttributeValue(NAMESPACE, ATTR_PHYSICAL_PORT);
- Long portId;
+ long portId;
try {
portId = Long.parseLong(port);
} catch (NumberFormatException e) {
diff --git a/service/src/com/android/car/audio/CarAudioZonesHelperLegacy.java b/service/src/com/android/car/audio/CarAudioZonesHelperLegacy.java
index b0df7e8..7f11275 100644
--- a/service/src/com/android/car/audio/CarAudioZonesHelperLegacy.java
+++ b/service/src/com/android/car/audio/CarAudioZonesHelperLegacy.java
@@ -74,7 +74,7 @@
}
}
- public CarAudioZone[] loadAudioZones() {
+ CarAudioZone[] loadAudioZones() {
final CarAudioZone zone = new CarAudioZone(CarAudioManager.PRIMARY_AUDIO_ZONE,
"Primary zone");
for (CarVolumeGroup group : loadVolumeGroups()) {