change binder interface to pass the whole vehicle_prop_value_t for get
- This allows passing property specific parameters through the passed
value.
- Client should at least set type properly even in get call as it can
be checked in various places.
bug: 24095928
Change-Id: Ifeb1260361eac0d85ae3b9ccd0182d2c8bed2a4b
(cherry picked from commit 85161fb1c76e9860b4ef6d671b7492a8fddc20f7)
diff --git a/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetwork.java b/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetwork.java
index b9cd870..09453dd 100644
--- a/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetwork.java
+++ b/libvehiclenetwork/java/src/com/android/car/vehiclenetwork/VehicleNetwork.java
@@ -49,7 +49,7 @@
public interface VehicleNetworkHalMock {
VehiclePropConfigs onListProperties();
void onPropertySet(VehiclePropValue value);
- VehiclePropValue onPropertyGet(int property);
+ VehiclePropValue onPropertyGet(VehiclePropValue property);
void onPropertySubscribe(int property, int sampleRate);
void onPropertyUnsubscribe(int property);
}
@@ -135,10 +135,17 @@
}
public VehiclePropValue getProperty(int property) {
+ int valueType = VehicleNetworkConsts.getVehicleValueType(property);
+ VehiclePropValue value = VehiclePropValueUtil.createBuilder(property, valueType, 0).build();
+ return getProperty(value);
+ }
+
+ public VehiclePropValue getProperty(VehiclePropValue value) {
+ VehiclePropValueParcelable parcelable = new VehiclePropValueParcelable(value);
try {
- VehiclePropValueParcelable parcelable = mService.getProperty(property);
- if (parcelable != null) {
- return parcelable.value;
+ VehiclePropValueParcelable resParcelable = mService.getProperty(parcelable);
+ if (resParcelable != null) {
+ return resParcelable.value;
}
} catch (RemoteException e) {
handleRemoteException(e);
@@ -406,13 +413,13 @@
}
@Override
- public VehiclePropValueParcelable onPropertyGet(int property) {
+ public VehiclePropValueParcelable onPropertyGet(VehiclePropValueParcelable value) {
VehicleNetwork vehicleNetwork = mVehicleNetwork.get();
if (vehicleNetwork == null) {
return null;
}
- VehiclePropValue value = vehicleNetwork.getHalMock().onPropertyGet(property);
- return new VehiclePropValueParcelable(value);
+ VehiclePropValue resValue = vehicleNetwork.getHalMock().onPropertyGet(value.value);
+ return new VehiclePropValueParcelable(resValue);
}
@Override