正在查看: Petal Maps v4.7.0.310001 应用的 IntentionHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Petal Maps v4.7.0.310001 应用的 IntentionHandler.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.huawei.hiassistant.platform.framework.intentionhandler;
import android.content.Intent;
import android.os.RemoteException;
import android.text.TextUtils;
import android.util.ArrayMap;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.huawei.decision.data.DecisionServiceConstant;
import com.huawei.hiassistant.platform.base.bean.AbTestInfo;
import com.huawei.hiassistant.platform.base.bean.CpInfo;
import com.huawei.hiassistant.platform.base.bean.InteractionIdInfo;
import com.huawei.hiassistant.platform.base.bean.OmtInfo;
import com.huawei.hiassistant.platform.base.bean.recognize.CmdData;
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.RemoteDirectives;
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.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.interrupt.InterruptInfo;
import com.huawei.hiassistant.platform.base.messagebus.SwitchConsumer;
import com.huawei.hiassistant.platform.base.module.IntentionHandlerInterface;
import com.huawei.hiassistant.platform.base.module.ModuleInstanceFactory;
import com.huawei.hiassistant.platform.base.module.PlatformModule;
import com.huawei.hiassistant.platform.base.module.ability.DecisionCallbackAdapter;
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.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.OperationReportConstants;
import com.huawei.hiassistant.platform.base.util.SecureIntentUtil;
import com.huawei.hiassistant.platform.framework.bus.FrameworkBus;
import com.huawei.hiassistant.platform.framework.bus.msg.MessageSenderInterface;
import com.huawei.hiassistant.platform.framework.intentionhandler.IntentionHandler;
import com.huawei.hiassistant.platform.framework.intentionhandler.remote.e;
import com.huawei.hiassistant.platform.framework.msg.HandlerThreadModule;
import com.huawei.hiassistant.voice.intentionhandler.VoiceIntentionHandlerImpl;
import com.huawei.hms.ml.language.common.utils.Constant;
import defpackage.avb;
import defpackage.bgb;
import defpackage.joa;
import defpackage.nx9;
import defpackage.t44;
import defpackage.uq1;
import defpackage.yna;
import defpackage.yrb;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
public class IntentionHandler extends HandlerThreadModule {
private static final String DATA_ID_AIASSIATANT = "AIAssiatant";
private static final DecisionCallbackAdapter DECISION_CALLBACK = new a();
private static final String DEFAULT_DATA_ID = "hivoice";
private static final String EVENT_DIALOG_DECISION = "huawei.intent.action.DialogDecision";
private static final String EVENT_REPORT = "com.huawei.hivoice.intent.action.Report";
private static final String INTENTION_HANDLER_CLASS_NAME = "com.huawei.hiassistant.voice.intentionhandler.VoiceIntentionHandlerImpl";
private static final long QUERY_TIME_OUT = 1500;
private static final int RESULT_BUSY = -100;
private static final int RESULT_DS_EXECUTE_FAIL = -99;
private static final int RESULT_OK = 0;
public static final int STATUS_FINISHED = 2;
public static final int STATUS_STARTED = 1;
private static final String TAG = "IntentionHandler";
private final bgb clientInfoProcessor;
private SwitchConsumer<AssistantMessage<?>> consumers;
private avb directivesManager;
private String disSession;
private VoiceKitMessage dmVoiceKitMessage;
private final com.huawei.hiassistant.platform.framework.intentionhandler.a executionStateProcessor;
private IntentionHandlerInterface intentionHandlerImpl;
private final e remoteDirectivesProcessor;
public class a implements DecisionCallbackAdapter {
@Override
public void onResult(Map map) throws RemoteException {
KitLog.info(IntentionHandler.TAG, "ds onResult.");
KitLog.debug(IntentionHandler.TAG, "ds return map: {}", GsonUtils.toJson(map));
Intent intent = new Intent();
intent.putExtra(DecisionServiceConstant.DS_RESPONSE_NAME, GsonUtils.toJson(map));
UiPayload uiPayload = new UiPayload();
uiPayload.setContent("DS_RESPONSE");
uiPayload.setIntent(intent);
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.INTENTION_EXECUTOR_UI_MESSAGE, VoiceKitMessage.buildUiMessage(UiMessageType.CONTROL, uiPayload));
}
@Override
public void onTimeout() {
KitLog.debug(IntentionHandler.TAG, "onTimeout.", new Object[0]);
}
}
public class b implements IntentionHandlerInterface.CallBack {
public b() {
}
public static String c(Session session) {
return String.valueOf(session.getDialogId());
}
public final List<HeaderPayload> d(CmdData cmdData) {
if (cmdData.getCallParams().getDirectives() != null && cmdData.getCallParams().getDirectives().size() > 0) {
return cmdData.getCallParams().getDirectives();
}
HeaderPayload headerPayload = (HeaderPayload) GsonUtils.toBean(cmdData.getCallParams().getDirective().get("directives"), HeaderPayload.class);
ArrayList arrayList = new ArrayList();
arrayList.add(headerPayload);
return arrayList;
}
public final void e(VoiceKitMessage voiceKitMessage) {
if (voiceKitMessage == null || !voiceKitMessage.isReject()) {
return;
}
UiPayload uiPayload = new UiPayload();
uiPayload.setContent(ExtendedBusinessFlowState.REJECTION.getBusinessFlowState());
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.COMMANDER_BUSINESS_FLOW_STATE_CHANGE, VoiceKitMessage.buildUiMessage(UiMessageType.BUSINESS_FLOW_STATE, uiPayload, voiceKitMessage.getSession()));
}
public final void f(VoiceKitMessage voiceKitMessage, InterruptInfo interruptInfo) {
KitLog.info(IntentionHandler.TAG, "checkAndHandleVadForInterrupt");
if (interruptInfo.getSpeechEndTime() <= 0) {
if (interruptInfo.getInterruptTtsInfo() == null) {
KitLog.info(IntentionHandler.TAG, "handleAsrEnded interruptTtsInfo is null");
return;
}
interruptInfo.setSpeechEndTime(System.currentTimeMillis());
if (ModuleInstanceFactory.Ability.tts().isSpeaking()) {
KitLog.info(IntentionHandler.TAG, "handleAsrEnded tts not finished");
return;
}
KitLog.info(IntentionHandler.TAG, "handleAsrEnded fire timeout message");
MessageSenderInterface msg = FrameworkBus.msg();
PlatformModule platformModule = PlatformModule.INTENTION_HANDLER;
PlatformModule platformModule2 = PlatformModule.INTENTION_EXECUTOR;
msg.removeMsg(platformModule, platformModule2, PlatformMsg.CtlExt.INTENTION_EXECUTOR_INTERRUPT_TIMER_EXPIRED);
FrameworkBus.msg().sendMsg(platformModule, platformModule2, PlatformMsg.CtlExt.INTENTION_EXECUTOR_INTERRUPT_TIMER_EXPIRED, voiceKitMessage.getSession());
}
}
public final void g(boolean z, VoiceKitMessage voiceKitMessage) {
if (!voiceKitMessage.getSession().isFullDuplexMode() || z) {
return;
}
FullDuplex.stateManager().setExitFullDuplexByDirectivesFinished(false);
}
public final void h(boolean z, VoiceKitMessage voiceKitMessage) {
if (CommonRejection.Helper.stateManager().isCommonRejectionMode(InteractionIdInfo.build(voiceKitMessage))) {
if (z) {
if (!CommonRejection.Helper.calculator().isTimeOut()) {
return;
}
} else if (voiceKitMessage.getSession().getInteractionId() != BusinessFlowId.getInstance().getInteractionId()) {
return;
}
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.ASSISTANT_CONTROLLER, PlatformMsg.Ctl.INTENTION_HANDLER_COMMONREJECTION_STOP_RECORD, voiceKitMessage.getSession());
}
}
public final boolean i(VoiceKitMessage voiceKitMessage) {
if (voiceKitMessage == null) {
KitLog.warn(IntentionHandler.TAG, "IntentionHandler result is null");
return true;
}
if (voiceKitMessage.getSession() == null) {
KitLog.warn(IntentionHandler.TAG, "IntentionHandler result session is null");
return true;
}
if (TextUtils.isEmpty(voiceKitMessage.getSession().getSessionId())) {
KitLog.error(IntentionHandler.TAG, "no sessionId id?");
voiceKitMessage.getSession().setSessionId(BusinessFlowId.getInstance().getSessionId());
voiceKitMessage.getSession().setInteractionId(BusinessFlowId.getInstance().getInteractionId());
}
if (voiceKitMessage.getSession().isIgnoreVerify() || voiceKitMessage.getSession().isFullDuplexMode() || voiceKitMessage.getSession().getInteractionId() >= BusinessFlowId.getInstance().getInteractionId()) {
return false;
}
KitLog.info(IntentionHandler.TAG, "skip not current interaction");
return true;
}
public final void j(VoiceKitMessage voiceKitMessage) {
InterruptInfo interruptInfo = FrameworkBus.flowState().getInterruptInfo(InteractionIdInfo.build(voiceKitMessage));
boolean z = interruptInfo != null;
if (z) {
KitLog.info(IntentionHandler.TAG, "isInterruptResult");
IntentionHandler.this.reportInterruptRecord(voiceKitMessage);
if (!voiceKitMessage.getSession().isIgnoreVerify() && interruptInfo.getInterruptStatus() == 2) {
KitLog.info(IntentionHandler.TAG, "interrupt is complete, skip result");
return;
}
interruptInfo.setInterruptStatus(2);
}
ExecutionState executionState = new ExecutionState();
executionState.a = voiceKitMessage.getSession();
IntentionHandler.this.executionStateProcessor.f(executionState);
IntentionHandler.this.exitFullDuplexIfNeeded(voiceKitMessage);
if (MessageConstants.MessageName.MSG_NAME_DIALOG_CONTROL.equals(voiceKitMessage.getSession().getMessageName())) {
if (IntentionHandler.this.isFullDuplexRejection(Optional.of(voiceKitMessage))) {
IntentionHandler.this.setIntentionExecuteRecord(voiceKitMessage);
}
IntentionHandler.this.dispatchResultToLocal(voiceKitMessage, PlatformMsg.Data.INTENTION_HANDLER_CONTROL_RESULT, true);
return;
}
if (z && voiceKitMessage.getErrorCode() != 0) {
KitLog.info(IntentionHandler.TAG, "handleDmMessage: error result while interrupt");
f(voiceKitMessage, interruptInfo);
return;
}
if (z && voiceKitMessage.getErrorCode() == 0) {
KitLog.info(IntentionHandler.TAG, "interrupt success. report intention execution record and delay time record.");
if (l(voiceKitMessage)) {
IntentionHandler.this.reportIntentionExcuteRecord();
}
OperationReportUtils.getInstance().reportChatModeRecord();
}
BaseUtils.getTargetInstance(voiceKitMessage, VoiceKitMessage.class).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.b.this.m((VoiceKitMessage) obj);
}
});
IntentionHandler.this.dispatchResultToLocal(voiceKitMessage, PlatformMsg.Data.INTENTION_HANDLER_RESULT, true);
IntentionHandler.this.dispatchResultToRemote(voiceKitMessage);
IntentionHandler.this.setIntentionExecuteRecord(voiceKitMessage);
IntentionHandler.this.setChatModeReportRecord(voiceKitMessage);
IntentionHandler.this.printDurationInfo(voiceKitMessage);
}
public final void k(VoiceKitMessage voiceKitMessage) {
InterruptInfo interruptInfo = FrameworkBus.flowState().getInterruptInfo(InteractionIdInfo.build(voiceKitMessage));
boolean z = interruptInfo != null;
KitLog.info(IntentionHandler.TAG, "isInterruptResult = " + z);
if (z) {
if (!voiceKitMessage.getSession().isIgnoreVerify() && interruptInfo.getInterruptStatus() == 2) {
KitLog.debug(IntentionHandler.TAG, "interrupt is complete, skip result", new Object[0]);
return;
}
interruptInfo.setInterruptStatus(2);
}
ExecutionState executionState = new ExecutionState();
executionState.a = voiceKitMessage.getSession();
IntentionHandler.this.executionStateProcessor.f(executionState);
IntentionHandler.this.dispatchResultToLocal(voiceKitMessage, PlatformMsg.Data.INTENTION_HANDLER_DM_PARTIAL_RESULT, false);
IntentionHandler.this.dispatchResultToRemote(voiceKitMessage);
}
public final boolean l(VoiceKitMessage voiceKitMessage) {
String dialogId = OperationReportUtils.getInstance().getIntentionExecuteRecord().getDialogId();
String str = (String) Optional.of(voiceKitMessage).map(new nx9()).map(new Function() {
@Override
public final Object apply(Object obj) {
String c;
c = IntentionHandler.b.c((Session) obj);
return c;
}
}).orElse("");
boolean z = !TextUtils.equals(dialogId, str);
KitLog.debug(IntentionHandler.TAG, "cacheDialogId={}, curDialogId={}, isDialogIdChanged={}", dialogId, str, Boolean.valueOf(z));
return z;
}
public final void m(VoiceKitMessage voiceKitMessage) {
if (voiceKitMessage.getDirectives() == null || voiceKitMessage.getDirectives().size() <= 0) {
return;
}
IntentionHandler.this.dmVoiceKitMessage = voiceKitMessage;
}
@Override
public void onDisResult(CmdData cmdData) {
if (cmdData == null) {
KitLog.warn(IntentionHandler.TAG, "cmdData is null");
return;
}
IntentionHandler.this.disSession = GsonUtils.toJson(cmdData.getSession());
KitLog.debug(IntentionHandler.TAG, "onDisResult session is {}", IntentionHandler.this.disSession);
if (cmdData.getCallParams() == null) {
KitLog.warn(IntentionHandler.TAG, "callParams is null");
return;
}
BusinessFlowState currentState = FrameworkBus.flowState().getCurrentState(InteractionIdInfo.build(BusinessFlowId.getInstance().getSessionId(), BusinessFlowId.getInstance().getInteractionId()));
Session session = cmdData.getSession();
if (session == null || !MessageConstants.MessageName.MSG_NAME_DIALOG_DECISION.equals(session.getMessageName())) {
if (IntentionHandler.this.isBusy(currentState)) {
KitLog.info(IntentionHandler.TAG, "voiceKit SDK is busy");
IntentionHandler intentionHandler = IntentionHandler.this;
intentionHandler.sendBusyResponse(intentionHandler.disSession);
return;
} else {
VoiceKitMessage voiceKitMessage = new VoiceKitMessage();
voiceKitMessage.setSession(cmdData.getSession());
voiceKitMessage.setDirectives(d(cmdData));
voiceKitMessage.setErrorCode(0);
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.INTENTION_EXECUTOR, PlatformMsg.Data.INTENTION_HANDLER_DIS_RESULT, voiceKitMessage);
return;
}
}
Session session2 = new Session(session);
session2.setSender("APP").setReceiver(MessageConstants.Receiver.MSG_RECEIVER_NATIVE_DS);
VoiceKitMessage voiceKitMessage2 = new VoiceKitMessage();
voiceKitMessage2.setSession(session2);
voiceKitMessage2.setDirectives(d(cmdData));
String json = GsonUtils.toJson(voiceKitMessage2);
HashMap hashMap = new HashMap();
hashMap.put("content", json);
boolean executeEvent = ModuleInstanceFactory.Ability.decisionService().executeEvent(IntentionHandler.EVENT_DIALOG_DECISION, IntentionHandler.DATA_ID_AIASSIATANT, hashMap, false);
KitLog.info(IntentionHandler.TAG, "dialog decision execute result:" + executeEvent);
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("resultCode", Integer.valueOf(executeEvent ? 0 : IntentionHandler.RESULT_DS_EXECUTE_FAIL));
ModuleInstanceFactory.Ability.disService().sendResponse(IntentionHandler.this.disSession, 0, jsonObject.toString());
}
@Override
public void onDmPartialResult(VoiceKitMessage voiceKitMessage) {
if (i(voiceKitMessage)) {
KitLog.warn(IntentionHandler.TAG, "onDmPartialResult: invalid dm result.");
FrameworkBus.flowState().setRecognizing(InteractionIdInfo.build(voiceKitMessage), false);
} else {
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.ASSISTANT_CONTROLLER, PlatformMsg.Data.INTENTION_HANDLER_RESULT_STARTED, AssistantMessage.builder(Boolean.TRUE, voiceKitMessage.getSession()).build());
g(false, voiceKitMessage);
k(voiceKitMessage);
}
}
@Override
public void onEventResult(VoiceKitMessage voiceKitMessage) {
OmtInfo omtInfo;
Session session = voiceKitMessage.getSession();
if (session != null && session.isOmt() && ((omtInfo = OmtStateManager.getInstance().getOmtInfo(InteractionIdInfo.build(session.getSessionId(), session.getInteractionId()))) == null || !omtInfo.isActive())) {
KitLog.warn(IntentionHandler.TAG, "omt not active");
return;
}
if (!TextUtils.isEmpty(voiceKitMessage.getDirectivePolicy())) {
ExecutionState executionState = new ExecutionState();
executionState.a = voiceKitMessage.getSession();
IntentionHandler.this.executionStateProcessor.f(executionState);
}
if (yrb.a().f(voiceKitMessage)) {
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Data.INTENTION_HANDLER_RESULT_TO_NORTH_INTERFACE, voiceKitMessage);
} else {
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.INTENTION_EXECUTOR, PlatformMsg.Data.INTENTION_HANDLER_EVENT_RESULT, voiceKitMessage);
}
}
@Override
public void onResult(VoiceKitMessage voiceKitMessage) {
boolean z = false;
if (i(voiceKitMessage)) {
KitLog.warn(IntentionHandler.TAG, "onResult: invalid dm result.");
FrameworkBus.flowState().setRecognizing(InteractionIdInfo.build(voiceKitMessage), false);
return;
}
if (voiceKitMessage.isTest()) {
KitLog.info(IntentionHandler.TAG, "action test result , make interaction active");
FrameworkBus.flowState().addActiveInteraction(InteractionIdInfo.build(voiceKitMessage));
} else {
if (!FrameworkBus.flowState().isRecognizing(InteractionIdInfo.build(voiceKitMessage)) && !voiceKitMessage.getSession().isIgnoreVerify()) {
KitLog.info(IntentionHandler.TAG, String.format(Locale.ROOT, "onResult %s, is not recognizing, ignore recognize result", voiceKitMessage.getSecureDmResult()));
return;
}
KitLog.debug(IntentionHandler.TAG, "onResult", new Object[0]);
}
boolean isCommonRejectionResult = voiceKitMessage.isCommonRejectionResult();
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.ASSISTANT_CONTROLLER, PlatformMsg.Data.INTENTION_HANDLER_RESULT_STARTED, AssistantMessage.builder(Boolean.valueOf((isCommonRejectionResult || voiceKitMessage.isAutoRetryResult()) ? false : true), voiceKitMessage.getSession()).build());
FrameworkBus.flowState().setRecognizing(InteractionIdInfo.build(voiceKitMessage), false);
e(voiceKitMessage);
OmtStateManager.getInstance().clear();
h(isCommonRejectionResult, voiceKitMessage);
if (voiceKitMessage.isReject() && !isCommonRejectionResult) {
z = true;
}
g(z, voiceKitMessage);
j(voiceKitMessage);
}
@Override
public void onUpdateVoiceContextResult(VoiceKitMessage voiceKitMessage) {
if (voiceKitMessage == null) {
KitLog.warn(IntentionHandler.TAG, "onUpdateVoiceContextResult result is null");
return;
}
if (voiceKitMessage.getSession() == null) {
KitLog.warn(IntentionHandler.TAG, "onUpdateVoiceContextResult result session is null");
return;
}
if (voiceKitMessage.getSession().getInteractionId() > 0 && !FrameworkBus.flowState().isInteractionActive(InteractionIdInfo.build(voiceKitMessage))) {
KitLog.warn(IntentionHandler.TAG, "onUpdateVoiceContextResult interaction inactive");
return;
}
if (voiceKitMessage.getDirectives() != null && voiceKitMessage.getDirectives().size() > 0) {
IntentionHandler.this.dmVoiceKitMessage = voiceKitMessage;
}
ExecutionState executionState = new ExecutionState();
executionState.a = voiceKitMessage.getSession();
IntentionHandler.this.executionStateProcessor.f(executionState);
IntentionHandler.this.setIntentionExecuteRecord(voiceKitMessage);
IntentionHandler.this.setChatModeReportRecord(voiceKitMessage);
IntentionHandler.this.dispatchResultToLocal(voiceKitMessage, PlatformMsg.Data.INTENTION_HANDLER_UPDATE_VOICE_CONTEXT_RESULT, true);
IntentionHandler.this.dispatchResultToRemote(voiceKitMessage);
}
public b(IntentionHandler intentionHandler, a aVar) {
this();
}
}
private IntentionHandler() {
super(TAG);
com.huawei.hiassistant.platform.framework.intentionhandler.a aVar = new com.huawei.hiassistant.platform.framework.intentionhandler.a();
this.executionStateProcessor = aVar;
this.remoteDirectivesProcessor = new e(aVar);
this.clientInfoProcessor = new bgb();
}
public void dispatchResultToLocal(VoiceKitMessage voiceKitMessage, int i, boolean z) {
if (yrb.a().c(voiceKitMessage)) {
voiceKitMessage.getSession().setSender(MessageConstants.Receiver.MSG_RECEIVER_CLOUD_DM);
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.INTENTION_EXECUTOR, i, voiceKitMessage);
} else {
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.NORTH_INTERFACE, PlatformMsg.Data.INTENTION_HANDLER_RESULT_TO_NORTH_INTERFACE, voiceKitMessage);
}
if (z) {
ArrayMap arrayMap = new ArrayMap();
arrayMap.put("content", Optional.ofNullable(GsonUtils.toJson(voiceKitMessage)).orElse(""));
ModuleInstanceFactory.Ability.decisionService().executeEvent(EVENT_REPORT, DEFAULT_DATA_ID, arrayMap, DECISION_CALLBACK, QUERY_TIME_OUT);
}
}
public void dispatchResultToRemote(VoiceKitMessage voiceKitMessage) {
if (voiceKitMessage == null) {
KitLog.info(TAG, "handleRemoteDirectives illegal input params");
return;
}
List<RemoteDirectives> remoteDirectives = voiceKitMessage.getRemoteDirectives();
if (remoteDirectives == null || remoteDirectives.size() == 0) {
KitLog.info(TAG, "handleRemoteDirectives empty");
} else {
this.remoteDirectivesProcessor.g(voiceKitMessage, remoteDirectives);
}
}
public void exitFullDuplexIfNeeded(VoiceKitMessage voiceKitMessage) {
Optional<VoiceKitMessage> ofNullable = Optional.ofNullable(voiceKitMessage);
Optional map = ofNullable.map(new nx9()).map(new Function() {
@Override
public final Object apply(Object obj) {
return Boolean.valueOf(((Session) obj).isFullDuplexMode());
}
});
Boolean bool = Boolean.FALSE;
if (((Boolean) map.orElse(bool)).booleanValue()) {
if (((Boolean) ofNullable.map(new Function() {
@Override
public final Object apply(Object obj) {
Boolean lambda$exitFullDuplexIfNeeded$13;
lambda$exitFullDuplexIfNeeded$13 = IntentionHandler.lambda$exitFullDuplexIfNeeded$13((VoiceKitMessage) obj);
return lambda$exitFullDuplexIfNeeded$13;
}
}).orElse(bool)).booleanValue() || isFullDuplexRejection(ofNullable)) {
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.ASSISTANT_CONTROLLER, PlatformMsg.Ctl.INTENTION_HANDLER_JUDGE_EXIT_FULLDUPLEX, voiceKitMessage);
}
}
}
private String getPayloadValueByKey(VoiceKitMessage voiceKitMessage, String str, String str2, final String str3) {
return voiceKitMessage == null ? "" : (String) Optional.ofNullable(voiceKitMessage.getVoicePayload(str, str2)).map(new yna()).map(new joa()).map(new Function() {
@Override
public final Object apply(Object obj) {
JsonElement lambda$getPayloadValueByKey$17;
lambda$getPayloadValueByKey$17 = IntentionHandler.lambda$getPayloadValueByKey$17(str3, (JsonObject) obj);
return lambda$getPayloadValueByKey$17;
}
}).map(new uq1()).orElse("");
}
private void initProcessMsg() {
SwitchConsumer<AssistantMessage<?>> switchConsumer = new SwitchConsumer<>();
this.consumers = switchConsumer;
switchConsumer.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandIntentionExecutorResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_BUSINESS_FINISHED, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandBusinessFinished((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.INTENTION_HANDLER_CALL_DECISION_SERVICE, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandCallDecisionService((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.INTENTION_UNDERSTAND_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandStartIntentionHandler((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.ABILITY_CONNECTOR_INTENTION_HANDLER_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandIntentionHandlerResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.ABILITY_CONNECTOR_INTENTION_HANDLER_PARTIAL_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandIntentionHandlerPartialResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(107011, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandIntentionHandlerResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.CONTROLLER_BUSINESS_ABORT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandBusinessAbort((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.NORTH_INTERFACE_INTENT_FOR_SDK, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandIntentForSdk((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.NORTH_INTERFACE_EVENT_FOR_OTHERS, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandEventForOthers((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.ABILITY_CONNECTOR_EVENT_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandEventResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.ABILITY_CONNECTOR_UPDATE_VOICE_CONTEXT_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandUpdateVoiceContextResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.ABILITY_CONNECTOR_LAST_RESULT_ACQUIRED, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandLastResultAcquired((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.ABILITY_CONNECTOR_DM_WAITING_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandDmWaitingResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.ABILITY_CONNECTOR_DM_PARTIAL_WAITING_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandDmPartialWaitingResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.ABILITY_CONNECTOR_DIS_RESULT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandDisResult((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Data.INTENTION_EXECUTOR_UPLOAD_CLIENT_INFO, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandUploadClientInfo((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_APP_DIALOG_FINISHED, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandSendAppDialogFinished((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_APP_CONTINUE_DIALOG, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandSendAppContinueDialog((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_EXECUTE_DIRECTIVE_STARTED, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandExecutionStarted((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_EXECUTE_DIRECTIVE_FINISHED, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandExecutionFinished((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.NORTH_INTERFACE_UPDATE_EVENT, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandUpdateEvent((AssistantMessage) obj);
}
});
this.consumers.addCommand(PlatformMsg.Ctl.INTENTION_EXECUTOR_SEND_APP_REJECT_RECOGNIZE, new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.processCommandSendAppRejectRecognize((AssistantMessage) obj);
}
});
}
public boolean isBusy(BusinessFlowState businessFlowState) {
String businessFlowState2 = businessFlowState.getBusinessFlowState();
KitLog.info(TAG, "currentState is " + businessFlowState2);
if (TextUtils.equals(businessFlowState2, "READYING") || TextUtils.equals(businessFlowState2, "PSEUDO")) {
return false;
}
return !TextUtils.equals(businessFlowState2, "INTENTION_HANDLE") || ModuleInstanceFactory.Ability.recognize().isInitEngineFinished();
}
public boolean isFullDuplexRejection(Optional<VoiceKitMessage> optional) {
return ((Boolean) optional.map(new t44()).map(new Function() {
@Override
public final Object apply(Object obj) {
HeaderPayload lambda$isFullDuplexRejection$14;
lambda$isFullDuplexRejection$14 = IntentionHandler.lambda$isFullDuplexRejection$14((List) obj);
return lambda$isFullDuplexRejection$14;
}
}).map(new yna()).map(new joa()).map(new Function() {
@Override
public final Object apply(Object obj) {
JsonElement lambda$isFullDuplexRejection$15;
lambda$isFullDuplexRejection$15 = IntentionHandler.lambda$isFullDuplexRejection$15((JsonObject) obj);
return lambda$isFullDuplexRejection$15;
}
}).map(new uq1()).map(new Function() {
@Override
public final Object apply(Object obj) {
Boolean lambda$isFullDuplexRejection$16;
lambda$isFullDuplexRejection$16 = IntentionHandler.lambda$isFullDuplexRejection$16((String) obj);
return lambda$isFullDuplexRejection$16;
}
}).orElse(Boolean.FALSE)).booleanValue();
}
public static Boolean lambda$exitFullDuplexIfNeeded$13(VoiceKitMessage voiceKitMessage) {
return Boolean.valueOf(voiceKitMessage.getErrorCode() != 0);
}
public static JsonElement lambda$getPayloadValueByKey$17(String str, JsonObject jsonObject) {
return jsonObject.get(str);
}
public static HeaderPayload lambda$isFullDuplexRejection$14(List list) {
return BaseUtils.parseHeaderPayload(list, "StartNewFullDuplexDialog", "System");
}
public static JsonElement lambda$isFullDuplexRejection$15(JsonObject jsonObject) {
return jsonObject.get(CommonRejection.Constants.FINISH_REASON_REJECTION);
}
public static Boolean lambda$isFullDuplexRejection$16(String str) {
return Boolean.valueOf(TextUtils.equals(str, FullDuplex.Constants.FULLDUPLEX_REJECT));
}
public static String lambda$printDurationInfo$12(List list) {
return (String) list.stream().map(new Function() {
@Override
public final Object apply(Object obj) {
String duration;
duration = ((Session.Duration) obj).toString();
return duration;
}
}).collect(Collectors.joining(Constant.COMMA, "[", "]"));
}
public static Optional lambda$processCommandExecutionFinished$2(AssistantMessage assistantMessage) {
return assistantMessage.getBody(Integer.class);
}
public void lambda$processCommandExecutionFinished$3(AssistantMessage assistantMessage, Integer num) {
this.executionStateProcessor.d(assistantMessage.getHeader(), 2, num.intValue());
}
public static Optional lambda$processCommandExecutionStarted$0(AssistantMessage assistantMessage) {
return assistantMessage.getBody(Integer.class);
}
public void lambda$processCommandExecutionStarted$1(AssistantMessage assistantMessage, Integer num) {
this.executionStateProcessor.d(assistantMessage.getHeader(), 1, num.intValue());
}
public void lambda$processCommandIntentionExecutorResult$4(Session session) {
this.executionStateProcessor.c(session);
}
public void lambda$processCommandSendAppDialogFinished$6(Intent intent) {
KitLog.info(TAG, "instanceof intent");
this.executionStateProcessor.e((Session) GsonUtils.toBean(SecureIntentUtil.getSecureIntentString(intent, "session"), Session.class), intent);
}
public void lambda$processCommandSendAppDialogFinished$7(Session session) {
KitLog.info(TAG, "instanceof session");
this.executionStateProcessor.e(session, null);
}
public void lambda$processCommandSendAppDialogFinished$8(VoiceKitMessage voiceKitMessage) {
Intent intent;
KitLog.info(TAG, "instanceof voiceKitMessage");
HeaderPayload voicePayload = voiceKitMessage.getVoicePayload("UiDisplay", "control");
if (voicePayload == null) {
KitLog.error(TAG, "uiControlPayload is null");
return;
}
Payload payload = voicePayload.getPayload();
if (payload instanceof UiPayload) {
KitLog.debug(TAG, "payload instanceof UiPayload", new Object[0]);
intent = ((UiPayload) payload).getIntent();
} else {
intent = null;
}
this.executionStateProcessor.e(voiceKitMessage.getSession(), intent);
}
public static void lambda$setChatModeReportRecord$18(CpInfo cpInfo) {
OperationReportUtils.getInstance().getChatModeReportRecord().setCpName(cpInfo.getName()).setAbility(cpInfo.getAbilityId());
}
public static boolean lambda$setChatModeReportRecord$19(AbTestInfo abTestInfo) {
return abTestInfo.getReportId() == 522;
}
public static void lambda$setChatModeReportRecord$20(AbTestInfo abTestInfo) {
OperationReportUtils.getInstance().getChatModeReportRecord().setAbtestInfo(abTestInfo.getAbtestInfoList().toString());
}
public static void lambda$setChatModeReportRecord$21(List list) {
list.stream().filter(new Predicate() {
@Override
public final boolean test(Object obj) {
boolean lambda$setChatModeReportRecord$19;
lambda$setChatModeReportRecord$19 = IntentionHandler.lambda$setChatModeReportRecord$19((AbTestInfo) obj);
return lambda$setChatModeReportRecord$19;
}
}).forEach(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.lambda$setChatModeReportRecord$20((AbTestInfo) obj);
}
});
}
private void modifyIntentionExecuteRecord(VoiceKitMessage voiceKitMessage, boolean z, String str, boolean z2) {
OperationReportConstants.IntentionExecuteRecord count = OperationReportUtils.getInstance().getIntentionExecuteRecord().setDialogFinishedFlag(voiceKitMessage.isDialogFinished() || z2).setDialogId(String.valueOf(voiceKitMessage.getSession().getDialogId())).setInteractionId(String.valueOf((int) voiceKitMessage.getSession().getInteractionId())).setDomain(voiceKitMessage.getDomainId()).setSubDomain(voiceKitMessage.getSubDomainId()).setIntentName(voiceKitMessage.getIntentName()).setCount(String.valueOf((int) voiceKitMessage.getSession().getInteractionId()));
if (z) {
str = "2";
}
count.setAccomplish(str).setResult(String.valueOf(voiceKitMessage.getOriErrorCode())).setModeStates(voiceKitMessage.getModeStates()).setNluIntentId(voiceKitMessage.getNluIntentId()).setNluIntentName(voiceKitMessage.getNluIntentName()).setFinalNluIntentId(voiceKitMessage.getFinalNluIntentId()).setFinalNluIntentName(voiceKitMessage.getFinalNluIntentName()).setSkillTriggerWord(voiceKitMessage.getSkillTriggerWordStr()).setSkillId(voiceKitMessage.getSkillId()).setSubError(voiceKitMessage.getSubErrorCode()).setSkillState(getPayloadValueByKey(voiceKitMessage, "Command", "TaskState", "skillState")).setScene(getPayloadValueByKey(voiceKitMessage, "DialogInfo", "DialogStatus", "scene")).setSearchSources(voiceKitMessage.getSearchSources());
if (OperationReportConstants.QA_INTENTION_ID.equals(voiceKitMessage.getIntentId())) {
String qaTags = voiceKitMessage.getQaTags();
OperationReportConstants.IntentionExecuteRecord intentionExecuteRecord = OperationReportUtils.getInstance().getIntentionExecuteRecord();
if ("".equals(qaTags)) {
qaTags = voiceKitMessage.getIntentId();
}
intentionExecuteRecord.setIntent(qaTags);
} else {
OperationReportUtils.getInstance().getIntentionExecuteRecord().setIntent(voiceKitMessage.getIntentId());
}
if (OperationReportUtils.getInstance().getIntentionExecuteRecord().isNewReportTurn()) {
OperationReportUtils.getInstance().getIntentionExecuteRecord().setFirstRoundIntentId(OperationReportUtils.getInstance().getIntentionExecuteRecord().getIntent());
OperationReportUtils.getInstance().getIntentionExecuteRecord().setNewReportTurn(false);
}
if (voiceKitMessage.isChangeDomain()) {
OperationReportUtils.getInstance().getIntentionExecuteRecord().setChangeDomain(true);
}
}
public void printDurationInfo(VoiceKitMessage voiceKitMessage) {
KitLog.info(TAG, "printDurationInfo -> " + ((String) Optional.ofNullable(voiceKitMessage).map(new Function() {
@Override
public final Object apply(Object obj) {
Session session;
session = ((VoiceKitMessage) obj).getSession();
return session;
}
}).map(new Function() {
@Override
public final Object apply(Object obj) {
List durations;
durations = ((Session) obj).getDurations();
return durations;
}
}).map(new Function() {
@Override
public final Object apply(Object obj) {
String lambda$printDurationInfo$12;
lambda$printDurationInfo$12 = IntentionHandler.lambda$printDurationInfo$12((List) obj);
return lambda$printDurationInfo$12;
}
}).orElse("")));
}
public void processCommandBusinessAbort(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleBusinessAbort(assistantMessage);
this.executionStateProcessor.a();
}
public void processCommandBusinessFinished(AssistantMessage<?> assistantMessage) {
KitLog.debug(TAG, "processCommandBusinessFinished", new Object[0]);
VoiceKitMessage voiceKitMessage = this.dmVoiceKitMessage;
if (voiceKitMessage != null) {
this.intentionHandlerImpl.handleIntentionExecutorResult(voiceKitMessage.copy());
OperationReportUtils.getInstance().reportChatModeRecord();
}
}
public void processCommandCallDecisionService(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleCallDecisionService(assistantMessage);
}
public void processCommandDisResult(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleDisResult(assistantMessage);
}
public void processCommandDmPartialWaitingResult(AssistantMessage<?> assistantMessage) {
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.INTENTION_EXECUTOR_UI_MESSAGE, VoiceKitMessage.buildUiMessage(UiMessageType.WAIT_DM_PARTIAL_RESULT, new UiPayload()));
}
public void processCommandDmWaitingResult(AssistantMessage<?> assistantMessage) {
if (FrameworkBus.flowState().getInterruptInfo(InteractionIdInfo.build(assistantMessage)) == null) {
this.intentionHandlerImpl.handleDmWaitingResult();
}
}
public void processCommandEventForOthers(AssistantMessage<?> assistantMessage) {
yrb.a().g();
yrb.a().e((String[]) assistantMessage.getBody(String[].class).orElse(new String[0]));
}
public void processCommandEventResult(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleEventResult(assistantMessage);
}
public void processCommandExecutionFinished(final AssistantMessage<?> assistantMessage) {
KitLog.debug(TAG, "processCommandExecutionFinished", new Object[0]);
Optional.ofNullable(assistantMessage).flatMap(new Function() {
@Override
public final Object apply(Object obj) {
Optional lambda$processCommandExecutionFinished$2;
lambda$processCommandExecutionFinished$2 = IntentionHandler.lambda$processCommandExecutionFinished$2((AssistantMessage) obj);
return lambda$processCommandExecutionFinished$2;
}
}).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.lambda$processCommandExecutionFinished$3(assistantMessage, (Integer) obj);
}
});
}
public void processCommandExecutionStarted(final AssistantMessage<?> assistantMessage) {
KitLog.debug(TAG, "processCommandExecutionStart", new Object[0]);
Optional.ofNullable(assistantMessage).flatMap(new Function() {
@Override
public final Object apply(Object obj) {
Optional lambda$processCommandExecutionStarted$0;
lambda$processCommandExecutionStarted$0 = IntentionHandler.lambda$processCommandExecutionStarted$0((AssistantMessage) obj);
return lambda$processCommandExecutionStarted$0;
}
}).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.lambda$processCommandExecutionStarted$1(assistantMessage, (Integer) obj);
}
});
}
public void processCommandIntentForSdk(AssistantMessage<?> assistantMessage) {
yrb.a().d();
yrb.a().b((String[]) assistantMessage.getBody(String[].class).orElse(new String[0]));
}
public void processCommandIntentionExecutorResult(AssistantMessage<?> assistantMessage) {
KitLog.debug(TAG, "execute end, report and switch state", new Object[0]);
if (assistantMessage != null) {
assistantMessage.getBody(Session.class).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.lambda$processCommandIntentionExecutorResult$4((Session) obj);
}
});
}
}
public void processCommandIntentionHandlerPartialResult(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleIntentionHandlerPartialResult(assistantMessage);
}
public void processCommandIntentionHandlerResult(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleIntentionHandlerResult(assistantMessage);
}
public void processCommandLastResultAcquired(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleLastResultAcquired(assistantMessage);
}
public void processCommandSendAppContinueDialog(AssistantMessage<?> assistantMessage) {
KitLog.debug(TAG, "send app ContinueDialog msg", new Object[0]);
final UiPayload uiPayload = new UiPayload();
uiPayload.setContent("ContinueDialog");
if (assistantMessage != null) {
assistantMessage.getBody(Intent.class).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
UiPayload.this.setIntent((Intent) obj);
}
});
}
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.INTENTION_EXECUTOR_UI_MESSAGE, VoiceKitMessage.buildUiMessage(UiMessageType.CONTROL, uiPayload));
}
public void processCommandSendAppDialogFinished(AssistantMessage<?> assistantMessage) {
KitLog.debug(TAG, "send app DialogFinished msg", new Object[0]);
if (assistantMessage != null) {
assistantMessage.getBody(Intent.class).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.lambda$processCommandSendAppDialogFinished$6((Intent) obj);
}
});
assistantMessage.getBody(Session.class).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.lambda$processCommandSendAppDialogFinished$7((Session) obj);
}
});
assistantMessage.getBody(VoiceKitMessage.class).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.this.lambda$processCommandSendAppDialogFinished$8((VoiceKitMessage) obj);
}
});
}
}
public void processCommandSendAppRejectRecognize(AssistantMessage<?> assistantMessage) {
String secureIntentString;
Intent intent;
KitLog.info(TAG, "send app rejectRecognize msg");
secureIntentString = (assistantMessage == null || !(assistantMessage.getBody() instanceof Intent)) ? "" : SecureIntentUtil.getSecureIntentString((Intent) assistantMessage.getBody(), "finishReason");
KitLog.debug(TAG, "send app rejectRecognize , finishReason {}", secureIntentString);
intent = new Intent();
secureIntentString.hashCode();
switch (secureIntentString) {
case "rejection":
case "timeout":
case "cloudServiceError":
case "slbOverload":
case "asrOverload":
intent.putExtra("finishReason", secureIntentString);
break;
}
UiPayload uiPayload = new UiPayload();
uiPayload.setIntent(intent);
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_EXECUTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.CtlExt.INTENTION_EXECUTOR_UI_MESSAGE, VoiceKitMessage.buildUiMessage(UiMessageType.REJECT_RECOGNIZE, uiPayload));
}
public void processCommandStartIntentionHandler(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.startIntentionHandler(assistantMessage);
}
public void processCommandUpdateEvent(AssistantMessage<?> assistantMessage) {
if (!(assistantMessage.getBody() instanceof String)) {
KitLog.warn(TAG, "updateEvent msg is not string");
return;
}
String valueOf = String.valueOf(assistantMessage.getBody());
if (!GsonUtils.isJsonValid(valueOf)) {
KitLog.warn(TAG, "invalid input parameter:NORTH_INTERFACE_UPDATE_EVENT");
return;
}
VoiceEvent voiceEvent = (VoiceEvent) GsonUtils.toBean(valueOf, VoiceEvent.class);
if (voiceEvent == null) {
KitLog.warn(TAG, "voiceEvent null");
return;
}
Session session = voiceEvent.getSession();
if (session == null || TextUtils.isEmpty(session.getMessageName())) {
KitLog.warn(TAG, "invalid parameter:session");
return;
}
String messageName = session.getMessageName();
messageName.hashCode();
if (messageName.equals("updateEvent")) {
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.ASSISTANT_CONTROLLER, PlatformMsg.Ctl.INTENTION_EXECUTOR_UPDATE_EVENT, assistantMessage);
return;
}
if (!messageName.equals(MessageConstants.MessageName.MSG_NAME_DIALOG_RESULT)) {
KitLog.info(TAG, "message name not match");
return;
}
KitLog.debug(TAG, "updateEvent dialog result:{}", GsonUtils.toJson(voiceEvent));
VoiceKitMessage voiceKitMessage = new VoiceKitMessage();
voiceKitMessage.setSession(session);
voiceKitMessage.setDirectives(voiceEvent.getDirectives());
voiceKitMessage.setContexts(voiceEvent.getContexts());
FrameworkBus.msg().sendMsg(PlatformModule.INTENTION_HANDLER, PlatformModule.INTENTION_EXECUTOR, PlatformMsg.Data.INTENTION_HANDLER_EVENT_RESULT, voiceKitMessage);
}
public void processCommandUpdateVoiceContextResult(AssistantMessage<?> assistantMessage) {
this.intentionHandlerImpl.handleUpdateVoiceContextResult(assistantMessage);
}
public void processCommandUploadClientInfo(AssistantMessage<?> assistantMessage) {
this.clientInfoProcessor.c(assistantMessage, this.disSession);
}
public void reportIntentionExcuteRecord() {
if (TextUtils.equals(OperationReportUtils.getInstance().getIntentionExecuteRecord().getSkillState(), "running") || !OperationReportUtils.getInstance().getIntentionExecuteRecord().isSkillScene()) {
OperationReportUtils.getInstance().getIntentionExecuteRecord().setResult("3");
boolean isNetworkAvailable = NetworkUtil.isNetworkAvailable(IAssistantConfig.getInstance().getAppContext());
OperationReportUtils.getInstance().getIntentionExecuteRecord().setEndTime(String.valueOf(System.currentTimeMillis()));
OperationReportUtils.getInstance().getIntentionExecuteRecord().setNetType(isNetworkAvailable ? "1" : "0");
OperationReportUtils.getInstance().reportIntentionExecuteRecord();
}
}
public void reportInterruptRecord(VoiceKitMessage voiceKitMessage) {
OperationReportUtils.getInstance().getInterruptRecord().setDialogId(String.valueOf(voiceKitMessage.getSession().getDialogId())).setInteraction(String.valueOf((int) voiceKitMessage.getSession().getInteractionId())).setResultTime(String.valueOf(System.currentTimeMillis())).setBreakResult(voiceKitMessage.getErrorCode() == 0 ? "1" : "2").setErrorCode(String.valueOf(voiceKitMessage.getOriErrorCode()));
OperationReportUtils.getInstance().reportInterruptRecord();
}
public void sendBusyResponse(String str) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("resultCode", -100);
ModuleInstanceFactory.Ability.disService().sendResponse(str, 0, jsonObject.toString());
}
public void setChatModeReportRecord(VoiceKitMessage voiceKitMessage) {
OperationReportUtils.getInstance().getChatModeReportRecord().setSessionId(voiceKitMessage.getSession().getSessionId()).setDialogId(String.valueOf(voiceKitMessage.getSession().getDialogId())).setInteractionId(String.valueOf((int) voiceKitMessage.getSession().getInteractionId()));
voiceKitMessage.getCpInfo().ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.lambda$setChatModeReportRecord$18((CpInfo) obj);
}
});
voiceKitMessage.getAbTestInfo().ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
IntentionHandler.lambda$setChatModeReportRecord$21((List) obj);
}
});
}
public void setIntentionExecuteRecord(VoiceKitMessage voiceKitMessage) {
boolean z;
boolean z2;
if (voiceKitMessage == null) {
return;
}
if (voiceKitMessage.getDirectiveNames() != null) {
List<String> directiveNames = voiceKitMessage.getDirectiveNames();
z = directiveNames.contains("SimulatingClick");
z2 = directiveNames.contains("DialogFinished");
} else {
z = false;
z2 = false;
}
modifyIntentionExecuteRecord(voiceKitMessage, OperationReportUtils.getInstance().getIntentionExecuteRecord().getAccomplish().equals("2"), z ? "2" : "1", z2);
}
@Override
public void destroy() {
super.destroy();
}
@Override
public void initInHandler() {
KitLog.debug(TAG, "[platform init] init start", new Object[0]);
initProcessMsg();
try {
Object newInstance = VoiceIntentionHandlerImpl.class.newInstance();
if (newInstance instanceof IntentionHandlerInterface) {
this.intentionHandlerImpl = (IntentionHandlerInterface) newInstance;
this.directivesManager = new avb();
this.intentionHandlerImpl.init(new b(this, null), this.directivesManager);
}
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException e) {
KitLog.error(TAG, "init exception" + e.getMessage());
}
yrb.a().d();
}
@Override
public void processMessage(AssistantMessage<?> assistantMessage) {
if (assistantMessage == null) {
return;
}
int type = assistantMessage.getType();
KitLog.info(TAG, "pcsMsg:name->" + MessageSparse.getName(type));
if (this.intentionHandlerImpl == null) {
KitLog.warn(TAG, "intentionHandlerImpl is null");
} else {
if (this.consumers.process(String.valueOf(type), assistantMessage)) {
return;
}
KitLog.debug(TAG, "Message ID is unknown:{} msgName:{}", Integer.valueOf(type), MessageSparse.getName(type));
}
}
}