正在查看: Petal Maps v4.7.0.310001 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Petal Maps v4.7.0.310001 应用的 a.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.huawei.hiassistant.voice.abilityconnector.tts;
import android.content.Context;
import android.content.Intent;
import android.media.AudioManager;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import com.huawei.hiai.tts.constants.BaseConstants;
import com.huawei.hiassistant.platform.base.VoiceKitSdkContext;
import com.huawei.hiassistant.platform.base.bean.util.GsonUtils;
import com.huawei.hiassistant.platform.base.northinterface.Constants;
import com.huawei.hiassistant.platform.base.northinterface.recognize.RecognizerIntent;
import com.huawei.hiassistant.platform.base.report.OperationReportUtils;
import com.huawei.hiassistant.platform.base.report.fault.TtsFaultReporter;
import com.huawei.hiassistant.platform.base.util.DeviceUtil;
import com.huawei.hiassistant.platform.base.util.KitLog;
import com.huawei.hiassistant.platform.base.util.SecureIntentUtil;
import com.huawei.hiassistant.platform.base.util.WhiteboxCipher;
import com.huawei.hiassistant.voice.abilityconnector.tts.BaseTtsAbility;
import com.huawei.hiassistant.voice.abilityconnector.tts.TtsListenerInterface;
import com.huawei.hiassistant.voice.common.util.CommonDataUtil;
import com.huawei.kit.tts.interfaces.IHwTTsCallback;
import com.huawei.kit.tts.sdk.TTSCloudManager;
import java.util.HashMap;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
public class a extends BaseTtsAbility {
public Context a;
public TTSCloudManager c;
public TtsListenerInterface d;
public AudioManager g;
public BaseTtsAbility.a h;
public HashMap<String, Integer> b = new HashMap<>();
public AtomicBoolean e = new AtomicBoolean(false);
public AtomicBoolean f = new AtomicBoolean(false);
public a(Context context, TtsListenerInterface ttsListenerInterface) {
KitLog.debug("CloudTtsAbility", "CloudTtsAbility", new Object[0]);
if (context == null) {
KitLog.warn("CloudTtsAbility", "context is null");
return;
}
this.a = context;
this.d = ttsListenerInterface;
TtsFaultReporter.getInstance().getFaultRecord().setEngineType(3);
}
@Override
public void cancel() {
KitLog.info("CloudTtsAbility", "enter cancel");
TTSCloudManager tTSCloudManager = this.c;
if (tTSCloudManager != null) {
tTSCloudManager.doSpeakStop();
}
abandonAudioFocus(this.g, this.h);
}
@Override
public void destroy() {
KitLog.debug("CloudTtsAbility", "enter destroy", new Object[0]);
this.e.set(false);
this.f.set(false);
abandonAudioFocus(this.g, this.h);
this.h = null;
TTSCloudManager tTSCloudManager = this.c;
if (tTSCloudManager != null) {
tTSCloudManager.doRelease();
}
}
@Override
public void initEngine(Intent intent) {
super.initEngine(intent);
KitLog.info("CloudTtsAbility", "enter initEngine");
if (this.d == null) {
KitLog.warn("CloudTtsAbility", "mTtsListener is null");
return;
}
this.f.set(false);
this.h = new BaseTtsAbility.a();
Object systemService = this.a.getSystemService("audio");
if (systemService instanceof AudioManager) {
this.g = (AudioManager) systemService;
}
this.c = new TTSCloudManager(this.a, new b());
KitLog.info("CloudTtsAbility", "ttsCloud version:" + this.c.getVersion());
int doInit = this.c.doInit(m(intent));
this.e.set(doInit == 100);
KitLog.debug("CloudTtsAbility", "initEngine result :{},errorCode {}", Boolean.valueOf(this.e.get()), Integer.valueOf(doInit));
this.f.set(true);
this.d.onInit(1 ^ (this.e.get() ? 1 : 0));
}
@Override
public boolean isInitFinish() {
return this.f.get();
}
@Override
public boolean isInitSuccess() {
return this.e.get();
}
@Override
public boolean isSpeaking() {
KitLog.debug("CloudTtsAbility", "enter isSpeaking", new Object[0]);
if (!this.e.get()) {
KitLog.warn("CloudTtsAbility", "not init");
return false;
}
TTSCloudManager tTSCloudManager = this.c;
if (tTSCloudManager != null) {
return tTSCloudManager.isSpeaking();
}
return false;
}
@Override
public boolean isTtsBind() {
return true;
}
@Override
public boolean isTtsToneEngineExist(int i) {
return true;
}
public final Intent m(Intent intent) {
Intent intent2 = new Intent();
String language = getLanguage(intent);
TtsFaultReporter.getInstance().getFaultRecord().setInitLanguage(language);
if (TextUtils.isEmpty(language)) {
KitLog.debug("CloudTtsAbility", "language is empty", new Object[0]);
} else {
KitLog.debug("CloudTtsAbility", "language is {}", language);
intent2.putExtra("language", language);
}
String decrypt4Aes = WhiteboxCipher.decrypt4Aes("MVoRwwG8BDEzFdlatPp7Ow==gDxLTq3x1LpDF9t3BrVZCOoZgupVapVGQEjOKadTpfQ35-v5RB3o0CVopguQ7n-z");
String decrypt4Aes2 = WhiteboxCipher.decrypt4Aes("I7kTC399wkVtOGYT1T7_mA==BugPf_w-3QEbfInn1KC52a3ouICn4w7LeLbEyOt9UyXaUH0Fa7iSw0EkBJ9ctGlF");
String str = (String) VoiceKitSdkContext.getInstance().get(RecognizerIntent.EXT_AUTH_AK, String.class).orElse("");
String str2 = (String) VoiceKitSdkContext.getInstance().get(RecognizerIntent.EXT_AUTH_SK, String.class).orElse("");
if (!TextUtils.isEmpty(str)) {
decrypt4Aes = str;
}
intent2.putExtra(BaseConstants.INTENT_AK, decrypt4Aes);
if (!TextUtils.isEmpty(str2)) {
decrypt4Aes2 = str2;
}
intent2.putExtra("sk", decrypt4Aes2);
intent2.putExtra("deviceId", DeviceUtil.getCompatUdid());
intent2.putExtra("speaker", CommonDataUtil.getToneColor());
intent2.putExtra("osVersion", Build.VERSION.RELEASE);
intent2.putExtra("romVersion", Build.DISPLAY);
String deviceCategory = getDeviceCategory();
if (TextUtils.isEmpty(deviceCategory)) {
intent2.putExtra("deviceType", getDeviceType());
} else {
intent2.putExtra("deviceCategory", deviceCategory);
}
String asUrl = getAsUrl(this.a);
if (TextUtils.isEmpty(asUrl)) {
KitLog.warn("CloudTtsAbility", "asUrl is empty");
} else {
intent2.putExtra("asUrl", asUrl);
}
intent2.putExtra("appName", this.a.getPackageName());
SecureIntentUtil.transferBooleanExtra(intent, intent2, "supportPki", true);
SecureIntentUtil.transferIntExtra(intent, intent2, "requestConnectTime");
return intent2;
}
public final Intent n(Intent intent, String str, int i) {
Intent intent2 = new Intent();
intent2.putExtra("session", GsonUtils.toJson(CommonDataUtil.getSessionInstanceWithInitialData()));
String secureIntentString = SecureIntentUtil.getSecureIntentString(intent, BaseConstants.INTENT_TEXTTYPE);
KitLog.info("CloudTtsAbility", "currentStreamType is " + i + "; and textType is " + secureIntentString);
intent2.putExtra("streamType", i);
if (!TextUtils.isEmpty(secureIntentString)) {
intent2.putExtra(BaseConstants.INTENT_TEXTTYPE, secureIntentString);
}
String language = getLanguage(intent);
TtsFaultReporter.getInstance().getFaultRecord().setSpeakLanguage(language);
if (TextUtils.isEmpty(language)) {
KitLog.warn("CloudTtsAbility", "language is empty");
} else {
KitLog.info("CloudTtsAbility", "language is " + language);
intent2.putExtra("language", language);
}
intent2.putExtra("utteranceId", str);
int secureIntentInt = SecureIntentUtil.getSecureIntentInt(intent, "synthesisMode", 0);
intent2.putExtra("synthesisMode", secureIntentInt);
SecureIntentUtil.transferIntExtra(intent, intent2, "audioFormat");
if (getAudioFormat() != -1 && !intent2.hasExtra("audioFormat") && secureIntentInt != 1) {
intent2.putExtra("audioFormat", getAudioFormat());
}
OperationReportUtils.getInstance().getTtsRecord().setToneColor(Constants.Tts.DEFAULT_TONE_COLOR);
if (intent.hasExtra(Constants.Tts.TONE_COLOR)) {
int secureIntentInt2 = SecureIntentUtil.getSecureIntentInt(intent, Constants.Tts.TONE_COLOR, -1);
KitLog.info("CloudTtsAbility", "toneColor:" + secureIntentInt2);
if (secureIntentInt2 != -1) {
intent2.putExtra("speaker", secureIntentInt2);
OperationReportUtils.getInstance().getTtsRecord().setToneColor(secureIntentInt2);
}
}
if (intent.hasExtra("audioDeviceType")) {
int secureIntentInt3 = SecureIntentUtil.getSecureIntentInt(intent, "audioDeviceType", -1);
KitLog.info("CloudTtsAbility", "audioDeviceType:" + secureIntentInt3);
if (secureIntentInt3 != -1) {
intent2.putExtra("audioDeviceType", secureIntentInt3);
}
}
SecureIntentUtil.transferIntExtra(intent, intent2, "speed");
SecureIntentUtil.transferIntExtra(intent, intent2, "volume");
SecureIntentUtil.transferIntExtra(intent, intent2, "pitch");
SecureIntentUtil.transferStringExtra(intent, intent2, "requestType");
SecureIntentUtil.transferStringExtra(intent, intent2, "style");
SecureIntentUtil.transferStringExtra(intent, intent2, "extensionRequestHeader");
SecureIntentUtil.transferIntExtra(intent, intent2, "compressRate");
SecureIntentUtil.transferBooleanExtra(intent, intent2, "supportNewSampleRate", false);
if (getSecondSpeaker() != -1) {
intent2.putExtra("secondSpeaker", getSecondSpeaker());
}
if (!intent2.hasExtra("compressRate") && getCompressRate() != -1) {
intent2.putExtra("compressRate", getCompressRate());
}
if (!intent2.hasExtra("supportNewSampleRate") && isSupportNewSampleRate()) {
intent2.putExtra("supportNewSampleRate", isSupportNewSampleRate());
}
SecureIntentUtil.transferIntExtra(intent, intent2, "streamState");
int secureIntentInt4 = SecureIntentUtil.getSecureIntentInt(intent, "usage", getUsage());
if (secureIntentInt4 != Integer.MAX_VALUE) {
intent2.putExtra("usage", secureIntentInt4);
}
return intent2;
}
public final void p(String str, Intent intent) {
this.b.clear();
this.b.put(str, Integer.valueOf(SecureIntentUtil.getSecureIntentInt(intent, Constants.Tts.TONE_COLOR, Constants.Tts.DEFAULT_TONE_COLOR)));
}
@Override
public void prepare() {
KitLog.info("CloudTtsAbility", "enter prepare");
if (this.e.get()) {
this.c.prepare((Intent) null);
}
}
@Override
public void textToSpeak(String str, final String str2, Intent intent) {
KitLog.info("CloudTtsAbility", "enter textToSpeak " + this.e);
OperationReportUtils.getInstance().getTtsRecord().setOda("0");
if (!this.e.get()) {
KitLog.warn("CloudTtsAbility", "not init");
Optional.ofNullable(this.d).ifPresent(new Consumer() {
@Override
public final void accept(Object obj) {
((TtsListenerInterface) obj).onTtsError(2, "tts is not available", str2);
}
});
return;
}
Intent intent2 = intent == null ? new Intent() : intent;
p(str2, intent);
OperationReportUtils.getInstance().getTtsRecord().setTts("cloud");
int secureIntentInt = SecureIntentUtil.getSecureIntentInt(intent2, "streamType", getStreamType());
Intent n = n(intent2, str2, secureIntentInt);
if (SecureIntentUtil.getSecureIntentInt(n, "synthesisMode", 0) == 0) {
requestAudioFocus(this.g, this.h, secureIntentInt);
}
int doSpeak = this.c.doSpeak(str, n);
StringBuilder sb = new StringBuilder();
sb.append("speakResult :");
sb.append(doSpeak == 100);
KitLog.info("CloudTtsAbility", sb.toString());
}
@Override
public void J() {
}
public class b implements IHwTTsCallback {
public b() {
}
public void onError(String str, String str2) {
a aVar = a.this;
aVar.onError(aVar.d, str, str2, a.this.g, a.this.h);
}
public void onFinish(String str) {
a aVar = a.this;
aVar.onTtsDataFinish(str, aVar.d);
}
public void onFormatChange(String str, Bundle bundle) {
a aVar = a.this;
aVar.onFormatChange(str, bundle, aVar.d);
}
public void onPhonemeFinish(String str, String str2) {
KitLog.debug("CloudTtsAbility", "onPhonemeFinish", new Object[0]);
a aVar = a.this;
aVar.onPhonemeFinish(str, str2, aVar.d);
}
public void onPhonemeProgress(String str, String str2, int i, String str3) {
KitLog.debug("CloudTtsAbility", "onPhonemeProgress", new Object[0]);
a aVar = a.this;
aVar.onPhonemeProgress(str, str2, i, str3, aVar.d);
}
public void onProgress(String str, byte[] bArr, int i) {
byte[] bArr2 = bArr != null ? (byte[]) bArr.clone() : null;
a aVar = a.this;
aVar.onTtsDataProgress(str, bArr2, i, aVar.d);
}
public void onSpeechFinish(String str) {
a aVar = a.this;
aVar.onSpeechFinish(str, aVar.d, a.this.g, a.this.h);
}
public void onSpeechProgressChanged(String str, int i) {
a aVar = a.this;
aVar.onSpeechProgressChanged(str, i, aVar.d);
}
public void onSpeechStart(String str) {
int intValue = ((Integer) Optional.ofNullable((Integer) a.this.b.get(str)).orElse(Integer.valueOf(Constants.Tts.DEFAULT_TONE_COLOR))).intValue();
a aVar = a.this;
aVar.onSpeechStart(str, intValue, aVar.d);
}
public void onStart(String str) {
}
public void onEvent(int i, Bundle bundle) {
}
}
@Override
public void downloadTtsToneEngine(int[] iArr) {
}
}