导航菜单

页面标题

页面副标题

Petal Maps v4.7.0.310001 - AssistantController.java 源代码

正在查看: Petal Maps v4.7.0.310001 应用的 AssistantController.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.huawei.hiassistant.platform.framework.commander;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import com.huawei.hiai.tts.constants.BaseConstants;
import com.huawei.hiassistant.platform.base.VoiceKitSdkContext;
import com.huawei.hiassistant.platform.base.bean.CommonHeader;
import com.huawei.hiassistant.platform.base.bean.ErrorInfo;
import com.huawei.hiassistant.platform.base.bean.InteractionIdInfo;
import com.huawei.hiassistant.platform.base.bean.OmtInfo;
import com.huawei.hiassistant.platform.base.bean.decision.DsEventCallerAppinfo;
import com.huawei.hiassistant.platform.base.bean.decision.DsEventTtsInfo;
import com.huawei.hiassistant.platform.base.bean.llmstatus.StreamingStatusManager;
import com.huawei.hiassistant.platform.base.bean.recognize.HeaderPayload;
import com.huawei.hiassistant.platform.base.bean.recognize.MessageConstants;
import com.huawei.hiassistant.platform.base.bean.recognize.RecognizeContext;
import com.huawei.hiassistant.platform.base.bean.recognize.Session;
import com.huawei.hiassistant.platform.base.bean.recognize.VoiceEvent;
import com.huawei.hiassistant.platform.base.bean.recognize.VoiceKitMessage;
import com.huawei.hiassistant.platform.base.bean.recognize.payload.Header;
import com.huawei.hiassistant.platform.base.bean.recognize.payload.Payload;
import com.huawei.hiassistant.platform.base.bean.ui.UiMessageType;
import com.huawei.hiassistant.platform.base.bean.ui.UiPayload;
import com.huawei.hiassistant.platform.base.bean.util.GsonUtils;
import com.huawei.hiassistant.platform.base.commonrejection.CommonRejection;
import com.huawei.hiassistant.platform.base.flow.BusinessFlowState;
import com.huawei.hiassistant.platform.base.flow.ExtendedBusinessFlowState;
import com.huawei.hiassistant.platform.base.fullduplex.FullDuplex;
import com.huawei.hiassistant.platform.base.fullduplex.FullDuplexUiStateUtil;
import com.huawei.hiassistant.platform.base.interrupt.InterruptTtsInfo;
import com.huawei.hiassistant.platform.base.messagebus.SwitchCommand;
import com.huawei.hiassistant.platform.base.messagebus.SwitchConsumer;
import com.huawei.hiassistant.platform.base.module.ModuleInstanceFactory;
import com.huawei.hiassistant.platform.base.module.PlatformModule;
import com.huawei.hiassistant.platform.base.module.RecordStartType;
import com.huawei.hiassistant.platform.base.module.SessionState;
import com.huawei.hiassistant.platform.base.msg.AssistantMessage;
import com.huawei.hiassistant.platform.base.msg.MessageSparse;
import com.huawei.hiassistant.platform.base.msg.PlatformMsg;
import com.huawei.hiassistant.platform.base.northinterface.Constants;
import com.huawei.hiassistant.platform.base.northinterface.recognize.RecognizerIntent;
import com.huawei.hiassistant.platform.base.northinterface.tts.ClientIdConstant;
import com.huawei.hiassistant.platform.base.omt.OmtStateManager;
import com.huawei.hiassistant.platform.base.report.OperationReportUtils;
import com.huawei.hiassistant.platform.base.util.BaseUtils;
import com.huawei.hiassistant.platform.base.util.BusinessFlowId;
import com.huawei.hiassistant.platform.base.util.IAssistantConfig;
import com.huawei.hiassistant.platform.base.util.KitLog;
import com.huawei.hiassistant.platform.base.util.NetworkUtil;
import com.huawei.hiassistant.platform.base.util.NumberUtil;
import com.huawei.hiassistant.platform.base.util.SecureIntentUtil;
import com.huawei.hiassistant.platform.base.util.TtsUtils;
import com.huawei.hiassistant.platform.base.util.UuidUtils;
import com.huawei.hiassistant.platform.base.util.VisibleInfoCacheManager;
import com.huawei.hiassistant.platform.base.util.VoiceBusinessFlowCache;
import com.huawei.hiassistant.platform.framework.bus.FrameworkBus;
import com.huawei.hiassistant.platform.framework.bus.msg.MessageSenderInterface;
import com.huawei.hiassistant.platform.framework.commander.AssistantController;
import com.huawei.hiassistant.platform.framework.commander.flow.BusinessFlowStateManager;
import com.huawei.hiassistant.platform.framework.msg.HandlerThreadModule;
import com.huawei.hiassistant.voice.abilityconnector.recognizer.cloud.common.HiVoiceConstants;
import com.huawei.hicarsdk.constant.ConstantEx;
import defpackage.bvb;
import defpackage.cgb;
import defpackage.cnb;
import defpackage.dl;
import defpackage.dm;
import defpackage.el;
import defpackage.fl;
import defpackage.gm;
import defpackage.hnb;
import defpackage.mtb;
import defpackage.otb;
import defpackage.qk;
import defpackage.tfb;
import defpackage.ufb;
import defpackage.uyb;
import defpackage.wfb;
import defpackage.xfb;
import defpackage.yfb;
import defpackage.zrb;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;

public class AssistantController extends HandlerThreadModule {
    private static final List<Integer> FULLDUPLEX_TIMEOUT_REMOVE_MESSAGES = Arrays.asList(Integer.valueOf(PlatformMsg.Ctl.NORTH_INTERFACE_RELEASE_RECOGNIZE_ENGINE), Integer.valueOf(PlatformMsg.Ctl.DATAPROCESS_PROCESS_ERROR), Integer.valueOf(PlatformMsg.Ctl.DATAACQUISITION_ACQUISITION_ERROR), Integer.valueOf(PlatformMsg.Ctl.NORTH_INTERFACE_STOP_BUSINESS), Integer.valueOf(PlatformMsg.Ctl.NORTH_INTERFACE_RELEASE_PLATFORM), Integer.valueOf(PlatformMsg.Ctl.NORTH_INTERFACE_CANCEL_RECOGNIZE), Integer.valueOf(PlatformMsg.Ctl.INTENTION_EXECUTOR_APP_EXIT));
    private static final String TAG = "AssistantController";
    private SwitchCommand commands;
    private SwitchConsumer<AssistantMessage<?>> consumers;
    private MessageSenderInterface msgSender;

    public AssistantController() {
        super(TAG);
        FrameworkBus.registerMsgSender(new uyb());
        FrameworkBus.msg().registerListener(new otb());
        FrameworkBus.msg().registerListener(new xfb());
        FrameworkBus.setFlowFlag(yfb.a());
        FrameworkBus.setFlowState(BusinessFlowStateManager.g());
        ModuleInstanceFactory.getInstance().setPlatformStateInterface(new cnb());
    }

    private synchronized void abortBusiness(AssistantMessage<?> assistantMessage) {
        abortBusiness(assistantMessage, true);
    }

