Correct the flag value for system_server reconnection
This change also updates the return value for onHostEndpointConnected
to be service specific.
Bug: 288092164
Test: Killing the system_server process and observing it reconnects and
is identified as system_server again; connect a endpoint with an out-of-
range id and observed the expected error code is returned.
Change-Id: I36bc317b1ed4098e58d1a173549b3e4c62238b39
diff --git a/host/hal_generic/common/hal_client_manager.cc b/host/hal_generic/common/hal_client_manager.cc
index 1660ff5..f6945eb 100644
--- a/host/hal_generic/common/hal_client_manager.cc
+++ b/host/hal_generic/common/hal_client_manager.cc
@@ -159,7 +159,8 @@
for (const auto &[procName, id] : mProcessNamesToClientIds) {
if (id == clientId && procName == kSystemServerName) {
- mIsFirstClient = false;
+ LOGE("System server is disconnected");
+ mIsFirstClient = true;
}
}
diff --git a/host/hal_generic/common/multi_client_context_hub_base.cc b/host/hal_generic/common/multi_client_context_hub_base.cc
index 543eb47..950c09f 100644
--- a/host/hal_generic/common/multi_client_context_hub_base.cc
+++ b/host/hal_generic/common/multi_client_context_hub_base.cc
@@ -41,6 +41,7 @@
enum class HalErrorCode : int32_t {
OPERATION_FAILED = -1,
INVALID_RESULT = -2,
+ INVALID_ARGUMENT = -3,
};
bool isValidContextHubId(uint32_t hubId) {
@@ -333,14 +334,14 @@
break;
default:
LOGE("Unsupported host endpoint type %" PRIu32, info.type);
- return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ return fromServiceError(HalErrorCode::INVALID_ARGUMENT);
}
uint16_t endpointId = info.hostEndpointId;
if (!mHalClientManager->registerEndpointId(info.hostEndpointId) ||
!mHalClientManager->mutateEndpointIdFromHostIfNeeded(
AIBinder_getCallingPid(), endpointId)) {
- return ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
+ return fromServiceError(HalErrorCode::INVALID_ARGUMENT);
}
flatbuffers::FlatBufferBuilder builder(64);
HostProtocolHost::encodeHostEndpointConnected(