[6.1.0]M1平行驾驶状态下弱网提示改为提示音提示并且不展示提示接管动画
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.vehicle
|
||||
|
||||
import android.content.Context
|
||||
import android.os.CountDownTimer
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
@@ -18,6 +19,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerParallelDrivingListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.SoundPoolUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.zhjt.mogo.adas.data.bean.MogoReport
|
||||
import mogo.yycp.paralleldriving.protocol.ParallelTaskProcessNoticeOuterClass
|
||||
@@ -111,36 +114,65 @@ class TakeOverView @JvmOverloads constructor(
|
||||
MogoReport.Code.Error.EPARALLEL.AICLOUD_CONNECTION_ERROR -> {
|
||||
//如果是平行驾驶状态下,提示弱网接管
|
||||
if(isParallel){
|
||||
CallerHmiManager.warningV2X(
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.poiType,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.content,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.tts,
|
||||
object : IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
takeOver = true
|
||||
ThreadUtils.runOnUiThread{
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
//加入消息盒子
|
||||
saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X, V2XMsg(
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.poiType,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.content,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.tts
|
||||
)
|
||||
)
|
||||
if(AppIdentityModeUtils.isM1(FunctionBuildConfig.appIdentityMode)){
|
||||
//M1仅做提示音和消息盒子,无语音播报和提示接管动画
|
||||
//加入消息盒子
|
||||
saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X, V2XMsg(
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.poiType,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.content,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.tts
|
||||
)
|
||||
)
|
||||
)
|
||||
//提示音播报
|
||||
val countDownTimer = object : CountDownTimer(3000, 1000){
|
||||
override fun onTick(p0: Long) {
|
||||
try {
|
||||
SoundPoolUtils.getSoundPool().playSoundWithRedId(context,R.raw.weak_net_tips)
|
||||
}catch (e: Exception){
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
takeOver = false
|
||||
ThreadUtils.runOnUiThread{
|
||||
visibility = View.GONE
|
||||
override fun onFinish() {
|
||||
}
|
||||
|
||||
}
|
||||
countDownTimer.start()
|
||||
}else{
|
||||
CallerHmiManager.warningV2X(
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.poiType,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.content,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.tts,
|
||||
object : IMoGoWarningStatusListener {
|
||||
override fun onShow() {
|
||||
takeOver = true
|
||||
ThreadUtils.runOnUiThread{
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
//加入消息盒子
|
||||
saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X, V2XMsg(
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.poiType,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.content,
|
||||
EventTypeEnumNew.NETWORK_WEAK_EVENT.tts
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
takeOver = false
|
||||
ThreadUtils.runOnUiThread{
|
||||
visibility = View.GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
,isFromObu = false)
|
||||
,isFromObu = false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
BIN
core/mogo-core-res/src/main/res/raw/weak_net_tips.wav
Normal file
BIN
core/mogo-core-res/src/main/res/raw/weak_net_tips.wav
Normal file
Binary file not shown.
@@ -0,0 +1,117 @@
|
||||
package com.mogo.eagle.core.utilcode.util;
|
||||
|
||||
import android.media.*;
|
||||
import android.content.*;
|
||||
import android.os.*;
|
||||
import android.app.*;
|
||||
|
||||
/**
|
||||
* 音频播放工具类
|
||||
*/
|
||||
public class SoundPoolUtils {
|
||||
|
||||
private SoundPool mSoundPool;
|
||||
private AudioManager mAudioManager;
|
||||
private float volume;
|
||||
// Maximumn sound stream.
|
||||
private static final int MAX_STREAMS = 5;
|
||||
// Stream type.
|
||||
private static final int streamType = AudioManager.STREAM_MUSIC;
|
||||
private int mSoundId;
|
||||
private int resId;
|
||||
private Context mContext;
|
||||
|
||||
private volatile static SoundPoolUtils INSTANCE;
|
||||
|
||||
public static SoundPoolUtils getSoundPool(){
|
||||
if (INSTANCE == null){
|
||||
synchronized (SoundPoolUtils.class){
|
||||
if (INSTANCE == null){
|
||||
INSTANCE = new SoundPoolUtils();
|
||||
}
|
||||
}
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public SoundPoolUtils(){}
|
||||
|
||||
//播放资源文件
|
||||
public void playSoundWithRedId(Context context,int resId){
|
||||
this.mContext = context;
|
||||
this.resId=resId;
|
||||
init();
|
||||
}
|
||||
|
||||
//init settings
|
||||
private void init(){
|
||||
// AudioManager audio settings for adjusting the volume
|
||||
mAudioManager = (AudioManager)this.mContext. getSystemService(Context.AUDIO_SERVICE);
|
||||
|
||||
// Current volumn Index of particular stream type.
|
||||
float currentVolumeIndex = (float) mAudioManager.getStreamVolume(streamType);
|
||||
|
||||
// Get the maximum volume index for a particular stream type.
|
||||
float maxVolumeIndex = (float) mAudioManager.getStreamMaxVolume(streamType);
|
||||
|
||||
// Volumn (0 --> 1)
|
||||
this.volume = currentVolumeIndex / maxVolumeIndex;
|
||||
|
||||
// Suggests an audio stream whose volume should be changed by
|
||||
// the hardware volume controls.
|
||||
((Activity)this.mContext).setVolumeControlStream(streamType);
|
||||
|
||||
if (mSoundPool == null){
|
||||
// For Android SDK >= 21
|
||||
if (Build.VERSION.SDK_INT >= 21 ) {
|
||||
|
||||
AudioAttributes audioAttrib = new AudioAttributes.Builder()
|
||||
.setUsage(AudioAttributes.USAGE_GAME)
|
||||
.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
|
||||
.build();
|
||||
|
||||
SoundPool.Builder builder= new SoundPool.Builder();
|
||||
builder.setAudioAttributes(audioAttrib).setMaxStreams(MAX_STREAMS);
|
||||
|
||||
this.mSoundPool = builder.build();
|
||||
} else {// for Android SDK < 21
|
||||
// SoundPool(int maxStreams, int streamType, int srcQuality)
|
||||
this.mSoundPool = new SoundPool(MAX_STREAMS, AudioManager.STREAM_MUSIC, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// When Sound Pool load complete.
|
||||
this.mSoundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
|
||||
@Override
|
||||
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
|
||||
playSound();
|
||||
}
|
||||
});
|
||||
|
||||
//load res
|
||||
this.mSoundId =this.mSoundPool.load(this.mContext,this.resId,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 释放资源
|
||||
*/
|
||||
public void releaseSoundPool() {
|
||||
if (mSoundPool != null) {
|
||||
mSoundPool.autoPause();
|
||||
mSoundPool.unload(mSoundId);
|
||||
mSoundPool.release();
|
||||
mSoundPool = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//play the sound res
|
||||
private void playSound(){
|
||||
float leftVolumn = volume;
|
||||
float rightVolumn = volume;
|
||||
// Play sound of gunfire. Returns the ID of the new stream.
|
||||
int streamId = this.mSoundPool.play(this.mSoundId,leftVolumn, rightVolumn, 1, 0, 1f);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user