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

Commit 9fa9bdd1 authored by Yan Han's avatar Yan Han Committed by Automerger Merge Worker
Browse files

Merge changes Ifebc283a,I146fd248 into tm-dev am: a7a729e9

parents 8ad9e976 a7a729e9
Loading
Loading
Loading
Loading
+17 −28
Original line number Original line Diff line number Diff line
@@ -810,35 +810,24 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        }
        }
    }
    }


    /**
     * Change ARC status into the given {@code enabled} status.
     *
     * @return {@code true} if ARC was in "Enabled" status
     */
    @ServiceThreadOnly
    @ServiceThreadOnly
    boolean setArcStatus(boolean enabled) {
    void enableArc(List<byte[]> supportedSads) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        HdmiLogger.debug("Set Arc Status[old:%b new:true]", mArcEstablished);


        HdmiLogger.debug("Set Arc Status[old:%b new:%b]", mArcEstablished, enabled);
        enableAudioReturnChannel(true);
        boolean oldStatus = mArcEstablished;
        notifyArcStatusToAudioService(true, supportedSads);
        if (enabled) {
        mArcEstablished = true;
            RequestSadAction action = new RequestSadAction(
                    this, Constants.ADDR_AUDIO_SYSTEM,
                    new RequestSadAction.RequestSadCallback() {
                        @Override
                        public void onRequestSadDone(List<byte[]> supportedSads) {
                            enableAudioReturnChannel(enabled);
                            notifyArcStatusToAudioService(enabled, supportedSads);
                            mArcEstablished = enabled;
    }
    }
                    });

            addAndStartAction(action);
    @ServiceThreadOnly
        } else {
    void disableArc() {
            enableAudioReturnChannel(enabled);
        assertRunOnServiceThread();
            notifyArcStatusToAudioService(enabled, new ArrayList<>());
        HdmiLogger.debug("Set Arc Status[old:%b new:false]", mArcEstablished);
            mArcEstablished = enabled;

        }
        enableAudioReturnChannel(false);
        return oldStatus;
        notifyArcStatusToAudioService(false, new ArrayList<>());
        mArcEstablished = false;
    }
    }


    /**
    /**
@@ -1066,7 +1055,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    protected int handleTerminateArc(HdmiCecMessage message) {
    protected int handleTerminateArc(HdmiCecMessage message) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        if (mService .isPowerStandbyOrTransient()) {
        if (mService .isPowerStandbyOrTransient()) {
            setArcStatus(false);
            disableArc();
            return Constants.HANDLED;
            return Constants.HANDLED;
        }
        }
        // Do not check ARC configuration since the AVR might have been already removed.
        // Do not check ARC configuration since the AVR might have been already removed.
@@ -1353,7 +1342,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        if (avr == null) {
        if (avr == null) {
            return;
            return;
        }
        }
        setArcStatus(false);
        disableArc();


        // Seq #44.
        // Seq #44.
        removeAllRunningArcAction();
        removeAllRunningArcAction();
+1 −1
Original line number Original line Diff line number Diff line
@@ -63,7 +63,7 @@ abstract class RequestArcAction extends HdmiCecFeatureAction {
                    finish();
                    finish();
                    return true;
                    return true;
                } else if (originalOpcode == Constants.MESSAGE_REQUEST_ARC_INITIATION) {
                } else if (originalOpcode == Constants.MESSAGE_REQUEST_ARC_INITIATION) {
                    tv().setArcStatus(false);
                    tv().disableArc();
                    finish();
                    finish();
                    return true;
                    return true;
                }
                }
+1 −1
Original line number Original line Diff line number Diff line
@@ -48,7 +48,7 @@ final class RequestArcInitiationAction extends RequestArcAction {
            public void onSendCompleted(int error) {
            public void onSendCompleted(int error) {
                if (error != SendMessageResult.SUCCESS) {
                if (error != SendMessageResult.SUCCESS) {
                    // Turn off ARC status if <Request ARC Initiation> fails.
                    // Turn off ARC status if <Request ARC Initiation> fails.
                    tv().setArcStatus(false);
                    tv().disableArc();
                    finish();
                    finish();
                }
                }
            }
            }
+17 −10
Original line number Original line Diff line number Diff line
@@ -181,14 +181,21 @@ final class RequestSadAction extends HdmiCecFeatureAction {
            return true;
            return true;
        }
        }
        if (cmd.getOpcode() == Constants.MESSAGE_FEATURE_ABORT
        if (cmd.getOpcode() == Constants.MESSAGE_FEATURE_ABORT
                && (cmd.getParams()[0] & 0xFF) == Constants.MESSAGE_REQUEST_SHORT_AUDIO_DESCRIPTOR
                && (cmd.getParams()[0] & 0xFF)
                && (cmd.getParams()[1] & 0xFF) == Constants.ABORT_INVALID_OPERAND) {
                == Constants.MESSAGE_REQUEST_SHORT_AUDIO_DESCRIPTOR) {
            if ((cmd.getParams()[1] & 0xFF) == Constants.ABORT_UNRECOGNIZED_OPCODE) {
                // SAD feature is not supported
                wrapUpAndFinish();
                return true;
            }
            if ((cmd.getParams()[1] & 0xFF) == Constants.ABORT_INVALID_OPERAND) {
                // Queried SADs are not supported
                // Queried SADs are not supported
                mQueriedSadCount += MAX_SAD_PER_REQUEST;
                mQueriedSadCount += MAX_SAD_PER_REQUEST;
                mTimeoutRetry = 0;
                mTimeoutRetry = 0;
                querySad();
                querySad();
                return true;
                return true;
            }
            }
        }
        return false;
        return false;
    }
    }


@@ -211,9 +218,9 @@ final class RequestSadAction extends HdmiCecFeatureAction {
                querySad();
                querySad();
                return;
                return;
            }
            }
            mQueriedSadCount += MAX_SAD_PER_REQUEST;
            // Don't query any other SADs if one of the SAD queries ran into the maximum amount of
            mTimeoutRetry = 0;
            // retries.
            querySad();
            wrapUpAndFinish();
        }
        }
    }
    }


+33 −25
Original line number Original line Diff line number Diff line
@@ -20,6 +20,8 @@ import android.hardware.hdmi.HdmiDeviceInfo;
import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.hardware.tv.cec.V1_0.SendMessageResult;
import android.util.Slog;
import android.util.Slog;


import java.util.List;

/**
/**
 * Feature action that handles enabling/disabling of ARC transmission channel.
 * Feature action that handles enabling/disabling of ARC transmission channel.
 * Once TV gets &lt;Initiate ARC&gt;, TV sends &lt;Report ARC Initiated&gt; to AV Receiver.
 * Once TV gets &lt;Initiate ARC&gt;, TV sends &lt;Report ARC Initiated&gt; to AV Receiver.
@@ -55,6 +57,12 @@ final class SetArcTransmissionStateAction extends HdmiCecFeatureAction {
    boolean start() {
    boolean start() {
        // Seq #37.
        // Seq #37.
        if (mEnabled) {
        if (mEnabled) {
            // Request SADs before enabling ARC
            RequestSadAction action = new RequestSadAction(
                    localDevice(), Constants.ADDR_AUDIO_SYSTEM,
                    new RequestSadAction.RequestSadCallback() {
                        @Override
                        public void onRequestSadDone(List<byte[]> supportedSads) {
                            // Enable ARC status immediately before sending <Report Arc Initiated>.
                            // Enable ARC status immediately before sending <Report Arc Initiated>.
                            // If AVR responds with <Feature Abort>, disable ARC status again.
                            // If AVR responds with <Feature Abort>, disable ARC status again.
                            // This is different from spec that says that turns ARC status to
                            // This is different from spec that says that turns ARC status to
@@ -62,14 +70,18 @@ final class SetArcTransmissionStateAction extends HdmiCecFeatureAction {
                            // <Feature Abort> is received.
                            // <Feature Abort> is received.
                            // But implemented this way to save the time having to wait for
                            // But implemented this way to save the time having to wait for
                            // <Feature Abort>.
                            // <Feature Abort>.
            setArcStatus(true);
                            Slog.i(TAG, "Enabling ARC");
            // If succeeds to send <Report ARC Initiated>, wait general timeout
                            tv().enableArc(supportedSads);
            // to check whether there is no <Feature Abort> for <Report ARC Initiated>.
                            // If succeeds to send <Report ARC Initiated>, wait general timeout to
                            // check whether there is no <Feature Abort> for <Report ARC Initiated>.
                            mState = STATE_WAITING_TIMEOUT;
                            mState = STATE_WAITING_TIMEOUT;
                            addTimer(mState, HdmiConfig.TIMEOUT_MS);
                            addTimer(mState, HdmiConfig.TIMEOUT_MS);
                            sendReportArcInitiated();
                            sendReportArcInitiated();
                        }
                    });
            addAndStartAction(action);
        } else {
        } else {
            setArcStatus(false);
            disableArc();
            finish();
            finish();
        }
        }
        return true;
        return true;
@@ -92,7 +104,7 @@ final class SetArcTransmissionStateAction extends HdmiCecFeatureAction {
                    case SendMessageResult.NACK:
                    case SendMessageResult.NACK:
                        // If <Report ARC Initiated> is negatively ack'ed, disable ARC and
                        // If <Report ARC Initiated> is negatively ack'ed, disable ARC and
                        // send <Report ARC Terminated> directly.
                        // send <Report ARC Terminated> directly.
                        setArcStatus(false);
                        disableArc();
                        HdmiLogger.debug("Failed to send <Report Arc Initiated>.");
                        HdmiLogger.debug("Failed to send <Report Arc Initiated>.");
                        finish();
                        finish();
                        break;
                        break;
@@ -101,17 +113,13 @@ final class SetArcTransmissionStateAction extends HdmiCecFeatureAction {
        });
        });
    }
    }


    private void setArcStatus(boolean enabled) {
    private void disableArc() {
        tv().setArcStatus(enabled);
        Slog.i(TAG, "Disabling ARC");
        Slog.i(TAG, "Change arc status to " + enabled);


        // If enabled before and set to "disabled" and send <Report Arc Terminated> to
        tv().disableArc();
        // av reciever.
        if (!enabled) {
        sendCommand(HdmiCecMessageBuilder.buildReportArcTerminated(getSourceAddress(),
        sendCommand(HdmiCecMessageBuilder.buildReportArcTerminated(getSourceAddress(),
                mAvrAddress));
                mAvrAddress));
    }
    }
    }


    @Override
    @Override
    boolean processCommand(HdmiCecMessage cmd) {
    boolean processCommand(HdmiCecMessage cmd) {
@@ -124,7 +132,7 @@ final class SetArcTransmissionStateAction extends HdmiCecFeatureAction {
            int originalOpcode = cmd.getParams()[0] & 0xFF;
            int originalOpcode = cmd.getParams()[0] & 0xFF;
            if (originalOpcode == Constants.MESSAGE_REPORT_ARC_INITIATED) {
            if (originalOpcode == Constants.MESSAGE_REPORT_ARC_INITIATED) {
                HdmiLogger.debug("Feature aborted for <Report Arc Initiated>");
                HdmiLogger.debug("Feature aborted for <Report Arc Initiated>");
                setArcStatus(false);
                disableArc();
                finish();
                finish();
                return true;
                return true;
            }
            }
Loading