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

Commit 9884f20f authored by Venkatarama NG. Avadhani's avatar Venkatarama NG. Avadhani Committed by Nathalie Le Clair
Browse files

CEC: Modify Standby Mode Handler

Add standby mode handler for generic device. Earlier, only TV devices
would use the standby mode handler to filter messages or feature abort
them when in standby. This does not change the standby mode handling of
TV devices.

Test: atest
android.hdmicec.cts.playback.HdmiCecRemoteControlPassThroughTest#cect_hf4_8_13_AbortIncorrectMode
Bug: 211843422

Change-Id: Ie00e16231e385db0f2d280f088882d5d0f9a8add
parent 21466743
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -75,6 +75,8 @@ abstract class HdmiCecLocalDevice {
    protected int mLastKeycode = HdmiCecKeycode.UNSUPPORTED_KEYCODE;
    protected int mLastKeyRepeatCount = 0;

    HdmiCecStandbyModeHandler mStandbyHandler;

    // Stores recent changes to the active source in the CEC network.
    private final ArrayBlockingQueue<HdmiCecController.Dumpable> mActiveSourceHistory =
            new ArrayBlockingQueue<>(MAX_HDMI_ACTIVE_SOURCE_HISTORY);
@@ -263,6 +265,11 @@ abstract class HdmiCecLocalDevice {
        if (dest != mDeviceInfo.getLogicalAddress() && dest != Constants.ADDR_BROADCAST) {
            return Constants.NOT_HANDLED;
        }
        if (mService.isPowerStandby()
                && !mService.isWakeUpMessageReceived()
                && mStandbyHandler.handleCommand(message)) {
            return Constants.HANDLED;
        }
        // Cache incoming message if it is included in the list of cacheable opcodes.
        mCecMessageCache.cacheMessage(message);
        return onMessage(message);
+1 −0
Original line number Diff line number Diff line
@@ -117,6 +117,7 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
        mSystemAudioControlFeatureEnabled = mService.getHdmiCecConfig().getIntValue(
                HdmiControlManager.CEC_SETTING_NAME_SYSTEM_AUDIO_CONTROL)
                    == HdmiControlManager.SYSTEM_AUDIO_CONTROL_ENABLED;
        mStandbyHandler = new HdmiCecStandbyModeHandler(service, this);
    }

    private static final String SHORT_AUDIO_DESCRIPTOR_CONFIG_PATH = "/vendor/etc/sadConfig.xml";
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ public class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
        super(service, HdmiDeviceInfo.DEVICE_PLAYBACK);

        mDelayedStandbyHandler = new Handler(service.getServiceLooper());
        mStandbyHandler = new HdmiCecStandbyModeHandler(service, this);
    }

    @Override
+0 −2
Original line number Diff line number Diff line
@@ -92,8 +92,6 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    @GuardedBy("mLock")
    private boolean mSystemAudioMute = false;

    private final HdmiCecStandbyModeHandler mStandbyHandler;

    // If true, do not do routing control/send active source for internal source.
    // Set to true when the device was woken up by <Text/Image View On>.
    private boolean mSkipRoutingControl;
+33 −22
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.android.server.hdmi;

import android.hardware.hdmi.HdmiDeviceInfo;
import android.util.SparseArray;

