From 91d10ccbefab934c4a14253bee617cd79f384e5d Mon Sep 17 00:00:00 2001 From: adelelimi Date: Tue, 9 Sep 2025 11:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=93=9D=E9=BB=84=E5=B7=AE?= =?UTF-8?q?=E5=BC=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: adelelimi --- .../napi/user_auth/src/user_auth_instance_v10.cpp | 1 + .../native/common/attributes/src/attributes.cpp | 14 ++++++++++++++ interfaces/inner_api/attributes.h | 12 ++++++++++++ services/context/inc/base_context.h | 2 +- services/context/inc/widget_client.h | 2 +- services/context/inc/widget_context.h | 1 + services/context/src/base_context.cpp | 4 +++- .../context/src/remote_auth_invoker_context.cpp | 2 ++ services/context/src/widget_client.cpp | 1 + services/context/src/widget_context.cpp | 1 + services/ipc/src/user_auth_service.cpp | 1 + 11 files changed, 38 insertions(+), 3 deletions(-) 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 8d6f7b376..e03b7d841 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 a8939c0cd..4560fe4cc 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 a1eea5065..5fa2ebc34 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 68d2b8a25..0e4dd94b5 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 d5fb6359e..7c788ae0d 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 5f6e9d0ed..f064423b5 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 5867ea584..9ac39280c 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 266ba6fd8..89d8166a7 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 f680c0c59..2a7431463 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 d775e8e50..3002577a4 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 21321eec5..7b7bba02f 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); } -- Gitee