add special error handling for vhal set
- -EAGAIN involves retry
- -ESHUTDOWN for powered off property:
this will lead into IllegalStateException in Java side
- also reduced retry number to 20 so that it will retry up to
2 secs. Most vehicle network message should be there within
this time.
bug: 28022648
Change-Id: Ic306eb427c24fbe445e7f2b136c16cf5dd40e9d1
(cherry picked from commit e78bf53959151d07c90bbb69fd3f99240dd139b1)
diff --git a/libvehiclenetwork/native/IVehicleNetwork.cpp b/libvehiclenetwork/native/IVehicleNetwork.cpp
index c0b2119..528034c 100644
--- a/libvehiclenetwork/native/IVehicleNetwork.cpp
+++ b/libvehiclenetwork/native/IVehicleNetwork.cpp
@@ -112,6 +112,17 @@
return status;
}
status = remote()->transact(SET_PROPERTY, data, &reply);
+ if (status == NO_ERROR) {
+ int32_t exceptionCode = reply.readExceptionCode();
+ if (exceptionCode != NO_ERROR) {
+ if (exceptionCode == binder::Status::EX_SERVICE_SPECIFIC) {
+ return -EAGAIN;
+ } else if (exceptionCode == binder::Status::EX_ILLEGAL_STATE) {
+ return -ESHUTDOWN;
+ }
+ return exceptionCode;
+ }
+ }
return status;
}
@@ -288,7 +299,17 @@
return PERMISSION_DENIED;
}
r = setProperty(value.value);
- BinderUtil::fillNoResultReply(reply);
+ if (r == NO_ERROR) {
+ reply->writeNoException();
+ } else if (r == -EAGAIN) {
+ // this should be handled specially to throw ServiceSpecificException in java.
+ reply->writeInt32(binder::Status::EX_SERVICE_SPECIFIC);
+ return NO_ERROR;
+ } else if (r == -ESHUTDOWN) {
+ // this should be handled specially to throw IllegalStateException in java.
+ reply->writeInt32(binder::Status::EX_ILLEGAL_STATE);
+ return NO_ERROR;
+ }
return r;
} break;
case GET_PROPERTY: {