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

Commit f8a823b0 authored by Jungshik Jang's avatar Jungshik Jang Committed by Android (Google) Code Review
Browse files

Merge "Fix system audio mode failure in boot up" into lmp-dev

parents 503a1021 a7221ce8
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -449,7 +449,7 @@ final class HdmiCecController {
                        allocated.add(address);
                    }
                }
                mIoThreadLogger.debug("DevicePollingResult:" + allocated);
                mIoThreadLogger.debug("[P]:Allocated Address=" + allocated);
                if (callback != null) {
                    runOnServiceThread(new Runnable() {
                        @Override
@@ -551,7 +551,7 @@ final class HdmiCecController {
        runOnIoThread(new Runnable() {
            @Override
            public void run() {
                mIoThreadLogger.debug("SendCommand:" + cecMessage);
                mIoThreadLogger.debug("[S]:" + cecMessage);
                byte[] body = buildBody(cecMessage.getOpcode(), cecMessage.getParams());
                int i = 0;
                int errorCode = Constants.SEND_RESULT_SUCCESS;
@@ -586,7 +586,7 @@ final class HdmiCecController {
    private void handleIncomingCecCommand(int srcAddress, int dstAddress, byte[] body) {
        assertRunOnServiceThread();
        HdmiCecMessage command = HdmiCecMessageBuilder.of(srcAddress, dstAddress, body);
        mServiceThreadLogger.debug("ReceiveCommand:" + command);
        mServiceThreadLogger.debug("[R]:" + command);
        onReceiveCommand(command);
    }

+3 −0
Original line number Diff line number Diff line
@@ -43,6 +43,9 @@ import java.util.List;
 */
abstract class HdmiCecFeatureAction {
    private static final String TAG = "HdmiCecFeatureAction";
    // As all actions run in the same thread (service thread), it's fine to have single logger.
    // TODO: create global logger for each threads and use them.
    protected static final HdmiLogger DLOGGER = new HdmiLogger(TAG);

    // Timer handler message used for timeout event
    protected static final int MSG_TIMEOUT = 100;
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ final class HdmiLogger {
    private final String mTag;

    HdmiLogger(String tag) {
        mTag = tag;
        mTag = "HDMI:" + tag;
    }

    void warning(String logMessage) {
+8 −5
Original line number Diff line number Diff line
@@ -73,9 +73,9 @@ abstract class SystemAudioAction extends HdmiCecFeatureAction {

    // Seq #27
    protected void sendSystemAudioModeRequest() {
        mState = STATE_CHECK_ROUTING_IN_PRGRESS;
        List<RoutingControlAction> routingActions = getActions(RoutingControlAction.class);
        if (!routingActions.isEmpty()) {
            mState = STATE_CHECK_ROUTING_IN_PRGRESS;
            // Should have only one Routing Control Action
            RoutingControlAction routingAction = routingActions.get(0);
            routingAction.addOnFinishedCallback(this, new Runnable() {
@@ -97,20 +97,21 @@ abstract class SystemAudioAction extends HdmiCecFeatureAction {
        sendCommand(command, new HdmiControlService.SendMessageCallback() {
            @Override
            public void onSendCompleted(int error) {
                if (error == Constants.SEND_RESULT_SUCCESS) {
                    mState = STATE_WAIT_FOR_SET_SYSTEM_AUDIO_MODE;
                    addTimer(mState, mTargetAudioStatus ? ON_TIMEOUT_MS : OFF_TIMEOUT_MS);
                } else {
                if (error != Constants.SEND_RESULT_SUCCESS) {
                    DLOGGER.debug("Failed to send <System Audio Mode Request>:" + error);
                    setSystemAudioMode(false);
                    finishWithCallback(HdmiControlManager.RESULT_COMMUNICATION_FAILED);
                }
            }
        });
        mState = STATE_WAIT_FOR_SET_SYSTEM_AUDIO_MODE;
        addTimer(mState, mTargetAudioStatus ? ON_TIMEOUT_MS : OFF_TIMEOUT_MS);
    }

    private void handleSendSystemAudioModeRequestTimeout() {
        if (!mTargetAudioStatus  // Don't retry for Off case.
                || mSendRetryCount++ >= MAX_SEND_RETRY_COUNT) {
            DLOGGER.debug("[T]:wait for <Set System Audio Mode>.");
            setSystemAudioMode(false);
            finishWithCallback(HdmiControlManager.RESULT_TIMEOUT);
            return;
@@ -129,6 +130,7 @@ abstract class SystemAudioAction extends HdmiCecFeatureAction {
                if (cmd.getOpcode() == Constants.MESSAGE_FEATURE_ABORT
                        && (cmd.getParams()[0] & 0xFF)
                                == Constants.MESSAGE_SYSTEM_AUDIO_MODE_REQUEST) {
                    DLOGGER.debug("Failed to start system audio mode request.");
                    setSystemAudioMode(false);
                    finishWithCallback(HdmiControlManager.RESULT_EXCEPTION);
                    return true;
@@ -143,6 +145,7 @@ abstract class SystemAudioAction extends HdmiCecFeatureAction {
                    startAudioStatusAction();
                    return true;
                } else {
                    DLOGGER.debug("Unexpected system audio mode request:" + receivedStatus);
                    // Unexpected response, consider the request is newly initiated by AVR.
                    // To return 'false' will initiate new SystemAudioActionFromAvr by the control
                    // service.