diff --git a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java index cc5aaf4f7f452..f84b68e7c5569 100644 --- a/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java +++ b/services/core/java/com/android/server/location/contexthub/IContextHubWrapper.java @@ -453,8 +453,13 @@ public abstract class IContextHubWrapper { public int sendMessageToContextHub( short hostEndpointId, int contextHubId, NanoAppMessage message) throws RemoteException { - return toTransactionResult(mHub.sendMessageToHub(contextHubId, - ContextHubServiceUtil.createAidlContextHubMessage(hostEndpointId, message))); + try { + mHub.sendMessageToHub(contextHubId, + ContextHubServiceUtil.createAidlContextHubMessage(hostEndpointId, message)); + return ContextHubTransaction.RESULT_SUCCESS; + } catch (RemoteException e) { + return ContextHubTransaction.RESULT_FAILED_UNKNOWN; + } } @ContextHubTransaction.Result @@ -462,31 +467,55 @@ public abstract class IContextHubWrapper { int transactionId) throws RemoteException { android.hardware.contexthub.NanoappBinary aidlNanoAppBinary = ContextHubServiceUtil.createAidlNanoAppBinary(binary); - return toTransactionResult( - mHub.loadNanoapp(contextHubId, aidlNanoAppBinary, transactionId)); + try { + mHub.loadNanoapp(contextHubId, aidlNanoAppBinary, transactionId); + return ContextHubTransaction.RESULT_SUCCESS; + } catch (RemoteException e) { + return ContextHubTransaction.RESULT_FAILED_UNKNOWN; + } } @ContextHubTransaction.Result public int unloadNanoapp(int contextHubId, long nanoappId, int transactionId) throws RemoteException { - return toTransactionResult(mHub.unloadNanoapp(contextHubId, nanoappId, transactionId)); + try { + mHub.unloadNanoapp(contextHubId, nanoappId, transactionId); + return ContextHubTransaction.RESULT_SUCCESS; + } catch (RemoteException e) { + return ContextHubTransaction.RESULT_FAILED_UNKNOWN; + } } @ContextHubTransaction.Result public int enableNanoapp(int contextHubId, long nanoappId, int transactionId) throws RemoteException { - return toTransactionResult(mHub.enableNanoapp(contextHubId, nanoappId, transactionId)); + try { + mHub.enableNanoapp(contextHubId, nanoappId, transactionId); + return ContextHubTransaction.RESULT_SUCCESS; + } catch (RemoteException e) { + return ContextHubTransaction.RESULT_FAILED_UNKNOWN; + } } @ContextHubTransaction.Result public int disableNanoapp(int contextHubId, long nanoappId, int transactionId) throws RemoteException { - return toTransactionResult(mHub.disableNanoapp(contextHubId, nanoappId, transactionId)); + try { + mHub.disableNanoapp(contextHubId, nanoappId, transactionId); + return ContextHubTransaction.RESULT_SUCCESS; + } catch (RemoteException e) { + return ContextHubTransaction.RESULT_FAILED_UNKNOWN; + } } @ContextHubTransaction.Result public int queryNanoapps(int contextHubId) throws RemoteException { - return toTransactionResult(mHub.queryNanoapps(contextHubId)); + try { + mHub.queryNanoapps(contextHubId); + return ContextHubTransaction.RESULT_SUCCESS; + } catch (RemoteException e) { + return ContextHubTransaction.RESULT_FAILED_UNKNOWN; + } } public void registerCallback(int contextHubId, ICallback callback) throws RemoteException { @@ -494,12 +523,6 @@ public abstract class IContextHubWrapper { mHub.registerCallback(contextHubId, mAidlCallbackMap.get(contextHubId)); } - @ContextHubTransaction.Result - private int toTransactionResult(boolean success) { - return success ? ContextHubTransaction.RESULT_SUCCESS - : ContextHubTransaction.RESULT_FAILED_UNKNOWN; - } - private void onSettingChanged(byte setting, boolean enabled) { try { mHub.onSettingChanged(setting, enabled);