mirror of
https://gitee.com/openharmony/useriam_user_auth_framework
synced 2024-11-22 23:29:55 +00:00
AI代码检视处理
Signed-off-by: 居凯 <shun0304@126.com> Change-Id: I355fde062b0973e663afcf3dc1a85ffc7e684b1f
This commit is contained in:
parent
044fbd29eb
commit
f4351ac6b9
@ -254,7 +254,7 @@ napi_status UnwrapAuthInstanceV10(napi_env env, napi_callback_info info, UserAut
|
||||
return ret;
|
||||
}
|
||||
if (*authInstanceV10 == nullptr) {
|
||||
IAM_LOGE("authInstanceV9 is null");
|
||||
IAM_LOGE("authInstanceV10 is null");
|
||||
return napi_generic_failure;
|
||||
}
|
||||
return ret;
|
||||
|
@ -334,8 +334,8 @@ UserAuthResultCode UserAuthInstanceV10::InitWidgetParam(napi_env env, napi_value
|
||||
return UserAuthNapiHelper::ThrowErrorMsg(env, UserAuthResultCode::OHOS_INVALID_PARAM, msgStr);
|
||||
}
|
||||
std::string title = UserAuthNapiHelper::GetStringPropertyUtf8(env, value, WIDGET_PARAM_TITLE);
|
||||
if (title == "" || title.length() > WidgetType::TITLE_MAX) {
|
||||
IAM_LOGE("title is invalid. size: %{public}zu", title.length());
|
||||
if (title == "" || title.size() > WidgetType::TITLE_MAX) {
|
||||
IAM_LOGE("title is invalid. size: %{public}zu", title.size());
|
||||
std::string msgStr = "Parameter error. The length of \"title\" connot exceed 500.";
|
||||
return UserAuthNapiHelper::ThrowErrorMsg(env, UserAuthResultCode::OHOS_INVALID_PARAM, msgStr);
|
||||
}
|
||||
@ -343,8 +343,8 @@ UserAuthResultCode UserAuthInstanceV10::InitWidgetParam(napi_env env, napi_value
|
||||
|
||||
if (UserAuthNapiHelper::HasNamedProperty(env, value, WIDGET_PARAM_NAVIBTNTEXT)) {
|
||||
std::string naviBtnTxt = UserAuthNapiHelper::GetStringPropertyUtf8(env, value, WIDGET_PARAM_NAVIBTNTEXT);
|
||||
if (naviBtnTxt == "" || naviBtnTxt.length() > WidgetType::BUTTON_MAX) {
|
||||
IAM_LOGE("navigation button text is invalid, size: %{public}zu", naviBtnTxt.length());
|
||||
if (naviBtnTxt == "" || naviBtnTxt.size() > WidgetType::BUTTON_MAX) {
|
||||
IAM_LOGE("navigation button text is invalid, size: %{public}zu", naviBtnTxt.size());
|
||||
std::string msgStr = "Parameter error. The length of \"navigationButtonText\" connot exceed 60.";
|
||||
return UserAuthNapiHelper::ThrowErrorMsg(env, UserAuthResultCode::OHOS_INVALID_PARAM, msgStr);
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ napi_status UserAuthNapiHelper::GetStrValue(napi_env env, napi_value value, char
|
||||
if (result != napi_ok) {
|
||||
IAM_LOGE("napi_get_value_string_utf8 fail");
|
||||
}
|
||||
if (out != nullptr && maxLen > 0) {
|
||||
if (maxLen > 0) {
|
||||
out[maxLen - 1] = '\0';
|
||||
}
|
||||
return result;
|
||||
|
@ -955,9 +955,7 @@ bool Attributes::Impl::DecodeStringValue(const std::vector<uint8_t> &src, std::s
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string out(static_cast<const char *>(static_cast<const void *>(src.data())));
|
||||
|
||||
dst.swap(out);
|
||||
dst.assign(src.begin(), src.end() -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ void UserAuthProxy::SetProperty(int32_t userId, AuthType authType, const Attribu
|
||||
bool UserAuthProxy::WriteAuthParam(MessageParcel &data, const AuthParamInner &authParam)
|
||||
{
|
||||
if (!data.WriteInt32(authParam.userId)) {
|
||||
IAM_LOGE("failed to write authType");
|
||||
IAM_LOGE("failed to write userId");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteUInt8Vector(authParam.challenge)) {
|
||||
|
@ -353,11 +353,11 @@ bool UserAuthStub::ReadWidgetParam(MessageParcel &data, WidgetParam &widgetParam
|
||||
{
|
||||
if (!data.ReadString(widgetParam.title)) {
|
||||
IAM_LOGE("failed to read title");
|
||||
return READ_PARCEL_ERROR;
|
||||
return false;
|
||||
}
|
||||
if (!data.ReadString(widgetParam.navigationButtonText)) {
|
||||
IAM_LOGE("failed to read navigationButtonText");
|
||||
return READ_PARCEL_ERROR;
|
||||
return false;
|
||||
}
|
||||
int32_t winMode;
|
||||
if (!data.ReadInt32(winMode)) {
|
||||
@ -493,7 +493,11 @@ int32_t UserAuthStub::NoticeStub(MessageParcel &data, MessageParcel &reply)
|
||||
IAM_LOGE("NoticeStub unsupport notice type");
|
||||
return ResultCode::GENERAL_ERROR;
|
||||
}
|
||||
std::string eventData = data.ReadString();
|
||||
std::string eventData;
|
||||
if (!data.ReadString(eventData)) {
|
||||
IAM_LOGE("failed to read eventData");
|
||||
return ResultCode::READ_PARCEL_ERROR;
|
||||
}
|
||||
|
||||
int32_t result = Notice(noticeType, eventData);
|
||||
if (!reply.WriteInt32(result)) {
|
||||
@ -664,7 +668,7 @@ int32_t UserAuthStub::SetGlobalConfigParamStub(MessageParcel &data, MessageParce
|
||||
return ret;
|
||||
}
|
||||
if (!data.ReadInt32Vector(&globalConfigParam.userIds)) {
|
||||
IAM_LOGE("failed to write userIds");
|
||||
IAM_LOGE("failed to read userIds");
|
||||
return READ_PARCEL_ERROR;
|
||||
}
|
||||
std::vector<int32_t> authTypeList;
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "context_pool.h"
|
||||
#include "device_manager_util.h"
|
||||
#include "hdi_wrapper.h"
|
||||
#include "iam_para2str.h"
|
||||
#include "remote_executor_stub.h"
|
||||
#include "remote_iam_callback.h"
|
||||
#include "remote_msg_util.h"
|
||||
|
@ -38,9 +38,7 @@ const std::string USERIAM_COMMON_EVENT_SAMGR_PERMISSION = "ohos.permission.INTER
|
||||
void PublishEvent(EventFwk::CommonEventData data, const std::string &permission)
|
||||
{
|
||||
EventFwk::CommonEventPublishInfo publishInfo;
|
||||
std::vector<std::string> permissions;
|
||||
permissions.push_back(permission);
|
||||
publishInfo.SetSubscriberPermissions(permissions);
|
||||
publishInfo.SetSubscriberPermissions({permission});
|
||||
publishInfo.SetSticky(false);
|
||||
if (!EventFwk::CommonEventManager::PublishCommonEvent(data, publishInfo)) {
|
||||
IAM_LOGE("PublishCommonEvent failed, eventAction is %{public}s", data.GetWant().GetAction().c_str());
|
||||
|
@ -219,7 +219,8 @@ ResultCode BaseSocket::SendRequest(const int32_t socketId, const std::string &co
|
||||
|
||||
int32_t messageSeq = GetMessageSeq();
|
||||
int32_t msgType = -1;
|
||||
attributes->GetInt32Value(Attributes::ATTR_MSG_TYPE, msgType);
|
||||
bool isGetVal = attributes->GetInt32Value(Attributes::ATTR_MSG_TYPE, msgType);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(isGetVal, INVALID_PARAMETERS);
|
||||
RefreshTraceInfo(connectionName, msgType, false, messageSeq);
|
||||
std::shared_ptr<SoftBusMessage> softBusMessage = Common::MakeShared<SoftBusMessage>(messageSeq,
|
||||
connectionName, srcEndPoint, destEndPoint, attributes);
|
||||
@ -260,7 +261,8 @@ ResultCode BaseSocket::SendResponse(const int32_t socketId, const std::string &c
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(attributes != nullptr, INVALID_PARAMETERS);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(socketId != INVALID_SOCKET_ID, INVALID_PARAMETERS);
|
||||
int32_t msgType = -1;
|
||||
attributes->GetInt32Value(Attributes::ATTR_MSG_TYPE, msgType);
|
||||
bool isGetVal = attributes->GetInt32Value(Attributes::ATTR_MSG_TYPE, msgType);
|
||||
IF_FALSE_LOGE_AND_RETURN_VAL(isGetVal, INVALID_PARAMETERS);
|
||||
RefreshTraceInfo(connectionName, msgType, true, messageSeq);
|
||||
|
||||
std::shared_ptr<SoftBusMessage> softBusMessage = Common::MakeShared<SoftBusMessage>(messageSeq,
|
||||
|
@ -339,6 +339,7 @@ void SoftBusManager::ServiceSocketUnInit()
|
||||
std::vector<int32_t> socketIds;
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(softBusMutex_);
|
||||
socketIds.reserve(socketMap_.size());
|
||||
for (const auto &iter : socketMap_) {
|
||||
socketIds.push_back(iter.first);
|
||||
}
|
||||
|
@ -200,6 +200,7 @@ HWTEST_F(SoftBusBaseSocketTest, SoftBusBaseSocketTestSendRequest, TestSize.Level
|
||||
std::string destEndPoint = "456";
|
||||
std::shared_ptr<Attributes> attributes = Common::MakeShared<Attributes>();
|
||||
ASSERT_NE(attributes, nullptr);
|
||||
attributes->SetInt32Value(Attributes::ATTR_MSG_TYPE, 1);
|
||||
MsgCallback callback;
|
||||
EXPECT_EQ(baseSocket->SendRequest(socketId, connectionName, srcEndPoint, destEndPoint, attributes,
|
||||
callback), GENERAL_ERROR);
|
||||
@ -215,6 +216,7 @@ HWTEST_F(SoftBusBaseSocketTest, SoftBusBaseSocketTestSendResponse, TestSize.Leve
|
||||
std::string destEndPoint = "456";
|
||||
std::shared_ptr<Attributes> attributes = Common::MakeShared<Attributes>();
|
||||
ASSERT_NE(attributes, nullptr);
|
||||
attributes->SetInt32Value(Attributes::ATTR_MSG_TYPE, 1);
|
||||
uint32_t messageSeq = 123;
|
||||
EXPECT_EQ(baseSocket->SendResponse(socketId, connectionName, srcEndPoint, destEndPoint, attributes,
|
||||
messageSeq), GENERAL_ERROR);
|
||||
|
Loading…
Reference in New Issue
Block a user