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

Commit 5411246b authored by Donghyun Cho's avatar Donghyun Cho Committed by Android (Google) Code Review
Browse files

Merge "CEC: Use isConnected() to check ARC transmission feasibility"

parents e00c7dd3 88909ce5
Loading
Loading
Loading
Loading
+16 −40
Original line number Original line Diff line number Diff line
@@ -796,7 +796,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    void onNewAvrAdded(HdmiDeviceInfo avr) {
    void onNewAvrAdded(HdmiDeviceInfo avr) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress()));
        addAndStartAction(new SystemAudioAutoInitiationAction(this, avr.getLogicalAddress()));
        if (isArcFeatureEnabled(avr.getPortId())
        if (isConnected(avr.getPortId()) && isArcFeatureEnabled(avr.getPortId())
                && !hasAction(SetArcTransmissionStateAction.class)) {
                && !hasAction(SetArcTransmissionStateAction.class)) {
            startArcAction(true);
            startArcAction(true);
        }
        }
@@ -899,29 +899,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        }
        }
    }
    }


    @ServiceThreadOnly
    private void updateArcFeatureStatus(int portId, boolean isConnected) {
        assertRunOnServiceThread();
        HdmiPortInfo portInfo = mService.getPortInfo(portId);
        if (!portInfo.isArcSupported()) {
            return;
        }
        HdmiDeviceInfo avr = getAvrDeviceInfo();
        if (avr == null) {
            if (isConnected) {
                // Update the status (since TV may not have seen AVR yet) so
                // that ARC can be initiated after discovery.
                mArcFeatureEnabled.put(portId, isConnected);
            }
            return;
        }
        // HEAC 2.4, HEACT 5-15
        // Should not activate ARC if +5V status is false.
        if (avr.getPortId() == portId) {
            changeArcFeatureEnabled(portId, isConnected);
        }
    }

    @ServiceThreadOnly
    @ServiceThreadOnly
    boolean isConnected(int portId) {
    boolean isConnected(int portId) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
@@ -952,20 +929,20 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    @ServiceThreadOnly
    @ServiceThreadOnly
    void changeArcFeatureEnabled(int portId, boolean enabled) {
    void changeArcFeatureEnabled(int portId, boolean enabled) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();

        if (mArcFeatureEnabled.get(portId) == enabled) {
        if (mArcFeatureEnabled.get(portId) != enabled) {
            return;
        }
        mArcFeatureEnabled.put(portId, enabled);
        mArcFeatureEnabled.put(portId, enabled);
            if (enabled) {
        HdmiDeviceInfo avr = getAvrDeviceInfo();
                if (!mArcEstablished) {
        if (avr == null || avr.getPortId() != portId) {
                    startArcAction(true);
            return;
        }
        }
            } else {
        if (enabled && !mArcEstablished) {
                if (mArcEstablished) {
            startArcAction(true);
        } else if (!enabled && mArcEstablished) {
            startArcAction(false);
            startArcAction(false);
        }
        }
    }
    }
        }
    }


    @ServiceThreadOnly
    @ServiceThreadOnly
    boolean isArcFeatureEnabled(int portId) {
    boolean isArcFeatureEnabled(int portId) {
@@ -1097,14 +1074,14 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        return true;
        return true;
    }
    }


    private boolean canStartArcUpdateAction(int avrAddress, boolean shouldCheckArcFeatureEnabled) {
    private boolean canStartArcUpdateAction(int avrAddress, boolean enabled) {
        HdmiDeviceInfo avr = getAvrDeviceInfo();
        HdmiDeviceInfo avr = getAvrDeviceInfo();
        if (avr != null
        if (avr != null
                && (avrAddress == avr.getLogicalAddress())
                && (avrAddress == avr.getLogicalAddress())
                && isConnectedToArcPort(avr.getPhysicalAddress())
                && isConnectedToArcPort(avr.getPhysicalAddress())
                && isDirectConnectAddress(avr.getPhysicalAddress())) {
                && isDirectConnectAddress(avr.getPhysicalAddress())) {
            if (shouldCheckArcFeatureEnabled) {
            if (enabled) {
                return isArcFeatureEnabled(avr.getPortId());
                return isConnected(avr.getPortId()) && isArcFeatureEnabled(avr.getPortId());
            } else {
            } else {
                return true;
                return true;
            }
            }
@@ -1566,7 +1543,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
            // It covers seq #40, #43.
            // It covers seq #40, #43.
            hotplugActions.get(0).pollAllDevicesNow();
            hotplugActions.get(0).pollAllDevicesNow();
        }
        }
        updateArcFeatureStatus(portId, connected);
    }
    }


    private void removeCecSwitches(int portId) {
    private void removeCecSwitches(int portId) {