Bläddra i källkod

删除掉一些无用资源,去掉mcu心跳,防止频繁重启,升级版本到1.1.3

weizhengliang 3 år sedan
förälder
incheckning
cbf54b1a24

+ 2 - 2
build.gradle

@@ -47,12 +47,12 @@ buildscript {
     /**
      * APP版本码
      */
-    ext.app_version_code = 3
+    ext.app_version_code = 2
 
     /**
      * APP版本号
      */
-    ext.app_version = "1.1.3"
+    ext.app_version = "1.1.2"
 
     /**
      * 项目依赖库

BIN
callingdoor/src/main/assets/launch.apk


+ 4 - 8
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/activity/CallingdoorActivity.kt

@@ -160,7 +160,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
         if ("rk3128".equals(Build.MODEL) || "rk3368".equals(Build.MODEL) || "WDMK_I".equals(Build.MODEL) || "WDMKI".equals(Build.MODEL)) {
             //串口监听
             setSerialListener()
-            SerialPortHelper.startHeartBeat()
+            //SerialPortHelper.startHeartBeat()
 
             Thread {
                 try {
@@ -249,7 +249,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
     }
 
     //检查launch版本
-    private fun checkLaunch() {
+    /*private fun checkLaunch() {
         Log.d(TAG, "start check launch")
         val pm = packageManager
         val packageInfo = pm.getInstalledPackages(0)
@@ -309,7 +309,7 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
             copyDone = false
             e.printStackTrace()
         }
-    }
+    }*/
 
 
     private fun checkServer() {
@@ -887,18 +887,14 @@ class CallingdoorActivity :BaseActivity<CallingdoorActivityPresenter, Callingdoo
                 UpdateTipsDialogHelper.showDialog(activity)
             } else {
                 if (!Constant.APP_UPDATING) {
-                    showMessage("正在升级...")
+                    //showMessage("正在升级...")
                     Constant.APP_UPDATING = true
                     Constant.APP_PATH = appInfo.appPath
                     AppTool.Time.delay(200) {
                         push("/callingdoor/update")
                     }
-                } else {
-                    showMessage("正在升级中...")
                 }
             }
-        } else {
-            showMessage("当前已是最新版本")
         }
     }
 

+ 0 - 2
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/di/CallingdoorComponent.kt

@@ -14,7 +14,5 @@ interface CallingdoorComponent {
 
     fun inject(fragment: MainFragment)
 
-    fun inject(fragment: CallFragment)
-
     fun inject(fragment: QrCodeFragment)
 }

+ 0 - 357
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/fragment/CallFragment.kt

