Merge "Support CAR_ZONE_GLOBAL in PropertyUtils." into androidx-main am: ae6b72a975
Original change: https://android-review.googlesource.com/c/platform/frameworks/support/+/2127981
Change-Id: Ie90fca4b99b6cc4ade54f460fd507d4994f8efec
Signed-off-by: Automerger Merge Worker <[email protected]>
diff --git a/car/app/app-automotive/src/main/java/androidx/car/app/hardware/common/PropertyUtils.java b/car/app/app-automotive/src/main/java/androidx/car/app/hardware/common/PropertyUtils.java
index f8a3312..4002ae5 100644
--- a/car/app/app-automotive/src/main/java/androidx/car/app/hardware/common/PropertyUtils.java
+++ b/car/app/app-automotive/src/main/java/androidx/car/app/hardware/common/PropertyUtils.java
@@ -143,6 +143,8 @@
.put(new CarZone.Builder().setRow(CarZone.CAR_ZONE_ROW_THIRD)
.setColumn(CarZone.CAR_ZONE_COLUMN_RIGHT).build(),
VehicleAreaSeat.SEAT_ROW_3_RIGHT)
+ .put(new CarZone.Builder().setRow(CarZone.CAR_ZONE_ROW_ALL)
+ .setColumn(CarZone.CAR_ZONE_COLUMN_ALL).build(), 0)
.buildOrThrow();
// Permissions for writing properties. They are system level permissions.
@@ -396,15 +398,16 @@
for (Map.Entry<Integer, List<CarZone>> propertyIdWithCarZones :
propertyIdToCarZones.entrySet()) {
for (CarZone carZone : propertyIdWithCarZones.getValue()) {
+ int propertyId = propertyIdWithCarZones.getKey();
if (CAR_ZONE_TO_AREA_ID.containsKey(carZone)) {
propertyIdWithAreaIds.add(PropertyIdAreaId.builder()
.setAreaId(CAR_ZONE_TO_AREA_ID.get(carZone))
- .setPropertyId(propertyIdWithCarZones.getKey())
+ .setPropertyId(propertyId)
.build());
} else {
Log.w(LogTags.TAG_CAR_HARDWARE,
"Could not find area Id for car zone: " + carZone.toString()
- + " for property: " + propertyIdWithCarZones.getKey());
+ + " for property: " + propertyId);
}
}
}
diff --git a/car/app/app-automotive/src/test/java/androidx/car/app/hardware/common/PropertyUtilsTest.java b/car/app/app-automotive/src/test/java/androidx/car/app/hardware/common/PropertyUtilsTest.java
index ef55551..e7d9a49 100644
--- a/car/app/app-automotive/src/test/java/androidx/car/app/hardware/common/PropertyUtilsTest.java
+++ b/car/app/app-automotive/src/test/java/androidx/car/app/hardware/common/PropertyUtilsTest.java
@@ -24,6 +24,8 @@
import android.car.hardware.CarPropertyValue;
+import com.google.common.collect.ImmutableMap;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -34,6 +36,11 @@
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.internal.DoNotInstrument;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
@RunWith(RobolectricTestRunner.class)
@DoNotInstrument
@@ -87,4 +94,19 @@
CAR_PROPERTY_RESPONSE_BUILDER.setStatus(CarValue.STATUS_UNKNOWN).build());
verify(mCarPropertyValue, never()).getValue();
}
+
+ @Test
+ public void convertPropertyValueToPropertyResponse_GetPropertyIdWithAreaIdForGlobalZone() {
+ List<PropertyIdAreaId> propertyIdAreaIds = new ArrayList<>();
+ propertyIdAreaIds.add(PropertyIdAreaId.builder()
+ .setAreaId(GLOBAL_AREA_ID)
+ .setPropertyId(PROPERTY_ID)
+ .build());
+ Map<Integer, List<CarZone>> propertyIdsWithCarZones =
+ ImmutableMap.<Integer, List<CarZone>>builder().put(PROPERTY_ID,
+ Collections.singletonList(CarZone.CAR_ZONE_GLOBAL)).buildKeepingLast();
+ assertThat(
+ PropertyUtils.getPropertyIdWithAreaIds(propertyIdsWithCarZones)).isEqualTo(
+ propertyIdAreaIds);
+ }
}