aboutsummaryrefslogtreecommitdiff
path: root/libvehiclenetwork
diff options
context:
space:
mode:
authorSteve Paik <spaik@google.com>2016-03-28 10:31:25 -0700
committerPavel Maltsev <pavelm@google.com>2016-04-12 15:58:27 -0700
commitfb5f6232486612413b129a2100bac720589dee0d (patch)
tree2a0970fce52d64386d991f9e5be2056facdb5219 /libvehiclenetwork
parent1d4f87822cc231ed34df1dfeb6b886d64e4ac7ee (diff)
downloadCar-fb5f6232486612413b129a2100bac720589dee0d.tar.gz
Implement changes from car api review of CarHvacManager
- Add @IntDef for all enums - Split CarHvacProperty into corresponding Config and Value classes; - Use java types to represent vehicle value type in API; - Use generics for different property types; - Add documentation to clarify behavior - Allow multiple listeners to register for callbacks - Remove @SystemApi tag from CarHvacEvent class - fixed CarHvacManagerTest and vehicle hal mocking - Added unit tests for CarPropertyConfig and CarPropertyValue BUG: 27814691, 27900797, 27142682 Change-Id: Ic860b4ef4ff87db1babde21226ec35ac81f77cea
Diffstat (limited to 'libvehiclenetwork')
-rw-r--r--libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehiclePropValueUtil.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehiclePropValueUtil.java b/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehiclePropValueUtil.java
index 78b2141dd6..1e24931d76 100644
--- a/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehiclePropValueUtil.java
+++ b/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehiclePropValueUtil.java
@@ -15,11 +15,11 @@
*/
package com.android.car.vehiclenetwork;
+import com.google.protobuf.ByteString;
+
import com.android.car.vehiclenetwork.VehicleNetworkConsts.VehicleValueType;
import com.android.car.vehiclenetwork.VehicleNetworkProto.VehiclePropValue;
-import com.google.protobuf.ByteString;
-
import java.util.Arrays;
import java.util.List;
@@ -198,6 +198,13 @@ public final class VehiclePropValueUtil {
public static int getVectorLength(int vehicleValueType) {
switch (vehicleValueType) {
+ case VehicleValueType.VEHICLE_VALUE_TYPE_BOOLEAN:
+ case VehicleValueType.VEHICLE_VALUE_TYPE_INT32:
+ case VehicleValueType.VEHICLE_VALUE_TYPE_FLOAT:
+ case VehicleValueType.VEHICLE_VALUE_TYPE_ZONED_INT32:
+ case VehicleValueType.VEHICLE_VALUE_TYPE_ZONED_BOOLEAN:
+ case VehicleValueType.VEHICLE_VALUE_TYPE_ZONED_FLOAT:
+ return 1;
case VehicleValueType.VEHICLE_VALUE_TYPE_FLOAT_VEC2:
case VehicleValueType.VEHICLE_VALUE_TYPE_INT32_VEC2:
case VehicleValueType.VEHICLE_VALUE_TYPE_ZONED_FLOAT_VEC2:
@@ -225,6 +232,9 @@ public final class VehiclePropValueUtil {
/** Converts {@link VehiclePropValue} to string just for debug purpose. */
public static String toString(VehiclePropValue value) {
+ if (value == null) {
+ return String.valueOf(null);
+ }
return new StringBuilder()
.append("prop: " + value.getProp() + "\n")
.append("valueType: " + value.getValueType() + "\n")
@@ -258,7 +268,7 @@ public final class VehiclePropValueUtil {
return array;
}
- private static int getVectorValueType(int vehicleValueType, int length) {
+ public static int getVectorValueType(int vehicleValueType, int length) {
return vehicleValueType + length - 1;
}
}