    public void abortInteractionInterrupt(AssistantMessage<?> assistantMessage) {
        short parseShort = NumberUtil.parseShort(String.valueOf(assistantMessage.getBody()), (short) 0, TAG);
        KitLog.info(TAG, "abortInteractionInterrupt " + ((int) parseShort));
        if (parseShort != BusinessFlowId.getInstance().getInteractionId()) {
            KitLog.info(TAG, "abortInteractionInterrupt not current interaction");
        } else if (FrameworkBus.flowState().getInterruptInfo(InteractionIdInfo.build(assistantMessage)) == null) {
            KitLog.info(TAG, "abortInteractionInterrupt is no interrupt");
        } else {
            ModuleInstanceFactory.Ability.recognize().cancelRecognize();
            FrameworkBus.msg().sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT, assistantMessage);
        }
    }

    public void addActiveInteraction(AssistantMessage<?> assistantMessage) {
        if (assistantMessage == null) {
            KitLog.debug(TAG, "addActiveInteraction msg is null", new Object[0]);
            return;
        }
        String sessionId = assistantMessage.getHeader().getSessionId();
        short interactionId = assistantMessage.getInteractionId();
        KitLog.debug(TAG, "addActiveInteraction {}", Short.valueOf(interactionId));
        BusinessFlowStateManager.g().addActiveInteraction(InteractionIdInfo.build(sessionId, interactionId));
    }

    private void addSynthesisMode2SpeakIntent(Intent intent) {
        int defaultSynthesisMode = TtsUtils.getDefaultSynthesisMode();
        if (defaultSynthesisMode != -1) {
            KitLog.info(TAG, "use synthesisMode " + defaultSynthesisMode);
            intent.putExtra("synthesisMode", defaultSynthesisMode);
        }
    }

    private void addToneColor2SpeakIntent(Intent intent) {
        int intValue = ((Integer) VoiceKitSdkContext.getInstance().get(Constants.Tts.TONE_COLOR, Integer.class).orElse(-1)).intValue();
        if (intent.hasExtra(Constants.Tts.FORCE_TONE_STYLE)) {
            boolean booleanExtra = intent.getBooleanExtra(Constants.Tts.FORCE_TONE_STYLE, false);
            boolean booleanValue = ((Boolean) VoiceKitSdkContext.getInstance().get(Constants.Tts.IS_SUPPORT_MULTI_SPEAKER, Boolean.class).orElse(Boolean.FALSE)).booleanValue();
            if (booleanExtra && booleanValue) {
                KitLog.info(TAG, "force set Tone and Style");
                intent.putExtra(Constants.Tts.TONE_COLOR, intent.getIntExtra("speaker", 0));
                return;
            }
        }
        if (intValue != -1) {
            KitLog.info(TAG, "use toneColor " + intValue);
            intent.putExtra(Constants.Tts.TONE_COLOR, intValue);
        }
        if (((Boolean) VoiceKitSdkContext.getInstance().get(Constants.KIDS_MODE, Boolean.class).orElse(Boolean.FALSE)).booleanValue()) {
            KitLog.info(TAG, "child type");
            intent.putExtra(Constants.Tts.TONE_COLOR, 2);
        }
    }

    private void addTtsMode2SpeakIntent(Intent intent) {
        int defaultTtsMode = TtsUtils.getDefaultTtsMode();
        if (defaultTtsMode != -1) {
            KitLog.info(TAG, "use ttsMode " + defaultTtsMode);
            intent.putExtra("ttsMode", defaultTtsMode);
        }
    }

    private void fullDuplexExitIfNeeded(AssistantMessage<?> assistantMessage) {
        BusinessFlowState businessFlowState;
        InteractionIdInfo build = InteractionIdInfo.build(BusinessFlowId.getInstance().getSessionId(), BusinessFlowId.getInstance().getInteractionId());
        BusinessFlowState currentState = FrameworkBus.flowState().getCurrentState(build);
        BusinessFlowState businessFlowState2 = BusinessFlowState.PSEUDO;
        InteractionIdInfo build2 = InteractionIdInfo.build(BusinessFlowId.getInstance().getSessionId(), (short) (build.getInteractionId() - 1));
        if (build.getInteractionId() > 1) {
            businessFlowState2 = FrameworkBus.flowState().getCurrentState(build2);
        }
        KitLog.info(TAG, "fullDuplexExitIfNeeded, current status= " + currentState + ", last status= " + businessFlowState2);
        if (currentState == BusinessFlowState.DATA_PROCESS || currentState == (businessFlowState = BusinessFlowState.INTENTION_UNDERSTAND)) {
            KitLog.info(TAG, "do not exit for having received ASRStarted.");
            FullDuplex.stateManager().setExitWaitIdInfo(build);
        } else if (businessFlowState2 != businessFlowState) {
            fullDuplexTimeOutExit(assistantMessage);
        } else {
            FullDuplex.stateManager().setExitWaitIdInfo(build2);
            KitLog.info(TAG, "do not exit for last interaction have not completed.");
        }
    }

    private void fullDuplexTimeOutExit(AssistantMessage<?> assistantMessage) {
        KitLog.debug(TAG, "fullDuplexTimeOutExit", new Object[0]);
        abortBusiness(AssistantMessage.builder(assistantMessage.getBody(), null).build(), false, false, true);
        FullDuplex.stateManager().resetTimeoutState();
        UiPayload uiPayload = new UiPayload();
        uiPayload.setContent(FullDuplex.Constants.FULL_DUPLEX_TIMEOUT);
        FrameworkBus.msg().sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.CONTROLLER_NORTH_INTERFACE_FULLDUPLEX_EXT_CHANNEL, VoiceKitMessage.buildUiMessage(UiMessageType.CONTROL, uiPayload, assistantMessage.getHeader()));
    }

    private void handleAppExit(AssistantMessage<?> assistantMessage) {
        FrameworkBus.flowFlag().setAppSwitchingToBackground(true);
        abortBusiness(assistantMessage);
        ufb.e().q();
        BusinessFlowId.getInstance().setSessionId("");
        FrameworkBus.flowState().resetState();
        FullDuplex.stateManager().resetState();
        StreamingStatusManager.getInstance().resetState();
        CommonRejection.Helper.stateManager().resetState();
        OmtStateManager.getInstance().clear();
        VisibleInfoCacheManager.getInstance().clear();
        VoiceBusinessFlowCache.getInstance().clear();
    }

    public void handleAppStart(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(Intent.class).filter(new Predicate() {
            @Override
            public final boolean test(Object obj) {
                boolean lambda$handleAppStart$16;
                lambda$handleAppStart$16 = AssistantController.lambda$handleAppStart$16((Intent) obj);
                return lambda$handleAppStart$16;
            }
        }).map(new Function() {
            @Override
            public final Object apply(Object obj) {
                CharSequence lambda$handleAppStart$17;
                lambda$handleAppStart$17 = AssistantController.lambda$handleAppStart$17((Intent) obj);
                return lambda$handleAppStart$17;
            }
        }).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$handleAppStart$18((CharSequence) obj);
            }
        });
        ufb.e().p();
        MessageSenderInterface msg = FrameworkBus.msg();
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        msg.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.COMMANDER_SDK_INIT_COMPLETE);
        ModuleInstanceFactory.State.platformState().setSdkCreated(true);
        FrameworkBus.msg().sendMsg(platformModule, PlatformModule.ASSISTANT_COMMANDER, PlatformMsg.Ctl.COMMANDER_SDK_INIT_COMPLETE);
    }

    private void handleCancelRecognize(AssistantMessage assistantMessage) {
        if (FullDuplex.stateManager().isFullDuplexMode()) {
            KitLog.debug(TAG, "handleCancelRecognize is in fullDuplex ,abort business", new Object[0]);
            abortBusiness(assistantMessage, false, false, true);
            return;
        }
        KitLog.info(TAG, "handleCancelRecognize current status is " + FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(BusinessFlowId.getInstance().getSessionId(), BusinessFlowId.getInstance().getInteractionId())));
        InteractionIdInfo build = InteractionIdInfo.build(assistantMessage);
        FrameworkBus.flowState().setRecognizing(build, false);
        Optional.ofNullable(OmtStateManager.getInstance().getOmtInfo(build)).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                ((OmtInfo) obj).setStatus(1);
            }
        });
        if (assistantMessage.getInteractionId() < BusinessFlowId.getInstance().getInteractionId()) {
            KitLog.info(TAG, "handleCancelRecognize not current ");
            return;
        }
        tfb.c("cancelRecognize", assistantMessage, false);
        OperationReportUtils.getInstance().getRecordTypeRecord().setEndType("1");
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_CANCEL_DATA_ACQUISITION, assistantMessage);
    }

    public void handleDataAcquisitionInitTimeout(AssistantMessage assistantMessage) {
        FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader());
        if (assistantMessage.getInteractionId() < BusinessFlowId.getInstance().getInteractionId()) {
            KitLog.info(TAG, "handleDataAcquisitionInitTimeout not current interaction, skip");
            return;
        }
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_RECOGNIZE_INIT_TIMEOUT);
        this.msgSender.sendMsg(platformModule, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT, assistantMessage);
    }

    public void handleStartFullDuplexRecognize(final AssistantMessage<?> assistantMessage) {
        Optional<M> body = assistantMessage.getBody(Intent.class);
        final boolean booleanValue = ((Boolean) body.map(new Function() {
            @Override
            public final Object apply(Object obj) {
                Boolean lambda$handleStartFullDuplexRecognize$19;
                lambda$handleStartFullDuplexRecognize$19 = AssistantController.lambda$handleStartFullDuplexRecognize$19((Intent) obj);
                return lambda$handleStartFullDuplexRecognize$19;
            }
        }).orElse(Boolean.FALSE)).booleanValue();
        if (booleanValue || !isInActiveMsg(InteractionIdInfo.build(assistantMessage))) {
            Optional.ofNullable(assistantMessage).map(new Function() {
                @Override
                public final Object apply(Object obj) {
                    CommonHeader header;
                    header = ((AssistantMessage) obj).getHeader();
                    return header;
                }
            }).ifPresent(new Consumer() {
                @Override
                public final void accept(Object obj) {
                    ((CommonHeader) obj).setFullDuplexMode(true);
                }
            });
            body.filter(new Predicate() {
                @Override
                public final boolean test(Object obj) {
                    boolean lambda$handleStartFullDuplexRecognize$23;
                    lambda$handleStartFullDuplexRecognize$23 = AssistantController.lambda$handleStartFullDuplexRecognize$23(booleanValue, (Intent) obj);
                    return lambda$handleStartFullDuplexRecognize$23;
                }
            }).ifPresent(new Consumer() {
                @Override
                public final void accept(Object obj) {
                    AssistantController.this.lambda$handleStartFullDuplexRecognize$24(assistantMessage, (Intent) obj);
                }
            });
            processCommandStartFullDuplexRecognize(assistantMessage);
        } else {
            KitLog.error(TAG, "{ " + ((String) Optional.ofNullable(assistantMessage.getHeader()).map(new Function() {
                @Override
                public final Object apply(Object obj) {
                    String secureInfo;
                    secureInfo = ((CommonHeader) obj).getSecureInfo();
                    return secureInfo;
                }
            }).orElse("")) + " } may be inactive or being aborting , skip");
        }
    }

    public void handleStartFullDuplexRecognizeReally(AssistantMessage<?> assistantMessage) {
        Intent intent = (Intent) assistantMessage.getBody(Intent.class).orElse(new Intent());
        if (SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.EXT_FULLDUPLEX_NEED_UPDATE_ID, true)) {
            prepareForRecognize(assistantMessage, intent);
        } else {
            if (isInActiveMsg(InteractionIdInfo.build(assistantMessage))) {
                KitLog.error(TAG, "handleStartFullDuplexRecognizeReally ignore, fullDuplex already stopped");
                return;
            }
            tfb.c("startNewFullDuplexDialog", assistantMessage, false);
        }
        if (TextUtils.isEmpty(OperationReportUtils.getInstance().getIntentionExecuteRecord().getSourceType())) {
            OperationReportUtils.getInstance().getIntentionExecuteRecord().setSourceType(SecureIntentUtil.getSecureIntentString(intent, RecognizerIntent.EXT_SOURCE_TYPE));
        }
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.CtlExt.CONTROLLER_START_ACQUISITION, assistantMessage);
    }

    public void handleStartRecognize(AssistantMessage<?> assistantMessage) {
        short interactionId = BusinessFlowId.getInstance().getInteractionId();
        String sessionId = BusinessFlowId.getInstance().getSessionId();
        assistantMessage.getHeader().setInteractionId(interactionId);
        Intent intent = (Intent) assistantMessage.getBody(Intent.class).orElse(new Intent());
        InterruptTtsInfo interruptTtsInfo = (InterruptTtsInfo) SecureIntentUtil.getSecureIntentParcelable(intent, RecognizerIntent.EXT_INTERRUPT_INFO, InterruptTtsInfo.class);
        boolean z = interruptTtsInfo != null;
        setupSessionState(intent);
        if (!z) {
            Optional.ofNullable(OmtStateManager.getInstance().getOmtInfo(InteractionIdInfo.build(sessionId, interactionId))).ifPresent(new Consumer() {
                @Override
                public final void accept(Object obj) {
                    ((OmtInfo) obj).setStatus(1);
                }
            });
        } else if (!IAssistantConfig.getInstance().sdkConfig().isSupportInterrupt()) {
            KitLog.error(TAG, "handleStartRecognize nextInterrupt, but not support interrupt");
            return;
        } else if (!FrameworkBus.flowState().isInteractionActive(InteractionIdInfo.build(sessionId, interactionId))) {
            KitLog.error(TAG, "handleStartRecognize nextInterrupt, but current inactive");
            return;
        }
        boolean z2 = FrameworkBus.flowState().getInterruptInfo(InteractionIdInfo.build(sessionId, interactionId)) != null;
        boolean isRecognizing = FrameworkBus.flowState().isRecognizing(InteractionIdInfo.build(sessionId, interactionId));
        KitLog.info(TAG, "handleStartRecognize current state is " + FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(sessionId, interactionId)) + " ;isCurrentInterrupt = " + z2 + "; isNextInterrupt=" + z + "; isRecognizing=" + isRecognizing);
        if (isRecognizing) {
            if (!z2 || z) {
                KitLog.info(TAG, "isRecognizing TRUE, both not interrupt, ignore duplicate recognize");
                return;
            } else {
                KitLog.info(TAG, "isRecognizing TRUE, first interrupt second normal");
                handleCancelRecognize(assistantMessage);
                ModuleInstanceFactory.Ability.tts().cancelSpeak();
            }
        }
        FrameworkBus.msg().removeMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.INTENTION_EXECUTOR, PlatformMsg.CtlExt.INTENTION_EXECUTOR_INTERRUPT_TIMER_EXPIRED);
        handleStartRecognizeReally(assistantMessage, intent, interruptTtsInfo, z);
    }

    private void handleStartRecognizeReally(AssistantMessage<?> assistantMessage, Intent intent, InterruptTtsInfo interruptTtsInfo, boolean z) {
        tfb.c(MessageConstants.MessageName.MSG_NAME_START_RECOGNIZE, assistantMessage, !z);
        short interactionId = assistantMessage.getHeader().getInteractionId();
        String sessionId = assistantMessage.getHeader().getSessionId();
        if (z) {
            intent.putExtra(RecognizerIntent.EXT_INIT_IF_NECESSARY, false);
            intent.putExtra(RecognizerIntent.RECORD_TYPE, RecordStartType.INTERRUPT.getType());
            FrameworkBus.flowState().saveInterruptInfo(InteractionIdInfo.build(sessionId, interactionId), interruptTtsInfo);
            OperationReportUtils.getInstance().getInterruptRecord().setBreakDiag(String.valueOf(BusinessFlowId.getInstance().getDialogId()));
            OperationReportUtils.getInstance().getInterruptRecord().setStartTime(String.valueOf(System.currentTimeMillis()));
        }
        if (!TextUtils.equals(OperationReportUtils.getInstance().getIntentionExecuteRecord().getSourceType(), "2")) {
            OperationReportUtils.getInstance().getIntentionExecuteRecord().setSourceType(SecureIntentUtil.getSecureIntentString(intent, RecognizerIntent.EXT_SOURCE_TYPE));
        }
        FullDuplex.stateManager().switchTo(InteractionIdInfo.build(sessionId, interactionId), FullDuplex.State.NONE);
        FullDuplex.stateManager().setCurrentAudioStreamId("");
        assistantMessage.getHeader().setFullDuplexMode(false);
        assistantMessage.getHeader().setAudioStreamId("");
        KitLog.info(TAG, "handleStartRecognize interactionId=" + ((int) interactionId) + " sessionId=" + KitLog.getSecurityString(sessionId) + " messageId=" + KitLog.getSecurityString(assistantMessage.getHeader().getMessageId()));
        if (SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.CONTINUE_FRONT_VAD, false) || SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.AUTO_MODE_RETRY, false)) {
            KitLog.info(TAG, "commonRejectionMod or autoRetry start recognize, not switch voice ball status.");
            FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader(), false);
        } else {
            FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader());
        }
        FrameworkBus.flowState().setRecognizing(InteractionIdInfo.build(assistantMessage), true);
        FrameworkBus.flowState().setAppRecording(InteractionIdInfo.build(assistantMessage), SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.EXT_SELF_RECORDING, false));
        if (!ModuleInstanceFactory.Ability.visible().isAutoMode()) {
            ModuleInstanceFactory.Ability.visible().reset();
            ModuleInstanceFactory.Ability.visible().getVisibleInfo();
        }
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.sendMsg(platformModule, PlatformModule.DATA_ACQUISITION, PlatformMsg.CtlExt.CONTROLLER_START_ACQUISITION, assistantMessage);
        this.msgSender.sendMsg(platformModule, PlatformModule.ASSISTANT_COMMANDER, PlatformMsg.Ctl.COMMANDER_NETWORK_CHECK_BUSINESS_TRIGGER);
    }

    private void handleStopAcquisition(Session session) {
        if (session == null) {
            KitLog.error(TAG, "handleStopAcquisition session is null");
            return;
        }
        short interactionId = session.getInteractionId();
        if (interactionId < BusinessFlowId.getInstance().getInteractionId()) {
            KitLog.error(TAG, ((int) interactionId) + " not current interaction, skip");
            return;
        }
        if (FrameworkBus.flowState().isRecognizing(InteractionIdInfo.build(session.getSessionId(), interactionId))) {
            this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_STOP_ACQUISITION);
            return;
        }
        KitLog.error(TAG, ((int) interactionId) + " isRecognizing false, skip");
    }

    public void handleStopRecognize(AssistantMessage<?> assistantMessage) {
        Boolean bool = (Boolean) assistantMessage.getBody(Intent.class).filter(new Predicate() {
            @Override
            public final boolean test(Object obj) {
                boolean lambda$handleStopRecognize$27;
                lambda$handleStopRecognize$27 = AssistantController.lambda$handleStopRecognize$27((Intent) obj);
                return lambda$handleStopRecognize$27;
            }
        }).map(new Function() {
            @Override
            public final Object apply(Object obj) {
                Boolean lambda$handleStopRecognize$28;
                lambda$handleStopRecognize$28 = AssistantController.lambda$handleStopRecognize$28((Intent) obj);
                return lambda$handleStopRecognize$28;
            }
        }).orElse(Boolean.TRUE);
        BusinessFlowState currentState = FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(assistantMessage));
        KitLog.info(TAG, "handleStopRecognize current status is " + currentState + ", cancelWhenDataAcquisition: " + bool);
        BusinessFlowState businessFlowState = BusinessFlowState.DATA_ACQUISITION;
        if (currentState == businessFlowState && bool.booleanValue()) {
            handleCancelRecognize(assistantMessage);
            return;
        }
        if (currentState != businessFlowState && currentState != BusinessFlowState.DATA_PROCESS) {
            KitLog.info(TAG, "other case, break.");
            return;
        }
        OperationReportUtils.getInstance().getRecordTypeRecord().setEndType("1");
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_STOP_ACQUISITION);
        OperationReportUtils.getInstance().getOperationNluIntentionCollect().setSpeechEndTime(System.currentTimeMillis());
    }

    private void initAbilityCommand() {
        this.consumers.addCommand(PlatformMsg.Ctl.CONTROLLER_RECOGNIZE_INIT_TIMEOUT, new qk(this));
    }

    private void initAssistantControllerCommand() {
        this.consumers.addCommand(PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_INVALID_INTENTIONS_TIMEOUT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandFullduplexInvalidIntentionsTimeOut((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_DIRECTIVES_FINISHED_TIMEOUT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandFullduplexDirectivesFinishedTimeOut((AssistantMessage) obj);
            }
        });
    }

    private void initDataAcquisitionCommand() {
        this.commands.addCommand(PlatformMsg.Ctl.DATAACQUISITION_START_RECORD, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandStartRecord();
            }
        });
        this.commands.addCommand(PlatformMsg.Ctl.DATAACQUISITION_STOP_RECORD, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandStopRecord();
            }
        });
        this.commands.addCommand(PlatformMsg.Ctl.DATAACQUISITION_ON_RECORD_END, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandOnRecordEnd();
            }
        });
        this.commands.addCommand(PlatformMsg.Ctl.DATAPROCESS_SPEECH_END, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandOnSpeechEnd();
            }
        });
        this.commands.addCommand(PlatformMsg.Ctl.DATAACQUISITION_START_FREE_WAKEUP_RECORD, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandStartFreeWakeupRecord();
            }
        });
        this.commands.addCommand(PlatformMsg.Ctl.DATAACQUISITION_STOP_FREE_WAKEUP_RECORD, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandStopFreeWakeupRecord();
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAACQUISITION_ACQUISITION_TIMEOUT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.lambda$initDataAcquisitionCommand$5((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAACQUISITION_REQUEST_ERROR, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandRequestError((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAACQUISITION_ACQUISITION_ERROR, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandRequestError((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAACQUISITION_RECOGNIZE_INIT_TIMEOUT, new qk(this));
        this.consumers.addCommand(PlatformMsg.Ctl.DATAACQUISITION_ACQUISITION_STOPPED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandAcquisitionStopped((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAACQUISITION_ACQUISITION_CANCELED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandAcquisitionCanceled((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAACQUISITION_ACQUISITION_STARTED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandAcquisitionStarted((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.DATAACQUISITION_FULLDUPLEX_JUDGE_UPDATE_INTERACTION_ID_RESULT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.handleStartFullDuplexRecognizeReally((AssistantMessage) obj);
            }
        });
    }

    private void initDataProcessCommand() {
        this.commands.addCommand(PlatformMsg.Ctl.DATAPROCESS_INIT_SUCCESS, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandDataProcessInitSuccess();
            }
        });
        this.commands.addCommand(PlatformMsg.Ctl.DATAPROCESS_RELEASE_SUCCESS, new Runnable() {
            @Override
            public final void run() {
                AssistantController.this.processCommandDataProcessReleaseSuccess();
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAPROCESS_FULLDUPLXE_VAD_ENDPOINT_ACQUIRED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.lambda$initDataProcessCommand$0((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAPROCESS_FULLDUPLXE_LAST_RESULT_ACQUIRED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.lambda$initDataProcessCommand$1((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAPROCESS_COMMONREJECTION_VAD_ENDPOINT_ACQUIRED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.lambda$initDataProcessCommand$2((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAPROCESS_COMMONREJECTION_LAST_RESULT_ACQUIRED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.lambda$initDataProcessCommand$3((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAPROCESS_STOP_ACQUISITION, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.lambda$initDataProcessCommand$4((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAPROCESS_STARTED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandDataProcessStarted((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.DATAPROCESS_PROCESS_ERROR, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandProcessError((AssistantMessage) obj);
            }
        });
    }

    private void initIntentionExecutorCommand() {
        this.consumers.addCommand(PlatformMsg.CtlExt.INTENTION_EXECUTOR_START_INTENT_ACQUISITION, new fl(this));
        this.consumers.addCommand(PlatformMsg.CtlExt.INTENTION_EXECUTOR_START_ACQUISITION, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandStartAcquisition((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_BUSINESS_FINISHED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandBusinessFinished((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_TEXT_TO_SPEAK, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processSpeakDirective((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_STREAM_TEXT_TO_SPEAK, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processStreamSpeakDirective((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_APP_EXIT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandAppExit((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_UPDATE_VOICE_CONTEXT, new gm(this));
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_RESEND_NLU, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandResendNlu((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_UPDATE_EVENT, new dm(this));
        this.consumers.addCommand(PlatformMsg.CtlExt.INTENTION_EXECUTOR_INTERRUPT_ABORT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.abortInteractionInterrupt((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.INTENTION_EXECUTOR_FULLDUPLEX_ABORT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandAbortFullDuplex((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.INTENTION_EXECUTOR_ADD_ACTIVE_INTERACTION, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.addActiveInteraction((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_EXECUTE_DIRECTIVE_STARTED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandDirectivesExecuteStart((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_EXECUTE_DIRECTIVE_FINISHED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandDirectivesExecuteFinished((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_STOP_RESPONDING, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandSendStopResponding((AssistantMessage) obj);
            }
        });
    }

    private void initIntentionHandlerCommand() {
        this.consumers.addCommand(PlatformMsg.Data.INTENTION_HANDLER_RESULT_STARTED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandResultStarted((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Data.INTENTION_HANDLER_DM_ABORT_FULLDUPLEX, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandDmAbortFullDuplex((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_HANDLER_JUDGE_EXIT_FULLDUPLEX, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandJudgeExitFullDuplex((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_HANDLER_COMMONREJECTION_STOP_RECORD, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandCommonRejectionStopRecord((AssistantMessage) obj);
            }
        });
    }

    private void initIntentionUnderStandCommand() {
        this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_UNDERSTAND_STARTED, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandIntentionUnderstandStart((AssistantMessage) obj);
            }
        });
    }

    private void initNorthInterfaceCommand() {
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_START_RECOGNIZE, new fl(this));
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_START_FULLDUPLEX_RECOGNIZE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.handleStartFullDuplexRecognize((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_UPDATE_VOICE_EVNET, new dm(this));
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_UPDATE_VOICE_CONTEXT, new gm(this));
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_RENEW_SESSION, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.renewSession((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_START_PLATFORM_MODULES, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.handleAppStart((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_STOP_BUSINESS, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandStopBusiness((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_RELEASE_PLATFORM, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandReleasePlatform((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_RELEASE_RECOGNIZE_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandReleaseRecognizeEngine((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_RELEASE_TTS_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandReleaseTtsEngine((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_IS_SPEAKING, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processIsSpeaking((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_IS_TTS_TONE_ENGINE_EXIST, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processIsTtsToneEngineExist((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_DOWNLOAD_TTS_TONE_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processDownLoadTtsToneEngine((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_TEXT_TO_SPEAK, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processTextToSpeak((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_STOP_SPEAK, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processStopSpeak((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_CANCEL_SPEAK, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCancelSpeak((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_POST_MESSAGE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandPostMessage((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_CANCEL_RECOGNIZE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandCancelRecognize((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_STOP_RECOGNIZE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.handleStopRecognize((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_INIT_RECOGNIZE_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processInitRecognizeEngine((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_UPDATE_SWITCH, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processUpdateSwitch((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_INIT_VISIBLE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processInitVisible((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_START_VISIBLE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processStartVisible((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_STOP_VISIBLE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processStopVisible((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_RELEASE_VISIBLE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processReleaseVisible((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_INIT_TTS_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processInitTtsEngine((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_DISPATCH_DS_MESSAGE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCommandDispatchDsMessage((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_INIT_ASR_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processInitAsrEngine((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.NORTH_INTERFACE_START_ASR_LISTENING, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processStartAsrListening((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_STOP_ASR_LISTENING, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processStopAsrListening((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_CANCEL_ASR_LISTENING, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processCancelAsrListening((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_RELEASE_ASR_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processReleaseAsrEngine((AssistantMessage) obj);
            }
        });
    }

    private void initProcessMsg() {
        this.commands = new SwitchCommand();
        this.consumers = new SwitchConsumer<>();
        initIntentionUnderStandCommand();
        initIntentionHandlerCommand();
        initDataProcessCommand();
        initDataAcquisitionCommand();
        initIntentionExecutorCommand();
        initNorthInterfaceCommand();
        initAbilityCommand();
        initAssistantControllerCommand();
        initVoicekitServiceCommand();
    }

    private void initVoicekitServiceCommand() {
        this.consumers.addCommand(PlatformMsg.CtlExt.VOICE_KIT_SERVICE_MSG_INIT_TTS_ENGINE, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processInitMultiInstanceTtsEngine((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.VOICE_KIT_SERVICE_MSG_TEXT_TO_SPEAK, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processMultiInstanceTextToSpeak((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.VOICE_KIT_SERVICE_MSG_STOP_SPEAK, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processInitMultiInstanceStopSpeak((AssistantMessage) obj);
            }
        });
        this.consumers.addCommand(PlatformMsg.CtlExt.VOICE_KIT_SERVICE_MSG_ROBOT_UPDATE_EVENT, new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.this.processDsDonateUpdateEvent((AssistantMessage) obj);
            }
        });
    }

    private boolean isHiCarPackageName() {
        Context appContext = IAssistantConfig.getInstance().getAppContext();
        if (appContext == null) {
            return false;
        }
        String packageName = appContext.getPackageName();
        KitLog.debug(TAG, "packageName is {}", packageName);
        return TextUtils.equals(packageName, ConstantEx.HICAR_PACKAGE_NAME);
    }

    private boolean isInActiveMsg(InteractionIdInfo interactionIdInfo) {
        return !BusinessFlowStateManager.g().isInteractionActive(interactionIdInfo) || FrameworkBus.flowFlag().isBusinessAborting();
    }

    private boolean isMessageInvalid(Session session) {
        if (session == null) {
            KitLog.error(TAG, "isMessageInvalid session is null");
            return true;
        }
        short interactionId = session.getInteractionId();
        if (interactionId < BusinessFlowId.getInstance().getInteractionId()) {
            KitLog.error(TAG, ((int) interactionId) + " not current interaction, skip");
            return true;
        }
        if (!isInActiveMsg(InteractionIdInfo.build(session.getSessionId(), session.getInteractionId()))) {
            return false;
        }
        KitLog.error(TAG, session.getSecureInfo() + " not active interaction, skip");
        return true;
    }

    public static boolean lambda$handleAppStart$16(Intent intent) {
        return intent.hasExtra("sessionId");
    }

    public static CharSequence lambda$handleAppStart$17(Intent intent) {
        return intent.getCharSequenceExtra("sessionId");
    }

    public static void lambda$handleAppStart$18(CharSequence charSequence) {
        if (TextUtils.isEmpty(charSequence)) {
            BusinessFlowId.getInstance().setSessionId(UuidUtils.getUuid());
        } else {
            BusinessFlowId.getInstance().setSessionId(charSequence.toString());
        }
    }

    public static Boolean lambda$handleStartFullDuplexRecognize$19(Intent intent) {
        boolean z = false;
        if (!SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.EXT_FULLDUPLEX_REJECT_INFO, false) && !SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.EXT_FULLDUPLEX_PREPARE_RECOGNIZE_INFO, false)) {
            z = true;
        }
        return Boolean.valueOf(z);
    }

    public void lambda$handleStartFullDuplexRecognize$24(AssistantMessage assistantMessage, Intent intent) {
        Long l = (Long) Optional.ofNullable(SecureIntentUtil.getSecureIntentString(intent, RecognizerIntent.EXT_FULLDUPLEX_DIRECTIVES_FINISHED_TIMEOUT)).map(new Function() {
            @Override
            public final Object apply(Object obj) {
                return Long.valueOf((String) obj);
            }
        }).orElse(FullDuplex.Constants.FULLDUPLEX_DIRECTIVES_FINISHED_TIMEOUT);
        l.longValue();
        FullDuplex.stateManager().setTimeoutValueOfDirectivesFinished(l);
        long longValue = ((Long) Optional.ofNullable(SecureIntentUtil.getSecureIntentString(intent, RecognizerIntent.EXT_FULLDUPLEX_INVALID_INTENTIONS_TIMEOUT)).map(new Function() {
            @Override
            public final Object apply(Object obj) {
                return Long.valueOf((String) obj);
            }
        }).orElse(FullDuplex.Constants.FULLDUPLEX_INVALID_INTENTIONS_TIMEOUT)).longValue();
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.removeMsg(platformModule, platformModule, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_INVALID_INTENTIONS_TIMEOUT);
        FullDuplex.stateManager().setExitFullDuplexByInvalidIntentions(false);
        this.msgSender.sendMsgDelayed(platformModule, platformModule, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_INVALID_INTENTIONS_TIMEOUT, longValue, assistantMessage);
    }

    public static boolean lambda$handleStopRecognize$27(Intent intent) {
        return intent.hasExtra(RecognizerIntent.EXT_CANCEL_WHEN_DATA_ACQUISITION);
    }

    public static Boolean lambda$handleStopRecognize$28(Intent intent) {
        return Boolean.valueOf(SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.EXT_CANCEL_WHEN_DATA_ACQUISITION, true));
    }

    public void lambda$initDataAcquisitionCommand$5(AssistantMessage assistantMessage) {
        handleStopAcquisition(assistantMessage.getHeader());
    }

    public void lambda$initDataProcessCommand$2(AssistantMessage assistantMessage) {
        processCommandCommonRejectionVadEndPointAcquired(assistantMessage.getHeader());
    }

    public void lambda$initDataProcessCommand$4(AssistantMessage assistantMessage) {
        handleStopAcquisition(assistantMessage.getHeader());
    }

    public static Optional lambda$processCommandDirectivesExecuteFinished$15(AssistantMessage assistantMessage) {
        return assistantMessage.getBody(Boolean.class);
    }

    public static void lambda$processCommandDispatchDsMessage$14(cgb cgbVar) {
        ModuleInstanceFactory.Ability.decisionService().dispatchDsMessage(cgbVar.a(), cgbVar.b());
    }

    public static void lambda$processCommandIntentionUnderstandStart$11() {
        if (BaseUtils.isOfflineMode()) {
            KitLog.warn(TAG, "isOfflineMode do not prepare tts");
        } else {
            KitLog.debug(TAG, "status switch to INTENTION_UNDERSTAND, ", new Object[0]);
            ModuleInstanceFactory.Ability.tts().prepare();
        }
    }

    public static Boolean lambda$processCommandJudgeExitFullDuplex$30(AssistantMessage assistantMessage, InteractionIdInfo interactionIdInfo) {
        return Boolean.valueOf(interactionIdInfo.equals(InteractionIdInfo.build(assistantMessage)));
    }

    public static void lambda$processCommandPostMessage$13(cgb cgbVar) {
        ModuleInstanceFactory.Ability.operation().postMessage(cgbVar.a(), cgbVar.b());
    }

    public static void lambda$processCommandProcessError$12(ErrorInfo errorInfo) {
        KitLog.info(TAG, "error info: " + errorInfo);
    }

    public static void lambda$processDsDonateUpdateEvent$8(String str) {
        ModuleInstanceFactory.Ability.recognize().updateVoiceEvent(null, str);
    }

    public static void lambda$processInitMultiInstanceStopSpeak$7(DsEventCallerAppinfo dsEventCallerAppinfo) {
        ModuleInstanceFactory.Ability.tts().stopSpeak(dsEventCallerAppinfo);
    }

    public static void lambda$processInitMultiInstanceTtsEngine$6(DsEventTtsInfo dsEventTtsInfo) {
        DsEventCallerAppinfo dsEventCallerAppinfo = dsEventTtsInfo.getDsEventCallerAppinfo();
        ModuleInstanceFactory.Ability.tts().registerCallback(new mtb(dsEventCallerAppinfo.getPackageName(), dsEventCallerAppinfo.getInstanceId()), ClientIdConstant.DS_INTERFACE_TTS_SDK, dsEventCallerAppinfo);
        if (ModuleInstanceFactory.Ability.tts().isTtsEngineInitFinished(dsEventCallerAppinfo)) {
            return;
        }
        ModuleInstanceFactory.Ability.tts().initTtsEngine(dsEventTtsInfo.getIntent(), dsEventCallerAppinfo);
    }

    public static void lambda$processInitVisible$10(bvb bvbVar) {
        ModuleInstanceFactory.Ability.visible().initVisible(bvbVar.a(), bvbVar.b());
    }

    public static void lambda$processMultiInstanceTextToSpeak$9(DsEventTtsInfo dsEventTtsInfo) {
        if (dsEventTtsInfo.getIntent() != null) {
            ModuleInstanceFactory.Ability.tts().textToSpeak(SecureIntentUtil.getSecureIntentString(dsEventTtsInfo.getIntent(), BaseConstants.INTENT_SPEAK_TEXT_CONTENT), "", dsEventTtsInfo.getIntent(), dsEventTtsInfo.getDsEventCallerAppinfo());
        }
    }

    public static RecognizeContext lambda$setupSessionState$26(String str) {
        return (RecognizeContext) GsonUtils.toBean(str, RecognizeContext.class);
    }

    private void prepareForRecognize(AssistantMessage<?> assistantMessage, Intent intent) {
        tfb.c(HiVoiceConstants.EventName.EVENT_CREATE_WEBSOCKET, assistantMessage, false);
        assistantMessage.getHeader().setFullDuplexMode(true);
        short interactionId = assistantMessage.getInteractionId();
        String sessionId = assistantMessage.getHeader().getSessionId();
        FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader());
        FrameworkBus.flowState().setRecognizing(InteractionIdInfo.build(assistantMessage), true);
        if (interactionId > 1) {
            FullDuplex.stateManager().switchTo(InteractionIdInfo.build(sessionId, interactionId), FullDuplex.State.MULTI_TURN);
        } else {
            FullDuplex.stateManager().switchTo(InteractionIdInfo.build(sessionId, interactionId), FullDuplex.State.FIRST_TURN);
        }
        FrameworkBus.flowState().setAppRecording(InteractionIdInfo.build(assistantMessage), SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.EXT_SELF_RECORDING, false));
    }

    public void processCancelAsrListening(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.asr().cancelAsrListening();
    }

    public void processCancelSpeak(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.tts().cancelSpeak();
    }

    public void processCommandAbortFullDuplex(AssistantMessage<?> assistantMessage) {
        if (assistantMessage == null || assistantMessage.getHeader() == null) {
            return;
        }
        KitLog.info(TAG, "processCommandAbortFullDuplex " + KitLog.getSecurityString(assistantMessage.getHeader().getSessionId()) + "_" + ((int) assistantMessage.getHeader().getInteractionId()));
        if (FullDuplex.stateManager().isFullDuplexMode()) {
            KitLog.debug(TAG, "processCommandAbortFullDuplex is in fullDuplex ,abort business", new Object[0]);
            abortBusiness(assistantMessage, false, false, true);
            UiPayload uiPayload = new UiPayload();
            uiPayload.setContent(FullDuplex.Constants.STOP_FULL_DUPLEX);
            FrameworkBus.msg().sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.CONTROLLER_NORTH_INTERFACE_FULLDUPLEX_EXT_CHANNEL, VoiceKitMessage.buildUiMessage(UiMessageType.CONTROL, uiPayload, assistantMessage.getHeader()));
        }
    }

    public void processCommandAcquisitionCanceled(AssistantMessage<?> assistantMessage) {
        if (FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(assistantMessage)) == BusinessFlowState.INTENTION_HANDLE || FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(assistantMessage)) == BusinessFlowState.PSEUDO) {
            return;
        }
        FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader());
    }

    public void processCommandAcquisitionStarted(AssistantMessage<?> assistantMessage) {
        if (((Boolean) assistantMessage.getBody(Boolean.class).orElse(Boolean.TRUE)).booleanValue()) {
            FrameworkBus.flowState().switchTo(BusinessFlowState.DATA_ACQUISITION, assistantMessage.getHeader());
        } else {
            KitLog.info(TAG, "autoRetry start recognize, not switch voice ball status.");
            FrameworkBus.flowState().switchTo(BusinessFlowState.DATA_ACQUISITION, assistantMessage.getHeader(), false);
        }
    }

    public void processCommandAcquisitionStopped(AssistantMessage<?> assistantMessage) {
        processCommandIntentionUnderstandStart(assistantMessage);
    }

    public void processCommandAppExit(AssistantMessage<?> assistantMessage) {
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_UI_EXIT, assistantMessage.getBody());
    }

    public void processCommandBusinessFinished(AssistantMessage<?> assistantMessage) {
        if (FrameworkBus.flowState().getInterruptInfo(InteractionIdInfo.build(BusinessFlowId.getInstance().getSessionId(), BusinessFlowId.getInstance().getInteractionId())) != null) {
            KitLog.info(TAG, "send business finish when interrupt");
            FrameworkBus.msg().sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.CONTROLLER_NORTH_INTERFACE_BUSINESS_FINISHED);
        }
        FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader());
    }

    public void processCommandCancelRecognize(AssistantMessage<?> assistantMessage) {
        if (FrameworkBus.flowState().isRecognizing(InteractionIdInfo.build(assistantMessage)) || !isHiCarPackageName()) {
            handleCancelRecognize(assistantMessage);
        } else {
            KitLog.info(TAG, "current interactionId not in recognizing");
        }
    }

    public void lambda$initDataProcessCommand$3(AssistantMessage<?> assistantMessage) {
        KitLog.info(TAG, "processCommandCommonRejectionLastResultAcquired " + assistantMessage.getHeader().getSecureInfo());
    }

    public void processCommandCommonRejectionStopRecord(AssistantMessage<?> assistantMessage) {
        if (CommonRejection.Helper.stateManager().isCommonRejectionMode(InteractionIdInfo.build(assistantMessage.getHeader().getSessionId(), assistantMessage.getHeader().getInteractionId()))) {
            KitLog.info(TAG, "processCommandCommonRejectionStopRecord stopRecord");
            this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_COMMONREJECTION_STOP_ACQUISITION);
        }
    }

    private void processCommandCommonRejectionVadEndPointAcquired(Session session) {
        handleStopAcquisition(session);
    }

    public void processCommandDataProcessInitSuccess() {
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_RECOGNIZE_INIT_SUCCESS);
        this.msgSender.sendMsg(platformModule, PlatformModule.ASSISTANT_COMMANDER, PlatformMsg.Ctl.CONTROLLER_RECOGNIZE_INIT_SUCCESS);
    }

    public void processCommandDataProcessReleaseSuccess() {
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_RECOGNIZE_RELEASE_SUCCESS);
    }

    public void processCommandDataProcessStarted(AssistantMessage<?> assistantMessage) {
        FrameworkBus.flowState().switchTo(BusinessFlowState.DATA_PROCESS, assistantMessage.getHeader());
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_DATAACQUISITION_FIRST_ASR);
    }

    public void processCommandDirectivesExecuteFinished(AssistantMessage<?> assistantMessage) {
        Optional map = Optional.ofNullable(assistantMessage).map(new dl()).map(new el());
        Boolean bool = Boolean.FALSE;
        boolean booleanValue = ((Boolean) map.orElse(bool)).booleanValue();
        UiPayload uiPayload = new UiPayload();
        uiPayload.setContent(ExtendedBusinessFlowState.EXECUTE_END.getBusinessFlowState());
        MessageSenderInterface msg = FrameworkBus.msg();
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        PlatformModule platformModule2 = PlatformModule.NORTH_INTERFACE;
        msg.sendMsg(platformModule, platformModule2, PlatformMsg.CtlExt.COMMANDER_BUSINESS_FLOW_STATE_CHANGE, VoiceKitMessage.buildUiMessage(UiMessageType.BUSINESS_FLOW_STATE, uiPayload, assistantMessage.getHeader()));
        if (booleanValue) {
            Boolean bool2 = (Boolean) Optional.ofNullable(assistantMessage).flatMap(new Function() {
                @Override
                public final Object apply(Object obj) {
                    Optional lambda$processCommandDirectivesExecuteFinished$15;
                    lambda$processCommandDirectivesExecuteFinished$15 = AssistantController.lambda$processCommandDirectivesExecuteFinished$15((AssistantMessage) obj);
                    return lambda$processCommandDirectivesExecuteFinished$15;
                }
            }).orElse(bool);
            boolean booleanValue2 = bool2.booleanValue();
            KitLog.debug(TAG, "fullDuplex directivesExecute finish, isDialogFinished={},session={}", bool2, assistantMessage.getHeader().getSecureInfo());
            this.msgSender.removeMsg(platformModule, platformModule, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_DIRECTIVES_FINISHED_TIMEOUT);
            this.msgSender.sendMsgDelayed(platformModule, platformModule, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_DIRECTIVES_FINISHED_TIMEOUT, FullDuplex.stateManager().getTimeoutValueOfDirectivesFinished().longValue(), assistantMessage);
            UiPayload uiPayload2 = new UiPayload();
            uiPayload2.setContent(FullDuplex.Constants.EXECUTE_DIRECTIVE_FINISHED);
            uiPayload2.setIntent(new Intent().putExtra("isDialogFinished", booleanValue2));
            FrameworkBus.msg().sendMsg(platformModule, platformModule2, PlatformMsg.CtlExt.CONTROLLER_NORTH_INTERFACE_FULLDUPLEX_EXT_CHANNEL, VoiceKitMessage.buildUiMessage(UiMessageType.CONTROL, uiPayload2, assistantMessage.getHeader()));
        }
    }

    public void processCommandDirectivesExecuteStart(AssistantMessage<?> assistantMessage) {
        boolean booleanValue = ((Boolean) Optional.ofNullable(assistantMessage).map(new dl()).map(new el()).orElse(Boolean.FALSE)).booleanValue();
        UiPayload uiPayload = new UiPayload();
        uiPayload.setContent(ExtendedBusinessFlowState.EXECUTE_START.getBusinessFlowState());
        MessageSenderInterface msg = FrameworkBus.msg();
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        msg.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.COMMANDER_BUSINESS_FLOW_STATE_CHANGE, VoiceKitMessage.buildUiMessage(UiMessageType.BUSINESS_FLOW_STATE, uiPayload, assistantMessage.getHeader()));
        if (booleanValue) {
            KitLog.debug(TAG, "fullDuplex directivesExecute start, session= {}", assistantMessage.getHeader().getSecureInfo());
            this.msgSender.removeMsg(platformModule, platformModule, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_DIRECTIVES_FINISHED_TIMEOUT);
        }
    }

    public void processCommandDispatchDsMessage(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(cgb.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processCommandDispatchDsMessage$14((cgb) obj);
            }
        });
    }

    public void processCommandDmAbortFullDuplex(AssistantMessage<?> assistantMessage) {
        KitLog.info(TAG, "processCommandDmAbortFullDuplex currentState =" + FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(assistantMessage)));
        FrameworkBus.flowState().switchTo(BusinessFlowState.PSEUDO, assistantMessage.getHeader());
        FrameworkBus.msg().sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT, assistantMessage);
        FullDuplexUiStateUtil.setIsAudioRecording(false);
    }

    public void processCommandFullduplexDirectivesFinishedTimeOut(AssistantMessage<?> assistantMessage) {
        KitLog.debug(TAG, "processCommandFullduplexDirectivesFinishedTimeOut", new Object[0]);
        FullDuplex.stateManager().setExitFullDuplexByDirectivesFinished(true);
        if (FullDuplex.stateManager().needExitFullDuplexByInvalidIntentions()) {
            fullDuplexExitIfNeeded(assistantMessage);
        }
    }

    public void processCommandFullduplexInvalidIntentionsTimeOut(AssistantMessage<?> assistantMessage) {
        KitLog.info(TAG, "processCommandFullduplexInvalidIntentionsTimeOut");
        FullDuplex.stateManager().setExitFullDuplexByInvalidIntentions(true);
        if (FullDuplex.stateManager().needExitFullDuplexByDirectivesFinished()) {
            fullDuplexExitIfNeeded(assistantMessage);
        }
    }

    public void lambda$initDataProcessCommand$1(AssistantMessage<?> assistantMessage) {
        if (isMessageInvalid(assistantMessage.getHeader())) {
            return;
        }
        processCommandIntentionUnderstandStart(assistantMessage);
        boolean isAppRecording = FrameworkBus.flowState().isAppRecording(InteractionIdInfo.build(assistantMessage));
        Intent intent = new Intent();
        intent.putExtra(RecognizerIntent.EXT_SELF_RECORDING, isAppRecording);
        prepareForRecognize(assistantMessage, intent);
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_LAST_RESULT_STOP_ACQUISITION);
    }

    public void lambda$initDataProcessCommand$0(AssistantMessage<?> assistantMessage) {
        if (isMessageInvalid(assistantMessage.getHeader())) {
            return;
        }
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_VAD_ENDPOINT_STOP_ACQUISITION);
        processCommandIntentionUnderstandStart(assistantMessage);
    }

    public void processCommandIntentionUnderstandStart(AssistantMessage<?> assistantMessage) {
        BusinessFlowState currentState = BusinessFlowStateManager.g().getCurrentState(InteractionIdInfo.build(assistantMessage));
        BusinessFlowState businessFlowState = BusinessFlowState.INTENTION_UNDERSTAND;
        if (currentState != businessFlowState) {
            FrameworkBus.flowState().switchTo(businessFlowState, assistantMessage.getHeader());
            ModuleInstanceFactory.Tools.THREAD_POOL.execute(new Runnable() {
                @Override
                public final void run() {
                    AssistantController.lambda$processCommandIntentionUnderstandStart$11();
                }
            });
        }
    }

    public void processCommandJudgeExitFullDuplex(final AssistantMessage<?> assistantMessage) {
        if (assistantMessage.getHeader().isFullDuplexMode() && FullDuplex.stateManager().needExitFullDuplex() && ((Boolean) FullDuplex.stateManager().getExitWaitIdInfo().map(new Function() {
            @Override
            public final Object apply(Object obj) {
                Boolean lambda$processCommandJudgeExitFullDuplex$30;
                lambda$processCommandJudgeExitFullDuplex$30 = AssistantController.lambda$processCommandJudgeExitFullDuplex$30(AssistantMessage.this, (InteractionIdInfo) obj);
                return lambda$processCommandJudgeExitFullDuplex$30;
            }
        }).orElse(Boolean.FALSE)).booleanValue()) {
            fullDuplexTimeOutExit(assistantMessage);
        }
    }

    public void processCommandOnRecordEnd() {
        if (ModuleInstanceFactory.Ability.visible().isAutoMode()) {
            return;
        }
        ModuleInstanceFactory.Ability.visible().hideCornerMark();
    }

    public void processCommandOnSpeechEnd() {
        if (ModuleInstanceFactory.Ability.visible().isAutoMode()) {
            return;
        }
        ModuleInstanceFactory.Ability.visible().hideCornerMark();
    }

    public void processCommandPostMessage(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(cgb.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processCommandPostMessage$13((cgb) obj);
            }
        });
    }

    public void processCommandProcessError(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(ErrorInfo.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processCommandProcessError$12((ErrorInfo) obj);
            }
        });
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.sendMsg(platformModule, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_COMMAND_PROCESS_ERROR, assistantMessage);
        this.msgSender.sendMsg(platformModule, PlatformModule.DATA_PROCESS, PlatformMsg.Ctl.CONTROLLER_COMMAND_PROCESS_ERROR);
        this.msgSender.sendMsg(platformModule, PlatformModule.INTENTION_UNDERSTAND, PlatformMsg.Ctl.CONTROLLER_COMMAND_PROCESS_ERROR);
        this.msgSender.sendMsg(platformModule, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.CONTROLLER_COMMAND_PROCESS_ERROR, assistantMessage);
        this.msgSender.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_COMMAND_PROCESS_ERROR);
        this.msgSender.sendMsg(platformModule, PlatformModule.INTENTION_EXECUTOR, PlatformMsg.Ctl.CONTROLLER_COMMAND_PROCESS_ERROR);
        abortBusiness(assistantMessage, false);
    }

    public void processCommandReleasePlatform(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.State.platformState().setSdkCreated(false);
        ModuleInstanceFactory.State.platformState().setRecognizeEngineInit(false);
        ModuleInstanceFactory.State.platformState().setTtsEngineInit(false);
        OperationReportUtils.getInstance().reportDelayTimeRecord();
        OperationReportUtils.getInstance().getDelayTimeRecord().resetCache();
        handleAppExit(assistantMessage);
    }

    public void processCommandReleaseRecognizeEngine(AssistantMessage<?> assistantMessage) {
        OperationReportUtils.getInstance().getRecordTypeRecord().setEndType("1");
        abortBusiness(assistantMessage, false);
        ModuleInstanceFactory.Ability.recognize().destroyEngine();
        ModuleInstanceFactory.State.platformState().setRecognizeEngineInit(false);
        OperationReportUtils.getInstance().reportDelayTimeRecord();
        OperationReportUtils.getInstance().getDelayTimeRecord().resetCache();
    }

    public void processCommandReleaseTtsEngine(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            ModuleInstanceFactory.Ability.tts().destroyEngine((Intent) body);
        }
        ModuleInstanceFactory.State.platformState().setTtsEngineInit(false);
    }

    public void processCommandRequestError(AssistantMessage<?> assistantMessage) {
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_NORTH_INTERFACE_REQUEST_ERROR, assistantMessage.getBody());
        handleCancelRecognize(assistantMessage);
    }

    public void processCommandResendNlu(AssistantMessage<?> assistantMessage) {
        if (assistantMessage == null) {
            KitLog.warn(TAG, "processCommandResendNlu msg is null");
            return;
        }
        tfb.c("ResendNlu", assistantMessage, false);
        BusinessFlowId.getInstance().setResendNluMessageId(assistantMessage.getHeader().getMessageId());
        FrameworkBus.flowState().setRecognizing(InteractionIdInfo.build(assistantMessage), true);
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.CtlExt.CONTROLLER_RESEND_NLU, assistantMessage);
    }

    public void processCommandResultStarted(AssistantMessage<?> assistantMessage) {
        if (((Boolean) assistantMessage.getBody(Boolean.class).orElse(Boolean.TRUE)).booleanValue()) {
            FrameworkBus.flowState().switchTo(BusinessFlowState.INTENTION_HANDLE, assistantMessage.getHeader());
        } else {
            KitLog.info(TAG, "commonRejectionMode rejection or autoRetry, not switch voice ball status.");
            FrameworkBus.flowState().switchTo(BusinessFlowState.INTENTION_HANDLE, assistantMessage.getHeader(), false);
        }
    }

    public void processCommandSendStopResponding(AssistantMessage<?> assistantMessage) {
        HeaderPayload headerPayload = new HeaderPayload();
        headerPayload.setHeader(new Header("StopResponding", "System"));
        headerPayload.setPayload(new Payload());
        VoiceEvent voiceEvent = new VoiceEvent();
        voiceEvent.getEvents().add(headerPayload);
        tfb.c("updateEvent", assistantMessage, false);
        CommonHeader header = assistantMessage.getHeader();
        header.setInteractionId(assistantMessage.getHeader().getInteractionId());
        header.setDialogId(assistantMessage.getHeader().getDialogId());
        header.setSessionId(assistantMessage.getHeader().getSessionId());
        ModuleInstanceFactory.Ability.recognize().updateVoiceEvent(header, GsonUtils.toJson(voiceEvent));
        StreamingStatusManager.getInstance().setStreamingStateMap(InteractionIdInfo.build(assistantMessage.getHeader().getSessionId(), assistantMessage.getHeader().getInteractionId()), StreamingStatusManager.StreamingState.STREAMING_END);
    }

    public void processCommandStartAcquisition(AssistantMessage<?> assistantMessage) {
        if (FrameworkBus.flowFlag().isVoiceInputEnabled()) {
            KitLog.info(TAG, "Voice input is enabled, will trigger recording as input source");
            handleStartRecognize(assistantMessage);
        } else {
            FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader());
            KitLog.info(TAG, "Voice input is disabled, will wait keyboard as input source");
        }
    }

    public void processCommandStartFreeWakeupRecord() {
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_NORTH_INTERFACE_START_FREE_WAKEUP_RECORD);
    }

    private void processCommandStartFullDuplexRecognize(AssistantMessage<?> assistantMessage) {
        short interactionId = BusinessFlowId.getInstance().getInteractionId();
        String sessionId = BusinessFlowId.getInstance().getSessionId();
        assistantMessage.getHeader().setInteractionId(interactionId);
        setupSessionState((Intent) assistantMessage.getBody(Intent.class).orElse(new Intent()));
        boolean isRecognizing = FrameworkBus.flowState().isRecognizing(InteractionIdInfo.build(sessionId, interactionId));
        KitLog.info(TAG, "fullduplexRecognize current state is " + FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(sessionId, interactionId)) + "; isRecognizing=" + isRecognizing);
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.DATA_ACQUISITION, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_JUDGE_UPDATE_INTERACTION_ID, assistantMessage);
    }

    public void processCommandStartRecord() {
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_NORTH_INTERFACE_START_RECORD);
        this.msgSender.sendMsg(platformModule, PlatformModule.ASSISTANT_COMMANDER, PlatformMsg.Ctl.CONTROLLER_NORTH_INTERFACE_START_RECORD);
    }

    public void processCommandStopBusiness(AssistantMessage<?> assistantMessage) {
        OperationReportUtils.getInstance().getRecordTypeRecord().setEndType("1");
        FrameworkBus.flowState().clearActiveInteraction();
        assistantMessage.getHeader().setInteractionId(BusinessFlowId.getInstance().getInteractionId());
        abortBusiness(assistantMessage, true, true, false, true);
        reportIntentionExcuteRecord();
        OperationReportUtils.getInstance().reportChatModeRecord();
    }

    public void processCommandStopFreeWakeupRecord() {
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_NORTH_INTERFACE_STOP_FREE_WAKEUP_RECORD);
    }

    public void processCommandStopRecord() {
        this.msgSender.sendMsg(PlatformModule.ASSISTANT_CONTROLLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_NORTH_INTERFACE_STOP_RECORD);
        if (ModuleInstanceFactory.Ability.visible().isAutoMode()) {
            return;
        }
        ModuleInstanceFactory.Ability.visible().hideCornerMark();
    }

    public void processCommandUpdateEvent(AssistantMessage<?> assistantMessage) {
        tfb.c("updateEvent", assistantMessage, false);
        ModuleInstanceFactory.Ability.recognize().updateVoiceEvent(assistantMessage.getHeader(), String.valueOf(assistantMessage.getBody()));
    }

    public void processCommandUpdateVoiceContext(AssistantMessage<?> assistantMessage) {
        tfb.c("updateVoiceContext", assistantMessage, false);
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.sendMsg(platformModule, PlatformModule.DATA_ACQUISITION, PlatformMsg.CtlExt.CONTROLLER_UPDATE_VOICE_CONTEXT, assistantMessage);
        this.msgSender.sendMsg(platformModule, PlatformModule.ASSISTANT_COMMANDER, PlatformMsg.CtlExt.CONTROLLER_UPDATE_VOICE_CONTEXT, assistantMessage);
    }

    public void processDownLoadTtsToneEngine(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            ModuleInstanceFactory.Ability.tts().downloadTtsToneEngine(((Intent) body).getIntArrayExtra(Constants.Tts.TONE_COLOR));
        }
    }

    public void processDsDonateUpdateEvent(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(String.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processDsDonateUpdateEvent$8((String) obj);
            }
        });
    }

    public void processInitAsrEngine(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            ModuleInstanceFactory.Ability.asr().initAsrEngine((Intent) body);
        }
    }

    public void processInitMultiInstanceStopSpeak(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(DsEventCallerAppinfo.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processInitMultiInstanceStopSpeak$7((DsEventCallerAppinfo) obj);
            }
        });
    }

    public void processInitMultiInstanceTtsEngine(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(DsEventTtsInfo.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processInitMultiInstanceTtsEngine$6((DsEventTtsInfo) obj);
            }
        });
    }

    public void processInitRecognizeEngine(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            Intent intent = (Intent) body;
            if (TextUtils.equals(SecureIntentUtil.getSecureIntentString(intent, RecognizerIntent.EXT_INIT_REASON), RecognizerIntent.INIT_REASON_CPU_LOAD_CHANGE)) {
                FrameworkBus.flowState().resetState();
            }
            FullDuplex.stateManager().resetState();
            ModuleInstanceFactory.Ability.recognize().initRecognizeEngine(intent);
        }
    }

    public void processInitTtsEngine(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            ModuleInstanceFactory.Ability.tts().initTtsEngine((Intent) body);
        }
    }

    public void processInitVisible(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(bvb.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processInitVisible$10((bvb) obj);
            }
        });
    }

    public void processIsSpeaking(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof hnb) {
            hnb hnbVar = (hnb) body;
            hnbVar.b().set(ModuleInstanceFactory.Ability.tts().isSpeaking());
            hnbVar.a().countDown();
        }
    }

    public void processIsTtsToneEngineExist(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof zrb) {
            zrb zrbVar = (zrb) body;
            zrbVar.b().set(ModuleInstanceFactory.Ability.tts().isTtsToneEngineExist(zrbVar.c()));
            zrbVar.a().countDown();
        }
    }

    public void processMultiInstanceTextToSpeak(AssistantMessage<?> assistantMessage) {
        assistantMessage.getBody(DsEventTtsInfo.class).ifPresent(new Consumer() {
            @Override
            public final void accept(Object obj) {
                AssistantController.lambda$processMultiInstanceTextToSpeak$9((DsEventTtsInfo) obj);
            }
        });
    }

    public void processReleaseAsrEngine(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.asr().releaseAsrEngine();
    }

    public void processReleaseVisible(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.visible().releaseVisible();
    }

    public void processSpeakDirective(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.tts().cancelSpeak();
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            sendTextToSpeak((Intent) body);
        }
    }

    public void processStartAsrListening(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            ModuleInstanceFactory.Ability.asr().startAsrListening((Intent) body);
        }
    }

    public void processStartVisible(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Bundle) {
            ModuleInstanceFactory.Ability.visible().startVisible((Bundle) body);
            if (ModuleInstanceFactory.Ability.visible().isAutoMode()) {
                ModuleInstanceFactory.Ability.visible().getVisibleInfo();
            }
        }
    }

    public void processStopAsrListening(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.asr().stopAsrListening();
    }

    public void processStopSpeak(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.tts().stopSpeak();
    }

    public void processStopVisible(AssistantMessage<?> assistantMessage) {
        ModuleInstanceFactory.Ability.visible().stopVisible();
    }

    public void processStreamSpeakDirective(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            Intent intent = (Intent) body;
            if (SecureIntentUtil.getSecureIntentInt(intent, "streamState", -1) == 0) {
                ModuleInstanceFactory.Ability.tts().cancelSpeak();
                StreamingStatusManager.getInstance().setTtsStreamingSpeaking(true);
            }
            sendTextToSpeak(intent);
        }
    }

    public void processTextToSpeak(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            Intent intent = (Intent) body;
            ModuleInstanceFactory.Ability.tts().textToSpeak(SecureIntentUtil.getSecureIntentString(intent, BaseConstants.INTENT_SPEAK_TEXT_CONTENT), "", intent);
        }
    }

    public void processUpdateSwitch(AssistantMessage<?> assistantMessage) {
        Object body = assistantMessage.getBody();
        if (body instanceof Intent) {
            Intent intent = (Intent) body;
            if (intent.hasExtra(Constants.Tts.TONE_COLOR)) {
                int secureIntentInt = SecureIntentUtil.getSecureIntentInt(intent, Constants.Tts.TONE_COLOR, Constants.Tts.DEFAULT_TONE_COLOR);
                KitLog.debug(TAG, "toneColor: {}", Integer.valueOf(secureIntentInt));
                VoiceKitSdkContext.getInstance().update(Constants.Tts.TONE_COLOR, Integer.valueOf(secureIntentInt));
            }
            if (intent.hasExtra(Constants.Tts.IS_TTS)) {
                boolean secureIntentBoolean = SecureIntentUtil.getSecureIntentBoolean(intent, Constants.Tts.IS_TTS, true);
                KitLog.debug(TAG, "isTts: {}", Boolean.valueOf(secureIntentBoolean));
                VoiceKitSdkContext.getInstance().update(Constants.Tts.IS_TTS, Boolean.valueOf(secureIntentBoolean));
            }
            if (intent.hasExtra("requestType")) {
                String secureIntentString = SecureIntentUtil.getSecureIntentString(intent, "requestType");
                KitLog.info(TAG, "processUpdateSwitch requestType: {}" + secureIntentString);
                VoiceKitSdkContext.getInstance().update("requestType", secureIntentString);
            }
            if (intent.hasExtra("ttsMode")) {
                int secureIntentInt2 = SecureIntentUtil.getSecureIntentInt(intent, "ttsMode", -1);
                KitLog.debug(TAG, "processUpdateSwitch ttsMode: {}", Integer.valueOf(secureIntentInt2));
                VoiceKitSdkContext.getInstance().update("ttsMode", Integer.valueOf(secureIntentInt2));
            }
            if (intent.hasExtra("synthesisMode")) {
                int secureIntentInt3 = SecureIntentUtil.getSecureIntentInt(intent, "synthesisMode", 0);
                KitLog.debug(TAG, "processUpdateSwitch synthesisMode: {}", Integer.valueOf(secureIntentInt3));
                VoiceKitSdkContext.getInstance().update("synthesisMode", Integer.valueOf(secureIntentInt3));
            }
        }
    }

    public void renewSession(AssistantMessage<?> assistantMessage) {
        KitLog.debug(TAG, "renewSession", new Object[0]);
        if (assistantMessage == null) {
            return;
        }
        Object body = assistantMessage.getBody();
        Intent intent = (body == null || !(body instanceof Intent)) ? null : (Intent) body;
        if (intent == null || !intent.hasExtra("sessionId")) {
            return;
        }
        String secureIntentString = SecureIntentUtil.getSecureIntentString(intent, "sessionId");
        if (TextUtils.isEmpty(secureIntentString)) {
            KitLog.warn(TAG, "empty session id");
            return;
        }
        ModuleInstanceFactory.Ability.websocket().destroy();
        BusinessFlowId.getInstance().setSessionId(secureIntentString.toString());
        FrameworkBus.flowState().resetState();
        FullDuplex.stateManager().resetState();
        StreamingStatusManager.getInstance().resetState();
        CommonRejection.Helper.stateManager().resetState();
        VisibleInfoCacheManager.getInstance().clear();
        VoiceBusinessFlowCache.getInstance().renew();
        if (SecureIntentUtil.getSecureIntentBoolean(intent, RecognizerIntent.KEY_IS_UPLOAD_CONTACT, true)) {
            wfb.b().d();
        } else {
            KitLog.warn(TAG, "no upload contact");
        }
    }

    private void reportIntentionExcuteRecord() {
        if (TextUtils.isEmpty(OperationReportUtils.getInstance().getIntentionExecuteRecord().getDialogId())) {
            return;
        }
        if (TextUtils.equals(OperationReportUtils.getInstance().getIntentionExecuteRecord().getSkillState(), "running") || !OperationReportUtils.getInstance().getIntentionExecuteRecord().isSkillScene()) {
            if (!OperationReportUtils.getInstance().getIntentionExecuteRecord().isDialogFinishedFlag()) {
                OperationReportUtils.getInstance().getIntentionExecuteRecord().setResult("6");
            }
            OperationReportUtils.getInstance().getIntentionExecuteRecord().setNetType(NetworkUtil.isNetworkAvailable(IAssistantConfig.getInstance().getAppContext()) ? "1" : "0");
            OperationReportUtils.getInstance().getIntentionExecuteRecord().setEndTime(String.valueOf(System.currentTimeMillis()));
            OperationReportUtils.getInstance().reportIntentionExecuteRecord();
        }
    }

    private void resetFullDuplexTimeout() {
        MessageSenderInterface messageSenderInterface = this.msgSender;
        PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
        messageSenderInterface.removeMsg(platformModule, platformModule, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_INVALID_INTENTIONS_TIMEOUT);
        this.msgSender.removeMsg(platformModule, platformModule, PlatformMsg.CtlExt.CONTROLLER_FULLDUPLEX_DIRECTIVES_FINISHED_TIMEOUT);
        FullDuplex.stateManager().resetTimeoutState();
    }

    private void sendTextToSpeak(Intent intent) {
        if (!intent.hasExtra(Constants.Tts.TONE_COLOR)) {
            addToneColor2SpeakIntent(intent);
        }
        addTtsMode2SpeakIntent(intent);
        addSynthesisMode2SpeakIntent(intent);
        ModuleInstanceFactory.Ability.tts().textToSpeak(SecureIntentUtil.getSecureIntentString(intent, BaseConstants.INTENT_SPEAK_TEXT_CONTENT), SecureIntentUtil.getSecureIntentString(intent, "utteranceId"), intent);
    }

    private void setupSessionState(Intent intent) {
        if (intent == null) {
            KitLog.warn(TAG, "setupSessionState recognizeIntent is null");
            return;
        }
        HeaderPayload contextsPayload = ((RecognizeContext) Optional.ofNullable(SecureIntentUtil.getSecureIntentString(intent, RecognizerIntent.EXT_VOICE_CONTEXT)).map(new Function() {
            @Override
            public final Object apply(Object obj) {
                RecognizeContext lambda$setupSessionState$26;
                lambda$setupSessionState$26 = AssistantController.lambda$setupSessionState$26((String) obj);
                return lambda$setupSessionState$26;
            }
        }).orElse(new RecognizeContext())).getContextsPayload("ClientContext", "System");
        if (contextsPayload == null) {
            return;
        }
        JsonObject jsonObject = contextsPayload.getPayload().getJsonObject();
        SessionState sessionState = ModuleInstanceFactory.State.platformState().getSessionState();
        JsonPrimitive asJsonPrimitive = jsonObject.getAsJsonPrimitive("userVoiceInput");
        if (asJsonPrimitive != null) {
            KitLog.info(TAG, "setUserVoiceInput =" + asJsonPrimitive.getAsBoolean());
            sessionState.setUserVoiceInput(asJsonPrimitive.getAsBoolean());
        } else {
            sessionState.setUserVoiceInput(true);
        }
        JsonPrimitive asJsonPrimitive2 = jsonObject.getAsJsonPrimitive("isInDriveMode");
        if (asJsonPrimitive2 != null) {
            KitLog.info(TAG, "setInDriveMode =" + asJsonPrimitive2.getAsBoolean());
            sessionState.setInDriveMode(asJsonPrimitive2.getAsBoolean());
        }
    }

    @Override
    public void destroy() {
        super.destroy();
    }

    @Override
    public void initInHandler() {
        KitLog.debug(TAG, "[platform init] init start", new Object[0]);
        this.msgSender = FrameworkBus.msg();
        initProcessMsg();
        KitLog.debug(TAG, "[platform init] init end", new Object[0]);
    }

    @Override
    public void processMessage(AssistantMessage<?> assistantMessage) {
        if (assistantMessage == null) {
            KitLog.warn(TAG, "AssistantController processMessage msg is null");
            return;
        }
        int type = assistantMessage.getType();
        KitLog.info(TAG, "pcsMsg:name->" + MessageSparse.getName(type));
        if (FULLDUPLEX_TIMEOUT_REMOVE_MESSAGES.contains(Integer.valueOf(type))) {
            resetFullDuplexTimeout();
        }
        if (this.commands.process(String.valueOf(type)) || this.consumers.process(String.valueOf(type), assistantMessage)) {
            return;
        }
        KitLog.warn(TAG, "pcsMsg: unexpected message");
    }

    private synchronized void abortBusiness(AssistantMessage<?> assistantMessage, boolean z, boolean z2, boolean z3) {
        abortBusiness(assistantMessage, z, z2, z3, false);
    }

    private synchronized void abortBusiness(AssistantMessage<?> assistantMessage, boolean z, boolean z2, boolean z3, boolean z4) {
        try {
            FrameworkBus.flowFlag().setBusinessAborting(true);
            tfb.c("abortBusiness", assistantMessage, false);
            MessageSenderInterface messageSenderInterface = this.msgSender;
            PlatformModule platformModule = PlatformModule.ASSISTANT_CONTROLLER;
            messageSenderInterface.sendMsg(platformModule, PlatformModule.DATA_ACQUISITION, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT, assistantMessage);
            this.msgSender.sendMsg(platformModule, PlatformModule.DATA_PROCESS, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT);
            this.msgSender.sendMsg(platformModule, PlatformModule.INTENTION_UNDERSTAND, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT);
            this.msgSender.sendMsg(platformModule, PlatformModule.INTENTION_HANDLER, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT, assistantMessage);
            this.msgSender.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT);
            if (z2) {
                this.msgSender.sendMsg(platformModule, PlatformModule.INTENTION_EXECUTOR, PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT);
            }
            FrameworkBus.flowState().switchTo(BusinessFlowState.READYING, assistantMessage.getHeader(), true, z4);
            if (z && ModuleInstanceFactory.Ability.tts().isSpeaking()) {
                ModuleInstanceFactory.Ability.tts().cancelSpeak();
            }
            if (FullDuplex.stateManager().isFullDuplexMode()) {
                KitLog.info(TAG, "fullduplex abort business");
                BusinessFlowStateManager.g().resetFullDuplexStatus();
                BusinessFlowStateManager.g().clearActiveInteraction();
                if (z3) {
                    this.msgSender.sendMsg(platformModule, PlatformModule.INTENTION_EXECUTOR, PlatformMsg.Ctl.CONTROLLER_CHECK_CURRENT_DIRECTIVE_SET);
                }
            }
            FrameworkBus.flowFlag().setBusinessAborting(false);
        } catch (Throwable th) {
            throw th;
        }
    }

    private synchronized void abortBusiness(AssistantMessage<?> assistantMessage, boolean z) {
        abortBusiness(assistantMessage, z, true, false);
    }

    public static boolean lambda$handleStartFullDuplexRecognize$23(boolean z, Intent intent) {
        return z;
    }
}