|
|
@ -4,6 +4,7 @@ import android.Manifest; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Activity; |
|
|
|
import android.app.Application; |
|
|
|
import android.app.Application; |
|
|
|
import android.content.Context; |
|
|
|
import android.content.Context; |
|
|
|
|
|
|
|
import android.text.TextUtils; |
|
|
|
import android.util.Log; |
|
|
|
import android.util.Log; |
|
|
|
import android.view.SurfaceView; |
|
|
|
import android.view.SurfaceView; |
|
|
|
import android.view.View; |
|
|
|
import android.view.View; |
|
|
@ -63,10 +64,13 @@ import io.rong.calllib.RongCallClient; |
|
|
|
import io.rong.calllib.RongCallCommon; |
|
|
|
import io.rong.calllib.RongCallCommon; |
|
|
|
import io.rong.calllib.RongCallMissedListener; |
|
|
|
import io.rong.calllib.RongCallMissedListener; |
|
|
|
import io.rong.calllib.RongCallSession; |
|
|
|
import io.rong.calllib.RongCallSession; |
|
|
|
|
|
|
|
import io.rong.calllib.message.CallSTerminateMessage; |
|
|
|
|
|
|
|
import io.rong.calllib.message.MultiCallEndMessage; |
|
|
|
import io.rong.common.utils.SSLUtils; |
|
|
|
import io.rong.common.utils.SSLUtils; |
|
|
|
import io.rong.imlib.IRongCoreListener; |
|
|
|
import io.rong.imlib.IRongCoreListener; |
|
|
|
import io.rong.imlib.RongCoreClient; |
|
|
|
import io.rong.imlib.RongCoreClient; |
|
|
|
import io.rong.imlib.RongIMClient; |
|
|
|
import io.rong.imlib.RongIMClient; |
|
|
|
|
|
|
|
import io.rong.imlib.model.Conversation; |
|
|
|
import okhttp3.OkHttpClient; |
|
|
|
import okhttp3.OkHttpClient; |
|
|
|
|
|
|
|
|
|
|
|
public class MyApplication extends Application { |
|
|
|
public class MyApplication extends Application { |
|
|
@ -103,6 +107,31 @@ public class MyApplication extends Application { |
|
|
|
initRong(); |
|
|
|
initRong(); |
|
|
|
RongIMClient.registerMessageType(MeetingMsgModel.class); |
|
|
|
RongIMClient.registerMessageType(MeetingMsgModel.class); |
|
|
|
RongIMClient.registerMessageType(CustomNoticeMessageModel.class); |
|
|
|
RongIMClient.registerMessageType(CustomNoticeMessageModel.class); |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 更换设备 本地存储通话状态 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
RongCallClient.setMissedCallListener( |
|
|
|
|
|
|
|
new RongCallMissedListener() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void onRongCallMissed( |
|
|
|
|
|
|
|
RongCallSession callSession, |
|
|
|
|
|
|
|
RongCallCommon.CallDisconnectedReason reason) { |
|
|
|
|
|
|
|
MultiCallEndMessage multiCallEndMessage = new MultiCallEndMessage(); |
|
|
|
|
|
|
|
multiCallEndMessage.setReason(reason); |
|
|
|
|
|
|
|
multiCallEndMessage.setMediaType(RongIMClient.MediaType.AUDIO); |
|
|
|
|
|
|
|
long serverTime = System.currentTimeMillis() - RongIMClient.getInstance().getDeltaTime(); |
|
|
|
|
|
|
|
RongIMClient.getInstance() |
|
|
|
|
|
|
|
.insertIncomingMessage( |
|
|
|
|
|
|
|
callSession.getConversationType(), |
|
|
|
|
|
|
|
callSession.getTargetId(), |
|
|
|
|
|
|
|
callSession.getCallerUserId(), |
|
|
|
|
|
|
|
VideoCallActivity.getReceivedStatus(reason), |
|
|
|
|
|
|
|
multiCallEndMessage, |
|
|
|
|
|
|
|
serverTime, |
|
|
|
|
|
|
|
null); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private SSLContext mySSLContext; |
|
|
|
private SSLContext mySSLContext; |
|
|
@ -158,11 +187,9 @@ public class MyApplication extends Application { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onReceivedCall(RongCallSession callSession) { |
|
|
|
public void onReceivedCall(RongCallSession callSession) { |
|
|
|
if (DoctorDetailActivity.checkCamera(getCurrentActivity())) { |
|
|
|
|
|
|
|
VideoCallActivity.currentStatus = VideoCallActivity.CallStatus.BeCall; |
|
|
|
VideoCallActivity.currentStatus = VideoCallActivity.CallStatus.BeCall; |
|
|
|
VideoCallActivity.startActivity(getCurrentActivity(), callSession.getInviterUserId(), "", VideoCallActivity.CALLED); |
|
|
|
VideoCallActivity.startActivity(getCurrentActivity(), callSession.getInviterUserId(), "", VideoCallActivity.CALLED); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* targetSDKVersion 大于等于 23 时检查权限的回调。当 targetSDKVersion 小于 23 的时候不需要实现。 |
|
|
|
* targetSDKVersion 大于等于 23 时检查权限的回调。当 targetSDKVersion 小于 23 的时候不需要实现。 |
|
|
@ -175,37 +202,33 @@ public class MyApplication extends Application { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onCheckPermission(RongCallSession callSession) { |
|
|
|
public void onCheckPermission(RongCallSession callSession) { |
|
|
|
XXPermissions.with(getCurrentActivity()) |
|
|
|
if (RongCallClient.getInstance() != null && RongCallClient.getInstance().getCallSession() != null) { |
|
|
|
// 申请单个权限
|
|
|
|
RongCallClient.getInstance().hangUpCall(RongCallClient.getInstance().getCallSession().getCallId()); |
|
|
|
.permission(Manifest.permission.CAMERA, Permission.RECORD_AUDIO) |
|
|
|
MultiCallEndMessage multiCallEndMessage = new MultiCallEndMessage(); |
|
|
|
// 设置权限请求拦截器(局部设置)
|
|
|
|
multiCallEndMessage.setReason(RongCallCommon.CallDisconnectedReason.REMOTE_REJECT); |
|
|
|
//.interceptor(new PermissionInterceptor())
|
|
|
|
multiCallEndMessage.setMediaType(RongIMClient.MediaType.AUDIO); |
|
|
|
// 设置不触发错误检测机制(局部设置)
|
|
|
|
long serverTime = System.currentTimeMillis() - RongIMClient.getInstance().getDeltaTime(); |
|
|
|
//.unchecked()
|
|
|
|
RongIMClient.getInstance() |
|
|
|
.request(new OnPermissionCallback() { |
|
|
|
.insertIncomingMessage( |
|
|
|
|
|
|
|
callSession.getConversationType(), |
|
|
|
@Override |
|
|
|
callSession.getTargetId(), |
|
|
|
public void onGranted(@NonNull List<String> permissions, boolean all) { |
|
|
|
callSession.getCallerUserId(), |
|
|
|
if (!all) { |
|
|
|
VideoCallActivity.getReceivedStatus(RongCallCommon.CallDisconnectedReason.REMOTE_REJECT), |
|
|
|
// toast("获取部分权限成功,但部分权限未正常授予");
|
|
|
|
multiCallEndMessage, |
|
|
|
return; |
|
|
|
serverTime, |
|
|
|
} |
|
|
|
null); |
|
|
|
if (DoctorDetailActivity.checkCamera(getCurrentActivity())) { |
|
|
|
|
|
|
|
VideoCallActivity.currentStatus = VideoCallActivity.CallStatus.BeCall; |
|
|
|
|
|
|
|
VideoCallActivity.startActivity(getCurrentActivity(), callSession.getInviterUserId(), "", VideoCallActivity.CALLED); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
new XPopup.Builder(getCurrentActivity()).isRequestFocus(true).asCustom(new TipDialog(getCurrentActivity(), "通话权限未设置", new TipDialog.DialogClick() { |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public void cancel() { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onDenied(@NonNull List<String> permissions, boolean never) { |
|
|
|
public void confirm() { |
|
|
|
if (never) { |
|
|
|
|
|
|
|
// 如果是被永久拒绝就跳转到应用权限系统设置页面
|
|
|
|
|
|
|
|
XXPermissions.startPermissionActivity(getCurrentActivity(), permissions); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
Toast.makeText(getCurrentActivity(), "语音权限获取失败", Toast.LENGTH_LONG).show(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
})).show(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|