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

Commit 1e4a8cc5 authored by Amy's avatar Amy Committed by shubang
Browse files

Update the power status of an existing hdmi device with TIF once receive

Report Power Status or Active Source from the existing device.

ag/5268275

Test: local tested
Bug: 117291910
Change-Id: I61f7bf3885a54dd0c0c0f547425f24ca086eae6f
parent 89e93af6
Loading
Loading
Loading
Loading
+26 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {

    /**
     * Called when a device is newly added or a new device is detected or
     * existing device is updated.
     * an existing device is updated.
     *
     * @param info device info of a new device.
     */
@@ -317,6 +317,13 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
        return true;
    }

    @Override
    protected boolean handleReportPowerStatus(HdmiCecMessage command) {
        int newStatus = command.getParams()[0] & 0xFF;
        updateDevicePowerStatus(command.getSource(), newStatus);
        return true;
    }

    @Override
    @ServiceThreadOnly
    protected boolean handleSetOsdName(HdmiCecMessage message) {
@@ -921,4 +928,22 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
                mAddress, routingInformationPath));
        routeToInputFromPortId(getRoutingPort());
    }

    protected void updateDevicePowerStatus(int logicalAddress, int newPowerStatus) {
        HdmiDeviceInfo info = getCecDeviceInfo(logicalAddress);
        if (info == null) {
            Slog.w(TAG, "Can not update power status of non-existing device:" + logicalAddress);
            return;
        }

        if (info.getDevicePowerStatus() == newPowerStatus) {
            return;
        }

        HdmiDeviceInfo newInfo = HdmiUtils.cloneHdmiDeviceInfo(info, newPowerStatus);
        // addDeviceInfo replaces old device info with new one if exists.
        addDeviceInfo(newInfo);

        invokeDeviceEventListener(newInfo, HdmiControlManager.DEVICE_EVENT_UPDATE_DEVICE);
    }
}
+8 −0
Original line number Diff line number Diff line
@@ -122,6 +122,7 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
            setActiveSource(activeSource);
        }
        setIsActiveSource(physicalAddress == mService.getPhysicalAddress());
        updateDevicePowerStatus(logicalAddress, HdmiControlManager.POWER_STATUS_ON);
        switchInputOnReceivingNewActivePath(physicalAddress);
        return true;
    }
@@ -190,6 +191,13 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
        // do nothing
    }

    // Update the power status of the devices connected to the current device.
    // This only works if the current device is a switch and keeps tracking the device info
    // of the device connected to it.
    protected void updateDevicePowerStatus(int logicalAddress, int newPowerStatus) {
        // do nothing
    }

    // Active source claiming needs to be handled in Service
    // since service can decide who will be the active source when the device supports
    // multiple device types in this method.