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

Commit 9f820688 authored by Arthur Ishiguro's avatar Arthur Ishiguro
Browse files

Converts Java reason to HAL reason

Bug: 384043831
Flag: android.chre.flags.offload_implementation
Test: Compile
Change-Id: I63b26a6761df92c9d0f523170a817f6de264a875
parent 7771fc74
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -145,7 +145,8 @@ public class ContextHubEndpointBroker extends IContextHubEndpoint.Stub
        super.closeSession_enforcePermission();
        if (!mIsRegistered.get()) throw new IllegalStateException("Endpoint is not registered");
        try {
            mContextHubProxy.closeEndpointSession(sessionId, (byte) reason);
            mContextHubProxy.closeEndpointSession(
                    sessionId, ContextHubServiceUtil.toHalReason(reason));
        } catch (RemoteException | IllegalArgumentException | UnsupportedOperationException e) {
            Log.e(TAG, "Exception while calling HAL closeEndpointSession", e);
            throw e;
+27 −0
Original line number Diff line number Diff line
@@ -539,6 +539,33 @@ import java.util.List;
        }
    }

    /**
     * Converts a byte integer defined by Reason.aidl to HubEndpoint.Reason values exposed to apps.
     *
     * @param reason The Reason.aidl value
     * @return The converted HubEndpoint.Reason value
     */
    /* package */
    static byte toHalReason(@HubEndpoint.Reason int reason) {
        switch (reason) {
            case HubEndpoint.REASON_FAILURE:
                return Reason.UNSPECIFIED;
            case HubEndpoint.REASON_OPEN_ENDPOINT_SESSION_REQUEST_REJECTED:
                return Reason.OPEN_ENDPOINT_SESSION_REQUEST_REJECTED;
            case HubEndpoint.REASON_CLOSE_ENDPOINT_SESSION_REQUESTED:
                return Reason.CLOSE_ENDPOINT_SESSION_REQUESTED;
            case HubEndpoint.REASON_ENDPOINT_INVALID:
                return Reason.ENDPOINT_INVALID;
            case HubEndpoint.REASON_ENDPOINT_STOPPED:
                return Reason.ENDPOINT_GONE;
            case HubEndpoint.REASON_PERMISSION_DENIED:
                return Reason.PERMISSION_DENIED;
            default:
                Log.w(TAG, "toHalReason: invalid reason: " + reason);
                return Reason.UNSPECIFIED;
        }
    }

    /**
     * Checks that the module with the provided context/pid/uid has all of the provided permissions.
     *