Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
bb4b087d
Commit
bb4b087d
authored
May 21, 2021
by
宋永孟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add 活体检测添加
parent
a589d400
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
128 additions
and
29 deletions
+128
-29
AppConfig.kt
...onLib/Common/src/main/java/com/yidian/common/AppConfig.kt
+0
-1
URLs.kt
...onLib/Common/src/main/java/com/yidian/common/http/URLs.kt
+1
-1
faceidmodel.bin
Components/newscontent/src/main/assets/faceidmodel.bin
+0
-0
ApiService.kt
...va/com/yidian/shenghuoquan/newscontent/http/ApiService.kt
+12
-13
CommonService.kt
...com/yidian/shenghuoquan/newscontent/http/CommonService.kt
+6
-2
AuthPersonalGetTokenBean.kt
...uan/newscontent/http/httpbean/AuthPersonalGetTokenBean.kt
+10
-0
AuthPersonalGetTokenCallback.kt
...newscontent/http/httpbean/AuthPersonalGetTokenCallback.kt
+1
-1
LoginLifeCircleActivity.kt
...an/shenghuoquan/newscontent/ui/LoginLifeCircleActivity.kt
+2
-2
AliveTestActivity.kt
...an/shenghuoquan/newscontent/ui/alive/AliveTestActivity.kt
+96
-9
No files found.
CommonLib/Common/src/main/java/com/yidian/common/AppConfig.kt
View file @
bb4b087d
...
...
@@ -38,6 +38,5 @@ class AppConfig {
const
val
ZIXUN_PUSH_LEVEL
=
PUSH_XIAOMI_SUPPORT_MASK
const
val
PUSH_LEVEL
=
(
PUSH_XIAOMI_SUPPORT_MASK
or
PUSH_UMENG_SUPPORT_MASK
or
PUSH_GETUI_SUPPORT_MASK
or
PUSH_PASS_THROGH_UNIQUE_MASK
)
}
}
\ No newline at end of file
CommonLib/Common/src/main/java/com/yidian/common/http/URLs.kt
View file @
bb4b087d
...
...
@@ -44,7 +44,7 @@ class URLs {
const
val
pushTokenAndroid
=
"/push/token/android"
// 生活圈B端
const
val
authPersonalGetToken
=
"/
auth/personal/get_t
oken"
const
val
authPersonalGetToken
=
"/
Identify/IdOcr/getBizT
oken"
const
val
getKSYunToken
=
"/ksy/Ksyun/getToken"
const
val
getIDCardOCR
=
"Identify/IdOcr/idCardOcr"
}
...
...
Components/newscontent/src/main/assets/faceidmodel.bin
0 → 100755
View file @
bb4b087d
File added
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/ApiService.kt
View file @
bb4b087d
...
...
@@ -10,11 +10,11 @@ import com.yidian.common.http.HttpParamsUtils
import
com.yidian.common.http.HttpResult
import
com.yidian.common.http.HttpResultSubscriber
import
com.yidian.common.http.TransformUtil
import
com.yidian.common.http.httpbean.WebResult
import
com.yidian.common.utils.ToolsUtil
import
com.yidian.http.ServiceFactory
import
com.yidian.shenghuoquan.newscontent.bean.DynamicExpressionBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.*
import
com.yidian.common.http.httpbean.WebResult
import
com.yidian.common.utils.ToolsUtil
import
com.yidian.xarc.xbrid.XBridManager
import
okhttp3.MultipartBody
import
org.json.JSONObject
...
...
@@ -23,20 +23,19 @@ class ApiService {
companion
object
{
//获取活体检测接口
fun
authPersonalGetToken
(
apiCallback
:
AuthPersonalGetTokenCallback
,
requestParams
:
HashMap
<
String
,
String
>
)
{
fun
authPersonalGetToken
(
apiCallback
:
AuthPersonalGetTokenCallback
,
requestParams
:
AuthPersonalGetTokenBean
.
Request
)
{
val
paramsMap
=
HttpParamsUtils
.
getParamsMap
()
ServiceFactory
.
getInstance
().
createService
(
CommonService
::
class
.
java
)
.
authPersonalGetToken
(
paramsMap
,
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultSubscriber
<
Any
?>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
Any
?
>?)
{
apiCallback
.
getTokenSuccess
(
result
)
}
override
fun
onFailer
(
result
:
HttpResult
<
Any
?
>?)
{
.
authPersonalGetToken
(
paramsMap
,
requestParams
)
.
compose
(
TransformUtil
.
defaultSchedulers
())
.
subscribe
(
object
:
HttpResultSubscriber
<
AuthPersonalGetTokenBean
.
Response
?>()
{
override
fun
onSuccess
(
result
:
HttpResult
<
AuthPersonalGetTokenBean
.
Response
?
>?)
{
apiCallback
.
getTokenSuccess
(
result
)
}
}
})
override
fun
onFailer
(
result
:
HttpResult
<
AuthPersonalGetTokenBean
.
Response
?
>?)
{
}
})
}
//获取金山云token接口
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/CommonService.kt
View file @
bb4b087d
...
...
@@ -102,8 +102,12 @@ interface CommonService {
@POST
(
URLs
.
pushTokenAndroid
)
fun
pushTokenAndroid
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
PushTokenAndroidBean
.
Request
):
Observable
<
HttpResult
<
Any
?
>>
@GET
(
URLs
.
authPersonalGetToken
)
fun
authPersonalGetToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@QueryMap
requestParams
:
Map
<
String
,
String
>):
Observable
<
HttpResult
<
Any
?
>>
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
authPersonalGetToken
)
fun
authPersonalGetToken
(
@QueryMap
commonParams
:
Map
<
String
,
String
>,
@Body
requestParams
:
AuthPersonalGetTokenBean
.
Request
):
Observable
<
HttpResult
<
AuthPersonalGetTokenBean
.
Response
?
>>
// @(URLs.authPersonalGetToken)
// fun authPersonalGetToken(@QueryMap commonParams: Map<String, String>, @QueryMap requestParams: Map<String, String>): Observable<HttpResult<Any?>>
@Headers
(
"Content-Type: application/json"
)
@POST
(
URLs
.
getKSYunToken
)
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/httpbean/AuthPersonalGetTokenBean.kt
0 → 100644
View file @
bb4b087d
package
com.yidian.shenghuoquan.newscontent.http.httpbean
class
AuthPersonalGetTokenBean
(
var
request
:
Request
,
val
response
:
Response
)
{
data class
Request
(
var
id_number
:
String
,
var
id_card_name
:
String
,
var
liveness_type
:
String
,
var
biz_no
:
String
)
data class
Response
(
val
biz_token
:
String
)
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/http/httpbean/AuthPersonalGetTokenCallback.kt
View file @
bb4b087d
...
...
@@ -3,5 +3,5 @@ package com.yidian.shenghuoquan.newscontent.http.httpbean
import
com.yidian.common.http.HttpResult
interface
AuthPersonalGetTokenCallback
{
fun
getTokenSuccess
(
t
:
HttpResult
<
A
ny
?
>?)
fun
getTokenSuccess
(
t
:
HttpResult
<
A
uthPersonalGetTokenBean
.
Response
?
>?)
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/LoginLifeCircleActivity.kt
View file @
bb4b087d
...
...
@@ -41,8 +41,8 @@ class LoginLifeCircleActivity : BaseActivity<ActivityLoginBinding>() {
}
viewBind
.
loginBtn
.
setOnClickListener
{
startActivity
(
Intent
(
this
@LoginLifeCircleActivity
,
IDCardTestActivity
::
class
.
java
))
//
startActivity(Intent(this@LoginLifeCircleActivity, AliveTestActivity::class.java))
//
startActivity(Intent(this@LoginLifeCircleActivity, IDCardTestActivity::class.java))
startActivity
(
Intent
(
this
@LoginLifeCircleActivity
,
AliveTestActivity
::
class
.
java
))
}
}
}
\ No newline at end of file
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/alive/AliveTestActivity.kt
View file @
bb4b087d
package
com.yidian.shenghuoquan.newscontent.ui.alive
import
android.app.ProgressDialog
import
android.os.Bundle
import
android.util.Log
import
com.megvii.meglive_sdk.listener.DetectCallback
import
com.megvii.meglive_sdk.listener.PreCallback
import
com.megvii.meglive_sdk.manager.MegLiveManager
import
com.yidian.common.AppConfig
import
com.yidian.common.base.BaseActivity
import
com.yidian.common.http.HttpResult
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityAliveLayoutBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenBean
import
com.yidian.shenghuoquan.newscontent.http.httpbean.AuthPersonalGetTokenCallback
import
java.io.File
import
java.io.FileOutputStream
import
java.io.InputStream
/**
* Author: sym
* Date: 2021/5/19 6:11 PM
* Describe:
* Describe:
onPreStart showDialogDismiss onPreFinish progressDialogDismiss
*/
class
AliveTestActivity
:
BaseActivity
<
ActivityAliveLayoutBinding
>()
{
class
AliveTestActivity
:
BaseActivity
<
ActivityAliveLayoutBinding
>()
,
PreCallback
,
DetectCallback
{
private
var
sign
=
""
private
var
megLiveManager
:
MegLiveManager
?
=
null
private
var
modelPath
=
""
// 模型本地存放路径
private
var
mProgressDialog
:
ProgressDialog
?
=
null
private
val
VERIFY_URL
=
"https://api.megvii.com/faceid/v3/sdk/verify"
override
fun
createViewBinding
():
ActivityAliveLayoutBinding
{
return
ActivityAliveLayoutBinding
.
inflate
(
layoutInflater
)
...
...
@@ -35,22 +48,96 @@ class AliveTestActivity : BaseActivity<ActivityAliveLayoutBinding>() {
val
currtTime
=
System
.
currentTimeMillis
()
/
1000
val
expireTime
=
(
System
.
currentTimeMillis
()
+
60
*
60
*
100
)
/
1000
sign
=
GenerateSign
.
appSign
(
AppConfig
.
KUANGSHI_ALIVE_API_KEY
,
AppConfig
.
KUANGSHI_SECRET
,
currtTime
,
expireTime
)
Log
.
d
(
"song_test"
,
sign
)
megLiveManager
=
MegLiveManager
.
getInstance
()
modelPath
=
saveAssets
(
"faceidmodel.bin"
,
"model"
)
!!
mProgressDialog
=
ProgressDialog
(
this
)
mProgressDialog
!!
.
setCancelable
(
false
)
}
private
fun
setOnListener
()
{
viewBind
.
btActionYy
.
setOnClickListener
{
val
requestMap
=
HashMap
<
String
,
String
>()
requestMap
[
"id_card"
]
=
"13010519881211121X"
requestMap
[
"name"
]
=
"宋永孟"
ApiService
.
authPersonalGetToken
(
authPersonalGetTokenCallback
,
requestMap
)
val
requestParams
:
AuthPersonalGetTokenBean
.
Request
=
AuthPersonalGetTokenBean
.
Request
(
"13010519881211121X"
,
"宋永孟"
,
"meglive"
,
"merchant"
)
ApiService
.
authPersonalGetToken
(
authPersonalGetTokenCallback
,
requestParams
)
}
}
private
val
authPersonalGetTokenCallback
=
object
:
AuthPersonalGetTokenCallback
{
override
fun
getTokenSuccess
(
t
:
HttpResult
<
Any
?
>?)
{
Log
.
d
(
"song_test"
,
t
.
toString
())
override
fun
getTokenSuccess
(
t
:
HttpResult
<
AuthPersonalGetTokenBean
.
Response
?
>?)
{
Log
.
d
(
"song_test"
,
t
?.
result
?.
biz_token
)
megLiveManager
?.
preDetect
(
this
@AliveTestActivity
,
t
?.
result
?.
biz_token
,
"zh"
,
"https://api.megvii.com"
,
modelPath
,
this
@AliveTestActivity
)
}
}
private
fun
saveAssets
(
fileName
:
String
,
path
:
String
):
String
?
{
val
dir
=
File
(
getExternalFilesDir
(
"megvii"
),
path
)
if
(!
dir
.
exists
())
{
if
(!
dir
.
mkdirs
())
{
return
null
}
}
val
file
=
File
(
dir
,
fileName
)
var
fos
:
FileOutputStream
?
=
null
var
`is`
:
InputStream
?
=
null
var
ret
:
String
?
=
null
try
{
var
count
:
Int
val
buffer
=
ByteArray
(
1024
)
fos
=
FileOutputStream
(
file
)
`is`
=
this
.
assets
.
open
(
fileName
)
while
(
`is`
.
read
(
buffer
).
also
{
count
=
it
}
!=
-
1
)
{
fos
.
write
(
buffer
,
0
,
count
)
}
ret
=
file
.
absolutePath
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
return
null
}
finally
{
try
{
fos
?.
close
()
`is`
?.
close
()
}
catch
(
e
:
Exception
)
{
e
.
printStackTrace
()
}
}
return
ret
}
override
fun
onPreStart
()
{
showDialogDismiss
()
}
private
fun
showDialogDismiss
()
{
runOnUiThread
{
mProgressDialog
?.
show
()
}
}
override
fun
onPreFinish
(
token
:
String
?,
errorCode
:
Int
,
errorMessage
:
String
?)
{
progressDialogDismiss
()
if
(
errorCode
==
1000
)
{
megLiveManager
!!
.
setVerticalDetectionType
(
MegLiveManager
.
DETECT_VERITICAL_FRONT
)
megLiveManager
!!
.
startDetect
(
this
@AliveTestActivity
)
}
}
private
fun
progressDialogDismiss
()
{
runOnUiThread
{
if
(
mProgressDialog
!=
null
)
{
mProgressDialog
!!
.
dismiss
()
}
}
}
override
fun
onDetectFinish
(
token
:
String
?,
errorCode
:
Int
,
errorMessage
:
String
?,
data
:
String
?)
{
if
(
errorCode
==
1000
)
{
token
?.
let
{
verify
(
it
,
data
!!
.
toByteArray
())
}
}
}
private
fun
verify
(
token
:
String
,
data
:
ByteArray
)
{
showDialogDismiss
()
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment