checkIsSoterEnrolledInDevice 检测是否存在面容 为true,但是启动startSoterAuthentication 识别抛 无面容(err_code:90011)
async checkBiometrics(index) {
const {mode, name} = this.data.opts[index]
const title = `【${name}-检测】`
console.log('checkBiometrics start', mode)
console.log(mode)
log.setFilterMsg('startCheckFingerPrint')
log.info(`checkBiometrics: ${mode}`)
if(mode === 'fingerPrint') {
VoiceHelp.play(VoiceType.Biometrics)
}
if (this.data.isDetectionFinger) return
log.info(`startCheckFinger: ${mode}`)
// 检查当前设备有未录入指纹
let isEnrolled = false
try {
this.data.isDetectionFinger = true
let res = await promiseApi('checkIsSupportSoterAuthentication')
// res.supportMode = [] 不具备任何被SOTER支持的生物识别方式
// res.supportMode = ['fingerPrint'] 只支持指纹识别
// res.supportMode = ['fingerPrint', 'facial'] 支持指纹识别和人脸识别
console.log(res)
const supportMode = res.supportMode
log.info(supportMode)
if (!supportMode.length || !supportMode.includes(mode)) {
await this.selectSoterConfirmV2(index, title, `当前不支持${name}/或微信不支持${name}`)
return
}
let checkHasEnrolled = async (m) => {
try {
log.info(`checkIsSoterEnrolledInDevice: ${m}`)
res = await promiseApi('checkIsSoterEnrolledInDevice',{
checkAuthMode: m
})
if (res.isEnrolled) {
isEnrolled = true
}
} catch (error) {
}
}
await checkHasEnrolled(mode)
log.info(`isEnrolled: ${isEnrolled}`)
// 开始识别
res = await promiseApi('startSoterAuthentication', {
requestAuthModes: [mode],
challenge: new Date().getTime().toString() + Math.floor(Math.random() * 10), //挑战因子
authContent: `检测:${name}`,
})
if (res.errCode) {
throw res
}
log.info(res)
this.checkRetStep(index, true)
} catch (error) {
log.info(error)
console.log(error)
const errCode = error && error.errCode
const errCodeMap = {
90001: '本设备不支持生物认证',
90002: '用户未授权微信使用该生物认证接口, 请授权后重试!',
90003: '请求使用的生物认证方式不支持',
90004: '未传入challenge或challenge长度过长',
90005: 'auth_content长度超过限制',
90008: '用户取消授权',
90009: '识别失败',
90010: '重试次数过多,请先锁屏后再解锁后重试!', // '重试次数过多被冻结',
90011: '当前未录入指纹/人脸信息,请前往【设置】完成录入(如果已录入,锁屏后再解锁重试)!', //'用户未录入所选识别方式'
}
// 90007 内部错误🙅♂️
if (errCode && !isEnrolled) {
await sleep(1000)
await this.selectSoterAgainV2(index, title, `当前未录入${name},请前往【设置】完成录入(如果已录入,锁屏后再解锁重试)`)
} else if (errCode && errCodeMap[errCode]) {
log.info(errCode)
await sleep(1000)
await this.selectSoterAgainV2(index, title, errCodeMap[errCode])
} else if (errCode == 90007) { //内部错误
await this.selectSoterConfirmV2(index, title, '内部处理异常:90007')
} else {
log.setFilterMsg('其他未知code')
await this.selectSoterConfirmV2(index, title, '检测结果异常', (error && error.errMsg) || `内部异常: ${errCode}`)
log.info(errCode)
}
} finally {
this.data.isDetectionFinger = false
console.log('checkBiometrics finally')
}
},