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

Commit b9d7f432 authored by Amy's avatar Amy Committed by shubang
Browse files

Broadcast Active Source when user enables HDMI CEC control.

ag/5666281

Test: manual
Bug: 120028222
Change-Id: Ic1afbadf64d5988c0d93ec40de157699613cdd14
parent 238f64fc
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -269,6 +269,10 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
    @ServiceThreadOnly
    @ServiceThreadOnly
    protected void onAddressAllocated(int logicalAddress, int reason) {
    protected void onAddressAllocated(int logicalAddress, int reason) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        if (reason == mService.INITIATED_BY_ENABLE_CEC) {
            mService.setAndBroadcastActiveSource(mService.getPhysicalAddress(),
                    getDeviceInfo().getDeviceType(), Constants.ADDR_BROADCAST);
        }
        mService.sendCecCommand(
        mService.sendCecCommand(
                HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                        mAddress, mService.getPhysicalAddress(), mDeviceType));
                        mAddress, mService.getPhysicalAddress(), mDeviceType));
+4 −0
Original line number Original line Diff line number Diff line
@@ -77,6 +77,10 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
    @ServiceThreadOnly
    @ServiceThreadOnly
    protected void onAddressAllocated(int logicalAddress, int reason) {
    protected void onAddressAllocated(int logicalAddress, int reason) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        if (reason == mService.INITIATED_BY_ENABLE_CEC) {
            mService.setAndBroadcastActiveSource(mService.getPhysicalAddress(),
                    getDeviceInfo().getDeviceType(), Constants.ADDR_BROADCAST);
        }
        mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
        mService.sendCecCommand(HdmiCecMessageBuilder.buildReportPhysicalAddressCommand(
                mAddress, mService.getPhysicalAddress(), mDeviceType));
                mAddress, mService.getPhysicalAddress(), mDeviceType));
        mService.sendCecCommand(HdmiCecMessageBuilder.buildDeviceVendorIdCommand(
        mService.sendCecCommand(HdmiCecMessageBuilder.buildDeviceVendorIdCommand(
+1 −1
Original line number Original line Diff line number Diff line
@@ -218,7 +218,7 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
    // This method should only be called when the device can be the active source.
    // This method should only be called when the device can be the active source.
    protected void setAndBroadcastActiveSource(HdmiCecMessage message, int physicalAddress) {
    protected void setAndBroadcastActiveSource(HdmiCecMessage message, int physicalAddress) {
        mService.setAndBroadcastActiveSource(
        mService.setAndBroadcastActiveSource(
                message, physicalAddress, getDeviceInfo().getDeviceType());
                physicalAddress, getDeviceInfo().getDeviceType(), message.getSource());
    }
    }


    @ServiceThreadOnly
    @ServiceThreadOnly
+3 −3
Original line number Original line Diff line number Diff line
@@ -2707,14 +2707,14 @@ public class HdmiControlService extends SystemService {
    // For example, when receiving broadcast messages, all the device types will call this
    // For example, when receiving broadcast messages, all the device types will call this
    // method but only one of them will be the Active Source.
    // method but only one of them will be the Active Source.
    protected void setAndBroadcastActiveSource(
    protected void setAndBroadcastActiveSource(
            HdmiCecMessage message, int physicalAddress, int deviceType) {
            int physicalAddress, int deviceType, int source) {
        // If the device has both playback and audio system logical addresses,
        // If the device has both playback and audio system logical addresses,
        // playback will claim active source. Otherwise audio system will.
        // playback will claim active source. Otherwise audio system will.
        if (deviceType == HdmiDeviceInfo.DEVICE_PLAYBACK) {
        if (deviceType == HdmiDeviceInfo.DEVICE_PLAYBACK) {
            HdmiCecLocalDevicePlayback playback = playback();
            HdmiCecLocalDevicePlayback playback = playback();
            playback.setIsActiveSource(true);
            playback.setIsActiveSource(true);
            playback.wakeUpIfActiveSource();
            playback.wakeUpIfActiveSource();
            playback.maySendActiveSource(message.getSource());
            playback.maySendActiveSource(source);
            setActiveSource(playback.mAddress, physicalAddress);
            setActiveSource(playback.mAddress, physicalAddress);
        }
        }


@@ -2725,7 +2725,7 @@ public class HdmiControlService extends SystemService {
            } else {
            } else {
                audioSystem.setIsActiveSource(true);
                audioSystem.setIsActiveSource(true);
                audioSystem.wakeUpIfActiveSource();
                audioSystem.wakeUpIfActiveSource();
                audioSystem.maySendActiveSource(message.getSource());
                audioSystem.maySendActiveSource(source);
                setActiveSource(audioSystem.mAddress, physicalAddress);
                setActiveSource(audioSystem.mAddress, physicalAddress);
            }
            }
        }
        }