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

Commit 16d119df authored by Shubang Lu's avatar Shubang Lu Committed by Android (Google) Code Review
Browse files

Merge changes I73b958da,I39d7c849,Ibf989023,I63c52c8e,I945c23cf, ...

* changes:
  Enable sendStandby for device not supporting CEC multi device type.
  Init ARC when system audio mode on in case TV won't request ARC on.
  Make PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE read-only.
  Rename setActiveSource(Boolean) to be different from setActiveSource(ActiveSource).
  Add RoutingInformation CEC message builder.
  Fix HandleActiveSource logic
  Add property to never claim playback logic address
parents 8939f1cf 777abd72
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -279,9 +279,17 @@ final class Constants {
     * <p>True means enabling muting logic.
     * <p>False means never mute device.
     */
    // TODO(OEM): Change property to ro and set to true to disable muting.
    static final String PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE =
            "persist.sys.hdmi.property_system_audio_mode_muting_enable";
            "ro.hdmi.property_system_audio_mode_muting_enable";

    /**
     * When set to true the HdmiControlService will never request a Logical Address for the
     * playback device type. Default is false.
     *
     * <p> This is useful when HDMI CEC multiple device types is not supported by the cec driver
     */
    static final String PROPERTY_HDMI_CEC_NEVER_CLAIM_PLAYBACK_LOGICAL_ADDRESS =
            "ro.hdmi.property_hdmi_cec_never_claim_playback_logical_address";

    // Set to false to allow playback device to go to suspend mode even
    // when it's an active source. True by default.
+7 −2
Original line number Diff line number Diff line
@@ -77,8 +77,6 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
        // TODO(amyjojo) make System Audio Control controllable by users
        /*mSystemAudioControlFeatureEnabled =
        mService.readBooleanSetting(Global.HDMI_SYSTEM_AUDIO_CONTROL_ENABLED, true);*/
        // TODO(b/80297700): set read-only property in config instead of setting here
        SystemProperties.set(Constants.PROPERTY_SYSTEM_AUDIO_MODE_MUTING_ENABLE, "false");
        mAutoDeviceOff = mService.readBooleanSetting(
                Global.HDMI_CONTROL_AUTO_DEVICE_OFF_ENABLED, true);
        mAutoTvOff = mService.readBooleanSetting(
@@ -461,6 +459,13 @@ public class HdmiCecLocalDeviceAudioSystem extends HdmiCecLocalDeviceSource {
                mService.announceSystemAudioModeChange(newSystemAudioMode);
            }
        }
        // Init arc whenever System Audio Mode is on
        // Since some TV like LG don't request ARC on with System Audio Mode on request
        if (newSystemAudioMode
                && SystemProperties.getBoolean(Constants.PROPERTY_ARC_SUPPORT, true)
                && !isArcEnabled() && isDirectConnectToTv()) {
            addAndStartAction(new ArcInitiationActionFromAvr(this));
        }
    }

    protected void switchToAudioInput() {
+4 −14
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
    }

    @ServiceThreadOnly
    void setActiveSource(boolean on) {
    void setIsActiveSource(boolean on) {
        assertRunOnServiceThread();
        mIsActiveSource = on;
        if (on) {
@@ -228,7 +228,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
        // If the path is under the current device, should switch
        int port = getLocalPortFromPhysicalAddress(physicalAddress);
        if (port == 0) {
            setActiveSource(true);
            setIsActiveSource(true);
            maySendActiveSource(message.getSource());
            wakeUpIfActiveSource();
        } else if (port > 0) {
@@ -263,7 +263,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
    }

    private void maySetActiveSource(int physicalAddress) {
        setActiveSource(physicalAddress == mService.getPhysicalAddress());
        setIsActiveSource(physicalAddress == mService.getPhysicalAddress());
    }

    private void wakeUpIfActiveSource() {
@@ -332,16 +332,6 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
        return Constants.ADDR_TV;
    }

    @Override
    @ServiceThreadOnly
    protected void sendStandby(int deviceId) {
        assertRunOnServiceThread();

        // Playback device can send <Standby> to TV only. Ignore the parameter.
        int targetAddress = Constants.ADDR_TV;
        mService.sendCecCommand(HdmiCecMessageBuilder.buildStandby(mAddress, targetAddress));
    }

    @Override
    @ServiceThreadOnly
    protected void disableDevice(boolean initiatedByCec, PendingActionClearedCallback callback) {
@@ -352,7 +342,7 @@ final class HdmiCecLocalDevicePlayback extends HdmiCecLocalDeviceSource {
            mService.sendCecCommand(HdmiCecMessageBuilder.buildInactiveSource(
                    mAddress, mService.getPhysicalAddress()));
        }
        setActiveSource(false);
        setIsActiveSource(false);
        checkIfPendingActionsCleared();
    }

+14 −4
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {

    private static final String TAG = "HdmiCecLocalDeviceSource";

    // Indicate if current device is Active Source or not
    private boolean mIsActiveSource = false;

    protected HdmiCecLocalDeviceSource(HdmiControlService service, int deviceType) {
@@ -49,6 +50,16 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
        }
    }

    @Override
    @ServiceThreadOnly
    protected void sendStandby(int deviceId) {
        assertRunOnServiceThread();

        // Send standby to TV only for now
        int targetAddress = Constants.ADDR_TV;
        mService.sendCecCommand(HdmiCecMessageBuilder.buildStandby(mAddress, targetAddress));
    }

    @ServiceThreadOnly
    void oneTouchPlay(IHdmiControlCallback callback) {
        assertRunOnServiceThread();
@@ -84,11 +95,10 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
        int logicalAddress = message.getSource();
        int physicalAddress = HdmiUtils.twoBytesToInt(message.getParams());
        ActiveSource activeSource = ActiveSource.of(logicalAddress, physicalAddress);
        if (physicalAddress != mService.getPhysicalAddress()
                || !mActiveSource.equals(activeSource)) {
        if (!mActiveSource.equals(activeSource)) {
            setActiveSource(activeSource);
            setActiveSource(false);
        }
        setIsActiveSource(physicalAddress == mService.getPhysicalAddress());
        return true;
    }

@@ -104,7 +114,7 @@ abstract class HdmiCecLocalDeviceSource extends HdmiCecLocalDevice {
    }

    @ServiceThreadOnly
    void setActiveSource(boolean on) {
    void setIsActiveSource(boolean on) {
        assertRunOnServiceThread();
        mIsActiveSource = on;
    }
+14 −0
Original line number Diff line number Diff line
@@ -364,6 +364,20 @@ public class HdmiCecMessageBuilder {
                param);
    }

    /**
     * Build &lt;Routing Information&gt; command.
     *
     * <p>This is a broadcast message sent to all devices on the bus.
     *
     * @param src source address of command
     * @param physicalAddress physical address of the new active routing path
     * @return newly created {@link HdmiCecMessage}
     */
    static HdmiCecMessage buildRoutingInformation(int src, int physicalAddress) {
        return buildCommand(src, Constants.ADDR_BROADCAST,
            Constants.MESSAGE_ROUTING_INFORMATION, physicalAddressToParam(physicalAddress));
    }

    /**
     * Build &lt;Give Device Power Status&gt; command.
     *
Loading