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

Commit 5352081c authored by Jungshik Jang's avatar Jungshik Jang
Browse files

Enable all actions to have chance to consume incoming message.

Some actions such as "DevicePowerStatusAction", "PowerStatusMonitorAction",
"Routing Contron Action" might wait for receiving <Report Power Status>
message, but the oldest aciton, which is normally PowerStatusMonitorAction,
can consume it.
This change enables all actions to have chance to touch incoming message.

Along with this, it fixes audio mute bug during volume control.

Bug: 17597377
Change-Id: Iafb71f6ea6309a4fba79833da2d634222058ac78
parent 2b268d7f
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -70,7 +70,8 @@ final class DevicePowerStatusAction extends HdmiCecFeatureAction {


    @Override
    @Override
    boolean processCommand(HdmiCecMessage cmd) {
    boolean processCommand(HdmiCecMessage cmd) {
        if (mState != STATE_WAITING_FOR_REPORT_POWER_STATUS) {
        if (mState != STATE_WAITING_FOR_REPORT_POWER_STATUS
               || mTargetAddress != cmd.getSource()) {
            return false;
            return false;
        }
        }
        if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
        if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -95,7 +95,7 @@ final class DeviceSelectAction extends HdmiCecFeatureAction {
        sendCommand(mGivePowerStatus, new SendMessageCallback() {
        sendCommand(mGivePowerStatus, new SendMessageCallback() {
            @Override
            @Override
            public void onSendCompleted(int error) {
            public void onSendCompleted(int error) {
                if (error == Constants.SEND_RESULT_NAK) {
                if (error != Constants.SEND_RESULT_SUCCESS) {
                    invokeCallback(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
                    invokeCallback(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
                    finish();
                    finish();
                    return;
                    return;
+1 −2
Original line number Original line Diff line number Diff line
@@ -84,8 +84,7 @@ abstract class HdmiCecFeatureAction {
     * Process the command. Called whenever a new command arrives.
     * Process the command. Called whenever a new command arrives.
     *
     *
     * @param cmd command to process
     * @param cmd command to process
     * @return true if the command was consumed in the process; Otherwise false, which
     * @return true if the command was consumed in the process; Otherwise false.
     *          indicates that the command shall be handled by other actions.
     */
     */
    abstract boolean processCommand(HdmiCecMessage cmd);
    abstract boolean processCommand(HdmiCecMessage cmd);


+9 −8
Original line number Original line Diff line number Diff line
@@ -34,7 +34,6 @@ import com.android.server.hdmi.HdmiAnnotations.ServiceThreadOnly;
import java.util.ArrayList;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Collections;
import java.util.Iterator;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.List;


/**
/**
@@ -125,7 +124,7 @@ abstract class HdmiCecLocalDevice {


    // A collection of FeatureAction.
    // A collection of FeatureAction.
    // Note that access to this collection should happen in service thread.
    // Note that access to this collection should happen in service thread.
    private final LinkedList<HdmiCecFeatureAction> mActions = new LinkedList<>();
    private final ArrayList<HdmiCecFeatureAction> mActions = new ArrayList<>();


    private final Handler mHandler = new Handler () {
    private final Handler mHandler = new Handler () {
        @Override
        @Override
@@ -290,12 +289,14 @@ abstract class HdmiCecLocalDevice {
    @ServiceThreadOnly
    @ServiceThreadOnly
    private boolean dispatchMessageToAction(HdmiCecMessage message) {
    private boolean dispatchMessageToAction(HdmiCecMessage message) {
        assertRunOnServiceThread();
        assertRunOnServiceThread();
        for (HdmiCecFeatureAction action : mActions) {
        boolean processed = false;
            if (action.processCommand(message)) {
        // Use copied action list in that processCommand may remove itself.
                return true;
        for (HdmiCecFeatureAction action : new ArrayList<>(mActions)) {
            }
            // Iterates all actions to check whether incoming message is consumed.
        }
            boolean result = action.processCommand(message);
        return false;
            processed = processed || result;
        }
        return processed;
    }
    }


    @ServiceThreadOnly
    @ServiceThreadOnly
+2 −1
Original line number Original line Diff line number Diff line
@@ -92,7 +92,8 @@ final class OneTouchPlayAction extends HdmiCecFeatureAction {


    @Override
    @Override
    boolean processCommand(HdmiCecMessage cmd) {
    boolean processCommand(HdmiCecMessage cmd) {
        if (mState != STATE_WAITING_FOR_REPORT_POWER_STATUS) {
        if (mState != STATE_WAITING_FOR_REPORT_POWER_STATUS
                || mTargetAddress != cmd.getSource()) {
            return false;
            return false;
        }
        }
        if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
        if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
Loading