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

Commit b449eecb authored by Jungshik Jang's avatar Jungshik Jang Committed by Android Git Automerger
Browse files

am 528c332d: Merge "Enable all actions to have chance to consume incoming...

am 528c332d: Merge "Enable all actions to have chance to consume incoming message." into lmp-mr1-dev

* commit '528c332df0360b11b82fb2235c1fbc61096caefe':
  Enable all actions to have chance to consume incoming message.
parents 994e954a 85cb8dc2
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