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

Commit f359542e authored by Paul Colta's avatar Paul Colta Committed by Android (Google) Code Review
Browse files

Merge "HDMI: Source asserts <AS> if TV doesn't answer to <Request AS>" into main

parents 150d0a23 777cf829
Loading
Loading
Loading
Loading
+50 −1
Original line number Diff line number Diff line
@@ -444,14 +444,62 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
                        new Runnable() {
                            @Override
                            public void run() {
                                if (!isActiveSource()) {
                                if (isActiveSource()) {
                                    return;
                                }

                                if (getActiveSource().logicalAddress != Constants.ADDR_TV) {
                                    startHdmiCecActiveSourceLostActivity();
                                    mDelayedStandbyOnActiveSourceLostHandler
                                            .removeCallbacksAndMessages(null);
                                    mDelayedStandbyOnActiveSourceLostHandler.postDelayed(
                                            new DelayedStandbyOnActiveSourceLostRunnable(),
                                            STANDBY_AFTER_ACTIVE_SOURCE_LOST_DELAY_MS);
                                    return;
                                }

                                // We observed specific TV panels (old models) that send faulty CEC
                                // source changing messages, especially during wake-up.
                                // This request helps to check if the TV correctly asserted active
                                // source or not. If the request times out, active source is
                                // asserted by the local device.
                                addAndStartAction(new RequestActiveSourceAction(mService.playback(),
                                        new IHdmiControlCallback.Stub() {
                                    @Override
                                    public void onComplete(int result) {
                                        // If a device answers to <Request Active Source>, the
                                        // pop-up should be triggered.
                                        // During this action, the TV can switch to an HDMI input
                                        // with a non-CEC capable device that won't be able to
                                        // answer this request.
                                        // In this case, the known active source would be
                                        // represented by a valid physical address, but invalid
                                        // logical address. The pop-up will be shown and the local
                                        // device will not assert active source.
                                        if (result == HdmiControlManager.RESULT_SUCCESS
                                                || getActiveSource().logicalAddress
                                                != Constants.ADDR_TV) {
                                                startHdmiCecActiveSourceLostActivity();
                                                mDelayedStandbyOnActiveSourceLostHandler
                                                        .removeCallbacksAndMessages(null);
                                                mDelayedStandbyOnActiveSourceLostHandler
                                                        .postDelayed(
                                                                new DelayedStandbyOnActiveSourceLostRunnable(),
                                                        STANDBY_AFTER_ACTIVE_SOURCE_LOST_DELAY_MS);
                                        } else {
                                            // The request times out and the local device is not
                                            // active source, but the TV previously asserted active
                                            // source.
                                            if (getActiveSource().logicalAddress
                                                    == Constants.ADDR_TV) {
                                                mService.setAndBroadcastActiveSource(
                                                        mService.getPhysicalAddress(),
                                                        getDeviceInfo().getDeviceType(),
                                                        Constants.ADDR_BROADCAST,
                                                        "RequestActiveSourceAction#RESULT_TIMEOUT");
                                            }
                                        }
                                    }}));
                            }
                        }, POPUP_AFTER_ACTIVE_SOURCE_LOST_DELAY_MS);
                return;
@@ -698,6 +746,7 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
        removeAction(HotplugDetectionAction.class);
        removeAction(NewDeviceAction.class);
        removeAction(PowerStatusMonitorActionFromPlayback.class);
        removeAction(RequestActiveSourceAction.class);
        super.disableDevice(initiatedByCec, callback);
        clearDeviceInfoList();
        checkIfPendingActionsCleared();
+1 −0
Original line number Diff line number Diff line
@@ -4344,6 +4344,7 @@ public class HdmiControlService extends SystemService {
        if (deviceType == HdmiDeviceInfo.DEVICE_PLAYBACK) {
            HdmiCecLocalDevicePlayback playback = playback();
            playback.dismissUiOnActiveSourceStatusRecovered();
            playback.removeAction(RequestActiveSourceAction.class);
            playback.setActiveSource(playback.getDeviceInfo().getLogicalAddress(), physicalAddress,
                    caller);
            playback.wakeUpIfActiveSource();
+12 −5
Original line number Diff line number Diff line
@@ -22,11 +22,11 @@ import android.util.Slog;
import com.android.internal.annotations.VisibleForTesting;

/**
 * Feature action that sends <Request Active Source> message and waits for <Active Source> on TV
 * panels.
 * This action has a delay before sending <Request Active Source>. This is because it should wait
 * for a possible request from LauncherX and can be cancelled if an <Active Source> message was
 * received or the TV switched to another input.
 * Feature action that sends <Request Active Source> message and waits for <Active Source>.
 *
 * For TV panels, this action has a delay before sending <Request Active Source>. This is because it
 * should wait for a possible request from LauncherX and can be cancelled if an <Active Source>
 * message was received or the TV switched to another input.
 */
public class RequestActiveSourceAction extends HdmiCecFeatureAction {
    private static final String TAG = "RequestActiveSourceAction";
@@ -55,6 +55,13 @@ public class RequestActiveSourceAction extends HdmiCecFeatureAction {
    boolean start() {
        Slog.v(TAG, "RequestActiveSourceAction started.");

        if (localDevice().mService.isPlaybackDevice()) {
            mState = STATE_WAIT_FOR_ACTIVE_SOURCE;
            sendCommand(HdmiCecMessageBuilder.buildRequestActiveSource(getSourceAddress()));
            addTimer(mState, HdmiConfig.TIMEOUT_MS);
            return true;
        }

        mState = STATE_WAIT_FOR_LAUNCHERX_API_CALL;

        // We wait for default timeout to allow the message triggered by the LauncherX API call to
+258 −21

File changed.

Preview size limit exceeded, changes collapsed.