Update AidlContextHubWrapper methods

Bug: 213474931
Test: Compile
Change-Id: Icf6d90f24191a49ea27f6aab91075e64b181985e
This commit is contained in:
Arthur Ishiguro
2022-01-07 01:30:39 +00:00
parent 45b002a809
commit 23d05c31b6

View File

@@ -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);