modify frameworks/js/napi

Signed-off-by: xinking129 <xinxin13@huawei.com>
This commit is contained in:
xinking129 2024-03-23 14:58:14 +08:00
parent 04641a54db
commit 74a88c25c8
22 changed files with 707 additions and 680 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -16,6 +16,7 @@
#include "napi_common_configuration.h"
#include "configuration_convertor.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "napi_common_util.h"
@ -34,7 +35,8 @@ bool InnerWrapConfigurationString(
napi_env env, napi_value jsObject, const std::string &key, const std::string &value)
{
if (!value.empty()) {
HILOG_INFO("%{public}s called. key=%{public}s, value=%{private}s", __func__, key.c_str(), value.c_str());
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s, value=%{private}s",
__func__, key.c_str(), value.c_str());
napi_value jsValue = WrapStringToJS(env, value);
if (jsValue != nullptr) {
NAPI_CALL_BASE(env, napi_set_named_property(env, jsObject, key.c_str(), jsValue), false);
@ -46,7 +48,7 @@ bool InnerWrapConfigurationString(
napi_value WrapConfiguration(napi_env env, const AppExecFwk::Configuration &configuration)
{
HILOG_DEBUG("called, config size %{public}d", static_cast<int>(configuration.GetItemSize()));
TAG_LOGD(AAFwkTag::JSNAPI, "called, config size %{public}d", static_cast<int>(configuration.GetItemSize()));
napi_value jsObject = nullptr;
NAPI_CALL(env, napi_create_object(env, &jsObject));
@ -88,40 +90,40 @@ napi_value WrapConfiguration(napi_env env, const AppExecFwk::Configuration &conf
bool UnwrapConfiguration(napi_env env, napi_value param, Configuration &config)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
if (!IsTypeForNapiValue(env, param, napi_object)) {
HILOG_INFO("%{public}s called. Params is invalid.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__);
return false;
}
std::string language {""};
if (UnwrapStringByPropertyName(env, param, "language", language)) {
HILOG_DEBUG("The parsed language part %{public}s", language.c_str());
TAG_LOGD(AAFwkTag::JSNAPI, "The parsed language part %{public}s", language.c_str());
if (!config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE, language)) {
HILOG_ERROR("language Parsing failed");
TAG_LOGE(AAFwkTag::JSNAPI, "language Parsing failed");
return false;
}
}
int32_t colormode = -1;
if (UnwrapInt32ByPropertyName(env, param, "colorMode", colormode)) {
HILOG_DEBUG("The parsed colormode part %{public}d", colormode);
TAG_LOGD(AAFwkTag::JSNAPI, "The parsed colormode part %{public}d", colormode);
if (colormode != Global::Resource::DARK && colormode != Global::Resource::LIGHT) {
HILOG_ERROR("Set colorMode to unsupported value.");
TAG_LOGE(AAFwkTag::JSNAPI, "Set colorMode to unsupported value.");
return false;
}
if (!config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE, GetColorModeStr(colormode))) {
HILOG_ERROR("colorMode parsing failed");
TAG_LOGE(AAFwkTag::JSNAPI, "colorMode parsing failed");
return false;
}
}
double fontSizeScale = 0.0;
if (UnwrapDoubleByPropertyName(env, param, "fontSizeScale", fontSizeScale)) {
HILOG_DEBUG("The parsed fontSizeScale part %{public}lf", fontSizeScale);
TAG_LOGD(AAFwkTag::JSNAPI, "The parsed fontSizeScale part %{public}lf", fontSizeScale);
if (fontSizeScale < FONT_SIZE_MIN_SCALE || fontSizeScale > FONT_SIZE_MAX_SCALE) {
HILOG_ERROR("invalid fontSizeScale");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid fontSizeScale");
return false;
}
if (!config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_SIZE_SCALE, std::to_string(fontSizeScale))) {
@ -131,9 +133,9 @@ bool UnwrapConfiguration(napi_env env, napi_value param, Configuration &config)
double fontWeightScale = 0.0;
if (UnwrapDoubleByPropertyName(env, param, "fontWeightScale", fontWeightScale)) {
HILOG_DEBUG("The parsed fontWeightScale part %{public}lf", fontWeightScale);
TAG_LOGD(AAFwkTag::JSNAPI, "The parsed fontWeightScale part %{public}lf", fontWeightScale);
if (fontWeightScale < FONT_WEIGHT_MIN_SCALE || fontWeightScale > FONT_WEIGHT_MAX_SCALE) {
HILOG_ERROR("invalid fontWeightScale");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid fontWeightScale");
return false;
}
if (!config.AddItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_WEIGHT_SCALE, std::to_string(fontWeightScale))) {

View File

@ -15,6 +15,7 @@
#include "napi_common_execute_param.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "napi_common_util.h"
#include "napi_common_want.h"
@ -25,34 +26,34 @@ using namespace OHOS::AppExecFwk;
bool UnwrapExecuteParam(napi_env env, napi_value param, InsightIntentExecuteParam &executeParam)
{
if (!IsTypeForNapiValue(env, param, napi_object)) {
HILOG_ERROR("Params is invalid.");
TAG_LOGE(AAFwkTag::JSNAPI, "Params is invalid.");
return false;
}
std::string bundleName {""};
if (!UnwrapStringByPropertyName(env, param, "bundleName", bundleName)) {
HILOG_ERROR("Wrong argument type bundleName.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type bundleName.");
return false;
}
executeParam.bundleName_ = bundleName;
std::string moduleName {""};
if (!UnwrapStringByPropertyName(env, param, "moduleName", moduleName)) {
HILOG_ERROR("Wrong argument type moduleName.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type moduleName.");
return false;
}
executeParam.moduleName_ = moduleName;
std::string abilityName {""};
if (!UnwrapStringByPropertyName(env, param, "abilityName", abilityName)) {
HILOG_ERROR("Wrong argument type abilityName.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type abilityName.");
return false;
}
executeParam.abilityName_ = abilityName;
std::string insightIntentName {""};
if (!UnwrapStringByPropertyName(env, param, "insightIntentName", insightIntentName)) {
HILOG_ERROR("Wrong argument type insightIntentName.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type insightIntentName.");
return false;
}
executeParam.insightIntentName_ = insightIntentName;
@ -60,26 +61,26 @@ bool UnwrapExecuteParam(napi_env env, napi_value param, InsightIntentExecutePara
napi_value napiIntentParam = nullptr;
napi_get_named_property(env, param, "insightIntentParam", &napiIntentParam);
if (napiIntentParam == nullptr) {
HILOG_ERROR("Wrong argument type insightIntentParam.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type insightIntentParam.");
return false;
}
napi_valuetype valueType = napi_undefined;
napi_typeof(env, napiIntentParam, &valueType);
if (valueType != napi_object) {
HILOG_ERROR("Wrong argument type intentParam.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type intentParam.");
return false;
}
auto wp = std::make_shared<WantParams>();
if (!AppExecFwk::UnwrapWantParams(env, napiIntentParam, *wp)) {
HILOG_ERROR("Wrong argument type intentParam.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type intentParam.");
return false;
}
executeParam.insightIntentParam_ = wp;
int32_t executeMode = 0;
if (!UnwrapInt32ByPropertyName(env, param, "executeMode", executeMode)) {
HILOG_ERROR("Wrong argument type executeMode.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type executeMode.");
return false;
}
executeParam.executeMode_ = executeMode;
@ -88,10 +89,10 @@ bool UnwrapExecuteParam(napi_env env, napi_value param, InsightIntentExecutePara
if (executeMode == ExecuteMode::UI_ABILITY_FOREGROUND &&
UnwrapInt32ByPropertyName(env, param, "displayId", displayId)) {
if (displayId < 0) {
HILOG_ERROR("Wrong argument displayId.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument displayId.");
return false;
}
HILOG_INFO("Get displayId %{public}d.", displayId);
TAG_LOGI(AAFwkTag::JSNAPI, "Get displayId %{public}d.", displayId);
executeParam.displayId_ = displayId;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 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
@ -15,6 +15,7 @@
#include "napi_common_execute_result.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "insight_intent_execute_result.h"
#include "napi_common_util.h"
@ -27,15 +28,15 @@ namespace AbilityRuntime {
using namespace OHOS::AppExecFwk;
bool UnwrapExecuteResult(napi_env env, napi_value param, InsightIntentExecuteResult &executeResult)
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::JSNAPI, "called.");
if (!IsTypeForNapiValue(env, param, napi_valuetype::napi_object)) {
HILOG_ERROR("UnwrapExecuteResult not object");
TAG_LOGE(AAFwkTag::JSNAPI, "UnwrapExecuteResult not object");
return false;
}
int32_t code = 0;
if (!UnwrapInt32ByPropertyName(env, param, "code", code)) {
HILOG_ERROR("Intent result must contian a code.");
TAG_LOGE(AAFwkTag::JSNAPI, "Intent result must contian a code.");
return false;
}
executeResult.code = code;
@ -46,16 +47,16 @@ bool UnwrapExecuteResult(napi_env env, napi_value param, InsightIntentExecuteRes
napi_valuetype valueType = napi_undefined;
napi_typeof(env, result, &valueType);
if (valueType != napi_object) {
HILOG_ERROR("Wrong argument type result.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type result.");
return false;
}
auto wp = std::make_shared<AAFwk::WantParams>();
if (!AppExecFwk::UnwrapWantParams(env, result, *wp)) {
HILOG_ERROR("Wrong argument type result.");
TAG_LOGE(AAFwkTag::JSNAPI, "Wrong argument type result.");
return false;
}
if (!executeResult.CheckResult(wp)) {
HILOG_ERROR("Invalid intent result.");
TAG_LOGE(AAFwkTag::JSNAPI, "Invalid intent result.");
return false;
}
executeResult.result = wp;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -15,6 +15,7 @@
#include "napi_common_start_options.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "napi_common_util.h"
#include "napi_common_want.h"
@ -34,26 +35,26 @@ bool UnwrapProcessOptions(napi_env env, napi_value param, std::shared_ptr<AAFwk:
auto option = std::make_shared<AAFwk::ProcessOptions>();
int32_t processMode = 0;
if (!UnwrapInt32ByPropertyName(env, param, "processMode", processMode)) {
HILOG_ERROR("Unwrap processMode failed.");
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap processMode failed.");
return false;
}
option->processMode = AAFwk::ProcessOptions::ConvertInt32ToProcessMode(processMode);
if (option->processMode == AAFwk::ProcessMode::UNSPECIFIED) {
HILOG_ERROR("Convert processMode failed.");
TAG_LOGE(AAFwkTag::JSNAPI, "Convert processMode failed.");
return false;
}
int32_t startupVisibility = 0;
if (!UnwrapInt32ByPropertyName(env, param, "startupVisibility", startupVisibility)) {
HILOG_ERROR("Unwrap startupVisibility failed.");
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap startupVisibility failed.");
return false;
}
option->startupVisibility = AAFwk::ProcessOptions::ConvertInt32ToStartupVisibility(startupVisibility);
if (option->startupVisibility == AAFwk::StartupVisibility::UNSPECIFIED) {
HILOG_ERROR("Convert startupVisibility failed.");
TAG_LOGE(AAFwkTag::JSNAPI, "Convert startupVisibility failed.");
return false;
}
processOptions = option;
HILOG_INFO("processMode:%{public}d, startupVisibility:%{public}d",
TAG_LOGI(AAFwkTag::JSNAPI, "processMode:%{public}d, startupVisibility:%{public}d",
static_cast<int32_t>(processOptions->processMode),
static_cast<int32_t>(processOptions->startupVisibility));
return true;
@ -63,7 +64,7 @@ bool UnwrapStartOptionsWithProcessOption(napi_env env, napi_value param, AAFwk::
{
UnwrapStartOptions(env, param, startOptions);
if (!UnwrapProcessOptions(env, param, startOptions.processOptions)) {
HILOG_ERROR("Unwrap processOptions failed.");
TAG_LOGE(AAFwkTag::JSNAPI, "Unwrap processOptions failed.");
return false;
}
return true;
@ -71,10 +72,10 @@ bool UnwrapStartOptionsWithProcessOption(napi_env env, napi_value param, AAFwk::
bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &startOptions)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
if (!IsTypeForNapiValue(env, param, napi_object)) {
HILOG_INFO("%{public}s called. Params is invalid.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__);
return false;
}
@ -85,7 +86,7 @@ bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &sta
int32_t displayId = 0;
if (UnwrapInt32ByPropertyName(env, param, "displayId", displayId)) {
HILOG_INFO("get display id ok displayId %{public}d", displayId);
TAG_LOGI(AAFwkTag::JSNAPI, "get display id ok displayId %{public}d", displayId);
startOptions.SetDisplayID(displayId);
}
@ -124,7 +125,7 @@ bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &sta
bool UnwrapStartOptionsAndWant(napi_env env, napi_value param, AAFwk::StartOptions &startOptions, AAFwk::Want &want)
{
if (!IsTypeForNapiValue(env, param, napi_object)) {
HILOG_INFO("%{public}s called. Params is invalid.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__);
return false;
}
napi_value jsValue = GetPropertyValueByPropertyName(env, param, "parameters", napi_object);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -16,6 +16,7 @@
#include <cstring>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "napi_common_data.h"
#include "napi_common_error.h"
@ -25,11 +26,11 @@ namespace OHOS {
namespace AppExecFwk {
bool IsTypeForNapiValue(napi_env env, napi_value param, napi_valuetype expectType)
{
HILOG_DEBUG("IsTypeForNapiValue start.");
TAG_LOGD(AAFwkTag::JSNAPI, "IsTypeForNapiValue start.");
napi_valuetype valueType = napi_undefined;
if (param == nullptr) {
HILOG_DEBUG("param is nullptr");
TAG_LOGD(AAFwkTag::JSNAPI, "param is nullptr");
return false;
}
@ -42,7 +43,7 @@ bool IsTypeForNapiValue(napi_env env, napi_value param, napi_valuetype expectTyp
bool IsArrayForNapiValue(napi_env env, napi_value param, uint32_t &arraySize)
{
HILOG_DEBUG("IsArrayForNapiValue start.");
TAG_LOGD(AAFwkTag::JSNAPI, "IsArrayForNapiValue start.");
bool isArray = false;
arraySize = 0;
@ -51,7 +52,7 @@ bool IsArrayForNapiValue(napi_env env, napi_value param, uint32_t &arraySize)
}
if (napi_get_array_length(env, param, &arraySize) != napi_ok) {
HILOG_DEBUG("napi_get_array_length is 0");
TAG_LOGD(AAFwkTag::JSNAPI, "napi_get_array_length is 0");
return false;
}
return true;
@ -219,7 +220,7 @@ napi_value WrapStringToJS(napi_env env, const std::string &value)
std::string UnwrapStringFromJS(napi_env env, napi_value param, const std::string &defaultValue)
{
HILOG_DEBUG("UnwrapStringFromJS enter");
TAG_LOGD(AAFwkTag::JSNAPI, "UnwrapStringFromJS enter");
size_t size = 0;
if (napi_get_value_string_utf8(env, param, nullptr, 0, &size) != napi_ok) {
return defaultValue;
@ -227,13 +228,13 @@ std::string UnwrapStringFromJS(napi_env env, napi_value param, const std::string
std::string value("");
if (size == 0) {
HILOG_DEBUG("size is 0");
TAG_LOGD(AAFwkTag::JSNAPI, "size is 0");
return defaultValue;
}
char *buf = new (std::nothrow) char[size + 1];
if (buf == nullptr) {
HILOG_DEBUG("buf is nullptr");
TAG_LOGD(AAFwkTag::JSNAPI, "buf is nullptr");
return value;
}
(void)memset_s(buf, size + 1, 0, size + 1);
@ -279,7 +280,7 @@ bool UnwrapStringFromJS2(napi_env env, napi_value param, std::string &value)
napi_value WrapArrayInt32ToJS(napi_env env, const std::vector<int> &value)
{
HILOG_DEBUG("WrapArrayInt32ToJS start.");
TAG_LOGD(AAFwkTag::JSNAPI, "WrapArrayInt32ToJS start.");
napi_value jsArray = nullptr;
napi_value jsValue = nullptr;
uint32_t index = 0;
@ -303,7 +304,7 @@ bool UnwrapArrayInt32FromJS(napi_env env, napi_value param, std::vector<int> &va
int natValue = 0;
if (!IsArrayForNapiValue(env, param, arraySize)) {
HILOG_DEBUG("Expanding ArrayInt32 from JS failed");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS failed");
return false;
}
@ -312,7 +313,7 @@ bool UnwrapArrayInt32FromJS(napi_env env, napi_value param, std::vector<int> &va
jsValue = nullptr;
natValue = 0;
if (napi_get_element(env, param, i, &jsValue) != napi_ok) {
HILOG_DEBUG("Expanding ArrayInt32 from JS failed");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS failed");
return false;
}
@ -350,7 +351,7 @@ bool UnwrapArrayLongFromJS(napi_env env, napi_value param, std::vector<long> &va
long natValue = 0;
if (!IsArrayForNapiValue(env, param, arraySize)) {
HILOG_DEBUG("Expanding ArrayInt32 from JS failed.");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS failed.");
return false;
}
@ -359,7 +360,7 @@ bool UnwrapArrayLongFromJS(napi_env env, napi_value param, std::vector<long> &va
jsValue = nullptr;
natValue = 0;
if (napi_get_element(env, param, i, &jsValue) != napi_ok) {
HILOG_DEBUG("Expanding ArrayInt32 from JS failed.");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS failed.");
return false;
}
@ -397,7 +398,7 @@ bool UnwrapArrayInt64FromJS(napi_env env, napi_value param, std::vector<int64_t>
int64_t natValue = 0;
if (!IsArrayForNapiValue(env, param, arraySize)) {
HILOG_DEBUG("Expanding ArrayInt32 from JS error");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS error");
return false;
}
@ -406,7 +407,7 @@ bool UnwrapArrayInt64FromJS(napi_env env, napi_value param, std::vector<int64_t>
jsValue = nullptr;
natValue = 0;
if (napi_get_element(env, param, i, &jsValue) != napi_ok) {
HILOG_DEBUG("Expanding ArrayInt32 from JS error");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS error");
return false;
}
@ -444,7 +445,7 @@ bool UnwrapArrayDoubleFromJS(napi_env env, napi_value param, std::vector<double>
double natValue = 0;
if (!IsArrayForNapiValue(env, param, arraySize)) {
HILOG_DEBUG("Expanding ArrayInt32 from JS error.");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS error.");
return false;
}
@ -453,7 +454,7 @@ bool UnwrapArrayDoubleFromJS(napi_env env, napi_value param, std::vector<double>
jsValue = nullptr;
natValue = 0;
if (napi_get_element(env, param, i, &jsValue) != napi_ok) {
HILOG_DEBUG("Expanding ArrayInt32 from JS error.");
TAG_LOGD(AAFwkTag::JSNAPI, "Expanding ArrayInt32 from JS error.");
return false;
}
@ -851,7 +852,7 @@ napi_value GetCallbackErrorValue(napi_env env, int errCode)
*/
AsyncJSCallbackInfo *CreateAsyncJSCallbackInfo(napi_env env)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
napi_value global = nullptr;
NAPI_CALL(env, napi_get_global(env, &global));
@ -864,7 +865,7 @@ AsyncJSCallbackInfo *CreateAsyncJSCallbackInfo(napi_env env)
AsyncJSCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncJSCallbackInfo;
if (asyncCallbackInfo == nullptr) {
HILOG_ERROR("%{public}s, asyncCallbackInfo == nullptr.", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, asyncCallbackInfo == nullptr.", __func__);
return nullptr;
}
asyncCallbackInfo->cbInfo.env = env;
@ -946,16 +947,16 @@ bool WrapThreadReturnData(napi_env env, const ThreadReturnData *data, napi_value
*/
bool CreateAsyncCallback(napi_env env, napi_value param, AsyncJSCallbackInfo *callback)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
if (param == nullptr || callback == nullptr) {
HILOG_INFO("%{public}s called, param or callback is null.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, param or callback is null.", __func__);
return false;
}
callback->cbInfo.callback = CreateCallbackRefFromJS(env, param);
if (callback->cbInfo.callback == nullptr) {
HILOG_INFO("%{public}s, create ref failed.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, create ref failed.", __func__);
return false;
}
@ -965,7 +966,7 @@ bool CreateAsyncCallback(napi_env env, napi_value param, AsyncJSCallbackInfo *ca
napi_ref CreateCallbackRefFromJS(napi_env env, napi_value param)
{
if (env == nullptr || param == nullptr) {
HILOG_INFO("%{public}s called, env or param is null ", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, env or param is null ", __func__);
return nullptr;
}
@ -973,7 +974,7 @@ napi_ref CreateCallbackRefFromJS(napi_env env, napi_value param)
NAPI_CALL(env, napi_typeof(env, param, &valueType));
if (valueType != napi_function) {
HILOG_INFO("%{public}s called, Param is invalid.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, Param is invalid.", __func__);
return nullptr;
}
@ -993,9 +994,9 @@ napi_ref CreateCallbackRefFromJS(napi_env env, napi_value param)
*/
napi_value ExecuteAsyncCallbackWork(napi_env env, AsyncJSCallbackInfo *asyncCallbackInfo, const AsyncParamEx *param)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
if (asyncCallbackInfo == nullptr || param == nullptr) {
HILOG_INFO("%{public}s called, asyncCallbackInfo or param is null", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo or param is null", __func__);
return nullptr;
}
@ -1027,9 +1028,9 @@ napi_value ExecuteAsyncCallbackWork(napi_env env, AsyncJSCallbackInfo *asyncCall
*/
napi_value ExecutePromiseCallbackWork(napi_env env, AsyncJSCallbackInfo *asyncCallbackInfo, const AsyncParamEx *param)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
if (asyncCallbackInfo == nullptr || param == nullptr) {
HILOG_INFO("%{public}s called, asyncCallbackInfo or param is null", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo or param is null", __func__);
return nullptr;
}
@ -1062,11 +1063,11 @@ napi_value ExecutePromiseCallbackWork(napi_env env, AsyncJSCallbackInfo *asyncCa
*/
void CompleteAsyncCallbackWork(napi_env env, napi_status status, void *data)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
HILOG_INFO("%{public}s called, asyncCallbackInfo is nullptr", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is nullptr", __func__);
return;
}
@ -1092,10 +1093,10 @@ void CompleteAsyncCallbackWork(napi_env env, napi_status status, void *data)
void CompleteAsyncVoidCallbackWork(napi_env env, napi_status status, void *data)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
HILOG_INFO("%{public}s called, asyncCallbackInfo is null", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is null", __func__);
return;
}
napi_value callback = nullptr;
@ -1132,11 +1133,11 @@ void CompleteAsyncVoidCallbackWork(napi_env env, napi_status status, void *data)
*/
void CompletePromiseCallbackWork(napi_env env, napi_status status, void *data)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
HILOG_INFO("%{public}s called, asyncCallbackInfo is nullptr.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is nullptr.", __func__);
return;
}
@ -1155,11 +1156,11 @@ void CompletePromiseCallbackWork(napi_env env, napi_status status, void *data)
void CompletePromiseVoidCallbackWork(napi_env env, napi_status status, void *data)
{
HILOG_INFO("%{public}s called.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
HILOG_INFO("%{public}s called, asyncCallbackInfo is null", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is null", __func__);
return;
}
napi_value result = nullptr;
@ -1207,7 +1208,7 @@ std::vector<std::string> ConvertStringVector(napi_env env, napi_value jsValue)
bool isTypedArray = false;
napi_status status = napi_is_typedarray(env, jsValue, &isTypedArray);
if (status != napi_ok || !isTypedArray) {
HILOG_ERROR("%{public}s called, napi_is_typedarray error", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, napi_is_typedarray error", __func__);
return {};
}
@ -1217,7 +1218,7 @@ std::vector<std::string> ConvertStringVector(napi_env env, napi_value jsValue)
size_t offset = 0;
NAPI_CALL_BASE(env, napi_get_typedarray_info(env, jsValue, &type, &length, nullptr, &buffer, &offset), {});
if (type != napi_uint8_array) {
HILOG_ERROR("%{public}s called, napi_uint8_array is nullptr", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, napi_uint8_array is nullptr", __func__);
return {};
}
std::string *data = nullptr;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -21,6 +21,7 @@
#include "byte_wrapper.h"
#include "double_wrapper.h"
#include "float_wrapper.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "int_wrapper.h"
#include "ipc_skeleton.h"
@ -267,7 +268,7 @@ bool InnerWrapWantParamsFloat(
bool InnerWrapWantParamsDouble(
napi_env env, napi_value jsObject, const std::string &key, const AAFwk::WantParams &wantParams)
{
HILOG_DEBUG("enter");
TAG_LOGD(AAFwkTag::JSNAPI, "enter");
auto value = wantParams.GetParam(key);
AAFwk::IDouble *ao = AAFwk::IDouble::Query(value);
if (ao == nullptr) {
@ -287,7 +288,7 @@ bool InnerWrapWantParamsDouble(
bool InnerWrapWantParamsWantParams(
napi_env env, napi_value jsObject, const std::string &key, const AAFwk::WantParams &wantParams)
{
HILOG_DEBUG("%{public}s called. key=%{public}s", __func__, key.c_str());
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str());
auto value = wantParams.GetParam(key);
AAFwk::IWantParams *o = AAFwk::IWantParams::Query(value);
if (o == nullptr) {
@ -307,17 +308,17 @@ bool InnerWrapWantParamsWantParams(
bool InnerWrapWantParamsRemoteObject(
napi_env env, napi_value jsObject, const std::string &key, const AAFwk::WantParams &wantParams)
{
HILOG_DEBUG("%{public}s called. key=%{public}s", __func__, key.c_str());
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str());
auto value = wantParams.GetParam(key);
AAFwk::IRemoteObjectWrap *remoteObjectIWrap = AAFwk::IRemoteObjectWrap::Query(value);
if (remoteObjectIWrap == nullptr) {
HILOG_ERROR("%{public}s remoteObjectIWrap is nullptr.", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s remoteObjectIWrap is nullptr.", __func__);
return false;
}
auto remoteObject = AAFwk::RemoteObjectWrap::UnBox(remoteObjectIWrap);
auto jsValue = NAPI_ohos_rpc_CreateJsRemoteObject(env, remoteObject);
if (jsValue == nullptr) {
HILOG_ERROR("%{public}s jsValue is nullptr.", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s jsValue is nullptr.", __func__);
return false;
}
@ -327,7 +328,7 @@ bool InnerWrapWantParamsRemoteObject(
bool InnerWrapWantParamsArrayChar(napi_env env, napi_value jsObject, const std::string &key, sptr<AAFwk::IArray> &ao)
{
HILOG_DEBUG("%{public}s called.", __func__);
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
long size = 0;
if (ao->GetLength(size) != ERR_OK) {
return false;
@ -608,7 +609,7 @@ bool InnerWrapWantParamsArrayWantParams(napi_env env, napi_value jsObject,
bool InnerWrapWantParamsArray(napi_env env, napi_value jsObject, const std::string &key, sptr<AAFwk::IArray> &ao)
{
HILOG_DEBUG("%{public}s called. key=%{public}s", __func__, key.c_str());
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str());
if (AAFwk::Array::IsStringArray(ao)) {
return InnerWrapWantParamsArrayString(env, jsObject, key, ao);
} else if (AAFwk::Array::IsBooleanArray(ao)) {
@ -698,7 +699,7 @@ bool InnerSetWantParamsArrayObject(napi_env env, const std::string &key,
bool InnerSetWantParamsArrayString(
const std::string &key, const std::vector<std::string> &value, AAFwk::WantParams &wantParams)
{
HILOG_DEBUG("InnerSetWantParamsArrayString enter");
TAG_LOGD(AAFwkTag::JSNAPI, "InnerSetWantParamsArrayString enter");
size_t size = value.size();
sptr<AAFwk::IArray> ao = new (std::nothrow) AAFwk::Array(size, AAFwk::g_IID_IString);
if (ao != nullptr) {
@ -775,7 +776,7 @@ bool InnerSetWantParamsArrayDouble(
bool InnerUnwrapWantParamsArray(napi_env env, const std::string &key, napi_value param, AAFwk::WantParams &wantParams)
{
HILOG_DEBUG("%{public}s called.", __func__);
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
ComplexArrayData natArrayValue;
if (!UnwrapArrayComplexFromJS(env, param, natArrayValue)) {
return false;
@ -804,7 +805,7 @@ bool InnerUnwrapWantParamsArray(napi_env env, const std::string &key, napi_value
bool InnerUnwrapWantParams(napi_env env, const std::string &key, napi_value param, AAFwk::WantParams &wantParams)
{
HILOG_DEBUG("%{public}s called.", __func__);
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called.", __func__);
AAFwk::WantParams wp;
if (UnwrapWantParams(env, param, wp)) {
@ -876,10 +877,10 @@ bool UnwrapWantParams(napi_env env, napi_value param, AAFwk::WantParams &wantPar
std::string strProName = UnwrapStringFromJS(env, jsProName);
/* skip reserved param */
if (BlackListFilter(strProName)) {
HILOG_DEBUG("%{public}s is filtered.", strProName.c_str());
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s is filtered.", strProName.c_str());
continue;
}
HILOG_DEBUG("%{public}s called. Property name=%{public}s.", __func__, strProName.c_str());
TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. Property name=%{public}s.", __func__, strProName.c_str());
NAPI_CALL_BASE(env, napi_get_named_property(env, param, strProName.c_str(), &jsProValue), false);
NAPI_CALL_BASE(env, napi_typeof(env, jsProValue, &jsValueType), false);
@ -921,7 +922,7 @@ void HandleNapiObject(napi_env env, napi_value param, napi_value jsProValue, std
if (Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) {
HandleRemoteObject(env, param, strProName, wantParams);
} else {
HILOG_WARN("not system app, REMOTE_OBJECT is FORIBBED IN WANT.");
TAG_LOGW(AAFwkTag::JSNAPI, "not system app, REMOTE_OBJECT is FORIBBED IN WANT.");
}
} else {
bool isArray = false;
@ -959,7 +960,7 @@ bool IsSpecialObject(napi_env env, napi_value param, std::string &strProName, st
NAPI_CALL_BASE(env, napi_get_array_length(env, jsProNameList, &jsProCount), false);
if (jsProCount != PROPERTIES_SIZE) {
HILOG_ERROR("%{public}s called, size is invalid, this object is not fd object.", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, size is invalid, this object is not fd object.", __func__);
return false;
}
@ -969,7 +970,8 @@ bool IsSpecialObject(napi_env env, napi_value param, std::string &strProName, st
false);
NAPI_CALL_BASE(env, napi_typeof(env, jsProValue, &jsValueType), false);
if (jsValueType != jsValueProType) {
HILOG_ERROR("%{public}s called, value property is invalid, this object is not fd object.", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, value property is invalid, this object is not fd object.",
__func__);
return false;
}
@ -986,7 +988,7 @@ bool HandleFdObject(napi_env env, napi_value param, std::string &strProName, AAF
int32_t natValue32 = 0;
napi_get_value_int32(env, jsProValue, &natValue32);
HILOG_INFO("%{public}s called, fd:%{public}d.", __func__, natValue32);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, fd:%{public}d.", __func__, natValue32);
WantParams wp;
wp.SetParam(TYPE_PROPERTY, String::Box(FD));
wp.SetParam(VALUE_PROPERTY, Integer::Box(natValue32));
@ -1005,7 +1007,7 @@ bool HandleRemoteObject(napi_env env, napi_value param, std::string &strProName,
sptr<IRemoteObject> remoteObject = NAPI_ohos_rpc_getNativeRemoteObject(env, jsProValue);
if (remoteObject == nullptr) {
HILOG_ERROR("%{public}s called, transfer to remoteObject fail", __func__);
TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, transfer to remoteObject fail", __func__);
return false;
}
@ -1071,7 +1073,7 @@ napi_value WrapWant(napi_env env, const Want &want)
napi_value jsElementName = WrapElementName(env, want.GetElement());
if (jsElementName == nullptr) {
HILOG_INFO("%{public}s called. Invoke WrapElementName failed.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Invoke WrapElementName failed.", __func__);
return nullptr;
}
@ -1120,7 +1122,7 @@ napi_value WrapWant(napi_env env, const Want &want)
bool UnwrapWant(napi_env env, napi_value param, Want &want)
{
if (!IsTypeForNapiValue(env, param, napi_object)) {
HILOG_INFO("%{public}s called. Params is invalid.", __func__);
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__);
return false;
}
@ -1290,7 +1292,7 @@ bool InnerWrapJsWantParamsWantParams(
bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr<AAFwk::IArray> &ao)
{
HILOG_INFO("%{public}s called. key=%{public}s", __func__, key.c_str());
TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str());
if (AAFwk::Array::IsStringArray(ao)) {
return InnerWrapWantParamsArray<AAFwk::IString, AAFwk::String, std::string>(
env, object, key, ao);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 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
@ -15,6 +15,7 @@
#include "js_dialog_request.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_error_utils.h"
#include "js_dialog_request_callback.h"
@ -33,16 +34,16 @@ constexpr int32_t RESULT_CANCEL = 1;
napi_value ResultCodeInit(napi_env env)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::DIALOG, "called");
if (env == nullptr) {
HILOG_ERROR("Invalid input parameters.");
TAG_LOGE(AAFwkTag::DIALOG, "Invalid input parameters.");
return nullptr;
}
napi_value objValue = nullptr;
napi_create_object(env, &objValue);
if (objValue == nullptr) {
HILOG_ERROR("Failed to get object");
TAG_LOGE(AAFwkTag::DIALOG, "Failed to get object");
return nullptr;
}
@ -59,7 +60,7 @@ public:
static void Finalizer(napi_env env, void* data, void* hint)
{
HILOG_INFO("JsDialogRequest::Finalizer is called");
TAG_LOGI(AAFwkTag::DIALOG, "JsDialogRequest::Finalizer is called");
std::unique_ptr<JsDialogRequest>(static_cast<JsDialogRequest*>(data));
}
@ -76,23 +77,23 @@ public:
private:
napi_value OnGetRequestInfo(napi_env env, NapiCallbackInfo& info)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::DIALOG, "%{public}s is called", __FUNCTION__);
if (info.argc < ARGC_ONE) {
HILOG_ERROR("Params not match");
TAG_LOGE(AAFwkTag::DIALOG, "Params not match");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
OHOS::AAFwk::Want want;
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
HILOG_ERROR("The input want is invalid.");
TAG_LOGE(AAFwkTag::DIALOG, "The input want is invalid.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
sptr<IRemoteObject> callerToken = want.GetRemoteObject(RequestConstants::REQUEST_TOKEN_KEY);
if (!callerToken) {
HILOG_ERROR("Can not get token from target want.");
TAG_LOGE(AAFwkTag::DIALOG, "Can not get token from target want.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -104,7 +105,7 @@ private:
auto requestInfo = new RequestInfo(callerToken, left, top, width, height);
auto jsRequestInfo = RequestInfo::WrapRequestInfo(env, requestInfo);
if (jsRequestInfo == nullptr) {
HILOG_ERROR("Can not wrap requestinfo from target request.");
TAG_LOGE(AAFwkTag::DIALOG, "Can not wrap requestinfo from target request.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -114,30 +115,30 @@ private:
napi_value OnGetRequestCallback(napi_env env, NapiCallbackInfo& info)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::DIALOG, "%{public}s is called", __FUNCTION__);
if (info.argc < ARGC_ONE) {
HILOG_ERROR("Params is not match");
TAG_LOGE(AAFwkTag::DIALOG, "Params is not match");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
OHOS::AAFwk::Want want;
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[0], want)) {
HILOG_ERROR("The input want is invalid.");
TAG_LOGE(AAFwkTag::DIALOG, "The input want is invalid.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
sptr<IRemoteObject> remoteObj = want.GetRemoteObject(RequestConstants::REQUEST_CALLBACK_KEY);
if (!remoteObj) {
HILOG_ERROR("Can not get callback from target want.");
TAG_LOGE(AAFwkTag::DIALOG, "Can not get callback from target want.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
sptr<IDialogRequestCallback> callback = iface_cast<IDialogRequestCallback>(remoteObj);
if (!callback) {
HILOG_ERROR("Cast to IDialogRequestCallback failed.");
TAG_LOGE(AAFwkTag::DIALOG, "Cast to IDialogRequestCallback failed.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
return CreateJsUndefined(env);
}
@ -148,9 +149,9 @@ private:
napi_value JsDialogRequestInit(napi_env env, napi_value exportObj)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::DIALOG, "called");
if (env == nullptr || exportObj == nullptr) {
HILOG_INFO("Invalid input parameters");
TAG_LOGI(AAFwkTag::DIALOG, "Invalid input parameters");
return nullptr;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 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
@ -15,6 +15,7 @@
#include "js_dialog_request_callback.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_context_utils.h"
#include "js_error_utils.h"
@ -33,14 +34,14 @@ public:
static void Finalizer(napi_env env, void* data, void* hint)
{
HILOG_DEBUG("JsDialogRequestCallback::Finalizer is called.");
TAG_LOGD(AAFwkTag::DIALOG, "JsDialogRequestCallback::Finalizer is called.");
std::unique_ptr<JsDialogRequestCallback>(static_cast<JsDialogRequestCallback*>(data));
}
static napi_value SetRequestResult(napi_env env, napi_callback_info info)
{
if (env == nullptr || info == nullptr) {
HILOG_ERROR("input parameters %{public}s is nullptr", ((env == nullptr) ? "env" : "info"));
TAG_LOGE(AAFwkTag::DIALOG, "input parameters %{public}s is nullptr", ((env == nullptr) ? "env" : "info"));
return nullptr;
}
@ -50,15 +51,15 @@ public:
private:
napi_value OnSetRequestResult(napi_env env, NapiCallbackInfo& info)
{
HILOG_INFO("function called");
TAG_LOGI(AAFwkTag::DIALOG, "function called");
if (info.argc < 1) {
HILOG_ERROR("Params not match");
TAG_LOGE(AAFwkTag::DIALOG, "Params not match");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
if (!CheckTypeForNapiValue(env, info.argv[0], napi_object)) {
HILOG_ERROR("param type mismatch!");
TAG_LOGE(AAFwkTag::DIALOG, "param type mismatch!");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -67,7 +68,7 @@ private:
napi_get_named_property(env, info.argv[0], "result", &resultCode);
int32_t resultCodeValue = 0;
if (!ConvertFromJsValue(env, resultCode, resultCodeValue)) {
HILOG_ERROR("Convert result failed!");
TAG_LOGE(AAFwkTag::DIALOG, "Convert result failed!");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -78,16 +79,16 @@ private:
if (jWant != nullptr && CheckTypeForNapiValue(env, jWant, napi_object)) {
AppExecFwk::UnwrapWant(env, jWant, wantValue);
} else {
HILOG_WARN("jWant is invalid data!");
TAG_LOGW(AAFwkTag::DIALOG, "jWant is invalid data!");
}
if (callback_ == nullptr) {
HILOG_ERROR("JsDialogRequestCallback::%{public}s, callback_ is nullptr", __func__);
TAG_LOGE(AAFwkTag::DIALOG, "JsDialogRequestCallback::%{public}s, callback_ is nullptr", __func__);
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
return CreateJsUndefined(env);
}
callback_->SendResult(resultCodeValue, wantValue);
HILOG_INFO("function called end.");
TAG_LOGI(AAFwkTag::DIALOG, "function called end.");
return CreateJsUndefined(env);
}
@ -98,16 +99,16 @@ private:
napi_value CreateJsDialogRequestCallback(napi_env env, const sptr<IDialogRequestCallback> &remoteObj)
{
HILOG_INFO("CreateJsDialogRequestCallback");
TAG_LOGI(AAFwkTag::DIALOG, "CreateJsDialogRequestCallback");
if (!remoteObj) {
HILOG_ERROR("remoteObj is invalid.");
TAG_LOGE(AAFwkTag::DIALOG, "remoteObj is invalid.");
return CreateJsUndefined(env);
}
napi_value objValue = nullptr;
napi_create_object(env, &objValue);
if (objValue == nullptr) {
HILOG_ERROR("object is invalid.");
TAG_LOGE(AAFwkTag::DIALOG, "object is invalid.");
return CreateJsUndefined(env);
}
@ -116,7 +117,7 @@ napi_value CreateJsDialogRequestCallback(napi_env env, const sptr<IDialogRequest
const char *moduleName = "JsDialogRequestCallback";
BindNativeFunction(env, objValue, "setRequestResult", moduleName, JsDialogRequestCallback::SetRequestResult);
HILOG_INFO("CreateJsDialogRequestCallback end");
TAG_LOGI(AAFwkTag::DIALOG, "CreateJsDialogRequestCallback end");
return objValue;
}
} // AbilityRuntime

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Copyright (c) 2023-2024 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
@ -16,6 +16,7 @@
#include "js_dialog_session.h"
#include "ability_manager_client.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_error_utils.h"
#include "napi/native_api.h"
@ -38,7 +39,7 @@ public:
static void Finalizer(napi_env env, void* data, void* hint)
{
HILOG_INFO("JsDialogSession::Finalizer is called");
TAG_LOGI(AAFwkTag::DIALOG, "JsDialogSession::Finalizer is called");
std::unique_ptr<JsDialogSession>(static_cast<JsDialogSession*>(data));
}
@ -55,9 +56,9 @@ public:
private:
napi_value OnGetDialogSessionInfo(napi_env env, NapiCallbackInfo& info)
{
HILOG_DEBUG("enter, argc = %{public}d", static_cast<int32_t>(info.argc));
TAG_LOGD(AAFwkTag::DIALOG, "enter, argc = %{public}d", static_cast<int32_t>(info.argc));
if (info.argc < 1) {
HILOG_ERROR("not enough params");
TAG_LOGE(AAFwkTag::DIALOG, "not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
@ -68,10 +69,10 @@ private:
}
sptr<AAFwk::DialogSessionInfo> dialogSessionInfo;
HILOG_DEBUG("GetDialogSessionInfo begin");
TAG_LOGD(AAFwkTag::DIALOG, "GetDialogSessionInfo begin");
auto errcode = AbilityManagerClient::GetInstance()->GetDialogSessionInfo(dialogSessionId, dialogSessionInfo);
if (errcode || dialogSessionInfo == nullptr) {
HILOG_ERROR("GetDialogSessionInfo error");
TAG_LOGE(AAFwkTag::DIALOG, "GetDialogSessionInfo error");
return CreateJsUndefined(env);
}
return OHOS::AppExecFwk::WrapDialogSessionInfo(env, *dialogSessionInfo);
@ -79,9 +80,9 @@ private:
napi_value OnSendDialogResult(napi_env env, NapiCallbackInfo& info)
{
HILOG_DEBUG("enter, argc = %{public}d", static_cast<int32_t>(info.argc));
TAG_LOGD(AAFwkTag::DIALOG, "enter, argc = %{public}d", static_cast<int32_t>(info.argc));
if (info.argc < ARGC_THREE) {
HILOG_ERROR("not enough params");
TAG_LOGE(AAFwkTag::DIALOG, "not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
@ -92,7 +93,7 @@ private:
}
AAFwk::Want want;
if (!AppExecFwk::UnwrapWant(env, info.argv[1], want)) {
HILOG_ERROR("Failed to unwrap want");
TAG_LOGE(AAFwkTag::DIALOG, "Failed to unwrap want");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -120,9 +121,9 @@ private:
napi_value JsDialogSessionInit(napi_env env, napi_value exportObj)
{
HILOG_INFO("JsDialogSessionInit is called");
TAG_LOGI(AAFwkTag::DIALOG, "JsDialogSessionInit is called");
if (env == nullptr || exportObj == nullptr) {
HILOG_INFO("Invalid input parameters");
TAG_LOGI(AAFwkTag::DIALOG, "Invalid input parameters");
return nullptr;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2023 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -15,6 +15,7 @@
#include "js_mission_info_utils.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "napi_common_want.h"
#include "napi_remote_object.h"
@ -139,7 +140,7 @@ bool InnerWrapJsWantParamsWantParams(
bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr<AAFwk::IArray> &ao)
{
HILOG_INFO("called. key=%{public}s", key.c_str());
TAG_LOGI(AAFwkTag::MISSION, "called. key=%{public}s", key.c_str());
if (AAFwk::Array::IsStringArray(ao)) {
return InnerWrapWantParamsArray<AAFwk::IString, AAFwk::String, std::string>(
env, object, key, ao);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -17,6 +17,7 @@
#include <memory>
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_runtime_utils.h"
@ -90,9 +91,9 @@ bool JsMissionListener::IsEmpty()
void JsMissionListener::CallJsMethod(const std::string &methodName, int32_t missionId)
{
HILOG_DEBUG("methodName = %{public}s", methodName.c_str());
TAG_LOGD(AAFwkTag::MISSION, "methodName = %{public}s", methodName.c_str());
if (env_ == nullptr) {
HILOG_ERROR("env_ nullptr");
TAG_LOGE(AAFwkTag::MISSION, "env_ nullptr");
return;
}
@ -131,9 +132,9 @@ void JsMissionListener::CallJsMethodInner(const std::string &methodName, int32_t
void JsMissionListener::CallJsFunction(
napi_value obj, const char* methodName, napi_value *argv, size_t argc)
{
HILOG_INFO("method:%{public}s", methodName);
TAG_LOGI(AAFwkTag::MISSION, "method:%{public}s", methodName);
if (obj == nullptr) {
HILOG_ERROR("Failed to get object");
TAG_LOGE(AAFwkTag::MISSION, "Failed to get object");
return;
}
@ -141,7 +142,7 @@ void JsMissionListener::CallJsFunction(
napi_get_named_property(env_, obj, methodName, &method);
if (method == nullptr || AppExecFwk::IsTypeForNapiValue(env_, method, napi_undefined)
|| AppExecFwk::IsTypeForNapiValue(env_, method, napi_null)) {
HILOG_ERROR("Failed to get %{public}s from object", methodName);
TAG_LOGE(AAFwkTag::MISSION, "Failed to get %{public}s from object", methodName);
return;
}
napi_value callResult = nullptr;
@ -151,14 +152,14 @@ void JsMissionListener::CallJsFunction(
#ifdef SUPPORT_GRAPHICS
void JsMissionListener::OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon)
{
HILOG_DEBUG("OnMissionIconUpdated, missionId = %{public}d", missionId);
TAG_LOGD(AAFwkTag::MISSION, "OnMissionIconUpdated, missionId = %{public}d", missionId);
if (env_ == nullptr) {
HILOG_ERROR("env_ is nullptr");
TAG_LOGE(AAFwkTag::MISSION, "env_ is nullptr");
return;
}
if (missionId <= 0 || !icon) {
HILOG_ERROR("missionId or icon is invalid, missionId:%{public}d", missionId);
TAG_LOGE(AAFwkTag::MISSION, "missionId or icon is invalid, missionId:%{public}d", missionId);
return;
}
@ -180,7 +181,7 @@ void JsMissionListener::OnMissionIconUpdated(int32_t missionId, const std::share
void JsMissionListener::CallJsMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon)
{
if (env_ == nullptr) {
HILOG_ERROR("env_ is nullptr, not call js mission updated.");
TAG_LOGE(AAFwkTag::MISSION, "env_ is nullptr, not call js mission updated.");
return;
}
@ -191,14 +192,14 @@ void JsMissionListener::CallJsMissionIconUpdated(int32_t missionId, const std::s
for (auto &item : tmpMap) {
napi_value obj = (item.second)->GetNapiValue();
if (obj == nullptr) {
HILOG_ERROR("Failed to get js object");
TAG_LOGE(AAFwkTag::MISSION, "Failed to get js object");
continue;
}
napi_value method = nullptr;
napi_get_named_property(env_, obj, "onMissionIconUpdated", &method);
if (method == nullptr || AppExecFwk::IsTypeForNapiValue(env_, method, napi_undefined)
|| AppExecFwk::IsTypeForNapiValue(env_, method, napi_null)) {
HILOG_ERROR("Failed to get onMissionIconUpdated method from object");
TAG_LOGE(AAFwkTag::MISSION, "Failed to get onMissionIconUpdated method from object");
continue;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 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
@ -18,6 +18,7 @@
#include "ability_manager_client.h"
#include "event_handler.h"
#include "event_runner.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_error_utils.h"
#include "js_mission_info_utils.h"
@ -55,7 +56,7 @@ public:
static void Finalizer(napi_env env, void* data, void* hint)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
std::unique_ptr<JsMissionManager>(static_cast<JsMissionManager*>(data));
}
@ -127,7 +128,7 @@ public:
private:
napi_value OnOn(napi_env env, size_t argc, napi_value* argv)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
std::string type = ParseParamType(env, argc, argv);
if (type == ON_OFF_TYPE_SYNC) {
return OnOnNew(env, argc, argv);
@ -137,9 +138,9 @@ private:
napi_value OnOnOld(napi_env env, size_t argc, napi_value* argv)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
if (argc < ARG_COUNT_TWO) {
HILOG_ERROR("Params not match");
TAG_LOGE(AAFwkTag::MISSION, "Params not match");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
@ -161,7 +162,7 @@ private:
missionListener_->AddJsListenerObject(missionListenerId_, argv[ARGC_ONE]);
return CreateJsValue(env, missionListenerId_);
} else {
HILOG_ERROR("RegisterMissionListener failed, ret = %{public}d", ret);
TAG_LOGE(AAFwkTag::MISSION, "RegisterMissionListener failed, ret = %{public}d", ret);
missionListener_ = nullptr;
if (ret == CHECK_PERMISSION_FAILED) {
ThrowNoPermissionError(env, PermissionConstants::PERMISSION_MANAGE_MISSION);
@ -174,14 +175,14 @@ private:
napi_value OnOnNew(napi_env env, size_t argc, napi_value* argv)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
if (argc < ARG_COUNT_TWO) {
HILOG_ERROR("Params not match");
TAG_LOGE(AAFwkTag::MISSION, "Params not match");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
if (!AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_object)) {
HILOG_ERROR("Invalid param");
TAG_LOGE(AAFwkTag::MISSION, "Invalid param");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -198,7 +199,7 @@ private:
missionListener_->AddJsListenerObject(missionListenerId_, argv[INDEX_ONE], true);
return CreateJsValue(env, missionListenerId_);
} else {
HILOG_ERROR("RegisterMissionListener failed, ret = %{public}d", ret);
TAG_LOGE(AAFwkTag::MISSION, "RegisterMissionListener failed, ret = %{public}d", ret);
missionListener_ = nullptr;
if (ret == CHECK_PERMISSION_FAILED) {
ThrowNoPermissionError(env, PermissionConstants::PERMISSION_MANAGE_MISSION);
@ -211,7 +212,7 @@ private:
napi_value OnOff(napi_env env, size_t argc, napi_value* argv)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
std::string type = ParseParamType(env, argc, argv);
if (type == ON_OFF_TYPE_SYNC) {
return OnOffNew(env, argc, argv);
@ -221,9 +222,9 @@ private:
napi_value OnOffOld(napi_env env, size_t argc, napi_value* argv)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
if (argc < ARG_COUNT_TWO) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
@ -235,7 +236,7 @@ private:
int32_t missionListenerId = -1;
if (!ConvertFromJsValue(env, argv[ARGC_ONE], missionListenerId)) {
HILOG_ERROR("Parse missionListenerId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -271,40 +272,40 @@ private:
napi_value OnOffNew(napi_env env, size_t argc, napi_value* argv)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
if (argc < ARG_COUNT_TWO) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionListenerId = -1;
if (!ConvertFromJsValue(env, argv[INDEX_ONE], missionListenerId)) {
HILOG_ERROR("Parse missionListenerId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
if (missionListener_ == nullptr) {
HILOG_ERROR("missionListener_ is nullptr");
TAG_LOGE(AAFwkTag::MISSION, "missionListener_ is nullptr");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER);
return CreateJsUndefined(env);
}
if (!missionListener_->RemoveJsListenerObject(missionListenerId, true)) {
HILOG_ERROR("missionListenerId not found");
TAG_LOGE(AAFwkTag::MISSION, "missionListenerId not found");
ThrowError(env, AbilityErrorCode::ERROR_CODE_NO_MISSION_LISTENER);
return CreateJsUndefined(env);
}
if (!missionListener_->IsEmpty()) {
HILOG_DEBUG("Off success, missionListener is not empty");
TAG_LOGD(AAFwkTag::MISSION, "Off success, missionListener is not empty");
return CreateJsUndefined(env);
}
auto ret = AbilityManagerClient::GetInstance()->UnRegisterMissionListener(missionListener_);
if (ret == 0) {
HILOG_DEBUG("UnRegisterMissionListener success");
TAG_LOGD(AAFwkTag::MISSION, "UnRegisterMissionListener success");
missionListener_ = nullptr;
} else {
HILOG_ERROR("UnRegisterMissionListener failed");
TAG_LOGE(AAFwkTag::MISSION, "UnRegisterMissionListener failed");
if (ret == CHECK_PERMISSION_FAILED) {
ThrowNoPermissionError(env, PermissionConstants::PERMISSION_MANAGE_MISSION);
} else {
@ -316,21 +317,21 @@ private:
napi_value OnGetMissionInfos(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc < ARG_COUNT_TWO) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::string deviceId;
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
HILOG_ERROR("Parse deviceId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
int numMax = -1;
if (!ConvertFromJsValue(env, argv[1], numMax)) {
HILOG_ERROR("Parse numMax failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse numMax failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -356,21 +357,21 @@ private:
napi_value OnGetMissionInfo(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc < ARG_COUNT_TWO) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::string deviceId;
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
HILOG_ERROR("Parse deviceId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[1], missionId)) {
HILOG_ERROR("Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -396,19 +397,19 @@ private:
napi_value OnGetMissionSnapShot(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("called");
TAG_LOGI(AAFwkTag::MISSION, "called");
return GetMissionSnapShot(env, argc, argv, false);
}
napi_value OnGetLowResolutionMissionSnapShot(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("called");
TAG_LOGI(AAFwkTag::MISSION, "called");
return GetMissionSnapShot(env, argc, argv, true);
}
napi_value GetMissionSnapShot(napi_env env, size_t argc, napi_value* argv, bool isLowResolution)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
std::string deviceId;
int32_t missionId = -1;
if (!CheckMissionSnapShotParams(env, argc, argv, deviceId, missionId)) {
@ -465,13 +466,13 @@ private:
}
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
HILOG_ERROR("missionSnapshot: Parse deviceId failed");
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse deviceId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return false;
}
if (!ConvertFromJsValue(env, argv[1], missionId)) {
HILOG_ERROR("missionSnapshot: Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return false;
}
@ -481,15 +482,15 @@ private:
napi_value OnLockMission(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnLockMission Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnLockMission Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnLockMission Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnLockMission Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -514,15 +515,15 @@ private:
napi_value OnUnlockMission(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnUnlockMission Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnUnlockMission Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnUnlockMission Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnUnlockMission Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -547,15 +548,15 @@ private:
napi_value OnClearMission(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnClearMission Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnClearMission Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnClearMission Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnClearMission Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -580,7 +581,7 @@ private:
napi_value OnClearAllMissions(napi_env env, const size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
NapiAsyncTask::CompleteCallback complete =
[](napi_env env, NapiAsyncTask &task, int32_t status) {
auto ret = AbilityManagerClient::GetInstance()->CleanAllMissions();
@ -601,15 +602,15 @@ private:
napi_value OnMoveMissionToFront(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnMoveMissionToFront Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionToFront Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnMoveMissionToFront Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionToFront Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -617,7 +618,7 @@ private:
AAFwk::StartOptions startOptions;
if (argc > ARGC_ONE && AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_object)) {
HILOG_INFO("OnMoveMissionToFront start options is used.");
TAG_LOGI(AAFwkTag::MISSION, "OnMoveMissionToFront start options is used.");
AppExecFwk::UnwrapStartOptions(env, argv[1], startOptions);
unwrapArgc++;
}
@ -642,17 +643,17 @@ private:
napi_value OnMoveMissionsToForeground(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
std::vector<int32_t> missionIds;
if (argc < ARGC_ONE) {
HILOG_ERROR("OnMoveMissionsToForeground Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
uint32_t nativeArrayLen = 0;
napi_get_array_length(env, argv[0], &nativeArrayLen);
if (nativeArrayLen == 0) {
HILOG_ERROR("OnMoveMissionsToForeground MissionId is null");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground MissionId is null");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -661,7 +662,7 @@ private:
int32_t missionId = 0;
napi_get_element(env, argv[0], i, &element);
if (!ConvertFromJsValue(env, element, missionId)) {
HILOG_ERROR("OnMoveMissionsToForeground Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -672,7 +673,7 @@ private:
decltype(argc) unwrapArgc = 1;
if (argc > ARGC_ONE && AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_number)) {
if (!ConvertFromJsValue(env, argv[1], topMissionId)) {
HILOG_ERROR("OnMoveMissionsToForeground Parse topMissionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToForeground Parse topMissionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -700,18 +701,18 @@ private:
napi_value OnMoveMissionsToBackground(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
std::vector<int32_t> missionIds;
if (argc < ARGC_ONE) {
HILOG_ERROR("OnMoveMissionsToBackground Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
uint32_t nativeArrayLen = 0;
napi_get_array_length(env, argv[0], &nativeArrayLen);
if (nativeArrayLen == 0) {
HILOG_ERROR("OnMoveMissionsToBackground MissionId is null");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground MissionId is null");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -720,7 +721,7 @@ private:
int32_t missionId;
napi_get_element(env, argv[0], i, &element);
if (!ConvertFromJsValue(env, element, missionId)) {
HILOG_ERROR("OnMoveMissionsToBackground Parse topMissionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionsToBackground Parse topMissionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -760,18 +761,18 @@ private:
}
if (!AppExecFwk::IsTypeForNapiValue(env, argv[0], napi_string)) {
HILOG_ERROR("CheckOnOffType, Param 0 is not string");
TAG_LOGE(AAFwkTag::MISSION, "CheckOnOffType, Param 0 is not string");
return false;
}
std::string type;
if (!ConvertFromJsValue(env, argv[0], type)) {
HILOG_ERROR("CheckOnOffType, Parse on off type failed");
TAG_LOGE(AAFwkTag::MISSION, "CheckOnOffType, Parse on off type failed");
return false;
}
if (type != ON_OFF_TYPE) {
HILOG_ERROR("CheckOnOffType, args[0] should be mission.");
TAG_LOGE(AAFwkTag::MISSION, "CheckOnOffType, args[0] should be mission.");
return false;
}
return true;
@ -792,9 +793,9 @@ private:
napi_value JsMissionManagerInit(napi_env env, napi_value exportObj)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::MISSION, "called");
if (env == nullptr || exportObj == nullptr) {
HILOG_INFO("Invalid input parameters");
TAG_LOGI(AAFwkTag::MISSION, "Invalid input parameters");
return nullptr;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2022 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -15,6 +15,7 @@
#include "js_mission_info_utils.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "napi_common_want.h"
#include "napi_remote_object.h"
@ -119,14 +120,14 @@ napi_value CreateJsMissionInfoArray(napi_env env, const std::vector<AAFwk::Missi
for (const auto &missionInfo : missionInfos) {
napi_set_element(env, arrayValue, index++, CreateJsMissionInfo(env, missionInfo));
}
HILOG_DEBUG("end");
TAG_LOGD(AAFwkTag::MISSION, "end");
return arrayValue;
}
bool InnerWrapJsWantParamsWantParams(
napi_env env, napi_value object, const std::string &key, const AAFwk::WantParams &wantParams)
{
HILOG_DEBUG("enter");
TAG_LOGD(AAFwkTag::MISSION, "enter");
auto value = wantParams.GetParam(key);
AAFwk::IWantParams *o = AAFwk::IWantParams::Query(value);
if (o != nullptr) {
@ -134,13 +135,13 @@ bool InnerWrapJsWantParamsWantParams(
napi_set_named_property(env, object, key.c_str(), CreateJsWantParams(env, wp));
return true;
}
HILOG_DEBUG("end");
TAG_LOGD(AAFwkTag::MISSION, "end");
return false;
}
bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr<AAFwk::IArray> &ao)
{
HILOG_INFO("%{public}s start. key=%{public}s", __func__, key.c_str());
TAG_LOGI(AAFwkTag::MISSION, "%{public}s start. key=%{public}s", __func__, key.c_str());
if (AAFwk::Array::IsStringArray(ao)) {
return InnerWrapWantParamsArray<AAFwk::IString, AAFwk::String, std::string>(
env, object, key, ao);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -16,6 +16,7 @@
#include "js_mission_listener.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_runtime_utils.h"
@ -79,9 +80,9 @@ bool JsMissionListener::IsEmpty()
void JsMissionListener::CallJsMethod(const std::string &methodName, int32_t missionId)
{
HILOG_INFO("methodName = %{public}s", methodName.c_str());
TAG_LOGI(AAFwkTag::MISSION, "methodName = %{public}s", methodName.c_str());
if (env_ == nullptr) {
HILOG_ERROR("env_ null");
TAG_LOGE(AAFwkTag::MISSION, "env_ null");
return;
}
@ -106,14 +107,14 @@ void JsMissionListener::CallJsMethodInner(const std::string &methodName, int32_t
for (auto &item : tmpMap) {
napi_value obj = (item.second)->GetNapiValue();
if (obj == nullptr) {
HILOG_ERROR("Failed to get object");
TAG_LOGE(AAFwkTag::MISSION, "Failed to get object");
continue;
}
napi_value method = nullptr;
napi_get_named_property(env_, obj, methodName.c_str(), &method);
if (method == nullptr || AppExecFwk::IsTypeForNapiValue(env_, method, napi_undefined)
|| AppExecFwk::IsTypeForNapiValue(env_, method, napi_null)) {
HILOG_ERROR("Failed to get %{public}s from object", methodName.c_str());
TAG_LOGE(AAFwkTag::MISSION, "Failed to get %{public}s from object", methodName.c_str());
continue;
}
napi_value argv[] = { CreateJsValue(env_, missionId) };
@ -125,14 +126,14 @@ void JsMissionListener::CallJsMethodInner(const std::string &methodName, int32_t
#ifdef SUPPORT_GRAPHICS
void JsMissionListener::OnMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon)
{
HILOG_INFO("OnMissionIconUpdated, missionId = %{public}d.", missionId);
TAG_LOGI(AAFwkTag::MISSION, "OnMissionIconUpdated, missionId = %{public}d.", missionId);
if (env_ == nullptr) {
HILOG_ERROR("env_ is null");
TAG_LOGE(AAFwkTag::MISSION, "env_ is null");
return;
}
if (missionId <= 0 || !icon) {
HILOG_ERROR("missionId or icon is invalid, missionId:%{public}d.", missionId);
TAG_LOGE(AAFwkTag::MISSION, "missionId or icon is invalid, missionId:%{public}d.", missionId);
return;
}
@ -154,7 +155,7 @@ void JsMissionListener::OnMissionIconUpdated(int32_t missionId, const std::share
void JsMissionListener::CallJsMissionIconUpdated(int32_t missionId, const std::shared_ptr<Media::PixelMap> &icon)
{
if (env_ == nullptr) {
HILOG_ERROR("env_ is null, not call js mission updated.");
TAG_LOGE(AAFwkTag::MISSION, "env_ is null, not call js mission updated.");
return;
}
@ -165,14 +166,14 @@ void JsMissionListener::CallJsMissionIconUpdated(int32_t missionId, const std::s
for (auto &item : tmpMap) {
napi_value obj = (item.second)->GetNapiValue();
if (obj == nullptr) {
HILOG_ERROR("Failed to get js object");
TAG_LOGE(AAFwkTag::MISSION, "Failed to get js object");
continue;
}
napi_value method = nullptr;
napi_get_named_property(env_, obj, "onMissionIconUpdated", &method);
if (method == nullptr || AppExecFwk::IsTypeForNapiValue(env_, method, napi_undefined)
|| AppExecFwk::IsTypeForNapiValue(env_, method, napi_null)) {
HILOG_ERROR("Failed to get onMissionIconUpdated method from object");
TAG_LOGE(AAFwkTag::MISSION, "Failed to get onMissionIconUpdated method from object");
continue;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 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
@ -15,6 +15,7 @@
#include "mission_continue_stub.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "ipc_types.h"
#include "message_parcel.h"
@ -32,19 +33,19 @@ int32_t MissionContinueStub::OnRemoteRequest(
uint32_t code, MessageParcel& data, MessageParcel& reply, MessageOption& option)
{
if (data.ReadInterfaceToken() != GetDescriptor()) {
HILOG_ERROR("Local descriptor is not equal to remote");
TAG_LOGE(AAFwkTag::MISSION, "Local descriptor is not equal to remote");
return ERR_INVALID_STATE;
}
switch (code) {
case IMissionContinue::NOTIFY_CONTINUATION_RESULT: {
int32_t result = data.ReadInt32();
HILOG_INFO("NOTIFY_CONTINUATION_RESULT result: %{public}d", result);
TAG_LOGI(AAFwkTag::MISSION, "NOTIFY_CONTINUATION_RESULT result: %{public}d", result);
OnContinueDone(result);
return NO_ERROR;
}
default: {
HILOG_WARN("MissionContinueStub::OnRemoteRequest code: %{public}d", code);
TAG_LOGW(AAFwkTag::MISSION, "MissionContinueStub::OnRemoteRequest code: %{public}d", code);
return IPCObjectStub::OnRemoteRequest(code, data, reply, option);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 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
@ -18,6 +18,7 @@
#include "ability_manager_client.h"
#include "event_handler.h"
#include "event_runner.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_error_utils.h"
#include "js_mission_info_utils.h"
@ -49,7 +50,7 @@ public:
static void Finalizer(napi_env env, void* data, void* hint)
{
HILOG_INFO("JsMissionManager::Finalizer is called");
TAG_LOGI(AAFwkTag::MISSION, "JsMissionManager::Finalizer is called");
std::unique_ptr<JsMissionManager>(static_cast<JsMissionManager*>(data));
}
@ -111,9 +112,9 @@ public:
private:
napi_value OnRegisterMissionListener(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc < 1) {
HILOG_ERROR("Params not match");
TAG_LOGE(AAFwkTag::MISSION, "Params not match");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
@ -130,7 +131,7 @@ private:
missionListener_->AddJsListenerObject(missionListenerId_, argv[0]);
return CreateJsValue(env, missionListenerId_);
} else {
HILOG_ERROR("RegisterMissionListener error, ret = %{public}d", ret);
TAG_LOGE(AAFwkTag::MISSION, "RegisterMissionListener error, ret = %{public}d", ret);
missionListener_ = nullptr;
if (ret == CHECK_PERMISSION_FAILED) {
ThrowNoPermissionError(env, PermissionConstants::PERMISSION_MANAGE_MISSION);
@ -143,16 +144,16 @@ private:
napi_value OnUnregisterMissionListener(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc < 1) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionListenerId = -1;
if (!ConvertFromJsValue(env, argv[0], missionListenerId)) {
HILOG_ERROR("Parse missionListenerId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse missionListenerId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -188,21 +189,21 @@ private:
napi_value OnGetMissionInfos(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc < ARG_COUNT_TWO) { // at least 2 parameters.
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::string deviceId;
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
HILOG_ERROR("Parse deviceId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
int numMax = -1;
if (!ConvertFromJsValue(env, argv[1], numMax)) {
HILOG_ERROR("Parse numMax failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse numMax failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -228,21 +229,21 @@ private:
napi_value OnGetMissionInfo(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc < ARG_COUNT_TWO) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::string deviceId;
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
HILOG_ERROR("Parse deviceId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse deviceId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[1], missionId)) {
HILOG_ERROR("Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -268,13 +269,13 @@ private:
napi_value OnGetMissionSnapShot(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("called");
TAG_LOGI(AAFwkTag::MISSION, "called");
return GetMissionSnapShot(env, argc, argv, false);
}
napi_value OnGetLowResolutionMissionSnapShot(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("called");
TAG_LOGI(AAFwkTag::MISSION, "called");
return GetMissionSnapShot(env, argc, argv, true);
}
@ -336,13 +337,13 @@ private:
}
if (!ConvertFromJsValue(env, argv[0], deviceId)) {
HILOG_ERROR("missionSnapshot: Parse deviceId failed");
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse deviceId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return false;
}
if (!ConvertFromJsValue(env, argv[1], missionId)) {
HILOG_ERROR("missionSnapshot: Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "missionSnapshot: Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return false;
}
@ -352,15 +353,15 @@ private:
napi_value OnLockMission(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnLockMission Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnLockMission Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnLockMission Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnLockMission Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -385,15 +386,15 @@ private:
napi_value OnUnlockMission(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnUnlockMission Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnUnlockMission Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnUnlockMission Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnUnlockMission Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -418,15 +419,15 @@ private:
napi_value OnClearMission(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnClearMission Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnClearMission Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnClearMission Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnClearMission Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -451,7 +452,7 @@ private:
napi_value OnClearAllMissions(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
NapiAsyncTask::CompleteCallback complete =
[](napi_env env, NapiAsyncTask &task, int32_t status) {
auto ret = AbilityManagerClient::GetInstance()->CleanAllMissions();
@ -472,15 +473,15 @@ private:
napi_value OnMoveMissionToFront(napi_env env, size_t argc, napi_value* argv)
{
HILOG_INFO("%{public}s is called", __FUNCTION__);
TAG_LOGI(AAFwkTag::MISSION, "%{public}s is called", __FUNCTION__);
if (argc == 0) {
HILOG_ERROR("OnMoveMissionToFront Not enough params");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionToFront Not enough params");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
int32_t missionId = -1;
if (!ConvertFromJsValue(env, argv[0], missionId)) {
HILOG_ERROR("OnMoveMissionToFront Parse missionId failed");
TAG_LOGE(AAFwkTag::MISSION, "OnMoveMissionToFront Parse missionId failed");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
@ -488,7 +489,7 @@ private:
AAFwk::StartOptions startOptions;
if (argc > ARGC_ONE && AppExecFwk::IsTypeForNapiValue(env, argv[1], napi_object)) {
HILOG_INFO("OnMoveMissionToFront start options is used.");
TAG_LOGI(AAFwkTag::MISSION, "OnMoveMissionToFront start options is used.");
AppExecFwk::UnwrapStartOptions(env, argv[1], startOptions);
unwrapArgc++;
}
@ -517,9 +518,9 @@ private:
napi_value JsMissionManagerInit(napi_env env, napi_value exportObj)
{
HILOG_INFO("JsMissionManagerInit is called");
TAG_LOGI(AAFwkTag::MISSION, "JsMissionManagerInit is called");
if (env == nullptr || exportObj == nullptr) {
HILOG_INFO("Invalid input parameters");
TAG_LOGI(AAFwkTag::MISSION, "Invalid input parameters");
return nullptr;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022-2023 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 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
@ -15,6 +15,7 @@
#include "js_quick_fix_manager.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_application_quick_fix_info.h"
#include "js_runtime_utils.h"
@ -38,7 +39,7 @@ public:
static void Finalizer(napi_env env, void *data, void *hint)
{
HILOG_DEBUG("function called.");
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
std::unique_ptr<JsQuickFixManager>(static_cast<JsQuickFixManager*>(data));
}
@ -75,16 +76,16 @@ public:
private:
napi_value OnGetApplyedQuickFixInfo(napi_env env, NapiCallbackInfo &info)
{
HILOG_DEBUG("function called.");
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
HILOG_ERROR("The number of parameter is invalid.");
TAG_LOGE(AAFwkTag::QUICKFIX, "The number of parameter is invalid.");
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
return CreateJsUndefined(env);
}
std::string bundleName;
if (!OHOS::AppExecFwk::UnwrapStringFromJS2(env, info.argv[0], bundleName)) {
HILOG_ERROR("The bundleName is invalid.");
TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleName is invalid.");
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
return CreateJsUndefined(env);
}
@ -104,22 +105,22 @@ private:
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsQuickFixManager::OnGetApplyedQuickFixInfo", env,
CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
HILOG_DEBUG("function finished.");
TAG_LOGD(AAFwkTag::QUICKFIX, "function finished.");
return result;
}
napi_value OnApplyQuickFix(napi_env env, NapiCallbackInfo &info)
{
HILOG_DEBUG("function called.");
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
if (info.argc != ARGC_ONE && info.argc != ARGC_TWO) {
HILOG_ERROR("The number of parameter is invalid.");
TAG_LOGE(AAFwkTag::QUICKFIX, "The number of parameter is invalid.");
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
return CreateJsUndefined(env);
}
std::vector<std::string> hapQuickFixFiles;
if (!OHOS::AppExecFwk::UnwrapArrayStringFromJS(env, info.argv[0], hapQuickFixFiles)) {
HILOG_ERROR("Hap quick fix files is invalid.");
TAG_LOGE(AAFwkTag::QUICKFIX, "Hap quick fix files is invalid.");
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
return CreateJsUndefined(env);
}
@ -138,22 +139,22 @@ private:
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsQuickFixManager::OnApplyQuickFix", env,
CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result));
HILOG_DEBUG("function finished.");
TAG_LOGD(AAFwkTag::QUICKFIX, "function finished.");
return result;
}
napi_value OnRevokeQuickFix(napi_env env, NapiCallbackInfo &info)
{
HILOG_DEBUG("called.");
TAG_LOGD(AAFwkTag::QUICKFIX, "called.");
if (info.argc == ARGC_ZERO) {
HILOG_ERROR("The number of parameter is invalid.");
TAG_LOGE(AAFwkTag::QUICKFIX, "The number of parameter is invalid.");
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
return CreateJsUndefined(env);
}
std::string bundleName;
if (!ConvertFromJsValue(env, info.argv[ARGC_ZERO], bundleName)) {
HILOG_ERROR("The bundleName is invalid.");
TAG_LOGE(AAFwkTag::QUICKFIX, "The bundleName is invalid.");
Throw(env, AAFwk::ERR_QUICKFIX_PARAM_INVALID);
return CreateJsUndefined(env);
}
@ -163,22 +164,22 @@ private:
auto quickFixMgr = DelayedSingleton<AAFwk::QuickFixManagerClient>::GetInstance();
if (quickFixMgr == nullptr) {
*retval = AAFwk::ERR_QUICKFIX_INTERNAL_ERROR;
HILOG_ERROR("Get quick fix mgr is nullptr.");
TAG_LOGE(AAFwkTag::QUICKFIX, "Get quick fix mgr is nullptr.");
return;
}
*retval = quickFixMgr->RevokeQuickFix(bundleName);
HILOG_DEBUG("Revoke quick fix execute retval is {%{public}d}.", *retval);
TAG_LOGD(AAFwkTag::QUICKFIX, "Revoke quick fix execute retval is {%{public}d}.", *retval);
};
auto complete = [retval = errCode](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("Revoke quick fix complete called.");
TAG_LOGD(AAFwkTag::QUICKFIX, "Revoke quick fix complete called.");
if (*retval != AAFwk::ERR_OK) {
HILOG_ERROR("Revoke quick fix execution failed. retval is %{public}d", *retval);
TAG_LOGE(AAFwkTag::QUICKFIX, "Revoke quick fix execution failed. retval is %{public}d", *retval);
task.Reject(env, CreateJsErrorByErrorCode(env, *retval));
return;
}
HILOG_DEBUG("Revoke quick fix complete called ok.");
TAG_LOGD(AAFwkTag::QUICKFIX, "Revoke quick fix complete called ok.");
task.ResolveWithNoError(env, CreateJsUndefined(env));
};
@ -186,16 +187,16 @@ private:
napi_value result = nullptr;
NapiAsyncTask::Schedule("JsQuickFixManager::OnRevokeQuickFix", env,
CreateAsyncTaskWithLastParam(env, lastParam, std::move(execute), std::move(complete), &result));
HILOG_DEBUG("Function finished.");
TAG_LOGD(AAFwkTag::QUICKFIX, "Function finished.");
return result;
}
};
napi_value CreateJsQuickFixManager(napi_env env, napi_value exportObj)
{
HILOG_DEBUG("function called.");
TAG_LOGD(AAFwkTag::QUICKFIX, "function called.");
if (env == nullptr || exportObj == nullptr) {
HILOG_ERROR("Input parameter is invalid.");
TAG_LOGE(AAFwkTag::QUICKFIX, "Input parameter is invalid.");
return nullptr;
}

View File

@ -18,6 +18,7 @@
#include "ability_business_error.h"
#include "ability_manager_errors.h"
#include "ability_runtime_error_util.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "ipc_skeleton.h"
#include "js_error_utils.h"
@ -43,7 +44,7 @@ public:
static void Finalizer(napi_env env, void* data, void* hint)
{
HILOG_INFO("JsUriPermMgr::Finalizer is called");
TAG_LOGI(AAFwkTag::URIPERMMGR, "JsUriPermMgr::Finalizer is called");
std::unique_ptr<JsUriPermMgr>(static_cast<JsUriPermMgr*>(data));
}
@ -60,33 +61,33 @@ public:
private:
napi_value OnGrantUriPermission(napi_env env, NapiCallbackInfo& info)
{
HILOG_DEBUG("Grant Uri Permission start");
TAG_LOGD(AAFwkTag::URIPERMMGR, "Grant Uri Permission start");
if (info.argc != argCountThree && info.argc != argCountFour) {
HILOG_ERROR("The number of parameter is invalid.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "The number of parameter is invalid.");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::string uriStr;
if (!OHOS::AppExecFwk::UnwrapStringFromJS2(env, info.argv[0], uriStr)) {
HILOG_ERROR("The uriStr is invalid.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "The uriStr is invalid.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
int flag = 0;
if (!OHOS::AppExecFwk::UnwrapInt32FromJS2(env, info.argv[1], flag)) {
HILOG_ERROR("The flag is invalid.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "The flag is invalid.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
std::string targetBundleName;
if (!OHOS::AppExecFwk::UnwrapStringFromJS2(env, info.argv[argCountTwo], targetBundleName)) {
HILOG_ERROR("The targetBundleName is invalid.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "The targetBundleName is invalid.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
auto selfToken = IPCSkeleton::GetSelfTokenID();
if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) {
HILOG_ERROR("This application is not system-app, can not use system-api.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "This application is not system-app, can not use system-api.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP);
return CreateJsUndefined(env);
}
@ -124,25 +125,25 @@ private:
{
// only support 2 or 3 params (2 parameter and 1 optional callback)
if (info.argc != argCountThree && info.argc != argCountTwo) {
HILOG_ERROR("Invalid arguments");
TAG_LOGE(AAFwkTag::URIPERMMGR, "Invalid arguments");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
std::string uriStr;
if (!OHOS::AppExecFwk::UnwrapStringFromJS2(env, info.argv[0], uriStr)) {
HILOG_ERROR("invalid of the uriStr.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "invalid of the uriStr.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
std::string bundleName;
if (!OHOS::AppExecFwk::UnwrapStringFromJS2(env, info.argv[1], bundleName)) {
HILOG_ERROR("The bundleName is invalid.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "The bundleName is invalid.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM);
return CreateJsUndefined(env);
}
auto selfToken = IPCSkeleton::GetSelfTokenID();
if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) {
HILOG_ERROR("can not use system-api, this application is not system-app.");
TAG_LOGE(AAFwkTag::URIPERMMGR, "can not use system-api, this application is not system-app.");
ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP);
return CreateJsUndefined(env);
}
@ -174,9 +175,9 @@ private:
napi_value CreateJsUriPermMgr(napi_env env, napi_value exportObj)
{
HILOG_INFO("CreateJsUriPermMgr is called");
TAG_LOGI(AAFwkTag::URIPERMMGR, "CreateJsUriPermMgr is called");
if (env == nullptr || exportObj == nullptr) {
HILOG_INFO("Invalid input parameters");
TAG_LOGI(AAFwkTag::URIPERMMGR, "Invalid input parameters");
return nullptr;
}

View File

@ -14,6 +14,7 @@
*/
#include "want_constant.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
namespace OHOS {
@ -28,7 +29,7 @@ namespace AppExecFwk {
*/
napi_value WantConstantInit(napi_env env, napi_value exports)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::WANT, "called");
napi_value action = nullptr;
napi_value entity = nullptr;
napi_value Flags = nullptr;
@ -133,7 +134,7 @@ napi_value WantConstantInit(napi_env env, napi_value exports)
void SetNamedProperty(napi_env env, napi_value dstObj, const char *objName, const char *propName)
{
HILOG_DEBUG("start");
TAG_LOGD(AAFwkTag::WANT, "start");
napi_value prop = nullptr;
napi_create_string_utf8(env, objName, NAPI_AUTO_LENGTH, &prop);
napi_set_named_property(env, dstObj, propName, prop);
@ -141,7 +142,7 @@ void SetNamedProperty(napi_env env, napi_value dstObj, const char *objName, cons
void SetNamedProperty(napi_env env, napi_value dstObj, const int32_t objValue, const char *propName)
{
HILOG_DEBUG("start");
TAG_LOGD(AAFwkTag::WANT, "start");
napi_value prop = nullptr;
napi_create_int32(env, objValue, &prop);
napi_set_named_property(env, dstObj, propName, prop);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Copyright (c) 2022-2024 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
@ -22,6 +22,7 @@
#include "napi/native_api.h"
#include "napi/native_node_api.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "js_runtime_utils.h"
@ -36,14 +37,14 @@ EXTERN_C_START
napi_value JsNapiWantAgentInit(napi_env env, napi_value exportObj)
{
HILOG_DEBUG("JsNapiWantAgentInit is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "JsNapiWantAgentInit is called");
if (env == nullptr || exportObj == nullptr) {
HILOG_ERROR("env or exportObj nullptr");
TAG_LOGE(AAFwkTag::WANTAGENT, "env or exportObj nullptr");
return nullptr;
}
if (!CheckTypeForNapiValue(env, exportObj, napi_object)) {
HILOG_ERROR("object nullptr");
TAG_LOGE(AAFwkTag::WANTAGENT, "object nullptr");
return nullptr;
}
@ -53,7 +54,7 @@ napi_value JsNapiWantAgentInit(napi_env env, napi_value exportObj)
napi_set_named_property(env, exportObj, "WantAgentFlags", WantAgentFlagsInit(env));
napi_set_named_property(env, exportObj, "OperationType", WantAgentOperationTypeInit(env));
HILOG_DEBUG("JsNapiWantAgentInit BindNativeFunction called");
TAG_LOGD(AAFwkTag::WANTAGENT, "JsNapiWantAgentInit BindNativeFunction called");
const char *moduleName = "JsWantAgent";
BindNativeFunction(env, exportObj, "equal", moduleName, JsWantAgent::Equal);
BindNativeFunction(env, exportObj, "getBundleName", moduleName, JsWantAgent::GetBundleName);
@ -63,7 +64,7 @@ napi_value JsNapiWantAgentInit(napi_env env, napi_value exportObj)
BindNativeFunction(env, exportObj, "getWant", moduleName, JsWantAgent::NapiGetWant);
BindNativeFunction(env, exportObj, "getWantAgent", moduleName, JsWantAgent::NapiGetWantAgent);
BindNativeFunction(env, exportObj, "getOperationType", moduleName, JsWantAgent::NapiGetOperationType);
HILOG_DEBUG("JsNapiWantAgentInit end");
TAG_LOGD(AAFwkTag::WANTAGENT, "JsNapiWantAgentInit end");
return exportObj;
}
EXTERN_C_END

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2021-2024 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
@ -21,6 +21,7 @@
#include <unistd.h>
#include "ability_runtime_error_util.h"
#include "hilog_tag_wrapper.h"
#include "hilog_wrapper.h"
#include "ipc_skeleton.h"
#include "js_runtime_utils.h"
@ -33,7 +34,7 @@ namespace OHOS {
#define NAPI_ASSERT_RETURN_NULL(env, assertion, message) \
do { \
if (!(assertion)) { \
HILOG_INFO(message); \
TAG_LOGI(AAFwkTag::WANTAGENT, message); \
return nullptr; \
} \
} while (0)
@ -69,9 +70,9 @@ void TriggerCompleteCallBack::SetWantAgentInstance(WantAgent* wantAgent)
napi_value RetErrMsg(napi_env env, napi_value lastParam, int32_t errorCode)
{
HILOG_DEBUG("RetErrMsg called");
TAG_LOGD(AAFwkTag::WANTAGENT, "RetErrMsg called");
auto complete = [err = errorCode] (napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("error information output");
TAG_LOGD(AAFwkTag::WANTAGENT, "error information output");
task.Reject(env, CreateJsError(env, err, "PARAMETER_ERROR"));
};
@ -84,7 +85,7 @@ napi_value RetErrMsg(napi_env env, napi_value lastParam, int32_t errorCode)
napi_value CreateErrorValue(napi_env env, int32_t errCode)
{
HILOG_INFO("enter, errorCode[%{public}d]", errCode);
TAG_LOGI(AAFwkTag::WANTAGENT, "enter, errorCode[%{public}d]", errCode);
napi_value error = NapiGetNull(env);
if (errCode == NO_ERROR) {
return error;
@ -104,22 +105,23 @@ napi_value CreateErrorValue(napi_env env, int32_t errCode)
void NapiThrow(napi_env env, int32_t errCode)
{
HILOG_INFO("enter");
TAG_LOGI(AAFwkTag::WANTAGENT, "enter");
napi_throw(env, CreateErrorValue(env, errCode));
}
auto OnSendFinishedUvAfterWorkCallback = [](uv_work_t* work, int status) {
HILOG_INFO("TriggerCompleteCallBack::OnSendFinishedUvAfterWorkCallback:status = %{public}d", status);
TAG_LOGI(AAFwkTag::WANTAGENT, "TriggerCompleteCallBack::OnSendFinishedUvAfterWorkCallback:status = %{public}d",
status);
TriggerReceiveDataWorker* dataWorkerData = static_cast<TriggerReceiveDataWorker *>(work->data);
if (dataWorkerData == nullptr) {
HILOG_ERROR("TriggerReceiveDataWorker instance(uv_work_t) is nullptr");
TAG_LOGE(AAFwkTag::WANTAGENT, "TriggerReceiveDataWorker instance(uv_work_t) is nullptr");
delete work;
return;
}
if (dataWorkerData->resultData == "canceled") {
HILOG_INFO("wantAgent is canceled");
TAG_LOGI(AAFwkTag::WANTAGENT, "wantAgent is canceled");
delete dataWorkerData;
dataWorkerData = nullptr;
delete work;
@ -129,7 +131,7 @@ auto OnSendFinishedUvAfterWorkCallback = [](uv_work_t* work, int status) {
napi_value objValueFirst = nullptr;
napi_create_object(dataWorkerData->env, &objValueFirst);
if (objValueFirst == nullptr) {
HILOG_ERROR("Failed to get objValueFirst");
TAG_LOGE(AAFwkTag::WANTAGENT, "Failed to get objValueFirst");
delete dataWorkerData;
dataWorkerData = nullptr;
delete work;
@ -138,7 +140,7 @@ auto OnSendFinishedUvAfterWorkCallback = [](uv_work_t* work, int status) {
napi_value objValueSecond = nullptr;
napi_create_object(dataWorkerData->env, &objValueSecond);
if (objValueSecond == nullptr) {
HILOG_ERROR("Failed to get objValueSecond");
TAG_LOGE(AAFwkTag::WANTAGENT, "Failed to get objValueSecond");
delete dataWorkerData;
dataWorkerData = nullptr;
delete work;
@ -175,9 +177,9 @@ auto OnSendFinishedUvAfterWorkCallback = [](uv_work_t* work, int status) {
void TriggerCompleteCallBack::OnSendFinished(
const AAFwk::Want &want, int resultCode, const std::string &resultData, const AAFwk::WantParams &resultExtras)
{
HILOG_INFO("TriggerCompleteCallBack::OnSendFinished start");
TAG_LOGI(AAFwkTag::WANTAGENT, "TriggerCompleteCallBack::OnSendFinished start");
if (triggerCompleteInfo_.nativeRef == nullptr) {
HILOG_INFO("triggerCompleteInfo_ CallBack is nullptr");
TAG_LOGI(AAFwkTag::WANTAGENT, "triggerCompleteInfo_ CallBack is nullptr");
return;
}
@ -186,18 +188,18 @@ void TriggerCompleteCallBack::OnSendFinished(
napi_get_uv_event_loop(triggerCompleteInfo_.env, &loop);
#endif // NAPI_VERSION >= 2
if (loop == nullptr) {
HILOG_INFO("loop instance is nullptr");
TAG_LOGI(AAFwkTag::WANTAGENT, "loop instance is nullptr");
return;
}
uv_work_t* work = new (std::nothrow) uv_work_t;
if (work == nullptr) {
HILOG_INFO("uv_work_t instance is nullptr");
TAG_LOGI(AAFwkTag::WANTAGENT, "uv_work_t instance is nullptr");
return;
}
TriggerReceiveDataWorker* dataWorker = new (std::nothrow) TriggerReceiveDataWorker();
if (dataWorker == nullptr) {
HILOG_INFO("TriggerReceiveDataWorker instance is nullptr");
TAG_LOGI(AAFwkTag::WANTAGENT, "TriggerReceiveDataWorker instance is nullptr");
delete work;
work = nullptr;
return;
@ -218,12 +220,12 @@ void TriggerCompleteCallBack::OnSendFinished(
work = nullptr;
}
HILOG_INFO("TriggerCompleteCallBack::OnSendFinished end");
TAG_LOGI(AAFwkTag::WANTAGENT, "TriggerCompleteCallBack::OnSendFinished end");
}
void JsWantAgent::Finalizer(napi_env env, void* data, void* hint)
{
HILOG_INFO("JsWantAgent::Finalizer is called");
TAG_LOGI(AAFwkTag::WANTAGENT, "JsWantAgent::Finalizer is called");
std::unique_ptr<JsWantAgent>(static_cast<JsWantAgent*>(data));
}
@ -304,12 +306,12 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
HILOG_DEBUG("enter, argc = %{public}d", static_cast<int32_t>(argc));
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
int32_t errCode = BUSINESS_ERROR_CODE_OK;
WantAgent* pWantAgentFirst = nullptr;
WantAgent* pWantAgentSecond = nullptr;
if (argc < ARGC_TWO || argc > ARGC_THREE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
#endif
@ -318,7 +320,7 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
napi_value lastParam = (argc >= ARGC_THREE) ? argv[INDEX_TWO] : nullptr;
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
#ifdef ENABLE_ERRCODE
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
AbilityRuntimeErrorUtil::Throw(env, errCode);
@ -331,7 +333,7 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgentFirst));
if (pWantAgentFirst == nullptr) {
HILOG_ERROR("Parse pWantAgentFirst failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgentFirst failed");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
@ -342,7 +344,7 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
}
if (!CheckTypeForNapiValue(env, argv[1], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
@ -354,7 +356,7 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
UnwrapWantAgent(env, argv[1], reinterpret_cast<void **>(&pWantAgentSecond));
if (pWantAgentSecond == nullptr) {
HILOG_ERROR("Parse pWantAgentSceond failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgentSceond failed");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
@ -368,7 +370,7 @@ napi_value JsWantAgent::OnEqual(napi_env env, napi_callback_info info)
std::shared_ptr<WantAgent> wantAgentSecond = std::make_shared<WantAgent>(*pWantAgentSecond);
NapiAsyncTask::CompleteCallback complete =
[wantAgentFirst, wantAgentSecond](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnEqual NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnEqual NapiAsyncTask is called");
bool ret = false;
ErrCode retCode = WantAgentHelper::IsEquals(wantAgentFirst, wantAgentSecond);
#ifdef ENABLE_ERRCODE
@ -403,31 +405,31 @@ napi_value JsWantAgent::OnGetWant(napi_env env, napi_callback_info info)
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
HILOG_DEBUG("enter, argc = %{public}d", static_cast<int32_t>(argc));
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
int32_t errCode = BUSINESS_ERROR_CODE_OK;
WantAgent* pWantAgent = nullptr;
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough arguments");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough arguments");
return CreateJsUndefined(env);
}
napi_value lastParam = (argc >= ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong parameter type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong parameter type. Object expected.");
errCode = ERR_NOT_OK;
return RetErrMsg(env, lastParam, errCode);
}
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent error");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent error");
errCode = ERR_NOT_OK;
return RetErrMsg(env, lastParam, errCode);
}
std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(*pWantAgent);
NapiAsyncTask::CompleteCallback complete = [wantAgent](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnGetWant NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnGetWant NapiAsyncTask is called");
std::shared_ptr<Want> want = WantAgentHelper::GetWant(wantAgent);
if (want == nullptr) {
task.Reject(env, CreateJsError(env, ERR_NOT_OK, "WantAgentHelper::GetWant result nullptr."));
@ -447,31 +449,32 @@ napi_value JsWantAgent::OnGetOperationType(napi_env env, napi_callback_info info
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
HILOG_DEBUG("JsWantAgent::OnGetOperationType enter, argc = %{public}d", static_cast<int32_t>(argc));
TAG_LOGD(AAFwkTag::WANTAGENT, "JsWantAgent::OnGetOperationType enter, argc = %{public}d",
static_cast<int32_t>(argc));
int32_t errCode = BUSINESS_ERROR_CODE_OK;
WantAgent* pWantAgent = nullptr;
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
return CreateJsUndefined(env);
}
napi_value lastParam = (argc >= ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
errCode = ERR_NOT_OK;
return RetErrMsg(env, lastParam, errCode);
}
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
errCode = ERR_NOT_OK;
return RetErrMsg(env, lastParam, errCode);
}
std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(*pWantAgent);
NapiAsyncTask::CompleteCallback complete = [wantAgent](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnGetOperationType NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnGetOperationType NapiAsyncTask is called");
auto ret = WantAgentHelper::GetType(wantAgent);
task.Resolve(env, CreateJsValue(env, ret));
};
@ -484,14 +487,14 @@ napi_value JsWantAgent::OnGetOperationType(napi_env env, napi_callback_info info
napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
{
HILOG_INFO("called.");
TAG_LOGI(AAFwkTag::WANTAGENT, "called.");
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
int32_t errCode = BUSINESS_ERROR_CODE_OK;
WantAgent* pWantAgent = nullptr;
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
#endif
@ -500,7 +503,7 @@ napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
napi_value lastParam = (argc >= ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
@ -512,7 +515,7 @@ napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
#ifdef ENABLE_ERRCODE
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
AbilityRuntimeErrorUtil::Throw(env, errCode);
@ -525,7 +528,7 @@ napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(*pWantAgent);
NapiAsyncTask::CompleteCallback complete = [wantAgent](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnGetBundleName NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnGetBundleName NapiAsyncTask is called");
std::string bundleName = "";
#ifdef ENABLE_ERRCODE
ErrCode result = WantAgentHelper::GetBundleName(wantAgent, bundleName);
@ -548,14 +551,14 @@ napi_value JsWantAgent::OnGetBundleName(napi_env env, napi_callback_info info)
napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
{
HILOG_INFO("called.");
TAG_LOGI(AAFwkTag::WANTAGENT, "called.");
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
int32_t errCode = BUSINESS_ERROR_CODE_OK;
WantAgent* pWantAgent = nullptr;
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
#ifdef ENABLE_ERRCODE
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
AbilityRuntimeErrorUtil::Throw(env, errCode);
@ -565,7 +568,7 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
napi_value lastParam = (argc >= ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
#ifdef ENABLE_ERRCODE
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
AbilityRuntimeErrorUtil::Throw(env, errCode);
@ -578,7 +581,7 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent error");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent error");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
@ -590,7 +593,7 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(*pWantAgent);
NapiAsyncTask::CompleteCallback complete = [wantAgent](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnGetUid NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnGetUid NapiAsyncTask is called");
int uid = -1;
#ifdef ENABLE_ERRCODE
ErrCode result = WantAgentHelper::GetUid(wantAgent, uid);
@ -612,14 +615,14 @@ napi_value JsWantAgent::OnGetUid(napi_env env, napi_callback_info info)
napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
{
HILOG_DEBUG("%{public}s is called", __FUNCTION__);
TAG_LOGD(AAFwkTag::WANTAGENT, "%{public}s is called", __FUNCTION__);
int32_t errCode = BUSINESS_ERROR_CODE_OK;
WantAgent* pWantAgent = nullptr;
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
#endif
@ -628,7 +631,7 @@ napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
napi_value lastParam = (argc >= ARGC_TWO) ? argv[INDEX_ONE] : nullptr;
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
#ifdef ENABLE_ERRCODE
errCode = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
AbilityRuntimeErrorUtil::Throw(env, errCode);
@ -641,7 +644,7 @@ napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
#ifdef ENABLE_ERRCODE
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
@ -654,7 +657,7 @@ napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(*pWantAgent);
NapiAsyncTask::CompleteCallback complete =
[wantAgent](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnCancel NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnCancel NapiAsyncTask is called");
#ifdef ENABLE_ERRCODE
ErrCode result = WantAgentHelper::Cancel(wantAgent);
if (result != NO_ERROR) {
@ -676,12 +679,12 @@ napi_value JsWantAgent::OnCancel(napi_env env, napi_callback_info info)
napi_value JsWantAgent::OnTrigger(napi_env env, napi_callback_info info)
{
HILOG_DEBUG("%{public}s is called", __FUNCTION__);
TAG_LOGD(AAFwkTag::WANTAGENT, "%{public}s is called", __FUNCTION__);
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != ARGC_THREE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
return CreateJsUndefined(env);
}
@ -705,26 +708,26 @@ int32_t JsWantAgent::UnWrapTriggerInfoParam(napi_env env, napi_callback_info inf
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != ARGC_THREE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
return ERR_NOT_OK;
}
if (!CheckTypeForNapiValue(env, argv[ARGC_ZERO], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
return ERR_NOT_OK;
}
WantAgent* pWantAgent = nullptr;
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
return ERR_NOT_OK;
}
wantAgent = std::make_shared<WantAgent>(*pWantAgent);
int32_t ret = GetTriggerInfo(env, argv[ARGC_ONE], triggerInfo);
if (ret != BUSINESS_ERROR_CODE_OK) {
HILOG_ERROR("Get trigger info error");
TAG_LOGE(AAFwkTag::WANTAGENT, "Get trigger info error");
return ret;
}
@ -738,9 +741,9 @@ int32_t JsWantAgent::UnWrapTriggerInfoParam(napi_env env, napi_callback_info inf
int32_t JsWantAgent::GetTriggerInfo(napi_env env, napi_value param, TriggerInfo &triggerInfo)
{
HILOG_DEBUG("GetTriggerInfo called.");
TAG_LOGD(AAFwkTag::WANTAGENT, "GetTriggerInfo called.");
if (!CheckTypeForNapiValue(env, param, napi_object)) {
HILOG_ERROR("param type mismatch!");
TAG_LOGE(AAFwkTag::WANTAGENT, "param type mismatch!");
return ERR_NOT_OK;
}
@ -748,7 +751,7 @@ int32_t JsWantAgent::GetTriggerInfo(napi_env env, napi_value param, TriggerInfo
napi_value jsCode = nullptr;
napi_get_named_property(env, param, "code", &jsCode);
if (!ConvertFromJsValue(env, jsCode, code)) {
HILOG_ERROR("GetTriggerInfo convert code error!");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetTriggerInfo convert code error!");
return ERR_NOT_OK;
}
@ -760,7 +763,7 @@ int32_t JsWantAgent::GetTriggerInfo(napi_env env, napi_value param, TriggerInfo
napi_get_named_property(env, param, "want", &jsWant);
want = std::make_shared<AAFwk::Want>();
if (!UnwrapWant(env, jsWant, *want)) {
HILOG_ERROR("GetTriggerInfo convert want error!");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetTriggerInfo convert want error!");
return ERR_NOT_OK;
}
}
@ -772,7 +775,7 @@ int32_t JsWantAgent::GetTriggerInfo(napi_env env, napi_value param, TriggerInfo
napi_value jsPermission = nullptr;
napi_get_named_property(env, param, "permission", &jsPermission);
if (!ConvertFromJsValue(env, jsPermission, permission)) {
HILOG_ERROR("GetTriggerInfo convert permission error!");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetTriggerInfo convert permission error!");
return ERR_NOT_OK;
}
}
@ -793,7 +796,7 @@ int32_t JsWantAgent::GetTriggerInfo(napi_env env, napi_value param, TriggerInfo
extraInfo = std::make_shared<AAFwk::WantParams>();
if (!UnwrapWantParams(env, (jsExtraInfo),
*extraInfo)) {
HILOG_ERROR("GetTriggerInfo convert extraInfo error!");
TAG_LOGE(AAFwkTag::WANTAGENT, "GetTriggerInfo convert extraInfo error!");
return ERR_NOT_OK;
}
}
@ -805,12 +808,12 @@ int32_t JsWantAgent::GetTriggerInfo(napi_env env, napi_value param, TriggerInfo
int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, WantAgentWantsParas &paras)
{
HILOG_DEBUG("GetWantAgentParam called.");
TAG_LOGD(AAFwkTag::WANTAGENT, "GetWantAgentParam called.");
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("param type mismatch!");
TAG_LOGE(AAFwkTag::WANTAGENT, "param type mismatch!");
return PARAMETER_ERROR;
}
@ -820,7 +823,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
bool isArray = false;
napi_is_array(env, jsWants, &isArray);
if (!isArray) {
HILOG_ERROR("wants is not array!");
TAG_LOGE(AAFwkTag::WANTAGENT, "wants is not array!");
return PARAMETER_ERROR;
}
@ -831,7 +834,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
napi_value jsWant = nullptr;
napi_get_element(env, jsWants, i, &jsWant);
if (!UnwrapWant(env, jsWant, *want)) {
HILOG_ERROR("UnwrapWant failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "UnwrapWant failed!");
return PARAMETER_ERROR;
}
paras.wants.emplace_back(want);
@ -843,7 +846,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
napi_value jsActionType = nullptr;
napi_get_named_property(env, argv[0], "actionType", &jsActionType);
if (!ConvertFromJsValue(env, jsActionType, paras.operationType)) {
HILOG_ERROR("Convert actionType failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "Convert actionType failed!");
return PARAMETER_ERROR;
}
}
@ -854,7 +857,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
napi_value jsOperationType = nullptr;
napi_get_named_property(env, argv[0], "operationType", &jsOperationType);
if (!ConvertFromJsValue(env, jsOperationType, paras.operationType)) {
HILOG_ERROR("Convert operationType failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "Convert operationType failed!");
return PARAMETER_ERROR;
}
}
@ -862,7 +865,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
napi_value jsRequestCode = nullptr;
napi_get_named_property(env, argv[0], "requestCode", &jsRequestCode);
if (!ConvertFromJsValue(env, jsRequestCode, paras.requestCode)) {
HILOG_ERROR("Convert requestCode failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "Convert requestCode failed!");
return PARAMETER_ERROR;
}
@ -874,7 +877,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
bool jsActionFlagsIsArray = false;
napi_is_array(env, jsActionFlags, &jsActionFlagsIsArray);
if (!jsActionFlagsIsArray) {
HILOG_ERROR("actionFlags is not array!");
TAG_LOGE(AAFwkTag::WANTAGENT, "actionFlags is not array!");
return PARAMETER_ERROR;
}
@ -884,12 +887,12 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
napi_value jsActionFlag = nullptr;
napi_get_element(env, jsActionFlags, i, &jsActionFlag);
if (!CheckTypeForNapiValue(env, jsActionFlag, napi_number)) {
HILOG_ERROR("ActionFlag type error!");
TAG_LOGE(AAFwkTag::WANTAGENT, "ActionFlag type error!");
return PARAMETER_ERROR;
}
int32_t actionFlag = 0;
if (!ConvertFromJsValue(env, jsActionFlag, actionFlag)) {
HILOG_ERROR("Convert actionFlag failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "Convert actionFlag failed!");
return PARAMETER_ERROR;
}
paras.wantAgentFlags.emplace_back(static_cast<WantAgentConstant::Flags>(actionFlag));
@ -904,7 +907,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
bool jsWantAgentFlagsIsArray = false;
napi_is_array(env, jsWantAgentFlags, &jsWantAgentFlagsIsArray);
if (!jsWantAgentFlagsIsArray) {
HILOG_ERROR("wantAgentFlags is not array!");
TAG_LOGE(AAFwkTag::WANTAGENT, "wantAgentFlags is not array!");
return PARAMETER_ERROR;
}
@ -914,12 +917,12 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
napi_value jsWantAgentFlag = nullptr;
napi_get_element(env, jsWantAgentFlags, i, &jsWantAgentFlag);
if (!CheckTypeForNapiValue(env, jsWantAgentFlag, napi_number)) {
HILOG_ERROR("WantAgentFlag type failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "WantAgentFlag type failed!");
return PARAMETER_ERROR;
}
int32_t wantAgentFlag = 0;
if (!ConvertFromJsValue(env, jsWantAgentFlag, wantAgentFlag)) {
HILOG_ERROR("Convert WantAgentFlag failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "Convert WantAgentFlag failed!");
return PARAMETER_ERROR;
}
paras.wantAgentFlags.emplace_back(static_cast<WantAgentConstant::Flags>(wantAgentFlag));
@ -939,12 +942,12 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
}
if (hasExtraInfo) {
if (!CheckTypeForNapiValue(env, jsExtraInfo, napi_object)) {
HILOG_ERROR("ExtraInfo type error!");
TAG_LOGE(AAFwkTag::WANTAGENT, "ExtraInfo type error!");
return PARAMETER_ERROR;
}
if (!UnwrapWantParams(env, (jsExtraInfo),
paras.extraInfo)) {
HILOG_ERROR("Convert extraInfo failed!");
TAG_LOGE(AAFwkTag::WANTAGENT, "Convert extraInfo failed!");
return PARAMETER_ERROR;
}
}
@ -953,7 +956,7 @@ int32_t JsWantAgent::GetWantAgentParam(napi_env env, napi_callback_info info, Wa
napi_value JsWantAgent::WrapWantAgent(napi_env env, WantAgent* wantAgent)
{
HILOG_DEBUG("WrapWantAgent called.");
TAG_LOGD(AAFwkTag::WANTAGENT, "WrapWantAgent called.");
napi_value wantAgentClass = nullptr;
napi_define_class(
env,
@ -971,7 +974,7 @@ napi_value JsWantAgent::WrapWantAgent(napi_env env, WantAgent* wantAgent)
napi_value result = nullptr;
napi_new_instance(env, wantAgentClass, 0, nullptr, &result);
if (result == nullptr) {
HILOG_ERROR("create instance failed.");
TAG_LOGE(AAFwkTag::WANTAGENT, "create instance failed.");
delete wantAgent;
wantAgent = nullptr;
return nullptr;
@ -981,7 +984,7 @@ napi_value JsWantAgent::WrapWantAgent(napi_env env, WantAgent* wantAgent)
result,
reinterpret_cast<void*>(wantAgent),
[](napi_env env, void* data, void* hint) {
HILOG_DEBUG("delete wantAgent.");
TAG_LOGD(AAFwkTag::WANTAGENT, "delete wantAgent.");
auto agent = static_cast<WantAgent*>(data);
delete agent;
agent = nullptr;
@ -993,14 +996,14 @@ napi_value JsWantAgent::WrapWantAgent(napi_env env, WantAgent* wantAgent)
void JsWantAgent::UnwrapWantAgent(napi_env env, napi_value jsParam, void** result)
{
HILOG_DEBUG("UnwrapWantAgent called.");
TAG_LOGD(AAFwkTag::WANTAGENT, "UnwrapWantAgent called.");
if (jsParam == nullptr) {
HILOG_ERROR("UnwrapWantAgent jsParam is nullptr!");
TAG_LOGE(AAFwkTag::WANTAGENT, "UnwrapWantAgent jsParam is nullptr!");
return;
}
if (!CheckTypeForNapiValue(env, jsParam, napi_object)) {
HILOG_ERROR("UnwrapWantAgent jsParam type error!");
TAG_LOGE(AAFwkTag::WANTAGENT, "UnwrapWantAgent jsParam type error!");
return;
}
@ -1012,9 +1015,9 @@ napi_value JsWantAgent::OnGetWantAgent(napi_env env, napi_callback_info info)
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
HILOG_DEBUG("enter, argc = %{public}d", static_cast<int32_t>(argc));
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
return CreateJsUndefined(env);
}
@ -1022,13 +1025,13 @@ napi_value JsWantAgent::OnGetWantAgent(napi_env env, napi_callback_info info)
std::shared_ptr<WantAgentWantsParas> spParas = std::make_shared<WantAgentWantsParas>();
int32_t ret = GetWantAgentParam(env, info, *spParas);
if (ret != 0) {
HILOG_ERROR("Failed to get wantAgent parameter.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Failed to get wantAgent parameter.");
return RetErrMsg(env, lastParam, ret);
}
NapiAsyncTask::CompleteCallback complete = [weak = weak_from_this(), parasobj = spParas](napi_env env,
NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnGetWantAgent NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnGetWantAgent NapiAsyncTask is called");
auto self = weak.lock();
std::shared_ptr<AAFwk::WantParams> extraInfo = std::make_shared<AAFwk::WantParams>(parasobj->extraInfo);
WantAgentInfo wantAgentInfo(parasobj->requestCode,
@ -1042,13 +1045,13 @@ napi_value JsWantAgent::OnGetWantAgent(napi_env env, napi_callback_info info)
WantAgentHelper::GetWantAgent(context, wantAgentInfo, wantAgent);
WantAgent* pWantAgent = nullptr;
if (wantAgent == nullptr) {
HILOG_INFO("wantAgent is nullptr...");
TAG_LOGI(AAFwkTag::WANTAGENT, "wantAgent is nullptr...");
} else {
pWantAgent = new WantAgent(wantAgent->GetPendingWant());
}
if (pWantAgent == nullptr) {
HILOG_INFO("pWantAgent is nullptr...");
TAG_LOGI(AAFwkTag::WANTAGENT, "pWantAgent is nullptr...");
}
task.Resolve(env, self->WrapWantAgent(env, pWantAgent));
};
@ -1064,36 +1067,36 @@ napi_value JsWantAgent::OnNapiGetWant(napi_env env, napi_callback_info info)
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
HILOG_DEBUG("enter, argc = %{public}d", static_cast<int32_t>(argc));
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
WantAgent* pWantAgent = nullptr;
auto selfToken = IPCSkeleton::GetSelfTokenID();
if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) {
HILOG_ERROR("This application is not system-app, can not use system-api");
TAG_LOGE(AAFwkTag::WANTAGENT, "This application is not system-app, can not use system-api");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_NOT_SYSTEM_APP);
return CreateJsUndefined(env);
}
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(*pWantAgent);
NapiAsyncTask::CompleteCallback complete = [wantAgent](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnNapiGetWant NapiAsyncTask is start");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnNapiGetWant NapiAsyncTask is start");
std::shared_ptr<Want> want = std::make_shared<Want>();
ErrCode result = WantAgentHelper::GetWant(wantAgent, want);
if (result != NO_ERROR) {
@ -1111,12 +1114,12 @@ napi_value JsWantAgent::OnNapiGetWant(napi_env env, napi_callback_info info)
napi_value JsWantAgent::OnNapiTrigger(napi_env env, napi_callback_info info)
{
HILOG_INFO("called.");
TAG_LOGI(AAFwkTag::WANTAGENT, "called.");
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (argc != ARGC_THREE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -1141,9 +1144,9 @@ napi_value JsWantAgent::OnNapiGetWantAgent(napi_env env, napi_callback_info info
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
HILOG_DEBUG("enter, argc = %{public}d", static_cast<int32_t>(argc));
TAG_LOGD(AAFwkTag::WANTAGENT, "enter, argc = %{public}d", static_cast<int32_t>(argc));
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -1151,14 +1154,14 @@ napi_value JsWantAgent::OnNapiGetWantAgent(napi_env env, napi_callback_info info
std::shared_ptr<WantAgentWantsParas> spParas = std::make_shared<WantAgentWantsParas>();
int32_t ret = GetWantAgentParam(env, info, *spParas);
if (ret != 0) {
HILOG_ERROR("Failed to get wantAgent param.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Failed to get wantAgent param.");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
NapiAsyncTask::CompleteCallback complete = [weak = weak_from_this(), parasobj = spParas](napi_env env,
NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnNapiGetWantAgent NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnNapiGetWantAgent NapiAsyncTask is called");
auto self = weak.lock();
std::shared_ptr<AAFwk::WantParams> extraInfo = std::make_shared<AAFwk::WantParams>(parasobj->extraInfo);
WantAgentInfo wantAgentInfo(parasobj->requestCode,
@ -1183,7 +1186,7 @@ napi_value JsWantAgent::OnNapiGetWantAgent(napi_env env, napi_callback_info info
}
if (pWantAgent == nullptr) {
HILOG_ERROR("pWantAgent is nullptr...");
TAG_LOGE(AAFwkTag::WANTAGENT, "pWantAgent is nullptr...");
result = ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER;
task.Reject(env, CreateJsError(env, result, AbilityRuntimeErrorUtil::GetErrMessage(result)));
} else {
@ -1201,19 +1204,19 @@ napi_value JsWantAgent::OnNapiGetWantAgent(napi_env env, napi_callback_info info
napi_value JsWantAgent::OnNapiGetOperationType(napi_env env, napi_callback_info info)
{
HILOG_INFO("called.");
TAG_LOGI(AAFwkTag::WANTAGENT, "called.");
size_t argc = ARGS_MAX_COUNT;
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
WantAgent* pWantAgent = nullptr;
if (argc > ARGC_TWO || argc < ARGC_ONE) {
HILOG_ERROR("Not enough params");
TAG_LOGE(AAFwkTag::WANTAGENT, "Not enough params");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
if (!CheckTypeForNapiValue(env, argv[0], napi_object)) {
HILOG_ERROR("Wrong argument type. Object expected.");
TAG_LOGE(AAFwkTag::WANTAGENT, "Wrong argument type. Object expected.");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
@ -1221,14 +1224,14 @@ napi_value JsWantAgent::OnNapiGetOperationType(napi_env env, napi_callback_info
UnwrapWantAgent(env, argv[0], reinterpret_cast<void **>(&pWantAgent));
if (pWantAgent == nullptr) {
HILOG_ERROR("Parse pWantAgent failed");
TAG_LOGE(AAFwkTag::WANTAGENT, "Parse pWantAgent failed");
AbilityRuntimeErrorUtil::Throw(env, ERR_ABILITY_RUNTIME_EXTERNAL_INVALID_PARAMETER);
return CreateJsUndefined(env);
}
std::shared_ptr<WantAgent> wantAgent = std::make_shared<WantAgent>(*pWantAgent);
NapiAsyncTask::CompleteCallback complete = [wantAgent](napi_env env, NapiAsyncTask &task, int32_t status) {
HILOG_DEBUG("OnNapiGetOperationType NapiAsyncTask is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "OnNapiGetOperationType NapiAsyncTask is called");
int32_t operType;
ErrCode ret = WantAgentHelper::GetType(wantAgent, operType);
if (ret != NO_ERROR) {
@ -1247,10 +1250,10 @@ napi_value JsWantAgent::OnNapiGetOperationType(napi_env env, napi_callback_info
napi_value WantAgentFlagsInit(napi_env env)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::WANTAGENT, "called");
if (env == nullptr) {
HILOG_ERROR("Invalid input parameters");
TAG_LOGE(AAFwkTag::WANTAGENT, "Invalid input parameters");
return nullptr;
}
@ -1283,10 +1286,10 @@ napi_value WantAgentFlagsInit(napi_env env)
napi_value WantAgentOperationTypeInit(napi_env env)
{
HILOG_DEBUG("called");
TAG_LOGD(AAFwkTag::WANTAGENT, "called");
if (env == nullptr) {
HILOG_ERROR("Invalid input parameters");
TAG_LOGE(AAFwkTag::WANTAGENT, "Invalid input parameters");
return nullptr;
}
@ -1311,10 +1314,10 @@ napi_value WantAgentOperationTypeInit(napi_env env)
napi_value JsWantAgentInit(napi_env env, napi_value exportObj)
{
HILOG_DEBUG("JsWantAgentInit is called");
TAG_LOGD(AAFwkTag::WANTAGENT, "JsWantAgentInit is called");
if (env == nullptr || exportObj == nullptr) {
HILOG_ERROR("env or exportObj null.");
TAG_LOGE(AAFwkTag::WANTAGENT, "env or exportObj null.");
return nullptr;
}
@ -1324,7 +1327,7 @@ napi_value JsWantAgentInit(napi_env env, napi_value exportObj)
napi_set_named_property(env, exportObj, "WantAgentFlags", WantAgentFlagsInit(env));
napi_set_named_property(env, exportObj, "OperationType", WantAgentOperationTypeInit(env));
HILOG_DEBUG("JsWantAgentInit BindNativeFunction called");
TAG_LOGD(AAFwkTag::WANTAGENT, "JsWantAgentInit BindNativeFunction called");
const char* moduleName = "JsWantAgent";
BindNativeFunction(env, exportObj, "equal", moduleName, JsWantAgent::Equal);
BindNativeFunction(env, exportObj, "getWant", moduleName, JsWantAgent::GetWant);
@ -1334,7 +1337,7 @@ napi_value JsWantAgentInit(napi_env env, napi_value exportObj)
BindNativeFunction(env, exportObj, "cancel", moduleName, JsWantAgent::Cancel);
BindNativeFunction(env, exportObj, "trigger", moduleName, JsWantAgent::Trigger);
BindNativeFunction(env, exportObj, "getWantAgent", moduleName, JsWantAgent::GetWantAgent);
HILOG_DEBUG("JsWantAgentInit end");
TAG_LOGD(AAFwkTag::WANTAGENT, "JsWantAgentInit end");
return CreateJsUndefined(env);
}