@@ -20,7 +20,7 @@ useriam_faceauth是用户身份认证与访问控制子系统的人脸认证组
|
||||
|
||||
## 编译构建
|
||||
|
||||
useriam_faceauth是Open Harmony标准系统的组件,安装依赖工具、获取源码、编译流程请参考Open Harmony官方构建文档。链接如下:
|
||||
useriam_faceauth是OpenHarmony标准系统的组件,安装依赖工具、获取源码、编译流程请参考OpenHarmony官方构建文档。链接如下:
|
||||
|
||||
[搭建Windows开发环境](https://www.openharmony.cn/pages/00010101/)
|
||||
|
||||
@@ -31,14 +31,14 @@ useriam_faceauth是Open Harmony标准系统的组件,安装依赖工具、获
|
||||
在完成全量构建后,可以单独构建faceauth组件,命令如下:
|
||||
|
||||
```bash
|
||||
# ./build.sh $platform_build_comand --build-target faceauth
|
||||
# ./build.sh $platform_build_command --build-target faceauth
|
||||
# 以Hi3516DV300为例,其他产品构建命令有所不同
|
||||
./build.sh --product-name Hi3516DV300 --build-target faceauth
|
||||
```
|
||||
|
||||
## 使用说明
|
||||
|
||||
本模块实现了Harmony OS用户认证接口,接口说明请参考[用户认证 JSAPI参考](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-useriam-userauth-0000001168311785)。
|
||||
本模块实现了用户认证接口,接口说明请参考[用户认证 JSAPI参考](https://developer.harmonyos.com/cn/docs/documentation/doc-references/js-apis-useriam-userauth-0000001168311785)。
|
||||
|
||||
使用示例:
|
||||
|
||||
@@ -99,7 +99,7 @@ export default {
|
||||
1. 在完成全量构建后,构建人脸faceauth UT测试例
|
||||
|
||||
```bash
|
||||
# ./build.sh $platform_build_comand --build-target faceauth_build_module_standard_test
|
||||
# ./build.sh $platform_build_command --build-target faceauth_build_module_standard_test
|
||||
# 以Hi3516DV300为例,其他产品构建命令有所不同
|
||||
./build.sh --product-name Hi3516DV300 --build-target faceauth_build_module_standard_test
|
||||
```
|
||||
|
||||
@@ -194,7 +194,7 @@ static int64_t GetTimestamp()
|
||||
t.tv_sec = 0;
|
||||
t.tv_nsec = 0;
|
||||
clock_gettime(CLOCK_REALTIME, &t);
|
||||
int64_t elapsedTime{((t.tv_sec) * SEC_TO_NANOSEC + t.tv_nsec)};
|
||||
int64_t elapsedTime { ((t.tv_sec) * SEC_TO_NANOSEC + t.tv_nsec) };
|
||||
return elapsedTime;
|
||||
}
|
||||
|
||||
@@ -380,7 +380,7 @@ napi_value FaceauthMgr::CreateExecutePromise(napi_env env, AsyncFaceAuthCallback
|
||||
napi_value FaceauthMgr::Execute(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGS_NUMBER_THREE;
|
||||
napi_value argv[ARGS_NUMBER_THREE] = {nullptr};
|
||||
napi_value argv[ARGS_NUMBER_THREE] = { nullptr };
|
||||
napi_value thisArg;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data));
|
||||
@@ -391,11 +391,11 @@ napi_value FaceauthMgr::Execute(napi_env env, napi_callback_info info)
|
||||
ParseString(env, type, argv[0]);
|
||||
ParseString(env, level, argv[1]);
|
||||
uint64_t reqId = GetTimestamp() % MAX_REQ_ID_COUNT;
|
||||
AsyncFaceAuthCallbackInfo *asyncCallbackInfo = new AsyncFaceAuthCallbackInfo {.env = env,
|
||||
AsyncFaceAuthCallbackInfo *asyncCallbackInfo = new AsyncFaceAuthCallbackInfo { .env = env,
|
||||
.asyncWork = nullptr,
|
||||
.deferred = nullptr,
|
||||
.type = type,
|
||||
.level = level};
|
||||
.level = level };
|
||||
InsertMap(reqId, asyncCallbackInfo);
|
||||
|
||||
if (argc == ARGS_NUMBER_THREE) {
|
||||
@@ -433,7 +433,7 @@ napi_value FaceauthMgr::CheckAvailability(napi_env env, napi_callback_info info)
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("Enter CheckAvailability.");
|
||||
size_t argc = ARGS_NUMBER_THREE;
|
||||
napi_value argv[ARGS_NUMBER_THREE] = {nullptr};
|
||||
napi_value argv[ARGS_NUMBER_THREE] = { nullptr };
|
||||
napi_value thisArg;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data));
|
||||
@@ -468,7 +468,7 @@ napi_value FaceauthMgr::JsOn(napi_env env, napi_callback_info info)
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("JsOn in");
|
||||
size_t argc = ARGS_NUMBER_TWO;
|
||||
napi_value argv[ARGS_NUMBER_TWO] = {nullptr};
|
||||
napi_value argv[ARGS_NUMBER_TWO] = { nullptr };
|
||||
napi_value thisArg;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data));
|
||||
@@ -504,7 +504,7 @@ napi_value FaceauthMgr::JsOff(napi_env env, napi_callback_info info)
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("JsOff in");
|
||||
size_t argc = ARGS_NUMBER_TWO;
|
||||
napi_value argv[ARGS_NUMBER_TWO] = {nullptr};
|
||||
napi_value argv[ARGS_NUMBER_TWO] = { nullptr };
|
||||
napi_value thisArg;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data));
|
||||
@@ -666,7 +666,7 @@ void FaceauthMgr::CreateEnrollAsynch(napi_env env, uint64_t reqId, napi_value ca
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("CreateEnrollAsynch reqId = xxxx%04llu", reqId);
|
||||
AsyncFaceAuthCallbackInfo *asyncCallbackInfo =
|
||||
new AsyncFaceAuthCallbackInfo {.env = env, .asyncWork = nullptr, .deferred = nullptr, .reqId = reqId};
|
||||
new AsyncFaceAuthCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr, .reqId = reqId };
|
||||
InsertMap(reqId, asyncCallbackInfo);
|
||||
|
||||
FACEAUTH_LABEL_LOGI("Enroll asyncCallback.");
|
||||
@@ -704,7 +704,7 @@ void FaceauthMgr::CreateEnrollAsynch(napi_env env, uint64_t reqId, napi_value ca
|
||||
napi_value FaceauthMgr::Enroll(napi_env env, napi_callback_info info)
|
||||
{
|
||||
size_t argc = ARGS_NUMBER_TWO;
|
||||
napi_value argv[ARGS_NUMBER_TWO] = {nullptr};
|
||||
napi_value argv[ARGS_NUMBER_TWO] = { nullptr };
|
||||
napi_value thisArg;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data));
|
||||
@@ -859,7 +859,7 @@ napi_value FaceauthMgr::Remove(napi_env env, napi_callback_info info)
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("Enter Remove.");
|
||||
size_t argc = ARGS_NUMBER_TWO;
|
||||
napi_value argv[ARGS_NUMBER_TWO] = {nullptr};
|
||||
napi_value argv[ARGS_NUMBER_TWO] = { nullptr };
|
||||
napi_value thisArg;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data));
|
||||
@@ -872,7 +872,7 @@ napi_value FaceauthMgr::Remove(napi_env env, napi_callback_info info)
|
||||
removeParam.reqId = reqId;
|
||||
removeParam.faceId = faceId;
|
||||
AsyncFaceAuthCallbackInfo *asyncCallbackInfo =
|
||||
new AsyncFaceAuthCallbackInfo {.env = env, .asyncWork = nullptr, .deferred = nullptr};
|
||||
new AsyncFaceAuthCallbackInfo { .env = env, .asyncWork = nullptr, .deferred = nullptr };
|
||||
InsertMap(reqId, asyncCallbackInfo);
|
||||
|
||||
if (argc == ARGS_NUMBER_TWO) {
|
||||
@@ -901,7 +901,7 @@ napi_value FaceauthMgr::GetEnrolledFaceIds(napi_env env, napi_callback_info info
|
||||
FACEAUTH_LABEL_LOGI("Enter GetEnrolledFaceIds.");
|
||||
|
||||
size_t argc = ARGS_NUMBER_ONE;
|
||||
napi_value argv[ARGS_NUMBER_ONE] = {nullptr};
|
||||
napi_value argv[ARGS_NUMBER_ONE] = { nullptr };
|
||||
napi_value thisArg;
|
||||
void *data = nullptr;
|
||||
NAPI_CALL(env, napi_get_cb_info(env, info, &argc, argv, &thisArg, &data));
|
||||
@@ -953,13 +953,13 @@ EXTERN_C_END
|
||||
/*
|
||||
* Module define
|
||||
*/
|
||||
static napi_module _module = {.nm_version = 1,
|
||||
static napi_module _module = { .nm_version = 1,
|
||||
.nm_flags = 0,
|
||||
.nm_filename = nullptr,
|
||||
.nm_register_func = Init,
|
||||
.nm_modname = "userIAM.userAuth",
|
||||
.nm_priv = ((void *) 0),
|
||||
.reserved = {0}};
|
||||
.reserved = { 0 } };
|
||||
/*
|
||||
* Module register function
|
||||
*/
|
||||
@@ -970,5 +970,4 @@ extern "C" __attribute__((constructor)) void RegisterModule(void)
|
||||
}
|
||||
} // namespace FaceAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
|
||||
} // namespace OHOS
|
||||
@@ -38,6 +38,7 @@ config("face_auth_services_public_config") {
|
||||
"${face_auth_innerkits_path}/include",
|
||||
"${face_auth_services_path}/include",
|
||||
"${face_auth_services_path}/mock/include",
|
||||
"${face_auth_services_path}/test/mock/include",
|
||||
"//foundation/appexecfwk/standard/interfaces/innerkits/libeventhandler/include",
|
||||
"//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy/include",
|
||||
"//utils/native/base/include",
|
||||
@@ -67,6 +68,7 @@ ohos_shared_library("face_auth_services") {
|
||||
"${face_auth_services_path}/mock/src/face_auth_algo_adapter.cpp",
|
||||
"${face_auth_services_path}/mock/src/face_auth_ca.cpp",
|
||||
"${face_auth_services_path}/mock/src/face_auth_algo_impl.cpp",
|
||||
"${face_auth_services_path}/src/face_auth_bms_adapter.cpp",
|
||||
]
|
||||
|
||||
configs = [ ":face_auth_services_config" ]
|
||||
@@ -13,20 +13,29 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef DISRIBUTED_PERMISSION_KIT_H
|
||||
#define DISRIBUTED_PERMISSION_KIT_H
|
||||
#ifndef FACE_AUTH_BMS_ADAPTER_H
|
||||
#define FACE_AUTH_BMS_ADAPTER_H
|
||||
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include "bundle_mgr_interface.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Security {
|
||||
namespace Permission {
|
||||
class DistributedPermissionKit {
|
||||
namespace UserIAM {
|
||||
namespace FaceAuth {
|
||||
class FaceAuthBmsAdapter {
|
||||
public:
|
||||
static int32_t CheckPermission(const std::string &permissionName, const std::string &appIdInfo);
|
||||
};
|
||||
} // namespace Permission
|
||||
} // namespace Security
|
||||
} // namespace OHOS
|
||||
FaceAuthBmsAdapter() = default;
|
||||
virtual ~FaceAuthBmsAdapter() = default;
|
||||
static std::shared_ptr<FaceAuthBmsAdapter> GetInstance();
|
||||
std::string GetCallingBundleName();
|
||||
|
||||
#endif // DISRIBUTED_PERMISSION_KIT_H
|
||||
private:
|
||||
sptr<AppExecFwk::IBundleMgr> GetBundleManager();
|
||||
static std::mutex mutex_;
|
||||
static std::shared_ptr<FaceAuthBmsAdapter> instance_;
|
||||
sptr<AppExecFwk::IBundleMgr> iBundleManager_;
|
||||
};
|
||||
} // namespace FaceAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
#endif // FACE_AUTH_BMS_ADAPTER_H
|
||||
@@ -72,7 +72,6 @@ private:
|
||||
void Prepare(HWExeType type);
|
||||
void SetChallenge(int64_t challenge);
|
||||
int32_t VerifyAuthToken(std::unique_ptr<uint8_t[]> authToken, uint32_t length, int type);
|
||||
std::string GetCallingBundleName();
|
||||
bool CheckFaceIDValidity(int32_t faceId);
|
||||
uint32_t SwitchFaceErrorCode(int32_t authErrorCode);
|
||||
bool CheckLockOutMode(const uint64_t reqId, const sptr<OnFaceAuth> &callback);
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "face_auth_bms_adapter.h"
|
||||
#include "constant.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "if_system_ability_manager.h"
|
||||
#include "iservice_registry.h"
|
||||
#include "faceauth_log_wrapper.h"
|
||||
#include "sa_mgr_client.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace FaceAuth {
|
||||
std::mutex FaceAuthBmsAdapter::mutex_;
|
||||
std::shared_ptr<FaceAuthBmsAdapter> FaceAuthBmsAdapter::instance_ = nullptr;
|
||||
std::shared_ptr<FaceAuthBmsAdapter> FaceAuthBmsAdapter::GetInstance()
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
std::lock_guard<std::mutex> lock_l(mutex_);
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = std::make_shared<FaceAuthBmsAdapter>();
|
||||
}
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
sptr<AppExecFwk::IBundleMgr> FaceAuthBmsAdapter::GetBundleManager()
|
||||
{
|
||||
auto bundleObj = OHOS::DelayedSingleton<AAFwk::SaMgrClient>::GetInstance()->GetSystemAbility(
|
||||
Constant::BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (bundleObj == nullptr) {
|
||||
FACEAUTH_LABEL_LOGE("failed to get bundle manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
iBundleManager_ = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
if (iBundleManager_ == nullptr) {
|
||||
FACEAUTH_LABEL_LOGI("iBundleMgr is null");
|
||||
return nullptr;
|
||||
}
|
||||
return iBundleManager_;
|
||||
}
|
||||
|
||||
std::string FaceAuthBmsAdapter::GetCallingBundleName()
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthBmsAdapter GetCallingBundleName start");
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
FACEAUTH_LABEL_LOGI("uid is %{public}d", uid);
|
||||
if (iBundleManager_ == nullptr) {
|
||||
iBundleManager_ = GetBundleManager();
|
||||
}
|
||||
std::string bundleName;
|
||||
bool result = iBundleManager_->GetBundleNameForUid(uid, bundleName);
|
||||
FACEAUTH_LABEL_LOGI("bundleName is %{public}s", bundleName.c_str());
|
||||
FACEAUTH_LABEL_LOGI("result is %{public}d", result);
|
||||
if (!result) {
|
||||
FACEAUTH_LABEL_LOGE("cannot get bundle name by uid %{public}d", uid);
|
||||
return "";
|
||||
}
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthBmsAdapter GetCallingBundleName end");
|
||||
return bundleName;
|
||||
}
|
||||
} // namespace FaceAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
@@ -28,6 +28,7 @@
|
||||
#include "iservice_registry.h"
|
||||
#include "ipc_skeleton.h"
|
||||
#include "sa_mgr_client.h"
|
||||
#include "face_auth_bms_adapter.h"
|
||||
|
||||
using namespace OHOS::AAFwk;
|
||||
|
||||
@@ -58,8 +59,8 @@ FaceAuthManager::~FaceAuthManager()
|
||||
|
||||
int32_t FaceAuthManager::Enroll(const EnrollParam ¶m, const sptr<OnFaceAuth> &callback)
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI(
|
||||
"reqId: xxxx%04llu, challenge: %{private}lld,faceId: %{private}d", param.reqId, param.challenge, param.faceId);
|
||||
FACEAUTH_LABEL_LOGI("reqId: xxxx%04llu, challenge: %{private}lld,faceId: %{private}d", param.reqId, param.challenge,
|
||||
param.faceId);
|
||||
if (CheckEnrollParam(param, callback) != FA_RET_OK) {
|
||||
return FA_RET_ERROR;
|
||||
}
|
||||
@@ -122,10 +123,7 @@ int32_t FaceAuthManager::Authenticate(const AuthParam ¶m, const sptr<OnFaceA
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("reqId: xxxx%04llu, flags: %{public}d, challenge: %{private}lld, "
|
||||
"faceId: %{private}d",
|
||||
param.reqId,
|
||||
param.flags,
|
||||
param.challenge,
|
||||
param.faceId);
|
||||
param.reqId, param.flags, param.challenge, param.faceId);
|
||||
if (CheckAuthParam(param, callback) != 0) {
|
||||
return FA_RET_ERROR;
|
||||
}
|
||||
@@ -188,7 +186,7 @@ int32_t FaceAuthManager::CheckAuthParam(const AuthParam ¶m, const sptr<OnFac
|
||||
int32_t FaceAuthManager::Init()
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthManager::Init");
|
||||
std::string bundleName = GetCallingBundleName();
|
||||
std::string bundleName = FaceAuthBmsAdapter::GetInstance()->GetCallingBundleName();
|
||||
if (bundleName == "") {
|
||||
FACEAUTH_LABEL_LOGE("FaceAuthManager::Init GetCallingBundleName Fail!");
|
||||
return FA_RET_ERROR;
|
||||
@@ -200,7 +198,7 @@ int32_t FaceAuthManager::Init()
|
||||
int32_t FaceAuthManager::Release()
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthManager::Release");
|
||||
std::string bundleName = GetCallingBundleName();
|
||||
std::string bundleName = FaceAuthBmsAdapter::GetInstance()->GetCallingBundleName();
|
||||
if (bundleName == "") {
|
||||
FACEAUTH_LABEL_LOGE("FaceAuthManager::Release GetCallingBundleName Fail!");
|
||||
return FA_RET_ERROR;
|
||||
@@ -218,9 +216,7 @@ void FaceAuthManager::HandleCallEnroll(const EnrollParam ¶m, const sptr<OnFa
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("reqId: xxxx%04llu, challenge: %{private}lld, "
|
||||
"faceId: %{private}d",
|
||||
param.reqId,
|
||||
param.challenge,
|
||||
param.faceId);
|
||||
param.reqId, param.challenge, param.faceId);
|
||||
if (CheckEnrollParam(param, callback) != FA_RET_OK) {
|
||||
return;
|
||||
}
|
||||
@@ -230,8 +226,9 @@ void FaceAuthManager::HandleCallEnroll(const EnrollParam ¶m, const sptr<OnFa
|
||||
FaceReqType reqType;
|
||||
reqType.reqId = param.reqId;
|
||||
reqType.operateType = FACE_OPERATE_TYPE_ENROLL;
|
||||
FaceAuthThreadPool::GetInstance()->AddTask(
|
||||
[&promiseobj, &producer]() { promiseobj.set_value(FaceAuthCamera::GetInstance()->OpenCamera(producer)); });
|
||||
FaceAuthThreadPool::GetInstance()->AddTask([&promiseobj, &producer]() {
|
||||
promiseobj.set_value(FaceAuthCamera::GetInstance()->OpenCamera(producer));
|
||||
});
|
||||
Prepare(HW_EXEC_TYPE_ENROOL);
|
||||
CallBackParam cbParam;
|
||||
cbParam.reqId = param.reqId;
|
||||
@@ -271,10 +268,7 @@ void FaceAuthManager::HandleCallAuthenticate(const AuthParam ¶m, const sptr<
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("reqId: xxxx%04llu, flags: %{public}d, challenge: %{private}lld, "
|
||||
"faceId: %{private}d",
|
||||
param.reqId,
|
||||
param.flags,
|
||||
param.challenge,
|
||||
param.faceId);
|
||||
param.reqId, param.flags, param.challenge, param.faceId);
|
||||
|
||||
if (CheckAuthParam(param, callback) != FA_RET_OK) {
|
||||
return;
|
||||
@@ -285,8 +279,9 @@ void FaceAuthManager::HandleCallAuthenticate(const AuthParam ¶m, const sptr<
|
||||
std::future<int32_t> futureobj = promiseobj.get_future();
|
||||
FaceReqType reqType = CreateAuthReqInfo(param.reqId, param.flags);
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthCurTaskNum is %{public}d ", FaceAuthThreadPool::GetInstance()->GetCurTaskNum());
|
||||
FaceAuthThreadPool::GetInstance()->AddTask(
|
||||
[&promiseobj, &producer]() { promiseobj.set_value(FaceAuthCamera::GetInstance()->OpenCamera(producer)); });
|
||||
FaceAuthThreadPool::GetInstance()->AddTask([&promiseobj, &producer]() {
|
||||
promiseobj.set_value(FaceAuthCamera::GetInstance()->OpenCamera(producer));
|
||||
});
|
||||
Prepare(HW_EXEC_TYPE_UNLOCK);
|
||||
SetChallenge(param.challenge);
|
||||
CallBackParam cbParam;
|
||||
@@ -332,8 +327,8 @@ void FaceAuthManager::HandleCallRemove(const RemoveParam ¶m, const sptr<OnFa
|
||||
return;
|
||||
}
|
||||
|
||||
void FaceAuthManager::ExecuteEnrollEvent(
|
||||
uint64_t reqId, int32_t faceId, std::vector<uint8_t> token, const sptr<OnFaceAuth> &callback)
|
||||
void FaceAuthManager::ExecuteEnrollEvent(uint64_t reqId, int32_t faceId, std::vector<uint8_t> token,
|
||||
const sptr<OnFaceAuth> &callback)
|
||||
{
|
||||
int32_t authErrorCode;
|
||||
FICode code;
|
||||
@@ -467,8 +462,8 @@ void FaceAuthManager::ExecuteAuthEvent(const uint64_t reqId, const int32_t flags
|
||||
return;
|
||||
}
|
||||
|
||||
void FaceAuthManager::HandleExceptionCallback(
|
||||
const FIResultType type, CallBackParam cbParam, const int32_t resetValue, const sptr<OnFaceAuth> &callback)
|
||||
void FaceAuthManager::HandleExceptionCallback(const FIResultType type, CallBackParam cbParam, const int32_t resetValue,
|
||||
const sptr<OnFaceAuth> &callback)
|
||||
{
|
||||
FaceReqType reqType;
|
||||
reqType.reqId = cbParam.reqId;
|
||||
@@ -496,7 +491,9 @@ bool FaceAuthManager::CheckLockOutMode(const uint64_t reqId, const sptr<OnFaceAu
|
||||
if (errorCount_ >= AUTH_FAIL_MAX_TIMES) {
|
||||
isLockOutMode_ = true;
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthCurTaskNum is %{public}d ", FaceAuthThreadPool::GetInstance()->GetCurTaskNum());
|
||||
FaceAuthThreadPool::GetInstance()->AddTask([this]() { StartTimer(); });
|
||||
FaceAuthThreadPool::GetInstance()->AddTask([this]() {
|
||||
StartTimer();
|
||||
});
|
||||
CallBackParam cbParam;
|
||||
cbParam.reqId = reqId;
|
||||
cbParam.code = CODE_CALLBACK_RESULT;
|
||||
@@ -644,14 +641,11 @@ int32_t FaceAuthManager::Remove(const RemoveParam ¶m, const sptr<OnFaceAuth>
|
||||
return FA_RET_OK;
|
||||
}
|
||||
|
||||
void FaceAuthManager::SendCallback(
|
||||
const FIResultType type, const CallBackParam cbParam, const sptr<OnFaceAuth> &callback)
|
||||
void FaceAuthManager::SendCallback(const FIResultType type, const CallBackParam cbParam,
|
||||
const sptr<OnFaceAuth> &callback)
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("type: %{public}d, reqId: xxxx%04llu, code: %{public}d, errorCode: %{public}d",
|
||||
type,
|
||||
cbParam.reqId,
|
||||
cbParam.code,
|
||||
cbParam.errorCode);
|
||||
FACEAUTH_LABEL_LOGI("type: %{public}d, reqId: xxxx%04llu, code: %{public}d, errorCode: %{public}d", type,
|
||||
cbParam.reqId, cbParam.code, cbParam.errorCode);
|
||||
Bundle bundleInfo;
|
||||
for (std::vector<uint8_t>::const_iterator iter = cbParam.authtoken.begin(); iter != cbParam.authtoken.end();
|
||||
++iter) {
|
||||
@@ -743,36 +737,6 @@ int32_t FaceAuthManager::SendCameraImage(std::unique_ptr<CameraImageStream> img)
|
||||
return FA_RET_OK;
|
||||
}
|
||||
|
||||
std::string FaceAuthManager::GetCallingBundleName()
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthManager GetCallingBundleName start");
|
||||
int32_t uid = IPCSkeleton::GetCallingUid();
|
||||
FACEAUTH_LABEL_LOGI("uid is %{public}d", uid);
|
||||
if (iBundleMgr_ == nullptr) {
|
||||
auto bundleObj =
|
||||
OHOS::DelayedSingleton<SaMgrClient>::GetInstance()->GetSystemAbility(BUNDLE_MGR_SERVICE_SYS_ABILITY_ID);
|
||||
if (bundleObj == nullptr) {
|
||||
FACEAUTH_LABEL_LOGE("failed to get bundle manager service.");
|
||||
return nullptr;
|
||||
}
|
||||
iBundleMgr_ = iface_cast<AppExecFwk::IBundleMgr>(bundleObj);
|
||||
if (iBundleMgr_ == nullptr) {
|
||||
FACEAUTH_LABEL_LOGI("iBundleMgr is null");
|
||||
return "";
|
||||
}
|
||||
}
|
||||
std::string bundleName;
|
||||
bool result = iBundleMgr_->GetBundleNameForUid(uid, bundleName);
|
||||
FACEAUTH_LABEL_LOGI("bundleName is %{public}s", bundleName.c_str());
|
||||
FACEAUTH_LABEL_LOGI("result is %{public}d", result);
|
||||
if (!result) {
|
||||
FACEAUTH_LABEL_LOGE("cannot get bundle name by uid %{public}d", uid);
|
||||
return "";
|
||||
}
|
||||
FACEAUTH_LABEL_LOGI("FaceAuthManager GetCallingBundleName end");
|
||||
return bundleName;
|
||||
}
|
||||
|
||||
std::list<int32_t> FaceAuthManager::GetEnrolledFaceIDs(const int32_t userId)
|
||||
{
|
||||
std::list<int32_t> faceInfolist;
|
||||
@@ -787,10 +751,8 @@ std::list<int32_t> FaceAuthManager::GetEnrolledFaceIDs(const int32_t userId)
|
||||
bool FaceAuthManager::CheckFaceIDValidity(int32_t faceId)
|
||||
{
|
||||
std::list<int32_t> enrolled_faceids = GetEnrolledFaceIDs(USER_ID_DEFAULT);
|
||||
FACEAUTH_LABEL_LOGI("faceId: %{public}d,enrolled_faceids size: %{public}d,enrolled_faceids[0]:%{public}d",
|
||||
faceId,
|
||||
enrolled_faceids.front(),
|
||||
enrolled_faceids.size());
|
||||
FACEAUTH_LABEL_LOGI("faceId: %{public}d,enrolled_faceids size: %{public}d,enrolled_faceids[0]:%{public}d", faceId,
|
||||
enrolled_faceids.front(), enrolled_faceids.size());
|
||||
if (std::find(enrolled_faceids.begin(), enrolled_faceids.end(), faceId) != enrolled_faceids.end()) {
|
||||
return true;
|
||||
}
|
||||
@@ -867,12 +829,12 @@ uint32_t FaceAuthManager::GenerateEventId()
|
||||
t.tv_sec = 0;
|
||||
t.tv_nsec = 0;
|
||||
clock_gettime(CLOCK_REALTIME, &t);
|
||||
int64_t elapsedTime {((t.tv_sec) * SEC_TO_NANOSEC + t.tv_nsec)};
|
||||
int64_t elapsedTime { ((t.tv_sec) * SEC_TO_NANOSEC + t.tv_nsec) };
|
||||
size_t elapsedHash = std::hash<std::string>()(std::to_string(elapsedTime));
|
||||
uint32_t eventId = static_cast<uint32_t>(elapsedHash);
|
||||
FACEAUTH_LABEL_LOGI("GenerateEventId generate eventId %{public}u", eventId);
|
||||
return eventId;
|
||||
}
|
||||
} // namespace FaceAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
} // namespace FaceAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "face_auth_bms_adapter.h"
|
||||
#include "faceauth_log_wrapper.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace FaceAuth {
|
||||
std::mutex FaceAuthBmsAdapter::mutex_;
|
||||
std::shared_ptr<FaceAuthBmsAdapter> FaceAuthBmsAdapter::instance_ = nullptr;
|
||||
std::shared_ptr<FaceAuthBmsAdapter> FaceAuthBmsAdapter::GetInstance()
|
||||
{
|
||||
if (instance_ == nullptr) {
|
||||
std::lock_guard<std::mutex> lock_l(mutex_);
|
||||
if (instance_ == nullptr) {
|
||||
instance_ = std::make_shared<FaceAuthBmsAdapter>();
|
||||
}
|
||||
}
|
||||
return instance_;
|
||||
}
|
||||
std::string FaceAuthBmsAdapter::GetCallingBundleName()
|
||||
{
|
||||
FACEAUTH_LABEL_LOGI("MOCK FaceAuthBmsAdapter::GetCallingBundleName bundle_name");
|
||||
return "bundle_name";
|
||||
}
|
||||
} // namespace FaceAuth
|
||||
} // namespace UserIAM
|
||||
} // namespace OHOS
|
||||
@@ -24,6 +24,7 @@ ohos_unittest("face_auth_manager_auth_test") {
|
||||
"src/face_auth_manager_auth_test.cpp",
|
||||
"${face_auth_services_path}/src/face_auth_service.cpp",
|
||||
"../../mock/src/mock_bundle_mgr.cpp",
|
||||
"../../mock/src/mock_bms_adapter.cpp",
|
||||
]
|
||||
|
||||
configs = [
|
||||
@@ -69,6 +70,7 @@ ohos_unittest("face_auth_manager_enroll_test") {
|
||||
"src/face_auth_manager_enroll_test.cpp",
|
||||
"${face_auth_services_path}/src/face_auth_service.cpp",
|
||||
"../../mock/src/mock_bundle_mgr.cpp",
|
||||
"../../mock/src/mock_bms_adapter.cpp",
|
||||
]
|
||||
|
||||
configs = [
|
||||
@@ -115,6 +117,7 @@ ohos_unittest("face_auth_manager_scenario_test") {
|
||||
"src/face_auth_manager_scenario_test.cpp",
|
||||
"${face_auth_services_path}/src/face_auth_service.cpp",
|
||||
"../../mock/src/mock_bundle_mgr.cpp",
|
||||
"../../mock/src/mock_bms_adapter.cpp",
|
||||
]
|
||||
|
||||
configs = [
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "distributed_permission_kit.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Security {
|
||||
namespace Permission {
|
||||
int32_t DistributedPermissionKit::CheckPermission(const std::string &permissionName, const std::string &appIdInfo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
} // namespace Permission
|
||||
} // namespace Security
|
||||
} // namespace OHOS
|
||||
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
|
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB |
|
Before Width: | Height: | Size: 4.9 KiB After Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 893 B After Width: | Height: | Size: 893 B |
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 6.6 KiB |
|
Before Width: | Height: | Size: 210 KiB After Width: | Height: | Size: 210 KiB |
|
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 9.6 KiB After Width: | Height: | Size: 9.6 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
@@ -15,7 +15,7 @@ useriam_path = "//base/useriam/faceauth"
|
||||
useriam_common_path = "${useriam_path}/common"
|
||||
face_auth_innerkits_path = "${useriam_path}/interfaces/innerkits/faceauth"
|
||||
useriam_auth_kits_path = "${useriam_path}/interfaces/kits"
|
||||
face_auth_services_path = "${useriam_path}/services/faceauth"
|
||||
face_auth_services_path = "${useriam_path}/service/faceauth"
|
||||
useriam_sa_path="${useriam_path}/sa_profile"
|
||||
aafwk_path = "//foundation/aafwk/standard"
|
||||
appexecfwk_path = "//foundation/appexecfwk/standard"
|
||||
|
||||