Commit 87878d30 authored by 宋永孟's avatar 宋永孟

add 完成活体检测功能

parent 20b26012
...@@ -79,6 +79,9 @@ ...@@ -79,6 +79,9 @@
<activity <activity
android:name=".ui.idcard.IDCardTestActivity" android:name=".ui.idcard.IDCardTestActivity"
android:theme="@style/Transparent" /> android:theme="@style/Transparent" />
<activity
android:name=".ui.TempListActivity"
android:theme="@style/Transparent" />
<activity <activity
android:name=".ui.idcard.IDCardResultActivity" android:name=".ui.idcard.IDCardResultActivity"
......
...@@ -28,12 +28,12 @@ class ApiService { ...@@ -28,12 +28,12 @@ class ApiService {
ServiceFactory.getInstance().createService(CommonService::class.java) ServiceFactory.getInstance().createService(CommonService::class.java)
.identifyIdOcrVerify(paramsMap, requestParams) .identifyIdOcrVerify(paramsMap, requestParams)
.compose(TransformUtil.defaultSchedulers()) .compose(TransformUtil.defaultSchedulers())
.subscribe(object : HttpResultSubscriber<Any?>() { .subscribe(object : HttpResultSubscriber<IdentifyIdOcrVerifyBean.Response?>() {
override fun onSuccess(result: HttpResult<Any?>?) { override fun onSuccess(result: HttpResult<IdentifyIdOcrVerifyBean.Response?>?) {
apiCallback.identifyIdOcrVerifySuccess(result) apiCallback.identifyIdOcrVerifySuccess(result)
} }
override fun onFailer(result: HttpResult<Any?>?) { override fun onFailer(result: HttpResult<IdentifyIdOcrVerifyBean.Response?>?) {
} }
}) })
} }
......
...@@ -119,7 +119,7 @@ interface CommonService { ...@@ -119,7 +119,7 @@ interface CommonService {
@Headers("Content-Type: application/json") @Headers("Content-Type: application/json")
@POST(URLs.identifyIdOcrVerify) @POST(URLs.identifyIdOcrVerify)
fun identifyIdOcrVerify(@QueryMap commonParams: Map<String, String>, @Body requestParams: IdentifyIdOcrVerifyBean.Request): Observable<HttpResult<Any?>> fun identifyIdOcrVerify(@QueryMap commonParams: Map<String, String>, @Body requestParams: IdentifyIdOcrVerifyBean.Request): Observable<HttpResult<IdentifyIdOcrVerifyBean.Response?>>
@GET(URLs.getKSYunObjectId) @GET(URLs.getKSYunObjectId)
fun getKSYunObjectId(@QueryMap commonParams: Map<String, String>) : Observable<HttpResult<GetKSYunObjectIdBean.Response>> fun getKSYunObjectId(@QueryMap commonParams: Map<String, String>) : Observable<HttpResult<GetKSYunObjectIdBean.Response>>
......
...@@ -2,9 +2,7 @@ package com.yidian.shenghuoquan.newscontent.http.httpbean ...@@ -2,9 +2,7 @@ package com.yidian.shenghuoquan.newscontent.http.httpbean
class IdentifyIdOcrVerifyBean(var request: Request, val response: Response) { class IdentifyIdOcrVerifyBean(var request: Request, val response: Response) {
data class Request(var biz_token: String, var meglive_objectid: String) data class Request(var biz_token: String, var meglive_objectid: String)
data class Response(val biz_token: String) data class Response(val verify_result: Boolean)
} }
...@@ -3,5 +3,5 @@ package com.yidian.shenghuoquan.newscontent.http.httpbean ...@@ -3,5 +3,5 @@ package com.yidian.shenghuoquan.newscontent.http.httpbean
import com.yidian.common.http.HttpResult import com.yidian.common.http.HttpResult
interface IdentifyIdOcrVerifyCallback { interface IdentifyIdOcrVerifyCallback {
fun identifyIdOcrVerifySuccess(t: HttpResult<Any?>?) fun identifyIdOcrVerifySuccess(t: HttpResult<IdentifyIdOcrVerifyBean.Response?>?)
} }
\ No newline at end of file
package com.yidian.shenghuoquan.newscontent.ui package com.yidian.shenghuoquan.newscontent.ui
import android.content.Intent
import android.os.Bundle import android.os.Bundle
import com.orhanobut.hawk.Hawk import com.orhanobut.hawk.Hawk
import com.yidian.common.HawkConfig import com.yidian.common.HawkConfig
...@@ -15,7 +16,6 @@ import com.yidian.shenghuoquan.newscontent.http.httpbean.IGuestLoginCallback ...@@ -15,7 +16,6 @@ import com.yidian.shenghuoquan.newscontent.http.httpbean.IGuestLoginCallback
import com.yidian.shenghuoquan.newscontent.subscription.subscriptionManager import com.yidian.shenghuoquan.newscontent.subscription.subscriptionManager
import com.yidian.shenghuoquan.newscontent.ui.dialog.ProtocolDialog import com.yidian.shenghuoquan.newscontent.ui.dialog.ProtocolDialog
import com.yidian.shenghuoquan.newscontent.utils.AccountUtil import com.yidian.shenghuoquan.newscontent.utils.AccountUtil
import com.yidian.xpage.XPageManager
class FlashActivity: BaseActivity<ActivityFlashBinding>() { class FlashActivity: BaseActivity<ActivityFlashBinding>() {
private var protocolDialog: ProtocolDialog? = null private var protocolDialog: ProtocolDialog? = null
...@@ -56,10 +56,11 @@ class FlashActivity: BaseActivity<ActivityFlashBinding>() { ...@@ -56,10 +56,11 @@ class FlashActivity: BaseActivity<ActivityFlashBinding>() {
private fun launcher(){ private fun launcher(){
val isAgree = Hawk.get<Boolean>(HawkConfig.ProtocolIsAgree, false) val isAgree = Hawk.get<Boolean>(HawkConfig.ProtocolIsAgree, false)
if(isAgree){ if(isAgree){
viewBind.clRoot.postDelayed( { viewBind.clRoot.postDelayed({
XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, paramsMap) // XPageManager.push(XRouterPathConstants.LOGIN_LIFE_CIRCLE, paramsMap)
startActivity(Intent(this@FlashActivity, TempListActivity::class.java))
finish() finish()
},2000) }, 2000)
}else{ }else{
viewBind.clRoot.postDelayed( { viewBind.clRoot.postDelayed( {
protocolPopupShow() protocolPopupShow()
......
package com.yidian.shenghuoquan.newscontent.ui
import android.content.Intent
import android.os.Bundle
import com.yidian.common.base.BaseActivity
import com.yidian.shenghuoquan.newscontent.databinding.ActivityTempListBinding
import com.yidian.shenghuoquan.newscontent.ui.alive.AliveTestActivity
import com.yidian.shenghuoquan.newscontent.ui.idcard.IDCardTestActivity
/**
* Author: sym
* Date: 2021/5/24 3:44 PM
* Describe:
*/
class TempListActivity : BaseActivity<ActivityTempListBinding>() {
override fun createViewBinding(): ActivityTempListBinding {
return ActivityTempListBinding.inflate(layoutInflater)
}
override fun getXPageName(): String {
return ""
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
viewBind.btActionCard.setOnClickListener {
startActivity(Intent(this@TempListActivity, IDCardTestActivity::class.java))
}
viewBind.btActionYy.setOnClickListener {
startActivity(Intent(this@TempListActivity, AliveTestActivity::class.java))
}
viewBind.btBusinessLicense.setOnClickListener {
startActivity(Intent(this@TempListActivity, AliveTestActivity::class.java))
}
}
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ package com.yidian.shenghuoquan.newscontent.ui.alive ...@@ -2,7 +2,7 @@ package com.yidian.shenghuoquan.newscontent.ui.alive
import android.app.ProgressDialog import android.app.ProgressDialog
import android.os.Bundle import android.os.Bundle
import android.util.Log import android.widget.Toast
import com.megvii.meglive_sdk.listener.DetectCallback import com.megvii.meglive_sdk.listener.DetectCallback
import com.megvii.meglive_sdk.listener.PreCallback import com.megvii.meglive_sdk.listener.PreCallback
import com.megvii.meglive_sdk.manager.MegLiveManager import com.megvii.meglive_sdk.manager.MegLiveManager
...@@ -33,7 +33,6 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -33,7 +33,6 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
private var modelPath = "" // 模型本地存放路径 private var modelPath = "" // 模型本地存放路径
private var dataPath = "" // 模型本地存放路径 private var dataPath = "" // 模型本地存放路径
private var mProgressDialog: ProgressDialog? = null private var mProgressDialog: ProgressDialog? = null
private val VERIFY_URL = "https://api.megvii.com/faceid/v3/sdk/verify"
override fun createViewBinding(): ActivityAliveLayoutBinding { override fun createViewBinding(): ActivityAliveLayoutBinding {
...@@ -69,11 +68,9 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -69,11 +68,9 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
private val authPersonalGetTokenCallback = object : AuthPersonalGetTokenCallback { private val authPersonalGetTokenCallback = object : AuthPersonalGetTokenCallback {
override fun getTokenSuccess(t: HttpResult<AuthPersonalGetTokenBean.Response?>?) { override fun getTokenSuccess(t: HttpResult<AuthPersonalGetTokenBean.Response?>?) {
Log.d("song_test", t?.result?.biz_token)
bizToken = t?.result?.biz_token!! bizToken = t?.result?.biz_token!!
megLiveManager?.preDetect(this@AliveTestActivity, bizToken, "zh", "https://api.megvii.com", modelPath, this@AliveTestActivity) megLiveManager?.preDetect(this@AliveTestActivity, bizToken, "zh", "https://api.megvii.com", modelPath, this@AliveTestActivity)
} }
} }
private fun saveAssets(fileName: String, path: String): String? { private fun saveAssets(fileName: String, path: String): String? {
...@@ -139,6 +136,8 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -139,6 +136,8 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
override fun onDetectFinish(token: String?, errorCode: Int, errorMessage: String?, data: String?) { override fun onDetectFinish(token: String?, errorCode: Int, errorMessage: String?, data: String?) {
if (errorCode == 1000) { if (errorCode == 1000) {
token?.let { verify(it, data!!.toByteArray()) } token?.let { verify(it, data!!.toByteArray()) }
} else {
Toast.makeText(this@AliveTestActivity, errorMessage, Toast.LENGTH_SHORT).show()
} }
} }
...@@ -148,8 +147,13 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -148,8 +147,13 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
} }
private val identifyIdOcrVerifyCallback = object : IdentifyIdOcrVerifyCallback { private val identifyIdOcrVerifyCallback = object : IdentifyIdOcrVerifyCallback {
override fun identifyIdOcrVerifySuccess(t: HttpResult<Any?>?) { override fun identifyIdOcrVerifySuccess(t: HttpResult<IdentifyIdOcrVerifyBean.Response?>?) {
progressDialogDismiss() progressDialogDismiss()
if (t!!.result!!.verify_result) {
Toast.makeText(this@AliveTestActivity, "活体检测结果成功 verify_result = true ", Toast.LENGTH_SHORT).show()
} else {
Toast.makeText(this@AliveTestActivity, "活体检测结果失败 msg = ${t.reason}", Toast.LENGTH_SHORT).show()
}
} }
} }
...@@ -185,7 +189,6 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac ...@@ -185,7 +189,6 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>(), PreCallbac
override fun onTaskSuccess(bucket: String?, objectKey: String?) { override fun onTaskSuccess(bucket: String?, objectKey: String?) {
val requestParams: IdentifyIdOcrVerifyBean.Request = IdentifyIdOcrVerifyBean.Request(bizToken, objectKey!!) val requestParams: IdentifyIdOcrVerifyBean.Request = IdentifyIdOcrVerifyBean.Request(bizToken, objectKey!!)
ApiService.identifyIdOcrVerify(identifyIdOcrVerifyCallback, requestParams) ApiService.identifyIdOcrVerify(identifyIdOcrVerifyCallback, requestParams)
} }
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/bt_action_card"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="200dp"
android:text="身份证OCR"
android:textColor="@android:color/black"
android:textSize="20sp" />
<Button
android:id="@+id/bt_action_yy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:text="活体检测"
android:textColor="@android:color/black"
android:textSize="20sp" />
<Button
android:id="@+id/bt_business_license"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="50dp"
android:text="执照采集"
android:textColor="@android:color/black"
android:textSize="20sp" />
</LinearLayout>
\ No newline at end of file
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