Commit ffcc2b94 by yjiucheng

声网日志

parent cd835900
...@@ -205,6 +205,7 @@ dependencies { ...@@ -205,6 +205,7 @@ dependencies {
// implementation project(':m-muse') // implementation project(':m-muse')
implementation project(':m-im') implementation project(':m-im')
implementation project(':m-dynamic') implementation project(':m-dynamic')
implementation project(':m-audioim')
// api rootProject.ext.dependencies["ydl-m-fm-module-ydl"] // api rootProject.ext.dependencies["ydl-m-fm-module-ydl"]
......
ext { ext {
kotlin_version = "1.3.21" kotlin_version = "1.3.21"
dev_mode = false dev_mode = true
ydl_app = [ ydl_app = [
appName : "心理咨询壹点灵", appName : "心理咨询壹点灵",
......
...@@ -24,6 +24,22 @@ import android.view.animation.AccelerateInterpolator ...@@ -24,6 +24,22 @@ import android.view.animation.AccelerateInterpolator
import com.alibaba.android.arouter.facade.annotation.Route import com.alibaba.android.arouter.facade.annotation.Route
import com.google.gson.Gson import com.google.gson.Gson
import com.tbruyelle.rxpermissions2.RxPermissions import com.tbruyelle.rxpermissions2.RxPermissions
import com.ydl.audioim.bean.AgoraLogInfoBean
import com.ydl.audioim.contract.IAudioHomeActivityContract
import com.ydl.audioim.http.command.ConnectCommand
import com.ydl.audioim.http.command.ConnectExceptionCommand
import com.ydl.audioim.http.command.NoticePushCommand
import com.ydl.audioim.http.command.PayLoad
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.utils.AudioLogUtils
import com.ydl.audioim.utils.DateUtils
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.burypointlib.ToastUtil
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.ydl_av.messge_service.ChannelManager import com.ydl.ydl_av.messge_service.ChannelManager
import com.ydl.ydl_av.messge_service.YDLRTMClient import com.ydl.ydl_av.messge_service.YDLRTMClient
import com.ydl.ydl_av.messge_service.bean.RTMMesssage import com.ydl.ydl_av.messge_service.bean.RTMMesssage
...@@ -36,22 +52,12 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler ...@@ -36,22 +52,12 @@ import com.ydl.ydl_av.voice.listener.IYDLVoiceEventHandler
import com.ydl.ydl_av.voice.manager.YDLVoiceManager import com.ydl.ydl_av.voice.manager.YDLVoiceManager
import com.ydl.ydl_image.config.SimpleImageOpConfiger import com.ydl.ydl_image.config.SimpleImageOpConfiger
import com.ydl.ydl_image.manager.YDLImageCacheManager import com.ydl.ydl_image.manager.YDLImageCacheManager
import com.ydl.ydl_av.chat.bean.AudioMessageBean
import com.ydl.audioim.contract.IAudioHomeActivityContract
import com.ydl.audioim.http.command.*
import com.ydl.audioim.player.AudioPlayer
import com.ydl.audioim.presenter.AudioHomePresenterImpl
import com.ydl.audioim.utils.DateUtils
import com.ydl.audioim.widget.AxbConfirmDialog
import com.ydl.burypointlib.ToastUtil
import com.ydl.webview.H5Params
import com.ydl.webview.NewH5Activity
import com.ydl.webview.RefreshWebEvent
import com.ydl.ydlcommon.base.BaseMvpActivity import com.ydl.ydlcommon.base.BaseMvpActivity
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.router.YdlCommonRouterManager import com.ydl.ydlcommon.router.YdlCommonRouterManager
import com.ydl.ydlcommon.utils.LogUtil import com.ydl.ydlcommon.utils.LogUtil
import com.ydl.ydlcommon.utils.StatusBarUtils import com.ydl.ydlcommon.utils.StatusBarUtils
import com.ydl.ydlcommon.utils.log.LogHelper
import com.ydl.ydlcommon.utils.remind.ToastHelper import com.ydl.ydlcommon.utils.remind.ToastHelper
import com.yidianling.user.api.service.IUserService import com.yidianling.user.api.service.IUserService
import de.greenrobot.event.EventBus import de.greenrobot.event.EventBus
...@@ -72,7 +78,8 @@ import java.util.concurrent.TimeUnit ...@@ -72,7 +78,8 @@ import java.util.concurrent.TimeUnit
* @date 2018/10/30 * @date 2018/10/30
*/ */
@Route(path = "/av/AudioHomeActivity") @Route(path = "/av/AudioHomeActivity")
class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(),IAudioHomeActivityContract.View, SensorEventListener { class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudioHomeActivityContract.Presenter>(),
IAudioHomeActivityContract.View, SensorEventListener {
/** /**
* 专家头像地址 * 专家头像地址
...@@ -93,7 +100,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -93,7 +100,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
/** /**
* 通话开始时间(接通) * 通话开始时间(接通)
*/ */
private var callStartTime:Long? = null private var callStartTime: Long? = null
/** /**
* 倾诉剩余时长(时长单位s,eg:剩余2min15s,返回135) * 倾诉剩余时长(时长单位s,eg:剩余2min15s,返回135)
*/ */
...@@ -161,9 +168,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -161,9 +168,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private var voiceManage: YDLVoiceManager? = null private var voiceManage: YDLVoiceManager? = null
//频道管理器 //频道管理器
private var channelManager : ChannelManager? = null private var channelManager: ChannelManager? = null
private var isLeavelChannel:Boolean = false private var isLeavelChannel: Boolean = false
/** /**
* 声网事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等) * 声网事件回调 (SDK 通过指定的事件通知应用程序 SDK 的运行事件,如: 加入或离开频道,新用户加入频道等)
...@@ -186,6 +193,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -186,6 +193,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
when (warn) { when (warn) {
103, 104, 105, 106, 107 -> { 103, 104, 105, 106, 107 -> {
showToast("当前网络较差,请更换网络!") showToast("当前网络较差,请更换网络!")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel() leaveChannel()
} }
} }
...@@ -255,6 +264,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -255,6 +264,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断 //因为用户端直接加入了频道,防止该回调执行时,专家还未加入频道,因此在连接成功之后,才进行频道人数判断
if (isConnectSuccess && null != stats?.users && stats.users == 1) { if (isConnectSuccess && null != stats?.users && stats.users == 1) {
com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断") com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel() leaveChannel()
} }
} }
...@@ -264,6 +275,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -264,6 +275,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
// 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑 // 3 网络连接被服务器中止 该情况现在是因为后端踢人逻辑
if (reason == 3) { if (reason == 3) {
com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断") com.yidianling.common.tools.ToastUtil.toastShort("专家已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel() leaveChannel()
} }
} }
...@@ -271,6 +284,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -271,6 +284,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onLeaveChannel(stats: IRtcEngineEventHandler.RtcStats?) { override fun onLeaveChannel(stats: IRtcEngineEventHandler.RtcStats?) {
super.onLeaveChannel(stats) super.onLeaveChannel(stats)
LogUtil.e("[agora]离开频道回调") LogUtil.e("[agora]离开频道回调")
//通话结束或挂断时,上传日志文件
uploadLog()
} }
override fun onLastmileQuality(quality: Int) { override fun onLastmileQuality(quality: Int) {
...@@ -296,6 +311,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -296,6 +311,8 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onUserOffline(uid: Int, elapsed: Int) { override fun onUserOffline(uid: Int, elapsed: Int) {
super.onUserOffline(uid, elapsed) super.onUserOffline(uid, elapsed)
LogUtil.e("[agora]远端用户$uid 离开频道回调") LogUtil.e("[agora]远端用户$uid 离开频道回调")
//通话结束或挂断时,上传日志文件
uploadLog()
showToast("专家已挂断") showToast("专家已挂断")
if (totalDisposable != null) { if (totalDisposable != null) {
...@@ -315,7 +332,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -315,7 +332,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private fun uploadException(message: String) { private fun uploadException(message: String) {
var time: String = (System.currentTimeMillis() / 1000).toString() var time: String = (System.currentTimeMillis() / 1000).toString()
var uid: String = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!! var uid: String = ModularServiceManager.provide(IUserService::class.java).getUserInfo()?.uid!!
var payLoad = PayLoad(channelId?:"0", time, uid, "1", "999", message) var payLoad = PayLoad(channelId ?: "0", time, uid, "1", "999", message)
var connectException = ConnectExceptionCommand(time, "2", "99", payLoad) var connectException = ConnectExceptionCommand(time, "2", "99", payLoad)
getPresenter().connectException(connectException) getPresenter().connectException(connectException)
} }
...@@ -371,11 +388,36 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -371,11 +388,36 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID) listenId = intent.getStringExtra(IntentConstants.INTENT_LISTEN_ID)
commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL) commentUrl = intent.getStringExtra(IntentConstants.INTENT_COMMENT_URL)
writeAgoraLog()
localRemainTime = remainTime?.toInt() localRemainTime = remainTime?.toInt()
handler = Handler() handler = Handler()
vibrator = getSystemService(Service.VIBRATOR_SERVICE) as Vibrator? vibrator = getSystemService(Service.VIBRATOR_SERVICE) as Vibrator?
} }
private fun writeAgoraLog(){
val logBean = AgoraLogInfoBean(
expertHeadUrl,
expertName,
channelId,
remainTime,
listenerUid,
totalDuration,
callId,
listenId
)
Observable.create<Any> {
try {
val content = Gson().toJson(logBean)
AudioLogUtils.writeAgoraLog(content)
} catch (e: Exception) {
}
}.subscribeOn(Schedulers.io())
.subscribe()
}
private fun initView() { private fun initView() {
tv_change_route.isEnabled = false tv_change_route.isEnabled = false
//水波纹view初始化 //水波纹view初始化
...@@ -441,7 +483,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -441,7 +483,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private fun setCallBack() { private fun setCallBack() {
YDLRTMClient.instances.setCallListener(object :CallListener{ YDLRTMClient.instances.setCallListener(object : CallListener {
override fun onCallRecivedByPeer(response: CallLocalResponse?) { override fun onCallRecivedByPeer(response: CallLocalResponse?) {
//返回给主叫:被叫已收到呼叫邀请 //返回给主叫:被叫已收到呼叫邀请
LogUtil.i("[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}") LogUtil.i("[agora]${response?.calleeId}已收到呼叫邀请,频道号${response?.ChannelId}")
...@@ -455,7 +497,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -455,7 +497,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onCallRefused(response: CallLocalResponse?) { override fun onCallRefused(response: CallLocalResponse?) {
//返回给主叫 //返回给主叫
LogUtil.i("[agora]${response?.calleeId}已拒绝呼叫邀请") LogUtil.i("[agora]${response?.calleeId}已拒绝呼叫邀请")
ToastUtil.showToast(applicationContext,"对方已挂断") ToastUtil.showToast(applicationContext, "对方已挂断")
//通话结束或挂断时,上传日志文件
uploadLog()
leaveChannel() leaveChannel()
} }
...@@ -498,7 +542,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -498,7 +542,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
LogUtil.i("[agora]其它消息:${error}") LogUtil.i("[agora]其它消息:${error}")
} }
}) })
channelManager = YDLRTMClient.instances.createChannelManager(channelId,object :ChannelListener{ channelManager = YDLRTMClient.instances.createChannelManager(channelId, object : ChannelListener {
override fun onMemberCountUpdated(memberCount: Int) { override fun onMemberCountUpdated(memberCount: Int) {
//频道人数更新 //频道人数更新
LogUtil.i("[agora]当前频道人数:$memberCount") LogUtil.i("[agora]当前频道人数:$memberCount")
...@@ -506,7 +550,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -506,7 +550,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onMessageReceived(message: RTMMesssage?, member: ChannelMember?) { override fun onMessageReceived(message: RTMMesssage?, member: ChannelMember?) {
//接到频道消息 //接到频道消息
LogUtil.i("[agora]接到${member?.channelId}频道${member?.userId}的消息:"+message?.text) LogUtil.i("[agora]接到${member?.channelId}频道${member?.userId}的消息:" + message?.text)
} }
override fun onMemberJoined(member: ChannelMember?) { override fun onMemberJoined(member: ChannelMember?) {
...@@ -527,22 +571,22 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -527,22 +571,22 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
private fun requestPermission() { private fun requestPermission() {
val rxPermissions = RxPermissions(this) val rxPermissions = RxPermissions(this)
rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO) rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO)
.subscribe { permission -> .subscribe { permission ->
if (permission.granted) { if (permission.granted) {
init() init()
} else if (permission.shouldShowRequestPermissionRationale) { } else if (permission.shouldShowRequestPermissionRationale) {
requestPermission() requestPermission()
} else { } else {
ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint)) ToastHelper.show(getString(R.string.audioim_need_storage_permission_hint))
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
val uri = Uri.fromParts("package", packageName, null) val uri = Uri.fromParts("package", packageName, null)
intent.data = uri intent.data = uri
startActivity(intent) startActivity(intent)
finish() finish()
}
} }
}
} }
@SuppressLint("CheckResult") @SuppressLint("CheckResult")
...@@ -552,39 +596,42 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -552,39 +596,42 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
initializeAgoraEngine() initializeAgoraEngine()
//发起呼叫 //发起呼叫
var msgBean = AudioMessageBean( var msgBean = AudioMessageBean(
1, 1,
channelId!!, channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(), remainTime!!.toInt(),
relationId, relationId,
callId, callId,
null, null,
channelId channelId
) )
YDLRTMClient.instances.call(listenerUid!!,channelId,Gson().toJson(msgBean)) YDLRTMClient.instances.call(listenerUid!!, channelId, Gson().toJson(msgBean))
//开始25s等待倒计时 //开始25s等待倒计时
Observable.interval(0, 100, TimeUnit.MILLISECONDS) Observable.interval(0, 100, TimeUnit.MILLISECONDS)
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.take(253) .take(253)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
progress_view.setProgress(it.toFloat() / 2.5f) progress_view.setProgress(it.toFloat() / 2.5f)
}, { }, {
LogUtil.d(it.message) LogUtil.d(it.message)
}, { }, {
waittingStatus() waittingStatus()
if (!isConnectSuccess){ if (!isConnectSuccess) {
// iv_hang_up.setImageResource(R.mipmap.audioim_ico_close) // iv_hang_up.setImageResource(R.mipmap.audioim_ico_close)
//关闭音乐 //关闭音乐
stopPlaying() stopPlaying()
//提示切换传统线路 //提示切换传统线路
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid,channelId) YDLRTMClient.instances.cancelCall(listenerUid, channelId)
showChooseDialog(2) //通话结束或挂断时,上传日志文件
} uploadLog()
})
showChooseDialog(2)
}
})
//加入频道135 //加入频道135
joinChannel() joinChannel()
//双重保险:加入频道成功,通过服务端发推送给专家 //双重保险:加入频道成功,通过服务端发推送给专家
...@@ -611,7 +658,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -611,7 +658,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* 声网加入频道 * 声网加入频道
*/ */
private fun joinChannel() { private fun joinChannel() {
voiceManage!!.getVoiceApi().joinChannel(token!!, channelId!!, "Extra Optional Data", YdlCommonRouterManager.getYdlCommonRoute().getUid()) voiceManage!!.getVoiceApi().joinChannel(
token!!,
channelId!!,
"Extra Optional Data",
YdlCommonRouterManager.getYdlCommonRoute().getUid()
)
} }
/** /**
...@@ -621,7 +673,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -621,7 +673,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
*/ */
private fun userCloseCalling() { private fun userCloseCalling() {
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid,channelId) YDLRTMClient.instances.cancelCall(listenerUid, channelId)
//通话结束或挂断时,上传日志文件
uploadLog()
handler!!.postDelayed({ handler!!.postDelayed({
leaveChannel() leaveChannel()
}, 100) }, 100)
...@@ -633,7 +687,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -633,7 +687,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* @param finishStatus 状态值: 0:开始 1:结束 * @param finishStatus 状态值: 0:开始 1:结束
*/ */
private fun updateExpertStatus(isSwitchAxb: Boolean, finishStatus: Int) { private fun updateExpertStatus(isSwitchAxb: Boolean, finishStatus: Int) {
if (isSwitchAxb){ if (isSwitchAxb) {
dialPhone() dialPhone()
} }
...@@ -659,9 +713,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -659,9 +713,9 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
/** /**
* 线路选择弹窗 * 线路选择弹窗
*/ */
private fun showChooseDialog(type:Int) { private fun showChooseDialog(type: Int) {
val dialog = AxbConfirmDialog(mContext,type, object : AxbConfirmDialog.OnClickEnsureListener { val dialog = AxbConfirmDialog(mContext, type, object : AxbConfirmDialog.OnClickEnsureListener {
override fun onClickEnsure() { override fun onClickEnsure() {
switchAXB() switchAXB()
} }
...@@ -681,7 +735,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -681,7 +735,7 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
* 切换成axb路线请求 * 切换成axb路线请求
*/ */
private fun switchAXB() { private fun switchAXB() {
mPresenter.getAXBPhone(ConnectCommand(listenId!!,"1")) mPresenter.getAXBPhone(ConnectCommand(listenId!!, "1"))
} }
/** /**
...@@ -692,12 +746,14 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -692,12 +746,14 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
this.axbPhone = axbPhone this.axbPhone = axbPhone
isJumpDail = true isJumpDail = true
if (isConnectSuccess) { if (isConnectSuccess) {
//通话结束或挂断时,上传日志文件
uploadLog()
//已经连接成功,切换axb时需要更新专家状态 //已经连接成功,切换axb时需要更新专家状态
updateExpertStatus(true, 1) updateExpertStatus(true, 1)
} else { } else {
//未连接成功,切换axb时:需发送消息通知专家端用户已挂断 //未连接成功,切换axb时:需发送消息通知专家端用户已挂断
//发送消息通知专家用户已挂断 //发送消息通知专家用户已挂断
YDLRTMClient.instances.cancelCall(listenerUid,channelId) YDLRTMClient.instances.cancelCall(listenerUid, channelId)
leaveChannel() leaveChannel()
} }
} }
...@@ -730,7 +786,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -730,7 +786,12 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
tv_change_route.isEnabled = true tv_change_route.isEnabled = true
tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.platform_white)) tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.platform_white))
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow), null) tv_change_route.setCompoundDrawablesWithIntrinsicBounds(
null,
null,
ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow),
null
)
} }
...@@ -851,32 +912,39 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -851,32 +912,39 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//剩余倾诉时长倒计时 //剩余倾诉时长倒计时
totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS) totalDisposable = Observable.interval(0, 1, TimeUnit.SECONDS)
.subscribeOn(Schedulers.computation()) .subscribeOn(Schedulers.computation())
.take(remainTime!!.toLong() + 1) .take(remainTime!!.toLong() + 1)
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe({ .subscribe({
localRemainTime = remainTime!!.toInt() - it.toInt() localRemainTime = remainTime!!.toInt() - it.toInt()
if (localRemainTime == 180) { if (localRemainTime == 180) {
playNoticeMusic(3) playNoticeMusic(3)
} }
if (localRemainTime == 60) { if (localRemainTime == 60) {
playNoticeMusic(1) playNoticeMusic(1)
} }
if (localRemainTime!! <= 60) { if (localRemainTime!! <= 60) {
if (tv_change_route.isEnabled) { if (tv_change_route.isEnabled) {
tv_change_route.isEnabled = false tv_change_route.isEnabled = false
tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.audioim_color_50ffffff)) tv_change_route.setTextColor(ContextCompat.getColor(this, R.color.audioim_color_50ffffff))
tv_change_route.setCompoundDrawablesWithIntrinsicBounds(null, null, ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow_unuse), null) tv_change_route.setCompoundDrawablesWithIntrinsicBounds(
} null,
null,
ContextCompat.getDrawable(this, R.drawable.audioim_img_choose_arrow_unuse),
null
)
} }
tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString()) }
}, { tv_remain_time.text = DateUtils.formatTime(localRemainTime.toString())
LogUtil.d(it.message) }, {
}, { LogUtil.d(it.message)
//注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口 }, {
showToast("通话已结束") //注意:自动挂断时,如果对方离开频道的回调已经触发,就不要再重复调用接口
updateExpertStatus(false, 1) showToast("通话已结束")
}) //通话结束或挂断时,上传日志文件
uploadLog()
updateExpertStatus(false, 1)
})
} }
/** /**
...@@ -907,16 +975,16 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -907,16 +975,16 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
*/ */
private fun noticeServerPush(isCall: Boolean) { private fun noticeServerPush(isCall: Boolean) {
var msgBean = AudioMessageBean( var msgBean = AudioMessageBean(
1, 1,
channelId!!, channelId!!,
YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(), YdlCommonRouterManager.getYdlCommonRoute().getUid().toString(),
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.headUrl,
YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName, YdlCommonRouterManager.getYdlCommonRoute().getUserInfo()!!.userName,
remainTime!!.toInt(), remainTime!!.toInt(),
relationId, relationId,
callId, callId,
null, null,
channelId channelId
) )
var cmd = NoticePushCommand() var cmd = NoticePushCommand()
cmd.data = msgBean cmd.data = msgBean
...@@ -946,7 +1014,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -946,7 +1014,11 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
sensorManager!!.registerListener(this, sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY), SensorManager.SENSOR_DELAY_NORMAL) sensorManager!!.registerListener(
this,
sensorManager!!.getDefaultSensor(Sensor.TYPE_PROXIMITY),
SensorManager.SENSOR_DELAY_NORMAL
)
} }
override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) { override fun onAccuracyChanged(sensor: Sensor?, accuracy: Int) {
...@@ -984,14 +1056,14 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -984,14 +1056,14 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
//// tv_toast.postDelayed({ //// tv_toast.postDelayed({
//// tv_toast.visibility = View.GONE //// tv_toast.visibility = View.GONE
//// }, 1000) //// }, 1000)
ToastHelper.show(msg?:"") ToastHelper.show(msg ?: "")
} }
} }
override fun showProgressView() { override fun showProgressView() {
try { try {
showProgressDialog() showProgressDialog()
}catch (e : Exception){ } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
...@@ -1000,12 +1072,16 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi ...@@ -1000,12 +1072,16 @@ class AudioHomeActivity : BaseMvpActivity<IAudioHomeActivityContract.View, IAudi
override fun dismissProgressView() { override fun dismissProgressView() {
try { try {
dismissProgressDialog() dismissProgressDialog()
}catch (e:Exception){ } catch (e: Exception) {
e.printStackTrace() e.printStackTrace()
} }
} }
private fun uploadLog(){
LogHelper.getInstance().uploadLog(false)
}
override fun finishActivity() { override fun finishActivity() {
leaveChannel() leaveChannel()
} }
......
package com.ydl.audioim.bean
/**
* @author jiucheng
* @描述:
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/2/12
*/
class AgoraLogInfoBean(
/**
* 专家头像地址
*/
private var expertHeadUrl: String? = null,
/**
* 专家姓名
*/
private var expertName: String? = null,
/**
* 声网点对点聊天房间id
*/
private var channelId: String? = null,
/**
* 倾诉剩余时长(时长单位s,eg:剩余2min15s,返回135)
*/
private var remainTime: String? = null,
/**
* listenerUid专家uid
*/
private var listenerUid: String? = null,
/**
* 倾述总时长
*/
private var totalDuration: Int? = 0,
/**
* callId
*/
private var callId: String? = null,
/**
*聆听者id(不是聆听者的uid)
*/
private var listenId: String? = null
)
\ No newline at end of file
package com.ydl.audioim.utils
import android.annotation.SuppressLint
import com.ydl.audioim.BuildConfig
import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.modular.ModularServiceManager
import com.yidianling.common.tools.LogUtil
import com.yidianling.common.tools.RxAppTool
import com.yidianling.common.tools.RxDeviceTool
import com.yidianling.common.tools.RxNetTool
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
import java.io.BufferedWriter
import java.io.File
import java.io.FileWriter
import java.io.IOException
import java.text.SimpleDateFormat
import java.util.*
/**
* @author jiucheng
* @描述:记录声网双方信息相关的日志工具
* @Copyright Copyright (c) 2018
* @Company 壹点灵
* @date 2020/2/12
*/
class AudioLogUtils {
companion object {
@SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeAgoraLog(content: String) {
Observable.create<Any> {
try {
writeLog(content)
if (BuildConfig.DEBUG) {
LogUtil.d("writeLog_complete")
}
} catch (e: Exception) {
}
}.subscribeOn(Schedulers.io())
.subscribe()
}
private fun writeLog(content: String) {
try {
val folder = getLogFolder()
val file = File(folder, "AgoraInfoLog")
if (!file.exists() || !file.isFile) {
file.createNewFile()
}
val fileWriter = FileWriter(file, true)
val writer = BufferedWriter(fileWriter)
writer.write("""Time:${format.format(Calendar.getInstance().time)}""")
writer.newLine()
writer.write("UserUid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}")
writer.newLine()
writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""")
writer.newLine()
writer.write("""DevicesInfo:${RxDeviceTool.getBuildBrandModel()},${RxDeviceTool.getSDKVersionName()}""")
writer.newLine()
writer.write("""VersionInfo:${RxAppTool.getAppVersionName(BaseApp.getApp())}""")
writer.newLine()
writer.write("AgoraLog:$content")
writer.newLine()
writer.write("--------")
writer.newLine()
writer.flush()
writer.close()
} catch (e: IOException) {
e.printStackTrace()
}
}
//获取app运行日志文件夹
private fun getLogFolder(): File {
val cacheDir = BaseApp.getApp().externalCacheDir.absolutePath
val logFolder = File(cacheDir, "log")
if (!logFolder.exists() || !logFolder.isDirectory) {
logFolder.mkdir()
}
val folder = File(logFolder, "NewYdlApp")
if (!folder.exists() || !folder.isDirectory) {
folder.mkdir()
}
return folder
}
}
}
\ No newline at end of file
package com.ydl.ydlcommon.utils.log package com.ydl.ydlcommon.utils.log
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.util.Log import android.util.Log
import com.yidianling.common.tools.*
import com.ydl.ydlcommon.base.BaseApp import com.ydl.ydlcommon.base.BaseApp
import com.ydl.ydlcommon.data.PlatformDataManager import com.ydl.ydlcommon.data.PlatformDataManager
import com.ydl.ydlcommon.data.http.LogParam import com.ydl.ydlcommon.data.http.LogParam
import com.ydl.ydlcommon.data.http.ThrowableConsumer import com.ydl.ydlcommon.data.http.ThrowableConsumer
import com.ydl.ydlcommon.modular.ModularServiceManager import com.ydl.ydlcommon.modular.ModularServiceManager
import com.ydl.ydlcommon.utils.FileUtils import com.ydl.ydlcommon.utils.FileUtils
import com.yidianling.common.tools.*
import io.reactivex.Observable import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.functions.Consumer import io.reactivex.functions.Consumer
...@@ -40,13 +40,13 @@ class LogHelper private constructor() { ...@@ -40,13 +40,13 @@ class LogHelper private constructor() {
} catch (e: Exception) { } catch (e: Exception) {
} }
}.subscribeOn(Schedulers.io()) }.subscribeOn(Schedulers.io())
.subscribe() .subscribe()
} }
/** /**
* 删除过期日志 * 删除过期日志
*/ */
fun deleteExpireLog() { private fun deleteExpireLog() {
val files = getLogFolder().listFiles() val files = getLogFolder().listFiles()
val calendar = Calendar.getInstance() val calendar = Calendar.getInstance()
calendar.add(Calendar.WEEK_OF_YEAR, -1) calendar.add(Calendar.WEEK_OF_YEAR, -1)
...@@ -59,7 +59,9 @@ class LogHelper private constructor() { ...@@ -59,7 +59,9 @@ class LogHelper private constructor() {
} }
} }
@SuppressLint("SimpleDateFormat")
private val dateFormat = SimpleDateFormat("yyyyMMdd") private val dateFormat = SimpleDateFormat("yyyyMMdd")
@SuppressLint("SimpleDateFormat")
private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") private val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss")
fun writeLogSync(content: String) { fun writeLogSync(content: String) {
...@@ -73,7 +75,7 @@ class LogHelper private constructor() { ...@@ -73,7 +75,7 @@ class LogHelper private constructor() {
} catch (e: Exception) { } catch (e: Exception) {
} }
}.subscribeOn(Schedulers.io()) }.subscribeOn(Schedulers.io())
.subscribe() .subscribe()
} }
private fun writeLog(content: String, className: String, methodName: String, line: Int) { private fun writeLog(content: String, className: String, methodName: String, line: Int) {
...@@ -82,7 +84,7 @@ class LogHelper private constructor() { ...@@ -82,7 +84,7 @@ class LogHelper private constructor() {
val writer = BufferedWriter(fileWriter) val writer = BufferedWriter(fileWriter)
writer.write("""Time:${format.format(Calendar.getInstance().time)}""") writer.write("""Time:${format.format(Calendar.getInstance().time)}""")
writer.newLine() writer.newLine()
writer.write("UserInfo:uid = ${ ModularServiceManager.getPlatformUserService()?.getUser()?.userId}") writer.write("UserInfo:uid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}")
writer.newLine() writer.newLine()
writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""") writer.write("""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}""")
writer.newLine() writer.newLine()
...@@ -108,30 +110,33 @@ class LogHelper private constructor() { ...@@ -108,30 +110,33 @@ class LogHelper private constructor() {
} }
fun uploadLog(showToast:Boolean) { @SuppressLint("CheckResult")
fun uploadLog(showToast: Boolean) {
Observable.create<File> { Observable.create<File> {
it.onNext(zip()) it.onNext(zip())
it.onComplete() it.onComplete()
}.subscribeOn(Schedulers.io()) }.subscribeOn(Schedulers.io())
.flatMap { PlatformDataManager.getHttp().uploadLog( .flatMap {
PlatformDataManager.getHttp().uploadLog(
LogParam( LogParam(
it it
) )
) } )
.observeOn(AndroidSchedulers.mainThread()) }
.subscribe(Consumer { .observeOn(AndroidSchedulers.mainThread())
if (showToast){ .subscribe(Consumer {
ToastUtil.toastShort(it.msg) if (showToast) {
} ToastUtil.toastShort(it.msg)
Log.d("TAG", "") }
}, object : ThrowableConsumer() { Log.d("TAG", "")
override fun accept(msg: String) { }, object : ThrowableConsumer() {
if (showToast){ override fun accept(msg: String) {
ToastUtil.toastShort(msg) if (showToast) {
} ToastUtil.toastShort(msg)
Log.d("TAG", msg)
} }
}) Log.d("TAG", msg)
}
})
} }
...@@ -153,18 +158,18 @@ class LogHelper private constructor() { ...@@ -153,18 +158,18 @@ class LogHelper private constructor() {
if (zipFile.exists()) zipFile.delete() if (zipFile.exists()) zipFile.delete()
zipFile.createNewFile() zipFile.createNewFile()
if (appLog.exists()){ if (appLog.exists()) {
files.add(appLog) files.add(appLog)
} }
if (yunxinLog.exists()){ if (yunxinLog.exists()) {
files.add(yunxinLog) files.add(yunxinLog)
} }
if (agoraLog.exists()){ if (agoraLog.exists()) {
files.add(agoraLog) files.add(agoraLog)
} }
// ZipUtils.toZip(getLogFolder().absolutePath, FileOutputStream(zipFile), true) // ZipUtils.toZip(getLogFolder().absolutePath, FileOutputStream(zipFile), true)
ZipUtils.toZip(files,FileOutputStream(zipFile)) ZipUtils.toZip(files, FileOutputStream(zipFile))
return zipFile return zipFile
} }
...@@ -213,14 +218,15 @@ class LogHelper private constructor() { ...@@ -213,14 +218,15 @@ class LogHelper private constructor() {
} }
//获取云信日志路径 //获取云信日志路径
private fun getYunXinLog(context: Context):File{ private fun getYunXinLog(context: Context): File {
val yunxin = FileUtils.getSDDirectory()+"/"+context.packageName+"/nim/log" val yunxin = FileUtils.getSDDirectory() + "/" + context.packageName + "/nim/log"
LogUtil.d(yunxin) LogUtil.d(yunxin)
return File(yunxin) return File(yunxin)
} }
//获取声网日志 //获取声网日志
private fun getAgoraLog(context: Context):File{ private fun getAgoraLog(context: Context): File {
val agora = FileUtils.getSDDirectory()+"/"+context.packageName+"/agorasdk.log" val agora = FileUtils.getSDDirectory() + "/" + context.packageName + "/agorasdk.log"
return File(agora) return File(agora)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment