[6.2.6] sp opt , update aicloud upload loc thread

This commit is contained in:
EmArrow
2024-01-03 16:31:29 +08:00
parent 74824c1eba
commit 6729fe50af
135 changed files with 649 additions and 792 deletions

View File

@@ -6,7 +6,7 @@ import android.os.Looper
import android.text.TextUtils
import com.google.gson.Gson
import com.mogo.eagle.core.function.chat.facade.gme.GMEApi
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.data.chat.UserInfo
import com.mogo.eagle.core.data.chat.socket.Message
import com.mogo.eagle.core.data.chat.socket.TeammateInfo
@@ -198,7 +198,7 @@ object MoGoChatFacade: IMoGoChatFacade {
}
} else {
val message = withContext(Dispatchers.Default) { Gson().fromJson(msg, Message::class.java) } ?: return@launch
if (message.type.toCallType() == CALL_TYPE_VOICE && message.snSender == MoGoAiCloudClientConfig.getInstance().sn) {
if (message.type.toCallType() == CALL_TYPE_VOICE && message.snSender == SharedPrefsMgr.getInstance().sn) {
return@launch
}
when(message.status) {
@@ -209,7 +209,8 @@ object MoGoChatFacade: IMoGoChatFacade {
if (GMEApi.isRoomEntered() && callType == CALL_TYPE_VEHICLE_TEAM) {
Logger.d(ChatConsts.TAG, "收到来电进房消息,此时正在车队通话。需要挂断电话")
try {
serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, message.snSender, message.roomId, PUSH_MSG_HANG_UP, message.type))
serverApi.requestConnectStatus(ConnectStatusParam(
SharedPrefsMgr.getInstance().sn, message.snSender, message.roomId, PUSH_MSG_HANG_UP, message.type))
} catch (t : Throwable) {
t.printStackTrace()
}
@@ -221,7 +222,7 @@ object MoGoChatFacade: IMoGoChatFacade {
CALL_TYPE_VEHICLE_TEAM -> {
if (callStatus.isReadyCalling()) {
try {
serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, message.snSender, message.roomId, PUSH_MSG_HANG_UP, message.type))
serverApi.requestConnectStatus(ConnectStatusParam(SharedPrefsMgr.getInstance().sn, message.snSender, message.roomId, PUSH_MSG_HANG_UP, message.type))
} catch (t : Throwable) {
t.printStackTrace()
}
@@ -241,7 +242,7 @@ object MoGoChatFacade: IMoGoChatFacade {
Logger.d(ChatConsts.TAG, "已经进房,收到被拒绝消息,则不处理(为兼容车队需求),否则会引发退房操作")
return@launch
}
if (callStatus == READY_TO_CALL_RECEIVER && message.snReceiver == MoGoAiCloudClientConfig.getInstance().sn) {
if (callStatus == READY_TO_CALL_RECEIVER && message.snReceiver == SharedPrefsMgr.getInstance().sn) {
//如果当前是来电状态,并且收到拒绝消息,说明呼叫方呼出又挂断
Logger.d(ChatConsts.TAG, "呼叫方呼出后,又挂断")
onCallingInterrupt?.get()?.invoke(false, message.toUser())
@@ -251,7 +252,7 @@ object MoGoChatFacade: IMoGoChatFacade {
channel4SocketMsg.send(message)
}
CALL_TYPE_VEHICLE_TEAM -> {
if (callStatus == READY_TO_CALL_RECEIVER && message.snReceiver == MoGoAiCloudClientConfig.getInstance().sn) {
if (callStatus == READY_TO_CALL_RECEIVER && message.snReceiver == SharedPrefsMgr.getInstance().sn) {
//如果当前是来电状态,并且收到拒绝消息,说明呼叫方呼出又挂断
onCallingInterrupt?.get()?.invoke(true, message.toUser())
callStatus = INIT_CALL
@@ -274,7 +275,7 @@ object MoGoChatFacade: IMoGoChatFacade {
if (callStatus.isCalling()) {
//如果正在通话, 直接拒接
try {
serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, message.snSender, message.roomId, PUSH_MSG_DENY_ENTER, message.type))
serverApi.requestConnectStatus(ConnectStatusParam(SharedPrefsMgr.getInstance().sn, message.snSender, message.roomId, PUSH_MSG_DENY_ENTER, message.type))
} catch (t: Throwable) {
t.printStackTrace()
}
@@ -322,7 +323,7 @@ object MoGoChatFacade: IMoGoChatFacade {
send(CallState.Error(CallState.CODE_USER_IN_ROOM, "[Call] - 当前用户已经进入房间了"))
return@channelFlow
}
if (params.sn == MoGoAiCloudClientConfig.getInstance().sn) {
if (params.sn == SharedPrefsMgr.getInstance().sn) {
send(CallState.Error(CallState.CODE_CALL_MYSELF, "[Call] - 不能呼叫自己"))
return@channelFlow
}
@@ -341,7 +342,7 @@ object MoGoChatFacade: IMoGoChatFacade {
}
if (mySelf.get() == null || mySelf.get().isIncomplete()) {
try {
val pair = serverApi.queryUserInfo(MoGoAiCloudClientConfig.getInstance().sn)
val pair = serverApi.queryUserInfo(SharedPrefsMgr.getInstance().sn)
if (pair == null || pair.first != null || pair.second == null) {
send(CallState.Error(CallState.CODE_CALLER_USER_INFO_FAIL, "[Call] - 获取用户信息失败 - ${pair?.first?.msg}"))
return@channelFlow
@@ -557,7 +558,7 @@ object MoGoChatFacade: IMoGoChatFacade {
send(AnswerState.Error(AnswerState.CODE_ANSWER_STATE_ERROR, "[Answer] - 应答状态错误 -> 当前状态:${callStatus.toText()}"))
return@channelFlow
}
val mySn = MoGoAiCloudClientConfig.getInstance().sn
val mySn = SharedPrefsMgr.getInstance().sn
if (TextUtils.isEmpty(mySn)) {
send(AnswerState.Error(AnswerState.CODE_ANSWER_PARAMS_INCOMPLETE, "[Answer] - 当前用户/应答方- sn参数不存在"))
return@channelFlow
@@ -568,7 +569,7 @@ object MoGoChatFacade: IMoGoChatFacade {
}
if (mySelf.get() == null || mySelf.get().isIncomplete()) {
try {
val pair = serverApi.queryUserInfo(MoGoAiCloudClientConfig.getInstance().sn)
val pair = serverApi.queryUserInfo(SharedPrefsMgr.getInstance().sn)
if (pair == null || pair.first != null || pair.second == null) {
send(AnswerState.Error(AnswerState.CODE_CALLER_USER_INFO_FAIL, "[Answer] - 获取应答方用户信息失败"))
return@channelFlow
@@ -582,7 +583,7 @@ object MoGoChatFacade: IMoGoChatFacade {
//告之服务器给发送方下发接收通话消息
try {
val location = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
val response = serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, sn, roomId, PUSH_MSG_AGREE_ENTER, CALL_TYPE_VOICE.type).also {
val response = serverApi.requestConnectStatus(ConnectStatusParam(SharedPrefsMgr.getInstance().sn, sn, roomId, PUSH_MSG_AGREE_ENTER, CALL_TYPE_VOICE.type).also {
it.nickName = mySelf.get().name
it.headImgUrl = mySelf.get().icon
it.carInfo = mySelf.get().brand
@@ -725,7 +726,7 @@ object MoGoChatFacade: IMoGoChatFacade {
return@flow
}
try {
val response = serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, sn, roomId, PUSH_MSG_HANG_UP, callType.type))
val response = serverApi.requestConnectStatus(ConnectStatusParam(SharedPrefsMgr.getInstance().sn, sn, roomId, PUSH_MSG_HANG_UP, callType.type))
val code = response.code
if (code != 0 && code != 200) {
emit(HangUpState.Error(HangUpState.CODE_HANG_UP_API_ERROR, response.msg, mutableMapOf<String, String>().also {
@@ -753,7 +754,7 @@ object MoGoChatFacade: IMoGoChatFacade {
return@flow
}
try {
val response = serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, sn, 0, PUSH_MSG_DENY_ENTER, callType.type))
val response = serverApi.requestConnectStatus(ConnectStatusParam(SharedPrefsMgr.getInstance().sn, sn, 0, PUSH_MSG_DENY_ENTER, callType.type))
val code = response.code
if (code != 0 && code != 200) {
emit(RefuseState.Error(RefuseState.CODE_REFUSE_API_ERROR, response.msg, mutableMapOf<String, String>().also {
@@ -779,7 +780,7 @@ object MoGoChatFacade: IMoGoChatFacade {
send(InviteState.Error(InviteState.CODE_INVITE_STATE_ERROR, "[InviteTeam] - 当前正在语音通话"))
return@channelFlow
}
val mySn = MoGoAiCloudClientConfig.getInstance().sn
val mySn = SharedPrefsMgr.getInstance().sn
if (TextUtils.isEmpty(mySn)){
send(InviteState.Error(InviteState.CODE_INVITE_SN_NOT_IN, "[InviteTeam] - 当前车机sn不存在"))
return@channelFlow
@@ -929,7 +930,7 @@ object MoGoChatFacade: IMoGoChatFacade {
send(JoinState.Error(JoinState.CODE_INVITE_STATE_ERROR, "[JoinTeam]-当前车机不是来电状态: status -> ${callStatus.toText()}"))
return@channelFlow
}
val mySn = MoGoAiCloudClientConfig.getInstance().sn
val mySn = SharedPrefsMgr.getInstance().sn
if (TextUtils.isEmpty(mySn)){
send(JoinState.Error(JoinState.CODE_JOIN_SN_NOT_IN, "[JoinTeam] - 当前车机sn不存在"))
return@channelFlow
@@ -944,7 +945,7 @@ object MoGoChatFacade: IMoGoChatFacade {
}
if (mySelf.get() == null || mySelf.get().isIncomplete()) {
try {
val pair = serverApi.queryUserInfo(MoGoAiCloudClientConfig.getInstance().sn)
val pair = serverApi.queryUserInfo(SharedPrefsMgr.getInstance().sn)
if (pair == null || pair.first != null || pair.second == null) {
send(JoinState.Error(JoinState.CODE_CALLER_USER_INFO_FAIL, "[JoinTeam] - 获取呼叫方用户信息失败"))
return@channelFlow
@@ -959,7 +960,7 @@ object MoGoChatFacade: IMoGoChatFacade {
//告之服务器给发送方下发接收通话消息
try {
val location = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
val response = serverApi.requestConnectStatus(ConnectStatusParam(MoGoAiCloudClientConfig.getInstance().sn, sn, roomId, PUSH_MSG_AGREE_ENTER, CALL_TYPE_VEHICLE_TEAM.type).also {
val response = serverApi.requestConnectStatus(ConnectStatusParam(SharedPrefsMgr.getInstance().sn, sn, roomId, PUSH_MSG_AGREE_ENTER, CALL_TYPE_VEHICLE_TEAM.type).also {
it.nickName = mySelf.get().name
it.headImgUrl = mySelf.get().icon
it.carInfo = mySelf.get().brand

View File

@@ -2,8 +2,8 @@ package com.mogo.eagle.core.function.chat.facade.net
import com.google.gson.Gson
import com.google.gson.JsonObject
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.constants.HostConst
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.data.BaseResponse
import com.mogo.eagle.core.data.chat.UserInfo
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
@@ -67,13 +67,13 @@ internal class ChatServiceModel {
suspend fun requestConnectStatus(params: ConnectStatusParam): BaseResponse<Any> {
val map = hashMapOf<String, String>()
val sn = MoGoAiCloudClientConfig.getInstance().sn
val sn = SharedPrefsMgr.getInstance().sn
val location = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
params.lon = location.longitude
params.lat = location.latitude
Logger.d(ChatConsts.TAG, "connectStatusParam:$params")
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
map["sn"] = SharedPrefsMgr.getInstance().sn
map["data"] = Gson().toJson(params)
return if (params.type == CALL_TYPE_VOICE.type) {
apiCall {
@@ -91,7 +91,7 @@ internal class ChatServiceModel {
suspend fun inviteJoinVehicleTeam(param: CallRequestParam): BaseResponse<Any> {
val map = hashMapOf<String, String>()
Logger.d(ChatConsts.TAG, "inviteJoinVehicleTeam paras: $param")
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
map["sn"] = SharedPrefsMgr.getInstance().sn
map["data"] = Gson().toJson(param)
return apiCall {
getNetWorkApi()?.inviteJoinVehicleTeam(map)

View File

@@ -1,7 +1,7 @@
package com.mogo.eagle.core.function.chat.facade.socket
import com.google.gson.Gson
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.commons.storage.SharedPrefsMgr
import com.mogo.eagle.core.data.chat.socket.HeartBeat
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts
import com.mogo.eagle.core.function.chat.facade.consts.ChatHttp
@@ -47,13 +47,13 @@ internal object SocketConnectManager {
private val socketMsgSetting: ISocketMsgSetting = object : ISocketMsgSetting {
override fun getHandShakeMsg(): String {
Logger.d(ChatConsts.TAG, "getHandShakeMsg")
val socketMsg = HeartBeat(SOCKET_HAND_SHAKE, MoGoAiCloudClientConfig.getInstance().sn)
val socketMsg = HeartBeat(SOCKET_HAND_SHAKE, SharedPrefsMgr.getInstance().sn)
return Gson().toJson(socketMsg)
}
override fun getHeartBeatMsg(): String {
Logger.d(ChatConsts.TAG, "getHeartBeatMsg")
val socketMsg = HeartBeat(SOCKET_HEART_BEAT, MoGoAiCloudClientConfig.getInstance().sn, roomId.get())
val socketMsg = HeartBeat(SOCKET_HEART_BEAT, SharedPrefsMgr.getInstance().sn, roomId.get())
return Gson().toJson(socketMsg)
}
}