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

Commit 01711c11 authored by Nathalie Le Clair's avatar Nathalie Le Clair
Browse files

Reduce calls for target power state

Only look up the target power state for 2.0 devices.

Bug: 182460328
Test: atest DeviceSelectActionTest and OneTouchPlayActionTest
Change-Id: I2471d20e750ae37719d70ea3e0215fe6fae94c6a
parent df3a54e1
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -100,19 +100,23 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
        // Wake-up on <Set Stream Path> was not mandatory before CEC 2.0.
        // The message is re-sent at the end of the action for devices that don't support 2.0.
        sendSetStreamPath();

        if (!mIsCec20) {
            queryDevicePowerStatus();
        } else {
            int targetPowerStatus = HdmiControlManager.POWER_STATUS_UNKNOWN;
        HdmiDeviceInfo targetDevice = localDevice().mService.getHdmiCecNetwork().getCecDeviceInfo(
                getTargetAddress());
            HdmiDeviceInfo targetDevice = localDevice().mService.getHdmiCecNetwork()
                    .getCecDeviceInfo(getTargetAddress());
            if (targetDevice != null) {
                targetPowerStatus = targetDevice.getDevicePowerStatus();
            }

        if (!mIsCec20 || targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
            if (targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
                queryDevicePowerStatus();
            } else if (targetPowerStatus == HdmiControlManager.POWER_STATUS_ON) {
                finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
                return true;
            }
        }
        mState = STATE_WAIT_FOR_REPORT_POWER_STATUS;
        addTimer(mState, HdmiConfig.TIMEOUT_MS);
        return true;
+16 −11
Original line number Diff line number Diff line
@@ -89,7 +89,7 @@ final class OneTouchPlayAction extends HdmiCecFeatureAction {
        mSource = source();
        sendCommand(HdmiCecMessageBuilder.buildTextViewOn(getSourceAddress(), mTargetAddress));

        boolean targetOnBefore = getTargetDevicePowerStatus(mSource, mTargetAddress,
        boolean is20TargetOnBefore = mIsCec20 && getTargetDevicePowerStatus(mSource, mTargetAddress,
                HdmiControlManager.POWER_STATUS_UNKNOWN) == HdmiControlManager.POWER_STATUS_ON;
        broadcastActiveSource();
        // If the device is not an audio system itself, request the connected audio system to
@@ -98,12 +98,16 @@ final class OneTouchPlayAction extends HdmiCecFeatureAction {
            sendCommand(HdmiCecMessageBuilder.buildSystemAudioModeRequest(getSourceAddress(),
                    Constants.ADDR_AUDIO_SYSTEM, getSourcePath(), true));
        }

        if (!mIsCec20) {
            queryDevicePowerStatus();
        } else {
            int targetPowerStatus = getTargetDevicePowerStatus(mSource, mTargetAddress,
                    HdmiControlManager.POWER_STATUS_UNKNOWN);
        if (!mIsCec20 || targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
            if (targetPowerStatus == HdmiControlManager.POWER_STATUS_UNKNOWN) {
                queryDevicePowerStatus();
            } else if (targetPowerStatus == HdmiControlManager.POWER_STATUS_ON) {
            if (!targetOnBefore) {
                if (!is20TargetOnBefore) {
                    // Suppress 2nd <Active Source> message if the target device was already on when
                    // the 1st one was sent.
                    broadcastActiveSource();
@@ -111,6 +115,7 @@ final class OneTouchPlayAction extends HdmiCecFeatureAction {
                finishWithCallback(HdmiControlManager.RESULT_SUCCESS);
                return true;
            }
        }
        mState = STATE_WAITING_FOR_REPORT_POWER_STATUS;
        addTimer(mState, HdmiConfig.TIMEOUT_MS);
        return true;