@@ -1,357 +0,0 @@
-package com.wdkl.app.ncs.callingdoor.fragment
-
-import android.os.CountDownTimer
-import android.os.SystemClock
-import android.util.Log
-import android.view.View
-import com.enation.javashop.net.engine.model.NetState
-import com.google.gson.Gson
-import com.wdkl.app.ncs.callingdoor.R
-import com.wdkl.app.ncs.callingdoor.databinding.VoiceCallLayBinding
-import com.wdkl.app.ncs.callingdoor.helper.MediaPlayHelper
-import com.wdkl.app.ncs.callingdoor.launch.CallingdoorLaunch
-import com.wdkl.app.ncs.callingdoor.settings.SettingConfig
-//import com.wdkl.app.ncs.sip.event.AEvent
-//import com.wdkl.app.ncs.sip.event.IEventListener
-//import com.wdkl.app.ncs.sip.helper.StarRtcHelper
-import com.wdkl.ncs.android.lib.base.BaseFragment
-import com.wdkl.ncs.android.lib.utils.errorLog
-import com.wdkl.ncs.android.lib.utils.showMessage
-import com.wdkl.ncs.android.lib.vo.filter
-import com.wdkl.ncs.android.middleware.common.Constant
-import com.wdkl.ncs.android.middleware.common.MessageEvent
-import com.wdkl.ncs.android.middleware.logic.contract.callingdoor.CallFragmentContract
-import com.wdkl.ncs.android.middleware.logic.presenter.callingdoor.MainFragmentPresenter
-import com.wdkl.ncs.android.middleware.model.vo.InteractionVO
-import com.wdkl.ncs.android.middleware.tcp.channel.VoiceUtil
-import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel
-import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction
-import kotlinx.android.synthetic.main.voice_call_lay.*
-import org.greenrobot.eventbus.EventBus
-import org.greenrobot.eventbus.Subscribe
-import org.greenrobot.eventbus.ThreadMode
-
-class CallFragment : BaseFragment<MainFragmentPresenter, VoiceCallLayBinding>(), CallFragmentContract.View/*, IEventListener*/ {
-    val TAG = "CallFragment"
-
-    //通话状态:0-去电, 1-来电, 2-接通, 3-挂断
-    var callState : Int = 0
-    //呼叫倒计时
-    lateinit var countDownTimer: CountDownTimer
-    //来电设备id
-    var fromId: Int = -1
-    //目的设备id
-    var toId: Int = -1
-    //Sip通话目标设备id
-    var sipTargetId: String = ""
-    //Interaction ID
-    var interactionId: Int = -1
-    //去电铃声id
-    //var outCallStreamId: Int = -1
-    //来电铃声id
-    //var inCallStreamId: Int = -1
-
-
-    override fun getLayId(): Int {
-        return R.layout.voice_call_lay
-    }
-
-    override fun bindDagger() {
-        CallingdoorLaunch.component.inject(this)
-    }
-
-    override fun init() {
-        initCountDownTimer()
-        //StarRtcHelper.getInstance().addAudioCallListeners(this)
-
-        when (callState) {
-            0 -> {
-                //去电
-                sendCall()
-                VoiceUtil.startAudioCall(Constant.DEVICE_ID)
-                //播放铃音
-                MediaPlayHelper.getInstance().playResMusic(R.raw.outgoing_call, 0.6f, true)
-            }
-
-            1 -> {
-                //来电
-                incomingCall()
-                //播放铃声
-                MediaPlayHelper.getInstance().playResMusic(R.raw.incoming_call, 1.0f, true)
-            }
-
-            2 -> {
-                //接通
-                //acceptCall()
-            }
-
-            3 -> {
-                //挂断
-                //rejectCall()
-            }
-        }
-    }
-
-    override fun bindEvent() {
-        //去电或正在通话界面挂断按钮
-        voice_call_hangup.setOnClickListener {
-            //挂断通话,返回首页
-            if (Constant.CALL_STATE == Constant.CALL_CALLING) {
-                Constant.CALL_STATE = Constant.CALL_STANDBY
-                //StarRtcHelper.getInstance().hangupAudioCall()
-                VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, interactionId)
-                backToMain()
-            } else {
-                Constant.CALL_STATE = Constant.CALL_STANDBY
-                VoiceUtil.cancelAudioCall(Constant.DEVICE_ID)
-                cancelCall()
-            }
-        }
-        //来电界面挂断按钮
-        voice_call_ring_hangoff.setOnClickListener {
-            //挂断通话,返回首页
-            MediaPlayHelper.getInstance().stopMusic()
-            Constant.CALL_STATE = Constant.CALL_STANDBY
-            VoiceUtil.rejectAudioCall(Constant.DEVICE_ID, fromId, interactionId)
-            backToMain()
-        }
-        //来电界面接听按钮
-        voice_call_ring_pickup_audio.setOnClickListener {
-            //接收通话,向主叫方发出已接听的TCP消息,主叫方接收该消息后向我发起sip通话请求,我自动接听sip通话
-            Log.d("wzlll", "pickup call state: " + Constant.CALL_STATE + ", my id: " + Constant.DEVICE_ID + ", from id: " + fromId + ", interaction id: " + interactionId + ", target sip: " + sipTargetId)
-            MediaPlayHelper.getInstance().stopMusic()
-            //if (!TextUtils.isEmpty(sipTargetId)) {
-                Constant.CALL_STATE = Constant.CALL_INCOMING
-                VoiceUtil.acceptAudioCall(Constant.DEVICE_ID, fromId, interactionId)
-            //}
-        }
-    }
-
-    override fun onStart() {
-        EventBus.getDefault().register(this)
-        super.onStart()
-    }
-
-    override fun onStop() {
-        EventBus.getDefault().unregister(this)
-        super.onStop()
-    }
-
-    override fun destory() {
-        countDownTimer.cancel()
-        if (Constant.CALL_STATE == Constant.CALL_CALLING) {
-            //StarRtcHelper.getInstance().hangupAudioCall()
-            VoiceUtil.handoffAudioCall(Constant.DEVICE_ID, fromId, interactionId)
-        }
-        Constant.CALL_STATE = Constant.CALL_STANDBY
-        //StarRtcHelper.getInstance().removeAudioCallListeners(this)
-        MediaPlayHelper.getInstance().stopMusic()
-    }
-
-    override fun onError(message: String, type: Int) {
-        getUtils().dismissDialog()
-        errorLog("error",message)
-        showMessage(message)
-    }
-
-    override fun complete(message: String, type: Int) {
-        getUtils().dismissDialog()
-    }
-
-    override fun start() {
-        getUtils().showDialog()
-    }
-
-    override fun networkMonitor(state: NetState) {
-        state.filter(onWifi = {
-
-        },onMobile = {
-
-        },offline = {
-
-        })
-    }
-
-/*    override fun dispatchEvent(aEventID: String, success: Boolean, eventObj: Any) {
-        Log.d("wzlll", "call state: " + Constant.CALL_STATE)
-        Log.d("wzlll", "received sip event: " + aEventID + ", success: " + success + ", event obj: " + eventObj.toString())
-        when (aEventID) {
-            AEvent.AEVENT_VOIP_REV_CALLING_AUDIO -> {
-                //分机呼叫主机,主机接听,同时发送sip通话请求,分机自动接听
-                if (Constant.CALL_STATE != Constant.CALL_CALLING) {
-                    MediaPlayHelper.getInstance().stopMusic()
-                    StarRtcHelper.getInstance().pickupAudioCall(activity, eventObj.toString())
-                    activity.runOnUiThread {
-                        acceptCall()
-                    }
-                }
-            }
-            AEvent.AEVENT_VOIP_REV_CALLING -> {
-                //语音通话请求
-                //if (Constant.CALL_STATE != Constant.CALL_CALLING) {
-                //    StarRtcHelper.getInstance().pickupAudioCall(activity, eventObj.toString())
-                //    activity.runOnUiThread {
-                //                        acceptCall()
-                //                    }
-                //}
-            }
-            AEvent.AEVENT_VOIP_REV_BUSY -> {
-                //对方线路忙
-                activity.runOnUiThread {
-                    //rejectCall()
-                    showMessage("线路忙!")
-                }
-            }
-
-            AEvent.AEVENT_VOIP_REV_REFUSED -> {
-                //对方拒绝通话
-                activity.runOnUiThread {
-                    //rejectCall()
-                }
-            }
-
-            AEvent.AEVENT_VOIP_REV_HANGUP -> {
-                //对方已挂断
-                activity.runOnUiThread {
-                    if (Constant.CALL_STATE == Constant.CALL_CALLING) {
-                        rejectCall()
-                    }
-                }
-            }
-
-            AEvent.AEVENT_VOIP_REV_CONNECT -> {
-                //对方接受通话
-                activity.runOnUiThread {
-                    //showMessage("通话成功!")
-                    //acceptCall()
-                }
-            }
-
-            AEvent.AEVENT_VOIP_REV_ERROR -> {
-                //通话错误
-                activity.runOnUiThread {
-                    //showMessage("通话错误!")
-                    rejectCall()
-                }
-            }
-        }
-    }*/
-
-    fun initCountDownTimer() {
-        val overTime = SettingConfig.getSipOverTime(getActivity()) * 1000L
-        countDownTimer = object: CountDownTimer(overTime, 1000) {
-            override fun onTick(millisUntilFinished: Long) {
-                val time = millisUntilFinished/1000
-                voice_call_timeout?.setText("呼叫倒计时: " + time + " 秒")
-            }
-
-            override fun onFinish() {
-                //呼叫超时,返回到主界面
-                showMessage("无人应答...")
-                MediaPlayHelper.getInstance().stopMusic()
-                VoiceUtil.cancelAudioCall(Constant.DEVICE_ID)
-                backToMain()
-            }
-        }
-    }
-
-    @Subscribe(threadMode = ThreadMode.MAIN)
-    fun onMoonEvent(messageEvent: MessageEvent) {
-        when (messageEvent.getType()) {
-            Constant.EVENT_TCP_MSG -> {
-                val tcpModel = messageEvent.message as TcpModel
-                if (tcpModel.getAction() == TcpAction.VoiceAction.ACCEPT) { //我方呼出,对方接受
-                    //todo: 通话中界面更新;建立数据通话
-                    val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
-                    interactionId = interactionVO.id
-                    fromId = tcpModel.fromId
-                    //acceptCall()
-                } else if (tcpModel.getAction() == TcpAction.VoiceAction.REJECT) { //我方呼出,对方拒绝
-                    //todo: 清掉呼出的TcpModel,通话中界面更新 --- 显示对方拒绝并停留3秒,结束至正常界面;更新左侧
-                    showMessage("对方已拒绝!")
-                    rejectCall()
-                } else if (tcpModel.getAction() == TcpAction.VoiceAction.CALLING) { //我方呼出,对方通话中
-                    //todo: 清掉呼出的TcpModel,通话中界面更新 --- 显示对方占线并停留3秒,结束至正常界面;更新左侧
-                    //对于分机来说,对方处于通话中应当还是可以正常呼叫,而不应该直接挂断
-                    //showMessage("对方处于通话中!")
-                    //rejectCall()
-                } else if (tcpModel.getAction() == TcpAction.VoiceAction.SUCCESS) { //呼叫成功
-                    val interactionVO = Gson().fromJson(tcpModel.data.toString(), InteractionVO::class.java)
-                    interactionId = interactionVO.id
-                    voice_call_calling_text.setText("呼叫成功,等待接听中...")
-                } else if (tcpModel.getAction() == TcpAction.VoiceAction.FAILED) { //我方呼出,对方不在线,设备离线或其它错误
-                    //todo: 清掉呼出的TcpModel,通话中界面更新 --- 显示对方离线并停留3秒,结束至正常界面;更新左侧
-                    showMessage("呼叫失败,对方可能不在线!")
-                    MediaPlayHelper.getInstance().stopMusic()
-                    rejectCall()
-                } else if (tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) { //对方挂断,不论我方呼出或呼入
-                    //todo: 清掉呼出的TcpModel,通话中界面更新 --- 显示对方已挂断并停留3秒,结束至正常界面;更新左侧
-                    //showMessage("通话结束!")
-                    MediaPlayHelper.getInstance().stopMusic()
-                    rejectCall()
-                } else if (tcpModel.getAction() == TcpAction.VoiceAction.CANCEL) {
-                    //对方呼叫时取消
-                    MediaPlayHelper.getInstance().stopMusic()
-                    cancelCall()
-                }
-            }
-        }
-    }
-
-    //呼叫
-    fun sendCall() {
-        Constant.CALL_STATE = Constant.CALL_OUTGOING
-        voice_call_calling_text.setText("正在呼叫...")
-        voice_call_hangup_view.visibility = View.VISIBLE
-        voice_call_ring_view.visibility = View.GONE
-        voice_call_timer.visibility = View.GONE
-        voice_call_timeout.visibility = View.VISIBLE
-        countDownTimer.start()
-    }
-
-    //来电
-    fun incomingCall() {
-        Constant.CALL_STATE = Constant.CALL_INCOMING
-        countDownTimer.cancel()
-        voice_call_calling_text.setText("有新的来电...")
-        voice_call_hangup_view.visibility = View.GONE
-        voice_call_ring_view.visibility = View.VISIBLE
-        voice_call_timer.visibility = View.GONE
-        voice_call_timeout.visibility = View.GONE
-    }
-
-    //接通
-    fun acceptCall() {
-        Constant.CALL_STATE = Constant.CALL_CALLING
-        countDownTimer.cancel()
-        voice_call_calling_text.setText("通话中...")
-        voice_call_hangup_view.visibility = View.VISIBLE
-        voice_call_ring_view.visibility = View.GONE
-        voice_call_timer.visibility = View.VISIBLE
-        voice_call_timeout.visibility = View.GONE
-        voice_call_timer.base = SystemClock.elapsedRealtime()
-        voice_call_timer.start()
-    }
-
-    //挂断通话
-    fun rejectCall() {
-        Constant.CALL_STATE = Constant.CALL_STANDBY
-        countDownTimer.cancel()
-        voice_call_timer.base = SystemClock.elapsedRealtime()
-        voice_call_timer.stop()
-        backToMain()
-    }
-
-    //呼叫取消
-    fun cancelCall() {
-        Constant.CALL_STATE = Constant.CALL_STANDBY
-        countDownTimer.cancel()
-        voice_call_timer.base = SystemClock.elapsedRealtime()
-        voice_call_timer.stop()
-        backToMain()
-    }
-
-    private fun backToMain() {
-        EventBus.getDefault().post(MessageEvent("BackToMain", Constant.EVENT_BACK_MAIN))
-    }
-}

