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

Commit 263bcea9 authored by Nathalie Le Clair's avatar Nathalie Le Clair Committed by Automerger Merge Worker
Browse files

Merge "Reduce calls for target power state" into sc-dev am: cdb0369d

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13843860

Change-Id: Ifc392e405817d7968b722f4ea6a8d5dd1f1a01fa
parents 039a2b45 cdb0369d
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;