contexthubhal: fix result when hal doesn't send mgmt message to nanohub

Return an error when the hal thinks the app being started is already
running or when the app being unloaded/erased is either not running or
doesn't exist.

Bug: 118398281
Test: pass VtsHalContexthubV1_0
Change-Id: I9c5f884e11c86ba6a608c24614e41784d5d19308
Signed-off-by: Ben Fennema <>
diff --git a/contexthubhal/system_comms.cpp b/contexthubhal/system_comms.cpp
index 6edd0cb..358e2f5 100644
--- a/contexthubhal/system_comms.cpp
+++ b/contexthubhal/system_comms.cpp
@@ -418,7 +418,7 @@
 int SystemComm::AppMgmtSession::setupMgmt(const hub_message_t *appMsg, uint32_t transactionId, uint32_t cmd, AppManager &appManager)
-    int32_t result = 0;
+    int32_t result = -1; // results are only directly returned on failure
     const hub_app_name_t &appName = *static_cast<const hub_app_name_t*>(appMsg->message);
     if (appMsg->message_len != sizeof(appName)) {
         return -EINVAL;