+ 1 - 0
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/AppUpdateHelper.java

@@ -203,6 +203,7 @@ public class AppUpdateHelper {
         Process process;
         PrintWriter printWriter;
         try {
+            Log.e(TAG, "start install: " + FILE_APK_NAME);
             String cmd1 = "chmod 777 " + FILE_APK_PATH;
             String cmd2 = "chmod 777 " + FILE_APK_PATH + "/" + FILE_APK_NAME;
             Runtime runtime = Runtime.getRuntime();

+ 4 - 8
callingdoor/src/main/java/com/wdkl/app/ncs/callingdoor/helper/SoundPoolManager.java

@@ -33,7 +33,7 @@ public class SoundPoolManager {
         if(Build.VERSION.SDK_INT > 21){
             SoundPool.Builder builder = new SoundPool.Builder();
             //传入音频数量
-            builder.setMaxStreams(4);
+            builder.setMaxStreams(1);
             //AudioAttributes是一个封装音频各种属性的方法
             AudioAttributes.Builder attrBuilder = new AudioAttributes.Builder();
             //设置音频流的合适的属性
@@ -42,16 +42,12 @@ public class SoundPoolManager {
             builder.setAudioAttributes(attrBuilder.build());
             soundPool = builder.build();
         }else{
-            soundPool = new SoundPool(4, AudioManager.STREAM_MUSIC, 0);
+            soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
         }
 
-        //来电
-        soundID.put(1, soundPool.load(BaseApplication.appContext, R.raw.incoming_call, 1));
-        //去电
-        soundID.put(2, soundPool.load(BaseApplication.appContext, R.raw.outgoing_call, 1));
         //测试
-        soundID.put(3, soundPool.load(BaseApplication.appContext, R.raw.speaker_test, 1));
-        soundID.put(4, soundPool.load(BaseApplication.appContext, R.raw.reinforced, 1));
+        soundID.put(1, soundPool.load(BaseApplication.appContext, R.raw.speaker_test, 1));
+
         soundPool.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() {
             @Override
             public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {

BIN
callingdoor/src/main/res/raw/incoming_call.mp3


BIN
callingdoor/src/main/res/raw/outgoing_call.mp3