implement
}
}
+
+ @Override
+ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+ super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+ if (requestCode == MOGO_PERMISSION_REQUEST_CODE) {
+ boolean isAllGranted = true;
+ // 判断是否所有的权限都已经授予了
+ for (int grant : grantResults) {
+ Log.d("liyz", "grant =" + grant);
+ if (grant != PackageManager.PERMISSION_GRANTED) {
+ isAllGranted = false;
+ break;
+ }
+ }
+
+ Log.d("liyz", "onRequestPermissionsResult isAllGranted = " + isAllGranted);
+ if (isAllGranted) {
+ isFirst = false;
+ } else {
+ // 弹出对话框告诉用户需要权限的原因, 并引导用户去应用权限管理中手动打开权限按钮
+ if (!isFirst) {
+ openAppDetails();
+ isFirst = true;
+ }
+ }
+ }
+ }
+
+ /**
+ * 打开APP的详情设置
+ */
+ private void openAppDetails() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage("请在 “应用信息 -> 权限” 中授予权限");
+ builder.setPositiveButton("手动授权", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ Intent intent = new Intent();
+ intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
+ intent.addCategory(Intent.CATEGORY_DEFAULT);
+ intent.setData(Uri.parse("package:" + getPackageName()));
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
+ intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
+ startActivity(intent);
+ }
+ });
+ builder.setNegativeButton("取消", null);
+ builder.show();
+ }
+
}
diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainPresenter.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainPresenter.java
index 6d3c6a4a66..a1f1c6b14c 100644
--- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainPresenter.java
+++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainPresenter.java
@@ -1,11 +1,17 @@
package com.mogo.module.main;
+import android.Manifest;
+import android.app.Activity;
import android.content.Intent;
+import android.content.pm.PackageManager;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
+import android.util.Log;
import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
import androidx.lifecycle.LifecycleOwner;
import com.mogo.commons.mvp.Presenter;
@@ -37,6 +43,8 @@ public class MainPresenter extends Presenter< MainView > {
}
};
+ public static final int MOGO_PERMISSION_REQUEST_CODE = 10000;
+
public MainPresenter( MainView view ) {
super( view );
SchemeIntent.getInstance().init( getContext(), mView.getApis() );
@@ -47,6 +55,46 @@ public class MainPresenter extends Presenter< MainView > {
super.onCreate( owner );
}
+ public void checkPermission(Activity activity) {
+ boolean isAllGranted = checkPermissionAllGranted(
+ new String[]{
+ Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS,
+ Manifest.permission.ACCESS_FINE_LOCATION
+ }
+ );
+ if (isAllGranted) {
+ return;
+ }
+
+ /**
+ * 请求权限
+ */
+ ActivityCompat.requestPermissions(
+ activity,
+ new String[]{
+ Manifest.permission.READ_EXTERNAL_STORAGE,
+ Manifest.permission.WRITE_EXTERNAL_STORAGE,
+ Manifest.permission.ACCESS_LOCATION_EXTRA_COMMANDS,
+ Manifest.permission.ACCESS_FINE_LOCATION
+ }, MOGO_PERMISSION_REQUEST_CODE);
+ }
+
+ /**
+ * 检查是否拥有指定的所有权限
+ */
+ private boolean checkPermissionAllGranted(String[] permissions) {
+ for (String permission : permissions) {
+ if (ContextCompat.checkSelfPermission(getContext(), permission) != PackageManager.PERMISSION_GRANTED) {
+ // 只要有一个权限没有被授予, 则直接返回 false
+ return false;
+ }
+ }
+ return true;
+ }
+
+
/**
* 延时操作
*/
diff --git a/settings.gradle b/settings.gradle
index 68ff11a9df..9a79d7e08c 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -10,6 +10,7 @@ include ':foudations:mogo-base-websocket-sdk'
include ':tts:tts-base'
include ':tts:tts-di'
include ':tts:tts-zhi'
+include ':tts:tts-pad'
include ':tts:tts-noop'
include ':test:crashreport'
include ':test:crashreport-bugly'
diff --git a/tts/tts-pad/.gitignore b/tts/tts-pad/.gitignore
new file mode 100644
index 0000000000..42afabfd2a
--- /dev/null
+++ b/tts/tts-pad/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/tts/tts-pad/build.gradle b/tts/tts-pad/build.gradle
new file mode 100644
index 0000000000..6c10fe8722
--- /dev/null
+++ b/tts/tts-pad/build.gradle
@@ -0,0 +1,54 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.alibaba.arouter'
+
+android {
+ compileSdkVersion rootProject.ext.android.compileSdkVersion
+ // buildToolsVersion rootProject.ext.android.buildToolsVersion
+ defaultConfig {
+ minSdkVersion rootProject.ext.android.minSdkVersion
+ targetSdkVersion rootProject.ext.android.targetSdkVersion
+ versionCode Integer.valueOf(VERSION_CODE)
+ versionName getValueFromRootProperties("${project.name.replace("-", "_").toUpperCase()}_VERSION")
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+
+ javaCompileOptions {
+ annotationProcessorOptions {
+ arguments = [AROUTER_MODULE_NAME: project.getName()]
+ }
+ }
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+ implementation rootProject.ext.dependencies.androidxappcompat
+ implementation rootProject.ext.dependencies.arouter
+ annotationProcessor rootProject.ext.dependencies.aroutercompiler
+
+ api rootProject.ext.dependencies.aiassist
+ api rootProject.ext.dependencies.aiassistReplace
+
+ if (Boolean.valueOf(RELEASE)) {
+ implementation rootProject.ext.dependencies.ttsbase
+ implementation rootProject.ext.dependencies.mogoutils
+ } else {
+ implementation project(":tts:tts-base")
+ implementation project(":foudations:mogo-utils")
+ }
+}
+
+apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
\ No newline at end of file
diff --git a/tts/tts-pad/consumer-rules.pro b/tts/tts-pad/consumer-rules.pro
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/tts/tts-pad/gradle.properties b/tts/tts-pad/gradle.properties
new file mode 100644
index 0000000000..5d81ca81ca
--- /dev/null
+++ b/tts/tts-pad/gradle.properties
@@ -0,0 +1,3 @@
+GROUP=com.mogo.tts
+POM_ARTIFACT_ID=tts-pad
+VERSION_CODE=1
diff --git a/tts/tts-pad/proguard-rules.pro b/tts/tts-pad/proguard-rules.pro
new file mode 100644
index 0000000000..481bb43481
--- /dev/null
+++ b/tts/tts-pad/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/tts/tts-pad/src/main/AndroidManifest.xml b/tts/tts-pad/src/main/AndroidManifest.xml
new file mode 100644
index 0000000000..70631ddf64
--- /dev/null
+++ b/tts/tts-pad/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+ /
+
\ No newline at end of file
diff --git a/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java
new file mode 100644
index 0000000000..3598d85479
--- /dev/null
+++ b/tts/tts-pad/src/main/java/com/mogo/tts/pad/PadTTS.java
@@ -0,0 +1,480 @@
+package com.mogo.tts.pad;
+
+import android.content.Context;
+import android.content.Intent;
+import android.text.TextUtils;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.tts.base.IMogoTTS;
+import com.mogo.tts.base.IMogoTTSCallback;
+import com.mogo.tts.base.MogoTTSConstants;
+import com.mogo.tts.base.PreemptType;
+import com.mogo.utils.AppUtils;
+import com.mogo.utils.logger.Logger;
+import com.zhidao.auto.platform.voice.VoiceClient;
+import com.zhidao.voicesdk.MogoVoiceManager;
+import com.zhidao.voicesdk.MogoVoiceManagerImpl;
+import com.zhidao.voicesdk.callback.OnConnStatusListener;
+import com.zhidao.voicesdk.callback.OnTtsListener;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+public
+/**
+ * @author congtaowang
+ * @since 2020/10/12
+ *
+ * 描述
+ */
+@Route( path = MogoTTSConstants.API_PATH )
+class PadTTS implements IMogoTTS, VoiceClient.VoiceCmdCallBack, OnTtsListener {
+
+ private static final String TAG = "ZhiTTS";
+ private String mLastQAndASpeakText;
+
+ private boolean mHasFlush = false;
+ private boolean mInitReady = false;
+ private Context mContext;
+
+ public synchronized void release() {
+ Logger.d( TAG, "release" );
+ if ( mCmdMap != null && !mCmdMap.isEmpty() && mVoiceClient != null ) {
+ for ( String cmd : mCmdMap.keySet() ) {
+ try {
+ mVoiceClient.unRegisterCustomWakeupCmd( cmd );
+ } catch ( Exception e ) {
+ }
+ }
+ }
+ mQAndAMap.clear();
+ mVoiceClient.release();
+ mSpeakVoiceMap.clear();
+ mCacheUnWakeupCommands.clear();
+ mContext = null;
+ }
+
+ private VoiceClient mVoiceClient;
+ private MogoVoiceManager mogoVoiceManager;
+ // 免唤醒指令
+ private Map< String, List< IMogoTTSCallback > > mCmdMap = new HashMap<>();
+ // 问答指令
+ private Map< String, IMogoTTSCallback > mQAndAMap = new HashMap<>();
+ // 单独的语音播放
+ private Map< String, IMogoTTSCallback > mSpeakVoiceMap = new HashMap<>();
+
+ private Map< String, String[] > mCacheUnWakeupCommands = new ConcurrentHashMap<>();
+
+ private void initFlushStatus() {
+ if ( !mHasFlush ) {
+ mHasFlush = isVoiceServiceReady( mContext );
+ }
+ }
+
+ /**
+ * 初始化
+ */
+ private void initSpeech( Context context ) {
+ mogoVoiceManager = MogoVoiceManagerImpl.getInstance();
+ mogoVoiceManager.init( context, new OnConnStatusListener() {
+ @Override
+ public void onSuccess() {
+ mInitReady = true;
+ }
+
+ @Override
+ public void onFailed() {
+
+ }
+ } );
+ }
+
+ /**
+ * 是否语音注册成功
+ *
+ * @return
+ */
+ @Override
+ public boolean hasFlush() {
+ return mHasFlush;
+ }
+
+ @Override
+ public void onCmdSelected( String cmd ) {
+ if ( !mCmdMap.containsKey( cmd ) ) {
+ return;
+ }
+ Logger.d( TAG, "received command: %s", cmd );
+
+ Iterator< IMogoTTSCallback > iterator = null;
+ try {
+ List< IMogoTTSCallback > cmdCallBacks = mCmdMap.get( cmd );
+ iterator = new ArrayList<>( cmdCallBacks ).iterator();
+ } catch ( Exception e ) {
+
+ }
+ while ( iterator != null && iterator.hasNext() ) {
+ IMogoTTSCallback callBack = iterator.next();
+ if ( callBack != null ) {
+ callBack.onCmdSelected( cmd );
+ }
+ }
+ }
+
+ @Override
+ public void onCmdAction( String speakText ) {
+ if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onCmdAction( speakText );
+ }
+ }
+ }
+
+ @Override
+ public void onCmdCancel( String speakText ) {
+ if ( !TextUtils.isEmpty( mLastQAndASpeakText ) ) {
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove( mLastQAndASpeakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onCmdCancel( speakText );
+ }
+ }
+ }
+
+ @Override
+ public void onSpeakEnd( String speakText ) {
+ if ( mQAndAMap.containsKey( speakText ) ) {
+ mLastQAndASpeakText = speakText;
+ IMogoTTSCallback cmdCallBack = mQAndAMap.get( speakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onSpeakEnd( speakText );
+ return;
+ }
+ }
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText );
+ if ( callBack != null ) {
+ callBack.onSpeakEnd( speakText );
+ }
+ }
+
+ @Override
+ public void onSpeakSelectTimeOut( String speakText ) {
+ if ( mQAndAMap.containsKey( speakText ) ) {
+ if ( TextUtils.equals( speakText, mLastQAndASpeakText ) ) {
+ mLastQAndASpeakText = null;
+ }
+ IMogoTTSCallback cmdCallBack = mQAndAMap.remove( speakText );
+ if ( cmdCallBack != null ) {
+ cmdCallBack.onSpeakSelectTimeOut( speakText );
+ return;
+ }
+ }
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( speakText );
+ if ( callBack != null ) {
+ callBack.onSpeakSelectTimeOut( speakText );
+ }
+ }
+
+ /**
+ * 语音播报
+ *
+ * @param text
+ */
+ public void speakTTSVoice( String text, IMogoTTSCallback callBack ) {
+ try {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mSpeakVoiceMap.put( text, callBack );
+ mVoiceClient.speakDefault( text );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ /**
+ * 语音播报
+ *
+ * @param text
+ */
+ public void speakTTSVoice( String text ) {
+ try {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mVoiceClient.speakDefault( text );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ /**
+ * 语音播报
+ *
+ * @param text 播报内容
+ * @param type 播报策略
+ */
+ public void speakTTSVoice( String text, PreemptType type, IMogoTTSCallback callBack ) {
+ try {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mSpeakVoiceMap.put( text, callBack );
+ VoiceClient.PreemptType preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NONE;
+ if ( type != null ) {
+ switch ( type ) {
+ case PREEMPT_TYPE_NEXT:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_NEXT;
+ break;
+ case PREEMPT_TYPE_FLUSH:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_FLUSH;
+ break;
+ case PREEMPT_TYPE_IMMEDIATELY:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY;
+ break;
+ case PREEMPT_TYPE_IMMEDIATELY_WITHOUT_CANCEL:
+ preemptType = VoiceClient.PreemptType.PREEMPT_TYPE_IMMEADIATELY_WITHOUT_CANCLE;
+ break;
+ }
+ }
+ mVoiceClient.speakTypeText( text, preemptType );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ /**
+ * 问答类型语音注册:默认确认和取消
+ *
+ * @param tts 播报内容
+ */
+ public void speakQAndACmd( String tts, IMogoTTSCallback callBack ) {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mQAndAMap.put( tts, callBack );
+ mVoiceClient.speakTtsAndRegistCmd( tts );
+ }
+ }
+
+ /**
+ * 问答类型语音注册
+ *
+ * @param tts 播报内容
+ * @param okCmds 确认命令唤醒词
+ * @param cancelCmds 取消命令唤醒词
+ */
+ public void speakQAndACmd( String tts, String[] okCmds, String[] cancelCmds, IMogoTTSCallback callBack ) {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mQAndAMap.put( tts, callBack );
+ mVoiceClient.speakTtsAndRegistCmd( tts, okCmds, cancelCmds );
+ }
+ }
+
+ /**
+ * 注册免唤醒命令
+ *
+ * @param cmd
+ * @param cmdWords
+ * @param callBack
+ */
+ public void registerUnWakeupCommand( String cmd, String[] cmdWords, IMogoTTSCallback callBack ) {
+ if ( !mCmdMap.containsKey( cmd ) ) {
+ mCmdMap.put( cmd, new ArrayList<>() );
+ }
+ mCmdMap.get( cmd ).add( callBack );
+
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+ Logger.i( TAG, "cache un wakeup command2. %s", cmd );
+ mCacheUnWakeupCommands.put( cmd, cmdWords );
+ }
+
+ /**
+ * 注册免唤醒命令
+ *
+ * @param cmd
+ * @param cmdWords
+ */
+ private void registerUnWakeupCommand( String cmd, String[] cmdWords ) {
+ initFlushStatus();
+ if ( mHasFlush ) {
+ mVoiceClient.registerCustomWakeupCmd( cmd, cmdWords );
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+ Logger.i( TAG, "cache un wakeup command. %s", cmd );
+ mCacheUnWakeupCommands.put( cmd, cmdWords );
+ }
+
+ /**
+ * 注销免唤醒命令
+ *
+ * @param cmd
+ */
+ public synchronized void unregisterUnWakeupCommand( String cmd ) {
+ mCmdMap.remove( cmd );
+ try {
+ mVoiceClient.unRegisterCustomWakeupCmd( cmd );
+ } catch ( Exception e ) {
+ }
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+
+ /**
+ * 注销免唤醒命令
+ *
+ * @param cmd
+ */
+ public synchronized void unregisterUnWakeupCommand( String cmd, IMogoTTSCallback callBack ) {
+ if ( mCmdMap.containsKey( cmd ) ) {
+ List< IMogoTTSCallback > callBacks = mCmdMap.get( cmd );
+ if ( callBacks != null ) {
+ callBacks.remove( callBack );
+ }
+ if ( callBacks.isEmpty() ) {
+ mCmdMap.remove( cmd );
+ try {
+ mVoiceClient.unRegisterCustomWakeupCmd( cmd );
+ } catch ( Exception e ) {
+ }
+ mCacheUnWakeupCommands.remove( cmd );
+ }
+ }
+ }
+
+ public static void startAssistant( Context context ) {
+ startAssistant( context, 1 );
+ }
+
+ /**
+ * @param context
+ * @param status window_start_cancel 0 - 结束, 1 - 显示, 2 - 未激活调试进入
+ */
+ public static void startAssistant( Context context, int status ) {
+ final Intent intent = new Intent();
+ intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
+ intent.setAction( "pvetec.intent.action.txz.switch" );
+ intent.putExtra( "window_start_cancel", status );
+ intent.putExtra( "extra_switch_type", "window_start_cancel" );
+ Logger.d( TAG, "status = %d", status );
+ context.sendBroadcast( intent );
+ }
+
+ public synchronized void flush() {
+ if ( mCacheUnWakeupCommands.isEmpty() ) {
+ return;
+ }
+ mHasFlush = true;
+ Logger.d( TAG, "flush cache voice command when voice service ready." );
+ final Map< String, String[] > tmp = new HashMap<>( mCacheUnWakeupCommands );
+ for ( String cmd : tmp.keySet() ) {
+ registerUnWakeupCommand( cmd, tmp.get( cmd ) );
+ }
+ }
+
+ private boolean isVoiceServiceReady( Context context ) {
+ if ( AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.zhidao.speech" ) )) {
+ return true;
+ } else if ( AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.txznet.txz" ) )
+ && AppUtils.isProcessRunning( context, AppUtils.getPackageUid( context, "com.txznet.adapter" ) ) ) {
+ Logger.d( TAG, "txz is voiceServiceReady" );
+ return true;
+ }
+ return true;
+ }
+
+ public void speakTTSAndDuck( String text ) {
+ speakTTSAndDuck( text, null );
+ }
+
+ public void speakTTSAndDuck( String text, IMogoTTSCallback callBack ) {
+ try {
+ if ( mInitReady ) {
+ mSpeakVoiceMap.put( text, callBack );
+ mogoVoiceManager.toSpeak( text, -3, this );
+ }
+ } catch ( Exception e ) {
+ }
+ }
+
+ public void shutUp( String ttsId, String text ) {
+ try {
+ mSpeakVoiceMap.remove( text );
+ mogoVoiceManager.shutUp( ttsId );
+ } catch ( Exception e ) {
+
+ }
+ }
+
+ /**
+ * 打断上一条正在播报的语音内容,仅在Speech上生效,TXZ为空实现
+ * 语音SDK生效版本从1.0.8.4版本起
+ */
+ public void breakOffSpeak() {
+ mVoiceClient.breakOffSpeak();
+ }
+
+ public void clearTTSCallback( String text ) {
+ try {
+ mSpeakVoiceMap.remove( text );
+ } catch ( Exception e ) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onTtsStart( String ttsId, String text ) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.get( text );
+ if ( callBack != null ) {
+ callBack.onTTSStart( ttsId, text );
+ }
+ }
+
+ @Override
+ public void onTtsFinish( String ttsId, String text ) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text );
+ if ( callBack != null ) {
+ callBack.onTTSEnd( ttsId, text );
+ }
+ }
+
+ @Override
+ public void onTtsError( String ttsId, String text ) {
+ IMogoTTSCallback callBack = mSpeakVoiceMap.remove( text );
+ if ( callBack != null ) {
+ callBack.onTTSError( ttsId, text );
+ }
+ }
+
+ @Override
+ public void init( Context context ) {
+ if ( context != null ) {
+ mContext = context.getApplicationContext();
+ mVoiceClient = new VoiceClient( mContext );
+ mVoiceClient.setCallBack( this );
+ initFlushStatus();
+ initSpeech( context );
+ Logger.w( TAG, "voice is ready = %s", mHasFlush );
+ }
+ }
+
+ @Override
+ public void startAIAssist( Context context ) {
+ startAssistant( context, 1 );
+ }
+
+ @Override
+ public void startAIAssist( Context context, int status ) {
+ final Intent intent = new Intent();
+ intent.setFlags( Intent.FLAG_INCLUDE_STOPPED_PACKAGES );
+ intent.setAction( "pvetec.intent.action.txz.switch" );
+ intent.putExtra( "window_start_cancel", status );
+ intent.putExtra( "extra_switch_type", "window_start_cancel" );
+ Logger.d( TAG, "status = %d", status );
+ context.sendBroadcast( intent );
+ }
+}
diff --git a/tts/tts-zhi/src/main/AndroidManifest.xml b/tts/tts-zhi/src/main/AndroidManifest.xml
index a70d8aa41b..70631ddf64 100644
--- a/tts/tts-zhi/src/main/AndroidManifest.xml
+++ b/tts/tts-zhi/src/main/AndroidManifest.xml
@@ -1,5 +1,5 @@
+ package="com.mogo.tts.pad">
/
\ No newline at end of file
diff --git a/tts/tts-zhi/src/main/java/com/mogo/tts/zhi/ZhiTTS.java b/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiTTS.java
similarity index 99%
rename from tts/tts-zhi/src/main/java/com/mogo/tts/zhi/ZhiTTS.java
rename to tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiTTS.java
index c2670b9f89..ef0bac205b 100644
--- a/tts/tts-zhi/src/main/java/com/mogo/tts/zhi/ZhiTTS.java
+++ b/tts/tts-zhi/src/main/java/com/mogo/tts/pad/ZhiTTS.java
@@ -1,4 +1,4 @@
-package com.mogo.tts.zhi;
+package com.mogo.tts.pad;
import android.content.Context;
import android.content.Intent;