Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6100aa7e authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Rename ContextHubTransaction.Result IntDef

Use RESULT_ instead of TRANSACTION_ to be consistent with the name.

Bug: 67734082
Test: make
Change-Id: Ib7cc4d527cc160ec6788449231cdffa5c3e8fc0d
parent 13eec469
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -291,7 +291,7 @@ public final class ContextHubManager {
            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 final class ContextHubManager {
            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));
            }
        };
    }
+19 −19
Original line number Diff line number Diff line
@@ -66,51 +66,51 @@ public class ContextHubTransaction<T> {
     * 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.
+4 −4
Original line number Diff line number Diff line
@@ -482,7 +482,7 @@ public class ContextHubService extends IContextHubService.Stub {

                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 @@ public class ContextHubService extends IContextHubService.Stub {
        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 @@ public class ContextHubService extends IContextHubService.Stub {
        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 @@ public class ContextHubService extends IContextHubService.Stub {
                    + 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);
            }
+5 −5
Original line number Diff line number Diff line
@@ -215,17 +215,17 @@ import java.util.ArrayList;
    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;
        }
    }
}
+8 −8
Original line number Diff line number Diff line
@@ -120,7 +120,7 @@ import java.util.concurrent.atomic.AtomicInteger;

            @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 @@ import java.util.concurrent.atomic.AtomicInteger;
                }
                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 @@ import java.util.concurrent.atomic.AtomicInteger;

            @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 @@ import java.util.concurrent.atomic.AtomicInteger;

        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 @@ import java.util.concurrent.atomic.AtomicInteger;
            return;
        }

        transaction.onQueryResponse(ContextHubTransaction.TRANSACTION_SUCCESS, nanoAppStateList);
        transaction.onQueryResponse(ContextHubTransaction.RESULT_SUCCESS, nanoAppStateList);
        removeTransactionAndStartNext();
    }

@@ -416,7 +416,7 @@ import java.util.concurrent.atomic.AtomicInteger;
                        if (!transaction.isComplete()) {
                            Log.d(TAG, transaction + " timed out");
                            transaction.onTransactionComplete(
                                    ContextHubTransaction.TRANSACTION_FAILED_TIMEOUT);
                                    ContextHubTransaction.RESULT_FAILED_TIMEOUT);

                            removeTransactionAndStartNext();
                        }