nanohub HAL: return 0 on successful management operations

Bug: 31824213
Change-Id: I8ea2e6a60207349a8dfdd59e82c3c1532754f5dc
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
diff --git a/contexthubhal/system_comms.cpp b/contexthubhal/system_comms.cpp
index fe4a18a..840607a 100644
--- a/contexthubhal/system_comms.cpp
+++ b/contexthubhal/system_comms.cpp
@@ -430,6 +430,16 @@
     bool valid = false;
 
     ALOGI("Nanohub MGMT response: CMD=%02X; STATUS=%08" PRIX32, rsp.cmd, rsp.status);
+    int32_t result = rsp.status;
+
+    // TODO: remove this when context hub service can handle non-zero success status
+    if (result > 0) {
+        // something happened; assume it worked
+        result = 0;
+    } else if (result == 0) {
+        // nothing happened; this is provably an error
+        result = -1;
+    }
 
     switch (rsp.cmd) {
     case NANOHUB_EXT_APPS_OFF:
@@ -450,7 +460,7 @@
         return -EINVAL;
     }
 
-    sendToApp(mCmd, &rsp.status, sizeof(rsp.status));
+    sendToApp(mCmd, &result, sizeof(result));
     complete();
 
     return 0;