Commit 813a30dd by 刘鹏

feat: 权限申请更换方式

parent 7da8a914
package com.ydl.confide.home.modular.service package com.ydl.confide.home.modular.service
import android.Manifest
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Context import android.content.Context
...@@ -7,8 +8,7 @@ import android.content.Intent ...@@ -7,8 +8,7 @@ import android.content.Intent
import android.net.Uri import android.net.Uri
import android.text.TextUtils import android.text.TextUtils
import com.alibaba.android.arouter.launcher.ARouter import com.alibaba.android.arouter.launcher.ARouter
import com.hjq.permissions.OnPermissionCallback import com.tbruyelle.rxpermissions2.RxPermissions
import com.hjq.permissions.XXPermissions
import com.ydl.audioim.IntentConstants import com.ydl.audioim.IntentConstants
import com.ydl.audioim.YDLavManager import com.ydl.audioim.YDLavManager
import com.ydl.audioim.bean.ExpertInfoBean import com.ydl.audioim.bean.ExpertInfoBean
...@@ -35,6 +35,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers ...@@ -35,6 +35,7 @@ import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers
/** /**
* Created by haorui on 2019-10-10. * Created by haorui on 2019-10-10.
* Des: 对应主项目中的WebServiceImpl * Des: 对应主项目中的WebServiceImpl
...@@ -188,27 +189,32 @@ class ConfideWebServiceImpl { ...@@ -188,27 +189,32 @@ class ConfideWebServiceImpl {
/** /**
* 检查权限 * 检查权限
* */ * */
@SuppressLint("CheckResult")
private fun checkPermission(id: Int, type: Int, activity: Activity, callType: String?) { private fun checkPermission(id: Int, type: Int, activity: Activity, callType: String?) {
try { try {
//申请音频权限 val rxPermissions = RxPermissions(activity)
XXPermissions.with(activity) // 申请单个权限 rxPermissions.requestEach(Manifest.permission.RECORD_AUDIO).subscribe { permission ->
.permission(com.hjq.permissions.Permission.RECORD_AUDIO) when {
.request(object : OnPermissionCallback { //权限已申请 进行通话
override fun onGranted(p0: MutableList<String>?, p1: Boolean) { permission.granted -> {
listenDial(id, type, activity,callType) listenDial(id, type, activity, callType)
AliYunRichLogsHelper.getInstance() AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "请求音频权限通过") .sendRichLog(AliYunLogConfig.AGORA, "请求音频权限通过")
} }
//权限未申请 重新申请
override fun onDenied(permissions: MutableList<String>?, never: Boolean) { permission.shouldShowRequestPermissionRationale -> {
listenDial(id, type, activity,"1"); checkPermission(id, type, activity, callType)
// 拒绝权限操作发送给服务端
AliYunRichLogsHelper.getInstance() AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "拒绝请求音频权限") .sendRichLog(AliYunLogConfig.AGORA, "权限未申请 重新申请")
}
//跳转设置界面
else -> {
listenDial(id, type, activity, "1")
AliYunRichLogsHelper.getInstance()
.sendRichLog(AliYunLogConfig.AGORA, "权限拒绝 转axb")
}
}
} }
})
} catch (e: Exception) { } catch (e: Exception) {
listenDial(id, type, activity,"1"); listenDial(id, type, activity,"1");
AliYunRichLogsHelper.getInstance() AliYunRichLogsHelper.getInstance()
......
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