mirror of
https://github.com/openharmony/useriam_user_auth.git
synced 2026-07-21 01:25:22 -04:00
update faceauth framework
Change-Id: Ieb20e8424f905de2def168cdf4f2ab5ad24b3110 Signed-off-by: Tianshi Liu <tianshi.liu@huawei.com>
This commit is contained in:
@@ -29,9 +29,9 @@ namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
AsyncCommandBase::AsyncCommandBase(std::string type, uint64_t scheduleId, std::shared_ptr<Executor> executor)
|
||||
: scheduleId_(scheduleId),
|
||||
executor_(executor)
|
||||
executor_(executor),
|
||||
commandId_(GenerateCommandId())
|
||||
{
|
||||
commandId_ = GenerateCommandId();
|
||||
std::ostringstream ss;
|
||||
ss << "Command(type:" << type << ", id:" << commandId_ << ", scheduleId:" << GET_MASKED_STRING(scheduleId_)
|
||||
<< ")";
|
||||
@@ -40,7 +40,7 @@ AsyncCommandBase::AsyncCommandBase(std::string type, uint64_t scheduleId, std::s
|
||||
|
||||
void AsyncCommandBase::OnHdiDisconnect()
|
||||
{
|
||||
IAM_LOGE("driver disconnect, %{public}s end process", GetDescription());
|
||||
IAM_LOGI("driver disconnect, %{public}s end process", GetDescription());
|
||||
// Need new result code: hal invalid
|
||||
OnResult(ResultCode::GENERAL_ERROR);
|
||||
}
|
||||
@@ -88,7 +88,7 @@ uint32_t AsyncCommandBase::GenerateCommandId()
|
||||
static std::mutex mutex;
|
||||
static uint32_t commandId = 0;
|
||||
std::lock_guard<std::mutex> guard(mutex);
|
||||
commandId++;
|
||||
++commandId;
|
||||
return commandId;
|
||||
}
|
||||
} // namespace UserAuth
|
||||
|
||||
@@ -62,7 +62,7 @@ void AuthCommand::OnResultInner(ResultCode result, const std::vector<uint8_t> &e
|
||||
IF_FALSE_LOGE_AND_RETURN(executorMessenger != nullptr);
|
||||
|
||||
std::vector<uint8_t> nonConstExtraInfo(extraInfo.begin(), extraInfo.end());
|
||||
std::shared_ptr<AuthResPool::AuthAttributes> authAttributes = Common::MakeShared<AuthResPool::AuthAttributes>();
|
||||
auto authAttributes = Common::MakeShared<AuthResPool::AuthAttributes>();
|
||||
IF_FALSE_LOGE_AND_RETURN(authAttributes != nullptr);
|
||||
authAttributes->SetUint32Value(AUTH_RESULT_CODE, result);
|
||||
authAttributes->SetUint8ArrayValue(AUTH_RESULT, nonConstExtraInfo);
|
||||
@@ -71,7 +71,7 @@ void AuthCommand::OnResultInner(ResultCode result, const std::vector<uint8_t> &e
|
||||
IAM_LOGI("%{public}s call fininsh fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call fininsh success result=%{public}d", GetDescription(), result);
|
||||
IAM_LOGI("%{public}s call fininsh success result %{public}d", GetDescription(), result);
|
||||
}
|
||||
|
||||
void AuthCommand::OnAcquireInfo(int32_t acquire, const std::vector<uint8_t> &extraInfo)
|
||||
@@ -82,15 +82,15 @@ void AuthCommand::OnAcquireInfo(int32_t acquire, const std::vector<uint8_t> &ext
|
||||
IF_FALSE_LOGE_AND_RETURN(executorMessenger != nullptr);
|
||||
|
||||
std::vector<uint8_t> nonConstExtraInfo(extraInfo.begin(), extraInfo.end());
|
||||
std::shared_ptr<AuthResPool::AuthMessage> msg = Common::MakeShared<AuthResPool::AuthMessage>(nonConstExtraInfo);
|
||||
auto msg = Common::MakeShared<AuthResPool::AuthMessage>(nonConstExtraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(msg != nullptr);
|
||||
int32_t ret = executorMessenger->SendData(scheduleId_, transNum_, TYPE_ALL_IN_ONE, TYPE_CO_AUTH, msg);
|
||||
transNum_++;
|
||||
++transNum_;
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGI("%{public}s call SendData fail", GetDescription());
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call SendData success acquire=%{public}d", GetDescription(), acquire);
|
||||
IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
|
||||
@@ -60,7 +60,7 @@ void EnrollCommand::OnResultInner(ResultCode result, const std::vector<uint8_t>
|
||||
IF_FALSE_LOGE_AND_RETURN(executorMessenger != nullptr);
|
||||
|
||||
std::vector<uint8_t> nonConstExtraInfo(extraInfo.begin(), extraInfo.end());
|
||||
std::shared_ptr<AuthResPool::AuthAttributes> authAttributes = Common::MakeShared<AuthResPool::AuthAttributes>();
|
||||
auto authAttributes = Common::MakeShared<AuthResPool::AuthAttributes>();
|
||||
IF_FALSE_LOGE_AND_RETURN(authAttributes != nullptr);
|
||||
authAttributes->SetUint32Value(AUTH_RESULT_CODE, result);
|
||||
authAttributes->SetUint8ArrayValue(AUTH_RESULT, nonConstExtraInfo);
|
||||
@@ -69,7 +69,7 @@ void EnrollCommand::OnResultInner(ResultCode result, const std::vector<uint8_t>
|
||||
IAM_LOGI("%{public}s call fininsh fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call fininsh success result=%{public}d", GetDescription(), result);
|
||||
IAM_LOGI("%{public}s call fininsh success result %{public}d", GetDescription(), result);
|
||||
}
|
||||
|
||||
void EnrollCommand::OnAcquireInfo(int32_t acquire, const std::vector<uint8_t> &extraInfo)
|
||||
@@ -80,15 +80,15 @@ void EnrollCommand::OnAcquireInfo(int32_t acquire, const std::vector<uint8_t> &e
|
||||
IF_FALSE_LOGE_AND_RETURN(executorMessenger != nullptr);
|
||||
|
||||
std::vector<uint8_t> nonConstExtraInfo(extraInfo.begin(), extraInfo.end());
|
||||
std::shared_ptr<AuthResPool::AuthMessage> msg = Common::MakeShared<AuthResPool::AuthMessage>(nonConstExtraInfo);
|
||||
auto msg = Common::MakeShared<AuthResPool::AuthMessage>(nonConstExtraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(msg != nullptr);
|
||||
int32_t ret = executorMessenger->SendData(scheduleId_, transNum_, TYPE_ALL_IN_ONE, TYPE_CO_AUTH, msg);
|
||||
transNum_++;
|
||||
++transNum_;
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGI("%{public}s call SendData fail", GetDescription());
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call SendData success acquire=%{public}d", GetDescription(), acquire);
|
||||
IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
|
||||
@@ -60,7 +60,7 @@ void IdentifyCommand::OnResultInner(ResultCode result, const std::vector<uint8_t
|
||||
IF_FALSE_LOGE_AND_RETURN(executorMessenger != nullptr);
|
||||
|
||||
std::vector<uint8_t> nonConstExtraInfo(extraInfo.begin(), extraInfo.end());
|
||||
std::shared_ptr<AuthResPool::AuthAttributes> authAttributes = Common::MakeShared<AuthResPool::AuthAttributes>();
|
||||
auto authAttributes = Common::MakeShared<AuthResPool::AuthAttributes>();
|
||||
IF_FALSE_LOGE_AND_RETURN(authAttributes != nullptr);
|
||||
authAttributes->SetUint32Value(AUTH_RESULT_CODE, result);
|
||||
authAttributes->SetUint8ArrayValue(AUTH_RESULT, nonConstExtraInfo);
|
||||
@@ -69,7 +69,7 @@ void IdentifyCommand::OnResultInner(ResultCode result, const std::vector<uint8_t
|
||||
IAM_LOGI("%{public}s call fininsh fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call fininsh success result=%{public}d", GetDescription(), result);
|
||||
IAM_LOGI("%{public}s call fininsh success result %{public}d", GetDescription(), result);
|
||||
}
|
||||
|
||||
void IdentifyCommand::OnAcquireInfo(int32_t acquire, const std::vector<uint8_t> &extraInfo)
|
||||
@@ -80,15 +80,15 @@ void IdentifyCommand::OnAcquireInfo(int32_t acquire, const std::vector<uint8_t>
|
||||
IF_FALSE_LOGE_AND_RETURN(executorMessenger != nullptr);
|
||||
|
||||
std::vector<uint8_t> nonConstExtraInfo(extraInfo.begin(), extraInfo.end());
|
||||
std::shared_ptr<AuthResPool::AuthMessage> msg = Common::MakeShared<AuthResPool::AuthMessage>(nonConstExtraInfo);
|
||||
auto msg = Common::MakeShared<AuthResPool::AuthMessage>(nonConstExtraInfo);
|
||||
IF_FALSE_LOGE_AND_RETURN(msg != nullptr);
|
||||
int32_t ret = executorMessenger->SendData(scheduleId_, transNum_, TYPE_ALL_IN_ONE, TYPE_CO_AUTH, msg);
|
||||
transNum_++;
|
||||
++transNum_;
|
||||
if (ret != USERAUTH_SUCCESS) {
|
||||
IAM_LOGI("%{public}s call SendData fail", GetDescription());
|
||||
IAM_LOGE("%{public}s call SendData fail", GetDescription());
|
||||
return;
|
||||
}
|
||||
IAM_LOGI("%{public}s call SendData success acquire=%{public}d", GetDescription(), acquire);
|
||||
IAM_LOGI("%{public}s call SendData success acquire %{public}d", GetDescription(), acquire);
|
||||
}
|
||||
} // namespace UserAuth
|
||||
} // namespace UserIAM
|
||||
|
||||
@@ -57,7 +57,10 @@ void Driver::OnHdiDisconnect()
|
||||
IAM_LOGI("start");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (const auto &executor : executorList_) {
|
||||
// executor is non-null
|
||||
if (executor == nullptr) {
|
||||
IAM_LOGE("executor is null");
|
||||
continue;
|
||||
}
|
||||
executor->OnHdiDisconnect();
|
||||
}
|
||||
executorList_.clear();
|
||||
@@ -69,7 +72,10 @@ void Driver::OnFrameworkReady()
|
||||
IAM_LOGI("start");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (const auto &executor : executorList_) {
|
||||
// executor is non-null
|
||||
if (executor == nullptr) {
|
||||
IAM_LOGE("executor is null");
|
||||
continue;
|
||||
}
|
||||
executor->OnFrameworkReady();
|
||||
}
|
||||
IAM_LOGI("success");
|
||||
|
||||
@@ -29,16 +29,15 @@
|
||||
namespace OHOS {
|
||||
namespace UserIAM {
|
||||
namespace UserAuth {
|
||||
const std::string GROUP_SCHEDULE = "GROUP_SCHEDULE";
|
||||
const char IAM_EVENT_KEY[] = "bootevent.useriam.fwkready";
|
||||
int32_t DriverManager::Start(const std::map<std::string, HdiConfig> &hdiName2Config)
|
||||
{
|
||||
IAM_LOGI("start");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (!HdiConfigIsValid(hdiName2Config)) {
|
||||
IAM_LOGE("service config is not valid");
|
||||
return USERAUTH_ERROR;
|
||||
}
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
hdiName2Config_ = hdiName2Config;
|
||||
serviceName2Driver_.clear();
|
||||
for (auto const &pair : hdiName2Config) {
|
||||
@@ -63,8 +62,8 @@ bool DriverManager::HdiConfigIsValid(const std::map<std::string, HdiConfig> &hdi
|
||||
std::set<uint16_t> idSet;
|
||||
for (auto const &pair : hdiName2Config) {
|
||||
uint16_t id = pair.second.id;
|
||||
if (idSet.count(id) != 0) {
|
||||
IAM_LOGE("duplicate hdi id %{public}d", id);
|
||||
if (idSet.find(id) != idSet.end()) {
|
||||
IAM_LOGE("duplicate hdi id %{public}hu", id);
|
||||
return false;
|
||||
}
|
||||
if (pair.second.driver == nullptr) {
|
||||
@@ -115,11 +114,14 @@ void DriverManager::OnReceive(const ServiceStatus &status)
|
||||
{
|
||||
IAM_LOGI("service %{public}s receive status", status.serviceName.c_str());
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (serviceName2Driver_.count(status.serviceName) == 0) {
|
||||
auto driverIter = serviceName2Driver_.find(status.serviceName);
|
||||
if (driverIter == serviceName2Driver_.end()) {
|
||||
IAM_LOGI("service name not match");
|
||||
return;
|
||||
}
|
||||
|
||||
auto driver = driverIter->second;
|
||||
IF_FALSE_LOGE_AND_RETURN(driver != nullptr);
|
||||
switch (status.status) {
|
||||
case SERVIE_STATUS_START:
|
||||
IAM_LOGI("service %{public}s status change to start", status.serviceName.c_str());
|
||||
@@ -127,7 +129,7 @@ void DriverManager::OnReceive(const ServiceStatus &status)
|
||||
IAM_LOGE("service %{public}s is not running, ignore this message", status.serviceName.c_str());
|
||||
break;
|
||||
}
|
||||
serviceName2Driver_[status.serviceName]->OnHdiConnect();
|
||||
driver->OnHdiConnect();
|
||||
break;
|
||||
case SERVIE_STATUS_STOP:
|
||||
IAM_LOGI("service %{public}s status change to stop", status.serviceName.c_str());
|
||||
@@ -135,7 +137,7 @@ void DriverManager::OnReceive(const ServiceStatus &status)
|
||||
IAM_LOGE("service %{public}s is running, ignore this message", status.serviceName.c_str());
|
||||
break;
|
||||
}
|
||||
serviceName2Driver_[status.serviceName]->OnHdiDisconnect();
|
||||
driver->OnHdiDisconnect();
|
||||
break;
|
||||
default:
|
||||
IAM_LOGE("service %{public}s status invalid", status.serviceName.c_str());
|
||||
@@ -171,7 +173,7 @@ void DriverManager::SubscribeFrameworkRedayEvent()
|
||||
return;
|
||||
}
|
||||
if (strcmp(value, "true")) {
|
||||
IAM_LOGI("event value is not true");
|
||||
IAM_LOGE("event value is not true");
|
||||
return;
|
||||
}
|
||||
DriverManager::GetInstance().OnFrameworkReady();
|
||||
@@ -189,6 +191,10 @@ void DriverManager::OnAllHdiDisconnect()
|
||||
IAM_LOGI("start");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto const &pair : serviceName2Driver_) {
|
||||
if (pair.second == nullptr) {
|
||||
IAM_LOGE("pair.second is null");
|
||||
continue;
|
||||
}
|
||||
pair.second->OnHdiDisconnect();
|
||||
}
|
||||
IAM_LOGI("success");
|
||||
@@ -199,6 +205,10 @@ void DriverManager::OnAllHdiConnect()
|
||||
IAM_LOGI("start");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto const &pair : serviceName2Driver_) {
|
||||
if (pair.second == nullptr) {
|
||||
IAM_LOGE("pair.second is null");
|
||||
continue;
|
||||
}
|
||||
pair.second->OnHdiConnect();
|
||||
}
|
||||
IAM_LOGI("success");
|
||||
@@ -209,6 +219,10 @@ void DriverManager::OnFrameworkReady()
|
||||
IAM_LOGI("start");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto const &pair : serviceName2Driver_) {
|
||||
if (pair.second == nullptr) {
|
||||
IAM_LOGE("pair.second is null");
|
||||
continue;
|
||||
}
|
||||
pair.second->OnFrameworkReady();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ void Executor::RegisterExecutorCallback(ExecutorInfo &executorInfo)
|
||||
auto executorCallback = Common::MakeShared<FrameworkExecutorCallback>(shared_from_this());
|
||||
IF_FALSE_LOGE_AND_RETURN(executorCallback != nullptr);
|
||||
UserIAM::AuthResPool::ExecutorMgr::GetInstance().Register(executorInfo, executorCallback);
|
||||
IAM_LOGI("register executor callback ok, executor id=%{public}s",
|
||||
IAM_LOGI("register executor callback ok, executor id %{public}s",
|
||||
GET_MASKED_STRING(executorInfo.executorId).c_str());
|
||||
}
|
||||
|
||||
@@ -115,7 +115,11 @@ void Executor::RespondCallbackOnDisconnect()
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
for (auto it = command2Respond_.begin(); it != command2Respond_.end();) {
|
||||
auto cmdToProc = it;
|
||||
it++;
|
||||
++it;
|
||||
if (*cmdToProc == nullptr) {
|
||||
IAM_LOGI("cmdToProc is null");
|
||||
continue;
|
||||
}
|
||||
(*cmdToProc)->OnHdiDisconnect();
|
||||
}
|
||||
command2Respond_.clear();
|
||||
|
||||
@@ -209,8 +209,7 @@ ResultCode FrameworkExecutorCallback::ProcessCustomCommand(std::shared_ptr<AuthR
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = command->GetResult();
|
||||
return ret;
|
||||
return command->GetResult();
|
||||
}
|
||||
|
||||
ResultCode FrameworkExecutorCallback::ProcessGetTemplateCommand(
|
||||
|
||||
@@ -40,10 +40,7 @@ static inline std::string GetMaskedString(uint16_t val)
|
||||
|
||||
static inline std::string GetPointerNullStateString(void *p)
|
||||
{
|
||||
if (p == nullptr) {
|
||||
return "null";
|
||||
}
|
||||
return "non-null";
|
||||
return p == nullptr ? "null" : "non-null";
|
||||
}
|
||||
} // namespace Common
|
||||
} // namespace UserIAM
|
||||
|
||||
@@ -35,6 +35,7 @@ ohos_shared_library("userauth_framework") {
|
||||
deps = [ "//base/user_iam/user_auth/frameworks/co_auth:coauth_framework" ]
|
||||
|
||||
external_deps = [
|
||||
"face_auth:faceauth_framework",
|
||||
"hiviewdfx_hilog_native:libhilog",
|
||||
"ipc:ipc_core",
|
||||
"samgr_standard:samgr_proxy",
|
||||
@@ -42,10 +43,7 @@ ohos_shared_library("userauth_framework") {
|
||||
]
|
||||
|
||||
if (defined(ability_runtime_graphics) && ability_runtime_graphics) {
|
||||
deps += [
|
||||
"//base/user_iam/face_auth/interfaces/innerkits/faceauth:faceauth_framework",
|
||||
"//foundation/graphic/graphic:libsurface",
|
||||
]
|
||||
deps += [ "//foundation/graphic/graphic:libsurface" ]
|
||||
defines = [ "SUPPORT_SURFACE" ]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user