diff options
| -rw-r--r-- | services/core/java/com/android/server/location/ContextHubServiceTransaction.java | 12 | ||||
| -rw-r--r-- | services/core/java/com/android/server/location/ContextHubTransactionManager.java | 32 |
2 files changed, 14 insertions, 30 deletions
diff --git a/services/core/java/com/android/server/location/ContextHubServiceTransaction.java b/services/core/java/com/android/server/location/ContextHubServiceTransaction.java index 66145bbb9784..a543dafc1ed1 100644 --- a/services/core/java/com/android/server/location/ContextHubServiceTransaction.java +++ b/services/core/java/com/android/server/location/ContextHubServiceTransaction.java @@ -54,18 +54,10 @@ import java.util.concurrent.TimeUnit; abstract int onTransact(); /** - * A function to invoke when a transaction times out. - * - * All instances of this class must implement this method by reporting the timeout to the - * client. - */ - /* package */ - abstract void onTimeout(); - - /** * A function to invoke when the transaction completes. * - * Only relevant for load, unload, enable, or disable transactions. + * For transactions with expected contents (such as a query), the class instance should + * implement the appropriate behavior (e.g. invoke onQueryResponse with an empty list). * * @param result the result of the transaction */ diff --git a/services/core/java/com/android/server/location/ContextHubTransactionManager.java b/services/core/java/com/android/server/location/ContextHubTransactionManager.java index 47d9d5686140..3fcc682cf143 100644 --- a/services/core/java/com/android/server/location/ContextHubTransactionManager.java +++ b/services/core/java/com/android/server/location/ContextHubTransactionManager.java @@ -106,17 +106,12 @@ import java.util.concurrent.atomic.AtomicInteger; contextHubId, hidlNanoAppBinary, this.getTransactionId()); } catch (RemoteException e) { Log.e(TAG, "RemoteException while trying to load nanoapp with ID 0x" + - Long.toHexString(nanoAppBinary.getNanoAppId())); + Long.toHexString(nanoAppBinary.getNanoAppId()), e); return Result.UNKNOWN_FAILURE; } } @Override - /* package */ void onTimeout() { - onTransactionComplete(ContextHubTransaction.TRANSACTION_FAILED_TIMEOUT); - } - - @Override /* package */ void onTransactionComplete(int result) { try { onCompleteCallback.onTransactionComplete(result); @@ -124,7 +119,7 @@ import java.util.concurrent.atomic.AtomicInteger; mClientManager.onNanoAppLoaded(contextHubId, nanoAppBinary.getNanoAppId()); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException while calling client onTransactionComplete"); + Log.e(TAG, "RemoteException while calling client onTransactionComplete", e); } } }; @@ -149,17 +144,12 @@ import java.util.concurrent.atomic.AtomicInteger; contextHubId, nanoAppId, this.getTransactionId()); } catch (RemoteException e) { Log.e(TAG, "RemoteException while trying to unload nanoapp with ID 0x" + - Long.toHexString(nanoAppId)); + Long.toHexString(nanoAppId), e); return Result.UNKNOWN_FAILURE; } } @Override - /* package */ void onTimeout() { - onTransactionComplete(ContextHubTransaction.TRANSACTION_FAILED_TIMEOUT); - } - - @Override /* package */ void onTransactionComplete(int result) { try { onCompleteCallback.onTransactionComplete(result); @@ -167,7 +157,7 @@ import java.util.concurrent.atomic.AtomicInteger; mClientManager.onNanoAppUnloaded(contextHubId, nanoAppId); } } catch (RemoteException e) { - Log.e(TAG, "RemoteException while calling client onTransactionComplete"); + Log.e(TAG, "RemoteException while calling client onTransactionComplete", e); } } }; @@ -189,15 +179,14 @@ import java.util.concurrent.atomic.AtomicInteger; try { return mContextHubProxy.queryApps(contextHubId); } catch (RemoteException e) { - Log.e(TAG, "RemoteException while trying to query for nanoapps"); + Log.e(TAG, "RemoteException while trying to query for nanoapps", e); return Result.UNKNOWN_FAILURE; } } @Override - /* package */ void onTimeout() { - onQueryResponse(ContextHubTransaction.TRANSACTION_FAILED_TIMEOUT, - Collections.emptyList()); + /* package */ void onTransactionComplete(int result) { + onQueryResponse(result, Collections.emptyList()); } @Override @@ -205,7 +194,7 @@ import java.util.concurrent.atomic.AtomicInteger; try { onCompleteCallback.onQueryResponse(result, nanoAppStateList); } catch (RemoteException e) { - Log.e(TAG, "RemoteException while calling client onQueryComplete"); + Log.e(TAG, "RemoteException while calling client onQueryComplete", e); } } }; @@ -333,7 +322,8 @@ import java.util.concurrent.atomic.AtomicInteger; synchronized (this) { if (!transaction.isComplete()) { Log.d(TAG, transaction + " timed out"); - transaction.onTimeout(); + transaction.onTransactionComplete( + ContextHubTransaction.TRANSACTION_FAILED_TIMEOUT); removeTransactionAndStartNext(); } @@ -344,6 +334,8 @@ import java.util.concurrent.atomic.AtomicInteger; mTimeoutFuture = mTimeoutExecutor.schedule(onTimeoutFunc, timeoutSeconds, TimeUnit.SECONDS); } else { + transaction.onTransactionComplete( + ContextHubServiceUtil.toTransactionResult(result)); mTransactionQueue.remove(); } } |