Handle ServiceSpecificException in register
When CarPropertyManager register for properties, it will call a getter
for getting the initial value. If the initial value is unavailable, it
will throw ServiceSpecificException. To avoid this case, return null if
PropertyHalService get a exception.
Bug: 188061475
Test: add new test cases in CarPropertyManagerTest
atest CarPropertyManagerTest
atest CarServiceTest
atest CarServiceUnitTest
Change-Id: I5f73f280a2611b1e700e7344ad9471b1aafb20e7
diff --git a/service/src/com/android/car/CarDrivingStateService.java b/service/src/com/android/car/CarDrivingStateService.java
index c12d803..146dd95 100644
--- a/service/src/com/android/car/CarDrivingStateService.java
+++ b/service/src/com/android/car/CarDrivingStateService.java
@@ -474,7 +474,7 @@
@GuardedBy("mLock")
private void updateVehiclePropertiesIfNeededLocked() {
if (mLastGearTimestamp == NOT_RECEIVED) {
- CarPropertyValue propertyValue = mPropertyService.getProperty(
+ CarPropertyValue propertyValue = mPropertyService.getPropertySafe(
VehicleProperty.GEAR_SELECTION,
VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL);
if (propertyValue != null) {
@@ -487,7 +487,7 @@
}
if (mLastParkingBrakeTimestamp == NOT_RECEIVED) {
- CarPropertyValue propertyValue = mPropertyService.getProperty(
+ CarPropertyValue propertyValue = mPropertyService.getPropertySafe(
VehicleProperty.PARKING_BRAKE_ON,
VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL);
if (propertyValue != null) {
@@ -500,7 +500,7 @@
}
if (mLastSpeedTimestamp == NOT_RECEIVED) {
- CarPropertyValue propertyValue = mPropertyService.getProperty(
+ CarPropertyValue propertyValue = mPropertyService.getPropertySafe(
VehicleProperty.PERF_VEHICLE_SPEED,
VehicleAreaType.VEHICLE_AREA_TYPE_GLOBAL);
if (propertyValue != null) {