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

Commit 43c23e27 authored by Jinsuk Kim's avatar Jinsuk Kim
Browse files

Invoke input change listener at path change

Previously input change listener is not invoked if the routing change
does not cause the TV port change, but this failed to trigger the change
from an active source connected to port 1 to a non-cec device also
connected to port 1. Do this by comparing paths not ports.

Also did some cleanup:
- Avoid allocating empty lists too often for getActions
- ActiveSource.invalidate()

Change-Id: Id79531e2552ef7fa38bd604796108b8650db69a1
parent 26ba7fdd
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import com.android.internal.annotations.GuardedBy;
import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -52,6 +53,9 @@ abstract class HdmiCecLocalDevice {
        int logicalAddress;
        int physicalAddress;

        public ActiveSource() {
            invalidate();
        }
        public ActiveSource(int logical, int physical) {
            logicalAddress = logical;
            physicalAddress = physical;
@@ -62,6 +66,10 @@ abstract class HdmiCecLocalDevice {
        public boolean isValid() {
            return HdmiUtils.isValidAddress(logicalAddress);
        }
        public void invalidate() {
            logicalAddress = Constants.ADDR_INVALID;
            physicalAddress = Constants.INVALID_PHYSICAL_ADDRESS;
        }
        public boolean equals(int logical, int physical) {
            return logicalAddress == logical && physicalAddress == physical;
        }
@@ -81,8 +89,7 @@ abstract class HdmiCecLocalDevice {
    }
    // Logical address of the active source.
    @GuardedBy("mLock")
    protected final ActiveSource mActiveSource =
            new ActiveSource(-1, Constants.INVALID_PHYSICAL_ADDRESS);
    protected final ActiveSource mActiveSource = new ActiveSource();

    // Active routing path. Physical address of the active source but not all the time, such as
    // when the new active source does not claim itself to be one. Note that we don't keep
@@ -504,9 +511,12 @@ abstract class HdmiCecLocalDevice {
    @ServiceThreadOnly
    <T extends FeatureAction> List<T> getActions(final Class<T> clazz) {
        assertRunOnServiceThread();
        ArrayList<T> actions = new ArrayList<>();
        List<T> actions = Collections.<T>emptyList();
        for (FeatureAction action : mActions) {
            if (action.getClass().equals(clazz)) {
                if (actions.isEmpty()) {
                    actions = new ArrayList<T>();
                }
                actions.add((T) action);
            }
        }
+5 −5
Original line number Diff line number Diff line
@@ -234,10 +234,10 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
    void updateActiveInput(int path, boolean notifyInputChange) {
        assertRunOnServiceThread();
        // Seq #15
        int portId = mService.pathToPortId(path);
        if (portId == getActivePortId()) {
        if (path == getActivePath()) {
            return;
        }
        int portId = mService.pathToPortId(path);
        setActivePath(path);
        setPrevPortId(portId);
        // TODO: Handle PAP/PIP case.
@@ -265,7 +265,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
            invokeCallback(callback, HdmiControlManager.RESULT_SUCCESS);
            return;
        }
        setActiveSource(Constants.ADDR_INVALID, Constants.INVALID_PHYSICAL_ADDRESS);
        mActiveSource.invalidate();
        if (!mService.isControlEnabled()) {
            setActivePortId(portId);
            invokeCallback(callback, HdmiControlManager.RESULT_INCORRECT_MODE);
@@ -480,9 +480,9 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        byte[] params = message.getParams();
        int currentPath = HdmiUtils.twoBytesToInt(params);
        if (HdmiUtils.isAffectingActiveRoutingPath(getActivePath(), currentPath)) {
            int newPath = HdmiUtils.twoBytesToInt(params, 2);
            setActivePath(newPath);
            mActiveSource.invalidate();
            removeAction(RoutingControlAction.class);
            int newPath = HdmiUtils.twoBytesToInt(params, 2);
            addAndStartAction(new RoutingControlAction(this, newPath, true, null));
        }
        return true;