fix issue

Signed-off-by: https://gitee.com/WALL_EYE <wangguoqiang12@huawei.com>
Change-Id: Ibe226eb216721acc9037c94c1aa390ed3839c5d4
This commit is contained in:
https://gitee.com/WALL_EYE
2022-03-24 19:04:27 +08:00
parent 1195ef0af6
commit fe721c1b19
11 changed files with 32 additions and 28 deletions
-1
View File
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Copyright (c) 2022 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
@@ -35,9 +35,9 @@ typedef struct AcquireInfoInner {
class AuthApiCallback : public UserAuthCallback {
public:
AuthApiCallback(AuthInfo *authInfo);
AuthApiCallback(AuthUserInfo *userInfo);
AuthApiCallback(ExecuteInfo *executeInfo);
explicit AuthApiCallback(AuthInfo *authInfo);
explicit AuthApiCallback(AuthUserInfo *userInfo);
explicit AuthApiCallback(ExecuteInfo *executeInfo);
virtual ~AuthApiCallback();
void onAcquireInfo(const int32_t module, const uint32_t acquireInfo, const int32_t extraInfo) override;
void onResult(const int32_t result, const AuthResult extraInfo) override;
@@ -59,7 +59,7 @@ private:
class GetPropApiCallback : public GetPropCallback {
public:
GetPropApiCallback(GetPropertyInfo *getPropertyInfo);
explicit GetPropApiCallback(GetPropertyInfo *getPropertyInfo);
virtual ~GetPropApiCallback();
void onGetProperty(const ExecutorProperty result) override;
@@ -72,7 +72,7 @@ private:
class SetPropApiCallback : public SetPropCallback {
public:
SetPropApiCallback(SetPropertyInfo *setPropertyInfo);
explicit SetPropApiCallback(SetPropertyInfo *setPropertyInfo);
virtual ~SetPropApiCallback();
void onSetProperty(const int32_t result) override;
@@ -142,7 +142,7 @@ std::vector<uint32_t> ResultConvert::GetInt32ArrayValueByKey(napi_env env, napi_
return std::vector<uint32_t>();
}
if (!isArray) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "not a array");
USERAUTH_HILOGE(MODULE_JS_NAPI, "not an array");
return std::vector<uint32_t>();
}
return GetCppArrayUint32(env, array);
@@ -155,7 +155,6 @@ std::string ResultConvert::NapiGetValueString(napi_env env, napi_value value)
USERAUTH_HILOGE(MODULE_JS_NAPI, "AuthBuild NapiGetValueString value is nullptr");
return "";
}
std::string resultValue = "";
char valueString[NAPI_GET_STRING_SIZE];
size_t valueSize = NAPI_GET_STRING_SIZE;
size_t resultSize = 0;
@@ -163,7 +162,7 @@ std::string ResultConvert::NapiGetValueString(napi_env env, napi_value value)
if (status != napi_ok) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "napi_get_value_string_utf8 failed");
}
resultValue = valueString;
std::string resultValue = valueString;
if (resultValue == "") {
USERAUTH_HILOGE(MODULE_JS_NAPI, "NapiGetValueString resultValue error");
return "";
@@ -52,7 +52,7 @@ napi_value GetVersion(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, GetVersion get nullptr");
return nullptr;
@@ -68,7 +68,7 @@ napi_value GetAvailableStatus(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, getAvailableStatus get nullptr");
return nullptr;
@@ -84,7 +84,7 @@ napi_value GetProperty(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, GetProperty get nullptr");
return nullptr;
@@ -100,7 +100,7 @@ napi_value SetProperty(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, SetProperty get nullptr");
return nullptr;
@@ -116,7 +116,7 @@ napi_value Auth(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, Auth get nullptr");
return nullptr;
@@ -132,7 +132,7 @@ napi_value Execute(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, Execute get nullptr");
return nullptr;
@@ -148,7 +148,7 @@ napi_value AuthUser(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, AuthUser get nullptr");
return nullptr;
@@ -164,7 +164,7 @@ napi_value CancelAuth(napi_env env, napi_callback_info info)
napi_value args[ARGS_MAX_COUNT] = {nullptr};
NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr));
UserAuthImpl *userAuthImpl = nullptr;
NAPI_CALL(env, napi_unwrap(env, thisVar, (void **)&userAuthImpl));
NAPI_CALL(env, napi_unwrap(env, thisVar, reinterpret_cast<void **>(&userAuthImpl)));
if (userAuthImpl == nullptr) {
USERAUTH_HILOGE(MODULE_JS_NAPI, "UserAuthHelper, CancelAuth get nullptr");
return nullptr;
@@ -192,7 +192,7 @@ napi_value UserAuthImpl::GetPropertyAsync(napi_env env, AsyncHolder *asyncHolder
napi_value resourceName = nullptr;
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, GetPropertyExecute, GetPropertyAsyncExecuteDone,
(void *)asyncHolder, &asyncHolder->asyncWork));
reinterpret_cast<void *>(asyncHolder), &asyncHolder->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork));
USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s end", __func__);
return result;
@@ -210,7 +210,7 @@ napi_value UserAuthImpl::GetPropertyPromise(napi_env env, AsyncHolder *asyncHold
getPropertyInfo->callBackInfo.callBack = nullptr;
getPropertyInfo->callBackInfo.deferred = deferred;
NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, GetPropertyExecute, GetPropertyPromiseExecuteDone,
(void *)asyncHolder, &asyncHolder->asyncWork));
reinterpret_cast<void *>(asyncHolder), &asyncHolder->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork));
USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s end", __func__);
return promise;
@@ -336,7 +336,7 @@ napi_value UserAuthImpl::SetPropertyAsync(napi_env env, AsyncHolder *asyncHolder
napi_value resourceName = nullptr;
NAPI_CALL(env, napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName));
NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, SetPropertyExecute, SetPropertyAsyncExecuteDone,
(void *)asyncHolder, &asyncHolder->asyncWork));
reinterpret_cast<void *>(asyncHolder), &asyncHolder->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork));
USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s end", __func__);
return result;
@@ -354,7 +354,8 @@ napi_value UserAuthImpl::SetPropertyPromise(napi_env env, AsyncHolder *asyncHold
setPropertyInfo->callBackInfo.callBack = nullptr;
setPropertyInfo->callBackInfo.deferred = deferred;
NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName,
SetPropertyExecute, SetPropertyPromiseExecuteDone, (void *)asyncHolder, &asyncHolder->asyncWork));
SetPropertyExecute, SetPropertyPromiseExecuteDone, reinterpret_cast<void *>(asyncHolder),
&asyncHolder->asyncWork));
NAPI_CALL(env, napi_queue_async_work(env, asyncHolder->asyncWork));
USERAUTH_HILOGI(MODULE_JS_NAPI, "%{public}s end", __func__);
return promise;
@@ -51,6 +51,7 @@ private:
private:
DISALLOW_COPY_AND_MOVE(UserAuthDeathRecipient);
};
void ResetProxy(const wptr<IRemoteObject> &remote);
sptr<IUserAuth> GetProxy();
+1 -1
View File
@@ -71,7 +71,7 @@ public:
private:
class ContextTask {
public:
explicit ContextTask();
ContextTask();
~ContextTask();
ThreadPool::Task GetTask();
@@ -41,6 +41,7 @@ public:
void OnAcquireInfoHandle(uint32_t acquire);
static int32_t SaveCoauthCallback(uint64_t contextId, std::shared_ptr<CoAuth::CoAuthCallback> coauthCallback);
static int32_t DeleteCoauthCallback(uint64_t contextId);
private:
void OnFinishHandleExtend(int32_t userId, SetPropertyRequest setPropertyRequest, AuthResult authResult,
int32_t ret, UserAuthToken authToken);
+5 -6
View File
@@ -131,8 +131,8 @@ void UserAuthService::GetProperty(const GetPropertyRequest request, sptr<IUserAu
return;
}
sptr<IRemoteObject::DeathRecipient> dr = new UserAuthServiceCallbackDeathRecipient(callback);
if ((!callback->AsObject()->AddDeathRecipient(dr))) {
sptr<IRemoteObject::DeathRecipient> dr = new (std::nothrow) UserAuthServiceCallbackDeathRecipient(callback);
if ((dr == nullptr) || (!callback->AsObject()->AddDeathRecipient(dr))) {
USERAUTH_HILOGE(MODULE_SERVICE, "Failed to add death recipient UserAuthServiceCallbackDeathRecipient");
}
@@ -146,7 +146,6 @@ void UserAuthService::GetProperty(const GetPropertyRequest request, sptr<IUserAu
void UserAuthService::SetProperty(const SetPropertyRequest request, sptr<IUserAuthCallback> &callback)
{
USERAUTH_HILOGI(MODULE_SERVICE, "UserAuthService SetProperty start");
std::string callerName;
if (callback == nullptr) {
USERAUTH_HILOGE(MODULE_SERVICE, "callback is nullptr");
return;
@@ -158,13 +157,13 @@ void UserAuthService::SetProperty(const SetPropertyRequest request, sptr<IUserAu
return;
}
sptr<IRemoteObject::DeathRecipient> dr = new UserAuthServiceCallbackDeathRecipient(callback);
if ((!callback->AsObject()->AddDeathRecipient(dr))) {
sptr<IRemoteObject::DeathRecipient> dr = new (std::nothrow) UserAuthServiceCallbackDeathRecipient(callback);
if ((dr == nullptr) || (!callback->AsObject()->AddDeathRecipient(dr))) {
USERAUTH_HILOGE(MODULE_SERVICE, "Failed to add death recipient UserAuthServiceCallbackDeathRecipient");
}
uint64_t callerId = static_cast<uint64_t>(this->GetCallingUid());
callerName = std::to_string(callerId);
std::string callerName = std::to_string(callerId);
int32_t ret = userAuthController_.SetExecutorProp(callerId, callerName, request, callback);
if (ret != SUCCESS) {
+3
View File
@@ -148,6 +148,7 @@ int32_t UserAuthStub::SetPropertyStub(MessageParcel &data, MessageParcel &reply)
return SUCCESS;
}
int32_t UserAuthStub::AuthStub(MessageParcel &data, MessageParcel &reply)
{
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub AuthStub start");
@@ -232,6 +233,7 @@ int32_t UserAuthStub::AuthUserStub(MessageParcel &data, MessageParcel &reply)
return SUCCESS;
}
int32_t UserAuthStub::GetVersionStub(MessageParcel &data, MessageParcel &reply)
{
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub GetVersionStub start");
@@ -244,6 +246,7 @@ int32_t UserAuthStub::GetVersionStub(MessageParcel &data, MessageParcel &reply)
return SUCCESS;
}
int32_t UserAuthStub::CancelAuthStub(MessageParcel &data, MessageParcel &reply)
{
USERAUTH_HILOGD(MODULE_SERVICE, "UserAuthStub CancelAuthStub start");
+1
View File
@@ -47,6 +47,7 @@ void UseriamUtTest::TearDownTestCase(void)
void UseriamUtTest::SetUp()
{
}
void UseriamUtTest::TearDown()
{
}