|
@@ -0,0 +1,441 @@
|
|
|
|
+package com.wdkl.ncs.android.component.home.ui;
|
|
|
|
+
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
|
+import android.content.BroadcastReceiver;
|
|
|
|
+import android.content.Context;
|
|
|
|
+import android.content.Intent;
|
|
|
|
+import android.content.IntentFilter;
|
|
|
|
+import android.os.Bundle;
|
|
|
|
+import android.os.Handler;
|
|
|
|
+import android.os.Message;
|
|
|
|
+import android.os.SystemClock;
|
|
|
|
+import android.text.TextUtils;
|
|
|
|
+import android.util.Log;
|
|
|
|
+import android.view.KeyEvent;
|
|
|
|
+import android.view.LayoutInflater;
|
|
|
|
+import android.view.View;
|
|
|
|
+import android.view.ViewGroup;
|
|
|
|
+import android.widget.Chronometer;
|
|
|
|
+import android.widget.ImageView;
|
|
|
|
+import android.widget.LinearLayout;
|
|
|
|
+import android.widget.TextView;
|
|
|
|
+import android.widget.Toast;
|
|
|
|
+
|
|
|
|
+import androidx.annotation.NonNull;
|
|
|
|
+import androidx.annotation.Nullable;
|
|
|
|
+import androidx.fragment.app.Fragment;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.google.gson.Gson;
|
|
|
|
+import com.wdkl.ncs.android.component.home.R;
|
|
|
|
+import com.wdkl.ncs.android.component.home.util.MediaPlayHelper;
|
|
|
|
+import com.wdkl.ncs.android.component.home.util.RingPlayHelper;
|
|
|
|
+import com.wdkl.ncs.android.component.home.util.SpeechUtil;
|
|
|
|
+import com.wdkl.ncs.android.component.home.util.VoiceManagerUtil;
|
|
|
|
+import com.wdkl.ncs.android.lib.base.BaseApplication;
|
|
|
|
+import com.wdkl.ncs.android.lib.utils.ExtendMethodsKt;
|
|
|
|
+import com.wdkl.ncs.android.lib.vo.MessageEvent;
|
|
|
|
+import com.wdkl.ncs.android.middleware.common.Constants;
|
|
|
|
+import com.wdkl.ncs.android.middleware.model.vo.InteractionVO;
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.TcpClient;
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.dto.TcpCallback;
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.dto.TcpModel;
|
|
|
|
+import com.wdkl.ncs.android.middleware.tcp.enums.TcpAction;
|
|
|
|
+import com.wdkl.ncs.host.service.WdklSipService;
|
|
|
|
+import com.wdkl.ncs.host.util.AudioRouteUtils;
|
|
|
|
+
|
|
|
|
+import org.greenrobot.eventbus.EventBus;
|
|
|
|
+import org.greenrobot.eventbus.Subscribe;
|
|
|
|
+import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
+import org.linphone.core.Address;
|
|
|
|
+import org.linphone.core.Call;
|
|
|
|
+import org.linphone.core.CallParams;
|
|
|
|
+import org.linphone.core.Core;
|
|
|
|
+
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
|
|
+
|
|
|
|
+public abstract class BaseSipCallFragment extends Fragment {
|
|
|
|
+ private static final String TAG = "BaseSipCallFragment";
|
|
|
|
+ ImageView minimizeImageView;
|
|
|
|
+ ImageView portraitImageView;// 用户头像
|
|
|
|
+ TextView nameTextView; // 用户昵称
|
|
|
|
+ TextView descTextView; // 状态提示用语
|
|
|
|
+ Chronometer durationTextView; // 通话时长
|
|
|
|
+
|
|
|
|
+ LinearLayout transLinearLayout;
|
|
|
|
+ LinearLayout hangupLinearLayout;
|
|
|
|
+ LinearLayout muteLinearLayout;
|
|
|
|
+ LinearLayout speakerLinearLayout;
|
|
|
|
+
|
|
|
|
+ ImageView outgoingHangupImageView;
|
|
|
|
+ ImageView incomingHangupImageView;
|
|
|
|
+ ImageView incomingTransImageView;
|
|
|
|
+ ImageView acceptImageView;
|
|
|
|
+ TextView tvStatus;
|
|
|
|
+ View outgoingActionContainer;
|
|
|
|
+ View incomingActionContainer;
|
|
|
|
+ View connectedActionContainer;
|
|
|
|
+
|
|
|
|
+ View lytParent;
|
|
|
|
+
|
|
|
|
+ boolean isOutgoing = true;
|
|
|
|
+
|
|
|
|
+ BaseCallActivity callActivity;
|
|
|
|
+ CallHandler handler;
|
|
|
|
+ boolean isHandoff = false;
|
|
|
|
+
|
|
|
|
+ protected Core core;
|
|
|
|
+
|
|
|
|
+ public static final int WHAT_DELAY_END_CALL = 0x01;
|
|
|
|
+ public static final int FINISH_CURRENT = 0x02;
|
|
|
|
+ public static final int WHAT_DELAY_CHECK_CALL = 0x03;
|
|
|
|
+
|
|
|
|
+ HeadsetPlugReceiver headsetPlugReceiver;
|
|
|
|
+
|
|
|
|
+ private boolean callSuccess = false;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onCreate(@Nullable Bundle savedInstanceState) {
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
+ setRetainInstance(true);
|
|
|
|
+
|
|
|
|
+ handler = new CallHandler();
|
|
|
|
+ EventBus.getDefault().register(this);
|
|
|
|
+
|
|
|
|
+ core = WdklSipService.getCore();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Nullable
|
|
|
|
+ @Override
|
|
|
|
+ public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
+ View view = inflater.inflate(getLayout(), container, false);
|
|
|
|
+ initView(view);
|
|
|
|
+ init();
|
|
|
|
+ return view;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onViewCreated(View view, @Nullable @org.jetbrains.annotations.Nullable Bundle savedInstanceState) {
|
|
|
|
+ super.onViewCreated(view, savedInstanceState);
|
|
|
|
+
|
|
|
|
+ if (isOutgoing) {
|
|
|
|
+ RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.ring_back2, true);
|
|
|
|
+ } else {
|
|
|
|
+ RingPlayHelper.playRingTone(BaseApplication.appContext, R.raw.ring_tone, true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onDestroyView() {
|
|
|
|
+ if (handler != null) {
|
|
|
|
+ handler.removeCallbacksAndMessages(null);
|
|
|
|
+ }
|
|
|
|
+ if (durationTextView != null)
|
|
|
|
+ durationTextView.stop();
|
|
|
|
+ super.onDestroyView();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onDestroy() {
|
|
|
|
+ super.onDestroy();
|
|
|
|
+ EventBus.getDefault().unregister(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ abstract int getLayout();
|
|
|
|
+ abstract void showCallConnected();
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onAttach(@NonNull Context context) {
|
|
|
|
+ super.onAttach(context);
|
|
|
|
+ callActivity = (SipCallActivity) getActivity();
|
|
|
|
+ if (callActivity != null) {
|
|
|
|
+ isOutgoing = callActivity.isOutgoing();
|
|
|
|
+ headsetPlugReceiver = new HeadsetPlugReceiver();
|
|
|
|
+ IntentFilter filter = new IntentFilter();
|
|
|
|
+ filter.addAction(Intent.ACTION_HEADSET_PLUG);
|
|
|
|
+ callActivity.registerReceiver(headsetPlugReceiver, filter);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onDetach() {
|
|
|
|
+ super.onDetach();
|
|
|
|
+ callActivity.unregisterReceiver(headsetPlugReceiver); //注销监听
|
|
|
|
+ callActivity = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void initView(View view) {
|
|
|
|
+ lytParent = view.findViewById(R.id.lytParent);
|
|
|
|
+ minimizeImageView = view.findViewById(R.id.minimizeImageView);
|
|
|
|
+ portraitImageView = view.findViewById(R.id.portraitImageView);
|
|
|
|
+ nameTextView = view.findViewById(R.id.nameTextView);
|
|
|
|
+ descTextView = view.findViewById(R.id.descTextView);
|
|
|
|
+ durationTextView = view.findViewById(R.id.durationTextView);
|
|
|
|
+ outgoingHangupImageView = view.findViewById(R.id.outgoingHangupImageView);
|
|
|
|
+ incomingHangupImageView = view.findViewById(R.id.incomingHangupImageView);
|
|
|
|
+ incomingTransImageView = view.findViewById(R.id.incomingTransImageView);
|
|
|
|
+ acceptImageView = view.findViewById(R.id.acceptImageView);
|
|
|
|
+ tvStatus = view.findViewById(R.id.tvStatus);
|
|
|
|
+ outgoingActionContainer = view.findViewById(R.id.outgoingActionContainer);
|
|
|
|
+ incomingActionContainer = view.findViewById(R.id.incomingActionContainer);
|
|
|
|
+ connectedActionContainer = view.findViewById(R.id.connectedActionContainer);
|
|
|
|
+ transLinearLayout = view.findViewById(R.id.transLinearLayout);
|
|
|
|
+ hangupLinearLayout = view.findViewById(R.id.hangupLinearLayout);
|
|
|
|
+ muteLinearLayout = view.findViewById(R.id.muteLinearLayout);
|
|
|
|
+ speakerLinearLayout = view.findViewById(R.id.speakerLinearLayout);
|
|
|
|
+
|
|
|
|
+ durationTextView.setVisibility(View.GONE);
|
|
|
|
+ if (isOutgoing) {
|
|
|
|
+ handler.sendEmptyMessageDelayed(WHAT_DELAY_CHECK_CALL, 5000); //5s后检查是否呼叫成功
|
|
|
|
+ }
|
|
|
|
+ handler.sendEmptyMessageDelayed(WHAT_DELAY_END_CALL, 60 * 1000);//60s之后未接通,则挂断电话
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void init() {
|
|
|
|
+ if (callActivity.recTcpModel.getData()!=null){
|
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(callActivity.recTcpModel.getData().toString(), InteractionVO.class);
|
|
|
|
+ Constants.Companion.setInteractionId(interactionVO.getId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (isOutgoing) {
|
|
|
|
+ startOutCall();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressLint("CheckResult")
|
|
|
|
+ private void startOutCall() {
|
|
|
|
+ //发送tcp call
|
|
|
|
+ TcpCallback transaction = new TcpCallback(callActivity.recTcpModel.getTid()) {
|
|
|
|
+ @Override
|
|
|
|
+ public void onSuccess(JSONObject jsonObject) {
|
|
|
|
+ //
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onFailed(JSONObject jsonObject) {
|
|
|
|
+ if (callActivity != null) {
|
|
|
|
+ callActivity.runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ ExtendMethodsKt.showMessage("Failed");
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ callActivity.finish();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ TcpClient.getInstance().sendTcp(callActivity.recTcpModel, false, transaction);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void callOutSuccess(TcpModel tcpModel) {
|
|
|
|
+ callActivity.recTcpModel = tcpModel;
|
|
|
|
+ InteractionVO interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
|
+ Constants.Companion.setInteractionId(interactionVO.getId());
|
|
|
|
+ callSuccess = true;
|
|
|
|
+ //callSingleActivity.janusClient.connect();
|
|
|
|
+ Log.d(TAG,"voice#success =>" + callActivity.recTcpModel.toJson());
|
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), R.string.call_success, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void startRefreshTime() {
|
|
|
|
+ if (durationTextView != null) {
|
|
|
|
+ leftTime = 0;
|
|
|
|
+ durationTextView.setOnChronometerTickListener(null);
|
|
|
|
+ durationTextView.stop();
|
|
|
|
+ durationTextView.setVisibility(View.VISIBLE);
|
|
|
|
+ durationTextView.setBase(SystemClock.elapsedRealtime());
|
|
|
|
+ durationTextView.start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private long leftTime = 60;
|
|
|
|
+ public void countDownTime() {
|
|
|
|
+ if (durationTextView != null) {
|
|
|
|
+ durationTextView.setVisibility(View.VISIBLE);
|
|
|
|
+ durationTextView.setBase(SystemClock.elapsedRealtime());
|
|
|
|
+ durationTextView.start();
|
|
|
|
+ durationTextView.setOnChronometerTickListener(
|
|
|
|
+ new Chronometer.OnChronometerTickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onChronometerTick(Chronometer chronometer) {
|
|
|
|
+ leftTime--;
|
|
|
|
+ Date d = new Date(leftTime * 1000);
|
|
|
|
+ SimpleDateFormat timeFormat = new SimpleDateFormat("mm:ss");
|
|
|
|
+ chronometer.setText(timeFormat.format(d));
|
|
|
|
+ if (leftTime == 0) {
|
|
|
|
+ durationTextView.stop();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void runOnUiThread(Runnable runnable) {
|
|
|
|
+ if (callActivity != null) {
|
|
|
|
+ callActivity.runOnUiThread(runnable);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @SuppressLint("HandlerLeak")
|
|
|
|
+ class CallHandler extends Handler {
|
|
|
|
+ @Override
|
|
|
|
+ public void handleMessage(@NonNull Message msg) {
|
|
|
|
+ switch (msg.what) {
|
|
|
|
+ case WHAT_DELAY_END_CALL:
|
|
|
|
+ if (core.getCurrentCall() != null) {
|
|
|
|
+ Call.State state = core.getCurrentCall().getState();
|
|
|
|
+ if (callActivity != null && state != Call.State.Connected && !isHandoff) {
|
|
|
|
+ callActivity.sendHandOffTcp();
|
|
|
|
+ callActivity.finish();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case WHAT_DELAY_CHECK_CALL:
|
|
|
|
+ if (callActivity != null && !callSuccess) {
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), R.string.net_error, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ case FINISH_CURRENT:
|
|
|
|
+ if (callActivity != null) {
|
|
|
|
+ callActivity.finish();
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public abstract void onBackPressed();
|
|
|
|
+
|
|
|
|
+ public abstract boolean onKeyUp(int keyCode, KeyEvent event);
|
|
|
|
+
|
|
|
|
+ protected abstract void handleHeadsetHook();
|
|
|
|
+
|
|
|
|
+ class HeadsetPlugReceiver extends BroadcastReceiver {
|
|
|
|
+ @Override
|
|
|
|
+ public void onReceive(Context context, Intent intent) {
|
|
|
|
+ if (intent.hasExtra("state")) {
|
|
|
|
+ if (intent.getIntExtra("state", 0) == 0) { //拔出耳机
|
|
|
|
+ AudioRouteUtils.Companion.routeAudioToSpeaker(core, null, false);
|
|
|
|
+ } else if (intent.getIntExtra("state", 0) == 1) { //插入耳机
|
|
|
|
+ AudioRouteUtils.Companion.routeAudioToHeadset(core, null, false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
|
+ public void onEvent(MessageEvent messageEvent) {
|
|
|
|
+ int code = messageEvent.getTag();
|
|
|
|
+ //TCP处理
|
|
|
|
+ if (code == 2) {
|
|
|
|
+ TcpModel tcpModel = (TcpModel) messageEvent.getMessage();
|
|
|
|
+ Log.i(TAG, "收到数据222: " + tcpModel.toJson());
|
|
|
|
+ int curInteractionId = -1;
|
|
|
|
+ InteractionVO interactionVO = null;
|
|
|
|
+ if (tcpModel.getData() != null) {
|
|
|
|
+ interactionVO = new Gson().fromJson(tcpModel.getData().toString(), InteractionVO.class);
|
|
|
|
+ curInteractionId = interactionVO.getId();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (tcpModel.getAction() == TcpAction.VoiceAction.ACCEPT) {
|
|
|
|
+ if (curInteractionId == Constants.Companion.getInteractionId()) {
|
|
|
|
+ MediaPlayHelper.getInstance().stopMusic(true);
|
|
|
|
+ RingPlayHelper.stopRingTone();
|
|
|
|
+ SpeechUtil.getInstance().stopSpeak();
|
|
|
|
+ callActivity.recTcpModel = tcpModel;
|
|
|
|
+ Log.d(TAG, "voice#accept =>" + callActivity.recTcpModel.toJson());
|
|
|
|
+ Log.i(TAG, "对方接听电话啦");
|
|
|
|
+
|
|
|
|
+ if (core == null || interactionVO == null || TextUtils.isEmpty(interactionVO.getToSipId())) {
|
|
|
|
+ //通话失败,重置并返回主界面
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), "sip_core targetSipId empty!", Toast.LENGTH_SHORT).show();
|
|
|
|
+ handler.sendEmptyMessageDelayed(FINISH_CURRENT, 1000);
|
|
|
|
+ } else {
|
|
|
|
+ Address addressToCall = core.interpretUrl(interactionVO.getToSipId());
|
|
|
|
+ CallParams params = core.createCallParams(null);
|
|
|
|
+ params.setVideoEnabled(false);
|
|
|
|
+ if (addressToCall != null) {
|
|
|
|
+ core.inviteAddressWithParams(addressToCall, params);
|
|
|
|
+ Log.d(TAG, ">>>>>>>>>>> invite address: " + addressToCall.asString());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (tcpModel.getAction() == TcpAction.VoiceAction.HANDOFF) { //对方挂断
|
|
|
|
+ if (curInteractionId == Constants.Companion.getInteractionId()) {
|
|
|
|
+ isHandoff = true;
|
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), R.string.call_end, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
|
+ }
|
|
|
|
+ } else if (tcpModel.getAction() == TcpAction.VoiceAction.REJECT) {
|
|
|
|
+ if (curInteractionId == Constants.Companion.getInteractionId()) {
|
|
|
|
+ handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
|
+
|
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), R.string.call_reject, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else if (tcpModel.getAction() == TcpAction.VoiceAction.CALLING) {
|
|
|
|
+ if (curInteractionId == Constants.Companion.getInteractionId()) {
|
|
|
|
+ handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), R.string.call_busy, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } else if (tcpModel.getAction() == TcpAction.VoiceAction.FAILED) {
|
|
|
|
+ //if (curInteractionId == interactionId) {
|
|
|
|
+ handler.sendEmptyMessageDelayed(FINISH_CURRENT, 1000);
|
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), R.string.call_failed, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ //}
|
|
|
|
+ } else if (tcpModel.getAction() == TcpAction.VoiceAction.CANCEL || tcpModel.getAction() == TcpAction.VoiceAction.VOICE_OFF) {
|
|
|
|
+ if (curInteractionId == Constants.Companion.getInteractionId()) {
|
|
|
|
+ handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
|
+ runOnUiThread(new Runnable() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ Toast.makeText(BaseSipCallFragment.this.getContext(), R.string.str_cancel, Toast.LENGTH_SHORT).show();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (code == 1) {
|
|
|
|
+ TcpModel tcpModel = (TcpModel) messageEvent.getMessage();
|
|
|
|
+ Log.i(TAG, "收到数据111: " + tcpModel.toJson());
|
|
|
|
+ if (isOutgoing && tcpModel.getAction() == TcpAction.VoiceAction.SUCCESS){ //服务器返回成功
|
|
|
|
+ callOutSuccess(tcpModel);
|
|
|
|
+ }
|
|
|
|
+ } else if (code == Constants.EVENT_HEADSET_HOOK) {
|
|
|
|
+ //收到耳机按键
|
|
|
|
+ handleHeadsetHook();
|
|
|
|
+ } else if (code == Constants.EVENT_END_CALL) {
|
|
|
|
+ handler.sendEmptyMessageDelayed(FINISH_CURRENT, 100);
|
|
|
|
+ } else if (code == Constants.SIP_CONNECTED) {
|
|
|
|
+ if (core != null) {
|
|
|
|
+ core.setMicEnabled(true);
|
|
|
|
+ }
|
|
|
|
+ showCallConnected();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|