正在查看: Petal Maps v4.7.0.310001 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Petal Maps v4.7.0.310001 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.huawei.hiassistant.platform.framework.northinterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import com.huawei.agconnect.apms.APMS;
import com.huawei.hiai.pdk.interfaces.tts.ParamsConstants;
import com.huawei.hiai.pdk.unifiedaccess.HttpConfig;
import com.huawei.hiai.tts.constants.BaseConstants;
import com.huawei.hiassistant.platform.base.bean.AudioDataMessage;
import com.huawei.hiassistant.platform.base.bean.InteractionIdInfo;
import com.huawei.hiassistant.platform.base.bean.VoicekitCallbackInfo;
import com.huawei.hiassistant.platform.base.bean.recognize.MessageConstants;
import com.huawei.hiassistant.platform.base.bean.recognize.Session;
import com.huawei.hiassistant.platform.base.bean.recognize.VoiceContext;
import com.huawei.hiassistant.platform.base.bean.recognize.VoiceKitMessage;
import com.huawei.hiassistant.platform.base.bean.util.GsonUtils;
import com.huawei.hiassistant.platform.base.module.ModuleInstanceFactory;
import com.huawei.hiassistant.platform.base.module.PlatformModule;
import com.huawei.hiassistant.platform.base.module.ability.TtsAbilityInterface;
import com.huawei.hiassistant.platform.base.msg.AssistantMessage;
import com.huawei.hiassistant.platform.base.msg.PlatformMsg;
import com.huawei.hiassistant.platform.base.northinterface.Constants;
import com.huawei.hiassistant.platform.base.northinterface.VoiceKitSdk;
import com.huawei.hiassistant.platform.base.northinterface.asr.BaseAsrListener;
import com.huawei.hiassistant.platform.base.northinterface.idsdata.BaseDataServiceListener;
import com.huawei.hiassistant.platform.base.northinterface.idsdata.DataServiceInterface;
import com.huawei.hiassistant.platform.base.northinterface.postoperation.VoicekitCallback;
import com.huawei.hiassistant.platform.base.northinterface.recognize.BaseRecognizeListener;
import com.huawei.hiassistant.platform.base.northinterface.recognize.RealMachineTestListener;
import com.huawei.hiassistant.platform.base.northinterface.recognize.RecognizerIntent;
import com.huawei.hiassistant.platform.base.northinterface.tts.BaseTtsListener;
import com.huawei.hiassistant.platform.base.northinterface.tts.ClientIdConstant;
import com.huawei.hiassistant.platform.base.northinterface.ui.BaseUiListener;
import com.huawei.hiassistant.platform.base.northinterface.visible.VisibleKitListener;
import com.huawei.hiassistant.platform.base.northinterface.wakeup.BaseWakeupListener;
import com.huawei.hiassistant.platform.base.northinterface.wakeup.WakeupIntent;
import com.huawei.hiassistant.platform.base.policy.OfflineReportManager;
import com.huawei.hiassistant.platform.base.report.HiAnalyticsReport;
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.PluginUtil;
import com.huawei.hiassistant.platform.base.util.SecureIntentUtil;
import com.huawei.hiassistant.platform.base.util.common.CommandActionContextUtil;
import com.huawei.hiassistant.platform.base.util.voice.CheckFeatureUtil;
import com.huawei.hiassistant.platform.framework.bus.FrameworkBus;
import com.huawei.hiassistant.platform.framework.bus.msg.MessageSenderInterface;
import com.huawei.hiassistant.platform.framework.northinterface.NorthInterfaceCallBack;
import com.huawei.hiassistant.platform.framework.northinterface.a;
import com.huawei.hiassistant.voice.abilityconnector.recognizer.cloud.common.HiVoiceConstants;
import defpackage.bvb;
import defpackage.cgb;
import defpackage.dwb;
import defpackage.hnb;
import defpackage.zrb;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import org.json.JSONArray;
public class a extends VoiceKitSdk {
public NorthInterfaceCallBack a;
public BaseUiListener c;
public BaseWakeupListener d;
public BaseAsrListener e;
public VisibleKitListener f;
public ConcurrentHashMap<String, BaseTtsListener> g = new ConcurrentHashMap<>();
public BaseRecognizeListener b = x();
public class C0024a extends BaseDataServiceListener {
public final VoicekitCallback a;
public C0024a(VoicekitCallback voicekitCallback) {
this.a = voicekitCallback;
}
@Override
public void onResult(int i, String str) {
Bundle bundle = new Bundle();
KitLog.info("VoiceKitSdkImpl", "uploadUserData onResult code: " + i + " msg: " + str);
int i2 = i != 0 ? -1 : 0;
bundle.putString("operationResponse", String.format(Locale.ROOT, "{\"errorCode\":\"%s\",\"errorMsg\":\"%s\"}", Integer.valueOf(i2), str));
final VoicekitCallbackInfo voicekitCallbackInfo = new VoicekitCallbackInfo(i2, bundle);
Optional.ofNullable(this.a).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
((VoicekitCallback) obj).onCallback(VoicekitCallbackInfo.this);
}
});
}
}
public class b extends BaseRecognizeListener {
public b() {
}
@Override
public void onCancel() {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onCancel] call");
}
@Override
public void onError(int i, String str) {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onError] call");
}
@Override
public void onInit() {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onInit] call");
}
@Override
public void onPartialResult(VoiceKitMessage voiceKitMessage) {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onPartialResult] call");
}
@Override
public void onRecordEnd() {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onRecordEnd] call");
}
@Override
public void onRecordStart() {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onRecordStart] call");
}
@Override
public void onResult(VoiceKitMessage voiceKitMessage) {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onResult] call");
}
@Override
public void onSpeechEnd() {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onSpeechEnd] call");
}
@Override
public void onSpeechStart() {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onSpeechStart] call");
}
@Override
public void onUploadWakeupResult(int i) {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onUploadWakeupResult] call");
}
@Override
public void onVolumeGet(int i) {
KitLog.error("VoiceKitSdkImpl", "unexpected method [onVolumeGet] call");
}
}
public static class c implements TtsAbilityInterface.Callback {
public String a;
public c(String str, C0024a c0024a) {
this(str);
}
@Override
public void onCanceled(Bundle bundle) {
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
KitLog.warn("VoiceKitSdkImpl", "ignore onCanceled for utteranceId=" + KitLog.getSecurityString(BaseUtils.getStringFromBundle(bundle, "utteranceId")));
}
@Override
public void onDownloadTtsToneEngine(Bundle bundle) {
bundle.putString("callbackMethod", "onDownloadTtsToneEngine");
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onFormatChange(String str, Bundle bundle) {
bundle.putString("callbackMethod", "onFormatChange");
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onInit() {
Bundle bundle = new Bundle();
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
bundle.putString("callbackMethod", "onInit");
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onPhonemeFinish(Bundle bundle, String str) {
bundle.putString("callbackMethod", "onPhonemeFinish");
bundle.putString("extend", str);
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onPhonemeProgress(Bundle bundle, String str, int i, String str2) {
bundle.putString("callbackMethod", "onPhonemeProgress");
bundle.putString(WakeupIntent.EXT_DATA, str);
bundle.putInt("type", i);
bundle.putString("extend", str2);
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onTextToSpeak(Bundle bundle) {
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.ASSISTANT_COMMANDER, PlatformMsg.Ctl.ABILITY_CONNECTOR_SEND_TXT_TO_TTS, bundle);
}
@Override
public void onTtsDataFinish(Bundle bundle) {
bundle.putString("callbackMethod", "onTtsDataFinish");
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onTtsDataProgress(Bundle bundle, byte[] bArr, int i) {
bundle.putString("callbackMethod", "onTtsDataProgress");
bundle.putInt("mimeType", i);
bundle.putByteArray("audioData", bArr);
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onTtsError(int i, String str, Bundle bundle) {
if (bundle == null) {
bundle = new Bundle();
}
bundle.putString("callbackMethod", "onTtsError");
bundle.putInt("errorCode", i);
bundle.putString(HttpConfig.ERROR_MESSAGE_NAME, str);
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onTtsFinish(Bundle bundle) {
bundle.putString("callbackMethod", "onTtsFinish");
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onTtsInterrupted(Bundle bundle) {
bundle.putString("callbackMethod", "onTtsFinish");
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onTtsProgressChanged(Bundle bundle, int i) {
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
bundle.putString("callbackMethod", "onTtsProgressChanged");
bundle.putInt("progress", i);
FrameworkBus.msg().sendMsg(PlatformModule.ABILITY_CONNECTOR, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_TTS, bundle);
}
@Override
public void onTtsStart(Bundle bundle) {
bundle.putString("callbackMethod", "onTtsStart");
bundle.putString(RecognizerIntent.EXT_CLIENT_ID, this.a);
MessageSenderInterface msg = FrameworkBus.msg();
PlatformModule platformModule = PlatformModule.ABILITY_CONNECTOR;
msg.sendMsg(platformModule, PlatformModule.NORTH_INTERFACE, PlatformMsg.Ctl.ABILITY_CONNECTOR_NORTH_TTS_START, bundle);
FrameworkBus.msg().sendMsg(platformModule, PlatformModule.ASSISTANT_COMMANDER, PlatformMsg.Ctl.ABILITY_CONNECTOR_NORTH_TTS_START, bundle);
}
public c(String str) {
this.a = str;
}
}
public a(NorthInterfaceCallBack northInterfaceCallBack) {
this.a = northInterfaceCallBack;
VoiceKitSdk.isSdkCreated = true;
}
public static ArrayList i(Intent intent) {
return SecureIntentUtil.getSecureIntentParcelableArrayList(intent, Constants.UserData.IDS_SYNC_PROPERTIES);
}
public static void l(Bundle bundle, VoicekitCallback voicekitCallback) {
voicekitCallback.onCallback(new VoicekitCallbackInfo(-1, bundle));
}
public static void m(JSONArray jSONArray) {
KitLog.info("VoiceKitSdkImpl", "uploadContactCount:" + jSONArray.length());
OperationReportUtils.getInstance().getContactUploadInfoRecord().setContactNum(jSONArray.length()).setUploadNum(jSONArray.length());
}
public static boolean s(Intent intent) {
return intent.hasExtra(Constants.UserData.IDS_SYNC_PROPERTIES);
}
public static Boolean u(Intent intent) {
return Boolean.valueOf(intent.hasExtra(Constants.UserData.FREE_WAKEUP_SWITCH));
}
@Override
public void cancelAsrListening() {
KitLog.info("VoiceKitSdkImpl", "cancelAsrListening");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.CANCEL_ASR_LISTENING, null);
}
@Override
public void cancelRecognize() {
KitLog.debug("VoiceKitSdkImpl", "cancelRecognize", new Object[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.CANCEL_RECOGNIZE, null);
}
@Override
public void cancelSpeak() {
KitLog.info("VoiceKitSdkImpl", "cancelSpeak");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.CANCEL_SPEAK, null);
}
@Override
public Bundle checkFeatures(String str, Intent intent) {
KitLog.info("VoiceKitSdkImpl", ParamsConstants.METHOD_CHECK_FEATURES);
if (str != null && intent != null) {
return CheckFeatureUtil.checkFeatures(str, intent.getExtras());
}
KitLog.warn("VoiceKitSdkImpl", "moduleName or params is null");
return new Bundle();
}
@Override
public void deleteData(Bundle bundle, BaseDataServiceListener baseDataServiceListener) {
if (!o(bundle)) {
KitLog.error("VoiceKitSdkImpl", "deleteData params is not completed");
if (baseDataServiceListener != null) {
baseDataServiceListener.onResult(1, "deleteData params is not completed");
return;
}
return;
}
String secureBundleString = SecureIntentUtil.getSecureBundleString(bundle, DataServiceInterface.DATA_METHOD, "");
if (TextUtils.equals(secureBundleString, DataServiceInterface.DATA_METHOD_ENTITES)) {
ModuleInstanceFactory.Ability.dataService().deleteData("ids_entities_delete", bundle, baseDataServiceListener);
return;
}
if (TextUtils.equals(secureBundleString, "databus")) {
ModuleInstanceFactory.Ability.dataService().deleteData("ids_databus_delete", bundle, baseDataServiceListener);
return;
}
if (TextUtils.equals(secureBundleString, DataServiceInterface.DATA_METHOD_COMMN_KV)) {
ModuleInstanceFactory.Ability.dataService().deleteData(DataServiceInterface.DATA_METHOD_COMMN_KV, bundle, baseDataServiceListener);
return;
}
KitLog.error("VoiceKitSdkImpl", "deleteEntitiesData method is not true");
if (baseDataServiceListener != null) {
baseDataServiceListener.onResult(1, "deleteEntitiesData method is not true");
}
}
@Override
public void dispatchDsMessage(Intent intent, VoicekitCallback voicekitCallback) {
KitLog.debug("VoiceKitSdkImpl", "dispatchDsMessage", new Object[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.DISPATCH_DS_MESSAGE, new cgb(intent, voicekitCallback));
}
@Override
public void downloadTtsToneEngine(Intent intent) {
KitLog.debug("VoiceKitSdkImpl", "downloadTtsToneEngine", new Object[0]);
if (intent == null) {
KitLog.warn("VoiceKitSdkImpl", "intent is null");
return;
}
int[] secureIntentIntArray = SecureIntentUtil.getSecureIntentIntArray(intent, Constants.Tts.TONE_COLOR);
Intent intent2 = new Intent();
intent2.putExtra(Constants.Tts.TONE_COLOR, secureIntentIntArray);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.DOWNLOAD_TTS_TONE_ENGINE, intent2);
}
@Override
public String getHiVoiceAddress() {
return ModuleInstanceFactory.Ability.recognize().getHiVoiceAddress();
}
@Override
public String getVersionInfo(String str) {
KitLog.debug("VoiceKitSdkImpl", "getVersionInfo", new Object[0]);
if (TextUtils.equals(str, "nlu")) {
return String.valueOf(PluginUtil.getHiAiPluginVersionCode(IAssistantConfig.getInstance().getAppContext(), "nlu"));
}
if (TextUtils.equals(str, "asr")) {
return String.valueOf(PluginUtil.getHiAiPluginVersionCode(IAssistantConfig.getInstance().getAppContext(), "asr"));
}
if (TextUtils.equals(str, PluginUtil.DM_PLUGIN)) {
return String.valueOf(PluginUtil.getHiAiPluginVersionCode(IAssistantConfig.getInstance().getAppContext(), PluginUtil.DM_PLUGIN));
}
KitLog.error("VoiceKitSdkImpl", "getVersionInfo param error");
return "0";
}
@Override
public String getVisibleFullInfo() {
KitLog.info("VoiceKitSdkImpl", "getVisibleFullInfo");
return ModuleInstanceFactory.Ability.visible().getCachedVisibleFullInfo();
}
public BaseRecognizeListener h() {
return this.b;
}
@Override
public void initAsrEngine(Intent intent, BaseAsrListener baseAsrListener) {
KitLog.info("VoiceKitSdkImpl", "initAsrEngine");
this.e = baseAsrListener;
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.INIT_ASR_ENGINE, intent);
}
@Override
public void initRecognizeEngine(Intent intent, BaseRecognizeListener baseRecognizeListener) {
KitLog.info("VoiceKitSdkImpl", "initRecognizeEngine");
this.b = baseRecognizeListener;
n(j(intent, RecognizerIntent.EXT_INTENT_FOR_SDK).orElse(new String[0]));
r(j(intent, RecognizerIntent.EXT_EVENT_FOR_OTHERS).orElse(new String[0]));
ModuleInstanceFactory.State.platformState().getSessionState().setPrivacyAgreement(true);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.INIT_RECOGNIZE_ENGINE, intent);
ModuleInstanceFactory.Ability.decisionService().initDecisionServiceEngine();
if (IAssistantConfig.getInstance().sdkConfig().isNeedDis()) {
ModuleInstanceFactory.Ability.disService().initDisServiceEngine();
}
}
@Override
public void initTtsEngine(Intent intent, BaseTtsListener baseTtsListener) {
KitLog.debug("VoiceKitSdkImpl", "initTtsEngine", new Object[0]);
if (baseTtsListener == null) {
KitLog.warn("VoiceKitSdkImpl", "listener is null");
return;
}
if (intent == null) {
KitLog.warn("VoiceKitSdkImpl", "intent is null");
baseTtsListener.onTtsError(1, "intent is null", "");
return;
}
if (SecureIntentUtil.getSecureIntentInt(intent, "ttsMode", -1) != 3) {
this.g.put(ClientIdConstant.NORTH_INTERFACE, baseTtsListener);
ModuleInstanceFactory.Ability.tts().registerCallback(p(ClientIdConstant.NORTH_INTERFACE), ClientIdConstant.NORTH_INTERFACE);
} else {
this.g.put(ClientIdConstant.NORTH_INTERFACE_TTS_SDK_CLOUD, baseTtsListener);
ModuleInstanceFactory.Ability.tts().registerCallback(p(ClientIdConstant.NORTH_INTERFACE_TTS_SDK_CLOUD), ClientIdConstant.NORTH_INTERFACE_TTS_SDK_CLOUD);
}
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.INIT_TTS_ENGINE, intent);
}
@Override
public void initVisible(Bundle bundle, List list, VisibleKitListener visibleKitListener) {
KitLog.info("VoiceKitSdkImpl", "initVisible");
this.f = visibleKitListener;
if (bundle == null) {
bundle = new Bundle();
}
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.INIT_VISIBLE, new bvb(bundle, list));
}
@Override
public void initWakeupEngine(Intent intent, BaseWakeupListener baseWakeupListener) {
KitLog.info("VoiceKitSdkImpl", "initWakeupEngine");
this.d = baseWakeupListener;
FrameworkBus.msg().sendMsg(PlatformModule.NORTH_INTERFACE, PlatformModule.WAKE_UP, PlatformMsg.CtlExt.NORTH_INTERFACE_INIT_WAKEUP, intent);
}
@Override
public boolean isCloudRecognizeAvailable() {
KitLog.info("VoiceKitSdkImpl", "isCloudRecognizeAvailable");
return ModuleInstanceFactory.Commander.networkCheckProvider().isHiVoiceAvailable();
}
@Override
public boolean isRecognizing() {
return FrameworkBus.flowState().isRecognizing(InteractionIdInfo.build(BusinessFlowId.getInstance().getSessionId(), BusinessFlowId.getInstance().getInteractionId()));
}
@Override
public boolean isSpeaking() {
KitLog.debug("VoiceKitSdkImpl", "isSpeaking", new Object[0]);
hnb hnbVar = new hnb(new CountDownLatch(1), new AtomicBoolean(false));
try {
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.IS_SPEAKING, hnbVar);
hnbVar.a().await(500L, TimeUnit.MILLISECONDS);
} catch (InterruptedException unused) {
KitLog.error("VoiceKitSdkImpl", "isSpeaking error");
}
return hnbVar.b().get();
}
@Override
public boolean isTtsToneEngineExist(Intent intent) {
KitLog.debug("VoiceKitSdkImpl", "isTtsToneEngineExist", new Object[0]);
if (intent == null) {
KitLog.warn("VoiceKitSdkImpl", "intent is null");
return false;
}
int secureIntentInt = SecureIntentUtil.getSecureIntentInt(intent, Constants.Tts.TONE_COLOR, -1);
KitLog.debug("VoiceKitSdkImpl", "isTtsToneEngineExist toneType {}", Integer.valueOf(secureIntentInt));
zrb zrbVar = new zrb(new CountDownLatch(1), new AtomicBoolean(false), secureIntentInt);
try {
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.IS_TTS_TONE_ENGINE_EXIST, zrbVar);
zrbVar.a().await(500L, TimeUnit.MILLISECONDS);
} catch (InterruptedException unused) {
KitLog.error("VoiceKitSdkImpl", "isTtsToneEngineExist error");
}
return zrbVar.b().get();
}
public final Optional<String[]> j(Intent intent, String str) {
return Optional.ofNullable(SecureIntentUtil.getSecureIntentStringArray(intent, str));
}
public Optional<BaseTtsListener> k(String str) {
return TextUtils.isEmpty(str) ? Optional.empty() : Optional.ofNullable(this.g.get(str));
}
public final void n(String[] strArr) {
this.a.onIntentionHandler(NorthInterfaceCallBack.IntentionHandlerCode.INTENT_FOR_SDK, strArr);
}
public final boolean o(Bundle bundle) {
if (bundle == null) {
return false;
}
return (TextUtils.isEmpty(SecureIntentUtil.getSecureBundleString(bundle, "dataType", "")) || TextUtils.isEmpty(SecureIntentUtil.getSecureBundleString(bundle, DataServiceInterface.UPLOAD_METHOD, ""))) ? false : true;
}
public final TtsAbilityInterface.Callback p(String str) {
return new c(str, null);
}
@Override
public void postMessage(Intent intent, VoicekitCallback voicekitCallback) {
KitLog.debug("VoiceKitSdkImpl", "postMessage", new Object[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.POST_MESSAGE, new cgb(intent, voicekitCallback));
}
@Override
public void prepareHttpsConnect(Intent intent) {
KitLog.info("VoiceKitSdkImpl", "prepareHttpsConnect");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.PREPARE_HTTPS_CONNECT, intent);
}
public BaseUiListener q() {
return this.c;
}
@Override
public Optional<Bundle> queryData(Bundle bundle) {
String secureBundleString = SecureIntentUtil.getSecureBundleString(bundle, DataServiceInterface.DATA_METHOD, "");
if (TextUtils.equals(secureBundleString, DataServiceInterface.DATA_METHOD_ENTITES)) {
return ModuleInstanceFactory.Ability.dataService().queryData("ids_entities_query", bundle);
}
if (TextUtils.equals(secureBundleString, "databus")) {
return ModuleInstanceFactory.Ability.dataService().queryData("ids_databus_query", bundle);
}
if (TextUtils.equals(secureBundleString, DataServiceInterface.DATA_METHOD_COMMN_KV)) {
return ModuleInstanceFactory.Ability.dataService().queryData(DataServiceInterface.DATA_METHOD_COMMN_KV, bundle);
}
KitLog.error("VoiceKitSdkImpl", "queryEntitiesData method is not true");
return Optional.empty();
}
public final void r(String[] strArr) {
this.a.onIntentionHandler(NorthInterfaceCallBack.IntentionHandlerCode.EVENT_FOR_OTHERS, strArr);
}
@Override
public void recycleWakeupEngine() {
KitLog.info("VoiceKitSdkImpl", "recycleWakeupEngine");
FrameworkBus.msg().sendMsg(PlatformModule.NORTH_INTERFACE, PlatformModule.WAKE_UP, PlatformMsg.Ctl.NORTH_INTERFACE_RECYCLE_WAKEUP);
}
@Override
public void registerUiListener(BaseUiListener baseUiListener) {
KitLog.info("VoiceKitSdkImpl", "registerUiListener");
this.c = baseUiListener;
}
@Override
public void release() {
KitLog.info("VoiceKitSdkImpl", "release");
OfflineReportManager.getInstance().reset();
n(new String[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.RELEASE_PLATFORM, null);
VoiceKitSdk.isSdkCreated = false;
OperationReportUtils.getInstance().getKitLifeCycleRecord().setEndTime(System.currentTimeMillis());
OperationReportUtils.getInstance().reportVoiceKitRelease("0");
OperationReportUtils.getInstance().reportKitLifeCycleRecord();
HiAnalyticsReport.getInstance().onReport();
try {
APMS.getInstance().onReport();
APMS.getInstance().enableCollectionByUser(false);
} catch (Exception unused) {
KitLog.error("VoiceKitSdkImpl", "APMS execute error");
}
this.g.clear();
}
@Override
public void releaseAsrEngine() {
KitLog.info("VoiceKitSdkImpl", "releaseAsrEngine");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.RELEASE_ASR_ENGINE, null);
}
@Override
public void releaseRecognizeEngine() {
KitLog.info("VoiceKitSdkImpl", "releaseRecognizeEngine");
n(new String[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.RELEASE_RECOGNIZE_ENGINE, null);
CommandActionContextUtil.clearAllContext();
}
@Override
public void releaseTtsEngine(Intent intent) {
KitLog.info("VoiceKitSdkImpl", "releaseTtsEngine");
NorthInterfaceCallBack northInterfaceCallBack = this.a;
NorthInterfaceCallBack.CommanderCode commanderCode = NorthInterfaceCallBack.CommanderCode.RELEASE_TTS_ENGINE;
if (intent == null) {
intent = new Intent();
}
northInterfaceCallBack.onCommander(commanderCode, intent);
}
@Override
public void releaseVisible() {
KitLog.info("VoiceKitSdkImpl", "releaseVisible");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.RELEASE_VISIBLE, null);
}
@Override
public void renewSession(Intent intent) {
KitLog.info("VoiceKitSdkImpl", "renewSession");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.RENEW_SESSION, intent);
}
@Override
public void startAsrListening(Intent intent) {
KitLog.info("VoiceKitSdkImpl", "startAsrListening");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.START_ASR_LISTENING, intent);
}
@Override
public void startRecognize(Intent intent) {
KitLog.info("VoiceKitSdkImpl", MessageConstants.MessageName.MSG_NAME_START_RECOGNIZE);
if (intent != null && !intent.hasExtra(RecognizerIntent.EXT_SELF_RECORDING)) {
intent.putExtra(RecognizerIntent.EXT_SELF_RECORDING, false);
}
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.START_RECOGNIZE, CommandActionContextUtil.getActionRecognizeContextPara(intent));
}
@Override
public void startRecognizeOnfullDuplexMod(Intent intent) {
KitLog.info("VoiceKitSdkImpl", "startFullDuplexRecognize");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.START_FULLDUPLEX_RECOGNIZE, CommandActionContextUtil.getActionRecognizeContextPara(intent));
}
@Override
public void startVisible(Bundle bundle) {
KitLog.info("VoiceKitSdkImpl", "startVisible");
NorthInterfaceCallBack northInterfaceCallBack = this.a;
NorthInterfaceCallBack.CommanderCode commanderCode = NorthInterfaceCallBack.CommanderCode.START_VISIBLE;
if (bundle == null) {
bundle = new Bundle();
}
northInterfaceCallBack.onCommander(commanderCode, bundle);
}
@Override
public void stopAsrListening() {
KitLog.info("VoiceKitSdkImpl", "stopAsrListening");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.STOP_ASR_LISTENING, null);
}
@Override
public void stopBusiness(Intent intent) {
KitLog.info("VoiceKitSdkImpl", "stopBusiness");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.STOP_BUSINESS, intent);
}
@Override
public void stopRecognize(Intent intent) {
KitLog.debug("VoiceKitSdkImpl", "stopRecognize", new Object[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.STOP_RECOGNIZE, intent);
}
@Override
public void stopSpeak() {
KitLog.debug("VoiceKitSdkImpl", "stopSpeak", new Object[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.STOP_SPEAK, null);
}
@Override
public void stopVisible() {
KitLog.info("VoiceKitSdkImpl", "stopVisible");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.STOP_VISIBLE, null);
}
@Override
public void submitIntentionAction(VoiceKitMessage voiceKitMessage) {
KitLog.info("VoiceKitSdkImpl", "submitIntentionAction");
this.a.onIntentionExecutor(NorthInterfaceCallBack.IntentionExecutorCode.SUBMIT_INTENTION_ACTION, voiceKitMessage);
}
@Override
public void switchRealMachineTestMode(boolean z, Bundle bundle, RealMachineTestListener realMachineTestListener) {
KitLog.debug("VoiceKitSdkImpl", "switchRealMachineTestMode", new Object[0]);
ModuleInstanceFactory.Ability.recognize().switchRealMachineTestMode(z, bundle, realMachineTestListener);
}
@Override
public void syncData(Bundle bundle, BaseDataServiceListener baseDataServiceListener) {
if (TextUtils.equals(SecureIntentUtil.getSecureBundleString(bundle, DataServiceInterface.DATA_METHOD, ""), DataServiceInterface.DATA_METHOD_COMMN_KV)) {
ModuleInstanceFactory.Ability.dataService().syncData(bundle, baseDataServiceListener);
} else {
KitLog.error("VoiceKitSdkImpl", "syncData method invalid");
}
}
public BaseWakeupListener t() {
return this.d;
}
@Override
public void textToSpeak(String str, Intent intent) {
KitLog.info("VoiceKitSdkImpl", "textToSpeak");
if (intent == null) {
intent = new Intent();
}
if (SecureIntentUtil.getSecureIntentInt(intent, "ttsMode", -1) != 3) {
intent.putExtra(RecognizerIntent.EXT_CLIENT_ID, ClientIdConstant.NORTH_INTERFACE);
} else {
intent.putExtra(RecognizerIntent.EXT_CLIENT_ID, ClientIdConstant.NORTH_INTERFACE_TTS_SDK_CLOUD);
}
intent.putExtra(BaseConstants.INTENT_SPEAK_TEXT_CONTENT, str);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.TEXT_TO_SPEAK, intent);
}
@Override
public void updateData(Bundle bundle, BaseDataServiceListener baseDataServiceListener) {
String stringFromBundle = BaseUtils.getStringFromBundle(bundle, DataServiceInterface.UPLOAD_METHOD);
String stringFromBundle2 = BaseUtils.getStringFromBundle(bundle, "dataType");
if (TextUtils.equals("cloud", stringFromBundle) && TextUtils.equals("entities_contacts", stringFromBundle2)) {
dwb.a(BaseUtils.getStringFromBundle(bundle, DataServiceInterface.DATA_VALUES)).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
a.m((JSONArray) obj);
}
});
}
String secureBundleString = SecureIntentUtil.getSecureBundleString(bundle, DataServiceInterface.DATA_METHOD, "");
if (TextUtils.equals(secureBundleString, DataServiceInterface.DATA_METHOD_ENTITES)) {
ModuleInstanceFactory.Ability.dataService().updateData("ids_entities_update", bundle, baseDataServiceListener);
return;
}
if (TextUtils.equals(secureBundleString, "databus")) {
ModuleInstanceFactory.Ability.dataService().updateData("ids_databus_update", bundle, baseDataServiceListener);
return;
}
if (TextUtils.equals(secureBundleString, DataServiceInterface.DATA_METHOD_COMMN_KV)) {
ModuleInstanceFactory.Ability.dataService().updateData(DataServiceInterface.DATA_METHOD_COMMN_KV, bundle, baseDataServiceListener);
return;
}
KitLog.error("VoiceKitSdkImpl", "updateEntitiesData method is not true");
if (baseDataServiceListener != null) {
baseDataServiceListener.onResult(1, "updateEntitiesData method is not true");
}
}
@Override
public void updateEvent(String str) {
KitLog.info("VoiceKitSdkImpl", "updateEvent");
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.UPDATE_EVENT, str);
}
@Override
public void updateSwitch(Intent intent) {
KitLog.debug("VoiceKitSdkImpl", "updateSwitch", new Object[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.UPDATE_SWITCH, intent);
if (((Boolean) Optional.ofNullable(intent).map(new Function() {
@Override
public final Object apply(Object obj) {
Boolean u;
u = a.u((Intent) obj);
return u;
}
}).orElse(Boolean.FALSE)).booleanValue()) {
FrameworkBus.msg().sendMsg(PlatformModule.NORTH_INTERFACE, PlatformModule.WAKE_UP, PlatformMsg.Ctl.NORTH_INTERFACE_UPDATE_FREE_WAKEUP_SWITCH, intent);
}
try {
ArrayList arrayList = (ArrayList) Optional.ofNullable(intent).filter(new Predicate() {
@Override
public final boolean test(Object obj) {
boolean s;
s = a.s((Intent) obj);
return s;
}
}).map(new Function() {
@Override
public final Object apply(Object obj) {
ArrayList i;
i = a.i((Intent) obj);
return i;
}
}).orElse(new ArrayList());
if (arrayList.isEmpty()) {
KitLog.debug("VoiceKitSdkImpl", "empty list", new Object[0]);
return;
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
Object next = it.next();
if (next instanceof Map) {
ModuleInstanceFactory.Ability.dataService().setSyncProperty((Map) next);
}
}
} catch (ArrayIndexOutOfBoundsException unused) {
KitLog.error("VoiceKitSdkImpl", "failed to get lists from params");
}
}
@Override
public void updateUserData(Intent intent, String str, VoicekitCallback voicekitCallback) {
KitLog.info("VoiceKitSdkImpl", "updateUserData");
if (dwb.d(intent, str)) {
Bundle bundle = new Bundle(SecureIntentUtil.getSecureIntentExtras(intent));
bundle.putString(DataServiceInterface.DATA_VALUES, str);
ModuleInstanceFactory.Ability.dataService().updateData("ids_entities_update", bundle, new C0024a(voicekitCallback));
} else {
final Bundle bundle2 = new Bundle();
bundle2.putString("operationResponse", String.format(Locale.ROOT, "{\"errorCode\":\"%s\",\"errorMsg\":\"%s\"}", -1, "the params is invalid"));
Optional.ofNullable(voicekitCallback).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
a.l(bundle2, (VoicekitCallback) obj);
}
});
}
}
@Override
public void updateVoiceContext(String str) {
KitLog.debug("VoiceKitSdkImpl", "updateVoiceContext", new Object[0]);
VoiceContext voiceContext = (VoiceContext) GsonUtils.toBean(str, VoiceContext.class);
Session session = voiceContext != null ? voiceContext.getSession() : null;
NorthInterfaceCallBack northInterfaceCallBack = this.a;
NorthInterfaceCallBack.CommanderCode commanderCode = NorthInterfaceCallBack.CommanderCode.UPDATE_VOICE_CONTEXT;
String str2 = str;
if (session != null) {
str2 = AssistantMessage.builder(str, session).build();
}
northInterfaceCallBack.onCommander(commanderCode, str2);
}
@Override
public void updateVoiceEvent(String str) {
KitLog.debug("VoiceKitSdkImpl", MessageConstants.MessageName.MSG_NAME_UPDATE_VOICE_EVENT, new Object[0]);
this.a.onCommander(NorthInterfaceCallBack.CommanderCode.UPDATE_VOICE_EVENT, str);
}
@Override
public void uploadData2Obs(String str, Map<String, String> map, String str2, VoicekitCallback voicekitCallback) {
KitLog.debug("VoiceKitSdkImpl", HiVoiceConstants.EventName.EVENT_UPLOAD_TO_OBS, new Object[0]);
ModuleInstanceFactory.Ability.obs().uploadData2Obs(str, map, str2, voicekitCallback);
}
@Override
public void uploadWakeupWords(String str, String str2) {
KitLog.debug("VoiceKitSdkImpl", "uploadWakeupWords", new Object[0]);
ModuleInstanceFactory.Ability.recognize().uploadWakeupWords(str, str2);
}
public VisibleKitListener v() {
return this.f;
}
public BaseAsrListener w() {
return this.e;
}
@Override
public void writeAsrAudio(byte[] bArr) {
ModuleInstanceFactory.Ability.asr().writeAsrAudio(bArr);
}
@Override
public void writeAudio(byte[] bArr) {
this.a.onDataAcquisition(NorthInterfaceCallBack.DataAcquisitionCode.WRITE_AUDIO, bArr);
}
@Override
public void writeWakeupAudio(byte[] bArr, int i) {
AudioDataMessage audioDataMessage = new AudioDataMessage();
audioDataMessage.setBuffers(bArr);
audioDataMessage.setSize(bArr.length);
audioDataMessage.setType(i);
FrameworkBus.msg().sendMsg(PlatformModule.NORTH_INTERFACE, PlatformModule.WAKE_UP, PlatformMsg.Data.NORTH_INTERFACE_WRITE_WAKEUP_AUDIO, audioDataMessage);
}
public final BaseRecognizeListener x() {
return new b();
}
@Override
public void uploadWakeupWords(String str, String str2, VoicekitCallback voicekitCallback) {
KitLog.debug("VoiceKitSdkImpl", "uploadWakeupWords", new Object[0]);
ModuleInstanceFactory.Ability.upload().uploadWakeupWords(str, str2, voicekitCallback);
}
}