Merge changes Ie1eb63dc,Ib7cc4d52
* changes:
Renames setCallbackOnComplete method in ContextHubTransaction
Rename ContextHubTransaction.Result IntDef
diff --git a/core/java/android/hardware/location/ContextHubManager.java b/core/java/android/hardware/location/ContextHubManager.java
index 6da6fb7..b7ce875 100644
--- a/core/java/android/hardware/location/ContextHubManager.java
+++ b/core/java/android/hardware/location/ContextHubManager.java
@@ -291,7 +291,7 @@
public void onQueryResponse(int result, List<NanoAppState> nanoappList) {
Log.e(TAG, "Received a query callback on a non-query request");
transaction.setResponse(new ContextHubTransaction.Response<Void>(
- ContextHubTransaction.TRANSACTION_FAILED_SERVICE_INTERNAL_FAILURE, null));
+ ContextHubTransaction.RESULT_FAILED_SERVICE_INTERNAL_FAILURE, null));
}
@Override
@@ -323,7 +323,7 @@
public void onTransactionComplete(int result) {
Log.e(TAG, "Received a non-query callback on a query request");
transaction.setResponse(new ContextHubTransaction.Response<List<NanoAppState>>(
- ContextHubTransaction.TRANSACTION_FAILED_SERVICE_INTERNAL_FAILURE, null));
+ ContextHubTransaction.RESULT_FAILED_SERVICE_INTERNAL_FAILURE, null));
}
};
}
diff --git a/core/java/android/hardware/location/ContextHubTransaction.java b/core/java/android/hardware/location/ContextHubTransaction.java
index 2a66cbc..ec1e68f 100644
--- a/core/java/android/hardware/location/ContextHubTransaction.java
+++ b/core/java/android/hardware/location/ContextHubTransaction.java
@@ -34,7 +34,7 @@
* through the ContextHubManager APIs. The caller can either retrieve the result
* synchronously through a blocking call ({@link #waitForResponse(long, TimeUnit)}) or
* asynchronously through a user-defined callback
- * ({@link #setCallbackOnComplete(ContextHubTransaction.Callback, Handler)}).
+ * ({@link #setOnCompleteCallback(ContextHubTransaction.Callback, Handler)}).
*
* @param <T> the type of the contents in the transaction response
*
@@ -66,51 +66,51 @@
* Constants describing the result of a transaction or request through the Context Hub Service.
*/
@Retention(RetentionPolicy.SOURCE)
- @IntDef(prefix = { "TRANSACTION_" }, value = {
- TRANSACTION_SUCCESS,
- TRANSACTION_FAILED_UNKNOWN,
- TRANSACTION_FAILED_BAD_PARAMS,
- TRANSACTION_FAILED_UNINITIALIZED,
- TRANSACTION_FAILED_PENDING,
- TRANSACTION_FAILED_AT_HUB,
- TRANSACTION_FAILED_TIMEOUT,
- TRANSACTION_FAILED_SERVICE_INTERNAL_FAILURE,
- TRANSACTION_FAILED_HAL_UNAVAILABLE
+ @IntDef(prefix = { "RESULT_" }, value = {
+ RESULT_SUCCESS,
+ RESULT_FAILED_UNKNOWN,
+ RESULT_FAILED_BAD_PARAMS,
+ RESULT_FAILED_UNINITIALIZED,
+ RESULT_FAILED_PENDING,
+ RESULT_FAILED_AT_HUB,
+ RESULT_FAILED_TIMEOUT,
+ RESULT_FAILED_SERVICE_INTERNAL_FAILURE,
+ RESULT_FAILED_HAL_UNAVAILABLE
})
public @interface Result {}
- public static final int TRANSACTION_SUCCESS = 0;
+ public static final int RESULT_SUCCESS = 0;
/**
* Generic failure mode.
*/
- public static final int TRANSACTION_FAILED_UNKNOWN = 1;
+ public static final int RESULT_FAILED_UNKNOWN = 1;
/**
* Failure mode when the request parameters were not valid.
*/
- public static final int TRANSACTION_FAILED_BAD_PARAMS = 2;
+ public static final int RESULT_FAILED_BAD_PARAMS = 2;
/**
* Failure mode when the Context Hub is not initialized.
*/
- public static final int TRANSACTION_FAILED_UNINITIALIZED = 3;
+ public static final int RESULT_FAILED_UNINITIALIZED = 3;
/**
* Failure mode when there are too many transactions pending.
*/
- public static final int TRANSACTION_FAILED_PENDING = 4;
+ public static final int RESULT_FAILED_PENDING = 4;
/**
* Failure mode when the request went through, but failed asynchronously at the hub.
*/
- public static final int TRANSACTION_FAILED_AT_HUB = 5;
+ public static final int RESULT_FAILED_AT_HUB = 5;
/**
* Failure mode when the transaction has timed out.
*/
- public static final int TRANSACTION_FAILED_TIMEOUT = 6;
+ public static final int RESULT_FAILED_TIMEOUT = 6;
/**
* Failure mode when the transaction has failed internally at the service.
*/
- public static final int TRANSACTION_FAILED_SERVICE_INTERNAL_FAILURE = 7;
+ public static final int RESULT_FAILED_SERVICE_INTERNAL_FAILURE = 7;
/**
* Failure mode when the Context Hub HAL was not available.
*/
- public static final int TRANSACTION_FAILED_HAL_UNAVAILABLE = 8;
+ public static final int RESULT_FAILED_HAL_UNAVAILABLE = 8;
/**
* A class describing the response for a ContextHubTransaction.
@@ -271,7 +271,7 @@
* A transaction can be invalidated if the process owning the transaction is no longer active
* and the reference to this object is lost.
*
- * This method or {@link #setCallbackOnComplete(ContextHubTransaction.Callback)} can only be
+ * This method or {@link #setOnCompleteCallback(ContextHubTransaction.Callback)} can only be
* invoked once, or an IllegalStateException will be thrown.
*
* @param callback the callback to be invoked upon completion
@@ -280,7 +280,7 @@
* @throws IllegalStateException if this method is called multiple times
* @throws NullPointerException if the callback or handler is null
*/
- public void setCallbackOnComplete(
+ public void setOnCompleteCallback(
@NonNull ContextHubTransaction.Callback<T> callback, @NonNull Handler handler) {
synchronized (this) {
if (callback == null) {
@@ -312,10 +312,10 @@
/**
* Sets a callback to be invoked when the transaction completes.
*
- * Equivalent to {@link #setCallbackOnComplete(ContextHubTransaction.Callback, Handler)}
+ * Equivalent to {@link #setOnCompleteCallback(ContextHubTransaction.Callback, Handler)}
* with the handler being that of the main thread's Looper.
*
- * This method or {@link #setCallbackOnComplete(ContextHubTransaction.Callback, Handler)}
+ * This method or {@link #setOnCompleteCallback(ContextHubTransaction.Callback, Handler)}
* can only be invoked once, or an IllegalStateException will be thrown.
*
* @param callback the callback to be invoked upon completion
@@ -323,8 +323,8 @@
* @throws IllegalStateException if this method is called multiple times
* @throws NullPointerException if the callback is null
*/
- public void setCallbackOnComplete(@NonNull ContextHubTransaction.Callback<T> callback) {
- setCallbackOnComplete(callback, new Handler(Looper.getMainLooper()));
+ public void setOnCompleteCallback(@NonNull ContextHubTransaction.Callback<T> callback) {
+ setOnCompleteCallback(callback, new Handler(Looper.getMainLooper()));
}
/**
diff --git a/services/core/java/com/android/server/location/ContextHubService.java b/services/core/java/com/android/server/location/ContextHubService.java
index 26edf62..dc95d41 100644
--- a/services/core/java/com/android/server/location/ContextHubService.java
+++ b/services/core/java/com/android/server/location/ContextHubService.java
@@ -482,7 +482,7 @@
IContextHubClient client = mDefaultClientMap.get(contextHubHandle);
success = (client.sendMessageToNanoApp(message) ==
- ContextHubTransaction.TRANSACTION_SUCCESS);
+ ContextHubTransaction.RESULT_SUCCESS);
} else {
Log.e(TAG, "Failed to send nanoapp message - nanoapp with handle "
+ nanoAppHandle + " does not exist.");
@@ -642,7 +642,7 @@
if (nanoAppBinary == null) {
Log.e(TAG, "NanoAppBinary cannot be null in loadNanoAppOnHub");
transactionCallback.onTransactionComplete(
- ContextHubTransaction.TRANSACTION_FAILED_BAD_PARAMS);
+ ContextHubTransaction.RESULT_FAILED_BAD_PARAMS);
return;
}
@@ -817,7 +817,7 @@
if (mContextHubProxy == null) {
try {
callback.onTransactionComplete(
- ContextHubTransaction.TRANSACTION_FAILED_HAL_UNAVAILABLE);
+ ContextHubTransaction.RESULT_FAILED_HAL_UNAVAILABLE);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException while calling onTransactionComplete", e);
}
@@ -828,7 +828,7 @@
+ ContextHubTransaction.typeToString(transactionType, false /* upperCase */)
+ " transaction for invalid hub ID " + contextHubId);
try {
- callback.onTransactionComplete(ContextHubTransaction.TRANSACTION_FAILED_BAD_PARAMS);
+ callback.onTransactionComplete(ContextHubTransaction.RESULT_FAILED_BAD_PARAMS);
} catch (RemoteException e) {
Log.e(TAG, "RemoteException while calling onTransactionComplete", e);
}
diff --git a/services/core/java/com/android/server/location/ContextHubServiceUtil.java b/services/core/java/com/android/server/location/ContextHubServiceUtil.java
index 7a57dd3..c356b63 100644
--- a/services/core/java/com/android/server/location/ContextHubServiceUtil.java
+++ b/services/core/java/com/android/server/location/ContextHubServiceUtil.java
@@ -215,17 +215,17 @@
static int toTransactionResult(int halResult) {
switch (halResult) {
case Result.OK:
- return ContextHubTransaction.TRANSACTION_SUCCESS;
+ return ContextHubTransaction.RESULT_SUCCESS;
case Result.BAD_PARAMS:
- return ContextHubTransaction.TRANSACTION_FAILED_BAD_PARAMS;
+ return ContextHubTransaction.RESULT_FAILED_BAD_PARAMS;
case Result.NOT_INIT:
- return ContextHubTransaction.TRANSACTION_FAILED_UNINITIALIZED;
+ return ContextHubTransaction.RESULT_FAILED_UNINITIALIZED;
case Result.TRANSACTION_PENDING:
- return ContextHubTransaction.TRANSACTION_FAILED_PENDING;
+ return ContextHubTransaction.RESULT_FAILED_PENDING;
case Result.TRANSACTION_FAILED:
case Result.UNKNOWN_FAILURE:
default: /* fall through */
- return ContextHubTransaction.TRANSACTION_FAILED_UNKNOWN;
+ return ContextHubTransaction.RESULT_FAILED_UNKNOWN;
}
}
}
diff --git a/services/core/java/com/android/server/location/ContextHubTransactionManager.java b/services/core/java/com/android/server/location/ContextHubTransactionManager.java
index 412d43d..cced781 100644
--- a/services/core/java/com/android/server/location/ContextHubTransactionManager.java
+++ b/services/core/java/com/android/server/location/ContextHubTransactionManager.java
@@ -120,7 +120,7 @@
@Override
/* package */ void onTransactionComplete(@ContextHubTransaction.Result int result) {
- if (result == ContextHubTransaction.TRANSACTION_SUCCESS) {
+ if (result == ContextHubTransaction.RESULT_SUCCESS) {
// NOTE: The legacy JNI code used to do a query right after a load success
// to synchronize the service cache. Instead store the binary that was
// requested to load to update the cache later without doing a query.
@@ -130,7 +130,7 @@
}
try {
onCompleteCallback.onTransactionComplete(result);
- if (result == ContextHubTransaction.TRANSACTION_SUCCESS) {
+ if (result == ContextHubTransaction.RESULT_SUCCESS) {
mClientManager.onNanoAppLoaded(contextHubId, nanoAppBinary.getNanoAppId());
}
} catch (RemoteException e) {
@@ -166,12 +166,12 @@
@Override
/* package */ void onTransactionComplete(@ContextHubTransaction.Result int result) {
- if (result == ContextHubTransaction.TRANSACTION_SUCCESS) {
+ if (result == ContextHubTransaction.RESULT_SUCCESS) {
mNanoAppStateManager.removeNanoAppInstance(contextHubId, nanoAppId);
}
try {
onCompleteCallback.onTransactionComplete(result);
- if (result == ContextHubTransaction.TRANSACTION_SUCCESS) {
+ if (result == ContextHubTransaction.RESULT_SUCCESS) {
mClientManager.onNanoAppUnloaded(contextHubId, nanoAppId);
}
} catch (RemoteException e) {
@@ -334,8 +334,8 @@
transaction.onTransactionComplete(
(result == TransactionResult.SUCCESS) ?
- ContextHubTransaction.TRANSACTION_SUCCESS :
- ContextHubTransaction.TRANSACTION_FAILED_AT_HUB);
+ ContextHubTransaction.RESULT_SUCCESS :
+ ContextHubTransaction.RESULT_FAILED_AT_HUB);
removeTransactionAndStartNext();
}
@@ -356,7 +356,7 @@
return;
}
- transaction.onQueryResponse(ContextHubTransaction.TRANSACTION_SUCCESS, nanoAppStateList);
+ transaction.onQueryResponse(ContextHubTransaction.RESULT_SUCCESS, nanoAppStateList);
removeTransactionAndStartNext();
}
@@ -416,7 +416,7 @@
if (!transaction.isComplete()) {
Log.d(TAG, transaction + " timed out");
transaction.onTransactionComplete(
- ContextHubTransaction.TRANSACTION_FAILED_TIMEOUT);
+ ContextHubTransaction.RESULT_FAILED_TIMEOUT);
removeTransactionAndStartNext();
}