diff --git a/frameworks/js/napi/user_auth/src/user_auth_instance_v10.cpp b/frameworks/js/napi/user_auth/src/user_auth_instance_v10.cpp index 8d6f7b3762d32f7c9cf81ef7de193ba7ce9b091e..e03b7d841a6501717978530090545cfffa47f1e3 100644 --- a/frameworks/js/napi/user_auth/src/user_auth_instance_v10.cpp +++ b/frameworks/js/napi/user_auth/src/user_auth_instance_v10.cpp @@ -156,6 +156,7 @@ UserAuthResultCode UserAuthInstanceV10::SetTipCallback(napi_env env, napi_value IAM_LOGE("malloc tip callback fail"); return UserAuthResultCode::OHOS_INVALID_PARAM; } + callback_->SetTipCallback(callbackRef); IAM_LOGI("SetTipCallback success"); return UserAuthResultCode::SUCCESS; diff --git a/frameworks/native/common/attributes/src/attributes.cpp b/frameworks/native/common/attributes/src/attributes.cpp index a8939c0cd89d14aaafb0f78f2e870727a9a5d0b9..4560fe4cc689c03c8bb1f728b594bfcb1a22db60 100644 --- a/frameworks/native/common/attributes/src/attributes.cpp +++ b/frameworks/native/common/attributes/src/attributes.cpp @@ -71,6 +71,7 @@ public: bool GetAttributesValue(AttributeKey key, Impl &array) const; std::vector Serialize() const; std::vector GetKeys() const; + bool HasAttribute(AttributeKey key) const; static bool EncodeUint32Value(uint32_t src, std::vector &dst); static bool DecodeUint32Value(const std::vector &src, uint32_t &dst); @@ -674,6 +675,11 @@ std::vector Attributes::Impl::GetKeys() const return keys; } +bool Attributes::Impl::HasAttribute(AttributeKey key) const +{ + return (map_.find(key) != map_.end()); +} + bool Attributes::Impl::EncodeBoolValue(bool src, std::vector &dst) { std::vector out(1); // only 1 @@ -1384,6 +1390,14 @@ std::vector Attributes::GetKeys() const } return impl_->GetKeys(); } + +bool Attributes::HasAttribute(AttributeKey key) const +{ + if (!impl_) { + return false; + } + return impl_->HasAttribute(key); +} } // namespace UserAuth } // namespace UserIam } // namespace OHOS \ No newline at end of file diff --git a/interfaces/inner_api/attributes.h b/interfaces/inner_api/attributes.h index a1eea5065a5925ecb862c505bdb8e9095777b3fd..5fa2ebc3473cbf7ca8b0332106beb31797437ff5 100644 --- a/interfaces/inner_api/attributes.h +++ b/interfaces/inner_api/attributes.h @@ -205,6 +205,11 @@ public: ATTR_TOKEN_TIME_INTERVAL = 100091, /* credential length, the value type is uint32_t. */ ATTR_CREDENTIAL_LENGTH = 100092, + /* + * Is token in attribute generated by remote device, if not setted indicate token generated by local device. + * The value type is bool. + */ + ATTR_TOKEN_FROM_REMOTE_DEVICE = 100093, }; /** @@ -525,6 +530,13 @@ public: */ std::vector GetKeys() const; + /** + * @brief Is specific attribute setted. + * + * @return Return is specific attribute setted. + */ + bool HasAttribute(AttributeKey key) const; + private: class Impl; std::unique_ptr impl_ {nullptr}; diff --git a/services/context/inc/base_context.h b/services/context/inc/base_context.h index 68d2b8a25bef25ebe8d0575b6d7057506deecd1c..0e4dd94b520e2b2e26dc70d9ee6451dc06142fa2 100644 --- a/services/context/inc/base_context.h +++ b/services/context/inc/base_context.h @@ -68,7 +68,7 @@ private: uint64_t contextId_ = INVALID_CONTEXT_ID; std::string description_; bool hasStarted_ = false; - std::mutex mutex_; + mutable std::recursive_mutex mutex_; int32_t latestError_ = ResultCode::GENERAL_ERROR; }; } // namespace UserAuth diff --git a/services/context/inc/widget_client.h b/services/context/inc/widget_client.h index d5fb6359ed24b92ed2a8baecee5b306fbfde30e9..7c788ae0deca71cd74fd2ec146e47c59efb29e90 100644 --- a/services/context/inc/widget_client.h +++ b/services/context/inc/widget_client.h @@ -54,6 +54,7 @@ public: void SetSensorInfo(const std::string &info); void Reset(); void ForceStopAuth(); + void ClearSchedule(uint64_t contextId); // extra info void SetChallenge(const std::vector &challenge); @@ -68,7 +69,6 @@ private: void InsertScheduleNode(uint64_t contextId, std::shared_ptr &scheduleNode); void RemoveScheduleNode(uint64_t contextId); std::shared_ptr GetScheduleNode(uint64_t contextId); - void ClearSchedule(uint64_t contextId); void WidgetLoad(uint64_t contextId, std::vector &authTypeList); void WidgetRelease(uint64_t contextId, std::vector &authTypeList); diff --git a/services/context/inc/widget_context.h b/services/context/inc/widget_context.h index 5f6e9d0edce6647cb0c9adf3ac05f01834826616..f064423b5e33366fe6353b4c6f4132830b856bcd 100644 --- a/services/context/inc/widget_context.h +++ b/services/context/inc/widget_context.h @@ -117,6 +117,7 @@ private: bool IsSupportFollowCallerUi(); bool IsInFollowCallerList(); void SetSysDialogZOrder(WidgetCmdParameters &widgetCmdParameters); + bool IsSingleFaceOrFingerPrintAuth(); bool IsNavigationAuth(); UserAuthTipCode GetAuthTipCode(int32_t authResult, int32_t freezingTime); diff --git a/services/context/src/base_context.cpp b/services/context/src/base_context.cpp index 5867ea5849c7d13871756cdf04ca6de35e417d44..9ac39280cf675f51536f67156b749571b7daacbb 100644 --- a/services/context/src/base_context.cpp +++ b/services/context/src/base_context.cpp @@ -81,7 +81,7 @@ std::string BaseContext::GetCallerName() const bool BaseContext::Start() { - std::lock_guard guard(mutex_); + std::lock_guard guard(mutex_); IAM_LOGD("%{public}s start", GetDescription()); if (hasStarted_) { IAM_LOGI("%{public}s context has started, cannot start again", GetDescription()); @@ -93,12 +93,14 @@ bool BaseContext::Start() bool BaseContext::Stop() { + std::lock_guard guard(mutex_); IAM_LOGD("%{public}s start", GetDescription()); return OnStop(); } std::shared_ptr BaseContext::GetScheduleNode(uint64_t scheduleId) const { + std::lock_guard guard(mutex_); for (auto const &schedule : scheduleList_) { if (schedule == nullptr) { continue; diff --git a/services/context/src/remote_auth_invoker_context.cpp b/services/context/src/remote_auth_invoker_context.cpp index 266ba6fd81e438c5d5a7e61a5444df266e1f8887..89d8166a7dac7a3ac3323d7d1a8555e6bd244da7 100644 --- a/services/context/src/remote_auth_invoker_context.cpp +++ b/services/context/src/remote_auth_invoker_context.cpp @@ -359,6 +359,8 @@ int32_t RemoteAuthInvokerContext::ProcAuthResultMsgInner(Attributes &message, in if (resultCode == ResultCode::SUCCESS) { bool setTokenRet = attr.SetUint8ArrayValue(Attributes::ATTR_SIGNATURE, authResultInfo.token); IF_FALSE_LOGE_AND_RETURN_VAL(setTokenRet, ResultCode::GENERAL_ERROR); + bool setTokenFromRemoteDevice = attr.SetBoolValue(Attributes::ATTR_TOKEN_FROM_REMOTE_DEVICE, true); + IF_FALSE_LOGE_AND_RETURN_VAL(setTokenFromRemoteDevice, ResultCode::GENERAL_ERROR); bool setUserId = attr.SetInt32Value(Attributes::ATTR_USER_ID, authResultInfo.userId); IF_FALSE_LOGE_AND_RETURN_VAL(setUserId, ResultCode::GENERAL_ERROR); } diff --git a/services/context/src/widget_client.cpp b/services/context/src/widget_client.cpp index f680c0c590ff1e308371f151ac225f694de397bf..2a7431463e9734824ab20ba7c383b8bc722b0df2 100644 --- a/services/context/src/widget_client.cpp +++ b/services/context/src/widget_client.cpp @@ -57,6 +57,7 @@ void WidgetClient::SetWidgetSchedule(uint64_t contextId, const std::shared_ptr lock(mutex_); if (type != WIDGET_NOTICE) { IAM_LOGE("Invalid notice type"); return ResultCode::INVALID_PARAMETERS; diff --git a/services/context/src/widget_context.cpp b/services/context/src/widget_context.cpp index d775e8e5095ba13bac69c4b7283cad987ae87cc0..3002577a458ce06aaba7fc696e4273b3ef494ed4 100644 --- a/services/context/src/widget_context.cpp +++ b/services/context/src/widget_context.cpp @@ -247,6 +247,7 @@ bool WidgetContext::OnStop() // response app.cancel() IAM_LOGI("%{public}s start", description_.c_str()); End(ResultCode::CANCELED); + WidgetClient::Instance().ClearSchedule(contextId_); return true; } diff --git a/services/ipc/src/user_auth_service.cpp b/services/ipc/src/user_auth_service.cpp index 21321eec5ebf7fd2fecf46f6c28e5aeeaf0f653d..7b7bba02f9d7eb3ad38b6a39cbec7d9a7c994874 100644 --- a/services/ipc/src/user_auth_service.cpp +++ b/services/ipc/src/user_auth_service.cpp @@ -1214,6 +1214,7 @@ int32_t UserAuthService::CheckSkipLockedBiometricAuth(int32_t userId, const Auth IAM_LOGE("get user auth profile failed"); continue; } + if (profile.remainTimes != 0 || type == PIN || type == PRIVATE_PIN) { authTypeList.push_back(type); }