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

Commit 699d25c0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Refactor handling of <Feature Abort> responses" into sc-dev

parents ab77b87f 9b7f74f6
Loading
Loading
Loading
Loading
+18 −3
Original line number Original line Diff line number Diff line
@@ -250,7 +250,19 @@ final class Constants {


    @Retention(RetentionPolicy.SOURCE)
    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
    @IntDef({
        ABORT_NO_ERROR,
            NOT_HANDLED,
            HANDLED,
            ABORT_UNRECOGNIZED_OPCODE,
            ABORT_NOT_IN_CORRECT_MODE,
            ABORT_CANNOT_PROVIDE_SOURCE,
            ABORT_INVALID_OPERAND,
            ABORT_REFUSED,
            ABORT_UNABLE_TO_DETERMINE,
    })
    public @interface HandleMessageResult {}

    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
        ABORT_UNRECOGNIZED_OPCODE,
        ABORT_UNRECOGNIZED_OPCODE,
        ABORT_NOT_IN_CORRECT_MODE,
        ABORT_NOT_IN_CORRECT_MODE,
        ABORT_CANNOT_PROVIDE_SOURCE,
        ABORT_CANNOT_PROVIDE_SOURCE,
@@ -260,8 +272,11 @@ final class Constants {
    })
    })
    public @interface AbortReason {}
    public @interface AbortReason {}


    // Internal abort error code. It's the same as success.
    // Indicates that a message was not handled, but could be handled by another local device.
    static final int ABORT_NO_ERROR = -1;
    // If no local devices handle the message, we send <Feature Abort>[Unrecognized Opcode].
    static final int NOT_HANDLED = -2;
    // Indicates that a message has been handled successfully; no feature abort needed.
    static final int HANDLED = -1;
    // Constants related to operands of HDMI CEC commands.
    // Constants related to operands of HDMI CEC commands.
    // Refer to CEC Table 29 in HDMI Spec v1.4b.
    // Refer to CEC Table 29 in HDMI Spec v1.4b.
    // [Abort Reason]
    // [Abort Reason]
+12 −7
Original line number Original line Diff line number Diff line
@@ -565,19 +565,24 @@ final class HdmiCecController {
    }
    }


    @ServiceThreadOnly
    @ServiceThreadOnly
    private void onReceiveCommand(HdmiCecMessage message) {
    @VisibleForTesting
    void onReceiveCommand(HdmiCecMessage message) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        if ((isAcceptableAddress(message.getDestination())
        if (mService.isAddressAllocated() && !isAcceptableAddress(message.getDestination())) {
            || !mService.isAddressAllocated())
            && mService.handleCecCommand(message)) {
            return;
            return;
        }
        }
        // Not handled message, so we will reply it with <Feature Abort>.
        @Constants.HandleMessageResult int messageState = mService.handleCecCommand(message);
        if (messageState == Constants.NOT_HANDLED) {
            // Message was not handled
            maySendFeatureAbortCommand(message, Constants.ABORT_UNRECOGNIZED_OPCODE);
            maySendFeatureAbortCommand(message, Constants.ABORT_UNRECOGNIZED_OPCODE);
        } else if (messageState != Constants.HANDLED) {
            // Message handler wants to send a feature abort
            maySendFeatureAbortCommand(message, messageState);
        }
    }
    }


    @ServiceThreadOnly
    @ServiceThreadOnly
    void maySendFeatureAbortCommand(HdmiCecMessage message, int reason) {
    void maySendFeatureAbortCommand(HdmiCecMessage message, @Constants.AbortReason int reason) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        // Swap the source and the destination.
        // Swap the source and the destination.
        int src = message.getDestination();
        int src = message.getDestination();
+154 −109

File changed.

Preview size limit exceeded, changes collapsed.

+55 −48

File changed.

Preview size limit exceeded, changes collapsed.

+22 −16

File changed.

Preview size limit exceeded, changes collapsed.

Loading