/**
@@ -56,7 +57,8 @@ public final class HdmiCecStandbyModeHandler {
    private final class AutoOnHandler implements CecMessageHandler {
        @Override
        public boolean handle(HdmiCecMessage message) {
            if (!mTv.getAutoWakeup()) {
            HdmiCecLocalDeviceTv tv = (HdmiCecLocalDeviceTv) mDevice;
            if (!tv.getAutoWakeup()) {
                mAborterRefused.handle(message);
                return true;
            }
@@ -78,7 +80,7 @@ public final class HdmiCecStandbyModeHandler {
    }

    private final HdmiControlService mService;
    private final HdmiCecLocalDeviceTv mTv;
    private final HdmiCecLocalDevice mDevice;

    private final SparseArray<CecMessageHandler> mCecMessageHandlers = new SparseArray<>();
    private final CecMessageHandler mDefaultHandler = new Aborter(
@@ -92,13 +94,7 @@ public final class HdmiCecStandbyModeHandler {
    private final UserControlProcessedHandler
            mUserControlProcessedHandler = new UserControlProcessedHandler();

    public HdmiCecStandbyModeHandler(HdmiControlService service, HdmiCecLocalDeviceTv tv) {
        mService = service;
        mTv = tv;

        addHandler(Constants.MESSAGE_IMAGE_VIEW_ON, mAutoOnHandler);
        addHandler(Constants.MESSAGE_TEXT_VIEW_ON, mAutoOnHandler);

    private void addCommonHandlers() {
        addHandler(Constants.MESSAGE_ACTIVE_SOURCE, mBystander);
        addHandler(Constants.MESSAGE_REQUEST_ACTIVE_SOURCE, mBystander);
        addHandler(Constants.MESSAGE_ROUTING_CHANGE, mBystander);
@@ -112,19 +108,6 @@ public final class HdmiCecStandbyModeHandler {
        addHandler(Constants.MESSAGE_SYSTEM_AUDIO_MODE_STATUS, mBystander);
        addHandler(Constants.MESSAGE_REPORT_AUDIO_STATUS, mBystander);

        // If TV supports the following messages during power-on, ignore them and do nothing,
        // else reply with <Feature Abort>["Unrecognized Opcode"]
        // <Deck Status>, <Tuner Device Status>, <Tuner Cleared Status>, <Timer Status>
        addHandler(Constants.MESSAGE_RECORD_STATUS, mBystander);

        // If TV supports the following messages during power-on, reply with <Feature Abort>["Not
        // in correct mode to respond"], else reply with <Feature Abort>["Unrecognized Opcode"]
        // <Give Tuner Device Status>, <Select Digital Service>, <Tuner Step Decrement>,
        // <Tuner Stem Increment>, <Menu Status>.
        addHandler(Constants.MESSAGE_RECORD_TV_SCREEN, mAborterIncorrectMode);
        addHandler(Constants.MESSAGE_INITIATE_ARC, mAborterIncorrectMode);
        addHandler(Constants.MESSAGE_TERMINATE_ARC, mAborterIncorrectMode);

        addHandler(Constants.MESSAGE_GIVE_PHYSICAL_ADDRESS, mBypasser);
        addHandler(Constants.MESSAGE_GET_MENU_LANGUAGE, mBypasser);
        addHandler(Constants.MESSAGE_REPORT_PHYSICAL_ADDRESS, mBypasser);
@@ -145,6 +128,34 @@ public final class HdmiCecStandbyModeHandler {
        addHandler(Constants.MESSAGE_SET_SYSTEM_AUDIO_MODE, mAborterIncorrectMode);
    }

    private void addTvHandlers() {
        addHandler(Constants.MESSAGE_IMAGE_VIEW_ON, mAutoOnHandler);
        addHandler(Constants.MESSAGE_TEXT_VIEW_ON, mAutoOnHandler);

        // If TV supports the following messages during power-on, ignore them and do nothing,
        // else reply with <Feature Abort>["Unrecognized Opcode"]
        // <Deck Status>, <Tuner Device Status>, <Tuner Cleared Status>, <Timer Status>
        addHandler(Constants.MESSAGE_RECORD_STATUS, mBystander);

        // If TV supports the following messages during power-on, reply with <Feature Abort>["Not
        // in correct mode to respond"], else reply with <Feature Abort>["Unrecognized Opcode"]
        // <Give Tuner Device Status>, <Select Digital Service>, <Tuner Step Decrement>,
        // <Tuner Stem Increment>, <Menu Status>.
        addHandler(Constants.MESSAGE_RECORD_TV_SCREEN, mAborterIncorrectMode);
        addHandler(Constants.MESSAGE_INITIATE_ARC, mAborterIncorrectMode);
        addHandler(Constants.MESSAGE_TERMINATE_ARC, mAborterIncorrectMode);
    }

    public HdmiCecStandbyModeHandler(HdmiControlService service, HdmiCecLocalDevice device) {
        mService = service;
        mDevice = device;

        addCommonHandlers();
        if (mDevice.getType() == HdmiDeviceInfo.DEVICE_TV) {
            addTvHandlers();
        }
    }

    private void addHandler(int opcode, CecMessageHandler handler) {
        mCecMessageHandlers.put(opcode, handler);
    }
Loading