1. 添加语音支持,未添加完成,需联调

2. 添加状态设置,其中与adas同步以及改变自车图片由Launcher内部实现
This commit is contained in:
tongchenfei
2020-04-13 14:53:36 +08:00
parent 243e727389
commit 797d0aac0c
4 changed files with 27 additions and 14 deletions

View File

@@ -1,7 +1,11 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mogo.module.share" >
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<application>
<service android:name=".VoiceCmdService" />
<receiver android:name=".ShareVoiceCmdReceiver">
<intent-filter>
<action android:name="com.zhidao.speech.awake.notify" />
</intent-filter>
</receiver>
</application>
</manifest>

View File

@@ -6,18 +6,17 @@ import android.content.Intent
import com.mogo.module.share.constant.ShareConstants
/**
* 用于接收唤醒词指令
* 用于接收唤醒词指令,现在只接收 com.zhidao.speech.awake.notify 这一条广播
*/
class ShareVoiceCmdReceiver:BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
class ShareVoiceCmdReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
// todo 接收唤醒词指令
// todo 开启服务,准备上报求助
context?.let {
val seekHelp = Intent(it, VoiceCmdService::class.java)
val command = intent.getStringExtra("command")
if (command == "zhunbeishangbao") {
//todo 开启服务,准备上报求助
val seekHelp = Intent(context, VoiceCmdService::class.java)
seekHelp.putExtra(ShareConstants.VOICE_CMD_SERVICE_EVENT_KEY, ShareConstants.VOICE_CMD_SERVICE_SEEK_HELP)
it.startService(seekHelp)
context.startService(seekHelp)
}
}
}

View File

@@ -42,7 +42,7 @@ class VoiceCmdService:Service() {
if (intent.getIntExtra(ShareConstants.VOICE_CMD_SERVICE_EVENT_KEY,0) == ShareConstants.VOICE_CMD_SERVICE_SEEK_HELP) {
// 收到语音指令,准备上报求助
Logger.i(TAG, "收到语音指令,准备上报求助")
SeekHelpManager.seekHelp(this,seekListener)
SeekHelpManager.seekHelp(this,seekListener,false)
}
}
return super.onStartCommand(intent, flags, startId)

View File

@@ -79,13 +79,16 @@ object SeekHelpManager {
/**
* 寻求帮助,是开始故障求助的入口
* 由于当前需求仅需要提供这一个方法所以context的初始化放到了此方法后面如果有增加需要把这部分提出去
*
* @param useLocalVoiceNotice 使用自己的语音播报,如果是从语音助手过来的请求,语音助手可能会走自己的播报,默认是使用自己的播报
*/
fun seekHelp(context: Context, seekHelpListener: ISeekHelpListener) {
fun seekHelp(context: Context, seekHelpListener: ISeekHelpListener,useLocalVoiceNotice:Boolean = true) {
// context初始化
if (this.context == null) {
this.context = context
aiAssist = AIAssist.getInstance(context)
}
isSeekHelp = ShareControl.getInstance(SeekHelpManager.context).mogoServiceApis.statusManagerApi.isSeekHelping
Logger.d(TAG, "开始故障求助上报---${isSeekHelp}")
seekListenerList.add(seekHelpListener)
when {
@@ -101,7 +104,13 @@ object SeekHelpManager {
}
else -> {
// 没有异常情况,开始故障求助
aiAssist?.speakTTSVoice(VOICE_WILL_SEEK_HELP, voiceCallback)
if(useLocalVoiceNotice) {
// 语音说完再请求,要不然可能请求的太快
aiAssist?.speakTTSVoice(VOICE_WILL_SEEK_HELP, voiceCallback)
}else{
Logger.d(TAG,"不使用本地语音播报,直接开始发起求助")
realSeekHelp()
}
}
}
@@ -144,7 +153,8 @@ object SeekHelpManager {
ShareControl.getInstance(context).mogoServiceApis.networkApi.create(ShareApiService::class.java, HttpConstant.getNetHost()).sendHelpSignal(param).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(object : SubscribeImpl<BaseData>(RequestOptions.create(context)) {
override fun onSuccess(o: BaseData?) {
super.onSuccess(o)
// todo 接口请求成功,需要同步v2x状态通知adas改变自车图标
// 接口请求成功,内部同步v2x状态通知adas改变自车图标
ShareControl.getInstance(context).mogoServiceApis.statusManagerApi.setSeekHelping("ShareDialog",true)
isSeekHelp = true
aiAssist?.speakTTSVoice("已发布求助信息,将为你通知其他车主")
toast("已发布求助信息,将为你通知其他车主")