[opt3.0]下沉工具类到mogo-core-utils模块
This commit is contained in:
@@ -34,9 +34,9 @@ import com.mogo.eagle.core.function.chat.facade.net.ChatServiceModel
|
||||
import com.mogo.eagle.core.function.chat.facade.net.bean.CallRequestParam
|
||||
import com.mogo.eagle.core.function.chat.facade.net.bean.ConnectStatusParam
|
||||
import com.mogo.eagle.core.function.chat.facade.socket.SocketConnectManager
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.eagle.core.function.chat.facade.voice.VoiceControlFacade
|
||||
import com.mogo.eagle.core.utilcode.kotlin.safeCancel
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.map.MogoLocationClient
|
||||
import kotlinx.coroutines.*
|
||||
@@ -137,7 +137,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
|
||||
private var callStatus by Delegates.observable(INIT_CALL) { _, _, newValue ->
|
||||
log(ChatConsts.TAG, "call-status: ${newValue.toText()}")
|
||||
Logger.d(ChatConsts.TAG, "call-status: ${newValue.toText()}")
|
||||
}
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
@@ -148,7 +148,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
|
||||
private var callType by Delegates.observable(CALL_TYPE_DEFAULT) { _, oldValue, newValue ->
|
||||
log(ChatConsts.TAG, "call type change: oldValue: $oldValue - newValue: $newValue")
|
||||
Logger.d(ChatConsts.TAG, "call type change: oldValue: $oldValue - newValue: $newValue")
|
||||
}
|
||||
|
||||
private val sender by lazy { AtomicReference<UserInfo>(null) }
|
||||
@@ -171,7 +171,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
|
||||
@ExperimentalCoroutinesApi
|
||||
private fun initSocketService() {
|
||||
log(ChatConsts.TAG, "-- initSocketService --")
|
||||
Logger.d(ChatConsts.TAG, "-- initSocketService --")
|
||||
SocketConnectManager.setOnMsgReceiveCb {
|
||||
handleMessage(it)
|
||||
}
|
||||
@@ -181,7 +181,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
@ExperimentalCoroutinesApi
|
||||
private fun handleMessage(msg: String) {
|
||||
mainScope.launch {
|
||||
log(ChatConsts.TAG, "长链下行消息: $msg")
|
||||
Logger.d(ChatConsts.TAG, "长链下行消息: $msg")
|
||||
val map = Gson().fromJson<Map<String, Any>>(msg, Map::class.java)
|
||||
val temp = map ?: return@launch
|
||||
val msgType = temp["msgType"]
|
||||
@@ -189,12 +189,12 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
when(val t = msgType.toInt()) {
|
||||
0 -> {
|
||||
val openId = (temp["localUserId"] as? Double ?: return@launch).toInt().toString()
|
||||
log(ChatConsts.TAG, "handleMessage --- openId:$openId")
|
||||
Logger.d(ChatConsts.TAG, "handleMessage --- openId:$openId")
|
||||
//初始化房间
|
||||
GMEApi.init(context(), openId = openId, cb = gmeCallback)
|
||||
}
|
||||
else ->
|
||||
log(ChatConsts.TAG, "handleMessage --- $t")
|
||||
Logger.d(ChatConsts.TAG, "handleMessage --- $t")
|
||||
}
|
||||
} else {
|
||||
val message = withContext(Dispatchers.Default) { Gson().fromJson(msg, Message::class.java) } ?: return@launch
|
||||
@@ -207,7 +207,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
when(message.type.toCallType()) {
|
||||
CALL_TYPE_VOICE -> {
|
||||
if (GMEApi.isRoomEntered() && callType == CALL_TYPE_VEHICLE_TEAM) {
|
||||
log(ChatConsts.TAG, "收到来电进房消息,此时正在车队通话。需要挂断电话")
|
||||
Logger.d(ChatConsts.TAG, "收到来电进房消息,此时正在车队通话。需要挂断电话")
|
||||
try {
|
||||
serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, message.snSender, message.roomId, PUSH_MSG_HANG_UP, message.type))
|
||||
} catch (t : Throwable) {
|
||||
@@ -230,7 +230,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
callType = message.type.toCallType()
|
||||
channel4SocketMsg.send(message)
|
||||
}
|
||||
else -> log(ChatConsts.TAG, "-- 接收者同意通话,但是呼叫类型不对: ${message.type}")
|
||||
else -> Logger.d(ChatConsts.TAG, "-- 接收者同意通话,但是呼叫类型不对: ${message.type}")
|
||||
}
|
||||
}
|
||||
PUSH_MSG_DENY_ENTER -> {
|
||||
@@ -238,12 +238,12 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
when(message.type.toCallType()) {
|
||||
CALL_TYPE_VOICE -> {
|
||||
if (GMEApi.isRoomEntered() && callType == CALL_TYPE_VEHICLE_TEAM) {
|
||||
log(ChatConsts.TAG, "已经进房,收到被拒绝消息,则不处理(为兼容车队需求),否则会引发退房操作")
|
||||
Logger.d(ChatConsts.TAG, "已经进房,收到被拒绝消息,则不处理(为兼容车队需求),否则会引发退房操作")
|
||||
return@launch
|
||||
}
|
||||
if (callStatus == READY_TO_CALL_RECEIVER && message.snReceiver == MoGoAiCloudClientConfig.getInstance().sn) {
|
||||
//如果当前是来电状态,并且收到拒绝消息,说明呼叫方呼出又挂断
|
||||
log(ChatConsts.TAG, "呼叫方呼出后,又挂断")
|
||||
Logger.d(ChatConsts.TAG, "呼叫方呼出后,又挂断")
|
||||
onCallingInterrupt?.get()?.invoke(false, message.toUser())
|
||||
return@launch
|
||||
}
|
||||
@@ -260,7 +260,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
callType = message.type.toCallType()
|
||||
channel4SocketMsg.send(message)
|
||||
}
|
||||
else -> log(ChatConsts.TAG, "-- 接收者拒绝,但是呼叫类型不对: ${message.type}")
|
||||
else -> Logger.d(ChatConsts.TAG, "-- 接收者拒绝,但是呼叫类型不对: ${message.type}")
|
||||
}
|
||||
}
|
||||
PUSH_MSG_HANG_UP -> {
|
||||
@@ -289,7 +289,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
channel4SocketMsg.send(message)
|
||||
}
|
||||
}
|
||||
else -> log(ChatConsts.TAG, "-- 收到来电,但是呼叫类型不对: ${message.type}")
|
||||
else -> Logger.d(ChatConsts.TAG, "-- 收到来电,但是呼叫类型不对: ${message.type}")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -411,7 +411,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
return@async
|
||||
}
|
||||
is UserChangeInRoom -> {
|
||||
log(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
Logger.d(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
if (!state.isEnter && state.left.isEmpty()) {
|
||||
exitRoom()
|
||||
continue
|
||||
@@ -439,7 +439,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
when(msg.status) {
|
||||
PUSH_MSG_AGREE_ENTER -> {
|
||||
//接收方同意进房
|
||||
log(ChatConsts.TAG, "[Call] - [Agree] - roomId: $roomId-msg: $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Call] - [Agree] - roomId: $roomId-msg: $msg")
|
||||
if (roomId == msg.roomId) {
|
||||
if (callType == CALL_TYPE_VOICE) {
|
||||
send(CallState.AgreeCall(false, msg))
|
||||
@@ -455,7 +455,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
PUSH_MSG_DENY_ENTER -> {
|
||||
//接收方拒绝进房
|
||||
log(ChatConsts.TAG, "[Call] - [Refuse] - roomId: $roomId-msg: $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Call] - [Refuse] - roomId: $roomId-msg: $msg")
|
||||
if (roomId == msg.roomId) {
|
||||
teamMembers.set(msg.teamMember ?: emptyList())
|
||||
if (callType == CALL_TYPE_VOICE) {
|
||||
@@ -470,7 +470,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
|
||||
PUSH_MSG_HANG_UP -> {
|
||||
log(ChatConsts.TAG, "[Call] - [hangUp] - roomId: $roomId-msg: $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Call] - [hangUp] - roomId: $roomId-msg: $msg")
|
||||
teamMembers.set(msg.teamMember ?: emptyList())
|
||||
if (callType == CALL_TYPE_VOICE) {
|
||||
send(CallState.HangUp(false, msg))
|
||||
@@ -496,7 +496,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
}
|
||||
}.catch {
|
||||
log(ChatConsts.TAG, "unknow exption:$it")
|
||||
Logger.d(ChatConsts.TAG, "unknow exption:$it")
|
||||
emit(CallState.Error(CallState.CODE_UNKNOWN_ERROR, "[Call] - ${it.message ?: "未知异常"}"))
|
||||
}.onCompletion {
|
||||
resetState()
|
||||
@@ -612,7 +612,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
val msg = channel4SocketMsg.receive()
|
||||
when(msg.status) {
|
||||
PUSH_MSG_HANG_UP -> {
|
||||
log(ChatConsts.TAG, "[Answer] - [hangUp] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Answer] - [hangUp] - msg -> $msg")
|
||||
if (callType == CALL_TYPE_VOICE) {
|
||||
send(AnswerState.HangUp(false, msg))
|
||||
exitRoom()
|
||||
@@ -623,18 +623,18 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
}
|
||||
PUSH_MSG_AGREE_ENTER -> {
|
||||
log(ChatConsts.TAG, "[Answer] - [Agree] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Answer] - [Agree] - msg -> $msg")
|
||||
if (callType.isTeam()) {
|
||||
//接受车队邀请
|
||||
log(ChatConsts.TAG, "[Answer] - [Agree] - [Team] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Answer] - [Agree] - [Team] - msg -> $msg")
|
||||
send(AnswerState.AcceptTeamInvite(msg))
|
||||
teamMembers.set(msg.teamMember)
|
||||
}
|
||||
}
|
||||
PUSH_MSG_DENY_ENTER -> {
|
||||
log(ChatConsts.TAG, "[Answer] - [hangUp] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Answer] - [hangUp] - msg -> $msg")
|
||||
if (callType.isTeam()) {
|
||||
log(ChatConsts.TAG, "[Answer] - [hangUp] - [Team] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[Answer] - [hangUp] - [Team] - msg -> $msg")
|
||||
send(AnswerState.RefuseTeamInvite(msg))
|
||||
teamMembers.set(msg.teamMember)
|
||||
}
|
||||
@@ -670,7 +670,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
return@async
|
||||
}
|
||||
is UserChangeInRoom -> {
|
||||
log(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
Logger.d(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
if (!state.isEnter && state.left.isEmpty()) {
|
||||
exitRoom()
|
||||
continue
|
||||
@@ -705,7 +705,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
}
|
||||
}.catch {
|
||||
log(ChatConsts.TAG, "unknow exption:$it")
|
||||
Logger.d(ChatConsts.TAG, "unknow exption:$it")
|
||||
emit(AnswerState.Error(AnswerState.CODE_UNKNOWN_ERROR, it.message ?: "未知异常"))
|
||||
}.onCompletion {
|
||||
resetState()
|
||||
@@ -885,7 +885,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
return@async
|
||||
}
|
||||
is UserChangeInRoom -> {
|
||||
log(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
Logger.d(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
if (!state.isEnter && state.left.isEmpty()) {
|
||||
exitRoom()
|
||||
continue
|
||||
@@ -993,15 +993,15 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
}
|
||||
when(msg.status) {
|
||||
PUSH_MSG_HANG_UP -> {
|
||||
log(ChatConsts.TAG, "[JoinTeam] - [hangUp] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[JoinTeam] - [hangUp] - msg -> $msg")
|
||||
teamMembers.set(msg.teamMember ?: emptyList())
|
||||
}
|
||||
PUSH_MSG_AGREE_ENTER -> {
|
||||
log(ChatConsts.TAG, "[JoinTeam] - [Agree] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[JoinTeam] - [Agree] - msg -> $msg")
|
||||
teamMembers.set(msg.teamMember ?: emptyList())
|
||||
}
|
||||
PUSH_MSG_DENY_ENTER -> {
|
||||
log(ChatConsts.TAG, "[JoinTeam] - [Deny] - msg -> $msg")
|
||||
Logger.d(ChatConsts.TAG, "[JoinTeam] - [Deny] - msg -> $msg")
|
||||
teamMembers.set(msg.teamMember ?: emptyList())
|
||||
}
|
||||
}
|
||||
@@ -1040,7 +1040,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
return@async
|
||||
}
|
||||
is UserChangeInRoom -> {
|
||||
log(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
Logger.d(ChatConsts.TAG, "openIds: ${state.left.joinToString(",")}")
|
||||
if (!state.isEnter && state.left.isEmpty()) {
|
||||
exitRoom()
|
||||
continue
|
||||
@@ -1083,7 +1083,7 @@ object MoGoChatFacade: IMoGoChatFacade {
|
||||
try {
|
||||
client.stopHeartBeat()
|
||||
} catch (t: Throwable) {
|
||||
log(ChatConsts.TAG, "$t")
|
||||
Logger.d(ChatConsts.TAG, "$t")
|
||||
}
|
||||
channel4GmeState.safeCancel()
|
||||
channel4SocketMsg.safeCancel()
|
||||
|
||||
@@ -11,7 +11,7 @@ import android.os.Looper
|
||||
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
|
||||
import com.mogo.eagle.core.function.api.chat.biz.IMoGoAudioFocusFacade
|
||||
import com.mogo.eagle.core.function.chat.facade.bridge.BridgeApi
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.asCoroutineDispatcher
|
||||
import java.util.concurrent.TimeUnit.SECONDS
|
||||
@@ -40,7 +40,7 @@ object AudioFocusFacade: IMoGoAudioFocusFacade {
|
||||
private var hasAudioFocus = false
|
||||
|
||||
override fun requireAudioFocus(onGetFocus: () -> Unit) {
|
||||
log(ChatConsts.TAG, "requireDuck===$hasAudioFocus")
|
||||
Logger.d(ChatConsts.TAG, "requireDuck===$hasAudioFocus")
|
||||
scope.launch {
|
||||
if (!hasAudioFocus) {
|
||||
while (true) {
|
||||
@@ -79,7 +79,7 @@ object AudioFocusFacade: IMoGoAudioFocusFacade {
|
||||
}
|
||||
|
||||
override fun releaseAudioFocus() {
|
||||
log(ChatConsts.TAG, "releaseDuck===$hasAudioFocus")
|
||||
Logger.d(ChatConsts.TAG, "releaseDuck===$hasAudioFocus")
|
||||
focusJob.get()?.takeIf { it.isActive }?.cancel()
|
||||
scope.launch {
|
||||
if (hasAudioFocus) {
|
||||
@@ -101,7 +101,7 @@ object AudioFocusFacade: IMoGoAudioFocusFacade {
|
||||
|
||||
private class MyAudioFocusChangeListener : OnAudioFocusChangeListener {
|
||||
override fun onAudioFocusChange(focusChange: Int) {
|
||||
log(ChatConsts.TAG, "onAudioFocusChange: $focusChange")
|
||||
Logger.d(ChatConsts.TAG, "onAudioFocusChange: $focusChange")
|
||||
when (focusChange) {
|
||||
AudioManager.AUDIOFOCUS_GAIN -> {
|
||||
hasAudioFocus = true
|
||||
|
||||
@@ -8,7 +8,7 @@ import com.gme.TMG.ITMGContext
|
||||
import com.gme.av.sdk.AVError
|
||||
import com.gme.av.sig.AuthBuffer
|
||||
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -66,22 +66,22 @@ internal object GMEApi {
|
||||
if (type == ITMGContext.ITMG_MAIN_EVENT_TYPE.ITMG_MAIN_EVNET_TYPE_USER_UPDATE) {
|
||||
val eventId = data.eventId
|
||||
val users = data.users
|
||||
log(ChatConsts.TAG, "RoomMembersUpdate: ${users.joinToString(",")}")
|
||||
Logger.d(ChatConsts.TAG, "RoomMembersUpdate: ${users.joinToString(",")}")
|
||||
if (users.isEmpty()) {
|
||||
log(ChatConsts.TAG, "没人了,准备退房")
|
||||
Logger.d(ChatConsts.TAG, "没人了,准备退房")
|
||||
cb?.invoke(GmeState.UserChangeInRoom(isEnter = false, emptyArray()))
|
||||
return
|
||||
}
|
||||
val filtered = users.filter {
|
||||
log(ChatConsts.TAG, "成员进房====$it===ownId:$openId")
|
||||
Logger.d(ChatConsts.TAG, "成员进房====$it===ownId:$openId")
|
||||
it.toInt() > 99999
|
||||
}.toTypedArray()
|
||||
if (filtered.isEmpty()) {
|
||||
log(ChatConsts.TAG, "成员为空,无操作")
|
||||
Logger.d(ChatConsts.TAG, "成员为空,无操作")
|
||||
return
|
||||
}
|
||||
if (eventId == ITMGContext.ITMG_EVENT_ID_USER_ENTER) {
|
||||
log(ChatConsts.TAG, "成员进房==去掉99999====$filtered")
|
||||
Logger.d(ChatConsts.TAG, "成员进房==去掉99999====$filtered")
|
||||
cb?.invoke(GmeState.UserChangeInRoom(isEnter = true, filtered))
|
||||
}
|
||||
if (eventId == ITMGContext.ITMG_EVENT_ID_USER_EXIT) {
|
||||
@@ -92,11 +92,11 @@ internal object GMEApi {
|
||||
}
|
||||
|
||||
fun enableAudio() {
|
||||
log(ChatConsts.TAG, "-- enable audio --- 1 ---")
|
||||
Logger.d(ChatConsts.TAG, "-- enable audio --- 1 ---")
|
||||
if (!hasInit.get()) {
|
||||
return
|
||||
}
|
||||
log(ChatConsts.TAG, "-- enable audio --- 2 ---")
|
||||
Logger.d(ChatConsts.TAG, "-- enable audio --- 2 ---")
|
||||
val audioCtrl = tmgCtx.GetAudioCtrl()
|
||||
//开启麦克
|
||||
audioCtrl?.EnableMic(true)
|
||||
@@ -109,11 +109,11 @@ internal object GMEApi {
|
||||
}
|
||||
|
||||
fun disableAudio() {
|
||||
log(ChatConsts.TAG, "-- disable audio --- 1 ---")
|
||||
Logger.d(ChatConsts.TAG, "-- disable audio --- 1 ---")
|
||||
if (!hasInit.get()) {
|
||||
return
|
||||
}
|
||||
log(ChatConsts.TAG, "-- disable audio --- 2 ---")
|
||||
Logger.d(ChatConsts.TAG, "-- disable audio --- 2 ---")
|
||||
val audioCtrl = tmgCtx.GetAudioCtrl()
|
||||
audioCtrl?.EnableSpeaker(false)
|
||||
//开启麦克
|
||||
@@ -122,7 +122,7 @@ internal object GMEApi {
|
||||
|
||||
fun init(ctx: Context, openId: String, cb: ((s: GmeState) -> Unit)? = null) {
|
||||
if (hasInit.get()) {
|
||||
log(ChatConsts.TAG, "Error: GmeApi has initialized.")
|
||||
Logger.d(ChatConsts.TAG, "Error: GmeApi has initialized.")
|
||||
return
|
||||
}
|
||||
hasInit.set(true)
|
||||
@@ -143,7 +143,7 @@ internal object GMEApi {
|
||||
cb?.invoke(GmeState.InitFail(ret))
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
log(ChatConsts.TAG, "GMEAPI - error: $t")
|
||||
Logger.d(ChatConsts.TAG, "GMEAPI - error: $t")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.media.MediaPlayer
|
||||
import android.os.Build
|
||||
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
|
||||
import com.mogo.eagle.core.function.api.chat.biz.IMoGoMediaFacade
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@@ -32,29 +32,29 @@ internal object MedialControlFacade : IMoGoMediaFacade {
|
||||
isLooping = isLoop
|
||||
prepareAsync()
|
||||
setOnPreparedListener { player ->
|
||||
log(ChatConsts.TAG,"real play 准备播放音频====")
|
||||
Logger.d(ChatConsts.TAG,"real play 准备播放音频====")
|
||||
player.start()
|
||||
}
|
||||
setOnCompletionListener { player ->
|
||||
log(ChatConsts.TAG,"播放完成====")
|
||||
Logger.d(ChatConsts.TAG,"播放完成====")
|
||||
player.reset()
|
||||
}
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
log(ChatConsts.TAG, "播放铃声异常:$t")
|
||||
Logger.d(ChatConsts.TAG, "播放铃声异常:$t")
|
||||
}
|
||||
}
|
||||
|
||||
override fun release() {
|
||||
try {
|
||||
val player = this.player.get()?.get() ?: return
|
||||
log(ChatConsts.TAG,"release 释放音频播放====")
|
||||
Logger.d(ChatConsts.TAG,"release 释放音频播放====")
|
||||
player.run {
|
||||
resetStatus(this)
|
||||
release()
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
log(ChatConsts.TAG, "释放MediaPlay异常: $t")
|
||||
Logger.d(ChatConsts.TAG, "释放MediaPlay异常: $t")
|
||||
} finally {
|
||||
player.set(null)
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ import com.mogo.eagle.core.function.api.chat.biz.IMCallType.CALL_TYPE_VOICE
|
||||
import com.mogo.eagle.core.function.chat.facade.consts.ChatHttp
|
||||
import com.mogo.eagle.core.function.chat.facade.consts.ChatHttp.Companion.getConfig
|
||||
import com.mogo.eagle.core.function.chat.facade.net.bean.*
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.map.MogoLocationClient
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import retrofit2.http.*
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ internal class ChatServiceModel {
|
||||
params.lon = location.longitude
|
||||
params.lat = location.latitude
|
||||
}
|
||||
log(ChatConsts.TAG, "connectStatusParam:$params")
|
||||
Logger.d(ChatConsts.TAG, "connectStatusParam:$params")
|
||||
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
map["data"] = Gson().toJson(params)
|
||||
return if (params.type == CALL_TYPE_VOICE.type) {
|
||||
@@ -93,7 +93,7 @@ internal class ChatServiceModel {
|
||||
|
||||
suspend fun inviteJoinVehicleTeam(param: CallRequestParam): BaseResponse<Any> {
|
||||
val map = hashMapOf<String, String>()
|
||||
log(ChatConsts.TAG, "inviteJoinVehicleTeam paras: $param")
|
||||
Logger.d(ChatConsts.TAG, "inviteJoinVehicleTeam paras: $param")
|
||||
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
map["data"] = Gson().toJson(param)
|
||||
return apiCall {
|
||||
@@ -109,7 +109,7 @@ internal class ChatServiceModel {
|
||||
param.lat = location.latitude
|
||||
param.lon = location.longitude
|
||||
}
|
||||
log(ChatConsts.TAG, "roomParam:$param")
|
||||
Logger.d(ChatConsts.TAG, "roomParam:$param")
|
||||
map["data"] = Gson().toJson(param)
|
||||
return apiCall {
|
||||
getNetWorkApi()?.requestRoomInfo(map) ?: throw IllegalStateException("apis is null.")
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
|
||||
import com.mogo.eagle.core.function.chat.facade.consts.ChatHttp
|
||||
import com.mogo.eagle.core.function.chat.facade.consts.SOCKET_HAND_SHAKE
|
||||
import com.mogo.eagle.core.function.chat.facade.consts.SOCKET_HEART_BEAT
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.websocket.ISocketMsgCallBack
|
||||
import com.mogo.websocket.ISocketMsgSetting
|
||||
import com.mogo.websocket.SocketClient
|
||||
@@ -46,13 +46,13 @@ internal object SocketConnectManager {
|
||||
|
||||
private val socketMsgSetting: ISocketMsgSetting = object : ISocketMsgSetting {
|
||||
override fun getHandShakeMsg(): String {
|
||||
log(ChatConsts.TAG, "getHandShakeMsg")
|
||||
Logger.d(ChatConsts.TAG, "getHandShakeMsg")
|
||||
val socketMsg = HeartBeat(SOCKET_HAND_SHAKE, MoGoAiCloudClientConfig.getInstance().sn)
|
||||
return Gson().toJson(socketMsg)
|
||||
}
|
||||
|
||||
override fun getHeartBeatMsg(): String {
|
||||
log(ChatConsts.TAG, "getHeartBeatMsg")
|
||||
Logger.d(ChatConsts.TAG, "getHeartBeatMsg")
|
||||
val socketMsg = HeartBeat(SOCKET_HEART_BEAT, MoGoAiCloudClientConfig.getInstance().sn, roomId.get())
|
||||
return Gson().toJson(socketMsg)
|
||||
}
|
||||
@@ -60,25 +60,25 @@ internal object SocketConnectManager {
|
||||
|
||||
private val socketMsgCallBack: ISocketMsgCallBack = object : ISocketMsgCallBack {
|
||||
override fun onConnectOpen() {
|
||||
log(ChatConsts.TAG, "onConnectOpen ---> ")
|
||||
Logger.d(ChatConsts.TAG, "onConnectOpen ---> ")
|
||||
}
|
||||
|
||||
override fun handleError(e: Exception) {
|
||||
log(ChatConsts.TAG, "handleError ---> msg: ${e.message}")
|
||||
Logger.d(ChatConsts.TAG, "handleError ---> msg: ${e.message}")
|
||||
client.stopHeartBeat()
|
||||
}
|
||||
|
||||
override fun onConnectClose() {
|
||||
log(ChatConsts.TAG, "onConnectClose ---> stop web socket thread ,and ready to reconnect")
|
||||
Logger.d(ChatConsts.TAG, "onConnectClose ---> stop web socket thread ,and ready to reconnect")
|
||||
client.stop()
|
||||
log(ChatConsts.TAG, "onConnectClose ---> stop Heart Beat")
|
||||
Logger.d(ChatConsts.TAG, "onConnectClose ---> stop Heart Beat")
|
||||
client.stopHeartBeat()
|
||||
log(ChatConsts.TAG, "ready to reconnect")
|
||||
Logger.d(ChatConsts.TAG, "ready to reconnect")
|
||||
client.reConnect()
|
||||
}
|
||||
|
||||
override fun handleMessage(message: String) {
|
||||
log(ChatConsts.TAG, "handleMessage ---> $message")
|
||||
Logger.d(ChatConsts.TAG, "handleMessage ---> $message")
|
||||
msgCallback?.invoke(message)
|
||||
}
|
||||
}
|
||||
@@ -91,7 +91,7 @@ internal object SocketConnectManager {
|
||||
client.disConnect()
|
||||
client.stop()
|
||||
} catch (t: Throwable) {
|
||||
log(ChatConsts.TAG, "IMService -- destroy -- ex: $t")
|
||||
Logger.d(ChatConsts.TAG, "IMService -- destroy -- ex: $t")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,6 @@ import com.mogo.eagle.core.function.chat.facade.MoGoChatFacade
|
||||
import com.mogo.eagle.core.function.chat.facade.OnCallingInterrupt
|
||||
import com.mogo.eagle.core.function.chat.facade.OnInComingCallback
|
||||
import com.mogo.eagle.core.function.chat.facade.bridge.BridgeApi
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.eagle.core.function.chat.facade.voice.VoiceControlFacade.REQUEST_CLOUD_VOICE_CALL
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.glide.transform.GlideRoundedCornersTransform
|
||||
@@ -40,6 +39,7 @@ import kotlinx.coroutines.flow.*
|
||||
import kotlinx.coroutines.selects.select
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
@@ -111,7 +111,7 @@ internal class CallChatWindowManager {
|
||||
private val onInComingCall = object : OnInComingCallback {
|
||||
override fun invoke(isTeam: Boolean, user: UserInfo) {
|
||||
if (isTeam) {
|
||||
log(TAG, "车队邀请,不做处理....")
|
||||
Logger.d(TAG, "车队邀请,不做处理....")
|
||||
} else {
|
||||
showInComingView(user)
|
||||
}
|
||||
@@ -121,7 +121,7 @@ internal class CallChatWindowManager {
|
||||
private val onCallInterrupt = object : OnCallingInterrupt {
|
||||
override fun invoke(isTeam: Boolean, user: UserInfo) {
|
||||
if (isTeam) {
|
||||
log(TAG, "车队邀请拒绝,不做处理....")
|
||||
Logger.d(TAG, "车队邀请拒绝,不做处理....")
|
||||
} else {
|
||||
onCallInterrupt()
|
||||
}
|
||||
@@ -152,7 +152,7 @@ internal class CallChatWindowManager {
|
||||
speak(REQUEST_CLOUD_VOICE_CALL)
|
||||
calling()
|
||||
} catch (t: Throwable) {
|
||||
log(TAG, "来电呼叫异常:$t")
|
||||
Logger.d(TAG, "来电呼叫异常:$t")
|
||||
}
|
||||
}.also { ring = it }
|
||||
answer.onClick {
|
||||
@@ -177,20 +177,20 @@ internal class CallChatWindowManager {
|
||||
timer = inComingTimer(user, incomingView)
|
||||
launch(Dispatchers.Main) {
|
||||
val d1 = async {
|
||||
log(TAG, "监听对方呼出,又挂断状态...")
|
||||
Logger.d(TAG, "监听对方呼出,又挂断状态...")
|
||||
var interrupted = interrupt.receive()
|
||||
while (!interrupted) {
|
||||
interrupted = interrupt.receive()
|
||||
}
|
||||
log(TAG, "收到对方呼出又挂断状态...")
|
||||
Logger.d(TAG, "收到对方呼出又挂断状态...")
|
||||
}
|
||||
val d2 = async {
|
||||
log(TAG, "监听拒绝状态...")
|
||||
Logger.d(TAG, "监听拒绝状态...")
|
||||
var isRefuse = refused.receive()
|
||||
while (!isRefuse) {
|
||||
isRefuse = refused.receive()
|
||||
}
|
||||
log(TAG, "收到拒绝状态, 隐藏来电界面")
|
||||
Logger.d(TAG, "收到拒绝状态, 隐藏来电界面")
|
||||
}
|
||||
val state = select<Int> {
|
||||
d1.onAwait { 1 }
|
||||
@@ -198,11 +198,11 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
when (state) {
|
||||
1 -> {
|
||||
log(TAG, "由于对方呼出又挂断,导致来电界面隐藏")
|
||||
Logger.d(TAG, "由于对方呼出又挂断,导致来电界面隐藏")
|
||||
d2.safeCancel()
|
||||
}
|
||||
2 -> {
|
||||
log(TAG, "由于自己主动拒接,导致来电界面隐藏")
|
||||
Logger.d(TAG, "由于自己主动拒接,导致来电界面隐藏")
|
||||
d1.safeCancel()
|
||||
}
|
||||
}
|
||||
@@ -278,9 +278,9 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
|
||||
private fun CoroutineScope.inComingTimer(user: UserInfo, incomingView: View) = launch {
|
||||
log(TAG, "延迟30s消失计时开始...")
|
||||
Logger.d(TAG, "延迟30s消失计时开始...")
|
||||
delay(DEFAULT_MAX_DIALING_TIME)
|
||||
log(TAG, "延迟30s消失计时结束...")
|
||||
Logger.d(TAG, "延迟30s消失计时结束...")
|
||||
doRefuse(user, false, incomingView, false)
|
||||
hide(incomingView)
|
||||
releaseAudioAndVoice()
|
||||
@@ -324,20 +324,20 @@ internal class CallChatWindowManager {
|
||||
isCallingShow = true
|
||||
launch(Dispatchers.Main) {
|
||||
val d1 = async {
|
||||
log(ChatConsts.TAG, "等着新用户进来...")
|
||||
Logger.d(ChatConsts.TAG, "等着新用户进来...")
|
||||
var isNewUserEnter = callerEnter.receive()
|
||||
while (!isNewUserEnter) {
|
||||
isNewUserEnter = callerEnter.receive()
|
||||
}
|
||||
//新用户进来了
|
||||
log(ChatConsts.TAG, "新用户进来了...")
|
||||
Logger.d(ChatConsts.TAG, "新用户进来了...")
|
||||
callingTimer()
|
||||
.collect {
|
||||
timer.text = parseTime(it)
|
||||
}
|
||||
}
|
||||
val d2 = async {
|
||||
log(ChatConsts.TAG, "等着退房通知...")
|
||||
Logger.d(ChatConsts.TAG, "等着退房通知...")
|
||||
var exit = exitRoom.receive()
|
||||
while (!exit) {
|
||||
exit = exitRoom.receive()
|
||||
@@ -349,10 +349,10 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
when (state) {
|
||||
1 -> {
|
||||
log(TAG, "通话中, 计时任务结束了(不般不会发生)...")
|
||||
Logger.d(TAG, "通话中, 计时任务结束了(不般不会发生)...")
|
||||
}
|
||||
2 -> {
|
||||
log(TAG, "收到退房通知,可以移除通话状态的界面了...")
|
||||
Logger.d(TAG, "收到退房通知,可以移除通话状态的界面了...")
|
||||
d1.safeCancel()
|
||||
}
|
||||
}
|
||||
@@ -459,7 +459,7 @@ internal class CallChatWindowManager {
|
||||
exitRoom()
|
||||
},
|
||||
onError = { code, msg, extra ->
|
||||
log(TAG, "-- 应答失败 --: code:: $code; msg:: $msg; extra:: $extra")
|
||||
Logger.d(TAG, "-- 应答失败 --: code:: $code; msg:: $msg; extra:: $extra")
|
||||
when (code) {
|
||||
AnswerState.CODE_ANSWER_SOCKET_DISCONNECT -> {
|
||||
ToastUtils.showShort("连接已断开")
|
||||
@@ -513,7 +513,7 @@ internal class CallChatWindowManager {
|
||||
onError.invoke(it.code, it.msg, it.extra)
|
||||
}
|
||||
else -> {
|
||||
log(ChatConsts.TAG, "[Answer][Other]-> $it")
|
||||
Logger.d(ChatConsts.TAG, "[Answer][Other]-> $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,7 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
},
|
||||
onError = { code, msg, extra ->
|
||||
log(TAG, "-- 拒绝失败 --: code:: $code; msg:: $msg; extra:: $extra")
|
||||
Logger.d(TAG, "-- 拒绝失败 --: code:: $code; msg:: $msg; extra:: $extra")
|
||||
if (isAnswerFail) {
|
||||
ToastUtils.showShort("应答异常")
|
||||
} else {
|
||||
@@ -569,7 +569,7 @@ internal class CallChatWindowManager {
|
||||
onError.invoke(itx.code, itx.msg, itx.extra)
|
||||
}
|
||||
else -> {
|
||||
log(ChatConsts.TAG, "[Refuse][Other]-> $it")
|
||||
Logger.d(ChatConsts.TAG, "[Refuse][Other]-> $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -581,10 +581,10 @@ internal class CallChatWindowManager {
|
||||
hangUp(
|
||||
user,
|
||||
onSuccess = {
|
||||
log(TAG, "挂断接口请求成功,等着退房...")
|
||||
Logger.d(TAG, "挂断接口请求成功,等着退房...")
|
||||
},
|
||||
onError = { code, msg, extra ->
|
||||
log(TAG, "挂断异常:code: $code; msg: $msg, ; extra: $extra")
|
||||
Logger.d(TAG, "挂断异常:code: $code; msg: $msg, ; extra: $extra")
|
||||
ToastUtils.showShort("挂断异常")
|
||||
})
|
||||
|
||||
@@ -638,14 +638,14 @@ internal class CallChatWindowManager {
|
||||
}
|
||||
is HangUpState.Error -> {
|
||||
hasHangUpped = false
|
||||
log(
|
||||
Logger.d(
|
||||
TAG,
|
||||
"-- 挂断失败 --: code:: ${itx.code}; msg:: ${itx.msg}; extra:: ${itx.extra}"
|
||||
)
|
||||
onError.invoke(itx.code, itx.msg, itx.extra)
|
||||
}
|
||||
else -> {
|
||||
log(ChatConsts.TAG, "[HangUp][Other]-> $it")
|
||||
Logger.d(ChatConsts.TAG, "[HangUp][Other]-> $it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
@file:JvmName("LogUtil")
|
||||
|
||||
package com.mogo.eagle.core.function.chat.facade.utils
|
||||
|
||||
import com.mogo.eagle.core.function.chat.facade.aop.DebugLog
|
||||
|
||||
|
||||
@DebugLog
|
||||
fun log(tag: String, msg: String) {}
|
||||
@@ -10,7 +10,7 @@ import com.mogo.commons.voice.IMogoVoiceCmdCallBack
|
||||
import com.mogo.eagle.core.function.api.chat.biz.IMoGoVoiceControlFacade
|
||||
import com.mogo.eagle.core.function.api.chat.biz.IMoGoVoiceControlFacade.IMoGoVoiceCallback
|
||||
import com.mogo.eagle.core.function.chat.facade.bridge.BridgeApi
|
||||
import com.mogo.eagle.core.function.chat.facade.utils.log
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -64,27 +64,27 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
||||
.forEach {
|
||||
when (itx) {
|
||||
VOICE_REGISTER_CANCEL_CALL -> {
|
||||
log(TAG, "语音免唤醒 取消打电话")
|
||||
Logger.d(TAG, "语音免唤醒 取消打电话")
|
||||
it.get()?.onVoiceCancelCall()
|
||||
}
|
||||
VOICE_REGISTER_INVITE_JOIN_TEAM -> {
|
||||
log(TAG, "语音免唤醒 邀請加入车队")
|
||||
Logger.d(TAG, "语音免唤醒 邀請加入车队")
|
||||
it.get()?.onVoiceInviteJoinTeam()
|
||||
}
|
||||
VOICE_REGISTER_JOIN_TEAM -> {
|
||||
log(TAG, "语音免唤醒 加入车队")
|
||||
Logger.d(TAG, "语音免唤醒 加入车队")
|
||||
it.get()?.onVoiceJoinTeam()
|
||||
}
|
||||
VOICE_REGISTER_REFUSE_JOIN_TEAM -> {
|
||||
log(TAG, "语音免唤醒 拒绝加入车队")
|
||||
Logger.d(TAG, "语音免唤醒 拒绝加入车队")
|
||||
it.get()?.onVoiceRefuseJoinTeam()
|
||||
}
|
||||
VOICE_INTENT_ANSWER_CALL -> {
|
||||
log(TAG, "语音免唤醒 接收电话邀请")
|
||||
Logger.d(TAG, "语音免唤醒 接收电话邀请")
|
||||
it.get()?.onVoiceAnswerCall()
|
||||
}
|
||||
VOICE_INTENT_REFUSE_CALL -> {
|
||||
log(TAG, "语音免唤醒 来电拒接")
|
||||
Logger.d(TAG, "语音免唤醒 来电拒接")
|
||||
it.get()?.onVoiceRefuseCall()
|
||||
}
|
||||
}
|
||||
@@ -125,14 +125,14 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
||||
}
|
||||
|
||||
override fun registerInviteJoinTeam(context: Context, listener: IMoGoVoiceCallback) {
|
||||
log(TAG, "registerInviteJoinTeam")
|
||||
Logger.d(TAG, "registerInviteJoinTeam")
|
||||
listeners += WeakReference(listener)
|
||||
AIAssist.getInstance(context)
|
||||
.registerUnWakeupCommand(VOICE_REGISTER_INVITE_JOIN_TEAM, customInviteJoinTeamArray, this)
|
||||
}
|
||||
|
||||
override fun registerJoinTeam(context: Context, listener: IMoGoVoiceCallback) {
|
||||
log(TAG, "registerJoinTeam")
|
||||
Logger.d(TAG, "registerJoinTeam")
|
||||
listeners += WeakReference(listener)
|
||||
AIAssist.getInstance(context)
|
||||
.registerUnWakeupCommand(VOICE_REGISTER_JOIN_TEAM, customJoinTeamArray, this)
|
||||
@@ -170,19 +170,19 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
||||
|
||||
override fun onCmdAction(speakText: String?) {
|
||||
super.onCmdAction(speakText)
|
||||
log(TAG, "onCmdAction ---> ")
|
||||
Logger.d(TAG, "onCmdAction ---> ")
|
||||
this@VoiceControlFacade.onCmdAgree?.get()?.invoke(true)
|
||||
}
|
||||
|
||||
override fun onCmdCancel(speakText: String?) {
|
||||
super.onCmdCancel(speakText)
|
||||
log(TAG, "onCmdCancel ---> ")
|
||||
Logger.d(TAG, "onCmdCancel ---> ")
|
||||
this@VoiceControlFacade.onCmdAgree?.get()?.invoke(false)
|
||||
}
|
||||
|
||||
override fun onSpeakEnd(speakText: String?) {
|
||||
super.onSpeakEnd(speakText)
|
||||
log(TAG, "onSpeakEnd ---> ")
|
||||
Logger.d(TAG, "onSpeakEnd ---> ")
|
||||
this@VoiceControlFacade.onSpeechFinish?.get()?.invoke()
|
||||
}
|
||||
})
|
||||
@@ -205,10 +205,10 @@ object VoiceControlFacade: IMoGoVoiceControlFacade, IMogoVoiceCmdCallBack, IMogo
|
||||
|
||||
override fun onIntentReceived(cmd: String?, intent: Intent?) {
|
||||
val command = cmd ?: return
|
||||
log(TAG, "handleOnIntentCmd: cmd -> $command")
|
||||
Logger.d(TAG, "handleOnIntentCmd: cmd -> $command")
|
||||
when (command) {
|
||||
VOICE_INTENT_CANCEL_CALL_COMMAND, VOICE_INTENT_REFUSE_CALL -> {
|
||||
log(TAG, "语音唤醒 取消打电话")
|
||||
Logger.d(TAG, "语音唤醒 取消打电话")
|
||||
listeners
|
||||
.filter {
|
||||
it.get() != null
|
||||
|
||||
@@ -65,7 +65,6 @@ import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Turning
|
||||
import com.mogo.eagle.core.function.call.monitor.CallerMonitorManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.function.call.telematic.CallerTelematicManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.notification.WarningFloat
|
||||
import com.mogo.eagle.core.function.hmi.notification.anim.DefaultAnimator
|
||||
@@ -74,7 +73,6 @@ import com.mogo.eagle.core.function.hmi.ui.bindingcar.ToBindingCarDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.bindingcar.UpgradeAppDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.camera.CameraListView
|
||||
import com.mogo.eagle.core.function.hmi.ui.camera.RoadVideoDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxBubbleView
|
||||
import com.mogo.eagle.core.function.hmi.ui.notice.NoticeCheckDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.notice.NoticeTrafficDialog
|
||||
import com.mogo.eagle.core.function.hmi.ui.setting.DebugSettingView
|
||||
@@ -87,7 +85,7 @@ import com.mogo.eagle.core.function.hmi.ui.tools.MaskView
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.DemoModeView
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.StatusBarView
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.V2XNotificationView
|
||||
import com.mogo.eagle.core.function.main.utils.DisplayEffectsHelper
|
||||
import com.mogo.eagle.core.function.main.DisplayEffectsHelper
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
@@ -101,7 +99,6 @@ import com.mogo.eagle.core.utilcode.reminder.api.impl.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils.millis2String
|
||||
import com.mogo.map.MogoMap
|
||||
import com.zhidao.support.adas.high.common.MogoReport.Code.Error.EMAP.*
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.consts.BadCaseConfig
|
||||
import com.zhjt.service_biz.BizConfig
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.main.utils;
|
||||
package com.mogo.eagle.core.function.main;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
@@ -46,7 +46,6 @@ import com.mogo.eagle.core.function.hmi.ui.widget.StatusBarView;
|
||||
import com.mogo.eagle.core.function.main.cards.MogoModulesManager;
|
||||
import com.mogo.eagle.core.function.main.service.MogoMainService;
|
||||
import com.mogo.eagle.core.function.main.stagetwo.AutopilotStartup;
|
||||
import com.mogo.eagle.core.function.main.utils.DisplayEffectsHelper;
|
||||
import com.mogo.eagle.core.function.main.windowview.FloatingViewHandler;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
@@ -10,7 +10,6 @@ import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Process;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
@@ -26,13 +25,12 @@ import com.mogo.eagle.core.function.api.base.IMoGoFunctionProvider;
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.hmi.R;
|
||||
import com.mogo.eagle.core.function.main.utils.MultiDisplayUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.MultiDisplayUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.rousetime.android_startup.model.CostTimesModel;
|
||||
|
||||
@@ -8,11 +8,11 @@ import android.util.Log;
|
||||
import androidx.core.util.Pools;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
package com.mogo.eagle.core.function.smp;
|
||||
|
||||
import com.amap.api.maps.AMapUtils;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.navi.model.NaviLatLng;
|
||||
import com.autonavi.amap.mapcore.IPoint;
|
||||
import com.autonavi.amap.mapcore.MapProjection;
|
||||
|
||||
/**
|
||||
* 包名: com.amap.navi.demo.util
|
||||
* <p>
|
||||
* 创建时间:2018/4/19
|
||||
* 项目名称:NaviDemo
|
||||
*
|
||||
* @author guibao.ggb
|
||||
* @email guibao.ggb@alibaba-inc.com
|
||||
* <p>
|
||||
* 类说明:
|
||||
*/
|
||||
public class NaviUtil {
|
||||
|
||||
public static float calculateDistance(NaviLatLng start, NaviLatLng end) {
|
||||
double x1 = start.getLongitude();
|
||||
double y1 = start.getLatitude();
|
||||
double x2 = end.getLongitude();
|
||||
double y2 = end.getLatitude();
|
||||
return AMapUtils.calculateLineDistance(new LatLng(y1, x1), new LatLng(y2, x2));
|
||||
}
|
||||
|
||||
|
||||
public static NaviLatLng getPointForDis(NaviLatLng sPt, NaviLatLng ePt, double dis) {
|
||||
double lSegLength = calculateDistance(sPt, ePt);
|
||||
NaviLatLng pt = new NaviLatLng();
|
||||
double preResult = dis / lSegLength;
|
||||
pt.setLatitude(((ePt.getLatitude() - sPt.getLatitude()) * preResult + sPt.getLatitude()));
|
||||
pt.setLongitude(((ePt.getLongitude() - sPt.getLongitude()) * preResult + sPt.getLongitude()));
|
||||
return pt;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度计算需要偏转的角度
|
||||
*
|
||||
* @param startPoi
|
||||
* @param secondPoi
|
||||
* @return
|
||||
*/
|
||||
public static float getRotate(NaviLatLng startPoi, NaviLatLng secondPoi) {
|
||||
float rotate = 0;
|
||||
try {
|
||||
IPoint point1 = new IPoint();
|
||||
IPoint point2 = new IPoint();
|
||||
MapProjection.lonlat2Geo(startPoi.getLongitude(), startPoi.getLatitude(), point1);
|
||||
MapProjection.lonlat2Geo(secondPoi.getLongitude(), secondPoi.getLatitude(), point2);
|
||||
double x1 = point1.x;
|
||||
double x2 = point2.x;
|
||||
double y1 = point1.y;
|
||||
double y2 = point2.y;
|
||||
rotate = (float) (Math.atan2(y2 - y1, x2 - x1) / Math.PI * 180);
|
||||
rotate = rotate + 90;
|
||||
return rotate;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return rotate;
|
||||
}
|
||||
|
||||
|
||||
public static final int MAXZOOMLEVEL = 20;
|
||||
public static final int PIXELSPERTILE = 256;
|
||||
public static final double MINLATITUDE = -85.0511287798;
|
||||
public static final double MAXLATITUDE = 85.0511287798;
|
||||
public static final double MINLONGITUDE = -180;
|
||||
public static final double MAXLONGITUDE = 180;
|
||||
public static final int EARTHRADIUSINMETERS = 6378137;
|
||||
public static final int TILESPLITLEVEL = 0;
|
||||
|
||||
|
||||
public static final double EarthCircumferenceInMeters = 2 * Math.PI
|
||||
* EARTHRADIUSINMETERS;
|
||||
|
||||
|
||||
public static double clip(double n, double minValue, double maxValue) {
|
||||
return Math.min(Math.max(n, minValue), maxValue);
|
||||
}
|
||||
|
||||
public static IPoint lonlat2Geo(double latitude, double longitude,
|
||||
int levelOfDetail) {
|
||||
IPoint rPnt = new IPoint();
|
||||
latitude = clip(latitude, MINLATITUDE, MAXLATITUDE) * Math.PI / 180;
|
||||
longitude = clip(longitude, MINLONGITUDE, MAXLONGITUDE) * Math.PI / 180;
|
||||
double sinLatitude = Math.sin(latitude);
|
||||
double xMeters = EARTHRADIUSINMETERS * longitude;
|
||||
double lLog = Math.log((1 + sinLatitude) / (1 - sinLatitude));
|
||||
double yMeters = EARTHRADIUSINMETERS / 2 * lLog;
|
||||
long numPixels = (long) PIXELSPERTILE << levelOfDetail;
|
||||
double metersPerPixel = EarthCircumferenceInMeters / numPixels;
|
||||
rPnt.x = (int) clip((EarthCircumferenceInMeters / 2 + xMeters)
|
||||
/ metersPerPixel + 0.5, 0, numPixels - 1);
|
||||
long tmp = (long) (EarthCircumferenceInMeters / 2 - yMeters);
|
||||
rPnt.y = (int) clip((double) tmp / metersPerPixel + 0.5, 0,
|
||||
numPixels - 1);
|
||||
return rPnt;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String formatKM(int d) {
|
||||
if (d == 0) {
|
||||
return "0米";
|
||||
} else if (d < 100) {
|
||||
return d + "米";
|
||||
} else if ((100 <= d) && (d < 1000)) {
|
||||
return d + "米";
|
||||
} else if ((1000 <= d) && (d < 10000)) {
|
||||
return (d / 10) * 10 / 1000.0D + "公里";
|
||||
} else if ((10000 <= d) && (d < 100000)) {
|
||||
return (d / 100) * 100 / 1000.0D + "公里";
|
||||
}
|
||||
return (d / 1000) + "公里";
|
||||
}
|
||||
}
|
||||
@@ -40,8 +40,8 @@ import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.eagle.core.widget.RoundLayout;
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -3,8 +3,9 @@ package com.mogo.eagle.core.function.v2x.events.alarm;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.DrivingDirectionUtils;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnum;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
|
||||
@@ -10,7 +10,6 @@ import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_CREATE
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
@@ -23,6 +22,7 @@ import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.V2X_EVENT_ALARM_P
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.overlay.*
|
||||
import io.netty.util.internal.*
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.mogo.eagle.core.function.v2x.events.scenario.scene.road
|
||||
import android.graphics.*
|
||||
import android.util.*
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.v2xMarker
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.R.raw
|
||||
import com.mogo.map.marker.*
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils;
|
||||
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/14 1:02 PM
|
||||
* desc : 计算车辆驾驶方向的工具类
|
||||
* version: 1.0
|
||||
*/
|
||||
public class DrivingDirectionUtils {
|
||||
|
||||
/**
|
||||
* 计算车辆行驶方向 与 poi点到车辆的连线 间的夹角
|
||||
*
|
||||
* @param carLon 车辆位置 lon
|
||||
* @param carLat 车辆位置 lat
|
||||
* @param poiLon poi 位置 lon
|
||||
* @param poiLat poi 位置 lat
|
||||
* @param carAngle 车辆行驶方向
|
||||
* @return
|
||||
*/
|
||||
public static int getDegreeOfCar2Poi(double carLon, double carLat, double poiLon, double poiLat, int carAngle) {
|
||||
int poiAngle = 0;
|
||||
// 以子午线作为y轴 计算两点的余切 再将余切值转化为角度
|
||||
double _angle = Math.atan2(Math.abs(carLon - poiLon), Math.abs(carLat - poiLat)) * (180 / PI);
|
||||
if (poiLon > carLon) {
|
||||
// poi 在 车辆位置的第1象限
|
||||
if (poiLat > carLat) {
|
||||
poiAngle = (int) _angle;
|
||||
}
|
||||
// poi 在 车辆位置的第2象限
|
||||
else {
|
||||
poiAngle = 180 - (int) _angle;
|
||||
}
|
||||
} else {
|
||||
// poi 在 车辆位置的第3象限
|
||||
if (poiLat < carLat) {
|
||||
poiAngle = (int) _angle + 180;
|
||||
}
|
||||
// poi 在 车辆位置的第4象限
|
||||
else {
|
||||
poiAngle = 360 - (int) _angle;
|
||||
}
|
||||
}
|
||||
return calculationAngle(poiAngle, carAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个行驶方向间的夹角 计算结果小于180度
|
||||
*
|
||||
* @param angle0
|
||||
* @param angle1
|
||||
* @return
|
||||
*/
|
||||
public static int calculationAngle(int angle0, int angle1) {
|
||||
// 获取两方向间夹角
|
||||
int angle = Math.abs(angle0 - angle1);
|
||||
if (angle > 180) {
|
||||
int minAngle = Math.min(angle0, angle1);
|
||||
int maxAngle = Math.max(angle0, angle1);
|
||||
return 180 - Math.abs(minAngle + 180 - maxAngle);
|
||||
} else {
|
||||
return angle;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算车辆行驶方向角度,起点&终点经纬度
|
||||
*
|
||||
* @param carLat 车辆位置 lat
|
||||
* @param carLon 车辆位置 lon
|
||||
* @param poiLat poi 位置 lat
|
||||
* @param poiLon poi 位置 lon
|
||||
*/
|
||||
public static int getCarAngle(double carLat, double carLon, double poiLat, double poiLon) {
|
||||
int poiAngle = 0;
|
||||
// 以子午线作为y轴 计算两点的余切 再将余切值转化为角度
|
||||
double _angle = Math.atan2(Math.abs(carLon - poiLon), Math.abs(carLat - poiLat)) * (180 / PI);
|
||||
|
||||
if (poiLon > carLon) {
|
||||
// poi 在 车辆位置的第1象限
|
||||
if (poiLat > carLat) {
|
||||
poiAngle = (int) _angle;
|
||||
}
|
||||
// poi 在 车辆位置的第2象限
|
||||
else {
|
||||
poiAngle = 180 - (int) _angle;
|
||||
}
|
||||
} else {
|
||||
// poi 在 车辆位置的第3象限
|
||||
if (poiLat < carLat) {
|
||||
poiAngle = (int) _angle + 180;
|
||||
}
|
||||
// poi 在 车辆位置的第4象限
|
||||
else {
|
||||
poiAngle = 360 - (int) _angle;
|
||||
}
|
||||
}
|
||||
|
||||
if (poiAngle >= 355) {
|
||||
poiAngle = 0;
|
||||
}
|
||||
return poiAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算连两个角度差值
|
||||
*
|
||||
* @param angle1 角度1
|
||||
* @param angle2 角度2
|
||||
* @return 差值
|
||||
*/
|
||||
public static double getAngleDiff(double angle1, double angle2) {
|
||||
// 两个角度差值较小
|
||||
return 180 - Math.abs(Math.abs(angle1 - angle2) - 180);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.coroutinescore
|
||||
implementation rootProject.ext.dependencies.coroutinesandroid
|
||||
implementation rootProject.ext.dependencies.androidautoSize
|
||||
implementation rootProject.ext.dependencies.litezxing
|
||||
|
||||
api rootProject.ext.dependencies.mogoaicloudpassport
|
||||
api rootProject.ext.dependencies.mogoaicloudnetwork
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.notice.utils
|
||||
package com.mogo.eagle.core.utilcode.util
|
||||
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.commons.utils;
|
||||
package com.mogo.eagle.core.utilcode.util;
|
||||
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.main.utils
|
||||
package com.mogo.eagle.core.utilcode.util
|
||||
|
||||
import android.app.ActivityOptions
|
||||
import android.content.Context
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.notice.utils
|
||||
package com.mogo.eagle.core.utilcode.util
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.mogo.eagle.core.function.notice.utils
|
||||
package com.mogo.eagle.core.utilcode.util
|
||||
|
||||
import android.graphics.Bitmap
|
||||
import com.google.zxing.EncodeHintType
|
||||
Reference in New Issue
Block a user