ipa: check return status of HAL calls

If the underlying HAL service object is invalidated, it
might result in a HAL transaction failure and the ipacm
process would be forced to abort.

To prevent the transaction error, use the isOk check right
after the HAL API is invoked to check whether the HAL
transaction was successful or not.

Change-Id: I4d71b35b6a31a6b705c1f61b542e1e82d1716a21
CRs-Fixed: 2340020
diff --git a/hal/src/IpaEventRelay.cpp b/hal/src/IpaEventRelay.cpp
index 788b152..137092f 100644
--- a/hal/src/IpaEventRelay.cpp
+++ b/hal/src/IpaEventRelay.cpp
@@ -47,37 +47,50 @@
 
 void IpaEventRelay::onOffloadStarted() {
     ALOGI("onOffloadStarted()");
-    mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STARTED);
+    auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STARTED);
+    if (!ret.isOk()) {
+        ALOGE("Triggering OffloadStarted Callback failed.");
+    }
 } /* onOffloadStarted */
 
 void IpaEventRelay::onOffloadStopped(StoppedReason reason) {
     ALOGI("onOffloadStopped(%d)", reason);
-    switch (reason) {
-        case REQUESTED:
-            /*
-             * No way to communicate this to Framework right now, they make an
-             * assumption that offload is stopped when they remove the
-             * configuration.
-             */
-             break;
-        case ERROR:
-            mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_ERROR);
-            break;
-        case UNSUPPORTED:
-            mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_UNSUPPORTED);
-            break;
-        default:
-            ALOGE("Unknown stopped reason(%d)", reason);
-            break;
+    if( reason == StoppedReason::REQUESTED ) {
+        /*
+         * No way to communicate this to Framework right now, they make an
+         * assumption that offload is stopped when they remove the
+         * configuration.
+         */
+    }
+    else if ( reason == StoppedReason::ERROR ) {
+        auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_ERROR);
+        if (!ret.isOk()) {
+            ALOGE("Triggering OffloadStopped Callback failed.");
+        }
+    }
+    else if ( reason == StoppedReason::UNSUPPORTED ) {
+        auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_UNSUPPORTED);
+        if (!ret.isOk()) {
+            ALOGE("Triggering OffloadStopped Callback failed.");
+        }
+    }
+    else {
+        ALOGE("Unknown stopped reason(%d)", reason);
     }
 } /* onOffloadStopped */
 
 void IpaEventRelay::onOffloadSupportAvailable() {
     ALOGI("onOffloadSupportAvailable()");
-    mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_SUPPORT_AVAILABLE);
+    auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_SUPPORT_AVAILABLE);
+    if (!ret.isOk()) {
+        ALOGE("Triggering OffloadSupportAvailable Callback failed.");
+    }
 } /* onOffloadSupportAvailable */
 
 void IpaEventRelay::onLimitReached() {
     ALOGI("onLimitReached()");
-    mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_LIMIT_REACHED);
+    auto ret = mFramework->onEvent(OffloadCallbackEvent::OFFLOAD_STOPPED_LIMIT_REACHED);
+    if (!ret.isOk()) {
+        ALOGE("Triggering LimitReached Callback failed.");
+    }
 } /* onLimitReached */