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 Diff line number Diff line
@@ -70,7 +70,8 @@ final class DevicePowerStatusAction extends HdmiCecFeatureAction {

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

+9 −8
Original line number Diff line number Diff line
@@ -34,7 +34,6 @@ 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;

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

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

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

    @Override
    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;
        }
        if (cmd.getOpcode() == Constants.MESSAGE_REPORT_POWER_STATUS) {
Loading