diff --git a/ability_runtime.gni b/ability_runtime.gni index 4858303cf6..9e2a8a52ed 100644 --- a/ability_runtime.gni +++ b/ability_runtime.gni @@ -93,7 +93,7 @@ declare_args() { background_task_mgr_continuous_task_enable = true resource_schedule_service_enable = true ability_runtime_power = true - ability_runtime_feature_sandboxmanager = true + ability_runtime_feature_sandboxmanager = false ability_runtime_relational = true ability_runtime_ces = true ability_runtime_resource = true @@ -183,4 +183,9 @@ declare_args() { } else { form_fwk_enable = false } + + if (defined(global_parts_info) && + defined(global_parts_info.accesscontrol_sandbox_manager)) { + ability_runtime_feature_sandboxmanager = true + } } diff --git a/bundle.json b/bundle.json index 684d70d648..78357e24b1 100644 --- a/bundle.json +++ b/bundle.json @@ -57,6 +57,7 @@ "ets_runtime", "ets_utils", "faultloggerd", + "app_file_service", "ffrt", "form_fwk", "graphic_2d", @@ -87,8 +88,8 @@ "resource_management", "resource_schedule_service", "safwk", - "sandbox_manager", "samgr", + "sandbox_manager", "screenlock_mgr", "storage_service", "toolchain", diff --git a/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_callback.cpp b/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_callback.cpp index 6bef7d671a..ba1ccc7329 100644 --- a/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_callback.cpp +++ b/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_callback.cpp @@ -32,23 +32,23 @@ JsAbilityAutoStartupCallBack::~JsAbilityAutoStartupCallBack() {} void JsAbilityAutoStartupCallBack::OnAutoStartupOn(const AutoStartupInfo &info) { - TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called."); + TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); JSCallFunction(info, METHOD_ON); } void JsAbilityAutoStartupCallBack::OnAutoStartupOff(const AutoStartupInfo &info) { - TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called."); + TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); JSCallFunction(info, METHOD_OFF); } void JsAbilityAutoStartupCallBack::Register(napi_value value) { - TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called."); + TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); std::lock_guard lock(mutexlock_); for (const auto &callback : callbacks_) { if (IsJsCallbackEquals(callback, value)) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The current callback already exists."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "callback exist"); return; } } @@ -60,12 +60,12 @@ void JsAbilityAutoStartupCallBack::Register(napi_value value) void JsAbilityAutoStartupCallBack::UnRegister(napi_value value) { - TAG_LOGD(AAFwkTag::AUTO_STARTUP, "Called."); + TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); napi_valuetype type = napi_undefined; napi_typeof(env_, value, &type); std::lock_guard lock(mutexlock_); if (type == napi_undefined || type == napi_null) { - TAG_LOGD(AAFwkTag::AUTO_STARTUP, "jsCallback is nullptr, delete all callback."); + TAG_LOGD(AAFwkTag::AUTO_STARTUP, "invalid callback, clear all callback"); callbacks_.clear(); return; } @@ -91,7 +91,7 @@ void JsAbilityAutoStartupCallBack::JSCallFunction(const AutoStartupInfo &info, c napi_env env, NapiAsyncTask &task, int32_t status) { sptr obj = stub.promote(); if (obj == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Callback object is nullptr"); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null obj"); return; } @@ -107,19 +107,19 @@ void JsAbilityAutoStartupCallBack::JSCallFunctionWorker(const AutoStartupInfo &i std::lock_guard lock(mutexlock_); for (auto callback : callbacks_) { if (callback == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "callback is nullptr."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null callback"); continue; } auto obj = callback->GetNapiValue(); if (obj == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get value."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null obj"); continue; } napi_value funcObject; if (napi_get_named_property(env_, obj, methodName.c_str(), &funcObject) != napi_ok) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Get function by name failed."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "get func failed"); continue; } @@ -132,19 +132,19 @@ bool JsAbilityAutoStartupCallBack::IsJsCallbackEquals(const std::shared_ptrGetNapiValue(); if (object == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to get object."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null object"); return false; } bool result = false; if (napi_strict_equals(env_, object, value, &result) != napi_ok) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Object does not match value."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "objects not match"); return false; } diff --git a/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp b/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp index 523c73494d..6781cb86c2 100644 --- a/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp +++ b/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp @@ -24,23 +24,23 @@ namespace AbilityRuntime { bool UnwrapAutoStartupInfo(napi_env env, napi_value param, AutoStartupInfo &info) { if (!IsNormalObject(env, param)) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid param"); return false; } if (!AppExecFwk::UnwrapStringByPropertyName(env, param, "bundleName", info.bundleName)) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert bundle name failed."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "convert bundleName failed"); return false; } if (!AppExecFwk::UnwrapStringByPropertyName(env, param, "abilityName", info.abilityName)) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert ability name failed."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "convert abilityName failed"); return false; } if (AppExecFwk::IsExistsByPropertyName(env, param, "appCloneIndex")) { if (!AppExecFwk::UnwrapInt32ByPropertyName(env, param, "appCloneIndex", info.appCloneIndex)) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert appCloneIndex failed."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "convert appCloneIndex failed"); return false; } } @@ -52,17 +52,17 @@ bool UnwrapAutoStartupInfo(napi_env env, napi_value param, AutoStartupInfo &info bool IsNormalObject(napi_env env, napi_value value) { if (value == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "value is nullptr."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null value"); return false; } napi_valuetype type; napi_typeof(env, value, &type); if (type == napi_undefined || type == napi_null) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "value is invalid type."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid type"); return false; } if (type != napi_object) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Invalid type."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid type"); return false; } return true; @@ -76,12 +76,12 @@ napi_value CreateJsAutoStartupInfoArray(napi_env env, const std::vector= 0 && info.appCloneIndex < GlobalConstant::MAX_APP_CLONE_INDEX) { napi_value appCloneIndex = AppExecFwk::WrapInt32ToJS(env, info.appCloneIndex); if (appCloneIndex == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert ability type name failed."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null appCloneIndex"); return nullptr; } if (!AppExecFwk::SetPropertyValueByPropertyName(env, object, "appCloneIndex", appCloneIndex)) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Create js AutoStartupInfo failed."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "create js AutoStartupInfo failed"); return nullptr; } } diff --git a/frameworks/js/napi/ability_auto_startup_manager/js_ability_auto_startup_manager.cpp b/frameworks/js/napi/ability_auto_startup_manager/js_ability_auto_startup_manager.cpp index 1ee8f3b4c7..6436adb8e3 100644 --- a/frameworks/js/napi/ability_auto_startup_manager/js_ability_auto_startup_manager.cpp +++ b/frameworks/js/napi/ability_auto_startup_manager/js_ability_auto_startup_manager.cpp @@ -73,7 +73,7 @@ bool JsAbilityAutoStartupManager::CheckCallerIsSystemApp() { auto selfToken = IPCSkeleton::GetSelfTokenID(); if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Current app is not system app, not allow."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "not system app"); return false; } return true; @@ -83,20 +83,20 @@ napi_value JsAbilityAutoStartupManager::OnRegisterAutoStartupCallback(napi_env e { TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } std::string type; if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], type) || type != ON_OFF_TYPE_SYSTEM) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid param"); ThrowError(env, INVALID_PARAM, "Parameter error. Convert type fail."); return CreateJsUndefined(env); } if (!CheckCallerIsSystemApp()) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Current app is not system app"); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "not system app"); ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP); return CreateJsUndefined(env); } @@ -104,7 +104,7 @@ napi_value JsAbilityAutoStartupManager::OnRegisterAutoStartupCallback(napi_env e if (jsAutoStartupCallback_ == nullptr) { jsAutoStartupCallback_ = new (std::nothrow) JsAbilityAutoStartupCallBack(env); if (jsAutoStartupCallback_ == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "JsAutoStartupCallback_ is nullptr."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null jsAutoStartupCallback_"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } @@ -113,7 +113,7 @@ napi_value JsAbilityAutoStartupManager::OnRegisterAutoStartupCallback(napi_env e AbilityManagerClient::GetInstance()->RegisterAutoStartupSystemCallback(jsAutoStartupCallback_->AsObject()); if (ret != ERR_OK) { jsAutoStartupCallback_ = nullptr; - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Register auto start up listener wrong[%{public}d].", ret); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "reg callback failed[%{public}d]", ret); if (ret == CHECK_PERMISSION_FAILED) { ThrowNoPermissionError(env, PermissionConstants::PERMISSION_MANAGE_APP_BOOT); } else { @@ -131,14 +131,14 @@ napi_value JsAbilityAutoStartupManager::OnUnregisterAutoStartupCallback(napi_env { TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The argument is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } std::string type; if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], type) || type != ON_OFF_TYPE_SYSTEM) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed to parse type."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "parse type failed"); ThrowError(env, INVALID_PARAM, "Parameter error. Convert type fail."); return CreateJsUndefined(env); } @@ -149,7 +149,7 @@ napi_value JsAbilityAutoStartupManager::OnUnregisterAutoStartupCallback(napi_env } if (jsAutoStartupCallback_ == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "JsAutoStartupCallback_ is nullptr."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null jsAutoStartupCallback_"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } @@ -176,39 +176,39 @@ napi_value JsAbilityAutoStartupManager::OnSetApplicationAutoStartup(napi_env env { TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The argument is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } if (!CheckCallerIsSystemApp()) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Current app is not system app"); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "not system app"); ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP); return CreateJsUndefined(env); } AutoStartupInfo autoStartupInfo; if (!UnwrapAutoStartupInfo(env, info.argv[INDEX_ZERO], autoStartupInfo)) { - ThrowError(env, INVALID_PARAM, "Parameter error. Convert autoStartupInfo fail."); + ThrowError(env, INVALID_PARAM, "unwrap AutoStartupInfo failed"); return CreateJsUndefined(env); } auto retVal = std::make_shared(0); NapiAsyncTask::ExecuteCallback execute = [autoStartupInfo, ret = retVal] () { if (ret == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null ret"); return; } *ret = AbilityManagerClient::GetInstance()->SetApplicationAutoStartup(autoStartupInfo); }; NapiAsyncTask::CompleteCallback complete = [ret = retVal](napi_env env, NapiAsyncTask &task, int32_t status) { if (ret == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The argument is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null ret"); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(INNER_ERR))); return; } if (*ret != ERR_OK) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Wrong error:%{public}d.", *ret); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "error:%{public}d", *ret); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(*ret))); return; } @@ -226,13 +226,13 @@ napi_value JsAbilityAutoStartupManager::OnCancelApplicationAutoStartup(napi_env { TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } if (!CheckCallerIsSystemApp()) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Current app is not system app."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "not system app"); ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP); return CreateJsUndefined(env); } @@ -246,7 +246,7 @@ napi_value JsAbilityAutoStartupManager::OnCancelApplicationAutoStartup(napi_env auto retVal = std::make_shared(0); NapiAsyncTask::ExecuteCallback execute = [autoStartupInfo, ret = retVal] () { if (ret == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null ret"); return; } *ret = AbilityManagerClient::GetInstance()->CancelApplicationAutoStartup(autoStartupInfo); @@ -254,12 +254,12 @@ napi_value JsAbilityAutoStartupManager::OnCancelApplicationAutoStartup(napi_env NapiAsyncTask::CompleteCallback complete = [ret = retVal](napi_env env, NapiAsyncTask &task, int32_t status) { if (ret == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The parameter is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null ret"); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(INNER_ERR))); return; } if (*ret != ERR_OK) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed error:%{public}d.", *ret); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "error:%{public}d", *ret); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(*ret))); return; } @@ -285,7 +285,7 @@ napi_value JsAbilityAutoStartupManager::OnQueryAllAutoStartupApplications(napi_e auto infoList = std::make_shared>(); NapiAsyncTask::ExecuteCallback execute = [infos = infoList, ret = retVal] () { if (ret == nullptr || infos == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null ret or infos"); return; } *ret = AbilityManagerClient::GetInstance()->QueryAllAutoStartupApplications(*infos); @@ -294,12 +294,12 @@ napi_value JsAbilityAutoStartupManager::OnQueryAllAutoStartupApplications(napi_e NapiAsyncTask::CompleteCallback complete = [infos = infoList, ret = retVal]( napi_env env, NapiAsyncTask &task, int32_t status) { if (ret == nullptr || infos == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null ret or infos"); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(INNER_ERR))); return; } if (*ret != ERR_OK) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Failed error:%{public}d.", *ret); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "error:%{public}d", *ret); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(*ret))); return; } @@ -317,7 +317,7 @@ napi_value JsAbilityAutoStartupManagerInit(napi_env env, napi_value exportObj) { TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called"); if (env == nullptr || exportObj == nullptr) { - TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Env or exportObj nullptr."); + TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null env or exportObj"); return nullptr; } @@ -334,7 +334,7 @@ napi_value JsAbilityAutoStartupManagerInit(napi_env env, napi_value exportObj) JsAbilityAutoStartupManager::CancelApplicationAutoStartup); BindNativeFunction(env, exportObj, "queryAllAutoStartupApplications", moduleName, JsAbilityAutoStartupManager::QueryAllAutoStartupApplications); - TAG_LOGD(AAFwkTag::AUTO_STARTUP, "End."); + TAG_LOGD(AAFwkTag::AUTO_STARTUP, "end"); return CreateJsUndefined(env); } } // namespace AbilityRuntime diff --git a/frameworks/js/napi/ability_constant/ability_constant_module.cpp b/frameworks/js/napi/ability_constant/ability_constant_module.cpp index 3888afac8d..1ff39cf951 100644 --- a/frameworks/js/napi/ability_constant/ability_constant_module.cpp +++ b/frameworks/js/napi/ability_constant/ability_constant_module.cpp @@ -31,7 +31,7 @@ enum class MemoryLevel { static napi_status SetEnumItem(napi_env env, napi_value object, const char* name, int32_t value) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_status status; napi_value itemName; napi_value itemValue; @@ -48,7 +48,7 @@ static napi_status SetEnumItem(napi_env env, napi_value object, const char* name static napi_value InitLaunchReasonObject(napi_env env) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_value object; NAPI_CALL(env, napi_create_object(env, &object)); @@ -67,7 +67,7 @@ static napi_value InitLaunchReasonObject(napi_env env) static napi_value InitLastExitReasonObject(napi_env env) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_value object; NAPI_CALL(env, napi_create_object(env, &object)); @@ -87,7 +87,7 @@ static napi_value InitLastExitReasonObject(napi_env env) static napi_value InitOnContinueResultObject(napi_env env) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_value object; NAPI_CALL(env, napi_create_object(env, &object)); @@ -112,7 +112,7 @@ static napi_value InitContinueStateObject(napi_env env) static napi_value InitWindowModeObject(napi_env env) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_value object; NAPI_CALL(env, napi_create_object(env, &object)); @@ -129,7 +129,7 @@ static napi_value InitWindowModeObject(napi_env env) // AbilityConstant.OnSaveResult static napi_value InitOnSaveResultEnum(napi_env env) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_value object; NAPI_CALL(env, napi_create_object(env, &object)); NAPI_CALL(env, SetEnumItem(env, object, "ALL_AGREE", AppExecFwk::ALL_AGREE)); @@ -145,7 +145,7 @@ static napi_value InitOnSaveResultEnum(napi_env env) // AbilityConstant.StateType static napi_value InitStateTypeEnum(napi_env env) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_value object; NAPI_CALL(env, napi_create_object(env, &object)); NAPI_CALL(env, SetEnumItem(env, object, "CONTINUATION", AppExecFwk::CONTINUATION)); @@ -156,7 +156,7 @@ static napi_value InitStateTypeEnum(napi_env env) static napi_value InitMemoryLevelObject(napi_env env) { - TAG_LOGD(AAFwkTag::JSNAPI, "start"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); napi_value object; NAPI_CALL(env, napi_create_object(env, &object)); @@ -178,49 +178,49 @@ static napi_value AbilityConstantInit(napi_env env, napi_value exports) { napi_value launchReason = InitLaunchReasonObject(env); if (launchReason == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create launch reason object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null launchReason"); return nullptr; } napi_value lastExitReason = InitLastExitReasonObject(env); if (lastExitReason == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create last exit reason object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null lastExitReason"); return nullptr; } napi_value onContinueResult = InitOnContinueResultObject(env); if (onContinueResult == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create onContinue result object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null onContinueResult"); return nullptr; } napi_value continueState = InitContinueStateObject(env); if (continueState == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create continue state object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null continueState"); return nullptr; } napi_value windowMode = InitWindowModeObject(env); if (windowMode == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create window mode object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null windowMode"); return nullptr; } napi_value memoryLevel = InitMemoryLevelObject(env); if (memoryLevel == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create memory level object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null memoryLevel"); return nullptr; } napi_value stateType = InitStateTypeEnum(env); if (stateType == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create state type object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null stateType"); return nullptr; } napi_value saveResult = InitOnSaveResultEnum(env); if (saveResult == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to create save result object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null saveResult"); return nullptr; } @@ -236,7 +236,7 @@ static napi_value AbilityConstantInit(napi_env env, napi_value exports) }; napi_status status = napi_define_properties(env, exports, sizeof(exportObjs) / sizeof(exportObjs[0]), exportObjs); if (status != napi_ok) { - TAG_LOGE(AAFwkTag::JSNAPI, "error to define properties for exports"); + TAG_LOGE(AAFwkTag::JSNAPI, "define properties failed"); return nullptr; } diff --git a/frameworks/js/napi/ability_manager/js_ability_foreground_state_observer.cpp b/frameworks/js/napi/ability_manager/js_ability_foreground_state_observer.cpp index b24fd1d068..5f709d1444 100644 --- a/frameworks/js/napi/ability_manager/js_ability_foreground_state_observer.cpp +++ b/frameworks/js/napi/ability_manager/js_ability_foreground_state_observer.cpp @@ -29,7 +29,7 @@ void JSAbilityForegroundStateObserver::OnAbilityStateChanged(const AbilityStateD { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (!valid_) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "The app manager may has destroyed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid appms"); return; } wptr jsObserver = this; @@ -37,7 +37,7 @@ void JSAbilityForegroundStateObserver::OnAbilityStateChanged(const AbilityStateD [jsObserver, abilityStateData](napi_env env, NapiAsyncTask &task, int32_t status) { sptr jsObserverSptr = jsObserver.promote(); if (jsObserverSptr == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Js Observer Sptr is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return; } jsObserverSptr->HandleOnAbilityStateChanged(abilityStateData); @@ -63,35 +63,35 @@ void JSAbilityForegroundStateObserver::HandleOnAbilityStateChanged(const Ability void JSAbilityForegroundStateObserver::CallJsFunction( const napi_value &value, const char *methodName, const napi_value *argv, const size_t argc) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Begin."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (value == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Value is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null value"); return; } napi_value method = nullptr; napi_get_named_property(env_, value, methodName, &method); if (method == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Get name from object Failed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null method"); return; } napi_value callResult = nullptr; napi_status status = napi_call_function(env_, value, method, argc, argv, &callResult); if (status != napi_ok) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Call Js Function failed %{public}d.", status); + TAG_LOGE(AAFwkTag::ABILITYMGR, "call js func failed: %{public}d", status); } - TAG_LOGD(AAFwkTag::ABILITYMGR, "End."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "end"); } bool JSAbilityForegroundStateObserver::IsObserverObjectExsit(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return false; } if (GetObserverObject(jsObserverObject) == nullptr) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Observer is not exists."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "observer not exist"); return false; } return true; @@ -100,12 +100,12 @@ bool JSAbilityForegroundStateObserver::IsObserverObjectExsit(const napi_value &j void JSAbilityForegroundStateObserver::AddJsObserverObject(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return; } if (IsObserverObjectExsit(jsObserverObject)) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Observer is exists."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "observer not exist"); return; } napi_ref ref = nullptr; @@ -116,7 +116,7 @@ void JSAbilityForegroundStateObserver::AddJsObserverObject(const napi_value &jsO void JSAbilityForegroundStateObserver::RemoveJsObserverObject(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return; } @@ -136,18 +136,18 @@ void JSAbilityForegroundStateObserver::RemoveAllJsObserverObject() std::shared_ptr JSAbilityForegroundStateObserver::GetObserverObject(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return nullptr; } for (auto &observer : jsObserverObjectSet_) { if (observer == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid observer."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); continue; } napi_value value = observer->GetNapiValue(); if (value == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to get object."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "get object failed"); continue; } diff --git a/frameworks/js/napi/ability_manager/js_ability_manager.cpp b/frameworks/js/napi/ability_manager/js_ability_manager.cpp index 4d33a17df9..da3a1d1872 100644 --- a/frameworks/js/napi/ability_manager/js_ability_manager.cpp +++ b/frameworks/js/napi/ability_manager/js_ability_manager.cpp @@ -70,7 +70,7 @@ public: static void Finalizer(napi_env env, void* data, void* hint) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "JsAbilityManager::Finalizer is called"); + TAG_LOGI(AAFwkTag::ABILITYMGR, "finalizer called"); std::unique_ptr(static_cast(data)); } @@ -150,12 +150,12 @@ private: { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } if (!AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid param"); ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver."); return CreateJsUndefined(env); } @@ -173,7 +173,7 @@ private: if (observerForeground_ == nullptr) { observerForeground_ = new (std::nothrow) JSAbilityForegroundStateObserver(env); if (observerForeground_ == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "observerForeground_ is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observerForeground_"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } @@ -182,7 +182,7 @@ private: if (observerForeground_->IsEmpty()) { int32_t ret = GetAppManagerInstance()->RegisterAbilityForegroundStateObserver(observerForeground_); if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed error: %{public}d.", ret); + TAG_LOGE(AAFwkTag::ABILITYMGR, "error: %{public}d", ret); ThrowErrorByNativeErr(env, ret); return CreateJsUndefined(env); } @@ -196,12 +196,12 @@ private: { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params when off."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } if (argc == ARGC_TWO && !AppExecFwk::IsTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid param."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid param"); ThrowInvalidParamError(env, "Parse param observer failed, must be a AbilityForegroundStateObserver."); return CreateJsUndefined(env); } @@ -219,12 +219,12 @@ private: const std::regex regexJsperf(R"(^\d*)"); std::match_results matchResults; if (numStr.empty() || !std::regex_match(numStr, matchResults, regexJsperf)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Number parsing error, %{public}s.", numStr.c_str()); + TAG_LOGE(AAFwkTag::ABILITYMGR, "parse failed: %{public}s", numStr.c_str()); return false; } if (MAX_UINT64_VALUE.length() < numStr.length() || (MAX_UINT64_VALUE.length() == numStr.length() && MAX_UINT64_VALUE.compare(numStr) < 0)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Number parsing error, %{public}s.", numStr.c_str()); + TAG_LOGE(AAFwkTag::ABILITYMGR, "parse failed: %{public}s", numStr.c_str()); return false; } return true; @@ -234,26 +234,26 @@ private: { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params when off."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } std::string assertSessionStr; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], assertSessionStr) || !CheckIsNumString(assertSessionStr)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id error."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "convert sessionId failed"); ThrowInvalidParamError(env, "Parse param sessionId failed, must be a string."); return CreateJsUndefined(env); } uint64_t assertSessionId = std::stoull(assertSessionStr); if (assertSessionId == 0) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert session id failed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "convert sessionId failed"); ThrowInvalidParamError(env, "Parse param sessionId failed, value must not be equal to zero."); return CreateJsUndefined(env); } int32_t userStatus; if (!ConvertFromJsValue(env, argv[INDEX_ONE], userStatus)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Convert status failed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "convert status failed"); ThrowInvalidParamError(env, "Parse param status failed, must be a UserStatus."); return CreateJsUndefined(env); } @@ -262,13 +262,13 @@ private: [assertSessionId, userStatus](napi_env env, NapiAsyncTask &task, int32_t status) { auto amsClient = AbilityManagerClient::GetInstance(); if (amsClient == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Ability manager service instance is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null amsClient"); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(AAFwk::INNER_ERR))); return; } auto ret = amsClient->NotifyDebugAssertResult(assertSessionId, static_cast(userStatus)); if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Notify user action result failed, error is %{public}d.", ret); + TAG_LOGE(AAFwkTag::ABILITYMGR, "notify assert ret failed, ret: %{public}d", ret); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(ret))); return; } @@ -284,7 +284,7 @@ private: napi_value OnOffAbilityForeground(napi_env env, size_t argc, napi_value *argv) { if (observerForeground_ == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } @@ -297,7 +297,7 @@ private: if (observerForeground_->IsEmpty()) { int32_t ret = GetAppManagerInstance()->UnregisterAbilityForegroundStateObserver(observerForeground_); if (ret != NO_ERROR) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed error: %{public}d.", ret); + TAG_LOGE(AAFwkTag::ABILITYMGR, "error: %{public}d", ret); ThrowErrorByNativeErr(env, ret); return CreateJsUndefined(env); } @@ -307,7 +307,7 @@ private: napi_value OnGetAbilityRunningInfos(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s is called", __FUNCTION__); + TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); NapiAsyncTask::CompleteCallback complete = [](napi_env env, NapiAsyncTask &task, int32_t status) { std::vector infos; @@ -334,9 +334,9 @@ private: napi_value OnGetExtensionRunningInfos(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s is called", __FUNCTION__); + TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (info.argc == 0) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); #ifdef ENABLE_ERRCODE ThrowTooFewParametersError(env); #endif @@ -377,12 +377,12 @@ private: napi_value OnUpdateConfiguration(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::ABILITYMGR, "called"); NapiAsyncTask::CompleteCallback complete; do { if (info.argc == 0) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); #ifdef ENABLE_ERRCODE ThrowTooFewParametersError(env); #else @@ -431,11 +431,11 @@ private: napi_value OnGetTopAbility(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::ABILITYMGR, "called"); #ifdef ENABLE_ERRCODE auto selfToken = IPCSkeleton::GetSelfTokenID(); if (!Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(selfToken)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "This application is not system-app, can not use system-api"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "not system app"); ThrowError(env, AbilityErrorCode::ERROR_CODE_NOT_SYSTEM_APP); return CreateJsUndefined(env); } @@ -459,7 +459,7 @@ private: napi_value OnAcquireShareData(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::ABILITYMGR, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::ABILITYMGR, "called"); if (info.argc < ARGC_ONE) { ThrowTooFewParametersError(env); return CreateJsUndefined(env); @@ -506,14 +506,14 @@ private: do { if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); ThrowTooFewParametersError(env); break; } int reqCode = 0; if (!ConvertFromJsValue(env, info.argv[1], reqCode)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Get requestCode param error"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "get requestCode failed"); ThrowInvalidParamError(env, "Parse param requestCode failed, must be a number."); break; } @@ -521,7 +521,7 @@ private: AppExecFwk::Want want; int resultCode = ERR_OK; if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[0], resultCode, want)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Unrwrap abilityResult param error"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "unwrap abilityResult failed"); ThrowInvalidParamError(env, "Parse param parameter failed, must be a AbilityResult."); break; } @@ -556,7 +556,7 @@ private: if (ret == ERR_OK) { task.ResolveWithNoError(env, CreateJsAbilityStateDataArray(env, list)); } else { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed error: %{public}d.", ret); + TAG_LOGE(AAFwkTag::ABILITYMGR, "error: %{public}d", ret); task.Reject(env, CreateJsError(env, GetJsErrorCodeByNativeError(ret))); } }; @@ -572,21 +572,21 @@ private: { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params when off."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } std::string bundleName; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName) || bundleName.empty()) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Parse param bundleName failed, must be a string."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "parse bundleName failed, not string"); ThrowInvalidParamError(env, "Parse param bundleName failed, must be a string."); return CreateJsUndefined(env); } bool enableState = false; if (!ConvertFromJsValue(env, argv[INDEX_ONE], enableState)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Parse param enable failed, must be a boolean."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "parse enable failed, not boolean"); ThrowInvalidParamError(env, "Parse param enable failed, must be a boolean."); return CreateJsUndefined(env); } @@ -595,7 +595,7 @@ private: NapiAsyncTask::ExecuteCallback execute = [bundleName, enableState, innerErrorCode, env]() { auto amsClient = AbilityManagerClient::GetInstance(); if (amsClient == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Ability manager service instance is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null amsClient"); *innerErrorCode = static_cast(AAFwk::INNER_ERR); return; } @@ -604,7 +604,7 @@ private: NapiAsyncTask::CompleteCallback complete = [innerErrorCode](napi_env env, NapiAsyncTask &task, int32_t status) { if (*innerErrorCode != ERR_OK) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Set resident process result failed, error is %{public}d.", + TAG_LOGE(AAFwkTag::ABILITYMGR, "set resident process result failed, error: %{public}d", *innerErrorCode); task.Reject(env, CreateJsErrorByNativeErr(env, *innerErrorCode)); return; @@ -622,7 +622,7 @@ private: { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -630,26 +630,26 @@ private: bool stageMode = false; napi_status status = OHOS::AbilityRuntime::IsStageContext(env, info.argv[0], stageMode); if (status != napi_ok || !stageMode) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "it is not a context of stageMode"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "not stageMode"); ThrowInvalidParamError(env, "Parse param context failed, must be a context of stageMode."); return CreateJsUndefined(env); } auto context = OHOS::AbilityRuntime::GetStageModeContext(env, info.argv[0]); if (context == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "get context failed"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null context"); ThrowInvalidParamError(env, "Parse param context failed, must not be nullptr."); return CreateJsUndefined(env); } auto uiAbilityContext = AbilityRuntime::Context::ConvertTo(context); if (uiAbilityContext == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "convert to UIAbility context failed"); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null UIAbilityContext"); ThrowInvalidParamError(env, "Parse param context failed, must be UIAbilityContext."); return CreateJsUndefined(env); } std::string appId; if (!ConvertFromJsValue(env, info.argv[1], appId)) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "OnOpenAtomicService, parse appId failed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "parse appId failed"); ThrowInvalidParamError(env, "Parse param appId failed, must be a string."); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/app/ability_delegator/ability_monitor.cpp b/frameworks/js/napi/app/ability_delegator/ability_monitor.cpp index c3e67f8cd6..c474b75d0d 100644 --- a/frameworks/js/napi/app/ability_delegator/ability_monitor.cpp +++ b/frameworks/js/napi/app/ability_delegator/ability_monitor.cpp @@ -42,7 +42,7 @@ void AbilityMonitor::OnAbilityStart(const std::weak_ptr &abilit jsMonitor_->OnAbilityCreate(abilityObj); - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void AbilityMonitor::OnAbilityForeground(const std::weak_ptr &abilityObj) @@ -55,7 +55,7 @@ void AbilityMonitor::OnAbilityForeground(const std::weak_ptr &a jsMonitor_->OnAbilityForeground(abilityObj); - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void AbilityMonitor::OnAbilityBackground(const std::weak_ptr &abilityObj) @@ -68,7 +68,7 @@ void AbilityMonitor::OnAbilityBackground(const std::weak_ptr &a jsMonitor_->OnAbilityBackground(abilityObj); - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void AbilityMonitor::OnAbilityStop(const std::weak_ptr &abilityObj) @@ -81,7 +81,7 @@ void AbilityMonitor::OnAbilityStop(const std::weak_ptr &ability jsMonitor_->OnAbilityDestroy(abilityObj); - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void AbilityMonitor::OnWindowStageCreate(const std::weak_ptr &abilityObj) @@ -95,7 +95,7 @@ void AbilityMonitor::OnWindowStageCreate(const std::weak_ptr &a jsMonitor_->OnWindowStageCreate(abilityObj); - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void AbilityMonitor::OnWindowStageRestore(const std::weak_ptr &abilityObj) @@ -108,7 +108,7 @@ void AbilityMonitor::OnWindowStageRestore(const std::weak_ptr & jsMonitor_->OnWindowStageRestore(abilityObj); - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void AbilityMonitor::OnWindowStageDestroy(const std::weak_ptr &abilityObj) @@ -121,7 +121,7 @@ void AbilityMonitor::OnWindowStageDestroy(const std::weak_ptr & jsMonitor_->OnWindowStageDestroy(abilityObj); - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } } // namespace AbilityDelegatorJs } // namespace OHOS diff --git a/frameworks/js/napi/app/ability_delegator/js_ability_delegator.cpp b/frameworks/js/napi/app/ability_delegator/js_ability_delegator.cpp index bd681333f5..bfed1b866c 100644 --- a/frameworks/js/napi/app/ability_delegator/js_ability_delegator.cpp +++ b/frameworks/js/napi/app/ability_delegator/js_ability_delegator.cpp @@ -94,14 +94,14 @@ void ResolveWithNoError(napi_env env, NapiAsyncTask &task, napi_value value = nu napi_value AttachAppContext(napi_env env, void *value, void *) { - TAG_LOGI(AAFwkTag::DELEGATOR, "AttachAppContext"); + TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (value == nullptr) { - TAG_LOGW(AAFwkTag::DELEGATOR, "invalid parameter."); + TAG_LOGW(AAFwkTag::DELEGATOR, "null value"); return nullptr; } auto ptr = reinterpret_cast*>(value)->lock(); if (ptr == nullptr) { - TAG_LOGW(AAFwkTag::DELEGATOR, "invalid context."); + TAG_LOGW(AAFwkTag::DELEGATOR, "null context"); return nullptr; } @@ -110,7 +110,7 @@ napi_value AttachAppContext(napi_env env, void *value, void *) auto workContext = new (std::nothrow) std::weak_ptr(ptr); napi_wrap(env, object, workContext, [](napi_env, void *data, void *) { - TAG_LOGI(AAFwkTag::DELEGATOR, "Finalizer for weak_ptr app context is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "finalizer called"); delete static_cast *>(data); }, nullptr, nullptr); return object; @@ -121,9 +121,9 @@ JSAbilityDelegator::JSAbilityDelegator() auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (delegator) { auto clearFunc = [](const std::shared_ptr &property) { - TAG_LOGI(AAFwkTag::DELEGATOR, "Clear function is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "clearFunc called"); if (!property) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid property"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null property"); return; } @@ -254,17 +254,17 @@ napi_value JSAbilityDelegator::SetMockList(napi_env env, napi_callback_info info napi_value JSAbilityDelegator::OnAddAbilityMonitor(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::shared_ptr monitor = nullptr; if (!ParseAbilityMonitorPara(env, info, monitor, false)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse addAbilityMonitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse param monitor failed, monitor must be Monitor."); } NapiAsyncTask::CompleteCallback complete = [monitor](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnAddAbilityMonitor NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "addAbilityMonitor failed.")); @@ -283,11 +283,11 @@ napi_value JSAbilityDelegator::OnAddAbilityMonitor(napi_env env, NapiCallbackInf napi_value JSAbilityDelegator::OnAddAbilityMonitorSync(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::shared_ptr monitor = nullptr; if (!ParseAbilityMonitorPara(env, info, monitor, true)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse addAbilityMonitorSync parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse param monitor failed, monitor must be Monitor."); } @@ -302,18 +302,18 @@ napi_value JSAbilityDelegator::OnAddAbilityMonitorSync(napi_env env, NapiCallbac napi_value JSAbilityDelegator::OnAddAbilityStageMonitor(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); bool isExisted = false; std::shared_ptr monitor = nullptr; if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, false)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse addAbilityStageMonitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse parameters failed, monitor must be Monitor and isExited must be boolean."); } NapiAsyncTask::CompleteCallback complete = [monitor](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnAddAbilityStageMonitor NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "addAbilityStageMonitor failed.")); @@ -336,12 +336,12 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitor(napi_env env, NapiCallba napi_value JSAbilityDelegator::OnAddAbilityStageMonitorSync(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); bool isExisted = false; std::shared_ptr monitor = nullptr; if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, true)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse addAbilityStageMonitorSync parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse param monitor failed, monitor must be Monitor."); } @@ -359,18 +359,18 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitorSync(napi_env env, NapiCa napi_value JSAbilityDelegator::OnRemoveAbilityMonitor(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::shared_ptr monitor = nullptr; if (!ParseAbilityMonitorPara(env, info, monitor, false)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse removeAbilityMonitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse monitor failed, removeAbilityMonitor must be Monitor."); } NapiAsyncTask::CompleteCallback complete = [monitor](napi_env env, NapiAsyncTask &task, int32_t status) mutable { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnRemoveAbilityMonitor NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "removeAbilityMonitor failed.")); @@ -403,11 +403,11 @@ napi_value JSAbilityDelegator::OnRemoveAbilityMonitor(napi_env env, NapiCallback napi_value JSAbilityDelegator::OnRemoveAbilityMonitorSync(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::shared_ptr monitor = nullptr; if (!ParseAbilityMonitorPara(env, info, monitor, true)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse removeAbilityMonitorSync parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse monitor failed, removeAbilityMonitor must be Monitor."); } @@ -431,19 +431,19 @@ napi_value JSAbilityDelegator::OnRemoveAbilityMonitorSync(napi_env env, NapiCall napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitor(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); bool isExisted = false; std::shared_ptr monitor = nullptr; if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, false)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse removeAbilityStageMonitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse monitor failed, removeAbilityMonitor must be Monitor."); } NapiAsyncTask::CompleteCallback complete = [monitor](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnRemoveAbilityStageMonitor NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { @@ -467,12 +467,12 @@ napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitor(napi_env env, NapiCal napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitorSync(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); bool isExisted = false; std::shared_ptr monitor = nullptr; if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, true)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse removeAbilityStageMonitorSync parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse monitor failed, removeAbilityMonitor must be Monitor."); } @@ -491,36 +491,36 @@ napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitorSync(napi_env env, Nap napi_value JSAbilityDelegator::OnWaitAbilityMonitor(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::shared_ptr monitor = nullptr; TimeoutCallback opt {false, false}; int64_t timeout = 0; if (!ParseWaitAbilityMonitorPara(env, info, monitor, opt, timeout)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse waitAbilityMonitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse waitAbilityMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse monitor want failed, removeAbilityMonitor must be Monitor."); } auto abilityObjectBox = std::make_shared(); NapiAsyncTask::ExecuteCallback execute = [monitor, timeout, opt, abilityObjectBox]() { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnWaitAbilityMonitor NapiAsyncTask ExecuteCallback is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "execute called"); if (!abilityObjectBox) { TAG_LOGE( - AAFwkTag::DELEGATOR, "OnWaitAbilityMonitor NapiAsyncTask ExecuteCallback, Invalid abilityObjectBox"); + AAFwkTag::DELEGATOR, "null abilityObjectBox"); return; } auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { - TAG_LOGE(AAFwkTag::DELEGATOR, "OnWaitAbilityMonitor NapiAsyncTask ExecuteCallback, Invalid delegator"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return; } std::shared_ptr property = opt.hasTimeoutPara ? delegator->WaitAbilityMonitor(monitor, timeout) : delegator->WaitAbilityMonitor(monitor); if (!property || property->object_.expired()) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid property"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid property"); return; } @@ -530,7 +530,7 @@ napi_value JSAbilityDelegator::OnWaitAbilityMonitor(napi_env env, NapiCallbackIn }; NapiAsyncTask::CompleteCallback complete = [abilityObjectBox](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnWaitAbilityMonitor NapiAsyncTask CompleteCallback is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); if (abilityObjectBox && !abilityObjectBox->object_.expired()) { ResolveWithNoError(env, task, abilityObjectBox->object_.lock()->GetNapiValue()); } else { @@ -551,28 +551,27 @@ napi_value JSAbilityDelegator::OnWaitAbilityMonitor(napi_env env, NapiCallbackIn napi_value JSAbilityDelegator::OnWaitAbilityStageMonitor(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::shared_ptr monitor = nullptr; TimeoutCallback opt {false, false}; int64_t timeout = 0; if (!ParseWaitAbilityStageMonitorPara(env, info, monitor, opt, timeout)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse waitAbilityStageMonitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse waitAbilityStageMonitor param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse monitor failed, removeAbilityMonitor must be Monitor."); } auto abilityStageObjBox = std::make_shared(); NapiAsyncTask::ExecuteCallback execute = [monitor, timeout, opt, abilityStageObjBox]() { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnWaitAbilityStageMonitor NapiAsyncTask ExecuteCallback is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "execute called"); if (!abilityStageObjBox) { - TAG_LOGE(AAFwkTag::DELEGATOR, - "OnWaitAbilityStageMonitor NapiAsyncTask ExecuteCallback, Invalid abilityStageObjBox"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null abilityStageObjBox"); return; } auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { - TAG_LOGE(AAFwkTag::DELEGATOR, "OnWaitAbilityMonitor NapiAsyncTask ExecuteCallback, Invalid delegator"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return; } std::shared_ptr result; @@ -586,7 +585,7 @@ napi_value JSAbilityDelegator::OnWaitAbilityStageMonitor(napi_env env, NapiCallb }; NapiAsyncTask::CompleteCallback complete = [abilityStageObjBox](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnWaitAbilityMonitor NapiAsyncTask CompleteCallback is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); if (abilityStageObjBox && !abilityStageObjBox->object_.expired()) { ResolveWithNoError(env, task, abilityStageObjBox->object_.lock()->GetNapiValue()); } else { @@ -605,17 +604,17 @@ napi_value JSAbilityDelegator::OnWaitAbilityStageMonitor(napi_env env, NapiCallb napi_value JSAbilityDelegator::OnPrint(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::string msg; if (!ParsePrintPara(env, info, msg)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse print parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse print param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse parameters msg failed, msg must be string."); } NapiAsyncTask::CompleteCallback complete = [msg](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnPrint NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "print failed.")); @@ -634,18 +633,18 @@ napi_value JSAbilityDelegator::OnPrint(napi_env env, NapiCallbackInfo& info) napi_value JSAbilityDelegator::OnPrintSync(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::string msg; if (!ParsePrintPara(env, info, msg)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse print parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse print param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse msg failed, msg must be string."); } auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid delegator"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return CreateJsUndefined(env); } @@ -655,29 +654,28 @@ napi_value JSAbilityDelegator::OnPrintSync(napi_env env, NapiCallbackInfo& info) napi_value JSAbilityDelegator::OnExecuteShellCommand(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::string cmd; TimeoutCallback opt {false, false}; int64_t timeoutSecs = 0; if (!ParseExecuteShellCommandPara(env, info, cmd, opt, timeoutSecs)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse executeShellCommand parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse executeShellCommand param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse parameters failed, cmd must be string and timeout must be number."); } auto shellCmdResultBox = std::make_shared(); NapiAsyncTask::ExecuteCallback execute = [cmd, timeoutSecs, shellCmdResultBox]() { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnExecuteShellCommand NapiAsyncTask ExecuteCallback is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "execute called"); if (!shellCmdResultBox) { - TAG_LOGE( - AAFwkTag::DELEGATOR, "OnExecuteShellCommand NapiAsyncTask ExecuteCallback, Invalid shellCmdResultBox"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null shellCmdResultBox"); return; } auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { - TAG_LOGE(AAFwkTag::DELEGATOR, "OnExecuteShellCommand NapiAsyncTask ExecuteCallback, Invalid delegator"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return; } @@ -685,10 +683,9 @@ napi_value JSAbilityDelegator::OnExecuteShellCommand(napi_env env, NapiCallbackI }; NapiAsyncTask::CompleteCallback complete = [shellCmdResultBox](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnExecuteShellCommand NapiAsyncTask CompleteCallback is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); if (!shellCmdResultBox) { - TAG_LOGE( - AAFwkTag::DELEGATOR, "OnExecuteShellCommand NapiAsyncTask CompleteCallback, Invalid shellCmdResultBox"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null shellCmdResultBox"); task.Reject(env, CreateJsError(env, COMMON_FAILED, "executeShellCommand failed.")); return; } @@ -714,28 +711,28 @@ napi_value JSAbilityDelegator::OnExecuteShellCommand(napi_env env, NapiCallbackI napi_value JSAbilityDelegator::OnGetAppContext(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { - TAG_LOGE(AAFwkTag::DELEGATOR, "delegator is null"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return CreateJsNull(env); } std::shared_ptr context = delegator->GetAppContext(); if (!context) { - TAG_LOGE(AAFwkTag::DELEGATOR, "context is null"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null context"); return CreateJsNull(env); } napi_value value = CreateJsBaseContext(env, context, false); auto workContext = new (std::nothrow) std::weak_ptr(context); if (workContext == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "invalid workContext"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null workContext"); return CreateJsNull(env); } napi_coerce_to_native_binding_object(env, value, DetachCallbackFunc, AttachAppContext, workContext, nullptr); napi_wrap(env, value, workContext, [](napi_env, void *data, void *) { - TAG_LOGI(AAFwkTag::DELEGATOR, "Finalizer for weak_ptr app context is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "finalizer called"); delete static_cast *>(data); }, nullptr, nullptr); return value; @@ -743,22 +740,22 @@ napi_value JSAbilityDelegator::OnGetAppContext(napi_env env, NapiCallbackInfo& i napi_value JSAbilityDelegator::OnGetAbilityState(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return CreateJsUndefined(env); } sptr remoteObject = nullptr; if (!ParseAbilityPara(env, info.argv[INDEX_ZERO], remoteObject)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse ability parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse ability param failed"); return CreateJsUndefined(env); } auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { - TAG_LOGE(AAFwkTag::DELEGATOR, "delegator is null"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return CreateJsNull(env); } AbilityDelegator::AbilityState lifeState = delegator->GetAbilityState(remoteObject); @@ -769,25 +766,25 @@ napi_value JSAbilityDelegator::OnGetAbilityState(napi_env env, NapiCallbackInfo& napi_value JSAbilityDelegator::OnGetCurrentTopAbility(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); if (info.argc >= ARGC_ONE && !AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ZERO], napi_function)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse getCurrentTopAbility parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse callback failed, callback must be function"); } NapiAsyncTask::CompleteCallback complete = [this](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnGetCurrentTopAbility NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid delegator"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); task.Reject(env, CreateJsError(env, COMMON_FAILED, "getCurrentTopAbility failed.")); return; } auto property = delegator->GetCurrentTopAbility(); if (!property || property->object_.expired()) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid property"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid property"); task.Reject(env, CreateJsError(env, COMMON_FAILED, "getCurrentTopAbility failed.")); } else { { @@ -807,17 +804,17 @@ napi_value JSAbilityDelegator::OnGetCurrentTopAbility(napi_env env, NapiCallback napi_value JSAbilityDelegator::OnStartAbility(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); AAFwk::Want want; if (!ParseStartAbilityPara(env, info, want)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse startAbility parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse startAbility param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse want failed, want must be Want."); } NapiAsyncTask::CompleteCallback complete = [want](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnStartAbility NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "startAbility failed.")); @@ -840,17 +837,17 @@ napi_value JSAbilityDelegator::OnStartAbility(napi_env env, NapiCallbackInfo& in napi_value JSAbilityDelegator::OnDoAbilityForeground(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); sptr remoteObject = nullptr; if (!ParseAbilityCommonPara(env, info, remoteObject)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse doAbilityForeground parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityCommon param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse remoteObject failed, remoteObject must be RemoteObject."); } NapiAsyncTask::CompleteCallback complete = [remoteObject](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnDoAbilityForeground NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "doAbilityForeground failed.")); @@ -872,17 +869,17 @@ napi_value JSAbilityDelegator::OnDoAbilityForeground(napi_env env, NapiCallbackI napi_value JSAbilityDelegator::OnDoAbilityBackground(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); sptr remoteObject = nullptr; if (!ParseAbilityCommonPara(env, info, remoteObject)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse doAbilityBackground parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityCommon param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse remoteObject failed, remoteObject must be RemoteObject."); } NapiAsyncTask::CompleteCallback complete = [remoteObject](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnDoAbilityBackground NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "doAbilityBackground failed.")); @@ -904,18 +901,18 @@ napi_value JSAbilityDelegator::OnDoAbilityBackground(napi_env env, NapiCallbackI napi_value JSAbilityDelegator::OnFinishTest(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::string msg; int64_t code = 0; if (!ParseFinishTestPara(env, info, msg, code)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse finishTest parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse finishTest param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse parameters failed, msg must be string and code must be number."); } NapiAsyncTask::CompleteCallback complete = [msg, code](napi_env env, NapiAsyncTask &task, int32_t status) { - TAG_LOGI(AAFwkTag::DELEGATOR, "OnFinishTest NapiAsyncTask is called"); + TAG_LOGI(AAFwkTag::DELEGATOR, "complete called"); auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator(); if (!delegator) { task.Reject(env, CreateJsError(env, COMMON_FAILED, "finishTest failed.")); @@ -933,11 +930,11 @@ napi_value JSAbilityDelegator::OnFinishTest(napi_env env, NapiCallbackInfo& info napi_value JSAbilityDelegator::OnSetMockList(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::DELEGATOR, "argc = %{public}d", static_cast(info.argc)); + TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast(info.argc)); std::map mockList; if (!ParseMockListPara(env, info, mockList)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse setMockList parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse mockList param failed"); return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse mockList failed, mockList must be MockList."); } @@ -949,14 +946,14 @@ napi_value JSAbilityDelegator::OnSetMockList(napi_env env, NapiCallbackInfo& inf napi_value JSAbilityDelegator::ParseMonitorPara( napi_env env, napi_value value, std::shared_ptr &monitor) { - TAG_LOGI(AAFwkTag::DELEGATOR, "monitorRecord size = %{public}zu", g_monitorRecord.size()); + TAG_LOGI(AAFwkTag::DELEGATOR, "monitorRecord size: %{public}zu", g_monitorRecord.size()); for (auto iter = g_monitorRecord.begin(); iter != g_monitorRecord.end(); ++iter) { std::shared_ptr jsMonitor = iter->first; bool isEquals = false; napi_strict_equals(env, value, jsMonitor->GetNapiValue(), &isEquals); if (isEquals) { - TAG_LOGE(AAFwkTag::DELEGATOR, "monitor existed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "monitor exist"); monitor = iter->second; return monitor ? CreateJsNull(env) : nullptr; } @@ -965,7 +962,7 @@ napi_value JSAbilityDelegator::ParseMonitorPara( napi_value abilityNameValue = nullptr; napi_get_named_property(env, value, "abilityName", &abilityNameValue); if (abilityNameValue == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get property abilityName"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null abilityNameValue"); return nullptr; } @@ -978,7 +975,7 @@ napi_value JSAbilityDelegator::ParseMonitorPara( napi_value moduleNameValue = nullptr; napi_get_named_property(env, value, "moduleName", &moduleNameValue); if (moduleNameValue != nullptr && !ConvertFromJsValue(env, moduleNameValue, moduleName)) { - TAG_LOGW(AAFwkTag::DELEGATOR, "Failed to get property moduleName"); + TAG_LOGW(AAFwkTag::DELEGATOR, "get property moduleName failed"); moduleName = ""; } @@ -1007,7 +1004,7 @@ napi_value JSAbilityDelegator::ParseMonitorPara( napi_value JSAbilityDelegator::ParseStageMonitorPara( napi_env env, napi_value value, std::shared_ptr &monitor, bool &isExisted) { - TAG_LOGI(AAFwkTag::DELEGATOR, "stageMonitorRecord size = %{public}zu", g_stageMonitorRecord.size()); + TAG_LOGI(AAFwkTag::DELEGATOR, "stageMonitorRecord size: %{public}zu", g_stageMonitorRecord.size()); isExisted = false; for (auto iter = g_stageMonitorRecord.begin(); iter != g_stageMonitorRecord.end(); ++iter) { @@ -1015,7 +1012,7 @@ napi_value JSAbilityDelegator::ParseStageMonitorPara( bool isEquals = false; napi_strict_equals(env, value, jsMonitor->GetNapiValue(), &isEquals); if (isEquals) { - TAG_LOGW(AAFwkTag::DELEGATOR, "AbilityStage monitor existed"); + TAG_LOGW(AAFwkTag::DELEGATOR, "abilityStage monitor exist"); isExisted = true; monitor = iter->second; return monitor ? CreateJsNull(env) : nullptr; @@ -1025,23 +1022,23 @@ napi_value JSAbilityDelegator::ParseStageMonitorPara( napi_value moduleNameValue = nullptr; napi_get_named_property(env, value, "moduleName", &moduleNameValue); if (moduleNameValue == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get property moduleName"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null moduleName"); return nullptr; } std::string moduleName; if (!ConvertFromJsValue(env, moduleNameValue, moduleName)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get moduleName from JsValue"); + TAG_LOGE(AAFwkTag::DELEGATOR, "convert moduleName failed"); return nullptr; } napi_value srcEntranceValue = nullptr; napi_get_named_property(env, value, "srcEntrance", &srcEntranceValue); if (srcEntranceValue == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get property srcEntrance"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null srcEntrance"); return nullptr; } std::string srcEntrance; if (!ConvertFromJsValue(env, srcEntranceValue, srcEntrance)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get srcEntrance from JsValue"); + TAG_LOGE(AAFwkTag::DELEGATOR, "convert srcEntrance failed"); return nullptr; } @@ -1052,7 +1049,7 @@ napi_value JSAbilityDelegator::ParseStageMonitorPara( napi_value JSAbilityDelegator::ParseAbilityPara( napi_env env, napi_value value, sptr &remoteObject) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGI(AAFwkTag::DELEGATOR, "called"); std::unique_lock lck(g_mutexAbilityRecord); for (auto iter = g_abilityRecord.begin(); iter != g_abilityRecord.end();) { @@ -1065,21 +1062,21 @@ napi_value JSAbilityDelegator::ParseAbilityPara( napi_strict_equals(env, value, iter->first.lock()->GetNapiValue(), &isEquals); if (isEquals) { remoteObject = iter->second; - TAG_LOGI(AAFwkTag::DELEGATOR, "Ability exist"); + TAG_LOGI(AAFwkTag::DELEGATOR, "ability exist"); return remoteObject ? CreateJsNull(env) : nullptr; } ++iter; } - TAG_LOGE(AAFwkTag::DELEGATOR, "Ability doesn't exist"); + TAG_LOGE(AAFwkTag::DELEGATOR, "ability not exist"); remoteObject = nullptr; return nullptr; } napi_value JSAbilityDelegator::CreateAbilityObject(napi_env env, const sptr &remoteObject) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (!remoteObject) { return nullptr; @@ -1088,7 +1085,7 @@ napi_value JSAbilityDelegator::CreateAbilityObject(napi_env env, const sptr(lifeState)); + TAG_LOGI(AAFwkTag::DELEGATOR, "lifeState: %{public}d", static_cast(lifeState)); switch (lifeState) { case AbilityDelegator::AbilityState::STARTED: abilityLifeState = AbilityLifecycleState::CREATE; @@ -1128,14 +1125,14 @@ void JSAbilityDelegator::AbilityLifecycleStateToJs( napi_value JSAbilityDelegator::ParseAbilityMonitorPara( napi_env env, NapiCallbackInfo& info, std::shared_ptr &monitor, bool isSync) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!ParseMonitorPara(env, info.argv[INDEX_ZERO], monitor)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse monitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse monitor param failed"); return nullptr; } @@ -1145,7 +1142,7 @@ napi_value JSAbilityDelegator::ParseAbilityMonitorPara( if (info.argc > ARGC_ONE) { if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "ParseAbilityMonitorPara, Parse callback parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } } @@ -1155,14 +1152,14 @@ napi_value JSAbilityDelegator::ParseAbilityMonitorPara( napi_value JSAbilityDelegator::ParseAbilityStageMonitorPara(napi_env env, NapiCallbackInfo& info, std::shared_ptr &monitor, bool &isExisted, bool isSync) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!ParseStageMonitorPara(env, info.argv[INDEX_ZERO], monitor, isExisted)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse stage monitor parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse stage monitor param failed"); return nullptr; } @@ -1172,7 +1169,7 @@ napi_value JSAbilityDelegator::ParseAbilityStageMonitorPara(napi_env env, NapiCa if (info.argc > ARGC_ONE) { if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "ParseAbilityStageMonitorPara, Parse callback parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } } @@ -1182,19 +1179,19 @@ napi_value JSAbilityDelegator::ParseAbilityStageMonitorPara(napi_env env, NapiCa napi_value JSAbilityDelegator::ParseWaitAbilityMonitorPara(napi_env env, NapiCallbackInfo& info, std::shared_ptr &monitor, TimeoutCallback &opt, int64_t &timeout) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!ParseMonitorPara(env, info.argv[INDEX_ZERO], monitor)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Monitor parse parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "monitor parse param failed"); return nullptr; } if (!ParseTimeoutCallbackPara(env, info, opt, timeout)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "TimeoutCallback parse parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } return CreateJsNull(env); @@ -1203,19 +1200,19 @@ napi_value JSAbilityDelegator::ParseWaitAbilityMonitorPara(napi_env env, NapiCal napi_value JSAbilityDelegator::ParseWaitAbilityStageMonitorPara(napi_env env, NapiCallbackInfo& info, std::shared_ptr &monitor, TimeoutCallback &opt, int64_t &timeout) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } bool isExisted = false; if (!ParseStageMonitorPara(env, info.argv[INDEX_ZERO], monitor, isExisted)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Stage monitor parse parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse stageMonitor param failed"); return nullptr; } if (!ParseTimeoutCallbackPara(env, info, opt, timeout)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "TimeoutCallback parse parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } if (!isExisted) { @@ -1237,7 +1234,7 @@ napi_value JSAbilityDelegator::ParseTimeoutCallbackPara( opt.hasTimeoutPara = true; } else { if (info.argv[INDEX_ONE] == nullptr) { - TAG_LOGW(AAFwkTag::DELEGATOR, "info.argv[1] is null"); + TAG_LOGW(AAFwkTag::DELEGATOR, "null info.argv[1]"); } else if (AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) { opt.hasCallbackPara = true; return CreateJsNull(env); @@ -1249,7 +1246,7 @@ napi_value JSAbilityDelegator::ParseTimeoutCallbackPara( if (info.argc > ARGC_TWO) { if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_TWO], napi_function)) { if (info.argv[INDEX_TWO] == nullptr) { - TAG_LOGW(AAFwkTag::DELEGATOR, "info.argv[2] is null"); + TAG_LOGW(AAFwkTag::DELEGATOR, "null info.argv[2]"); return CreateJsNull(env); } return nullptr; @@ -1264,18 +1261,18 @@ napi_value JSAbilityDelegator::ParsePrintPara(napi_env env, NapiCallbackInfo& in { TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], msg)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse msg parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "convert msg failed"); return nullptr; } if (info.argc > ARGC_ONE) { if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse callback parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } } @@ -1287,16 +1284,16 @@ napi_value JSAbilityDelegator::ParseExecuteShellCommandPara( { TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], cmd)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse cmd parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "convert cmd failed"); return nullptr; } if (!ParseTimeoutCallbackPara(env, info, opt, timeout)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse timeOut callback parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } return CreateJsNull(env); @@ -1307,18 +1304,18 @@ napi_value JSAbilityDelegator::ParseAbilityCommonPara( { TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!ParseAbilityPara(env, info.argv[INDEX_ZERO], remoteObject)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse ability parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse ability param failed"); return nullptr; } if (info.argc > ARGC_ONE) { if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse ability callback parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } } @@ -1330,18 +1327,18 @@ napi_value JSAbilityDelegator::ParseStartAbilityPara( { TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse want parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse want param failed"); return nullptr; } if (info.argc > ARGC_ONE) { if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse StartAbility callback parameters failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } } @@ -1353,23 +1350,23 @@ napi_value JSAbilityDelegator::ParseFinishTestPara( { TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return nullptr; } if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], msg)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse msg parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "convert msg failed"); return nullptr; } if (!ConvertFromJsValue(env, info.argv[INDEX_ONE], code)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Parse code para parameter failed"); + TAG_LOGE(AAFwkTag::DELEGATOR, "convert code failed"); return nullptr; } if (info.argc > ARGC_TWO) { if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_TWO], napi_function)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect Callback Function type"); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed"); return nullptr; } } @@ -1379,20 +1376,20 @@ napi_value JSAbilityDelegator::ParseFinishTestPara( bool JSAbilityDelegator::ParseMockListPara( napi_env env, NapiCallbackInfo& info, std::map &mockList) { - TAG_LOGD(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); if (info.argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc"); return false; } napi_value value = info.argv[INDEX_ZERO]; if (value == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "The arg[0] is nullptr."); + TAG_LOGE(AAFwkTag::DELEGATOR, "null arg[0]"); return false; } if (!CheckTypeForNapiValue(env, value, napi_object)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "The type of arg[0] is not napi_object."); + TAG_LOGE(AAFwkTag::DELEGATOR, "arg[0] not napi_object"); return false; } @@ -1400,7 +1397,7 @@ bool JSAbilityDelegator::ParseMockListPara( napi_value array = nullptr; napi_get_property_names(env, value, &array); if (!ParseArrayStringValue(env, array, propNames)) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to property names."); + TAG_LOGE(AAFwkTag::DELEGATOR, "parse propNames failed"); return false; } @@ -1408,19 +1405,19 @@ bool JSAbilityDelegator::ParseMockListPara( napi_value prop = nullptr; napi_get_named_property(env, value, propName.c_str(), &prop); if (prop == nullptr) { - TAG_LOGW(AAFwkTag::DELEGATOR, "Prop is null: %{public}s", propName.c_str()); + TAG_LOGW(AAFwkTag::DELEGATOR, "null Prop: %{public}s", propName.c_str()); continue; } if (!CheckTypeForNapiValue(env, prop, napi_string)) { - TAG_LOGW(AAFwkTag::DELEGATOR, "Prop is not string: %{public}s", propName.c_str()); + TAG_LOGW(AAFwkTag::DELEGATOR, "prop not string: %{public}s", propName.c_str()); continue; } std::string valName; if (!ConvertFromJsValue(env, prop, valName)) { - TAG_LOGW(AAFwkTag::DELEGATOR, "Failed to ConvertFromJsValue: %{public}s", propName.c_str()); + TAG_LOGW(AAFwkTag::DELEGATOR, "convert valName failed: %{public}s", propName.c_str()); continue; } - TAG_LOGD(AAFwkTag::DELEGATOR, "add mock list: key: %{public}s, value: %{public}s", propName.c_str(), + TAG_LOGD(AAFwkTag::DELEGATOR, "key: %{public}s, value: %{public}s", propName.c_str(), valName.c_str()); mockList.emplace(propName, valName); } @@ -1431,12 +1428,12 @@ bool JSAbilityDelegator::ParseArrayStringValue( napi_env env, napi_value array, std::vector &vector) { if (array == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "array is nullptr!"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null array"); return false; } bool isArray = false; if (napi_is_array(env, array, &isArray) != napi_ok || isArray == false) { - TAG_LOGE(AAFwkTag::DELEGATOR, "not array!"); + TAG_LOGE(AAFwkTag::DELEGATOR, "not array"); return false; } @@ -1451,7 +1448,7 @@ bool JSAbilityDelegator::ParseArrayStringValue( napi_value jsValue = nullptr; napi_get_element(env, array, i, &jsValue); if (!ConvertFromJsValue(env, jsValue, strItem)) { - TAG_LOGW(AAFwkTag::DELEGATOR, "Failed to ConvertFromJsValue, index: %{public}u", i); + TAG_LOGW(AAFwkTag::DELEGATOR, "convert jsValue failed, i: %{public}u", i); continue; } vector.emplace_back(std::move(strItem)); @@ -1463,11 +1460,11 @@ void JSAbilityDelegator::AddStageMonitorRecord( napi_env env, napi_value value, const std::shared_ptr &monitor) { if (!value) { - TAG_LOGE(AAFwkTag::DELEGATOR, "UpdateStageMonitorRecord value is empty"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null value"); return; } if (!AbilityDelegatorRegistry::GetAbilityDelegator()) { - TAG_LOGE(AAFwkTag::DELEGATOR, "AbilityDelegator is null"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return; } std::shared_ptr reference = nullptr; @@ -1478,17 +1475,17 @@ void JSAbilityDelegator::AddStageMonitorRecord( std::unique_lock lck(g_mtxStageMonitorRecord); g_stageMonitorRecord.emplace(reference, monitor); } - TAG_LOGI(AAFwkTag::DELEGATOR, "g_stageMonitorRecord added, size = %{public}zu", g_stageMonitorRecord.size()); + TAG_LOGI(AAFwkTag::DELEGATOR, "end, size: %{public}zu", g_stageMonitorRecord.size()); } void JSAbilityDelegator::RemoveStageMonitorRecord(napi_env env, napi_value value) { if (!value) { - TAG_LOGE(AAFwkTag::DELEGATOR, "UpdateStageMonitorRecord value is empty"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null value"); return; } if (!AbilityDelegatorRegistry::GetAbilityDelegator()) { - TAG_LOGE(AAFwkTag::DELEGATOR, "AbilityDelegator is null"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator"); return; } std::unique_lock lck(g_mtxStageMonitorRecord); @@ -1498,8 +1495,7 @@ void JSAbilityDelegator::RemoveStageMonitorRecord(napi_env env, napi_value value napi_strict_equals(env, value, jsMonitor->GetNapiValue(), &isEquals); if (isEquals) { g_stageMonitorRecord.erase(iter); - TAG_LOGI( - AAFwkTag::DELEGATOR, "g_stageMonitorRecord removed, size = %{public}zu", g_stageMonitorRecord.size()); + TAG_LOGI(AAFwkTag::DELEGATOR, "end, size: %{public}zu", g_stageMonitorRecord.size()); break; } } diff --git a/frameworks/js/napi/app/ability_delegator/js_ability_delegator_registry.cpp b/frameworks/js/napi/app/ability_delegator/js_ability_delegator_registry.cpp index 7e71ad1a1d..d5b4bac48e 100644 --- a/frameworks/js/napi/app/ability_delegator/js_ability_delegator_registry.cpp +++ b/frameworks/js/napi/app/ability_delegator/js_ability_delegator_registry.cpp @@ -56,7 +56,7 @@ private: { TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (!AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator()) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get delegator object"); + TAG_LOGE(AAFwkTag::DELEGATOR, "get delegator failed"); return CreateJsNull(env); } @@ -77,7 +77,7 @@ private: std::shared_ptr abilityDelegatorArgs = AppExecFwk::AbilityDelegatorRegistry::GetArguments(); if (!abilityDelegatorArgs) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get delegator args object"); + TAG_LOGE(AAFwkTag::DELEGATOR, "get delegator args object failed"); return CreateJsNull(env); } return CreateJsAbilityDelegatorArguments(env, abilityDelegatorArgs); @@ -89,7 +89,7 @@ napi_value JsAbilityDelegatorRegistryInit(napi_env env, napi_value exportObj) { TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (env == nullptr || exportObj == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid input parameters"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null env or exportObj"); return nullptr; } @@ -112,14 +112,14 @@ napi_value AbilityLifecycleStateInit(napi_env env) TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (env == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid input arguments"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null env"); return nullptr; } napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get object"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null objValue"); return nullptr; } napi_set_named_property(env, objValue, "UNINITIALIZED", diff --git a/frameworks/js/napi/app/ability_delegator/js_ability_delegator_utils.cpp b/frameworks/js/napi/app/ability_delegator/js_ability_delegator_utils.cpp index bde1102ae6..129f4b5916 100644 --- a/frameworks/js/napi/app/ability_delegator/js_ability_delegator_utils.cpp +++ b/frameworks/js/napi/app/ability_delegator/js_ability_delegator_utils.cpp @@ -30,7 +30,7 @@ napi_value CreateJsAbilityDelegator(napi_env env) napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get object"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null objValue"); return nullptr; } @@ -74,7 +74,7 @@ napi_value SetAbilityDelegatorArgumentsPara(napi_env env, const std::map TAG_LOGI(AAFwkTag::DELEGATOR, "called"); if (!shellResult) { - TAG_LOGE(AAFwkTag::DELEGATOR, "shellResult is null"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null shellResult"); return nullptr; } napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get object"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null objValue"); return nullptr; } diff --git a/frameworks/js/napi/app/ability_delegator/js_ability_monitor.cpp b/frameworks/js/napi/app/ability_delegator/js_ability_monitor.cpp index c07f6ded1f..e1d2005a79 100644 --- a/frameworks/js/napi/app/ability_delegator/js_ability_monitor.cpp +++ b/frameworks/js/napi/app/ability_delegator/js_ability_monitor.cpp @@ -31,70 +31,56 @@ JSAbilityMonitor::JSAbilityMonitor(const std::string &abilityName, const std::st void JSAbilityMonitor::OnAbilityCreate(const std::weak_ptr &abilityObj) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); - + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); CallLifecycleCBFunction("onAbilityCreate", abilityObj); - - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void JSAbilityMonitor::OnAbilityForeground(const std::weak_ptr &abilityObj) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); - + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); CallLifecycleCBFunction("onAbilityForeground", abilityObj); - - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void JSAbilityMonitor::OnAbilityBackground(const std::weak_ptr &abilityObj) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); - + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); CallLifecycleCBFunction("onAbilityBackground", abilityObj); - - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void JSAbilityMonitor::OnAbilityDestroy(const std::weak_ptr &abilityObj) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); - + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); CallLifecycleCBFunction("onAbilityDestroy", abilityObj); - - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void JSAbilityMonitor::OnWindowStageCreate(const std::weak_ptr &abilityObj) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); - + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); CallLifecycleCBFunction("onWindowStageCreate", abilityObj); - - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void JSAbilityMonitor::OnWindowStageRestore(const std::weak_ptr &abilityObj) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); - + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); CallLifecycleCBFunction("onWindowStageRestore", abilityObj); - - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void JSAbilityMonitor::OnWindowStageDestroy(const std::weak_ptr &abilityObj) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); - + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); CallLifecycleCBFunction("onWindowStageDestroy", abilityObj); - - TAG_LOGI(AAFwkTag::DELEGATOR, "end"); + TAG_LOGD(AAFwkTag::DELEGATOR, "end"); } void JSAbilityMonitor::SetJsAbilityMonitor(napi_value jsAbilityMonitor) { - TAG_LOGI(AAFwkTag::DELEGATOR, "enter"); + TAG_LOGD(AAFwkTag::DELEGATOR, "called"); napi_ref ref = nullptr; napi_create_reference(env_, jsAbilityMonitor, 1, &ref); @@ -105,25 +91,25 @@ napi_value JSAbilityMonitor::CallLifecycleCBFunction(const std::string &function const std::weak_ptr &abilityObj) { if (functionName.empty()) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid function name"); + TAG_LOGE(AAFwkTag::DELEGATOR, "empty funcName"); return nullptr; } if (!jsAbilityMonitor_) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid jsAbilityMonitor"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null jsAbilityMonitor"); return nullptr; } napi_value obj = jsAbilityMonitor_->GetNapiValue(); if (obj == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get object"); + TAG_LOGE(AAFwkTag::DELEGATOR, "null obj"); return nullptr; } napi_value method = nullptr; napi_get_named_property(env_, obj, functionName.data(), &method); if (method == nullptr) { - TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get %{public}s from object", functionName.data()); + TAG_LOGE(AAFwkTag::DELEGATOR, "null method: %{public}s", functionName.data()); return nullptr; } diff --git a/frameworks/js/napi/app/app_manager/js_app_manager.cpp b/frameworks/js/napi/app/app_manager/js_app_manager.cpp index 08a2c91963..81ca3dc77e 100644 --- a/frameworks/js/napi/app/app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/app_manager/js_app_manager.cpp @@ -83,19 +83,19 @@ public: static napi_value IsRunningInStabilityTest(napi_env env, napi_callback_info info) { - TAG_LOGD(AAFwkTag::APPMGR, "IsRunningInStabilityTest start."); + TAG_LOGD(AAFwkTag::APPMGR, "called"); GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnIsRunningInStabilityTest); } static napi_value KillProcessWithAccount(napi_env env, napi_callback_info info) { - TAG_LOGD(AAFwkTag::APPMGR, "KillProcessWithAccount start."); + TAG_LOGD(AAFwkTag::APPMGR, "called"); GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnKillProcessWithAccount); } static napi_value KillProcessesByBundleName(napi_env env, napi_callback_info info) { - TAG_LOGD(AAFwkTag::APPMGR, "KillProcessesByBundleName start."); + TAG_LOGD(AAFwkTag::APPMGR, "called"); GET_CB_INFO_AND_CALL(env, info, JsAppManager, OnKillProcessByBundleName); } @@ -123,11 +123,11 @@ private: TAG_LOGD(AAFwkTag::APPMGR, "called"); // only support 1 or 2 params if (argc != ARGC_ONE && argc != ARGC_TWO) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); return CreateJsUndefined(env); } if (appManager_ == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "appManager nullptr"); + TAG_LOGE(AAFwkTag::APPMGR, "null appManager"); return CreateJsUndefined(env); } static int64_t serialNumber = 0; @@ -141,7 +141,7 @@ private: } int32_t ret = appManager_->RegisterApplicationStateObserver(observer_, bundleNameList); if (ret == 0) { - TAG_LOGD(AAFwkTag::APPMGR, "success."); + TAG_LOGD(AAFwkTag::APPMGR, "success"); int64_t observerId = serialNumber; observer_->AddJsObserverObject(observerId, argv[INDEX_ZERO]); if (serialNumber < INT32_MAX) { @@ -151,7 +151,7 @@ private: } return CreateJsValue(env, observerId); } else { - TAG_LOGE(AAFwkTag::APPMGR, "failed error:%{public}d.", ret); + TAG_LOGE(AAFwkTag::APPMGR, "error:%{public}d", ret); return CreateJsUndefined(env); } } @@ -164,7 +164,7 @@ private: // only support 1 or 2 params if (argc != ARGC_ONE && argc != ARGC_TWO) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } else { // unwrap connectId @@ -172,44 +172,39 @@ private: bool isExist = observer_->FindObserverByObserverId(observerId); if (isExist) { // match id - TAG_LOGD(AAFwkTag::APPMGR, "find observer exist observer:%{public}d", static_cast(observerId)); + TAG_LOGD(AAFwkTag::APPMGR, "observer exist:%{public}d", static_cast(observerId)); } else { - TAG_LOGD(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast(observerId)); + TAG_LOGD(AAFwkTag::APPMGR, "observer not exist:%{public}d", static_cast(observerId)); errCode = ERR_NOT_OK; } } + NapiAsyncTask::CompleteCallback complete = + [appManager = appManager_, observer = observer_, observerId, errCode]( + napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + if (observer == nullptr || appManager == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "observer or appManager nullptr"); + task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "observer or appManager nullptr")); + return; + } + int32_t ret = appManager->UnregisterApplicationStateObserver(observer); + if (ret == 0 && observer->RemoveJsObserverObject(observerId)) { + task.Resolve(env, CreateJsUndefined(env)); + TAG_LOGD(AAFwkTag::APPMGR, "success size:%{public}zu", observer->GetJsObserverMapSize()); + } else { + TAG_LOGE(AAFwkTag::APPMGR, "failed error:%{public}d", ret); + task.Reject(env, CreateJsError(env, ret, "UnregisterApplicationStateObserver failed")); + } + }; + napi_value lastParam = (argc == ARGC_TWO) ? argv[INDEX_ONE] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [appManager = appManager_, observer = observer_, observerId, errCode, - env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; - return; - } - if (observer == nullptr || appManager == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "observer or appManager nullptr"); - task->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "observer or appManager nullptr")); - delete task; - return; - } - int32_t ret = appManager->UnregisterApplicationStateObserver(observer); - if (ret == 0 && observer->RemoveJsObserverObject(observerId)) { - task->Resolve(env, CreateJsUndefined(env)); - TAG_LOGD(AAFwkTag::APPMGR, "success size:%{public}zu", observer->GetJsObserverMapSize()); - } else { - TAG_LOGE(AAFwkTag::APPMGR, "failed error:%{public}d", ret); - task->Reject(env, CreateJsError(env, ret, "UnregisterApplicationStateObserver failed")); - } - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + NapiAsyncTask::Schedule("JSAppManager::OnUnregisterApplicationStateObserver", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } @@ -220,41 +215,35 @@ private: // only support 0 or 1 params if (argc != ARGC_ZERO && argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } + NapiAsyncTask::CompleteCallback complete = + [appManager = appManager_, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + if (appManager == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "appManager nullptr"); + task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "appManager nullptr")); + return; + } + std::vector list; + int32_t ret = appManager->GetForegroundApplications(list); + if (ret == 0) { + TAG_LOGD(AAFwkTag::APPMGR, "success."); + task.Resolve(env, CreateJsAppStateDataArray(env, list)); + } else { + TAG_LOGE(AAFwkTag::APPMGR, "failed error:%{public}d", ret); + task.Reject(env, CreateJsError(env, ret, "OnGetForegroundApplications failed")); + } + }; napi_value lastParam = (argc == ARGC_ONE) ? argv[INDEX_ZERO] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [appManager = appManager_, errCode, env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; - return; - } - if (appManager == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "appManager nullptr"); - task->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "appManager nullptr")); - delete task; - return; - } - std::vector list; - int32_t ret = appManager->GetForegroundApplications(list); - if (ret == 0) { - TAG_LOGD(AAFwkTag::APPMGR, "success."); - task->Resolve(env, CreateJsAppStateDataArray(env, list)); - } else { - TAG_LOGE(AAFwkTag::APPMGR, "failed error:%{public}d", ret); - task->Reject(env, CreateJsError(env, ret, "OnGetForegroundApplications failed")); - } - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + NapiAsyncTask::Schedule("JSAppManager::OnGetForegroundApplications", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } @@ -265,33 +254,28 @@ private: // only support 0 or 1 params if (argc != ARGC_ZERO && argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } + NapiAsyncTask::CompleteCallback complete = + [appManager = appManager_, errCode](napi_env env, NapiAsyncTask &task, int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + std::vector infos; + auto ret = appManager->GetAllRunningProcesses(infos); + if (ret == 0) { + task.Resolve(env, CreateJsProcessRunningInfoArray(env, infos)); + } else { + task.Reject(env, CreateJsError(env, ret, "Get mission infos failed.")); + } + }; napi_value lastParam = (argc == ARGC_ONE) ? argv[INDEX_ZERO] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [appManager = appManager_, errCode, env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; - return; - } - std::vector infos; - auto ret = appManager->GetAllRunningProcesses(infos); - if (ret == 0) { - task->Resolve(env, CreateJsProcessRunningInfoArray(env, infos)); - } else { - task->Reject(env, CreateJsError(env, ret, "Get mission infos failed.")); - } - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + NapiAsyncTask::Schedule("JSAppManager::OnGetProcessRunningInfos", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } @@ -302,54 +286,32 @@ private: // only support 0 or 1 params if (argc != ARGC_ZERO && argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough arguments"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } + NapiAsyncTask::CompleteCallback complete = + [abilityManager = abilityManager_, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + if (abilityManager == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); + task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); + return; + } + bool ret = abilityManager->IsRunningInStabilityTest(); + TAG_LOGI(AAFwkTag::APPMGR, "result:%{public}d", ret); + task.Resolve(env, CreateJsValue(env, ret)); + }; napi_value lastParam = (argc == ARGC_ONE) ? argv[INDEX_ZERO] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [abilityManager = abilityManager_, errCode, env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; - return; - } - if (abilityManager == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); - task->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); - delete task; - return; - } - bool ret = abilityManager->IsRunningInStabilityTest(); - TAG_LOGI(AAFwkTag::APPMGR, "result:%{public}d", ret); - task->Resolve(env, CreateJsValue(env, ret)); - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + NapiAsyncTask::Schedule("JSAppManager::OnIsRunningInStabilityTest", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } - static void OnKillProcessByBundleNameInner(std::string bundleName, bool clearPageStack, - sptr abilityManager, napi_env env, NapiAsyncTask *task) - { - if (abilityManager == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "abilityManager null"); - task->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); - return; - } - auto ret = abilityManager->KillProcess(bundleName, clearPageStack); - if (ret == 0) { - task->Resolve(env, CreateJsValue(env, ret)); - } else { - task->Reject(env, CreateJsError(env, ret, "kill process failed.")); - } - } - napi_value OnKillProcessByBundleName(napi_env env, size_t argc, napi_value* argv) { TAG_LOGD(AAFwkTag::APPMGR, "called"); @@ -360,41 +322,47 @@ private: int32_t appIndex = 0; // only support 1 or 2 or 3 params if (argc != ARGC_ONE && argc != ARGC_TWO && argc != ARGC_THREE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough arguments"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } else { if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); + TAG_LOGE(AAFwkTag::APPMGR, "convert bundleName failed"); errCode = ERR_NOT_OK; } if (argc > ARGC_ONE && ConvertFromJsValue(env, argv[INDEX_ONE], clearPageStack)) { hasClearPageStack = true; } if (hasClearPageStack && argc == ARGC_THREE && !ConvertFromJsValue(env, argv[INDEX_TWO], appIndex)) { - TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed!"); + TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed"); errCode = ERR_NOT_OK; } } TAG_LOGI(AAFwkTag::APPMGR, - "kill [%{public}s], hasClearPageStack [%{public}d], clearPageStack [%{public}d],appIndex [%{public}d]", + "kill:%{public}s,hasClearPageStack:%{public}d,clearPageStack:%{public}d,appIndex:%{public}d", bundleName.c_str(), hasClearPageStack, clearPageStack, appIndex); + NapiAsyncTask::CompleteCallback complete = + [bundleName, clearPageStack, abilityManager = abilityManager_, errCode](napi_env env, NapiAsyncTask& task, + int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + if (abilityManager == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "abilityManager null"); + task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); + return; + } + auto ret = abilityManager->KillProcess(bundleName, clearPageStack); + if (ret == 0) { + task.Resolve(env, CreateJsValue(env, ret)); + } else { + task.Reject(env, CreateJsError(env, ret, "kill process failed.")); + } + }; napi_value lastParam = (argc == ARGC_TWO && !hasClearPageStack) ? argv[INDEX_ONE] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [bundleName, clearPageStack, abilityManager = abilityManager_, errCode, - env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - } else { - OnKillProcessByBundleNameInner(bundleName, clearPageStack, abilityManager, env, task); - } - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + NapiAsyncTask::ScheduleHighQos("JSAppManager::OnKillProcessByBundleName", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } @@ -406,46 +374,41 @@ private: // only support 1 or 2 params if (argc != ARGC_ONE && argc != ARGC_TWO) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } else { if (!ConvertFromJsValue(env, argv[0], bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed!"); + TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed"); errCode = ERR_NOT_OK; } else { TAG_LOGI(AAFwkTag::APPMGR, "kill process [%{public}s]", bundleName.c_str()); } } - napi_value lastParam = (argc == ARGC_TWO) ? argv[INDEX_ONE] : nullptr; - napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [bundleName, appManager = appManager_, errCode, env, task = napiAsyncTask.get()]() { + NapiAsyncTask::CompleteCallback complete = + [bundleName, appManager = appManager_, errCode](napi_env env, NapiAsyncTask& task, + int32_t status) { if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); return; } if (appManager == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "appManager nullptr"); - task->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "appManager nullptr")); - delete task; + TAG_LOGW(AAFwkTag::APPMGR, "null appManager"); + task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "appManager nullptr")); return; } auto ret = appManager->ClearUpApplicationData(bundleName, 0); if (ret == 0) { - task->Resolve(env, CreateJsValue(env, ret)); + task.Resolve(env, CreateJsValue(env, ret)); } else { - task->Reject(env, CreateJsError(env, AAFwk::CLEAR_APPLICATION_DATA_FAIL, - "clear up application failed.")); + task.Reject(env, CreateJsError(env, ret, "clear up application failed.")); } - delete task; }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_high)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + + napi_value lastParam = (argc == ARGC_TWO) ? argv[INDEX_ONE] : nullptr; + napi_value result = nullptr; + NapiAsyncTask::Schedule("JSAppManager::OnClearUpApplicationData", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } @@ -460,53 +423,47 @@ private: int32_t appIndex = 0; // only support 2 or 3 or 4 params if (argc != ARGC_TWO && argc != ARGC_THREE && argc != ARGC_FOUR) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } else { if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "Parse bundleName failed"); + TAG_LOGE(AAFwkTag::APPMGR, "convert bundleName failed"); errCode = ERR_NOT_OK; } if (!ConvertFromJsValue(env, argv[INDEX_ONE], accountId)) { - TAG_LOGE(AAFwkTag::APPMGR, "Parse userId failed"); + TAG_LOGE(AAFwkTag::APPMGR, "convert userId failed"); errCode = ERR_NOT_OK; } if (argc > ARGC_TWO && ConvertFromJsValue(env, argv[INDEX_TWO], clearPageStack)) { hasClearPageStack = true; } if (hasClearPageStack && argc == ARGC_FOUR && !ConvertFromJsValue(env, argv[INDEX_THREE], appIndex)) { - TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed!"); + TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed"); errCode = ERR_NOT_OK; } } TAG_LOGI(AAFwkTag::APPMGR, "kill [%{public}s], hasClearPageStack [%{public}d], clearPageStack [%{public}d],appIndex [%{public}d]", bundleName.c_str(), hasClearPageStack, clearPageStack, appIndex); + NapiAsyncTask::CompleteCallback complete = + [appManager = appManager_, bundleName, accountId, clearPageStack, errCode]( + napi_env env, NapiAsyncTask &task, int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + auto ret = appManager->GetAmsMgr()->KillProcessWithAccount(bundleName, accountId, clearPageStack); + if (ret == 0) { + task.Resolve(env, CreateJsUndefined(env)); + } else { + TAG_LOGD(AAFwkTag::APPMGR, "failed error:%{public}d", ret); + task.Reject(env, CreateJsError(env, ret, "Kill processes failed.")); + } + }; napi_value lastParam = (argc == ARGC_THREE) ? argv[INDEX_TWO] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [appManager = appManager_, bundleName, accountId, clearPageStack, errCode, - env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; - return; - } - auto ret = appManager->GetAmsMgr()->KillProcessWithAccount(bundleName, accountId, clearPageStack); - if (ret == 0) { - task->Resolve(env, CreateJsUndefined(env)); - } else { - TAG_LOGD(AAFwkTag::APPMGR, "failed error:%{public}d", ret); - task->Reject(env, CreateJsError(env, ret, "Kill processes failed.")); - } - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } - TAG_LOGD(AAFwkTag::APPMGR, "end"); + NapiAsyncTask::ScheduleHighQos("JSAppManager::OnKillProcessWithAccount", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } @@ -516,35 +473,30 @@ private: // only support 0 or 1 params if (argc != ARGC_ZERO && argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Insufficient params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } + NapiAsyncTask::CompleteCallback complete = + [abilityManager = abilityManager_, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + if (abilityManager == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); + task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); + return; + } + int32_t memorySize = abilityManager->GetAppMemorySize(); + TAG_LOGI(AAFwkTag::APPMGR, "memorySize:%{public}d", memorySize); + task.Resolve(env, CreateJsValue(env, memorySize)); + }; + napi_value lastParam = (argc == ARGC_ONE) ? argv[INDEX_ZERO] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [abilityManager = abilityManager_, errCode, env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; - return; - } - if (abilityManager == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); - task->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); - delete task; - return; - } - int32_t memorySize = abilityManager->GetAppMemorySize(); - TAG_LOGI(AAFwkTag::APPMGR, "memorySize:%{public}d", memorySize); - task->Resolve(env, CreateJsValue(env, memorySize)); - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + NapiAsyncTask::ScheduleHighQos("JSAppManager::OnGetAppMemorySize", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } @@ -554,35 +506,30 @@ private: // only support 0 or 1 params if (argc != ARGC_ZERO && argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough parameters"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); errCode = ERR_NOT_OK; } + NapiAsyncTask::CompleteCallback complete = + [abilityManager = abilityManager_, errCode](napi_env env, NapiAsyncTask& task, int32_t status) { + if (errCode != 0) { + task.Reject(env, CreateJsError(env, errCode, "Invalidate params.")); + return; + } + if (abilityManager == nullptr) { + TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); + task.Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); + return; + } + bool ret = abilityManager->IsRamConstrainedDevice(); + TAG_LOGI(AAFwkTag::APPMGR, "result:%{public}d", ret); + task.Resolve(env, CreateJsValue(env, ret)); + }; + napi_value lastParam = (argc == ARGC_ONE) ? argv[INDEX_ZERO] : nullptr; napi_value result = nullptr; - std::unique_ptr napiAsyncTask = CreateEmptyAsyncTask(env, lastParam, &result); - auto asyncTask = [abilityManager = abilityManager_, errCode, env, task = napiAsyncTask.get()]() { - if (errCode != 0) { - task->Reject(env, CreateJsError(env, errCode, "Invalidate params.")); - delete task; - return; - } - if (abilityManager == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "abilityManager nullptr"); - task->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "abilityManager nullptr")); - delete task; - return; - } - bool ret = abilityManager->IsRamConstrainedDevice(); - TAG_LOGI(AAFwkTag::APPMGR, "result:%{public}d", ret); - task->Resolve(env, CreateJsValue(env, ret)); - delete task; - }; - if (napi_status::napi_ok != napi_send_event(env, asyncTask, napi_eprio_immediate)) { - napiAsyncTask->Reject(env, CreateJsError(env, ERROR_CODE_ONE, "send event failed")); - } else { - napiAsyncTask.release(); - } + NapiAsyncTask::ScheduleHighQos("JSAppManager::OnIsRamConstrainedDevice", + env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); return result; } }; @@ -607,9 +554,9 @@ OHOS::sptr GetAbilityManagerInstance() napi_value JsAppManagerInit(napi_env env, napi_value exportObj) { - TAG_LOGD(AAFwkTag::APPMGR, "JsAppManagerInit start"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (env == nullptr || exportObj == nullptr) { - TAG_LOGW(AAFwkTag::APPMGR, "env or exportObj null"); + TAG_LOGW(AAFwkTag::APPMGR, "null env or exportObj"); return nullptr; } diff --git a/frameworks/js/napi/app/app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/app_manager/js_app_manager_utils.cpp index 2f2bb97371..c449b99a55 100644 --- a/frameworks/js/napi/app/app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/app_manager/js_app_manager_utils.cpp @@ -30,13 +30,13 @@ napi_value CreateJsAppStateData(napi_env env, const AppStateData &appStateData) napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, appStateData.bundleName)); napi_set_named_property(env, object, "uid", CreateJsValue(env, appStateData.uid)); napi_set_named_property(env, object, "state", CreateJsValue(env, appStateData.state)); - TAG_LOGI(AAFwkTag::APPMGR, "end."); + TAG_LOGD(AAFwkTag::APPMGR, "end"); return object; } @@ -46,7 +46,7 @@ napi_value CreateJsAbilityStateData(napi_env env, const AbilityStateData &abilit napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, abilityStateData.bundleName)); @@ -58,7 +58,7 @@ napi_value CreateJsAbilityStateData(napi_env env, const AbilityStateData &abilit napi_set_named_property(env, object, "abilityType", CreateJsValue(env, abilityStateData.abilityType)); napi_set_named_property(env, object, "isAtomicService", CreateJsValue(env, abilityStateData.isAtomicService)); - TAG_LOGD(AAFwkTag::APPMGR, "end."); + TAG_LOGD(AAFwkTag::APPMGR, "end"); return object; } @@ -68,7 +68,7 @@ napi_value CreateJsProcessData(napi_env env, const ProcessData &processData) napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, processData.bundleName)); @@ -77,7 +77,7 @@ napi_value CreateJsProcessData(napi_env env, const ProcessData &processData) napi_set_named_property(env, object, "state", CreateJsValue(env, processData.state)); napi_set_named_property(env, object, "isContinuousTask", CreateJsValue(env, processData.isContinuousTask)); napi_set_named_property(env, object, "isKeepAlive", CreateJsValue(env, processData.isKeepAlive)); - TAG_LOGD(AAFwkTag::APPMGR, "end."); + TAG_LOGD(AAFwkTag::APPMGR, "end"); return object; } @@ -108,7 +108,7 @@ napi_value CreateJsProcessRunningInfo(napi_env env, const RunningProcessInfo &in napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "processName", CreateJsValue(env, info.processName_)); @@ -140,7 +140,7 @@ JsAppProcessState ConvertToJsAppProcessState( processState = STATE_DESTROY; break; default: - TAG_LOGE(AAFwkTag::APPMGR, "Process state is invalid."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid state"); processState = STATE_DESTROY; break; } diff --git a/frameworks/js/napi/app/app_manager/js_app_state_observer.cpp b/frameworks/js/napi/app/app_manager/js_app_state_observer.cpp index 158069790f..522ccf2e9b 100644 --- a/frameworks/js/napi/app/app_manager/js_app_state_observer.cpp +++ b/frameworks/js/napi/app/app_manager/js_app_state_observer.cpp @@ -92,7 +92,7 @@ void JSAppStateObserver::OnExtensionStateChanged(const AbilityStateData &ability ([jsObserver, abilityStateData](napi_env env, NapiAsyncTask &task, int32_t status) { sptr jsObserverSptr = jsObserver.promote(); if (!jsObserverSptr) { - TAG_LOGW(AAFwkTag::APPMGR, "jsObserverSptr nullptr"); + TAG_LOGW(AAFwkTag::APPMGR, "null jsObserver"); return; } jsObserverSptr->HandleOnExtensionStateChanged(abilityStateData); @@ -121,7 +121,7 @@ void JSAppStateObserver::OnProcessCreated(const ProcessData &processData) ([jsObserver, processData](napi_env env, NapiAsyncTask &task, int32_t status) { sptr jsObserverSptr = jsObserver.promote(); if (!jsObserverSptr) { - TAG_LOGW(AAFwkTag::APPMGR, "jsObserverSptr nullptr"); + TAG_LOGW(AAFwkTag::APPMGR, "null jsObserver"); return; } jsObserverSptr->HandleOnProcessCreated(processData); @@ -206,14 +206,14 @@ void JSAppStateObserver::CallJsFunction( { TAG_LOGD(AAFwkTag::APPMGR, "CallJsFunction start, method:%{public}s", methodName); if (value == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to get object"); + TAG_LOGE(AAFwkTag::APPMGR, "null value"); return; } napi_value method = nullptr; napi_get_named_property(env_, value, methodName, &method); if (method == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Wrong to get from object"); + TAG_LOGE(AAFwkTag::APPMGR, "null method"); return; } napi_value callResult = nullptr; @@ -223,7 +223,7 @@ void JSAppStateObserver::CallJsFunction( void JSAppStateObserver::AddJsObserverObject(const int32_t observerId, napi_value jsObserverObject) { - TAG_LOGD(AAFwkTag::APPMGR, "AddJsObserverObject start."); + TAG_LOGD(AAFwkTag::APPMGR, "called"); napi_ref ref = nullptr; napi_create_reference(env_, jsObserverObject, 1, &ref); jsObserverObjectMap_.emplace(observerId, std::shared_ptr(reinterpret_cast(ref))); @@ -231,7 +231,7 @@ void JSAppStateObserver::AddJsObserverObject(const int32_t observerId, napi_valu bool JSAppStateObserver::RemoveJsObserverObject(const int32_t observerId) { - TAG_LOGD(AAFwkTag::APPMGR, "RemoveJsObserverObject start."); + TAG_LOGD(AAFwkTag::APPMGR, "called"); bool result = (jsObserverObjectMap_.erase(observerId) == 1); return result; } @@ -245,7 +245,7 @@ bool JSAppStateObserver::FindObserverByObserverId(const int32_t observerId) size_t JSAppStateObserver::GetJsObserverMapSize() { - TAG_LOGD(AAFwkTag::APPMGR, "GetJsObserverMapSize start"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); size_t length = jsObserverObjectMap_.size(); return length; } diff --git a/frameworks/js/napi/app/error_manager/js_error_manager.cpp b/frameworks/js/napi/app/error_manager/js_error_manager.cpp index 1a838d7e58..03541d1fca 100644 --- a/frameworks/js/napi/app/error_manager/js_error_manager.cpp +++ b/frameworks/js/napi/app/error_manager/js_error_manager.cpp @@ -141,7 +141,7 @@ public: static void Finalizer(napi_env env, void* data, void* hint) { - TAG_LOGI(AAFwkTag::JSNAPI, "JsErrorManager Finalizer is called"); + TAG_LOGI(AAFwkTag::JSNAPI, "finalizer called"); std::unique_ptr(static_cast(data)); ClearReference(env); } @@ -209,7 +209,7 @@ private: } if (type == ON_OFF_TYPE_SYNC_LOOP) { if (!AppExecFwk::EventRunner::IsAppMainThread()) { - TAG_LOGE(AAFwkTag::JSNAPI, "LoopObserver can only be set from main thread."); + TAG_LOGE(AAFwkTag::JSNAPI, "not mainThread"); ThrowInvalidCallerError(env); return CreateJsUndefined(env); } @@ -217,7 +217,7 @@ private: } if (type == ON_OFF_TYPE_UNHANDLED_REJECTION) { if (argc != ARGC_TWO) { - TAG_LOGE(AAFwkTag::JSNAPI, "The number of params is invalid."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); ThrowInvalidNumParametersError(env); return CreateJsUndefined(env); } @@ -230,7 +230,7 @@ private: { TAG_LOGD(AAFwkTag::JSNAPI, "called"); if (argc != ARGC_TWO) { - TAG_LOGE(AAFwkTag::JSNAPI, "The param is invalid, observers need."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -238,7 +238,7 @@ private: std::string type; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], type) || type != ON_OFF_TYPE) { ThrowInvalidParamError(env, "Parameter error: Parse type failed, must be a string error."); - TAG_LOGE(AAFwkTag::JSNAPI, "Parse type failed"); + TAG_LOGE(AAFwkTag::JSNAPI, "parse type failed"); return CreateJsUndefined(env); } int32_t observerId = serialNumber_; @@ -249,7 +249,7 @@ private: } if (observer_ == nullptr) { - TAG_LOGD(AAFwkTag::JSNAPI, "observer_ is null."); + TAG_LOGD(AAFwkTag::JSNAPI, "null observer_"); // create observer observer_ = std::make_shared(env); AppExecFwk::ApplicationDataManager::GetInstance().AddErrorObserver(observer_); @@ -284,14 +284,14 @@ private: { TAG_LOGD(AAFwkTag::JSNAPI, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::JSNAPI, "The param is invalid, observers need."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } if (!CheckTypeForNapiValue(env, argv[INDEX_ONE], napi_object)) { - TAG_LOGE(AAFwkTag::JSNAPI, "Invalid param"); - ThrowInvalidParamError(env, "Parameter error: Parse ovserver failed, must be a ErrorObserver."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid param"); + ThrowInvalidParamError(env, "Parameter error: Parse observer failed, must be a ErrorObserver."); return CreateJsUndefined(env); } @@ -320,7 +320,7 @@ private: } if (type == ON_OFF_TYPE_SYNC_LOOP) { if (!AppExecFwk::EventRunner::IsAppMainThread()) { - TAG_LOGE(AAFwkTag::JSNAPI, "LoopObserver can only be set from main thread."); + TAG_LOGE(AAFwkTag::JSNAPI, "not mainThread"); ThrowInvalidCallerError(env); return CreateJsUndefined(env); } @@ -328,7 +328,7 @@ private: } if (type == ON_OFF_TYPE_UNHANDLED_REJECTION) { if (argc != ARGC_TWO && argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "The number of params is invalid."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); ThrowInvalidNumParametersError(env); return CreateJsUndefined(env); } @@ -343,7 +343,7 @@ private: int32_t observerId = -1; if (argc != ARGC_TWO && argc != ARGC_THREE) { ThrowTooFewParametersError(env); - TAG_LOGE(AAFwkTag::JSNAPI, "not enough params."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); } else { napi_get_value_int32(env, argv[INDEX_ONE], &observerId); TAG_LOGI(AAFwkTag::JSNAPI, "observer:%{public}d", observerId); @@ -351,7 +351,7 @@ private: std::string type; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], type) || type != ON_OFF_TYPE) { - TAG_LOGE(AAFwkTag::JSNAPI, "Parse type failed"); + TAG_LOGE(AAFwkTag::JSNAPI, "parse type failed"); ThrowInvalidParamError(env, "Parameter error: Parse type failed, must be a string error."); return CreateJsUndefined(env); } @@ -359,7 +359,7 @@ private: NapiAsyncTask::CompleteCallback complete = [&observer = observer_, observerId]( napi_env env, NapiAsyncTask& task, int32_t status) { - TAG_LOGI(AAFwkTag::JSNAPI, "called"); + TAG_LOGI(AAFwkTag::JSNAPI, "complete called"); if (observerId == -1) { task.Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM)); return; @@ -407,7 +407,7 @@ private: return res; } } - TAG_LOGE(AAFwkTag::JSNAPI, "Remove UnhandledRejectionObserver failed"); + TAG_LOGE(AAFwkTag::JSNAPI, "remove observer failed"); ThrowError(env, AbilityErrorCode::ERROR_CODE_OBSERVER_NOT_FOUND); return res; } @@ -417,24 +417,24 @@ private: TAG_LOGD(AAFwkTag::JSNAPI, "called"); if (argc < ARGC_TWO) { ThrowTooFewParametersError(env); - TAG_LOGE(AAFwkTag::JSNAPI, "unregister errorObserver error, not enough params."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); return CreateJsUndefined(env); } int32_t observerId = -1; if (!ConvertFromJsValue(env, argv[INDEX_ONE], observerId)) { - TAG_LOGE(AAFwkTag::JSNAPI, "Parse observerId failed"); + TAG_LOGE(AAFwkTag::JSNAPI, "parse observerId failed"); ThrowInvalidParamError(env, "Parameter error: Parse observerId failed, must be a number."); return CreateJsUndefined(env); } if (observer_ == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "observer is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null observer"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } if (observer_->RemoveJsObserverObject(observerId, true)) { - TAG_LOGD(AAFwkTag::JSNAPI, "RemoveJsObserverObject success"); + TAG_LOGD(AAFwkTag::JSNAPI, "success"); } else { - TAG_LOGE(AAFwkTag::JSNAPI, "RemoveJsObserverObject failed"); + TAG_LOGE(AAFwkTag::JSNAPI, "failed"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_ID); } if (observer_->IsEmpty()) { @@ -447,16 +447,16 @@ private: static void CallJsFunction(napi_env env, napi_value obj, const char* methodName, napi_value const* argv, size_t argc) { - TAG_LOGI(AAFwkTag::JSNAPI, "CallJsFunction begin methodName: %{public}s", methodName); + TAG_LOGI(AAFwkTag::JSNAPI, "call func: %{public}s", methodName); if (obj == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "Failed to get object"); + TAG_LOGE(AAFwkTag::JSNAPI, "null obj"); return; } napi_value method = nullptr; napi_get_named_property(env, obj, methodName, &method); if (method == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "Failed to get method"); + TAG_LOGE(AAFwkTag::JSNAPI, "null method"); return; } napi_value callResult = nullptr; @@ -468,15 +468,15 @@ private: std::unique_ptr complete = std::make_unique ([number](napi_env env, NapiAsyncTask &task, int32_t status) { if (loopObserver_ == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "loopObserver_ is null."); + TAG_LOGE(AAFwkTag::JSNAPI, "null loopObserver_"); return; } if (loopObserver_->env == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "env is null."); + TAG_LOGE(AAFwkTag::JSNAPI, "null env"); return; } if (loopObserver_->observerObject == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "observerObject is null."); + TAG_LOGE(AAFwkTag::JSNAPI, "null observer"); return; } napi_value jsValue[] = { CreateJsValue(loopObserver_->env, number) }; @@ -494,28 +494,28 @@ private: napi_value OnSetLoopWatch(napi_env env, size_t argc, napi_value* argv) { if (argc != ARGC_THREE) { - TAG_LOGE(AAFwkTag::JSNAPI, "OnSetLoopWatch: Not enough params."); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } if (!CheckTypeForNapiValue(env, argv[INDEX_ONE], napi_number)) { - TAG_LOGE(AAFwkTag::JSNAPI, "OnSetLoopWatch: Invalid param"); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Failed to parse timeout, must be a number."); return CreateJsUndefined(env); } if (!CheckTypeForNapiValue(env, argv[INDEX_TWO], napi_object)) { - TAG_LOGE(AAFwkTag::JSNAPI, "OnSetLoopWatch: Invalid param"); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid param"); ThrowInvalidParamError(env, "Parameter error: Failed to parse observer, must be a LoopObserver."); return CreateJsUndefined(env); } int64_t number; if (!ConvertFromJsNumber(env, argv[INDEX_ONE], number)) { - TAG_LOGE(AAFwkTag::JSNAPI, "OnSetLoopWatch: Parse timeout failed"); + TAG_LOGE(AAFwkTag::JSNAPI, "parse timeout failed"); ThrowInvalidParamError(env, "Parameter error: Failed to parse timeout, must be a number."); return CreateJsUndefined(env); } if (number <= 0) { - TAG_LOGE(AAFwkTag::JSNAPI, "The timeout cannot be less than 0"); + TAG_LOGE(AAFwkTag::JSNAPI, "timeout<=0"); ThrowInvalidParamError(env, "Parameter error: The timeout cannot be less than 0."); return CreateJsUndefined(env); } @@ -538,7 +538,7 @@ private: if (loopObserver_) { loopObserver_.reset(); loopObserver_ = nullptr; - TAG_LOGI(AAFwkTag::JSNAPI, "Remove loopObserver success"); + TAG_LOGI(AAFwkTag::JSNAPI, "success"); } else { TAG_LOGI(AAFwkTag::JSNAPI, "called"); } @@ -559,7 +559,7 @@ private: if (function == nullptr || CheckTypeForNapiValue(env, function, napi_null) || CheckTypeForNapiValue(env, function, napi_undefined)) { - TAG_LOGE(AAFwkTag::JSNAPI, "function is invalid"); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid func"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INVALID_PARAM); return false; } @@ -573,16 +573,16 @@ private: napi_value JsErrorManagerInit(napi_env env, napi_value exportObj) { - TAG_LOGI(AAFwkTag::JSNAPI, "Js error manager Init."); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (env == nullptr || exportObj == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "env or exportObj null"); + TAG_LOGI(AAFwkTag::JSNAPI, "null env or exportObj"); return nullptr; } std::unique_ptr jsErrorManager = std::make_unique(); jsErrorManager->SetRejectionCallback(env); napi_wrap(env, exportObj, jsErrorManager.release(), JsErrorManager::Finalizer, nullptr, nullptr); - TAG_LOGI(AAFwkTag::JSNAPI, "JsErrorManager BindNativeFunction called"); + TAG_LOGD(AAFwkTag::JSNAPI, "bind func ready"); const char *moduleName = "JsErrorManager"; BindNativeFunction(env, exportObj, "on", moduleName, JsErrorManager::On); BindNativeFunction(env, exportObj, "off", moduleName, JsErrorManager::Off); diff --git a/frameworks/js/napi/app/error_manager/js_error_observer.cpp b/frameworks/js/napi/app/error_manager/js_error_observer.cpp index f91cc62ce6..d8b8842ae5 100644 --- a/frameworks/js/napi/app/error_manager/js_error_observer.cpp +++ b/frameworks/js/napi/app/error_manager/js_error_observer.cpp @@ -31,7 +31,7 @@ JsErrorObserver::~JsErrorObserver() = default; void JsErrorObserver::OnUnhandledException(const std::string errMsg) { - TAG_LOGD(AAFwkTag::JSNAPI, "OnUnhandledException come."); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); std::weak_ptr thisWeakPtr(shared_from_this()); std::unique_ptr complete = std::make_unique ([thisWeakPtr, errMsg](napi_env env, NapiAsyncTask &task, int32_t status) { @@ -48,7 +48,7 @@ void JsErrorObserver::OnUnhandledException(const std::string errMsg) void JsErrorObserver::HandleOnUnhandledException(const std::string &errMsg) { - TAG_LOGD(AAFwkTag::JSNAPI, "HandleOnUnhandledException come."); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); auto tmpMap = jsObserverObjectMap_; for (auto &item : tmpMap) { napi_value value = (item.second)->GetNapiValue(); @@ -65,7 +65,7 @@ void JsErrorObserver::HandleOnUnhandledException(const std::string &errMsg) void JsErrorObserver::CallJsFunction(napi_value obj, const char* methodName, napi_value const* argv, size_t argc) { - TAG_LOGD(AAFwkTag::JSNAPI, "called method:%{public}s", methodName); + TAG_LOGD(AAFwkTag::JSNAPI, "call method:%{public}s", methodName); if (obj == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "Failed to get object"); return; @@ -74,7 +74,7 @@ void JsErrorObserver::CallJsFunction(napi_value obj, const char* methodName, nap napi_value method = nullptr; napi_get_named_property(env_, obj, methodName, &method); if (method == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "Failed to get method"); + TAG_LOGE(AAFwkTag::JSNAPI, "null method"); return; } napi_value callResult = nullptr; @@ -113,7 +113,7 @@ bool JsErrorObserver::IsEmpty() void JsErrorObserver::OnExceptionObject(const AppExecFwk::ErrorObject &errorObj) { - TAG_LOGD(AAFwkTag::JSNAPI, "OnExceptionObject come."); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); std::weak_ptr thisWeakPtr(shared_from_this()); std::unique_ptr complete = std::make_unique ([thisWeakPtr, errorObj](napi_env env, NapiAsyncTask &task, int32_t status) { @@ -130,7 +130,7 @@ void JsErrorObserver::OnExceptionObject(const AppExecFwk::ErrorObject &errorObj) void JsErrorObserver::HandleException(const AppExecFwk::ErrorObject &errorObj) { - TAG_LOGD(AAFwkTag::JSNAPI, "HandleException come."); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); auto tmpMap = jsObserverObjectMap_; for (auto &item : tmpMap) { napi_value jsObj = (item.second)->GetNapiValue(); @@ -150,7 +150,7 @@ napi_value JsErrorObserver::CreateJsErrorObject(napi_env env, const AppExecFwk:: napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGW(AAFwkTag::JSNAPI, "invalid object."); + TAG_LOGW(AAFwkTag::JSNAPI, "null obj"); return objValue; } napi_set_named_property(env, objValue, "name", CreateJsValue(env, errorObj.name)); diff --git a/frameworks/js/napi/app/js_app_manager/js_ability_first_frame_state_observer.cpp b/frameworks/js/napi/app/js_app_manager/js_ability_first_frame_state_observer.cpp index 94ffa00e39..90c612b775 100644 --- a/frameworks/js/napi/app/js_app_manager/js_ability_first_frame_state_observer.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_ability_first_frame_state_observer.cpp @@ -35,7 +35,7 @@ void JSAbilityFirstFrameStateObserver::OnAbilityFirstFrameState( [self, abilityFirstFrameStateData](napi_env env, NapiAsyncTask &task, int32_t status) { sptr jsObserver = self.promote(); if (jsObserver == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Js Observer Sptr is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null js observer"); return; } jsObserver->HandleOnAbilityFirstFrameState(abilityFirstFrameStateData); @@ -59,27 +59,27 @@ void JSAbilityFirstFrameStateObserver::CallJsFunction( { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (value == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "value is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null value"); return; } napi_value method = nullptr; napi_get_named_property(env_, value, methodName, &method); if (method == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Get name from object Failed."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null method"); return; } napi_value callResult = nullptr; napi_status status = napi_call_function(env_, value, method, argc, argv, &callResult); if (status != napi_ok) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Call Js Function failed %{public}d.", status); + TAG_LOGE(AAFwkTag::ABILITYMGR, "call js func failed %{public}d", status); } } void JSAbilityFirstFrameStateObserver::SetJsObserverObject(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return; } napi_ref ref = nullptr; @@ -108,7 +108,7 @@ void JSAbilityFirstFrameStateObserverManager::AddJSAbilityFirstFrameStateObserve const sptr observer) { if (observer == nullptr || observer->GetNativeReference() == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return; } std::lock_guard lock(observerListLock_); @@ -118,10 +118,10 @@ void JSAbilityFirstFrameStateObserverManager::AddJSAbilityFirstFrameStateObserve bool JSAbilityFirstFrameStateObserverManager::IsObserverObjectExist(const napi_value &jsObserverObject) { if (GetObserverObject(jsObserverObject) == nullptr) { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "null observer"); return false; } - TAG_LOGD(AAFwkTag::ABILITYMGR, "Observer is exists."); + TAG_LOGD(AAFwkTag::ABILITYMGR, "observer exist"); return true; } @@ -130,7 +130,7 @@ void JSAbilityFirstFrameStateObserverManager::RemoveAllJsObserverObjects( { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (abilityManager == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityManager is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null abilityManager"); return; } std::lock_guard lock(observerListLock_); @@ -146,7 +146,7 @@ void JSAbilityFirstFrameStateObserverManager::RemoveJsObserverObject( { TAG_LOGD(AAFwkTag::ABILITYMGR, "called"); if (abilityManager == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityManager is nullptr."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null abilityManager"); return; } std::lock_guard lock(observerListLock_); @@ -155,7 +155,7 @@ void JSAbilityFirstFrameStateObserverManager::RemoveJsObserverObject( std::shared_ptr tmpObject = (*it)->GetNativeReference(); napi_value value = tmpObject->GetNapiValue(); if (value == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to get object."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null value"); continue; } bool isEqual = false; @@ -173,19 +173,19 @@ std::shared_ptr JSAbilityFirstFrameStateObserverManager::GetObs const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); return nullptr; } std::lock_guard lock(observerListLock_); for (auto &observer : jsAbilityFirstFrameStateObserverList_) { if (observer == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Invalid observer."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer"); continue; } std::shared_ptr tmpObject = observer->GetNativeReference(); napi_value value = tmpObject->GetNapiValue(); if (value == nullptr) { - TAG_LOGE(AAFwkTag::ABILITYMGR, "Failed to get object."); + TAG_LOGE(AAFwkTag::ABILITYMGR, "null value"); continue; } diff --git a/frameworks/js/napi/app/js_app_manager/js_app_foreground_state_observer.cpp b/frameworks/js/napi/app/js_app_manager/js_app_foreground_state_observer.cpp index 9fac524d68..bc0164e9c4 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_foreground_state_observer.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_foreground_state_observer.cpp @@ -29,7 +29,7 @@ void JSAppForegroundStateObserver::OnAppStateChanged(const AppStateData &appStat { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (!valid_) { - TAG_LOGE(AAFwkTag::APPMGR, "The app manager may has destroyed."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid appmgr"); return; } wptr self = this; @@ -37,7 +37,7 @@ void JSAppForegroundStateObserver::OnAppStateChanged(const AppStateData &appStat [self, appStateData](napi_env env, NapiAsyncTask &task, int32_t status) { sptr jsObserver = self.promote(); if (jsObserver == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Js Observer Sptr is nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null observer"); return; } jsObserver->HandleOnAppStateChanged(appStateData); @@ -61,30 +61,30 @@ void JSAppForegroundStateObserver::HandleOnAppStateChanged(const AppStateData &a void JSAppForegroundStateObserver::CallJsFunction( const napi_value value, const char *methodName, const napi_value *argv, const size_t argc) { - TAG_LOGD(AAFwkTag::APPMGR, "Begin."); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (value == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "value is nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null value"); return; } napi_value method = nullptr; napi_get_named_property(env_, value, methodName, &method); if (method == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Get name from object Failed."); + TAG_LOGE(AAFwkTag::APPMGR, "null method"); return; } napi_value callResult = nullptr; napi_status status = napi_call_function(env_, value, method, argc, argv, &callResult); if (status != napi_ok) { - TAG_LOGE(AAFwkTag::APPMGR, "Call Js Function failed %{public}d.", status); + TAG_LOGE(AAFwkTag::APPMGR, "call js func failed %{public}d.", status); } - TAG_LOGD(AAFwkTag::APPMGR, "End."); + TAG_LOGD(AAFwkTag::APPMGR, "end"); } void JSAppForegroundStateObserver::AddJsObserverObject(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::APPMGR, "null observer"); return; } @@ -94,7 +94,7 @@ void JSAppForegroundStateObserver::AddJsObserverObject(const napi_value &jsObser napi_create_reference(env_, jsObserverObject, 1, &ref); jsObserverObjectSet_.emplace(std::shared_ptr(reinterpret_cast(ref))); } else { - TAG_LOGD(AAFwkTag::APPMGR, "Observer is exists."); + TAG_LOGD(AAFwkTag::APPMGR, "observer exist"); } } @@ -107,7 +107,7 @@ void JSAppForegroundStateObserver::RemoveAllJsObserverObjects() void JSAppForegroundStateObserver::RemoveJsObserverObject(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::APPMGR, "null observer"); return; } @@ -121,20 +121,20 @@ void JSAppForegroundStateObserver::RemoveJsObserverObject(const napi_value &jsOb std::shared_ptr JSAppForegroundStateObserver::GetObserverObject(const napi_value &jsObserverObject) { if (jsObserverObject == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Observer is null."); + TAG_LOGE(AAFwkTag::APPMGR, "null observer"); return nullptr; } std::lock_guard lock(jsObserverObjectSetLock_); for (auto &observer : jsObserverObjectSet_) { if (observer == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Invalid observer."); + TAG_LOGE(AAFwkTag::APPMGR, "null observer"); continue; } napi_value value = observer->GetNapiValue(); if (value == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to get object."); + TAG_LOGE(AAFwkTag::APPMGR, "null value"); continue; } diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp index dbd4a6ec36..e88dec828d 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager.cpp @@ -71,7 +71,7 @@ public: ~JsAppManager() { if (observer_ != nullptr) { - TAG_LOGI(AAFwkTag::APPMGR, "Set valid false"); + TAG_LOGI(AAFwkTag::APPMGR, "set valid false"); observer_->SetValid(false); } if (observerForeground_ != nullptr) { @@ -81,7 +81,7 @@ public: static void Finalizer(napi_env env, void* data, void* hint) { - TAG_LOGI(AAFwkTag::APPMGR, "JsAbilityContext::Finalizer is called"); + TAG_LOGI(AAFwkTag::APPMGR, "finalizer called"); std::unique_ptr(static_cast(data)); } @@ -194,7 +194,7 @@ public: static bool IsJSFunctionExist(napi_env env, const napi_value para, const std::string& methodName) { if (para == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "para is nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null param"); return false; } napi_ref ref = nullptr; @@ -232,7 +232,7 @@ private: napi_value OnOn(napi_env env, size_t argc, napi_value* argv) { - TAG_LOGD(AAFwkTag::APPMGR, "OnOn called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); std::string type = ParseParamType(env, argc, argv); if (type == ON_OFF_TYPE_SYNC) { return OnOnNew(env, argc, argv); @@ -242,7 +242,7 @@ private: #ifdef SUPPORT_SCREEN return OnOnAbilityFirstFrameState(env, argc, argv); #else - TAG_LOGE(AAFwkTag::APPMGR, "Not Supported."); + TAG_LOGE(AAFwkTag::APPMGR, "not support"); return CreateJsUndefined(env); #endif } @@ -252,9 +252,9 @@ private: napi_value OnOnOld(napi_env env, size_t argc, napi_value* argv) { - TAG_LOGD(AAFwkTag::APPMGR, "OnOnOld called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_TWO) { // support 2 or 3 params, if > 3 params, ignore other params - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -301,7 +301,7 @@ private: { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_TWO) { // support 2 or 3 params, if > 3 params, ignore other params - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -344,7 +344,7 @@ private: { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -358,7 +358,7 @@ private: } if (appManager_ == nullptr || observerForeground_ == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "AppManager or observer is nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null appManager or observer"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } @@ -387,7 +387,7 @@ private: #ifdef SUPPORT_SCREEN return OnOffAbilityFirstFrameState(env, argc, argv); #else - TAG_LOGE(AAFwkTag::APPMGR, "Not Supported."); + TAG_LOGE(AAFwkTag::APPMGR, "not support"); return CreateJsUndefined(env); #endif } @@ -404,9 +404,9 @@ private: return CreateJsUndefined(env); } JSAbilityFirstFrameStateObserverManager::GetInstance()->Init(env); - TAG_LOGD(AAFwkTag::APPMGR, "OnOnAbilityFirstFrameState called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -434,7 +434,7 @@ private: } if (JSAbilityFirstFrameStateObserverManager::GetInstance()->IsObserverObjectExist(argv[INDEX_ONE])) { - TAG_LOGE(AAFwkTag::APPMGR, "Observer is already exists."); + TAG_LOGE(AAFwkTag::APPMGR, "observer exist"); return CreateJsUndefined(env); } int32_t ret = abilityManager_->RegisterAbilityFirstFrameStateObserver(observer, bundleName); @@ -456,9 +456,9 @@ private: return CreateJsUndefined(env); } JSAbilityFirstFrameStateObserverManager::GetInstance()->Init(env); - TAG_LOGD(AAFwkTag::APPMGR, "OnOffAbilityFirstFrameState called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -485,7 +485,7 @@ private: int64_t observerId, napi_env env, NapiAsyncTask *task) { if (observer == nullptr || appManager == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "observer or appManager nullptr"); + TAG_LOGE(AAFwkTag::APPMGR, "null observer or appManager"); task->Reject(env, CreateJsError(env, AbilityErrorCode::ERROR_CODE_INNER)); return; } @@ -503,7 +503,7 @@ private: { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params when off."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -548,7 +548,7 @@ private: { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params when off."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -584,7 +584,7 @@ private: { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params when off."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -693,7 +693,7 @@ private: #endif // only support 1 params if (argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough arguments"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -733,13 +733,13 @@ private: { TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::APPMGR, "Not enough params."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } int32_t bundleType = -1; if (!ConvertFromJsValue(env, argv[INDEX_ZERO], bundleType)) { - TAG_LOGE(AAFwkTag::APPMGR, "get bundleType error!"); + TAG_LOGE(AAFwkTag::APPMGR, "get bundleType error"); ThrowInvalidParamError(env, "Parse param bundleType failed, must be a BundleType."); return CreateJsUndefined(env); } @@ -822,7 +822,7 @@ private: } napi_value OnKillProcessesByBundleName(napi_env env, size_t argc, napi_value* argv) { - TAG_LOGD(AAFwkTag::APPMGR, "OnKillProcessesByBundleName called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::APPMGR, "Params not match"); ThrowTooFewParametersError(env); @@ -867,7 +867,7 @@ private: napi_value OnClearUpApplicationData(napi_env env, size_t argc, napi_value* argv) { - TAG_LOGD(AAFwkTag::APPMGR, "OnClearUpApplicationData called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::APPMGR, "arguments not match"); ThrowTooFewParametersError(env); @@ -910,7 +910,7 @@ private: napi_value OnClearUpAppData(napi_env env, size_t argc, napi_value* argv) { - TAG_LOGD(AAFwkTag::APPMGR, "OnClearUpAppData called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_ONE) { TAG_LOGE(AAFwkTag::APPMGR, "arguments not match"); ThrowTooFewParametersError(env); @@ -958,7 +958,7 @@ private: napi_value OnIsSharedBundleRunning(napi_env env, size_t argc, napi_value* argv) { - TAG_LOGD(AAFwkTag::APPMGR, "OnIsSharedBundleRunning called"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (argc < ARGC_TWO) { TAG_LOGE(AAFwkTag::APPMGR, "Params not match"); ThrowTooFewParametersError(env); @@ -1247,7 +1247,7 @@ private: [bundleName, appManager, innerErrorCode, isRunning]() { sptr appMgr = appManager.promote(); if (appMgr == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "App manager is nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null appmgr"); *innerErrorCode = static_cast(AbilityErrorCode::ERROR_CODE_INNER); return; } @@ -1341,7 +1341,7 @@ private: [param, innerErrorCode, weak]() { sptr appMgr = weak.promote(); if (appMgr == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication appMgr is nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null appMgr"); *innerErrorCode = static_cast(AbilityErrorCode::ERROR_CODE_INNER); return; } @@ -1369,7 +1369,7 @@ private: } if (!AppExecFwk::IsTypeForNapiValue(env, argv[0], napi_string)) { - TAG_LOGE(AAFwkTag::APPMGR, "Param 0 is not string"); + TAG_LOGE(AAFwkTag::APPMGR, "argv[0] not string"); return false; } diff --git a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp index cd0439e672..5c58c8cb8f 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_manager_utils.cpp @@ -36,7 +36,7 @@ napi_value CreateJsAppStateData(napi_env env, const AppStateData &appStateData) napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, appStateData.bundleName)); @@ -44,7 +44,7 @@ napi_value CreateJsAppStateData(napi_env env, const AppStateData &appStateData) napi_set_named_property(env, object, "state", CreateJsValue(env, appStateData.state)); napi_set_named_property(env, object, "isSplitScreenMode", CreateJsValue(env, appStateData.isSplitScreenMode)); napi_set_named_property(env, object, "isFloatingWindowMode", CreateJsValue(env, appStateData.isFloatingWindowMode)); - TAG_LOGD(AAFwkTag::APPMGR, "end."); + TAG_LOGD(AAFwkTag::APPMGR, "end"); return object; } @@ -54,7 +54,7 @@ napi_value CreateJsAbilityStateData(napi_env env, const AbilityStateData &abilit napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, abilityStateData.bundleName)); @@ -68,7 +68,7 @@ napi_value CreateJsAbilityStateData(napi_env env, const AbilityStateData &abilit if (abilityStateData.appCloneIndex != -1) { napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, abilityStateData.appCloneIndex)); } - TAG_LOGD(AAFwkTag::APPMGR, "end."); + TAG_LOGD(AAFwkTag::APPMGR, "end"); return object; } @@ -80,7 +80,7 @@ napi_value CreateJsAbilityFirstFrameStateData(napi_env env, napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "ObjValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, abilityFirstFrameStateData.bundleName)); @@ -98,7 +98,7 @@ napi_value CreateJsProcessData(napi_env env, const ProcessData &processData) napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, processData.bundleName)); @@ -107,7 +107,7 @@ napi_value CreateJsProcessData(napi_env env, const ProcessData &processData) napi_set_named_property(env, object, "state", CreateJsValue(env, processData.state)); napi_set_named_property(env, object, "isContinuousTask", CreateJsValue(env, processData.isContinuousTask)); napi_set_named_property(env, object, "isKeepAlive", CreateJsValue(env, processData.isKeepAlive)); - TAG_LOGD(AAFwkTag::APPMGR, "end."); + TAG_LOGD(AAFwkTag::APPMGR, "end"); return object; } @@ -138,7 +138,7 @@ napi_value CreateJsRunningProcessInfo(napi_env env, const RunningProcessInfo &in napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } @@ -160,7 +160,7 @@ napi_value CreateJsRunningMultiAppInfo(napi_env env, const RunningMultiAppInfo & napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "bundleName", CreateJsValue(env, info.bundleName)); @@ -186,7 +186,7 @@ napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info) napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "objValue nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "appCloneIndex", CreateJsValue(env, info.appCloneIndex)); @@ -198,17 +198,17 @@ napi_value CreateJsRunningAppClone(napi_env env, const RunningAppClone &info) napi_value ApplicationStateInit(napi_env env) { - TAG_LOGD(AAFwkTag::APPMGR, "ApplicationStateInit enter"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (env == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Invalid input parameters"); + TAG_LOGE(AAFwkTag::APPMGR, "null env"); return nullptr; } napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Wrong to get object"); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } @@ -228,17 +228,17 @@ napi_value ApplicationStateInit(napi_env env) napi_value ProcessStateInit(napi_env env) { - TAG_LOGD(AAFwkTag::APPMGR, "ProcessStateInit enter"); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (env == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Invalid input arguments"); + TAG_LOGE(AAFwkTag::APPMGR, "null env"); return nullptr; } napi_value object = nullptr; napi_create_object(env, &object); if (object == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "Failed to get object"); + TAG_LOGE(AAFwkTag::APPMGR, "null obj"); return nullptr; } napi_set_named_property(env, object, "STATE_CREATE", @@ -256,9 +256,9 @@ napi_value ProcessStateInit(napi_env env) napi_value PreloadModeInit(napi_env env) { - TAG_LOGD(AAFwkTag::APPMGR, "PreloadModeInit enter."); + TAG_LOGD(AAFwkTag::APPMGR, "called"); if (env == nullptr) { - TAG_LOGE(AAFwkTag::APPMGR, "PreloadModeInit, env is nullptr."); + TAG_LOGE(AAFwkTag::APPMGR, "null env"); return nullptr; } napi_value objValue = nullptr; @@ -274,23 +274,23 @@ bool ConvertPreloadApplicationParam(napi_env env, size_t argc, napi_value *argv, std::string &errorMsg) { if (!ConvertFromJsValue(env, argv[ARG_INDEX_0], param.bundleName)) { - TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param bundleName failed."); + TAG_LOGE(AAFwkTag::APPMGR, "get bundleName failed"); errorMsg = "Parse param bundleName failed, must be a valid string."; return false; } if (!ConvertFromJsValue(env, argv[ARG_INDEX_1], param.userId)) { - TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param userId failed."); + TAG_LOGE(AAFwkTag::APPMGR, "get userId failed"); errorMsg = "Parse param userId failed, must be a valid number."; return false; } if (!ConvertFromJsValue(env, argv[ARG_INDEX_2], param.preloadMode) || param.preloadMode != AppExecFwk::PreloadMode::PRESS_DOWN) { - TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param preloadMode failed."); + TAG_LOGE(AAFwkTag::APPMGR, "get preloadMode failed"); errorMsg = "Unsupported preloadMode, must be PreloadMode.PRESS_DOWN."; return false; } if (argc > ARG_INDEX_3 && !ConvertFromJsValue(env, argv[ARG_INDEX_3], param.appIndex)) { - TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication get param appIndex failed."); + TAG_LOGE(AAFwkTag::APPMGR, "get appIndex failed"); errorMsg = "Parse param appIndex failed, must be a valid number."; return false; } @@ -317,7 +317,7 @@ JsAppProcessState ConvertToJsAppProcessState( processState = STATE_DESTROY; break; default: - TAG_LOGE(AAFwkTag::APPMGR, "Process state is invalid."); + TAG_LOGE(AAFwkTag::APPMGR, "invalid state"); processState = STATE_DESTROY; break; } diff --git a/frameworks/js/napi/app/js_app_manager/js_app_state_observer.cpp b/frameworks/js/napi/app/js_app_manager/js_app_state_observer.cpp index 1ee9d18357..0c18d5faf4 100644 --- a/frameworks/js/napi/app/js_app_manager/js_app_state_observer.cpp +++ b/frameworks/js/napi/app/js_app_manager/js_app_state_observer.cpp @@ -31,7 +31,7 @@ void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appS TAG_LOGD(AAFwkTag::APPMGR, "bundleName:%{public}s, uid:%{public}d, state:%{public}d", appStateData.bundleName.c_str(), appStateData.uid, appStateData.state); if (!valid_) { - TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed"); + TAG_LOGE(AAFwkTag::APPMGR, "invalid appmgr"); return; } wptr jsObserver = this; @@ -39,7 +39,7 @@ void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appS ([jsObserver, appStateData](napi_env env, NapiAsyncTask &task, int32_t status) { sptr jsObserverSptr = jsObserver.promote(); if (!jsObserverSptr) { - TAG_LOGW(AAFwkTag::APPMGR, "jsObserverSptr nullptr"); + TAG_LOGW(AAFwkTag::APPMGR, "null jsObserver"); return; } jsObserverSptr->HandleOnForegroundApplicationChanged(appStateData); @@ -234,7 +234,7 @@ void JSAppStateObserver::HandleOnProcessDied(const ProcessData &processData) void JSAppStateObserver::OnAppStarted(const AppStateData &appStateData) { - TAG_LOGD(AAFwkTag::APPMGR, "onAppStarted bundleName:%{public}s, uid:%{public}d, state:%{public}d", + TAG_LOGD(AAFwkTag::APPMGR, "bundleName:%{public}s, uid:%{public}d, state:%{public}d", appStateData.bundleName.c_str(), appStateData.uid, appStateData.state); if (!valid_) { TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed"); @@ -259,7 +259,7 @@ void JSAppStateObserver::OnAppStarted(const AppStateData &appStateData) void JSAppStateObserver::HandleOnAppStarted(const AppStateData &appStateData) { TAG_LOGD(AAFwkTag::APPMGR, - "HandleOnAppStarted bundleName:%{public}s, uid:%{public}d, state:%{public}d", + "bundleName:%{public}s, uid:%{public}d, state:%{public}d", appStateData.bundleName.c_str(), appStateData.uid, appStateData.state); auto tmpMap = jsObserverObjectMap_; for (auto &item : tmpMap) { @@ -274,7 +274,7 @@ void JSAppStateObserver::HandleOnAppStarted(const AppStateData &appStateData) void JSAppStateObserver::OnAppStopped(const AppStateData &appStateData) { - TAG_LOGD(AAFwkTag::APPMGR, "OnAppStopped bundleName:%{public}s, uid:%{public}d, state:%{public}d", + TAG_LOGD(AAFwkTag::APPMGR, "bundleName:%{public}s, uid:%{public}d, state:%{public}d", appStateData.bundleName.c_str(), appStateData.uid, appStateData.state); if (!valid_) { TAG_LOGE(AAFwkTag::APPMGR, "the app manager may has destroyed"); @@ -299,7 +299,7 @@ void JSAppStateObserver::OnAppStopped(const AppStateData &appStateData) void JSAppStateObserver::HandleOnAppStopped(const AppStateData &appStateData) { TAG_LOGD(AAFwkTag::APPMGR, - "HandleOnAppStopped bundleName:%{public}s, uid:%{public}d, state:%{public}d", + "bundleName:%{public}s, uid:%{public}d, state:%{public}d", appStateData.bundleName.c_str(), appStateData.uid, appStateData.state); auto tmpMap = jsObserverObjectMap_; for (auto &item : tmpMap) { @@ -315,7 +315,7 @@ void JSAppStateObserver::HandleOnAppStopped(const AppStateData &appStateData) void JSAppStateObserver::CallJsFunction( napi_value value, const char *methodName, napi_value* argv, size_t argc) { - TAG_LOGD(AAFwkTag::APPMGR, "called, method:%{public}s", methodName); + TAG_LOGD(AAFwkTag::APPMGR, "call method:%{public}s", methodName); if (value == nullptr) { TAG_LOGE(AAFwkTag::APPMGR, "Failed to get object"); return; diff --git a/frameworks/js/napi/app/recovery/app_recovery_api.cpp b/frameworks/js/napi/app/recovery/app_recovery_api.cpp index a99b26c018..7d40691d5e 100644 --- a/frameworks/js/napi/app/recovery/app_recovery_api.cpp +++ b/frameworks/js/napi/app/recovery/app_recovery_api.cpp @@ -88,7 +88,7 @@ private: napi_typeof(env, argv[i], ¶mType); if (paramType != napi_number) { TAG_LOGE( - AAFwkTag::RECOVERY, "AppRecoveryApi argv[%{public}s] type isn't number", std::to_string(i).c_str()); + AAFwkTag::RECOVERY, "argv[%{public}s] not number", std::to_string(i).c_str()); return result; } int32_t tmp = 0; @@ -111,21 +111,18 @@ private: uint16_t restartFlag = params[0]; constexpr uint16_t restartMaxVal = 0x0003; if ((restartFlag < 0 || restartFlag > restartMaxVal) && (restartFlag != RestartFlag::NO_RESTART)) { - TAG_LOGE( - AAFwkTag::RECOVERY, "AppRecoveryApi CheckParamsValid restartFlag: %{public}d is Invalid", restartFlag); + TAG_LOGE(AAFwkTag::RECOVERY, "invalid restartFlag: %{public}d", restartFlag); return false; } uint16_t saveFlag = params[1]; constexpr uint16_t saveMaxVal = 0x0003; if (saveFlag < SaveOccasionFlag::SAVE_WHEN_ERROR || saveFlag > saveMaxVal) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryApi CheckParamsValid SaveOccasionFlag: %{public}d is Invalid", - saveFlag); + TAG_LOGE(AAFwkTag::RECOVERY, "invalid saveOccasionFlag: %{public}d", saveFlag); return false; } uint16_t saveModeFlag = params[2]; if (saveModeFlag < SaveModeFlag::SAVE_WITH_FILE || saveModeFlag > SaveModeFlag::SAVE_WITH_SHARED_MEMORY) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryApi CheckParamsValid saveModeFlag: %{public}d is Invalid", - saveModeFlag); + TAG_LOGE(AAFwkTag::RECOVERY, "invalid saveModeFlag: %{public}d", saveModeFlag); return false; } return true; @@ -134,14 +131,14 @@ private: napi_value OnSaveAppState(napi_env env, const size_t argc, napi_value* argv) { if (argc > 1) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryApi SaveAppState Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::RECOVERY, "invalid argc"); return CreateJsValue(env, false); } uintptr_t ability = 0; if (argc == 1) { napi_value value = argv[0]; if (value == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryApi Invalid abilityContext."); + TAG_LOGE(AAFwkTag::RECOVERY, "null abilityContext"); return CreateJsValue(env, false); } void* result = nullptr; @@ -157,7 +154,7 @@ private: napi_value OnRestartApp(napi_env env, const size_t argc, napi_value* argv) { if (argc != 0) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryApi OnRestartApp Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::RECOVERY, "invalid argc"); return CreateJsUndefined(env); } @@ -168,7 +165,7 @@ private: napi_value OnSetRestartWant(napi_env env, const size_t argc, napi_value* argv) { if (argc != 1) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryApi OnSetRestartWant Incorrect number of parameters"); + TAG_LOGE(AAFwkTag::RECOVERY, "invalid argc"); return CreateJsUndefined(env); } std::shared_ptr want = std::make_shared(); @@ -182,7 +179,7 @@ private: napi_value AppRecoveryRestartFlagInit(napi_env env) { if (env == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryRestartFlagInit Invalid input parameters"); + TAG_LOGE(AAFwkTag::RECOVERY, "null env"); return nullptr; } @@ -190,7 +187,7 @@ napi_value AppRecoveryRestartFlagInit(napi_env env) napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryRestartFlagInit Failed to get object"); + TAG_LOGE(AAFwkTag::RECOVERY, "null obj"); return nullptr; } @@ -206,7 +203,7 @@ napi_value AppRecoveryRestartFlagInit(napi_env env) napi_value AppRecoveryStateSaveFlagInit(napi_env env) { if (env == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryStateSaveFlagInit Invalid input parameters"); + TAG_LOGE(AAFwkTag::RECOVERY, "null env"); return nullptr; } @@ -214,7 +211,7 @@ napi_value AppRecoveryStateSaveFlagInit(napi_env env) napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoveryStateSaveFlagInit Failed to get object"); + TAG_LOGE(AAFwkTag::RECOVERY, "null obj"); return nullptr; } @@ -229,7 +226,7 @@ napi_value AppRecoveryStateSaveFlagInit(napi_env env) napi_value AppRecoverySaveModeFlagInit(napi_env env) { if (env == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoverySaveModeFlagInit Invalid input parameters"); + TAG_LOGE(AAFwkTag::RECOVERY, "null env"); return nullptr; } @@ -237,7 +234,7 @@ napi_value AppRecoverySaveModeFlagInit(napi_env env) napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecoverySaveModeFlagInit Failed to get object"); + TAG_LOGE(AAFwkTag::RECOVERY, "null obj"); return nullptr; } napi_set_named_property(env, objValue, "SAVE_WITH_FILE", @@ -250,7 +247,7 @@ napi_value AppRecoverySaveModeFlagInit(napi_env env) napi_value InitAppRecoveryApiModule(napi_env env, napi_value exportObj) { if (env == nullptr || exportObj == nullptr) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecovery API Invalid input parameters"); + TAG_LOGE(AAFwkTag::RECOVERY, "null env or exportObj"); return nullptr; } diff --git a/frameworks/js/napi/app/sendable_context_manager/js_sendable_context_manager.cpp b/frameworks/js/napi/app/sendable_context_manager/js_sendable_context_manager.cpp index 6228410bf9..a67d2e2722 100644 --- a/frameworks/js/napi/app/sendable_context_manager/js_sendable_context_manager.cpp +++ b/frameworks/js/napi/app/sendable_context_manager/js_sendable_context_manager.cpp @@ -46,9 +46,9 @@ public: void JsContext::Finalizer(napi_env env, void* data, void* hint) { - TAG_LOGD(AAFwkTag::CONTEXT, "JsContext finalizer."); + TAG_LOGD(AAFwkTag::CONTEXT, "finalizer called"); if (data == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Input data invalid."); + TAG_LOGE(AAFwkTag::CONTEXT, "null data"); return; } std::unique_ptr(static_cast(data)); @@ -79,14 +79,14 @@ napi_value CreateJsBaseContextFromSendable(napi_env env, void* wrapped) { JsContext *sendableContext = static_cast(wrapped); if (sendableContext == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Get sendable context failed."); + TAG_LOGE(AAFwkTag::CONTEXT, "null sendableContext"); return nullptr; } auto weakContext = sendableContext->context_; std::shared_ptr context = weakContext.lock(); if (context == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Context invalid."); + TAG_LOGE(AAFwkTag::CONTEXT, "null context"); return nullptr; } @@ -111,7 +111,7 @@ napi_value CreateJsApplicationContextFromSendable(napi_env env, void* wrapped) { JsContext *sendableContext = static_cast(wrapped); if (sendableContext == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Get sendable context failed."); + TAG_LOGE(AAFwkTag::CONTEXT, "null sendableContext"); return nullptr; } @@ -143,7 +143,7 @@ napi_value CreateJsAbilityStageContextFromSendable(napi_env env, void* wrapped) { JsContext *sendableContext = static_cast(wrapped); if (sendableContext == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Get sendable context failed."); + TAG_LOGE(AAFwkTag::CONTEXT, "null sendableContext"); return nullptr; } @@ -175,20 +175,20 @@ napi_value CreateJsUIAbilityContextFromSendable(napi_env env, void* wrapped) { JsContext *sendableContext = static_cast(wrapped); if (sendableContext == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Get sendable context failed."); + TAG_LOGE(AAFwkTag::CONTEXT, "null sendableContext"); return nullptr; } auto weakContext = sendableContext->context_; std::shared_ptr context = weakContext.lock(); if (context == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Context invalid."); + TAG_LOGE(AAFwkTag::CONTEXT, "null ontext"); return nullptr; } auto uiAbilityContext = Context::ConvertTo(context); if (uiAbilityContext == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Convert to UIAbility context failed."); + TAG_LOGE(AAFwkTag::CONTEXT, "null uiAbilityContext"); return nullptr; } @@ -210,9 +210,9 @@ public: static void Finalizer(napi_env env, void *data, void *hint) { - TAG_LOGD(AAFwkTag::CONTEXT, "JsSendableContextManager finalizer."); + TAG_LOGD(AAFwkTag::CONTEXT, "finalizer called"); if (data == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "Input data invalid."); + TAG_LOGE(AAFwkTag::CONTEXT, "null data"); return; } std::unique_ptr(static_cast(data)); @@ -246,9 +246,9 @@ public: private: napi_value OnConvertFromContext(napi_env env, NapiCallbackInfo &info) { - TAG_LOGD(AAFwkTag::CONTEXT, "Convert from context."); + TAG_LOGD(AAFwkTag::CONTEXT, "called"); if (info.argc != ARGC_ONE) { - TAG_LOGE(AAFwkTag::CONTEXT, "The number of parameter is invalid."); + TAG_LOGE(AAFwkTag::CONTEXT, "invalid argc"); ThrowInvalidParamError(env, "Parameter error: The number of parameter is invalid."); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/app_startup/startup_manager/js_startup_manager.cpp b/frameworks/js/napi/app_startup/startup_manager/js_startup_manager.cpp index 5fec31899e..d878dfd708 100644 --- a/frameworks/js/napi/app_startup/startup_manager/js_startup_manager.cpp +++ b/frameworks/js/napi/app_startup/startup_manager/js_startup_manager.cpp @@ -66,7 +66,7 @@ napi_value JsStartupManager::OnRun(napi_env env, NapiCallbackInfo &info) { TAG_LOGD(AAFwkTag::STARTUP, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid."); + TAG_LOGE(AAFwkTag::STARTUP, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -114,7 +114,7 @@ napi_value JsStartupManager::OnGetResult(napi_env env, NapiCallbackInfo &info) { TAG_LOGD(AAFwkTag::STARTUP, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::STARTUP, "the param is invalid."); + TAG_LOGE(AAFwkTag::STARTUP, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -139,7 +139,7 @@ napi_value JsStartupManager::OnGetResult(napi_env env, NapiCallbackInfo &info) } std::shared_ptr jsResult = std::static_pointer_cast(result); if (jsResult == nullptr) { - TAG_LOGE(AAFwkTag::STARTUP, "%{public}s, failed to convert to js result.", startupTask.c_str()); + TAG_LOGE(AAFwkTag::STARTUP, "null jsResult: %{public}s", startupTask.c_str()); ThrowInvalidParamError(env, "%{public}s, failed to convert to js result."); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/auto_fill_manager/js_auto_fill_manager.cpp b/frameworks/js/napi/auto_fill_manager/js_auto_fill_manager.cpp index 229820d1fa..cb2cc1a019 100644 --- a/frameworks/js/napi/auto_fill_manager/js_auto_fill_manager.cpp +++ b/frameworks/js/napi/auto_fill_manager/js_auto_fill_manager.cpp @@ -44,14 +44,14 @@ napi_value JsAutoFillManager::OnRequestAutoSave(napi_env env, NapiCallbackInfo & { TAG_LOGD(AAFwkTag::AUTOFILLMGR, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::AUTOFILLMGR, "The param is invalid."); + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } napi_value instanceIdValue = nullptr; if (napi_get_named_property(env, info.argv[INDEX_ZERO], "instanceId_", &instanceIdValue) != napi_ok) { - TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Get function by name failed."); + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "get function by name failed"); ThrowError(env, static_cast(AbilityErrorCode::ERROR_CODE_INVALID_PARAM), "Parameter error. Get instance id failed."); return CreateJsUndefined(env); @@ -74,7 +74,7 @@ napi_value JsAutoFillManager::OnRequestAutoSave(napi_env env, NapiCallbackInfo & auto autoSaveMangerFunc = [this](const int32_t arg) { this->OnRequestAutoSaveDone(arg); }; saveCallback = std::make_shared(env, instanceId, autoSaveMangerFunc); if (saveCallback == nullptr) { - TAG_LOGE(AAFwkTag::AUTOFILLMGR, "saveCallback is nullptr."); + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "null saveCallback"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } @@ -98,7 +98,7 @@ void JsAutoFillManager::OnRequestAutoSaveInner(napi_env env, int32_t instanceId, #ifdef SUPPORT_GRAPHICS auto uiContent = Ace::UIContent::GetUIContent(instanceId); if (uiContent == nullptr) { - TAG_LOGE(AAFwkTag::AUTOFILLMGR, "UIContent is nullptr."); + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "null uiContent"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return; } diff --git a/frameworks/js/napi/auto_fill_manager/js_auto_save_request_callback.cpp b/frameworks/js/napi/auto_fill_manager/js_auto_save_request_callback.cpp index 222937e62d..7d6b2430fd 100644 --- a/frameworks/js/napi/auto_fill_manager/js_auto_save_request_callback.cpp +++ b/frameworks/js/napi/auto_fill_manager/js_auto_save_request_callback.cpp @@ -54,7 +54,7 @@ void JsAutoSaveRequestCallback::Register(napi_value value) { TAG_LOGD(AAFwkTag::AUTOFILLMGR, "called"); if (IsJsCallbackEquals(callback_, value)) { - TAG_LOGE(AAFwkTag::AUTOFILLMGR, "The current callback already exists."); + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "callback exist"); return; } @@ -81,7 +81,7 @@ void JsAutoSaveRequestCallback::JSCallFunction(const std::string &methodName) void JsAutoSaveRequestCallback::JSCallFunctionWorker(const std::string &methodName) { if (callback_ == nullptr) { - TAG_LOGE(AAFwkTag::AUTOFILLMGR, "callback is nullptr."); + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "null callback_"); return; } @@ -109,7 +109,7 @@ bool JsAutoSaveRequestCallback::IsJsCallbackEquals(std::shared_ptrGetNapiValue(); if (object == nullptr) { - TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Failed to get object."); + TAG_LOGE(AAFwkTag::AUTOFILLMGR, "null obj"); return false; } diff --git a/frameworks/js/napi/dialog_request_info/request_info.cpp b/frameworks/js/napi/dialog_request_info/request_info.cpp index c8d2070bef..51041ea0b0 100755 --- a/frameworks/js/napi/dialog_request_info/request_info.cpp +++ b/frameworks/js/napi/dialog_request_info/request_info.cpp @@ -43,7 +43,7 @@ napi_value RequestInfo::WrapRequestInfo(napi_env env, RequestInfo *request) { TAG_LOGD(AAFwkTag::DIALOG, "called"); if (request == nullptr) { - TAG_LOGE(AAFwkTag::DIALOG, "request is nullptr."); + TAG_LOGE(AAFwkTag::DIALOG, "null request"); return nullptr; } @@ -59,17 +59,17 @@ napi_value RequestInfo::WrapRequestInfo(napi_env env, RequestInfo *request) napi_value result = nullptr; napi_new_instance(env, requestInfoClass, 0, nullptr, &result); if (result == nullptr) { - TAG_LOGE(AAFwkTag::DIALOG, "create instance failed."); + TAG_LOGE(AAFwkTag::DIALOG, "create instance failed"); return nullptr; } if (!CheckTypeForNapiValue(env, result, napi_object)) { - TAG_LOGE(AAFwkTag::DIALOG, "UnwrapRequestInfo result type error!"); + TAG_LOGE(AAFwkTag::DIALOG, "UnwrapRequestInfo result type error"); return nullptr; } auto nativeFinalize = [](napi_env env, void* data, void* hint) { - TAG_LOGI(AAFwkTag::DIALOG, "Js RequestInfo finalizer is called"); + TAG_LOGI(AAFwkTag::DIALOG, "finalizer called"); auto requestInfo = static_cast(data); if (requestInfo) { delete requestInfo; @@ -90,7 +90,7 @@ napi_value RequestInfo::CreateJsWindowRect( napi_value objValue = nullptr; napi_create_object(env, &objValue); if (objValue == nullptr) { - TAG_LOGE(AAFwkTag::DIALOG, "Native object is nullptr."); + TAG_LOGE(AAFwkTag::DIALOG, "null obj"); return objValue; } napi_set_named_property(env, objValue, "left", CreateJsValue(env, left)); @@ -104,12 +104,12 @@ std::shared_ptr RequestInfo::UnwrapRequestInfo(napi_env env, napi_v { TAG_LOGI(AAFwkTag::DIALOG, "called"); if (jsParam == nullptr) { - TAG_LOGE(AAFwkTag::DIALOG, "jsParam is nullptr"); + TAG_LOGE(AAFwkTag::DIALOG, "null jsParam"); return nullptr; } if (!CheckTypeForNapiValue(env, jsParam, napi_object)) { - TAG_LOGE(AAFwkTag::DIALOG, "UnwrapRequestInfo jsParam type error!"); + TAG_LOGE(AAFwkTag::DIALOG, "jsParam type error"); return nullptr; } void* result = nullptr; diff --git a/frameworks/js/napi/featureAbility/feature_ability.cpp b/frameworks/js/napi/featureAbility/feature_ability.cpp index cd43c139a2..9fa136af93 100644 --- a/frameworks/js/napi/featureAbility/feature_ability.cpp +++ b/frameworks/js/napi/featureAbility/feature_ability.cpp @@ -103,7 +103,7 @@ void JsFeatureAbility::Finalizer(napi_env env, void *data, void *hint) napi_value JsFeatureAbilityInit(napi_env env, napi_value exports) { - TAG_LOGD(AAFwkTag::FA, "JsFeatureAbilityInit is called"); + TAG_LOGD(AAFwkTag::FA, "called"); if (env == nullptr || exports == nullptr) { TAG_LOGE(AAFwkTag::FA, "Invalid input parameters"); return exports; @@ -219,7 +219,7 @@ napi_value JsFeatureAbility::TerminateAbility(napi_env env, napi_callback_info i #ifdef SUPPORT_SCREEN napi_value JsFeatureAbility::OnHasWindowFocus(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGD(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGD(AAFwkTag::FA, "called"); if (info.argc > ARGS_ONE || info.argc < ARGS_ZERO) { TAG_LOGE(AAFwkTag::FA, " wrong number of arguments."); return CreateJsUndefined(env); @@ -238,7 +238,7 @@ napi_value JsFeatureAbility::OnHasWindowFocus(napi_env env, const NapiCallbackIn napi_value lastParam = (info.argc == ARGS_ZERO) ? nullptr : info.argv[PARAM0]; NapiAsyncTask::ScheduleHighQos("JSFeatureAbility::OnHasWindowFocus", env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); - TAG_LOGD(AAFwkTag::FA, "OnHasWindowFocus is called end"); + TAG_LOGD(AAFwkTag::FA, "end"); return result; } #endif @@ -276,7 +276,7 @@ Ability* JsFeatureAbility::GetAbility(napi_env env) napi_value JsFeatureAbility::OnStartAbilityForResult(napi_env env, NapiCallbackInfo& info) { - TAG_LOGD(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGD(AAFwkTag::FA, "called"); if (info.argc < ARGS_ONE || info.argc > ARGS_TWO) { TAG_LOGE(AAFwkTag::FA, "wrong number of arguments."); return CreateJsUndefined(env); @@ -292,7 +292,7 @@ napi_value JsFeatureAbility::OnStartAbilityForResult(napi_env env, NapiCallbackI startAbilityCallback->env = env; if (UnwrapForResultParam(*abilityParam, env, info.argv[0]) == nullptr) { - TAG_LOGE(AAFwkTag::FA, "OnStartAbilityForResult UnwrapForResultParam failed."); + TAG_LOGE(AAFwkTag::FA, "unwrapForResultParam failed"); startAbilityCallback->errCode = NAPI_ERR_PARAM_INVALID; } @@ -320,14 +320,14 @@ napi_value JsFeatureAbility::OnStartAbilityForResult(napi_env env, NapiCallbackI napi_value JsFeatureAbility::OnFinishWithResult(napi_env env, NapiCallbackInfo& info) { - TAG_LOGD(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGD(AAFwkTag::FA, "called"); if (info.argc > ARGS_TWO || info.argc < ARGS_ONE) { TAG_LOGE(AAFwkTag::FA, "wrong number of arguments."); return CreateJsUndefined(env); } if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[0], napi_object)) { - TAG_LOGE(AAFwkTag::FA, "OnFinishWithResult param is not object."); + TAG_LOGE(AAFwkTag::FA, "param not object"); return CreateJsUndefined(env); } @@ -335,11 +335,11 @@ napi_value JsFeatureAbility::OnFinishWithResult(napi_env env, NapiCallbackInfo& napi_value jsRequestCode = nullptr; napi_get_named_property(env, info.argv[0], "resultCode", &jsRequestCode); if (!AppExecFwk::IsTypeForNapiValue(env, jsRequestCode, napi_number)) { - TAG_LOGE(AAFwkTag::FA, "OnFinishWithResult resultCode type failed."); + TAG_LOGE(AAFwkTag::FA, "resultCode type failed"); return CreateJsUndefined(env); } if (!ConvertFromJsValue(env, jsRequestCode, param.requestCode)) { - TAG_LOGE(AAFwkTag::FA, "OnFinishWithResult convert resultCode failed."); + TAG_LOGE(AAFwkTag::FA, "convert resultCode failed"); return CreateJsUndefined(env); } bool hasWant = false; @@ -348,11 +348,11 @@ napi_value JsFeatureAbility::OnFinishWithResult(napi_env env, NapiCallbackInfo& napi_value jsWant = nullptr; napi_get_named_property(env, info.argv[0], "want", &jsWant); if (!AppExecFwk::IsTypeForNapiValue(env, jsWant, napi_object)) { - TAG_LOGE(AAFwkTag::FA, "OnFinishWithResult want type failed."); + TAG_LOGE(AAFwkTag::FA, "want type failed"); return CreateJsUndefined(env); } if (!UnwrapWant(env, jsWant, param.want)) { - TAG_LOGE(AAFwkTag::FA, "OnFinishWithResult UnwrapWant failed."); + TAG_LOGE(AAFwkTag::FA, "unwrapWant failed"); return CreateJsUndefined(env); } } @@ -362,7 +362,7 @@ napi_value JsFeatureAbility::OnFinishWithResult(napi_env env, NapiCallbackInfo& obj->ability_->SetResult(param.requestCode, param.want); obj->ability_->TerminateAbility(); } else { - TAG_LOGE(AAFwkTag::FA, "OnFinishWithResult ability is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null ability"); } task.Resolve(env, CreateJsNull(env)); }; @@ -377,14 +377,13 @@ napi_value JsFeatureAbility::OnFinishWithResult(napi_env env, NapiCallbackInfo& napi_value JsFeatureAbility::GetWindow(napi_env env, napi_callback_info info) { if (env == nullptr || info == nullptr) { - TAG_LOGE(AAFwkTag::FA, "JsFeatureAbility::%{public}s is called, but input parameters %{public}s is nullptr", - __func__, ((env == nullptr) ? "env" : "info")); + TAG_LOGE(AAFwkTag::FA, "null %{public}s", ((env == nullptr) ? "env" : "info")); return nullptr; } auto object = CheckParamsAndGetThis(env, info); if (object == nullptr) { - TAG_LOGE(AAFwkTag::FA, "CheckParamsAndGetThis return nullptr"); + TAG_LOGE(AAFwkTag::FA, "null obj"); return nullptr; } @@ -393,7 +392,7 @@ napi_value JsFeatureAbility::GetWindow(napi_env env, napi_callback_info info) napi_value JsFeatureAbility::OnGetWindow(napi_env env, napi_callback_info info) { - TAG_LOGD(AAFwkTag::FA, "%{public}s called", __func__); + TAG_LOGD(AAFwkTag::FA, "called"); size_t argc = ARGS_MAX_COUNT; napi_value argv[ARGS_MAX_COUNT] = { nullptr }; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); @@ -434,29 +433,29 @@ napi_value JsFeatureAbility::OnGetWindow(napi_env env, napi_callback_info info) napi_value NAPI_SetResult(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); AsyncCallbackInfo *asyncCallbackInfo = CreateAsyncCallbackInfo(env); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s,asyncCallbackInfo == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return WrapVoidToJS(env); } napi_value ret = SetResultWrap(env, info, asyncCallbackInfo); if (ret == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s,ret == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null ret"); if (asyncCallbackInfo != nullptr) { delete asyncCallbackInfo; asyncCallbackInfo = nullptr; } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } napi_value SetResultWrap(napi_env env, napi_callback_info info, AsyncCallbackInfo *asyncCallbackInfo) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); size_t argcAsync = 2; const size_t argcPromise = 1; const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; @@ -465,13 +464,13 @@ napi_value SetResultWrap(napi_env env, napi_callback_info info, AsyncCallbackInf NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Fail argument count.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid argc"); return nullptr; } CallAbilityParam param; if (UnwrapAbilityResult(param, env, args[0]) == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, call unwrapWant failed.", __func__); + TAG_LOGE(AAFwkTag::FA, "call unwrapWant failed"); return nullptr; } asyncCallbackInfo->param = param; @@ -481,7 +480,7 @@ napi_value SetResultWrap(napi_env env, napi_callback_info info, AsyncCallbackInf } else { ret = SetResultPromise(env, asyncCallbackInfo); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -489,10 +488,10 @@ napi_value CreateAsyncWork(napi_env env, napi_value &resourceName, AsyncCallback { NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, worker pool thread enter."); + TAG_LOGI(AAFwkTag::FA, "worker pool thread"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "NAPI_SetResult, execute asyncCallbackInfo is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } @@ -501,15 +500,15 @@ napi_value CreateAsyncWork(napi_env env, napi_value &resourceName, AsyncCallback asyncCallbackInfo->param.requestCode, asyncCallbackInfo->param.want); asyncCallbackInfo->ability->TerminateAbility(); } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_SetResult, ability == null"); + TAG_LOGE(AAFwkTag::FA, "null ability"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, worker pool thread execute exit."); + TAG_LOGI(AAFwkTag::FA, "worker pool thread execute exit"); }, [](napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "main event thread complete"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "NAPI_SetResult, complete asyncCallbackInfo is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } napi_value result[ARGS_TWO] = {nullptr}; @@ -528,23 +527,23 @@ napi_value CreateAsyncWork(napi_env env, napi_value &resourceName, AsyncCallback } napi_delete_async_work(env, asyncCallbackInfo->asyncWork); delete asyncCallbackInfo; - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "complete end"); }, static_cast(asyncCallbackInfo), &asyncCallbackInfo->asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value SetResultAsync( napi_env env, napi_value *args, const size_t argCallback, AsyncCallbackInfo *asyncCallbackInfo) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -561,9 +560,9 @@ napi_value SetResultAsync( napi_value SetResultPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "promise"); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "SetResultPromise, param == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -575,10 +574,10 @@ napi_value SetResultPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo) NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "worker pool thread execute"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "NAPI_SetResult promise, execute asyncCallbackInfo is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } @@ -587,15 +586,15 @@ napi_value SetResultPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo) asyncCallbackInfo->param.requestCode, asyncCallbackInfo->param.want); asyncCallbackInfo->ability->TerminateAbility(); } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_SetResult, ability == nullptr"); + TAG_LOGE(AAFwkTag::FA, "ability == nullptr"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "execute end"); }, [](napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "complete called"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "NAPI_SetResult promise, execute asyncCallbackInfo is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } napi_value result = nullptr; @@ -603,12 +602,12 @@ napi_value SetResultPromise(napi_env env, AsyncCallbackInfo *asyncCallbackInfo) napi_resolve_deferred(env, asyncCallbackInfo->deferred, result); napi_delete_async_work(env, asyncCallbackInfo->asyncWork); delete asyncCallbackInfo; - TAG_LOGI(AAFwkTag::FA, "NAPI_SetResult, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "complete end"); }, static_cast(asyncCallbackInfo), &asyncCallbackInfo->asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, asyncCallbackInfo->asyncWork)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } @@ -622,12 +621,12 @@ int CreateUVQueueWork(uv_loop_t *loop, uv_work_t *work) [](uv_work_t *work, int status) { // JS Thread if (work == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, uv_queue_work work == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null work"); return; } auto onAbilityCB = static_cast(work->data); if (onAbilityCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, uv_queue_work onAbilityCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null onAbilityCB"); delete work; work = nullptr; return; @@ -661,40 +660,46 @@ int CreateUVQueueWork(uv_loop_t *loop, uv_work_t *work) onAbilityCB = nullptr; delete work; work = nullptr; - TAG_LOGI(AAFwkTag::FA, "CallOnAbilityResult, uv_queue_work end"); + TAG_LOGI(AAFwkTag::FA, "uv_queue_work end"); }); return rev; } void CallOnAbilityResult(int requestCode, int resultCode, const Want &resultData, CallbackInfo callbackInfo) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (callbackInfo.env == nullptr) { - TAG_LOGE(AAFwkTag::FA, "CallOnAbilityResult cb.env is nullptr."); + TAG_LOGE(AAFwkTag::FA, "null cb.env"); return; } if (callbackInfo.napiAsyncTask == nullptr) { - TAG_LOGE(AAFwkTag::FA, "CallOnAbilityResult cb.asyncTask is nullptr."); + TAG_LOGE(AAFwkTag::FA, "null cb.asyncTask"); return; } uv_loop_t *loop = nullptr; napi_get_uv_event_loop(callbackInfo.env, &loop); if (loop == nullptr) { - TAG_LOGE(AAFwkTag::FA, "loop instance is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null loop"); return; } auto work = new uv_work_t; auto onAbilityCB = new (std::nothrow) OnAbilityCallback; + if (onAbilityCB == nullptr) { + TAG_LOGE(AAFwkTag::FA, "Failed to allocate OnAbilityCallback"); + delete work; + return; + } + onAbilityCB->requestCode = requestCode; onAbilityCB->resultCode = resultCode; onAbilityCB->resultData = resultData; onAbilityCB->cb = callbackInfo; if (work == nullptr) { - TAG_LOGE(AAFwkTag::FA, "work == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null work"); return; } work->data = static_cast(onAbilityCB); @@ -710,23 +715,23 @@ void CallOnAbilityResult(int requestCode, int resultCode, const Want &resultData work = nullptr; } } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } EXTERN_C_END bool InnerUnwrapWant(napi_env env, napi_value args, Want &want) { - TAG_LOGI(AAFwkTag::FA, "%{public}s called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); napi_valuetype valueType = napi_undefined; NAPI_CALL_BASE(env, napi_typeof(env, args, &valueType), false); if (valueType != napi_object) { - TAG_LOGE(AAFwkTag::FA, "%{public}s wrong argument type", __func__); + TAG_LOGE(AAFwkTag::FA, "wrong argument type"); return false; } napi_value jsWant = GetPropertyValueByPropertyName(env, args, "want", napi_object); if (jsWant == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s jsWant == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null jsWant"); return false; } @@ -735,7 +740,7 @@ bool InnerUnwrapWant(napi_env env, napi_value args, Want &want) napi_value UnwrapForResultParam(CallAbilityParam ¶m, napi_env env, napi_value args) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); // dummy requestCode for NativeC++ interface and onabilityresult callback param.requestCode = dummyRequestCode_; param.forResultOption = true; @@ -759,20 +764,20 @@ napi_value UnwrapForResultParam(CallAbilityParam ¶m, napi_env env, napi_valu if (jsSettingObj != nullptr) { param.setting = AbilityStartSetting::GetEmptySetting(); if (!UnwrapAbilityStartSetting(env, jsSettingObj, *(param.setting))) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, unwrap abilityStartSetting failed.", __func__); + TAG_LOGE(AAFwkTag::FA, "unwrap abilityStartSetting failed"); } - TAG_LOGI(AAFwkTag::FA, "%{public}s abilityStartSetting", __func__); + TAG_LOGI(AAFwkTag::FA, "abilityStartSetting"); } napi_value result; NAPI_CALL(env, napi_create_int32(env, 1, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value UnwrapAbilityResult(CallAbilityParam ¶m, napi_env env, napi_value args) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); // unwrap the param napi_valuetype valueType = napi_undefined; NAPI_CALL(env, napi_typeof(env, args, &valueType)); @@ -783,14 +788,14 @@ napi_value UnwrapAbilityResult(CallAbilityParam ¶m, napi_env env, napi_value NAPI_CALL(env, napi_typeof(env, property, &valueType)); NAPI_ASSERT(env, valueType == napi_number, "property type mismatch!"); NAPI_CALL(env, napi_get_value_int32(env, property, ¶m.requestCode)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, requestCode=%{public}d.", __func__, param.requestCode); + TAG_LOGI(AAFwkTag::FA, "requestCode=%{public}d", param.requestCode); // unwrap the param : want object InnerUnwrapWant(env, args, param.want); napi_value result; NAPI_CALL(env, napi_create_int32(env, 1, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } @@ -806,13 +811,13 @@ napi_value GetWantSyncWrap(napi_env env, napi_callback_info info, AsyncCallbackI { TAG_LOGI(AAFwkTag::FA, "called"); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, asyncCallbackInfo == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return nullptr; } asyncCallbackInfo->errCode = NAPI_ERR_NO_ERROR; if (asyncCallbackInfo->ability == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, ability == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null ability"); asyncCallbackInfo->errCode = NAPI_ERR_ACE_ABILITY; return nullptr; } @@ -830,7 +835,7 @@ napi_value GetWantSyncWrap(napi_env env, napi_callback_info info, AsyncCallbackI } else { result = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } @@ -858,9 +863,9 @@ napi_value NAPI_GetWantSync(napi_env env, napi_callback_info info) if (ret == nullptr) { ret = WrapVoidToJS(env); - TAG_LOGE(AAFwkTag::FA, "%{public}s ret == null", __func__); + TAG_LOGE(AAFwkTag::FA, "null ret"); } else { - TAG_LOGI(AAFwkTag::FA, "%{public}s, exit.", __func__); + TAG_LOGI(AAFwkTag::FA, "exit"); } return ret; } @@ -931,23 +936,23 @@ napi_value NAPI_GetHapModuleInfo(napi_env env, napi_callback_info info) */ napi_value NAPI_GetDataAbilityHelper(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DataAbilityHelperCB *dataAbilityHelperCB = new (std::nothrow) DataAbilityHelperCB; if (dataAbilityHelperCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, dataAbilityHelperCB == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelperCB"); return WrapVoidToJS(env); } dataAbilityHelperCB->cbBase.cbInfo.env = env; napi_value ret = GetDataAbilityHelperWrap(env, info, dataAbilityHelperCB); if (ret == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, ret == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null ret"); if (dataAbilityHelperCB != nullptr) { delete dataAbilityHelperCB; dataAbilityHelperCB = nullptr; } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -961,9 +966,9 @@ napi_value NAPI_GetDataAbilityHelper(napi_env env, napi_callback_info info) */ napi_value GetDataAbilityHelperWrap(napi_env env, napi_callback_info info, DataAbilityHelperCB *dataAbilityHelperCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (dataAbilityHelperCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s,dataAbilityHelperCB == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelperCB"); return nullptr; } @@ -975,7 +980,7 @@ napi_value GetDataAbilityHelperWrap(napi_env env, napi_callback_info info, DataA NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument count.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid argc"); return nullptr; } @@ -990,16 +995,16 @@ napi_value GetDataAbilityHelperWrap(napi_env env, napi_callback_info info, DataA } else { ret = GetDataAbilityHelperPromise(env, dataAbilityHelperCB); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } napi_value GetDataAbilityHelperAsync( napi_env env, napi_value *args, const size_t argCallback, DataAbilityHelperCB *dataAbilityHelperCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "asyncCallback"); if (args == nullptr || dataAbilityHelperCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1014,7 +1019,7 @@ napi_value GetDataAbilityHelperAsync( NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "worker pool thread execute"); }, GetDataAbilityHelperAsyncCompleteCB, static_cast(dataAbilityHelperCB), @@ -1023,15 +1028,15 @@ napi_value GetDataAbilityHelperAsync( napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value GetDataAbilityHelperPromise(napi_env env, DataAbilityHelperCB *dataAbilityHelperCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "promise"); if (dataAbilityHelperCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -1044,23 +1049,23 @@ napi_value GetDataAbilityHelperPromise(napi_env env, DataAbilityHelperCB *dataAb NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "worker pool thread execute"); }, GetDataAbilityHelperPromiseCompleteCB, static_cast(dataAbilityHelperCB), &dataAbilityHelperCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, dataAbilityHelperCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void GetDataAbilityHelperAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DataAbilityHelperCB *dataAbilityHelperCB = static_cast(data); if (dataAbilityHelperCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "GetDataAbilityHelperAsyncCompleteCB, dataAbilityHelperCB is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelperCB"); return; } @@ -1077,7 +1082,7 @@ void GetDataAbilityHelperAsyncCompleteCB(napi_env env, napi_status status, void if (IsTypeForNapiValue(env, dataAbilityHelperCB->result, napi_object)) { result[PARAM1] = dataAbilityHelperCB->result; } else { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, helper is nullptr."); + TAG_LOGI(AAFwkTag::FA, "helper is nullptr"); result[PARAM1] = WrapVoidToJS(env); } result[PARAM0] = GetCallbackErrorValue(env, NO_ERROR); @@ -1089,15 +1094,15 @@ void GetDataAbilityHelperAsyncCompleteCB(napi_env env, napi_status status, void napi_delete_reference(env, dataAbilityHelperCB->uri); } napi_delete_async_work(env, dataAbilityHelperCB->cbBase.asyncWork); - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void GetDataAbilityHelperPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DataAbilityHelperCB *dataAbilityHelperCB = static_cast(data); if (dataAbilityHelperCB == nullptr) { - TAG_LOGI(AAFwkTag::FA, "GetDataAbilityHelperPromiseCompleteCB, dataAbilityHelperCB is nullptr."); + TAG_LOGI(AAFwkTag::FA, "null dataAbilityHelperCB"); return; } @@ -1111,14 +1116,14 @@ void GetDataAbilityHelperPromiseCompleteCB(napi_env env, napi_status status, voi } else { result = GetCallbackErrorValue(env, dataAbilityHelperCB->cbBase.errCode); napi_reject_deferred(env, dataAbilityHelperCB->cbBase.deferred, result); - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, helper is nullptr."); + TAG_LOGI(AAFwkTag::FA, "null helper"); } if (dataAbilityHelperCB->uri != nullptr) { napi_delete_reference(env, dataAbilityHelperCB->uri); } napi_delete_async_work(env, dataAbilityHelperCB->cbBase.asyncWork); - TAG_LOGI(AAFwkTag::FA, "NAPI_GetDataAbilityHelper, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } /** @@ -1144,10 +1149,10 @@ napi_value NAPI_AcquireDataAbilityHelper(napi_env env, napi_callback_info info) */ napi_value NAPI_FAContinueAbility(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); AsyncCallbackInfo *asyncCallbackInfo = CreateAsyncCallbackInfo(env); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, asyncCallbackInfo == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return WrapVoidToJS(env); } @@ -1159,7 +1164,7 @@ napi_value NAPI_FAContinueAbility(napi_env env, napi_callback_info info) } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -1182,7 +1187,7 @@ napi_value ContinueAbilityWrap(napi_env env, napi_callback_info info, AsyncCallb NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, nullptr, nullptr)); NAPI_CALL(env, napi_typeof(env, args[0], &valueType)); if (valueType != napi_object && valueType != napi_function) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type. Object or function expected.", __func__); + TAG_LOGE(AAFwkTag::FA, "wrong argument type. Object or function expected"); return nullptr; } if (argc == 0) { @@ -1197,14 +1202,14 @@ napi_value ContinueAbilityWrap(napi_env env, napi_callback_info info, AsyncCallb napi_valuetype value = napi_undefined; NAPI_CALL(env, napi_typeof(env, args[1], &value)); if (value != napi_function) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type. function expected.", __func__); + TAG_LOGE(AAFwkTag::FA, "function expected"); return nullptr; } ret = ContinueAbilityAsync(env, args, asyncCallbackInfo, argc); } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument count.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid argc"); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -1212,25 +1217,25 @@ void CreateContinueAsyncWork(napi_env env, napi_value &resourceName, AsyncCallba { napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbility, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "worker pool thread execute"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "NAPI_ContinueAbility, asyncCallbackInfo is nullptr."); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } if (asyncCallbackInfo->ability != nullptr) { asyncCallbackInfo->ability->ContinueAbility(asyncCallbackInfo->optionInfo.deviceId); } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_ContinueAbilityForResult, asyncCallbackInfo == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbilityForResult, worker pool thread execute exit."); + TAG_LOGI(AAFwkTag::FA, "worker pool thread execute exit"); }, [](napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbility, main event thread end."); + TAG_LOGI(AAFwkTag::FA, "main event thread end"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "NAPI_ContinueAbility complete, asyncCallbackInfo is nullptr."); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } napi_value callback = nullptr; @@ -1248,7 +1253,7 @@ void CreateContinueAsyncWork(napi_env env, napi_value &resourceName, AsyncCallba } napi_delete_async_work(env, asyncCallbackInfo->asyncWork); delete asyncCallbackInfo; - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbilityForResult, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); }, static_cast(asyncCallbackInfo), &asyncCallbackInfo->asyncWork); @@ -1256,9 +1261,9 @@ void CreateContinueAsyncWork(napi_env env, napi_value &resourceName, AsyncCallba napi_value ContinueAbilityAsync(napi_env env, napi_value *args, AsyncCallbackInfo *asyncCallbackInfo, size_t argc) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "asyncCallback"); if (args == nullptr || asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1269,11 +1274,11 @@ napi_value ContinueAbilityAsync(napi_env env, napi_value *args, AsyncCallbackInf napi_valuetype valueTypeOptions = napi_undefined; NAPI_CALL(env, napi_typeof(env, args[0], &valueTypeOptions)); if (valueTypeOptions != napi_object) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type. Object expected.", __func__); + TAG_LOGE(AAFwkTag::FA, "object expected"); return nullptr; } if (GetContinueAbilityOptionsInfoCommon(env, args[0], asyncCallbackInfo->optionInfo) == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, GetContinueAbilityOptionsInfoCommonFail", __func__); + TAG_LOGE(AAFwkTag::FA, "getContinueAbilityOptionsInfoCommon fail"); return nullptr; } @@ -1297,15 +1302,15 @@ napi_value ContinueAbilityAsync(napi_env env, napi_value *args, AsyncCallbackInf napi_queue_async_work(env, asyncCallbackInfo->asyncWork); napi_value result = nullptr; napi_get_null(env, &result); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value ContinueAbilityPromise(napi_env env, napi_value *args, AsyncCallbackInfo *asyncCallbackInfo, size_t argc) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } @@ -1314,7 +1319,7 @@ napi_value ContinueAbilityPromise(napi_env env, napi_value *args, AsyncCallbackI napi_valuetype valueTypeOptions = napi_undefined; NAPI_CALL(env, napi_typeof(env, args[0], &valueTypeOptions)); if (valueTypeOptions != napi_object) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type. Object expected.", __func__); + TAG_LOGE(AAFwkTag::FA, "object expected"); return nullptr; } if (GetContinueAbilityOptionsInfoCommon(env, args[0], asyncCallbackInfo->optionInfo) == nullptr) { @@ -1332,26 +1337,24 @@ napi_value ContinueAbilityPromise(napi_env env, napi_value *args, AsyncCallbackI napi_create_async_work(env, nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbility, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "execute called"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE( - AAFwkTag::FA, "NAPI_ContinueAbility, worker pool thread execute asyncCallbackInfo is nullptr."); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } if (asyncCallbackInfo->ability != nullptr) { asyncCallbackInfo->ability->ContinueAbility(asyncCallbackInfo->optionInfo.deviceId); } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_ContinueAbilityForResult, asyncCallbackInfo == nullptr"); + TAG_LOGE(AAFwkTag::FA, "null ability"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbilityForResult, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "execute end"); }, [](napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbility, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "complete called"); AsyncCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE( - AAFwkTag::FA, "NAPI_ContinueAbility, main event thread complete asyncCallbackInfo is nullptr."); + TAG_LOGE(AAFwkTag::FA, "null asyncCallbackInfo"); return; } napi_value result = nullptr; @@ -1359,11 +1362,11 @@ napi_value ContinueAbilityPromise(napi_env env, napi_value *args, AsyncCallbackI napi_resolve_deferred(env, asyncCallbackInfo->deferred, result); napi_delete_async_work(env, asyncCallbackInfo->asyncWork); delete asyncCallbackInfo; - TAG_LOGI(AAFwkTag::FA, "NAPI_ContinueAbilityForResult, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "complete end"); }, static_cast(asyncCallbackInfo), &asyncCallbackInfo->asyncWork); napi_queue_async_work(env, asyncCallbackInfo->asyncWork); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } } // namespace AppExecFwk diff --git a/frameworks/js/napi/featureAbility/feature_ability_constant.cpp b/frameworks/js/napi/featureAbility/feature_ability_constant.cpp index 040366364c..3f2fd15680 100644 --- a/frameworks/js/napi/featureAbility/feature_ability_constant.cpp +++ b/frameworks/js/napi/featureAbility/feature_ability_constant.cpp @@ -66,7 +66,7 @@ napi_value FAConstantInit(napi_env env, napi_value exports) void SetNamedProperty(napi_env env, napi_value dstObj, const char *objName, const char *propName) { - TAG_LOGD(AAFwkTag::FA, "SetNamedProperty start"); + TAG_LOGD(AAFwkTag::FA, "called"); napi_value prop = nullptr; napi_create_string_utf8(env, objName, NAPI_AUTO_LENGTH, &prop); napi_set_named_property(env, dstObj, propName, prop); @@ -74,7 +74,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) { - TAG_LOGD(AAFwkTag::FA, "SetNamedProperty start"); + TAG_LOGD(AAFwkTag::FA, "end"); napi_value prop = nullptr; napi_create_int32(env, objValue, &prop); napi_set_named_property(env, dstObj, propName, prop); diff --git a/frameworks/js/napi/featureAbility/napi_data_ability_helper.cpp b/frameworks/js/napi/featureAbility/napi_data_ability_helper.cpp index c9b27bd547..b0a0d7701f 100644 --- a/frameworks/js/napi/featureAbility/napi_data_ability_helper.cpp +++ b/frameworks/js/napi/featureAbility/napi_data_ability_helper.cpp @@ -183,10 +183,10 @@ napi_value DataAbilityHelperConstructor(napi_env env, napi_callback_info info) */ napi_value NAPI_Insert(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperInsertCB *insertCB = new (std::nothrow) DAHelperInsertCB; if (insertCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, insertCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null insertCB"); return WrapVoidToJS(env); } insertCB->cbBase.cbInfo.env = env; @@ -196,12 +196,12 @@ napi_value NAPI_Insert(napi_env env, napi_callback_info info) napi_value ret = InsertWrap(env, info, insertCB); if (ret == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, ret == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "ret == nullptr"); delete insertCB; insertCB = nullptr; ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,called end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -215,7 +215,7 @@ napi_value NAPI_Insert(napi_env env, napi_callback_info info) */ napi_value InsertWrap(napi_env env, napi_callback_info info, DAHelperInsertCB *insertCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); size_t argcAsync = ARGS_THREE; const size_t argcPromise = ARGS_TWO; const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; @@ -225,7 +225,7 @@ napi_value InsertWrap(napi_env env, napi_callback_info info, DAHelperInsertCB *i NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong parameter count.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid argc"); return nullptr; } @@ -233,9 +233,9 @@ napi_value InsertWrap(napi_env env, napi_callback_info info, DAHelperInsertCB *i NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); if (valuetype == napi_string) { insertCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - TAG_LOGI(AAFwkTag::FA, "%{public}s,uri=%{public}s", __func__, insertCB->uri.c_str()); + TAG_LOGI(AAFwkTag::FA, "uri=%{public}s", insertCB->uri.c_str()); } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type.", __func__); + TAG_LOGE(AAFwkTag::FA, "wrong argument type"); } insertCB->valueBucket.Clear(); @@ -247,7 +247,7 @@ napi_value InsertWrap(napi_env env, napi_callback_info info, DAHelperInsertCB *i } else { ret = InsertPromise(env, insertCB); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -319,26 +319,26 @@ void SetValuesBucketObject( */ napi_value UnwrapValuesBucket(std::string &value, napi_env env, napi_value args) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); napi_valuetype valueType = napi_undefined; napi_typeof(env, args, &valueType); if (valueType != napi_object) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, valueType != napi_object.", __func__); + TAG_LOGE(AAFwkTag::FA, "valueType != napi_object"); return nullptr; } std::string strValue = ""; if (UnwrapStringByPropertyName(env, args, "value", strValue)) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,strValue=%{private}s", __func__, strValue.c_str()); + TAG_LOGI(AAFwkTag::FA, "strValue=%{private}s", strValue.c_str()); value = strValue; } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, value == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid value"); return nullptr; } napi_value result; NAPI_CALL(env, napi_create_int32(env, 1, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } @@ -352,7 +352,7 @@ napi_value UnwrapValuesBucket(std::string &value, napi_env env, napi_value args) */ napi_value NAPI_NotifyChange(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperNotifyChangeCB *notifyChangeCB = new DAHelperNotifyChangeCB; notifyChangeCB->cbBase.cbInfo.env = env; notifyChangeCB->cbBase.asyncWork = nullptr; @@ -361,12 +361,12 @@ napi_value NAPI_NotifyChange(napi_env env, napi_callback_info info) napi_value ret = NotifyChangeWrap(env, info, notifyChangeCB); if (ret == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, ret == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "ret == nullptr"); delete notifyChangeCB; notifyChangeCB = nullptr; ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -380,7 +380,7 @@ napi_value NAPI_NotifyChange(napi_env env, napi_callback_info info) */ napi_value NotifyChangeWrap(napi_env env, napi_callback_info info, DAHelperNotifyChangeCB *notifyChangeCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); size_t argcAsync = ARGS_TWO; const size_t argcPromise = ARGS_ONE; const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; @@ -390,7 +390,7 @@ napi_value NotifyChangeWrap(napi_env env, napi_callback_info info, DAHelperNotif NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); if (argcAsync > argCountWithAsync) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong parameter count.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid argc"); return nullptr; } @@ -398,7 +398,7 @@ napi_value NotifyChangeWrap(napi_env env, napi_callback_info info, DAHelperNotif NAPI_CALL(env, napi_typeof(env, args[PARAM0], &valuetype)); if (valuetype == napi_string) { notifyChangeCB->uri = NapiValueToStringUtf8(env, args[PARAM0]); - TAG_LOGI(AAFwkTag::FA, "%{public}s,uri=%{public}s", __func__, notifyChangeCB->uri.c_str()); + TAG_LOGI(AAFwkTag::FA, "uri=%{public}s", notifyChangeCB->uri.c_str()); } GetDataAbilityHelper(env, thisVar, notifyChangeCB->dataAbilityHelper); @@ -420,7 +420,7 @@ napi_value NotifyChangeWrap(napi_env env, napi_callback_info info, DAHelperNotif */ napi_value NAPI_Register(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperOnOffCB *onCB = new DAHelperOnOffCB; onCB->cbBase.cbInfo.env = env; onCB->cbBase.asyncWork = nullptr; @@ -429,12 +429,12 @@ napi_value NAPI_Register(napi_env env, napi_callback_info info) napi_value ret = RegisterWrap(env, info, onCB); if (ret == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, ret == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null ret"); delete onCB; onCB = nullptr; ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,called end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -448,7 +448,7 @@ napi_value NAPI_Register(napi_env env, napi_callback_info info) */ napi_value RegisterWrap(napi_env env, napi_callback_info info, DAHelperOnOffCB *onCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,start", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); size_t argcAsync = ARGS_THREE; const size_t argcPromise = ARGS_TWO; const size_t argCountWithAsync = argcPromise + ARGS_ASYNC_COUNT; @@ -458,7 +458,7 @@ napi_value RegisterWrap(napi_env env, napi_callback_info info, DAHelperOnOffCB * NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); if (argcAsync > argCountWithAsync) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong parameter count.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid argc"); return nullptr; } @@ -468,22 +468,22 @@ napi_value RegisterWrap(napi_env env, napi_callback_info info, DAHelperOnOffCB * if (valuetype == napi_string) { std::string type = NapiValueToStringUtf8(env, args[PARAM0]); if (type == "dataChange") { - TAG_LOGI(AAFwkTag::FA, "%{public}s, Right type=%{public}s", __func__, type.c_str()); + TAG_LOGI(AAFwkTag::FA, "type:%{public}s", type.c_str()); } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type is %{public}s.", __func__, type.c_str()); + TAG_LOGE(AAFwkTag::FA, "error type: %{public}s", type.c_str()); onCB->result = INVALID_PARAMETER; } } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type.", __func__); + TAG_LOGE(AAFwkTag::FA, "wrong type"); onCB->result = INVALID_PARAMETER; } NAPI_CALL(env, napi_typeof(env, args[PARAM1], &valuetype)); if (valuetype == napi_string) { onCB->uri = NapiValueToStringUtf8(env, args[PARAM1]); - TAG_LOGI(AAFwkTag::FA, "%{public}s,uri=%{public}s", __func__, onCB->uri.c_str()); + TAG_LOGI(AAFwkTag::FA, "uri=%{public}s", onCB->uri.c_str()); } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type.", __func__); + TAG_LOGE(AAFwkTag::FA, "wrong type"); onCB->result = INVALID_PARAMETER; } GetDataAbilityHelper(env, thisVar, onCB->dataAbilityHelper); @@ -495,9 +495,9 @@ napi_value RegisterWrap(napi_env env, napi_callback_info info, DAHelperOnOffCB * napi_value RegisterAsync( napi_env env, napi_value *args, size_t argcAsync, const size_t argcPromise, DAHelperOnOffCB *onCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || onCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -544,7 +544,7 @@ void RegisterExecuteCB(napi_env env, void *data) auto onCBIter = std::find(g_registerInstances.begin(), g_registerInstances.end(), onCB); if (onCBIter == g_registerInstances.end()) { // onCB is invalid or onCB has been delete - TAG_LOGE(AAFwkTag::FA, "%{public}s, input params onCB is invalid.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid onCB"); return; } @@ -554,7 +554,7 @@ void RegisterExecuteCB(napi_env env, void *data) OHOS::Uri uri(onCB->uri); dataAbilityHelper->RegisterObserver(uri, onCB->observer); } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, dataAbilityHelper uri is empty or callback is nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "empty uri or null callback"); } } } @@ -564,14 +564,14 @@ void RegisterCompleteCB(napi_env env, napi_status status, void *data) TAG_LOGI(AAFwkTag::FA, "NAPI_Register, main event thread complete."); DAHelperOnOffCB *onCB = static_cast(data); if (onCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, input params onCB is nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null onCB"); return; } auto onCBIter = std::find(g_registerInstances.begin(), g_registerInstances.end(), onCB); if (onCBIter == g_registerInstances.end()) { // onCB is invalid or onCB has been delete - TAG_LOGE(AAFwkTag::FA, "%{public}s, input params onCB is invalid.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid onCB"); return; } @@ -593,7 +593,7 @@ void RegisterCompleteCB(napi_env env, napi_status status, void *data) */ napi_value NAPI_UnRegister(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperOnOffCB *offCB = new DAHelperOnOffCB; offCB->cbBase.cbInfo.env = env; offCB->cbBase.asyncWork = nullptr; @@ -602,12 +602,12 @@ napi_value NAPI_UnRegister(napi_env env, napi_callback_info info) napi_value ret = UnRegisterWrap(env, info, offCB); if (ret == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, ret == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null ret"); delete offCB; offCB = nullptr; ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,called end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } @@ -621,7 +621,7 @@ napi_value NAPI_UnRegister(napi_env env, napi_callback_info info) */ napi_value UnRegisterWrap(napi_env env, napi_callback_info info, DAHelperOnOffCB *offCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); size_t argcAsync = ARGS_THREE; const size_t argCountWithAsync = ARGS_TWO + ARGS_ASYNC_COUNT; napi_value args[ARGS_MAX_COUNT] = {nullptr}; @@ -630,7 +630,7 @@ napi_value UnRegisterWrap(napi_env env, napi_callback_info info, DAHelperOnOffCB NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, &thisVar, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument count.", __func__); + TAG_LOGE(AAFwkTag::FA, "invalid argc"); return nullptr; } @@ -646,7 +646,7 @@ napi_value UnRegisterWrap(napi_env env, napi_callback_info info, DAHelperOnOffCB offCB->result = INVALID_PARAMETER; } } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, Wrong argument type.", __func__); + TAG_LOGE(AAFwkTag::FA, "wrong argument type"); offCB->result = INVALID_PARAMETER; } diff --git a/frameworks/js/napi/featureAbility/napi_data_ability_helper_utils.cpp b/frameworks/js/napi/featureAbility/napi_data_ability_helper_utils.cpp index 02b55b1e2e..5045ef4675 100644 --- a/frameworks/js/napi/featureAbility/napi_data_ability_helper_utils.cpp +++ b/frameworks/js/napi/featureAbility/napi_data_ability_helper_utils.cpp @@ -30,9 +30,9 @@ namespace AppExecFwk { napi_value InsertAsync(napi_env env, napi_value *args, const size_t argCallback, DAHelperInsertCB *insertCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || insertCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -55,15 +55,15 @@ napi_value InsertAsync(napi_env env, napi_value *args, const size_t argCallback, NAPI_CALL(env, napi_queue_async_work_with_qos(env, insertCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value InsertPromise(napi_env env, DAHelperInsertCB *insertCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (insertCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -82,13 +82,13 @@ napi_value InsertPromise(napi_env env, DAHelperInsertCB *insertCB) static_cast(insertCB), &insertCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, insertCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void InsertExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperInsertCB *insertCB = static_cast(data); if (insertCB == nullptr) { TAG_LOGW(AAFwkTag::FA, "NAPI_Insert, insertCB is nullptr."); @@ -103,14 +103,14 @@ void InsertExecuteCB(napi_env env, void *data) insertCB->execResult = NO_ERROR; } } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_Insert, dataAbilityHelper == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void InsertAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperInsertCB *insertCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -129,12 +129,12 @@ void InsertAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, insertCB->cbBase.asyncWork)); delete insertCB; insertCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void InsertPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperInsertCB *insertCB = static_cast(data); napi_value result = nullptr; napi_create_int32(env, insertCB->result, &result); @@ -142,15 +142,15 @@ void InsertPromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, insertCB->cbBase.asyncWork)); delete insertCB; insertCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_Insert, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value NotifyChangeAsync( napi_env env, napi_value *args, size_t argcAsync, const size_t argcPromise, DAHelperNotifyChangeCB *notifyChangeCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || notifyChangeCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -178,9 +178,9 @@ napi_value NotifyChangeAsync( napi_value NotifyChangePromise(napi_env env, DAHelperNotifyChangeCB *notifyChangeCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (notifyChangeCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -204,7 +204,7 @@ napi_value NotifyChangePromise(napi_env env, DAHelperNotifyChangeCB *notifyChang void NotifyChangeExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_NotifyChange, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperNotifyChangeCB *notifyChangeCB = static_cast(data); auto dataAbilityHelper = notifyChangeCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -214,14 +214,14 @@ void NotifyChangeExecuteCB(napi_env env, void *data) dataAbilityHelper->NotifyChange(uri); notifyChangeCB->execResult = NO_ERROR; } else { - TAG_LOGE(AAFwkTag::FA, "%{public}s, notifyChangeCB uri is empty.", __func__); + TAG_LOGE(AAFwkTag::FA, "empty uri"); } } } void NotifyChangeAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_NotifyChange, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperNotifyChangeCB *notifyChangeCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -233,7 +233,7 @@ void NotifyChangeAsyncCompleteCB(napi_env env, napi_status status, void *data) if (!IsTypeForNapiValue(env, callback, napi_function)) { delete notifyChangeCB; notifyChangeCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_NotifyChange, callback is invalid."); + TAG_LOGI(AAFwkTag::FA, "invalid callback"); return; } @@ -251,7 +251,7 @@ void NotifyChangeAsyncCompleteCB(napi_env env, napi_status status, void *data) void NotifyChangePromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_NotifyChange, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperNotifyChangeCB *notifyChangeCB = static_cast(data); napi_value result = nullptr; napi_create_int32(env, 0, &result); @@ -263,9 +263,9 @@ void NotifyChangePromiseCompleteCB(napi_env env, napi_status status, void *data) napi_value GetTypeAsync(napi_env env, napi_value *args, const size_t argCallback, DAHelperGetTypeCB *gettypeCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || gettypeCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -288,15 +288,15 @@ napi_value GetTypeAsync(napi_env env, napi_value *args, const size_t argCallback NAPI_CALL(env, napi_queue_async_work_with_qos(env, gettypeCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value GetTypePromise(napi_env env, DAHelperGetTypeCB *gettypeCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (gettypeCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -315,13 +315,13 @@ napi_value GetTypePromise(napi_env env, DAHelperGetTypeCB *gettypeCB) static_cast(gettypeCB), &gettypeCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, gettypeCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void GetTypeExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetType, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperGetTypeCB *gettypeCB = static_cast(data); auto dataAbilityHelper = gettypeCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -331,17 +331,17 @@ void GetTypeExecuteCB(napi_env env, void *data) gettypeCB->result = dataAbilityHelper->GetType(uri); gettypeCB->execResult = NO_ERROR; } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_GetType, dataAbilityHelper uri is empty."); + TAG_LOGE(AAFwkTag::FA, "empty uri"); } } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_GetType, dataAbilityHelper == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_GetType, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void GetTypeAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetType, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperGetTypeCB *gettypeCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -361,12 +361,12 @@ void GetTypeAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, gettypeCB->cbBase.asyncWork)); delete gettypeCB; gettypeCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_GetType, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void GetTypePromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetType, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperGetTypeCB *gettypeCB = static_cast(data); napi_value result = nullptr; NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, gettypeCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); @@ -374,15 +374,15 @@ void GetTypePromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, gettypeCB->cbBase.asyncWork)); delete gettypeCB; gettypeCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_GetType, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value GetFileTypesAsync( napi_env env, napi_value *args, const size_t argCallback, DAHelperGetFileTypesCB *getfiletypesCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || getfiletypesCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -405,15 +405,15 @@ napi_value GetFileTypesAsync( NAPI_CALL(env, napi_queue_async_work_with_qos(env, getfiletypesCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value GetFileTypesPromise(napi_env env, DAHelperGetFileTypesCB *getfiletypesCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (getfiletypesCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -432,36 +432,36 @@ napi_value GetFileTypesPromise(napi_env env, DAHelperGetFileTypesCB *getfiletype static_cast(getfiletypesCB), &getfiletypesCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, getfiletypesCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void GetFileTypesExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperGetFileTypesCB *getfiletypesCB = static_cast(data); auto dataAbilityHelper = getfiletypesCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { getfiletypesCB->execResult = INVALID_PARAMETER; if (!getfiletypesCB->uri.empty()) { OHOS::Uri uri(getfiletypesCB->uri); - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, uri:%{public}s", uri.ToString().c_str()); + TAG_LOGI(AAFwkTag::FA, "uri:%{public}s", uri.ToString().c_str()); TAG_LOGI( - AAFwkTag::FA, "NAPI_GetFileTypes, mimeTypeFilter:%{public}s", getfiletypesCB->mimeTypeFilter.c_str()); + AAFwkTag::FA, "mimeTypeFilter:%{public}s", getfiletypesCB->mimeTypeFilter.c_str()); getfiletypesCB->result = dataAbilityHelper->GetFileTypes(uri, getfiletypesCB->mimeTypeFilter); getfiletypesCB->execResult = NO_ERROR; } else { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, dataAbilityHelper uri is empty."); + TAG_LOGI(AAFwkTag::FA, "empty uri"); } } else { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, dataAbilityHelper == nullptr."); + TAG_LOGI(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void GetFileTypesAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperGetFileTypesCB *getfiletypesCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -482,12 +482,12 @@ void GetFileTypesAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, getfiletypesCB->cbBase.asyncWork)); delete getfiletypesCB; getfiletypesCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void GetFileTypesPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperGetFileTypesCB *getfiletypesCB = static_cast(data); napi_value result = nullptr; @@ -496,7 +496,7 @@ void GetFileTypesPromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, getfiletypesCB->cbBase.asyncWork)); delete getfiletypesCB; getfiletypesCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_GetFileTypes, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value WrapGetFileTypesCB(napi_env env, const DAHelperGetFileTypesCB &getfiletypesCB) @@ -504,7 +504,7 @@ napi_value WrapGetFileTypesCB(napi_env env, const DAHelperGetFileTypesCB &getfil TAG_LOGI(AAFwkTag::FA, "result.size:%{public}zu", getfiletypesCB.result.size()); for (size_t i = 0; i < getfiletypesCB.result.size(); i++) { TAG_LOGI( - AAFwkTag::FA, "NAPI_GetFileTypes, result[%{public}zu]:%{public}s", i, getfiletypesCB.result.at(i).c_str()); + AAFwkTag::FA, "result[%{public}zu]:%{public}s", i, getfiletypesCB.result.at(i).c_str()); } napi_value proValue = nullptr; @@ -515,16 +515,16 @@ napi_value WrapGetFileTypesCB(napi_env env, const DAHelperGetFileTypesCB &getfil NAPI_CALL(env, napi_create_string_utf8(env, getfiletypesCB.result.at(i).c_str(), NAPI_AUTO_LENGTH, &proValue)); NAPI_CALL(env, napi_set_element(env, jsArrayresult, i, proValue)); } - TAG_LOGI(AAFwkTag::FA, "WrapGetFileTypesCB, end."); + TAG_LOGI(AAFwkTag::FA, "end"); return jsArrayresult; } napi_value NormalizeUriAsync( napi_env env, napi_value *args, const size_t argCallback, DAHelperNormalizeUriCB *normalizeuriCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || normalizeuriCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -547,15 +547,15 @@ napi_value NormalizeUriAsync( NAPI_CALL(env, napi_queue_async_work_with_qos(env, normalizeuriCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value NormalizeUriPromise(napi_env env, DAHelperNormalizeUriCB *normalizeuriCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (normalizeuriCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -574,13 +574,13 @@ napi_value NormalizeUriPromise(napi_env env, DAHelperNormalizeUriCB *normalizeur static_cast(normalizeuriCB), &normalizeuriCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, normalizeuriCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void NormalizeUriExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_NormalizeUri, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperNormalizeUriCB *normalizeuriCB = static_cast(data); Uri uriValue(normalizeuriCB->uri); auto dataAbilityHelper = normalizeuriCB->dataAbilityHelper; @@ -593,14 +593,14 @@ void NormalizeUriExecuteCB(napi_env env, void *data) normalizeuriCB->execResult = NO_ERROR; } } else { - TAG_LOGI(AAFwkTag::FA, "NAPI_NormalizeUri, dataAbilityHelper == nullptr"); + TAG_LOGI(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_NormalizeUri, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void NormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_NormalizeUri, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperNormalizeUriCB *normalizeuriCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -621,12 +621,12 @@ void NormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, normalizeuriCB->cbBase.asyncWork)); delete normalizeuriCB; normalizeuriCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_NormalizeUri, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void NormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_NormalizeUri, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperNormalizeUriCB *normalizeuriCB = static_cast(data); napi_value result = nullptr; NAPI_CALL_RETURN_VOID(env, napi_create_string_utf8(env, normalizeuriCB->result.c_str(), NAPI_AUTO_LENGTH, &result)); @@ -634,15 +634,15 @@ void NormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, normalizeuriCB->cbBase.asyncWork)); delete normalizeuriCB; normalizeuriCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_NormalizeUri, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value DenormalizeUriAsync( napi_env env, napi_value *args, const size_t argCallback, DAHelperDenormalizeUriCB *denormalizeuriCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || denormalizeuriCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -665,15 +665,15 @@ napi_value DenormalizeUriAsync( NAPI_CALL(env, napi_queue_async_work_with_qos(env, denormalizeuriCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value DenormalizeUriPromise(napi_env env, DAHelperDenormalizeUriCB *denormalizeuriCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (denormalizeuriCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -692,13 +692,13 @@ napi_value DenormalizeUriPromise(napi_env env, DAHelperDenormalizeUriCB *denorma static_cast(denormalizeuriCB), &denormalizeuriCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, denormalizeuriCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void DenormalizeUriExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_DenormalizeUri, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperDenormalizeUriCB *denormalizeuriCB = static_cast(data); Uri uriValue(denormalizeuriCB->uri); auto dataAbilityHelper = denormalizeuriCB->dataAbilityHelper; @@ -710,17 +710,17 @@ void DenormalizeUriExecuteCB(napi_env env, void *data) denormalizeuriCB->result = uriValue.ToString(); denormalizeuriCB->execResult = NO_ERROR; } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_DenormalizeUri, dataAbilityHelper uri is empty"); + TAG_LOGE(AAFwkTag::FA, "empty uri"); } } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_DenormalizeUri, dataAbilityHelper == nullptr"); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_DenormalizeUri, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void DenormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_DenormalizeUri, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperDenormalizeUriCB *denormalizeuriCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -741,12 +741,12 @@ void DenormalizeUriAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, denormalizeuriCB->cbBase.asyncWork)); delete denormalizeuriCB; denormalizeuriCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_DenormalizeUri, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void DenormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_DenormalizeUri, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperDenormalizeUriCB *denormalizeuriCB = static_cast(data); napi_value result = nullptr; NAPI_CALL_RETURN_VOID( @@ -755,14 +755,14 @@ void DenormalizeUriPromiseCompleteCB(napi_env env, napi_status status, void *dat NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, denormalizeuriCB->cbBase.asyncWork)); delete denormalizeuriCB; denormalizeuriCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_DenormalizeUri, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value DeleteAsync(napi_env env, napi_value *args, const size_t argCallback, DAHelperDeleteCB *deleteCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || deleteCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -785,15 +785,15 @@ napi_value DeleteAsync(napi_env env, napi_value *args, const size_t argCallback, NAPI_CALL(env, napi_queue_async_work_with_qos(env, deleteCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value DeletePromise(napi_env env, DAHelperDeleteCB *deleteCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (deleteCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -812,13 +812,13 @@ napi_value DeletePromise(napi_env env, DAHelperDeleteCB *deleteCB) static_cast(deleteCB), &deleteCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, deleteCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void DeleteExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Delete, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperDeleteCB *deleteCB = static_cast(data); auto dataAbilityHelper = deleteCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -828,17 +828,17 @@ void DeleteExecuteCB(napi_env env, void *data) deleteCB->result = dataAbilityHelper->Delete(uri, deleteCB->predicates); deleteCB->execResult = NO_ERROR; } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_Delete, dataAbilityHelper uri is empty"); + TAG_LOGE(AAFwkTag::FA, "empty uri"); } } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_Delete, dataAbilityHelper == nullptr"); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_Delete, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void DeleteAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Delete, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "complete"); DAHelperDeleteCB *DeleteCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -857,12 +857,12 @@ void DeleteAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, DeleteCB->cbBase.asyncWork)); delete DeleteCB; DeleteCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_Delete, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void DeletePromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Delete, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperDeleteCB *DeleteCB = static_cast(data); napi_value result = nullptr; napi_create_int32(env, DeleteCB->result, &result); @@ -870,14 +870,14 @@ void DeletePromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, DeleteCB->cbBase.asyncWork)); delete DeleteCB; DeleteCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_Delete, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value UpdateAsync(napi_env env, napi_value *args, const size_t argCallback, DAHelperUpdateCB *updateCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || updateCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -900,15 +900,15 @@ napi_value UpdateAsync(napi_env env, napi_value *args, const size_t argCallback, NAPI_CALL(env, napi_queue_async_work_with_qos(env, updateCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value UpdatePromise(napi_env env, DAHelperUpdateCB *updateCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (updateCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -927,13 +927,13 @@ napi_value UpdatePromise(napi_env env, DAHelperUpdateCB *updateCB) static_cast(updateCB), &updateCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, updateCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void UpdateExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Update, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperUpdateCB *updateCB = static_cast(data); auto dataAbilityHelper = updateCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -943,17 +943,17 @@ void UpdateExecuteCB(napi_env env, void *data) updateCB->result = dataAbilityHelper->Update(uri, updateCB->valueBucket, updateCB->predicates); updateCB->execResult = NO_ERROR; } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_Update, dataAbilityHelper uri is empty"); + TAG_LOGE(AAFwkTag::FA, "empty uri"); } } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_Update, dataAbilityHelper == nullptr"); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_Update, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void UpdateAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Update, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperUpdateCB *updateCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -972,12 +972,12 @@ void UpdateAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, updateCB->cbBase.asyncWork)); delete updateCB; updateCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_Update, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void UpdatePromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_Update, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperUpdateCB *updateCB = static_cast(data); napi_value result = nullptr; napi_create_int32(env, updateCB->result, &result); @@ -985,12 +985,12 @@ void UpdatePromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, updateCB->cbBase.asyncWork)); delete updateCB; updateCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_Update, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void CallErrorAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "CallErrorAsyncCompleteCB, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperErrorCB *errorCB = static_cast(data); if (errorCB != nullptr) { napi_value callback = nullptr; @@ -1010,12 +1010,12 @@ void CallErrorAsyncCompleteCB(napi_env env, napi_status status, void *data) } delete errorCB; errorCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "CallErrorAsyncCompleteCB, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void CallErrorPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "CallErrorPromiseCompleteCB, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperErrorCB *errorCB = static_cast(data); if (errorCB != nullptr) { napi_value result = nullptr; @@ -1025,26 +1025,26 @@ void CallErrorPromiseCompleteCB(napi_env env, napi_status status, void *data) } delete errorCB; errorCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "CallErrorPromiseCompleteCB, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void CallErrorExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "CallErrorExecuteCB, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperErrorCB *errorCB = static_cast(data); if (errorCB != nullptr) { errorCB->execResult = INVALID_PARAMETER; } else { - TAG_LOGE(AAFwkTag::FA, "CallErrorExecuteCB, errorCB is null"); + TAG_LOGE(AAFwkTag::FA, "null errorCB"); } - TAG_LOGI(AAFwkTag::FA, "CallErrorExecuteCB, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value CallErrorAsync(napi_env env, napi_value *args, const size_t argCallback, DAHelperErrorCB *errorCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || errorCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param or errorCB is null.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1061,15 +1061,15 @@ napi_value CallErrorAsync(napi_env env, napi_value *args, const size_t argCallba NAPI_CALL(env, napi_queue_async_work_with_qos(env, errorCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value CallErrorPromise(napi_env env, DAHelperErrorCB *errorCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (errorCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param is null.", __func__); + TAG_LOGE(AAFwkTag::FA, "param is null"); return nullptr; } napi_value resourceName; @@ -1082,13 +1082,13 @@ napi_value CallErrorPromise(napi_env env, DAHelperErrorCB *errorCB) NAPI_CALL(env, napi_create_async_work(env, nullptr, resourceName, CallErrorExecuteCB, CallErrorPromiseCompleteCB, static_cast(errorCB), &errorCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, errorCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } napi_value CallErrorWrap(napi_env env, napi_value thisVar, napi_callback_info info, napi_value *args, bool isPromise) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperErrorCB *errorCB = new DAHelperErrorCB; errorCB->cbBase.cbInfo.env = env; errorCB->cbBase.asyncWork = nullptr; @@ -1101,18 +1101,18 @@ napi_value CallErrorWrap(napi_env env, napi_value thisVar, napi_callback_info in ret = CallErrorPromise(env, errorCB); } if (ret == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s,ret == nullptr", __func__); + TAG_LOGE(AAFwkTag::FA, "null ret"); delete errorCB; errorCB = nullptr; ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return ret; } void CallExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "CallExecuteCB, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperCallCB *callCB = static_cast(data); auto dataAbilityHelper = callCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -1123,14 +1123,14 @@ void CallExecuteCB(napi_env env, void *data) callCB->execResult = NO_ERROR; } } else { - TAG_LOGE(AAFwkTag::FA, "CallExecuteCB, dataAbilityHelper == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "CallExecuteCB, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } static std::string ExcludeTag(const std::string& jsonString, const std::string& tagString) { - TAG_LOGD(AAFwkTag::FA, "enter"); + TAG_LOGD(AAFwkTag::FA, "called"); size_t pos = jsonString.find(tagString); if (pos == std::string::npos) { return jsonString; @@ -1150,7 +1150,7 @@ static std::string ExcludeTag(const std::string& jsonString, const std::string& if (valuePos >= valueString.size()) { return ""; } - TAG_LOGD(AAFwkTag::FA, "exit"); + TAG_LOGD(AAFwkTag::FA, "end"); valueString = valueString.substr(valuePos); return valueString.substr(0, valueString.size() - 1); } @@ -1166,14 +1166,14 @@ napi_value CallPacMapValue(napi_env env, std::shared_ptr res napi_create_string_utf8(env, resultWithoutTag.c_str(), NAPI_AUTO_LENGTH, &napiResult); NAPI_CALL(env, napi_set_named_property(env, value, "result", napiResult)); } else { - TAG_LOGE(AAFwkTag::FA, "Return result is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null ret"); } return value; } void CallAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "CallAsyncCompleteCB, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperCallCB *callCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -1192,12 +1192,12 @@ void CallAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, callCB->cbBase.asyncWork)); delete callCB; callCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "CallAsyncCompleteCB, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void CallPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "CallPromiseCompleteCB, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperCallCB *callCB = static_cast(data); napi_value result = nullptr; result = CallPacMapValue(env, callCB->result); @@ -1205,14 +1205,14 @@ void CallPromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, callCB->cbBase.asyncWork)); delete callCB; callCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "CallPromiseCompleteCB, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value CallAsync(napi_env env, napi_value *args, const size_t argCallback, DAHelperCallCB *callCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || callCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1235,15 +1235,15 @@ napi_value CallAsync(napi_env env, napi_value *args, const size_t argCallback, D NAPI_CALL(env, napi_queue_async_work(env, callCB->cbBase.asyncWork)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value CallPromise(napi_env env, DAHelperCallCB *callCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (callCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -1262,15 +1262,15 @@ napi_value CallPromise(napi_env env, DAHelperCallCB *callCB) static_cast(callCB), &callCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, callCB->cbBase.asyncWork)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } napi_value OpenFileAsync(napi_env env, napi_value *args, const size_t argCallback, DAHelperOpenFileCB *openFileCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || openFileCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = 0; @@ -1293,15 +1293,15 @@ napi_value OpenFileAsync(napi_env env, napi_value *args, const size_t argCallbac NAPI_CALL(env, napi_queue_async_work_with_qos(env, openFileCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value OpenFilePromise(napi_env env, DAHelperOpenFileCB *openFileCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (openFileCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -1320,13 +1320,13 @@ napi_value OpenFilePromise(napi_env env, DAHelperOpenFileCB *openFileCB) static_cast(openFileCB), &openFileCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, openFileCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void OpenFileExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_OpenFile, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperOpenFileCB *OpenFileCB = static_cast(data); auto dataAbilityHelper = OpenFileCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -1336,17 +1336,17 @@ void OpenFileExecuteCB(napi_env env, void *data) OpenFileCB->result = dataAbilityHelper->OpenFile(uri, OpenFileCB->mode); OpenFileCB->execResult = NO_ERROR; } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_OpenFile, dataAbilityHelper uri is empty"); + TAG_LOGE(AAFwkTag::FA, "empty uri"); } } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_OpenFile, dataAbilityHelper == nullptr"); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_OpenFile, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void OpenFileAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_OpenFile, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperOpenFileCB *OpenFileCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -1365,12 +1365,12 @@ void OpenFileAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, OpenFileCB->cbBase.asyncWork)); delete OpenFileCB; OpenFileCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_OpenFile, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void OpenFilePromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_OpenFileCB, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperOpenFileCB *OpenFileCB = static_cast(data); napi_value result = nullptr; napi_create_int32(env, OpenFileCB->result, &result); @@ -1378,15 +1378,15 @@ void OpenFilePromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, OpenFileCB->cbBase.asyncWork)); delete OpenFileCB; OpenFileCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_OpenFileCB, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value BatchInsertAsync( napi_env env, napi_value *args, const size_t argCallback, DAHelperBatchInsertCB *batchInsertCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (args == nullptr || batchInsertCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1409,15 +1409,15 @@ napi_value BatchInsertAsync( NAPI_CALL(env, napi_queue_async_work(env, batchInsertCB->cbBase.asyncWork)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value BatchInsertPromise(napi_env env, DAHelperBatchInsertCB *batchInsertCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (batchInsertCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -1436,13 +1436,13 @@ napi_value BatchInsertPromise(napi_env env, DAHelperBatchInsertCB *batchInsertCB static_cast(batchInsertCB), &batchInsertCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, batchInsertCB->cbBase.asyncWork)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void BatchInsertExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_BatchInsert, worker pool thread execute."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperBatchInsertCB *batchInsertCB = static_cast(data); auto dataAbilityHelper = batchInsertCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -1452,17 +1452,17 @@ void BatchInsertExecuteCB(napi_env env, void *data) batchInsertCB->result = dataAbilityHelper->BatchInsert(uri, batchInsertCB->values); batchInsertCB->execResult = NO_ERROR; } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_BatchInsert, dataAbilityHelper uri is empyt"); + TAG_LOGE(AAFwkTag::FA, "empty uri"); } } else { - TAG_LOGE(AAFwkTag::FA, "NAPI_BatchInsert, dataAbilityHelper == nullptr"); + TAG_LOGE(AAFwkTag::FA, "null dataAbilityHelper"); } - TAG_LOGI(AAFwkTag::FA, "NAPI_BatchInsert, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void BatchInsertAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_BatchInsert, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperBatchInsertCB *BatchInsertCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -1481,12 +1481,12 @@ void BatchInsertAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, BatchInsertCB->cbBase.asyncWork)); delete BatchInsertCB; BatchInsertCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_BatchInsert, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } void BatchInsertPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "NAPI_BatchInsertCB, main event thread complete."); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperBatchInsertCB *BatchInsertCB = static_cast(data); napi_value result = nullptr; napi_create_int32(env, BatchInsertCB->result, &result); @@ -1494,14 +1494,14 @@ void BatchInsertPromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, BatchInsertCB->cbBase.asyncWork)); delete BatchInsertCB; BatchInsertCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "NAPI_BatchInsertCB, main event thread complete end."); + TAG_LOGI(AAFwkTag::FA, "end"); } napi_value QuerySync(napi_env env, napi_value *args, const size_t argCallback, DAHelperQueryCB *queryCB) { - TAG_LOGD(AAFwkTag::FA, "asyncCallback."); + TAG_LOGD(AAFwkTag::FA, "called"); if (args == nullptr || queryCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "param == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } @@ -1547,9 +1547,9 @@ napi_value QuerySync(napi_env env, napi_value *args, const size_t argCallback, D napi_value QueryPromise(napi_env env, DAHelperQueryCB *queryCB) { - TAG_LOGD(AAFwkTag::FA, "promise."); + TAG_LOGD(AAFwkTag::FA, "called"); if (queryCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "param == nullptr."); + TAG_LOGE(AAFwkTag::FA, "null queryCB"); return nullptr; } @@ -1579,7 +1579,7 @@ napi_value WrapResultSet(napi_env env, const std::shared_ptrcbBase.asyncWork)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return result; } napi_value ExecuteBatchPromise(napi_env env, DAHelperExecuteBatchCB *executeBatchCB) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise start.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); if (executeBatchCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, param is nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null param"); return nullptr; } napi_value resourceName; @@ -1641,13 +1641,13 @@ napi_value ExecuteBatchPromise(napi_env env, DAHelperExecuteBatchCB *executeBatc static_cast(executeBatchCB), &executeBatchCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, executeBatchCB->cbBase.asyncWork)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); return promise; } void ExecuteBatchExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,NAPI_ExecuteBatch, worker pool thread execute start.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperExecuteBatchCB *executeBatchCB = static_cast(data); auto dataAbilityHelper = executeBatchCB->dataAbilityHelper; if (dataAbilityHelper != nullptr) { @@ -1656,12 +1656,12 @@ void ExecuteBatchExecuteCB(napi_env env, void *data) TAG_LOGI(AAFwkTag::FA, "%{public}s, dataAbilityHelper is not nullptr. %{public}zu", __func__, executeBatchCB->result.size()); } - TAG_LOGI(AAFwkTag::FA, "%{public}s,NAPI_ExecuteBatch, worker pool thread execute end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } void ExecuteBatchAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, main event thread complete start.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperExecuteBatchCB *executeBatchCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -1681,12 +1681,12 @@ void ExecuteBatchAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, executeBatchCB->cbBase.asyncWork)); delete executeBatchCB; executeBatchCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, main event thread complete end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } void ExecuteBatchPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, main event thread complete start.", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); DAHelperExecuteBatchCB *executeBatchCB = static_cast(data); napi_value result = nullptr; napi_create_array(env, &result); @@ -1695,14 +1695,13 @@ void ExecuteBatchPromiseCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, executeBatchCB->cbBase.asyncWork)); delete executeBatchCB; executeBatchCB = nullptr; - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, main event thread complete end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } void GetDataAbilityResultForResult( napi_env env, const std::vector> &dataAbilityResult, napi_value result) { - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, getDataAbilityResultForResult start. %{public}zu", - __func__, dataAbilityResult.size()); + TAG_LOGI(AAFwkTag::FA, "size:%{public}zu", dataAbilityResult.size()); int32_t index = 0; std::vector> entities = dataAbilityResult; for (const auto &item : entities) { @@ -1712,19 +1711,18 @@ void GetDataAbilityResultForResult( napi_value uri; NAPI_CALL_RETURN_VOID( env, napi_create_string_utf8(env, item->GetUri().ToString().c_str(), NAPI_AUTO_LENGTH, &uri)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, uri = [%{public}s]", __func__, - item->GetUri().ToString().c_str()); + TAG_LOGI(AAFwkTag::FA, "uri= [%{public}s]", item->GetUri().ToString().c_str()); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objDataAbilityResult, "uri", uri)); napi_value count; NAPI_CALL_RETURN_VOID(env, napi_create_int32(env, item->GetCount(), &count)); - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, count = [%{public}d]", __func__, item->GetCount()); + TAG_LOGI(AAFwkTag::FA, "count= [%{public}d]", item->GetCount()); NAPI_CALL_RETURN_VOID(env, napi_set_named_property(env, objDataAbilityResult, "count", count)); NAPI_CALL_RETURN_VOID(env, napi_set_element(env, result, index, objDataAbilityResult)); index++; } - TAG_LOGI(AAFwkTag::FA, "%{public}s, NAPI_ExecuteBatch, getDataAbilityResultForResult end.", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } void GetDataAbilityHelper(napi_env env, napi_value thisVar, std::shared_ptr& dataAbilityHelper) diff --git a/frameworks/js/napi/featureAbility/napi_data_ability_observer.cpp b/frameworks/js/napi/featureAbility/napi_data_ability_observer.cpp index c2763a8a11..46a3ed6f58 100644 --- a/frameworks/js/napi/featureAbility/napi_data_ability_observer.cpp +++ b/frameworks/js/napi/featureAbility/napi_data_ability_observer.cpp @@ -27,18 +27,18 @@ void NAPIDataAbilityObserver::ReleaseJSCallback() { std::lock_guard lock(mutex_); if (ref_ == nullptr) { - TAG_LOGE(AAFwkTag::FA, "NAPIDataAbilityObserver::ReleaseJSCallback, ref_ is null."); + TAG_LOGE(AAFwkTag::FA, "null ref_"); return; } if (isCallingback_) { needRelease_ = true; - TAG_LOGW(AAFwkTag::FA, "%{public}s, ref_ is calling back.", __func__); + TAG_LOGW(AAFwkTag::FA, "calling back"); return; } SafeReleaseJSCallback(); - TAG_LOGI(AAFwkTag::FA, "NAPIDataAbilityObserver::%{public}s, called. end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } void NAPIDataAbilityObserver::SafeReleaseJSCallback() @@ -46,7 +46,7 @@ void NAPIDataAbilityObserver::SafeReleaseJSCallback() uv_loop_s* loop = nullptr; napi_get_uv_event_loop(env_, &loop); if (loop == nullptr) { - TAG_LOGE(AAFwkTag::FA, "%{public}s, loop == nullptr.", __func__); + TAG_LOGE(AAFwkTag::FA, "null loop"); return; } @@ -67,12 +67,12 @@ void NAPIDataAbilityObserver::SafeReleaseJSCallback() [](uv_work_t* work, int status) { // JS Thread if (work == nullptr) { - TAG_LOGE(AAFwkTag::FA, "uv_queue_work input work is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null work"); return; } auto delRefCallbackInfo = reinterpret_cast(work->data); if (delRefCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::FA, "uv_queue_work delRefCallbackInfo is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null delRefCallbackInfo"); delete work; work = nullptr; return; @@ -100,25 +100,25 @@ void NAPIDataAbilityObserver::SafeReleaseJSCallback() void NAPIDataAbilityObserver::SetEnv(const napi_env &env) { env_ = env; - TAG_LOGI(AAFwkTag::FA, "NAPIDataAbilityObserver::%{public}s, called. end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } void NAPIDataAbilityObserver::SetCallbackRef(const napi_ref &ref) { ref_ = ref; - TAG_LOGI(AAFwkTag::FA, "NAPIDataAbilityObserver::%{public}s, called. end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } static void OnChangeJSThreadWorker(uv_work_t *work, int status) { - TAG_LOGI(AAFwkTag::FA, "OnChange, uv_queue_work"); + TAG_LOGI(AAFwkTag::FA, "called"); if (work == nullptr) { - TAG_LOGE(AAFwkTag::FA, "OnChange, uv_queue_work input work is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null work"); return; } DAHelperOnOffCB *onCB = (DAHelperOnOffCB *)work->data; if (onCB == nullptr) { - TAG_LOGE(AAFwkTag::FA, "OnChange, uv_queue_work onCB is nullptr"); + TAG_LOGE(AAFwkTag::FA, "null onCB"); delete work; work = nullptr; return; @@ -132,7 +132,7 @@ static void OnChangeJSThreadWorker(uv_work_t *work, int status) onCB = nullptr; delete work; work = nullptr; - TAG_LOGI(AAFwkTag::FA, "OnChange, uv_queue_work. end"); + TAG_LOGI(AAFwkTag::FA, "end"); } void NAPIDataAbilityObserver::CallJsMethod() @@ -140,7 +140,7 @@ void NAPIDataAbilityObserver::CallJsMethod() { std::lock_guard lock(mutex_); if (ref_ == nullptr || env_ == nullptr) { - TAG_LOGW(AAFwkTag::FA, "%{public}s observer is invalid.", __func__); + TAG_LOGW(AAFwkTag::FA, "invalid observer"); return; } isCallingback_ = true; @@ -198,7 +198,7 @@ void NAPIDataAbilityObserver::OnChange() work = nullptr; } } - TAG_LOGI(AAFwkTag::FA, "%{public}s, called. end", __func__); + TAG_LOGI(AAFwkTag::FA, "end"); } } // namespace AppExecFwk diff --git a/frameworks/js/napi/feature_ability/js_feature_ability.cpp b/frameworks/js/napi/feature_ability/js_feature_ability.cpp index 2f930d4c3c..c5d4132b06 100644 --- a/frameworks/js/napi/feature_ability/js_feature_ability.cpp +++ b/frameworks/js/napi/feature_ability/js_feature_ability.cpp @@ -28,7 +28,7 @@ const std::string RESULT_DATA_TAG = "resultData"; void JsFeatureAbility::Finalizer(napi_env env, void* data, void* hint) { - TAG_LOGI(AAFwkTag::FA, "JsFeatureAbility::Finalizer is called"); + TAG_LOGI(AAFwkTag::FA, "finalizer called"); std::unique_ptr(static_cast(data)); } @@ -89,7 +89,7 @@ napi_value JsFeatureAbility::UnsubscribeMsg(napi_env env, napi_callback_info inf napi_value JsFeatureAbility::OnStartAbility(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); if (info.argc != 1) { TAG_LOGE(AAFwkTag::FA, "arguments not match"); return CreateJsUndefined(env); @@ -97,7 +97,7 @@ napi_value JsFeatureAbility::OnStartAbility(napi_env env, NapiCallbackInfo& info Ability* ability = GetAbility(env); if (ability == nullptr) { - TAG_LOGE(AAFwkTag::FA, "ability is null"); + TAG_LOGE(AAFwkTag::FA, "ability null"); return CreateJsUndefined(env); } @@ -123,14 +123,14 @@ napi_value JsFeatureAbility::OnStartAbility(napi_env env, NapiCallbackInfo& info napi_value JsFeatureAbility::OnStartAbilityForResult(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); if (info.argc != 1) { TAG_LOGE(AAFwkTag::FA, "Params not match"); return CreateJsUndefined(env); } Ability* ability = GetAbility(env); if (ability == nullptr) { - TAG_LOGE(AAFwkTag::FA, "ability is nullptr"); + TAG_LOGE(AAFwkTag::FA, "ability null"); return CreateJsUndefined(env); } @@ -168,7 +168,7 @@ napi_value JsFeatureAbility::OnStartAbilityForResult(napi_env env, NapiCallbackI napi_value JsFeatureAbility::OnFinishWithResult(napi_env env, NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); if (info.argc != 1) { TAG_LOGE(AAFwkTag::FA, "Params not match"); return CreateJsUndefined(env); @@ -227,49 +227,49 @@ napi_value JsFeatureAbility::OnFinishWithResult(napi_env env, NapiCallbackInfo& napi_value JsFeatureAbility::OnGetDeviceList(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } napi_value JsFeatureAbility::OnCallAbility(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } napi_value JsFeatureAbility::OnContinueAbility(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } napi_value JsFeatureAbility::OnSubscribeAbilityEvent(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } napi_value JsFeatureAbility::OnUnsubscribeAbilityEvent(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } napi_value JsFeatureAbility::OnSendMsg(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } napi_value JsFeatureAbility::OnSubscribeMsg(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } napi_value JsFeatureAbility::OnUnsubscribeMsg(napi_env env, const NapiCallbackInfo& info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s is called", __FUNCTION__); + TAG_LOGI(AAFwkTag::FA, "called"); return CreateJsUndefined(env); } @@ -281,8 +281,7 @@ Ability* JsFeatureAbility::GetAbility(napi_env env) ret = napi_get_global(env, &global); if (ret != napi_ok) { napi_get_last_error_info(env, &errorInfo); - TAG_LOGE(AAFwkTag::FA, "JsFeatureAbility::GetAbility, get_global=%{public}d err:%{public}s", - ret, errorInfo->error_message); + TAG_LOGE(AAFwkTag::FA, "get_global=%{public}d err:%{public}s", ret, errorInfo->error_message); return nullptr; } @@ -290,7 +289,7 @@ Ability* JsFeatureAbility::GetAbility(napi_env env) ret = napi_get_named_property(env, global, "ability", &abilityObj); if (ret != napi_ok) { napi_get_last_error_info(env, &errorInfo); - TAG_LOGE(AAFwkTag::FA, "JsFeatureAbility::GetAbility, get_named_property=%{public}d err:%{public}s", + TAG_LOGE(AAFwkTag::FA, "get_named_property=%{public}d err:%{public}s", ret, errorInfo->error_message); return nullptr; } @@ -299,7 +298,7 @@ Ability* JsFeatureAbility::GetAbility(napi_env env) ret = napi_get_value_external(env, abilityObj, reinterpret_cast(&ability)); if (ret != napi_ok) { napi_get_last_error_info(env, &errorInfo); - TAG_LOGE(AAFwkTag::FA, "JsFeatureAbility::GetAbility, get_value_external=%{public}d err:%{public}s", + TAG_LOGE(AAFwkTag::FA, "get_value_external=%{public}d err:%{public}s", ret, errorInfo->error_message); return nullptr; } @@ -392,7 +391,7 @@ bool JsFeatureAbility::UnWrapRequestParams(napi_env env, napi_value param, Distr TAG_LOGI(AAFwkTag::FA, "called"); if (!IsTypeForNapiValue(env, param, napi_object)) { - TAG_LOGI(AAFwkTag::FA, "%{public}s called. Params is invalid.", __func__); + TAG_LOGI(AAFwkTag::FA, "invalid params"); return false; } @@ -489,7 +488,7 @@ napi_value JsFeatureAbilityInit(napi_env env, napi_value exports) { TAG_LOGD(AAFwkTag::FA, "called"); if (env == nullptr) { - TAG_LOGE(AAFwkTag::FA, "env nullptr."); + TAG_LOGE(AAFwkTag::FA, "null env"); return nullptr; } diff --git a/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp b/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp index 9becafab43..7235772add 100644 --- a/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp +++ b/frameworks/js/napi/inner/napi_ability_common/js_napi_common.cpp @@ -95,19 +95,19 @@ napi_value JsNapiCommon::OnFindAbilityConnection(napi_env env, sptr lock(g_connectionsLock_); Want want; if (!UnwrapWant(env, argv[PARAM0], want)) { - TAG_LOGE(AAFwkTag::JSNAPI, "called. Invoke UnwrapWant fail"); + TAG_LOGE(AAFwkTag::JSNAPI, "unwrapWant failed"); return CreateJsUndefined(env); } @@ -145,7 +145,7 @@ void JsNapiCommon::SetJsDisConnectAbilityCallback(std::shared_ptr &erro execute = [obj = this, value = errorVal, abilityType, abilityConnection] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr."); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -170,7 +170,7 @@ napi_value JsNapiCommon::JsDisConnectAbility(napi_env env, napi_callback_info in napi_value argv[ARGS_MAX_COUNT] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc == ARGS_ZERO || argc > ARGS_TWO) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -233,7 +233,7 @@ bool JsNapiCommon::CreateConnectionAndConnectAbilityLocked( sptr JsNapiCommon::FindConnectionLocked(const Want &want, int64_t &id) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s uri:%{public}s", __func__, want.GetElement().GetURI().c_str()); + TAG_LOGD(AAFwkTag::JSNAPI, "uri:%{public}s", want.GetElement().GetURI().c_str()); std::string deviceId = want.GetElement().GetDeviceID(); std::string bundleName = want.GetBundle(); std::string abilityName = want.GetElement().GetAbilityName(); @@ -260,7 +260,7 @@ sptr JsNapiCommon::FindConnectionLocked(const Want &want, void JsNapiCommon::RemoveAllCallbacksLocked() { - TAG_LOGD(AAFwkTag::JSNAPI, "RemoveAllCallbacksLocked begin"); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); std::lock_guard lock(g_connectionsLock_); for (auto it = connects_.begin(); it != connects_.end();) { auto connection = it->second; @@ -305,12 +305,12 @@ napi_value JsNapiCommon::JsGetContext(napi_env env, const napi_callback_info inf napi_value JsNapiCommon::JsGetFilesDir(napi_env env, napi_callback_info info, const AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "JsGetFilesDir called"); + TAG_LOGD(AAFwkTag::JSNAPI, "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 > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetFilesDir input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -319,7 +319,7 @@ napi_value JsNapiCommon::JsGetFilesDir(napi_env env, napi_callback_info info, co auto execute = [obj = this, dir = filesDir, abilityType, value = errorVal] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetFilesDir task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -329,7 +329,7 @@ napi_value JsNapiCommon::JsGetFilesDir(napi_env env, napi_callback_info info, co auto context = obj->ability_->GetAbilityContext(); if (context == nullptr) { *value = static_cast(NAPI_ERR_ABILITY_CALL_INVALID); - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetFilesDir task execute error, the abilitycontext is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null abilityContext"); return; } dir->name = context->GetFilesDir(); @@ -354,12 +354,12 @@ napi_value JsNapiCommon::JsGetFilesDir(napi_env env, napi_callback_info info, co napi_value JsNapiCommon::JsIsUpdatingConfigurations( napi_env env, napi_callback_info info, const AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "JsIsUpdatingConfigurations called"); + TAG_LOGD(AAFwkTag::JSNAPI, "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 > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "JsIsUpdatingConfigurations input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -368,7 +368,7 @@ napi_value JsNapiCommon::JsIsUpdatingConfigurations( auto execute = [obj = this, data = config, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "JsIsUpdatingConfigurations task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -377,7 +377,7 @@ napi_value JsNapiCommon::JsIsUpdatingConfigurations( } if (data == nullptr) { *value = static_cast(NAPI_ERR_ABILITY_CALL_INVALID); - TAG_LOGE(AAFwkTag::JSNAPI, "JsIsUpdatingConfigurations task execute error, param is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null data"); return; } data->status = obj->ability_->IsUpdatingConfigurations(); @@ -403,12 +403,12 @@ napi_value JsNapiCommon::JsIsUpdatingConfigurations( napi_value JsNapiCommon::JsPrintDrawnCompleted( napi_env env, napi_callback_info info, const AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "JsPrintDrawnCompleted called"); + TAG_LOGD(AAFwkTag::JSNAPI, "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 > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "JsPrintDrawnCompleted input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -417,7 +417,7 @@ napi_value JsNapiCommon::JsPrintDrawnCompleted( auto execute = [obj = this, data = drawComplete, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "JsPrintDrawnCompleted task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -426,7 +426,7 @@ napi_value JsNapiCommon::JsPrintDrawnCompleted( } if (data == nullptr) { *value = static_cast(NAPI_ERR_ABILITY_CALL_INVALID); - TAG_LOGE(AAFwkTag::JSNAPI, "JsPrintDrawnCompleted task execute error, data is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null data"); return; } data->status = obj->ability_->PrintDrawnCompleted(); @@ -451,12 +451,12 @@ napi_value JsNapiCommon::JsPrintDrawnCompleted( napi_value JsNapiCommon::JsGetCacheDir(napi_env env, napi_callback_info info, const AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "JsGetCacheDir called"); + TAG_LOGD(AAFwkTag::JSNAPI, "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 > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetCacheDir input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -465,7 +465,7 @@ napi_value JsNapiCommon::JsGetCacheDir(napi_env env, napi_callback_info info, co auto execute = [obj = this, dir = cacheDir, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetCacheDir task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -475,7 +475,7 @@ napi_value JsNapiCommon::JsGetCacheDir(napi_env env, napi_callback_info info, co auto context = obj->ability_->GetAbilityContext(); if (context == nullptr) { *value = static_cast(NAPI_ERR_ABILITY_CALL_INVALID); - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetCacheDir task execute error, the ability context is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null context"); return; } dir->name = context->GetCacheDir(); @@ -502,12 +502,12 @@ napi_value JsNapiCommon::JsGetCacheDir(napi_env env, napi_callback_info info, co napi_value JsNapiCommon::JsGetCtxAppType( napi_env env, napi_callback_info info, const AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "JsGetCtxAppType called"); + TAG_LOGD(AAFwkTag::JSNAPI, "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 > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -516,7 +516,7 @@ napi_value JsNapiCommon::JsGetCtxAppType( auto execute = [obj = this, apptype = type, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -550,12 +550,12 @@ napi_value JsNapiCommon::JsGetCtxAppType( napi_value JsNapiCommon::JsGetCtxHapModuleInfo( napi_env env, napi_callback_info info, const AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "JsGetCtxHapModuleInfo called"); + TAG_LOGD(AAFwkTag::JSNAPI, "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 > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -564,7 +564,7 @@ napi_value JsNapiCommon::JsGetCtxHapModuleInfo( auto execute = [obj = this, hapMod = infoData, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -657,7 +657,7 @@ napi_value JsNapiCommon::JsGetCtxAbilityInfo( napi_value argv[ARGS_MAX_COUNT] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -666,7 +666,7 @@ napi_value JsNapiCommon::JsGetCtxAbilityInfo( auto execute = [obj = this, abilityInfo = infoData, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -708,7 +708,7 @@ napi_value JsNapiCommon::JsGetOrCreateDistributedDir( napi_value argv[ARGS_MAX_COUNT] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -717,7 +717,7 @@ napi_value JsNapiCommon::JsGetOrCreateDistributedDir( auto execute = [obj = this, dir = orCreateDistributedDir, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -759,7 +759,7 @@ napi_value JsNapiCommon::JsGetDisplayOrientation(napi_env env, napi_callback_inf napi_value argv[ARGS_MAX_COUNT] = {nullptr}; napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); if (argc > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -767,7 +767,7 @@ napi_value JsNapiCommon::JsGetDisplayOrientation(napi_env env, napi_callback_inf auto execute = [obj = this, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -902,7 +902,7 @@ napi_value JsNapiCommon::CreateModuleInfos(napi_env env, const std::vector ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } @@ -1157,7 +1157,7 @@ napi_value JsNapiCommon::JsGetWant(napi_env env, napi_callback_info info, const auto execute = [obj = this, want = pwant, value = errorVal, abilityType] () { if (obj->ability_ == nullptr) { *value = static_cast(NAPI_ERR_ACE_ABILITY); - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } if (!obj->CheckAbilityType(abilityType)) { @@ -1194,7 +1194,7 @@ napi_value JsNapiCommon::JsGetWant(napi_env env, napi_callback_info info, const napi_value JsNapiCommon::CreateWant(napi_env env, const std::shared_ptr &want) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s,called", __func__); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); if (want == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "CreateWant error, want is nullptr."); return CreateJsUndefined(env); @@ -1205,9 +1205,9 @@ napi_value JsNapiCommon::CreateWant(napi_env env, const std::shared_ptr napi_value JsNapiCommon::JsTerminateAbility(napi_env env, NapiCallbackInfo& info) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called", __func__); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); if (info.argc > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s input params count error, argc=%{public}zu", __func__, info.argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", info.argc); return CreateJsUndefined(env); } @@ -1215,7 +1215,7 @@ napi_value JsNapiCommon::JsTerminateAbility(napi_env env, NapiCallbackInfo& info if (obj->ability_ != nullptr) { obj->ability_->TerminateAbility(); } else { - TAG_LOGE(AAFwkTag::JSNAPI, "JsTerminateAbility ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); } task.Resolve(env, CreateJsNull(env)); }; @@ -1244,13 +1244,13 @@ bool UnwrapParamForWant(napi_env env, napi_value args, AbilityType, CallAbilityP param.setting = nullptr; NAPI_CALL_BASE(env, napi_typeof(env, args, &valueType), false); if (valueType != napi_object) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, Wrong argument type.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "wrong argument type"); return false; } napi_value jsWant = GetPropertyValueByPropertyName(env, args, "want", napi_object); if (jsWant == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, jsWant == nullptr", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null jsWant"); return false; } @@ -1263,12 +1263,12 @@ bool UnwrapParamForWant(napi_env env, napi_value args, AbilityType, CallAbilityP if (jsSettingObj != nullptr) { param.setting = AbilityStartSetting::GetEmptySetting(); if (!UnwrapAbilityStartSetting(env, jsSettingObj, *(param.setting))) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, unwrap abilityStartSetting failed.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "unwrap abilityStartSetting failed"); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s abilityStartSetting", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "abilityStartSetting"); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -1283,7 +1283,7 @@ void JsNapiCommon::SetJsStartAbilityExecuteCallback(std::shared_ptr &er if (obj->ability_ == nullptr) { *value = NAPI_ERR_ACE_ABILITY; - TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } @@ -1328,18 +1328,18 @@ void JsNapiCommon::SetJsStartAbilityExecuteCallback(std::shared_ptr &er napi_value JsNapiCommon::JsStartAbility(napi_env env, napi_callback_info info, AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called", __func__); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); auto errorVal = std::make_shared(static_cast(NAPI_ERR_NO_ERROR)); auto param = std::make_shared(); 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 == 0 || argc > ARGS_TWO) { - TAG_LOGE(AAFwkTag::JSNAPI, "input params count error, argc=%{public}zu", argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); *errorVal = NAPI_ERR_PARAM_INVALID; } else { if (!UnwrapParamForWant(env, argv[PARAM0], abilityType, *param)) { - TAG_LOGE(AAFwkTag::JSNAPI, "call UnwrapParamForWant failed."); + TAG_LOGE(AAFwkTag::JSNAPI, "unwrapParamForWant failed"); *errorVal = NAPI_ERR_PARAM_INVALID; } } @@ -1377,18 +1377,18 @@ napi_value JsNapiCommon::JsStartAbility(napi_env env, napi_callback_info info, A napi_value JsNapiCommon::JsGetExternalCacheDir(napi_env env, napi_callback_info info, AbilityType abilityType) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called", __func__); + TAG_LOGD(AAFwkTag::JSNAPI, "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 > ARGS_ONE) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s input params count error, argc=%{public}zu", __func__, argc); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc:%{public}zu", argc); return CreateJsUndefined(env); } auto complete = [obj = this, abilityType](napi_env env, NapiAsyncTask &task, int32_t status) { if (obj->ability_ == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetExternalCacheDir ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); task.RejectWithCustomize( env, CreateJsError(env, NAPI_ERR_ACE_ABILITY, "JsGetExternalCacheDir Failed"), @@ -1397,7 +1397,7 @@ napi_value JsNapiCommon::JsGetExternalCacheDir(napi_env env, napi_callback_info } if (!obj->CheckAbilityType(abilityType)) { - TAG_LOGE(AAFwkTag::JSNAPI, "JsGetExternalCacheDir abilityType is error"); + TAG_LOGE(AAFwkTag::JSNAPI, "error abilityType"); task.Reject(env, CreateJsError(env, NAPI_ERR_ABILITY_TYPE_INVALID, "JsGetExternalCacheDir Failed")); return; } @@ -1417,9 +1417,9 @@ void JsNapiCommon::AddFreeInstallObserver(napi_env env, const AAFwk::Want &want, napi_value* result) { // adapter free install async return install and start result - TAG_LOGD(AAFwkTag::JSNAPI, "AddFreeInstallObserver start."); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); if (ability_ == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "the ability is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); return; } int ret = 0; @@ -1483,14 +1483,14 @@ void ConnectionCallback::Reset() TAG_LOGI(AAFwkTag::JSNAPI, "not in-js-thread"); auto loop = engine->GetUVLoop(); if (loop == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, loop == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null loop"); env = nullptr; removeKey = nullptr; return; } uv_work_t *work = new(std::nothrow) uv_work_t; if (work == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "work == nullptr."); + TAG_LOGE(AAFwkTag::JSNAPI, "work == nullptr"); return; } ConnectionCallback *data = new(std::nothrow) ConnectionCallback(std::move(*this)); diff --git a/frameworks/js/napi/inner/napi_ability_common/napi_context.cpp b/frameworks/js/napi/inner/napi_ability_common/napi_context.cpp index 4f103c3dfc..ca9b0c1e69 100644 --- a/frameworks/js/napi/inner/napi_ability_common/napi_context.cpp +++ b/frameworks/js/napi/inner/napi_ability_common/napi_context.cpp @@ -285,14 +285,14 @@ static void SetWakeUpScreenAsyncCompleteCB(napi_env env, napi_status status, voi TAG_LOGI(AAFwkTag::JSNAPI, "called"); SetWakeUpScreenCB *setWakeUpScreenCB = static_cast(data); if (setWakeUpScreenCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, input param is nullptr", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null callback"); return; } do { setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_NO_ERROR; if (setWakeUpScreenCB->cbBase.ability == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, input param is nullptr", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY; break; } @@ -346,7 +346,7 @@ static napi_value SetWakeUpScreenAsync(napi_env env, napi_value *args, SetWakeUp nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_SetWakeUpScreenScreen, worker pool thread execute."); + TAG_LOGI(AAFwkTag::JSNAPI, "execute called"); }, SetWakeUpScreenAsyncCompleteCB, static_cast(cbData), @@ -359,9 +359,9 @@ static napi_value SetWakeUpScreenAsync(napi_env env, napi_value *args, SetWakeUp napi_value SetWakeUpScreenPromise(napi_env env, SetWakeUpScreenCB *cbData) { - TAG_LOGI(AAFwkTag::JSNAPI, "promise."); + TAG_LOGI(AAFwkTag::JSNAPI, "promise"); if (cbData == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr."); + TAG_LOGE(AAFwkTag::JSNAPI, "null cbData"); return nullptr; } napi_value resourceName = nullptr; @@ -376,14 +376,14 @@ napi_value SetWakeUpScreenPromise(napi_env env, SetWakeUpScreenCB *cbData) nullptr, resourceName, [](napi_env env, void *data) { - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_SetWakeUpScreenScreen, worker pool thread execute."); + TAG_LOGI(AAFwkTag::JSNAPI, "execute called"); }, [](napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::JSNAPI, "SetWakeUpScreenPromise, main event thread complete."); + TAG_LOGI(AAFwkTag::JSNAPI, "complete called"); SetWakeUpScreenCB *setWakeUpScreenCB = static_cast(data); setWakeUpScreenCB->cbBase.errCode = NO_ERROR; if (setWakeUpScreenCB->cbBase.ability == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "input param is nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY; } else { #ifdef SUPPORT_SCREEN @@ -400,7 +400,7 @@ napi_value SetWakeUpScreenPromise(napi_env env, SetWakeUpScreenCB *cbData) napi_delete_async_work(env, setWakeUpScreenCB->cbBase.asyncWork); delete setWakeUpScreenCB; setWakeUpScreenCB = nullptr; - TAG_LOGI(AAFwkTag::JSNAPI, "SetWakeUpScreenPromise, main event thread complete end."); + TAG_LOGI(AAFwkTag::JSNAPI, "complete end"); }, static_cast(cbData), &cbData->cbBase.asyncWork); @@ -788,11 +788,11 @@ struct OnRequestPermissionsData { { TAG_LOGD(AAFwkTag::JSNAPI, "called"); if (work == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, work is nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null work"); return; } if (work->data == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, work data is nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null data"); return; } std::unique_ptr data{static_cast(work->data)}; @@ -813,28 +813,28 @@ EXTERN_C_START void CallOnRequestPermissionsFromUserResult(int requestCode, const std::vector &permissions, const std::vector &grantResults, CallbackInfo callbackInfo) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s,called env", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (permissions.empty()) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, the string vector permissions is empty.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "empty permissions"); return; } if (permissions.size() != grantResults.size()) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, the size of permissions not equal the size of grantResults.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "permissions size not match"); return; } if (callbackInfo.env == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "CallOnRequestPermissionsFromUserResult callbackInfo.env is nullptr."); + TAG_LOGE(AAFwkTag::JSNAPI, "null env"); return; } if (callbackInfo.napiAsyncTask == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "CallOnRequestPermissionsFromUserResult callbackInfo.napiAsyncTask is nullptr."); + TAG_LOGE(AAFwkTag::JSNAPI, "null napiAsyncTask"); return; } uv_loop_t *loop = nullptr; napi_get_uv_event_loop(callbackInfo.env, &loop); if (loop == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "CallOnRequestPermissionsFromUserResult loop is nullptr."); + TAG_LOGE(AAFwkTag::JSNAPI, "null loop"); return; } @@ -906,12 +906,12 @@ bool UnwrapVerifyPermissionOptions(napi_env env, napi_value argv, AsyncJSCallbac { TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (asyncCallbackInfo == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is null", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return false; } if (!IsTypeForNapiValue(env, argv, napi_object)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, type of parameter is error.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "wrong param type"); return false; } @@ -929,42 +929,42 @@ bool UnwrapVerifyPermissionOptions(napi_env env, napi_value argv, AsyncJSCallbac bool UnwrapParamVerifyPermission(napi_env env, size_t argc, napi_value *argv, AsyncJSCallbackInfo *asyncCallbackInfo) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, argc=%{public}zu", __func__, argc); + TAG_LOGI(AAFwkTag::JSNAPI, "argc=%{public}zu", argc); const size_t argcMax = ARGS_THREE; if (argc > argcMax || argc < 1) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, Params is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid argc"); return false; } std::string permission(""); if (!UnwrapStringFromJS2(env, argv[PARAM0], permission)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, the first parameter is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid argv[PARAM0]"); return false; } asyncCallbackInfo->param.paramArgs.PutStringValue("permission", permission); if (argc == argcMax) { if (!CreateAsyncCallback(env, argv[PARAM2], asyncCallbackInfo)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, the second parameter is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid argv[PARAM2]"); return false; } if (!UnwrapVerifyPermissionOptions(env, argv[PARAM1], asyncCallbackInfo)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, the second parameter is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid argv[PARAM1]"); return false; } } else if (argc == ARGS_TWO) { if (!CreateAsyncCallback(env, argv[PARAM1], asyncCallbackInfo)) { if (!UnwrapVerifyPermissionOptions(env, argv[PARAM1], asyncCallbackInfo)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, the second parameter is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid argv[PARAM1]"); return false; } } } else if (argc == ARGS_ONE) { asyncCallbackInfo->cbInfo.callback = nullptr; } else { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, the parameter is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid argc"); return false; } return true; @@ -976,7 +976,7 @@ void VerifyPermissionExecuteCallback(napi_env env, void *data) AsyncJSCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. asyncCallbackInfo is null", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return; } @@ -1013,20 +1013,20 @@ napi_value NAPI_VerifyPermissionWrap(napi_env env, napi_callback_info info, Asyn NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &jsthis, &data)); if (!UnwrapParamVerifyPermission(env, argc, args, asyncCallbackInfo)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Invoke UnwrapParamVerifyPermission fail", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "unwrapParamVerifyPermission failed"); return nullptr; } AsyncParamEx asyncParamEx; if (asyncCallbackInfo->cbInfo.callback != nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback"); asyncParamEx.resource = "NAPI_VerifyPermissionCallback"; asyncParamEx.execute = VerifyPermissionExecuteCallback; asyncParamEx.complete = CompleteAsyncCallbackWork; return ExecuteAsyncCallbackWork(env, asyncCallbackInfo, &asyncParamEx); } else { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. promise.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "promise"); asyncParamEx.resource = "NAPI_VerifyPermissionPromise"; asyncParamEx.execute = VerifyPermissionExecuteCallback; asyncParamEx.complete = CompletePromiseCallbackWork; @@ -1040,7 +1040,7 @@ napi_value NAPI_VerifyPermission(napi_env env, napi_callback_info info) TAG_LOGI(AAFwkTag::JSNAPI, "called"); AsyncJSCallbackInfo *asyncCallbackInfo = CreateAsyncJSCallbackInfo(env); if (asyncCallbackInfo == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Invoke CreateAsyncJSCallbackInfo failed.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return WrapVoidToJS(env); } @@ -1054,12 +1054,12 @@ napi_value NAPI_VerifyPermission(napi_env env, napi_callback_info info) void GetAppInfoExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, worker pool thread execute."); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); AppInfoCB *appInfoCB = static_cast(data); appInfoCB->cbBase.errCode = NAPI_ERR_NO_ERROR; if (appInfoCB->cbBase.ability == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, ability == nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); appInfoCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY; return; } @@ -1068,15 +1068,15 @@ void GetAppInfoExecuteCB(napi_env env, void *data) if (appInfoPtr != nullptr) { appInfoCB->appInfo = *appInfoPtr; } else { - TAG_LOGE(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, appInfoPtr == nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoPtr"); appInfoCB->cbBase.errCode = NAPI_ERR_ABILITY_CALL_INVALID; } - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); } void GetAppInfoAsyncCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, main event thread complete."); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); AppInfoCB *appInfoCB = static_cast(data); napi_value callback = nullptr; napi_value undefined = nullptr; @@ -1098,14 +1098,14 @@ void GetAppInfoAsyncCompleteCB(napi_env env, napi_status status, void *data) NAPI_CALL_RETURN_VOID(env, napi_delete_async_work(env, appInfoCB->cbBase.asyncWork)); delete appInfoCB; appInfoCB = nullptr; - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, main event thread complete end."); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); } napi_value GetApplicationInfoAsync(napi_env env, napi_value *args, const size_t argCallback, AppInfoCB *appInfoCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (args == nullptr || appInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1127,16 +1127,16 @@ napi_value GetApplicationInfoAsync(napi_env env, napi_value *args, const size_t NAPI_CALL(env, napi_queue_async_work_with_qos(env, appInfoCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } void GetAppInfoPromiseCompleteCB(napi_env env, napi_status status, void *data) { - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, main event thread complete."); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); AppInfoCB *appInfoCB = static_cast(data); if (appInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, appInfoCB == nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB"); return; } @@ -1152,14 +1152,14 @@ void GetAppInfoPromiseCompleteCB(napi_env env, napi_status status, void *data) napi_delete_async_work(env, appInfoCB->cbBase.asyncWork); delete appInfoCB; appInfoCB = nullptr; - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetApplicationInfo, main event thread complete end."); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); } napi_value GetApplicationInfoPromise(napi_env env, AppInfoCB *appInfoCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "promise"); if (appInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB"); return nullptr; } napi_value resourceName = nullptr; @@ -1178,15 +1178,15 @@ napi_value GetApplicationInfoPromise(napi_env env, AppInfoCB *appInfoCB) static_cast(appInfoCB), &appInfoCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, appInfoCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return promise; } napi_value GetApplicationInfoWrap(napi_env env, napi_callback_info info, AppInfoCB *appInfoCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (appInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, appInfoCB == null.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB"); return nullptr; } @@ -1198,7 +1198,7 @@ napi_value GetApplicationInfoWrap(napi_env env, napi_callback_info info, AppInfo NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, Wrong parameter count.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); return nullptr; } @@ -1207,7 +1207,7 @@ napi_value GetApplicationInfoWrap(napi_env env, napi_callback_info info, AppInfo } else { ret = GetApplicationInfoPromise(env, appInfoCB); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -1225,7 +1225,7 @@ AppInfoCB *CreateAppInfoCBInfo(napi_env env) AppInfoCB *appInfoCB = new (std::nothrow) AppInfoCB; if (appInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, appInfoCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB"); return nullptr; } appInfoCB->cbBase.cbInfo.env = env; @@ -1235,7 +1235,7 @@ AppInfoCB *CreateAppInfoCBInfo(napi_env env) appInfoCB->cbBase.abilityType = AbilityType::UNKNOWN; appInfoCB->cbBase.errCode = NAPI_ERR_NO_ERROR; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return appInfoCB; } @@ -1244,21 +1244,21 @@ void GetBundleNameExecuteCallback(napi_env env, void *data) TAG_LOGI(AAFwkTag::JSNAPI, "called"); AsyncJSCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s. asyncCallbackInfo is null", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return; } asyncCallbackInfo->error_code = NAPI_ERR_NO_ERROR; asyncCallbackInfo->native_data.data_type = NVT_NONE; if (asyncCallbackInfo->ability == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s ability == nullptr", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); asyncCallbackInfo->error_code = NAPI_ERR_ACE_ABILITY; return; } asyncCallbackInfo->native_data.data_type = NVT_STRING; asyncCallbackInfo->native_data.str_value = asyncCallbackInfo->ability->GetBundleName(); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end. bundleName=%{public}s", __func__, + TAG_LOGI(AAFwkTag::JSNAPI, "bundleName=%{public}s", asyncCallbackInfo->native_data.str_value.c_str()); } @@ -1273,27 +1273,27 @@ napi_value NAPI_GetBundleNameWrap(napi_env env, napi_callback_info info, AsyncJS NAPI_CALL(env, napi_get_cb_info(env, info, &argc, args, &jsthis, &data)); if (argc > ARGS_ONE) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, parameters is invalid", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid argc"); return nullptr; } if (argc == ARGS_ONE) { if (!CreateAsyncCallback(env, args[PARAM0], asyncCallbackInfo)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, the first parameter is invalid", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid args[PARAM0]"); return nullptr; } } AsyncParamEx asyncParamEx; if (asyncCallbackInfo->cbInfo.callback != nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. asyncCallback", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback"); asyncParamEx.resource = "NAPI_GetBundleNameCallback"; asyncParamEx.execute = GetBundleNameExecuteCallback; asyncParamEx.complete = CompleteAsyncCallbackWork; return ExecuteAsyncCallbackWork(env, asyncCallbackInfo, &asyncParamEx); } else { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. promise.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "promise"); asyncParamEx.resource = "NAPI_GetBundleNamePromise"; asyncParamEx.execute = GetBundleNameExecuteCallback; asyncParamEx.complete = CompletePromiseCallbackWork; @@ -1306,7 +1306,7 @@ napi_value WrapProcessInfo(napi_env env, ProcessInfoCB *processInfoCB) { TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (processInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s Invalid param(processInfoCB == nullptr)", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB"); return nullptr; } napi_value result = nullptr; @@ -1317,7 +1317,7 @@ napi_value WrapProcessInfo(napi_env env, ProcessInfoCB *processInfoCB) NAPI_CALL(env, napi_create_string_utf8(env, processInfoCB->processName.c_str(), NAPI_AUTO_LENGTH, &proValue)); NAPI_CALL(env, napi_set_named_property(env, result, "processName", proValue)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -1377,9 +1377,9 @@ void GetProcessInfoAsyncCompleteCB(napi_env env, napi_status status, void *data) napi_value GetProcessInfoAsync(napi_env env, napi_value *args, const size_t argCallback, ProcessInfoCB *processInfoCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (args == nullptr || processInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1401,7 +1401,7 @@ napi_value GetProcessInfoAsync(napi_env env, napi_value *args, const size_t argC NAPI_CALL(env, napi_queue_async_work_with_qos(env, processInfoCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -1426,9 +1426,9 @@ void GetProcessInfoPromiseCompleteCB(napi_env env, napi_status status, void *dat napi_value GetProcessInfoPromise(napi_env env, ProcessInfoCB *processInfoCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (processInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB"); return nullptr; } napi_value resourceName = nullptr; @@ -1447,15 +1447,15 @@ napi_value GetProcessInfoPromise(napi_env env, ProcessInfoCB *processInfoCB) static_cast(processInfoCB), &processInfoCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, processInfoCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return promise; } napi_value GetProcessInfoWrap(napi_env env, napi_callback_info info, ProcessInfoCB *processInfoCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback"); if (processInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, processInfoCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB"); return nullptr; } @@ -1467,7 +1467,7 @@ napi_value GetProcessInfoWrap(napi_env env, napi_callback_info info, ProcessInfo NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, argument count fail.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); return nullptr; } @@ -1476,7 +1476,7 @@ napi_value GetProcessInfoWrap(napi_env env, napi_callback_info info, ProcessInfo } else { ret = GetProcessInfoPromise(env, processInfoCB); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -1494,7 +1494,7 @@ ProcessInfoCB *CreateProcessInfoCBInfo(napi_env env) ProcessInfoCB *processInfoCB = new (std::nothrow) ProcessInfoCB; if (processInfoCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, processInfoCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB"); return nullptr; } processInfoCB->cbBase.cbInfo.env = env; @@ -1502,7 +1502,7 @@ ProcessInfoCB *CreateProcessInfoCBInfo(napi_env env) processInfoCB->cbBase.deferred = nullptr; processInfoCB->cbBase.ability = ability; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return processInfoCB; } @@ -1520,7 +1520,7 @@ ElementNameCB *CreateElementNameCBInfo(napi_env env) ElementNameCB *elementNameCB = new (std::nothrow) ElementNameCB; if (elementNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, elementNameCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null elementNameCB"); return nullptr; } elementNameCB->cbBase.cbInfo.env = env; @@ -1528,7 +1528,7 @@ ElementNameCB *CreateElementNameCBInfo(napi_env env) elementNameCB->cbBase.deferred = nullptr; elementNameCB->cbBase.ability = ability; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return elementNameCB; } @@ -1536,7 +1536,7 @@ napi_value WrapElementName(napi_env env, const ElementNameCB *elementNameCB) { TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (elementNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s,Invalid param(appInfoCB = nullptr)", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB"); return nullptr; } napi_value result = nullptr; @@ -1556,7 +1556,7 @@ napi_value WrapElementName(napi_env env, const ElementNameCB *elementNameCB) NAPI_CALL(env, napi_create_string_utf8(env, elementNameCB->uri.c_str(), NAPI_AUTO_LENGTH, &proValue)); NAPI_CALL(env, napi_set_named_property(env, result, "uri", proValue)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -1564,18 +1564,18 @@ void GetElementNameExecuteCB(napi_env env, void *data) { TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetElementName, worker pool thread execute."); if (data == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, data == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null data"); return; } ElementNameCB *elementNameCB = static_cast(data); if (elementNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "NAPI_GetElementName, elementNameCB == nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null elementNameCB"); return; } elementNameCB->cbBase.errCode = NAPI_ERR_NO_ERROR; if (elementNameCB->cbBase.ability == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "NAPI_GetElementName, ability == nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); elementNameCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY; return; } @@ -1590,7 +1590,7 @@ void GetElementNameExecuteCB(napi_env env, void *data) } else { elementNameCB->cbBase.errCode = NAPI_ERR_ABILITY_CALL_INVALID; } - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetElementName, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); } void GetElementNameAsyncCompleteCB(napi_env env, napi_status status, void *data) @@ -1641,9 +1641,9 @@ void GetElementNamePromiseCompleteCB(napi_env env, napi_status status, void *dat napi_value GetElementNamePromise(napi_env env, ElementNameCB *elementNameCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (elementNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null elementNameCB"); return nullptr; } napi_value resourceName = nullptr; @@ -1662,15 +1662,15 @@ napi_value GetElementNamePromise(napi_env env, ElementNameCB *elementNameCB) static_cast(elementNameCB), &elementNameCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, elementNameCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return promise; } napi_value GetElementNameAsync(napi_env env, napi_value *args, const size_t argCallback, ElementNameCB *elementNameCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (args == nullptr || elementNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null param"); return nullptr; } napi_value resourceName = nullptr; @@ -1692,15 +1692,15 @@ napi_value GetElementNameAsync(napi_env env, napi_value *args, const size_t argC NAPI_CALL(env, napi_queue_async_work_with_qos(env, elementNameCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } napi_value GetElementNameWrap(napi_env env, napi_callback_info info, ElementNameCB *elementNameCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (elementNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, appInfoCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB"); return nullptr; } @@ -1712,7 +1712,7 @@ napi_value GetElementNameWrap(napi_env env, napi_callback_info info, ElementName NAPI_CALL(env, napi_get_cb_info(env, info, &argcAsync, args, nullptr, nullptr)); if (argcAsync > argCountWithAsync || argcAsync > ARGS_MAX_COUNT) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, argument count fail.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc"); return nullptr; } @@ -1721,7 +1721,7 @@ napi_value GetElementNameWrap(napi_env env, napi_callback_info info, ElementName } else { ret = GetElementNamePromise(env, elementNameCB); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -1739,7 +1739,7 @@ ProcessNameCB *CreateProcessNameCBInfo(napi_env env) ProcessNameCB *processNameCB = new (std::nothrow) ProcessNameCB; if (processNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, processNameCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null processNameCB"); return nullptr; } processNameCB->cbBase.cbInfo.env = env; @@ -1747,28 +1747,28 @@ ProcessNameCB *CreateProcessNameCBInfo(napi_env env) processNameCB->cbBase.deferred = nullptr; processNameCB->cbBase.ability = ability; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return processNameCB; } void GetProcessNameExecuteCB(napi_env env, void *data) { - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetProcessName, worker pool thread execute."); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); ProcessNameCB *processNameCB = static_cast(data); if (processNameCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "NAPI_GetProcessName, processNameCB == nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null processNameCB"); return; } processNameCB->cbBase.errCode = NAPI_ERR_NO_ERROR; if (processNameCB->cbBase.ability == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "NAPI_GetProcessName, ability == nullptr"); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); processNameCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY; return; } processNameCB->processName = processNameCB->cbBase.ability->GetProcessName(); - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetProcessName, worker pool thread execute end."); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); } napi_value WrapProcessName(napi_env env, const ProcessNameCB *processNameCB) @@ -1780,7 +1780,7 @@ napi_value WrapProcessName(napi_env env, const ProcessNameCB *processNameCB) } napi_value result = nullptr; NAPI_CALL(env, napi_create_string_utf8(env, processNameCB->processName.c_str(), NAPI_AUTO_LENGTH, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -1832,7 +1832,7 @@ void GetProcessNamePromiseCompleteCB(napi_env env, napi_status status, void *dat napi_value GetProcessNameAsync(napi_env env, napi_value *args, const size_t argCallback, ProcessNameCB *processNameCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (args == nullptr || processNameCB == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); return nullptr; @@ -1856,7 +1856,7 @@ napi_value GetProcessNameAsync(napi_env env, napi_value *args, const size_t argC NAPI_CALL(env, napi_queue_async_work_with_qos(env, processNameCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -1883,13 +1883,13 @@ napi_value GetProcessNamePromise(napi_env env, ProcessNameCB *processNameCB) static_cast(processNameCB), &processNameCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, processNameCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return promise; } napi_value GetProcessNameWrap(napi_env env, napi_callback_info info, ProcessNameCB *processNameCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (processNameCB == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, processNameCB == nullptr.", __func__); return nullptr; @@ -1912,7 +1912,7 @@ napi_value GetProcessNameWrap(napi_env env, napi_callback_info info, ProcessName } else { ret = GetProcessNamePromise(env, processNameCB); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -1938,7 +1938,7 @@ CallingBundleCB *CreateCallingBundleCBInfo(napi_env env) callingBundleCB->cbBase.deferred = nullptr; callingBundleCB->cbBase.ability = ability; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return callingBundleCB; } @@ -1971,7 +1971,7 @@ napi_value WrapCallingBundle(napi_env env, const CallingBundleCB *callingBundleC } napi_value result = nullptr; NAPI_CALL(env, napi_create_string_utf8(env, callingBundleCB->callingBundleName.c_str(), NAPI_AUTO_LENGTH, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -2024,7 +2024,7 @@ void GetCallingBundlePromiseCompleteCB(napi_env env, napi_status status, void *d napi_value GetCallingBundleAsync( napi_env env, napi_value *args, const size_t argCallback, CallingBundleCB *callingBundleCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (args == nullptr || callingBundleCB == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); return nullptr; @@ -2048,7 +2048,7 @@ napi_value GetCallingBundleAsync( NAPI_CALL(env, napi_queue_async_work_with_qos(env, callingBundleCB->cbBase.asyncWork, napi_qos_user_initiated)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -2075,13 +2075,13 @@ napi_value GetCallingBundlePromise(napi_env env, CallingBundleCB *callingBundleC static_cast(callingBundleCB), &callingBundleCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work_with_qos(env, callingBundleCB->cbBase.asyncWork, napi_qos_user_initiated)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return promise; } napi_value GetCallingBundleWrap(napi_env env, napi_callback_info info, CallingBundleCB *callingBundleCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (callingBundleCB == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, callingBundleCB == nullptr.", __func__); return nullptr; @@ -2104,7 +2104,7 @@ napi_value GetCallingBundleWrap(napi_env env, napi_callback_info info, CallingBu } else { ret = GetCallingBundlePromise(env, callingBundleCB); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -2130,7 +2130,7 @@ GetOrCreateLocalDirCB *CreateGetOrCreateLocalDirCBInfo(napi_env env) getOrCreateLocalDirCB->cbBase.deferred = nullptr; getOrCreateLocalDirCB->cbBase.ability = ability; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return getOrCreateLocalDirCB; } @@ -2171,7 +2171,7 @@ napi_value WrapGetOrCreateLocalDir(napi_env env, const GetOrCreateLocalDirCB *ge } napi_value result = nullptr; NAPI_CALL(env, napi_create_string_utf8(env, getOrCreateLocalDirCB->rootDir.c_str(), NAPI_AUTO_LENGTH, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -2224,7 +2224,7 @@ void GetOrCreateLocalDirPromiseCompleteCB(napi_env env, napi_status status, void napi_value GetOrCreateLocalDirAsync( napi_env env, napi_value *args, const size_t argCallback, GetOrCreateLocalDirCB *getOrCreateLocalDirCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (args == nullptr || getOrCreateLocalDirCB == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, param == nullptr.", __func__); return nullptr; @@ -2249,7 +2249,7 @@ napi_value GetOrCreateLocalDirAsync( NAPI_CALL(env, napi_queue_async_work(env, getOrCreateLocalDirCB->cbBase.asyncWork)); napi_value result = nullptr; NAPI_CALL(env, napi_get_null(env, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -2276,13 +2276,13 @@ napi_value GetOrCreateLocalDirPromise(napi_env env, GetOrCreateLocalDirCB *getOr static_cast(getOrCreateLocalDirCB), &getOrCreateLocalDirCB->cbBase.asyncWork)); NAPI_CALL(env, napi_queue_async_work(env, getOrCreateLocalDirCB->cbBase.asyncWork)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, promise end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return promise; } napi_value GetOrCreateLocalDirWrap(napi_env env, napi_callback_info info, GetOrCreateLocalDirCB *getOrCreateLocalDirCB) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (getOrCreateLocalDirCB == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, getOrCreateLocalDirCB == nullptr.", __func__); return nullptr; @@ -2305,7 +2305,7 @@ napi_value GetOrCreateLocalDirWrap(napi_env env, napi_callback_info info, GetOrC } else { ret = GetOrCreateLocalDirPromise(env, getOrCreateLocalDirCB); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, asyncCallback end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -2324,13 +2324,13 @@ napi_value NAPI_GetBundleName(napi_env env, napi_callback_info info) FreeAsyncJSCallbackInfo(&asyncCallbackInfo); ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } napi_value NAPI_GetApplicationInfo(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); AppInfoCB *appInfoCB = CreateAppInfoCBInfo(env); if (appInfoCB == nullptr) { return WrapVoidToJS(env); @@ -2367,7 +2367,7 @@ napi_value NAPI_GetProcessInfo(napi_env env, napi_callback_info info) } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -2389,7 +2389,7 @@ napi_value NAPI_GetElementName(napi_env env, napi_callback_info info) } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -2411,7 +2411,7 @@ napi_value NAPI_GetProcessName(napi_env env, napi_callback_info info) } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -2433,7 +2433,7 @@ napi_value NAPI_GetCallingBundle(napi_env env, napi_callback_info info) } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -2455,7 +2455,7 @@ napi_value NAPI_GetOrCreateLocalDir(napi_env env, napi_callback_info info) } ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; } @@ -2481,7 +2481,7 @@ DatabaseDirCB *CreateGetDatabaseDirCBInfo(napi_env env) getDatabaseDirCB->cbBase.deferred = nullptr; getDatabaseDirCB->cbBase.ability = ability; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return getDatabaseDirCB; } @@ -2531,7 +2531,7 @@ napi_value GetDatabaseDirWrap(napi_env env, napi_callback_info info, DatabaseDir napi_value result = nullptr; NAPI_CALL(env, napi_create_string_utf8(env, getDatabaseDirCB->dataBaseDir.c_str(), NAPI_AUTO_LENGTH, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -2580,7 +2580,7 @@ PreferencesDirCB *CreateGetPreferencesDirCBInfo(napi_env env) getPreferencesDirCB->cbBase.deferred = nullptr; getPreferencesDirCB->cbBase.ability = ability; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return getPreferencesDirCB; } @@ -2588,13 +2588,13 @@ napi_value GetPreferencesDirWrap(napi_env env, napi_callback_info info, Preferen { TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (getPreferencesDirCB == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, getPreferencesDirCB == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null getPreferencesDirCB"); return nullptr; } getPreferencesDirCB->cbBase.errCode = NAPI_ERR_NO_ERROR; if (getPreferencesDirCB->cbBase.ability == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, ability == nullptr", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null ability"); getPreferencesDirCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY; return nullptr; } @@ -2604,8 +2604,7 @@ napi_value GetPreferencesDirWrap(napi_env env, napi_callback_info info, Preferen std::shared_ptr hap = getPreferencesDirCB->cbBase.ability->GetHapModuleInfo(); std::string moduleName = (hap != nullptr) ? hap->name : std::string(); std::string dataDirWithModuleName = dataDir + NAPI_CONTEXT_FILE_SEPARATOR + moduleName; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, dataDir:%{public}s moduleName:%{public}s abilityName:%{public}s", - __func__, + TAG_LOGI(AAFwkTag::JSNAPI, "dataDir:%{public}s moduleName:%{public}s abilityName:%{public}s", dataDir.c_str(), moduleName.c_str(), abilityName.c_str()); @@ -2613,17 +2612,13 @@ napi_value GetPreferencesDirWrap(napi_env env, napi_callback_info info, Preferen // if dataDirWithModuleName is not exits, do nothing and return. if (!OHOS::FileExists(dataDirWithModuleName)) { getPreferencesDirCB->preferencesDir = ""; - TAG_LOGI(AAFwkTag::JSNAPI, - "%{public}s, dirWithModuleName is not exits:%{public}s, do nothing and return null.", - __func__, - dataDirWithModuleName.c_str()); + TAG_LOGI(AAFwkTag::JSNAPI, "dirWithModuleName not exist:%{public}s", dataDirWithModuleName.c_str()); } else { getPreferencesDirCB->preferencesDir = dataDirWithModuleName + NAPI_CONTEXT_FILE_SEPARATOR + abilityName + NAPI_CONTEXT_FILE_SEPARATOR + NAPI_CONTEXT_PREFERENCES; - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, GetDir preferencesDir:%{public}s", __func__, - getPreferencesDirCB->preferencesDir.c_str()); + TAG_LOGI(AAFwkTag::JSNAPI, "preferencesDir:%{public}s", getPreferencesDirCB->preferencesDir.c_str()); if (!OHOS::FileExists(getPreferencesDirCB->preferencesDir)) { - TAG_LOGI(AAFwkTag::JSNAPI, "NAPI_GetPreferencesDir dir is not exits, create dir."); + TAG_LOGI(AAFwkTag::JSNAPI, "dir not exist, create"); OHOS::ForceCreateDirectory(getPreferencesDirCB->preferencesDir); OHOS::ChangeModeDirectory(getPreferencesDirCB->preferencesDir, MODE); } @@ -2632,7 +2627,7 @@ napi_value GetPreferencesDirWrap(napi_env env, napi_callback_info info, Preferen NAPI_CALL( env, napi_create_string_utf8(env, getPreferencesDirCB->preferencesDir.c_str(), NAPI_AUTO_LENGTH, &result)); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return result; } @@ -2652,9 +2647,9 @@ napi_value NAPI_GetPreferencesDirSync(napi_env env, napi_callback_info info) if (ret == nullptr) { ret = WrapVoidToJS(env); - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s ret == nullptr", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null ret"); } else { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); } return ret; } @@ -2667,7 +2662,7 @@ napi_value NAPI_IsUpdatingConfigurations(napi_env env, napi_callback_info info) napi_value NAPI_GetExternalCacheDir(napi_env env, napi_callback_info info) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called", __func__); + TAG_LOGD(AAFwkTag::JSNAPI, "called"); return NAPI_GetExternalCacheDirCommon(env, info, AbilityType::PAGE); } @@ -2684,7 +2679,7 @@ napi_value NAPI_SetDisplayOrientation(napi_env env, napi_callback_info info) AsyncJSCallbackInfo *asyncCallbackInfo = CreateAsyncJSCallbackInfo(env); if (asyncCallbackInfo == nullptr) { - TAG_LOGW(AAFwkTag::JSNAPI, "%{public}s called. Invoke CreateAsyncJSCallbackInfo failed.", __func__); + TAG_LOGW(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return WrapVoidToJS(env); } @@ -2759,7 +2754,7 @@ napi_value ContextPermissionInit(napi_env env, napi_value exports) napi_value NAPI_SetWakeUpScreen(napi_env env, napi_callback_info info) { #ifdef SUPPORT_GRAPHICS - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "called"); SetWakeUpScreenCB *setWakeUpScreenCB = new (std::nothrow) SetWakeUpScreenCB; if (setWakeUpScreenCB == nullptr) { TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, SetWakeUpScreenCB new failed", __func__); @@ -2776,7 +2771,7 @@ napi_value NAPI_SetWakeUpScreen(napi_env env, napi_callback_info info) TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, setWakeUpScreenCB run failed, delete resource", __func__); ret = WrapVoidToJS(env); } - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s,called end", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "end"); return ret; #else return nullptr; diff --git a/frameworks/js/napi/inner/napi_common/napi_common_configuration.cpp b/frameworks/js/napi/inner/napi_common/napi_common_configuration.cpp index f92d9279f5..97cc20131e 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_configuration.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_configuration.cpp @@ -34,8 +34,7 @@ bool InnerWrapConfigurationString( napi_env env, napi_value jsObject, const std::string &key, const std::string &value) { if (!value.empty()) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s, value=%{private}s", - __func__, key.c_str(), value.c_str()); + TAG_LOGI(AAFwkTag::JSNAPI, "key=%{public}s, value=%{private}s", 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); @@ -98,7 +97,7 @@ bool UnwrapConfiguration(napi_env env, napi_value param, Configuration &config) TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (!IsTypeForNapiValue(env, param, napi_object)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "not napi_object"); return false; } diff --git a/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp b/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp index 927edaa2b5..3189911b97 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp @@ -74,7 +74,7 @@ bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &sta TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (!IsTypeForNapiValue(env, param, napi_object)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "not napi_object"); return false; } @@ -129,7 +129,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)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "not napi_object"); return false; } napi_value jsValue = GetPropertyValueByPropertyName(env, param, "parameters", napi_object); diff --git a/frameworks/js/napi/inner/napi_common/napi_common_util.cpp b/frameworks/js/napi/inner/napi_common/napi_common_util.cpp index ae05832998..551801833b 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_util.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_util.cpp @@ -864,7 +864,7 @@ AsyncJSCallbackInfo *CreateAsyncJSCallbackInfo(napi_env env) AsyncJSCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncJSCallbackInfo; if (asyncCallbackInfo == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s, asyncCallbackInfo == nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return nullptr; } asyncCallbackInfo->cbInfo.env = env; @@ -949,13 +949,13 @@ bool CreateAsyncCallback(napi_env env, napi_value param, AsyncJSCallbackInfo *ca TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (param == nullptr || callback == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, param or callback is null.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null param or callback"); return false; } callback->cbInfo.callback = CreateCallbackRefFromJS(env, param); if (callback->cbInfo.callback == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s, create ref failed.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "create ref failed"); return false; } @@ -965,7 +965,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) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, env or param is null ", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null env or param"); return nullptr; } @@ -973,7 +973,7 @@ napi_ref CreateCallbackRefFromJS(napi_env env, napi_value param) NAPI_CALL(env, napi_typeof(env, param, &valueType)); if (valueType != napi_function) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, Param is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "invalid param"); return nullptr; } @@ -995,7 +995,7 @@ napi_value ExecuteAsyncCallbackWork(napi_env env, AsyncJSCallbackInfo *asyncCall { TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (asyncCallbackInfo == nullptr || param == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo or param is null", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo or param"); return nullptr; } @@ -1029,7 +1029,7 @@ napi_value ExecutePromiseCallbackWork(napi_env env, AsyncJSCallbackInfo *asyncCa { TAG_LOGI(AAFwkTag::JSNAPI, "called"); if (asyncCallbackInfo == nullptr || param == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo or param is null", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo or param"); return nullptr; } @@ -1066,7 +1066,7 @@ void CompleteAsyncCallbackWork(napi_env env, napi_status status, void *data) AsyncJSCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is nullptr", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return; } @@ -1095,7 +1095,7 @@ void CompleteAsyncVoidCallbackWork(napi_env env, napi_status status, void *data) TAG_LOGI(AAFwkTag::JSNAPI, "called"); AsyncJSCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is null", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return; } napi_value callback = nullptr; @@ -1136,7 +1136,7 @@ void CompletePromiseCallbackWork(napi_env env, napi_status status, void *data) AsyncJSCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is nullptr.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return; } @@ -1159,7 +1159,7 @@ void CompletePromiseVoidCallbackWork(napi_env env, napi_status status, void *dat AsyncJSCallbackInfo *asyncCallbackInfo = static_cast(data); if (asyncCallbackInfo == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, asyncCallbackInfo is null", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo"); return; } napi_value result = nullptr; @@ -1207,7 +1207,7 @@ std::vector ConvertStringVector(napi_env env, napi_value jsValue) bool isTypedArray = false; napi_status status = napi_is_typedarray(env, jsValue, &isTypedArray); if (status != napi_ok || !isTypedArray) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, napi_is_typedarray error", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "napi_is_typedarray error"); return {}; } @@ -1217,7 +1217,7 @@ std::vector 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) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, napi_uint8_array is nullptr", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null napi_uint8_array"); return {}; } std::string *data = nullptr; diff --git a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp index 3a698a75a7..8331a9b9f9 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_want.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_want.cpp @@ -287,7 +287,7 @@ bool InnerWrapWantParamsDouble( bool InnerWrapWantParamsWantParams( napi_env env, napi_value jsObject, const std::string &key, const AAFwk::WantParams &wantParams) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str()); + TAG_LOGD(AAFwkTag::JSNAPI, "key=%{public}s", key.c_str()); auto value = wantParams.GetParam(key); AAFwk::IWantParams *o = AAFwk::IWantParams::Query(value); if (o == nullptr) { @@ -307,17 +307,17 @@ bool InnerWrapWantParamsWantParams( bool InnerWrapWantParamsRemoteObject( napi_env env, napi_value jsObject, const std::string &key, const AAFwk::WantParams &wantParams) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str()); + TAG_LOGD(AAFwkTag::JSNAPI, "key=%{public}s", key.c_str()); auto value = wantParams.GetParam(key); AAFwk::IRemoteObjectWrap *remoteObjectIWrap = AAFwk::IRemoteObjectWrap::Query(value); if (remoteObjectIWrap == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s remoteObjectIWrap is nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null remoteObjectIWrap"); return false; } auto remoteObject = AAFwk::RemoteObjectWrap::UnBox(remoteObjectIWrap); auto jsValue = NAPI_ohos_rpc_CreateJsRemoteObject(env, remoteObject); if (jsValue == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s jsValue is nullptr.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null jsValue"); return false; } @@ -608,7 +608,7 @@ bool InnerWrapWantParamsArrayWantParams(napi_env env, napi_value jsObject, bool InnerWrapWantParamsArray(napi_env env, napi_value jsObject, const std::string &key, sptr &ao) { - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str()); + TAG_LOGD(AAFwkTag::JSNAPI, "key=%{public}s", key.c_str()); if (AAFwk::Array::IsStringArray(ao)) { return InnerWrapWantParamsArrayString(env, jsObject, key, ao); } else if (AAFwk::Array::IsBooleanArray(ao)) { @@ -878,7 +878,7 @@ bool UnwrapWantParams(napi_env env, napi_value param, AAFwk::WantParams &wantPar TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s is filtered.", strProName.c_str()); continue; } - TAG_LOGD(AAFwkTag::JSNAPI, "%{public}s called. Property name=%{public}s.", __func__, strProName.c_str()); + TAG_LOGD(AAFwkTag::JSNAPI, "property name=%{public}s", 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); @@ -920,7 +920,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 { - TAG_LOGW(AAFwkTag::JSNAPI, "not system app, REMOTE_OBJECT is FORIBBED IN WANT."); + TAG_LOGW(AAFwkTag::JSNAPI, "not system app"); } } else { bool isArray = false; @@ -958,7 +958,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) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, size is invalid, this object is not fd object.", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid size, not fd object"); return false; } @@ -968,8 +968,7 @@ 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) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, value property is invalid, this object is not fd object.", - __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "invalid value property, not fd object"); return false; } @@ -986,7 +985,7 @@ bool HandleFdObject(napi_env env, napi_value param, std::string &strProName, AAF int32_t natValue32 = 0; napi_get_value_int32(env, jsProValue, &natValue32); - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called, fd:%{public}d.", __func__, natValue32); + TAG_LOGI(AAFwkTag::JSNAPI, "fd:%{public}d", natValue32); WantParams wp; wp.SetParam(TYPE_PROPERTY, String::Box(FD)); wp.SetParam(VALUE_PROPERTY, Integer::Box(natValue32)); @@ -1005,7 +1004,7 @@ bool HandleRemoteObject(napi_env env, napi_value param, std::string &strProName, sptr remoteObject = NAPI_ohos_rpc_getNativeRemoteObject(env, jsProValue); if (remoteObject == nullptr) { - TAG_LOGE(AAFwkTag::JSNAPI, "%{public}s called, transfer to remoteObject fail", __func__); + TAG_LOGE(AAFwkTag::JSNAPI, "null remoteObject"); return false; } @@ -1071,7 +1070,7 @@ napi_value WrapWant(napi_env env, const Want &want) napi_value jsElementName = WrapElementName(env, want.GetElement()); if (jsElementName == nullptr) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Invoke WrapElementName failed.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "null jsElementName"); return nullptr; } @@ -1120,7 +1119,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)) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. Params is invalid.", __func__); + TAG_LOGI(AAFwkTag::JSNAPI, "not napi_object"); return false; } @@ -1290,7 +1289,7 @@ bool InnerWrapJsWantParamsWantParams( bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr &ao) { - TAG_LOGI(AAFwkTag::JSNAPI, "%{public}s called. key=%{public}s", __func__, key.c_str()); + TAG_LOGI(AAFwkTag::JSNAPI, "key=%{public}s", key.c_str()); if (AAFwk::Array::IsStringArray(ao)) { return InnerWrapWantParamsArray( env, object, key, ao); diff --git a/frameworks/js/napi/js_dialog_request/js_dialog_request_callback.cpp b/frameworks/js/napi/js_dialog_request/js_dialog_request_callback.cpp index afe8fef821..a5bb5d6ccb 100755 --- a/frameworks/js/napi/js_dialog_request/js_dialog_request_callback.cpp +++ b/frameworks/js/napi/js_dialog_request/js_dialog_request_callback.cpp @@ -78,16 +78,16 @@ private: if (jWant != nullptr && CheckTypeForNapiValue(env, jWant, napi_object)) { AppExecFwk::UnwrapWant(env, jWant, wantValue); } else { - TAG_LOGW(AAFwkTag::DIALOG, "jWant is invalid data!"); + TAG_LOGW(AAFwkTag::DIALOG, "invalid jWant"); } if (callback_ == nullptr) { - TAG_LOGE(AAFwkTag::DIALOG, "JsDialogRequestCallback::%{public}s, callback_ is nullptr", __func__); + TAG_LOGE(AAFwkTag::DIALOG, "null callback_"); ThrowError(env, AbilityErrorCode::ERROR_CODE_INNER); return CreateJsUndefined(env); } callback_->SendResult(resultCodeValue, wantValue); - TAG_LOGI(AAFwkTag::DIALOG, "function called end."); + TAG_LOGI(AAFwkTag::DIALOG, "end"); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/js_dialog_session/js_dialog_session.cpp b/frameworks/js/napi/js_dialog_session/js_dialog_session.cpp index da5d19dc8a..646518f1b3 100644 --- a/frameworks/js/napi/js_dialog_session/js_dialog_session.cpp +++ b/frameworks/js/napi/js_dialog_session/js_dialog_session.cpp @@ -57,7 +57,7 @@ private: { TAG_LOGD(AAFwkTag::DIALOG, "argc = %{public}d", static_cast(info.argc)); if (info.argc < 1) { - TAG_LOGE(AAFwkTag::DIALOG, "not enough params"); + TAG_LOGE(AAFwkTag::DIALOG, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -84,7 +84,7 @@ private: { TAG_LOGD(AAFwkTag::DIALOG, "argc = %{public}d", static_cast(info.argc)); if (info.argc < ARGC_THREE) { - TAG_LOGE(AAFwkTag::DIALOG, "not enough params"); + TAG_LOGE(AAFwkTag::DIALOG, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } diff --git a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp index a6fce7e1ef..5e6ee25b50 100644 --- a/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp +++ b/frameworks/js/napi/mission_manager/distributed_mission_manager.cpp @@ -393,7 +393,7 @@ napi_value NAPI_StopSyncRemoteMissions(napi_env env, napi_callback_info info) napi_create_string_latin1(env, __func__, NAPI_AUTO_LENGTH, &resourceName); StopSyncRemoteMissionsAsyncWork(env, resourceName, syncContext); - TAG_LOGI(AAFwkTag::MISSION, "%{public}s, end.", __func__); + TAG_LOGI(AAFwkTag::MISSION, "end"); return result; } @@ -402,14 +402,14 @@ RegisterMissionCB *CreateRegisterMissionCBCBInfo(napi_env &env) TAG_LOGI(AAFwkTag::MISSION, "called"); auto registerMissionCB = new (std::nothrow) RegisterMissionCB; if (registerMissionCB == nullptr) { - TAG_LOGE(AAFwkTag::MISSION, "%{public}s registerMissionCB == nullptr", __func__); + TAG_LOGE(AAFwkTag::MISSION, "null registerMissionCB"); return nullptr; } registerMissionCB->cbBase.cbInfo.env = env; registerMissionCB->cbBase.asyncWork = nullptr; registerMissionCB->cbBase.deferred = nullptr; registerMissionCB->callbackRef = nullptr; - TAG_LOGI(AAFwkTag::MISSION, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::MISSION, "end"); return registerMissionCB; } @@ -418,14 +418,14 @@ OnCB *CreateOnCBCBInfo(napi_env &env) TAG_LOGI(AAFwkTag::MISSION, "called"); auto onCB = new (std::nothrow) OnCB; if (onCB == nullptr) { - TAG_LOGE(AAFwkTag::MISSION, "%{public}s onCB == nullptr", __func__); + TAG_LOGE(AAFwkTag::MISSION, "null onCB"); return nullptr; } onCB->cbBase.cbInfo.env = env; onCB->cbBase.asyncWork = nullptr; onCB->cbBase.deferred = nullptr; onCB->callbackRef = nullptr; - TAG_LOGI(AAFwkTag::MISSION, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::MISSION, "end"); return onCB; } diff --git a/frameworks/js/napi/mission_manager/js_mission_info_utils.cpp b/frameworks/js/napi/mission_manager/js_mission_info_utils.cpp index c832893cf9..4e76af1832 100644 --- a/frameworks/js/napi/mission_manager/js_mission_info_utils.cpp +++ b/frameworks/js/napi/mission_manager/js_mission_info_utils.cpp @@ -140,7 +140,7 @@ bool InnerWrapJsWantParamsWantParams( bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr &ao) { - TAG_LOGI(AAFwkTag::MISSION, "%{public}s start. key=%{public}s", __func__, key.c_str()); + TAG_LOGI(AAFwkTag::MISSION, "key=%{public}s", key.c_str()); if (AAFwk::Array::IsStringArray(ao)) { return InnerWrapWantParamsArray( env, object, key, ao); diff --git a/frameworks/js/napi/particleAbility/particle_ability.cpp b/frameworks/js/napi/particleAbility/particle_ability.cpp index 9c829aabdf..05d1063f19 100644 --- a/frameworks/js/napi/particleAbility/particle_ability.cpp +++ b/frameworks/js/napi/particleAbility/particle_ability.cpp @@ -138,7 +138,7 @@ napi_value NAPI_PAStopAbility(napi_env env, napi_callback_info info) */ napi_value NAPI_PAAcquireDataAbilityHelper(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); return NAPI_AcquireDataAbilityHelperCommon(env, info, AbilityType::UNKNOWN); } @@ -152,7 +152,7 @@ napi_value NAPI_PAAcquireDataAbilityHelper(napi_env env, napi_callback_info info */ napi_value NAPI_PAStartBackgroundRunning(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); return NAPI_StartBackgroundRunningCommon(env, info); } @@ -166,7 +166,7 @@ napi_value NAPI_PAStartBackgroundRunning(napi_env env, napi_callback_info info) */ napi_value NAPI_PACancelBackgroundRunning(napi_env env, napi_callback_info info) { - TAG_LOGI(AAFwkTag::FA, "%{public}s,called", __func__); + TAG_LOGI(AAFwkTag::FA, "called"); return NAPI_CancelBackgroundRunningCommon(env, info); } @@ -200,7 +200,7 @@ napi_value ParticleAbilityInit(napi_env env, napi_value exports) void JsParticleAbility::Finalizer(napi_env env, void *data, void *hint) { - TAG_LOGI(AAFwkTag::FA, "JsParticleAbility::Finalizer is called"); + TAG_LOGI(AAFwkTag::FA, "finalizer called"); std::unique_ptr(static_cast(data)); } @@ -235,7 +235,7 @@ Ability* JsParticleAbility::GetAbility(napi_env env) ret = napi_get_global(env, &global); if (ret != napi_ok) { napi_get_last_error_info(env, &errorInfo); - TAG_LOGE(AAFwkTag::FA, "JsParticleAbility::GetAbility, get_global=%{public}d err:%{public}s", + TAG_LOGE(AAFwkTag::FA, "get_global=%{public}d err:%{public}s", ret, errorInfo->error_message); return nullptr; } @@ -243,7 +243,7 @@ Ability* JsParticleAbility::GetAbility(napi_env env) ret = napi_get_named_property(env, global, "ability", &abilityObj); if (ret != napi_ok) { napi_get_last_error_info(env, &errorInfo); - TAG_LOGE(AAFwkTag::FA, "JsParticleAbility::GetAbility, get_named_property=%{public}d err:%{public}s", + TAG_LOGE(AAFwkTag::FA, "get_named_property=%{public}d err:%{public}s", ret, errorInfo->error_message); return nullptr; } @@ -251,7 +251,7 @@ Ability* JsParticleAbility::GetAbility(napi_env env) ret = napi_get_value_external(env, abilityObj, reinterpret_cast(&ability)); if (ret != napi_ok) { napi_get_last_error_info(env, &errorInfo); - TAG_LOGE(AAFwkTag::FA, "JsParticleAbility::GetAbility, get_value_external=%{public}d err:%{public}s", + TAG_LOGE(AAFwkTag::FA, "get_value_external=%{public}d err:%{public}s", ret, errorInfo->error_message); return nullptr; } @@ -260,7 +260,7 @@ Ability* JsParticleAbility::GetAbility(napi_env env) napi_value JsParticleAbilityInit(napi_env env, napi_value exportObj) { - TAG_LOGD(AAFwkTag::FA, "JsParticleAbility is called"); + TAG_LOGD(AAFwkTag::FA, "called"); if (env == nullptr || exportObj == nullptr) { TAG_LOGE(AAFwkTag::FA, "env or exportObj null"); @@ -275,14 +275,14 @@ napi_value JsParticleAbilityInit(napi_env env, napi_value exportObj) jsParticleAbility->ability_ = jsParticleAbility->GetAbility(env); napi_wrap(env, exportObj, jsParticleAbility.release(), JsParticleAbility::Finalizer, nullptr, nullptr); - TAG_LOGD(AAFwkTag::FA, "JsParticleAbility BindNativeFunction called"); + TAG_LOGD(AAFwkTag::FA, "BindNativeFunction called"); const char *moduleName = "JsParticleAbility"; BindNativeFunction(env, exportObj, "connectAbility", moduleName, JsParticleAbility::PAConnectAbility); BindNativeFunction(env, exportObj, "disconnectAbility", moduleName, JsParticleAbility::PADisConnectAbility); BindNativeFunction(env, exportObj, "startAbility", moduleName, JsParticleAbility::PAStartAbility); BindNativeFunction(env, exportObj, "terminateSelf", moduleName, JsParticleAbility::PATerminateAbility); - TAG_LOGD(AAFwkTag::FA, "JsParticleAbility end"); + TAG_LOGD(AAFwkTag::FA, "end"); return exportObj; } } // namespace AppExecFwk diff --git a/frameworks/js/napi/wantConstant/want_constant.cpp b/frameworks/js/napi/wantConstant/want_constant.cpp index 15953d7a36..73d838c0b0 100644 --- a/frameworks/js/napi/wantConstant/want_constant.cpp +++ b/frameworks/js/napi/wantConstant/want_constant.cpp @@ -98,11 +98,13 @@ napi_value WantConstantInit(napi_env env, napi_value exports) #ifdef ENABLE_ERRCODE napi_value params = nullptr; napi_create_object(env, ¶ms); +#ifdef WITH_DLP SetNamedProperty(env, params, "ohos.dlp.params.sandbox", "DLP_PARAMS_SANDBOX"); SetNamedProperty(env, params, "ohos.dlp.params.bundleName", "DLP_PARAMS_BUNDLE_NAME"); SetNamedProperty(env, params, "ohos.dlp.params.moduleName", "DLP_PARAMS_MODULE_NAME"); SetNamedProperty(env, params, "ohos.dlp.params.abilityName", "DLP_PARAMS_ABILITY_NAME"); SetNamedProperty(env, params, "ohos.dlp.params.index", "DLP_PARAMS_INDEX"); +#endif // WITH_DLP SetNamedProperty(env, params, "ability.params.backToOtherMissionStack", "ABILITY_BACK_TO_OTHER_MISSION_STACK"); SetNamedProperty(env, params, "ohos.ability.params.abilityRecoveryRestart", "ABILITY_RECOVERY_RESTART"); SetNamedProperty(env, params, "ohos.ability.params.asssertFaultSessionId", "ASSERT_FAULT_SESSION_ID"); diff --git a/frameworks/native/ability/ability_runtime/ability_connection.cpp b/frameworks/native/ability/ability_runtime/ability_connection.cpp index 1c43bfe263..0713fb8fa9 100644 --- a/frameworks/native/ability/ability_runtime/ability_connection.cpp +++ b/frameworks/native/ability/ability_runtime/ability_connection.cpp @@ -29,10 +29,10 @@ constexpr int32_t DIED = -1; void AbilityConnection::OnAbilityConnectDone( const AppExecFwk::ElementName& element, const sptr& remoteObject, int resultCode) { - TAG_LOGD(AAFwkTag::CONNECTION, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::CONNECTION, "called"); mutex_.lock(); if (abilityConnectCallbackList_.empty()) { - TAG_LOGD(AAFwkTag::CONNECTION, "%{public}s abilityConnectCallbackList is empty.", __func__); + TAG_LOGD(AAFwkTag::CONNECTION, "empty abilityConnectCallbackList"); mutex_.unlock(); return; } @@ -54,17 +54,17 @@ void AbilityConnection::OnAbilityConnectDone( (*item)->OnAbilityConnectDone(element, remoteObject, resultCode); item++; } - TAG_LOGD(AAFwkTag::CONNECTION, "%{public}s end, bundleName:%{public}s, abilityName:%{public}s.", - __func__, element.GetBundleName().c_str(), element.GetAbilityName().c_str()); + TAG_LOGD(AAFwkTag::CONNECTION, "end, bundleName:%{public}s, abilityName:%{public}s.", + element.GetBundleName().c_str(), element.GetAbilityName().c_str()); } void AbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName& element, int resultCode) { - TAG_LOGD(AAFwkTag::CONNECTION, "%{public}s begin, resultCode:%{public}d.", __func__, resultCode); + TAG_LOGD(AAFwkTag::CONNECTION, "resultCode:%{public}d", resultCode); mutex_.lock(); SetConnectionState(CONNECTION_STATE_DISCONNECTED); if (abilityConnectCallbackList_.empty()) { - TAG_LOGE(AAFwkTag::CONNECTION, "%{public}s abilityConnectCallback is empty.", __func__); + TAG_LOGE(AAFwkTag::CONNECTION, "empty abilityConnectCallback"); mutex_.unlock(); return; } @@ -88,8 +88,8 @@ void AbilityConnection::OnAbilityDisconnectDone(const AppExecFwk::ElementName& e (*item)->OnAbilityDisconnectDone(element, resultCode); item++; } - TAG_LOGD(AAFwkTag::CONNECTION, "%{public}s end, bundleName:%{public}s, abilityName:%{public}s.", - __func__, element.GetBundleName().c_str(), element.GetAbilityName().c_str()); + TAG_LOGD(AAFwkTag::CONNECTION, "bundleName:%{public}s, abilityName:%{public}s.", + element.GetBundleName().c_str(), element.GetAbilityName().c_str()); } void AbilityConnection::AddConnectCallback(const sptr& abilityConnectCallback) diff --git a/frameworks/native/ability/ability_runtime/authorization_result.cpp b/frameworks/native/ability/ability_runtime/authorization_result.cpp index d2a8b8683c..13c3b7b1a2 100755 --- a/frameworks/native/ability/ability_runtime/authorization_result.cpp +++ b/frameworks/native/ability/ability_runtime/authorization_result.cpp @@ -23,7 +23,7 @@ void AuthorizationResult::GrantResultsCallback(const std::vector& p { TAG_LOGI(AAFwkTag::DEFAULT, "called"); if (task_) { - TAG_LOGD(AAFwkTag::DEFAULT, "%{public}s callback client function.", __func__); + TAG_LOGD(AAFwkTag::DEFAULT, "call client func"); task_(permissions, grantResults); } } diff --git a/frameworks/native/ability/ability_runtime/local_call_container.cpp b/frameworks/native/ability/ability_runtime/local_call_container.cpp index db482aeb68..33d7063dfb 100644 --- a/frameworks/native/ability/ability_runtime/local_call_container.cpp +++ b/frameworks/native/ability/ability_runtime/local_call_container.cpp @@ -215,10 +215,10 @@ void LocalCallContainer::DumpCalls(std::vector& info) tempstr += " uri[" + item.first + "]" + "\n"; tempstr += " callers #" + std::to_string(itemCall->GetCallers().size()); if (IsCallBackCalled(itemCall->GetCallers())) { - TAG_LOGI(AAFwkTag::LOCAL_CALL, "%{public}s state is REQUESTEND.", __func__); + TAG_LOGI(AAFwkTag::LOCAL_CALL, "state: REQUESTEND"); tempstr += " state #REQUESTEND"; } else { - TAG_LOGI(AAFwkTag::LOCAL_CALL, "%{public}s state is REQUESTING.", __func__); + TAG_LOGI(AAFwkTag::LOCAL_CALL, "state: REQUESTING"); tempstr += " state #REQUESTING"; } info.emplace_back(tempstr); diff --git a/frameworks/native/ability/ability_runtime/local_call_record.cpp b/frameworks/native/ability/ability_runtime/local_call_record.cpp index de878c4ba4..1efaa40ebc 100644 --- a/frameworks/native/ability/ability_runtime/local_call_record.cpp +++ b/frameworks/native/ability/ability_runtime/local_call_record.cpp @@ -186,8 +186,7 @@ bool LocalCallRecord::IsSameObject(const sptr& remote) const } bool retVal = (remoteObject_ == remote); - TAG_LOGD(AAFwkTag::LOCAL_CALL, "LocalCallRecord::%{public}s the input object same as local object is %{public}s.", - __func__, retVal ? "true" : "false"); + TAG_LOGD(AAFwkTag::LOCAL_CALL, "remoteObject_ matches remote: %{public}s", retVal ? "true" : "false"); return retVal; } diff --git a/frameworks/native/ability/native/BUILD.gn b/frameworks/native/ability/native/BUILD.gn index 6ee5f85a9c..e48187c2ab 100644 --- a/frameworks/native/ability/native/BUILD.gn +++ b/frameworks/native/ability/native/BUILD.gn @@ -263,7 +263,6 @@ ohos_shared_library("abilitykit_native") { "ability_base:base", "ability_base:configuration", "ability_base:extractortool", - "ability_base:session_info", "ability_base:want", "ability_base:zuri", "access_token:libaccesstoken_sdk", @@ -290,6 +289,7 @@ ohos_shared_library("abilitykit_native") { } public_external_deps = [ + "ability_base:session_info", "accessibility:accessibility_common", "bundle_framework:appexecfwk_core", "jsoncpp:jsoncpp", @@ -423,6 +423,7 @@ ohos_shared_library("extensionkit_native") { public_deps = [ ":abilitykit_utils" ] public_external_deps = [ + "ability_base:session_info", "bundle_framework:appexecfwk_core", "jsoncpp:jsoncpp", ] diff --git a/frameworks/native/ability/native/ability.cpp b/frameworks/native/ability/native/ability.cpp index ce200a4b05..cba3c6a85d 100644 --- a/frameworks/native/ability/native/ability.cpp +++ b/frameworks/native/ability/native/ability.cpp @@ -71,7 +71,9 @@ const int Ability::DEFAULT_DMS_SESSION_ID(0); const std::string LAUNCHER_BUNDLE_NAME = "com.ohos.launcher"; const std::string LAUNCHER_ABILITY_NAME = "com.ohos.launcher.MainAbility"; const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen"; +#ifdef WITH_DLP const std::string DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag"; +#endif // WITH_DLP const std::string COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules"; Ability* Ability::Create(const std::unique_ptr& runtime) @@ -163,8 +165,10 @@ void Ability::OnStart(const Want &want, sptr sessionInfo) return; } +#ifdef WITH_DLP securityFlag_ = want.GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false); (const_cast(want)).RemoveParam(DLP_PARAMS_SECURITY_FLAG); +#endif // WITH_DLP SetWant(want); #ifdef SUPPORT_SCREEN if (sessionInfo != nullptr) { diff --git a/frameworks/native/ability/native/ability_context.cpp b/frameworks/native/ability/native/ability_context.cpp index 1cc4ec1e68..5fab3b53e8 100644 --- a/frameworks/native/ability/native/ability_context.cpp +++ b/frameworks/native/ability/native/ability_context.cpp @@ -50,29 +50,28 @@ const std::string CALLBACK_KEY = "ohos.ability.params.callback"; ErrCode AbilityContext::StartAbility(const AAFwk::Want &want, int requestCode) { - TAG_LOGD(AAFwkTag::CONTEXT, "AbilityContext::StartAbility called, requestCode = %{public}d", requestCode); + TAG_LOGD(AAFwkTag::CONTEXT, "requestCode: %{public}d", requestCode); AppExecFwk::AbilityType type = GetAbilityInfoType(); if (type != AppExecFwk::AbilityType::PAGE && type != AppExecFwk::AbilityType::SERVICE) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::StartAbility AbilityType = %{public}d", type); + TAG_LOGE(AAFwkTag::CONTEXT, "abilityType: %{public}d", type); return ERR_INVALID_VALUE; } ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, token_, requestCode); - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s. End calling ability_manager->StartAbility. ret=%{public}d", __func__, err); + TAG_LOGD(AAFwkTag::CONTEXT, "ret=%{public}d", err); return err; } ErrCode AbilityContext::StartAbility(const Want &want, int requestCode, const AbilityStartSetting &abilityStartSetting) { - TAG_LOGD(AAFwkTag::CONTEXT, "AbilityContext::StartAbility with start setting called, requestCode = %{public}d", - requestCode); + TAG_LOGD(AAFwkTag::CONTEXT, "requestCode: %{public}d", requestCode); AppExecFwk::AbilityType type = GetAbilityInfoType(); if (type != AppExecFwk::AbilityType::PAGE && type != AppExecFwk::AbilityType::SERVICE) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::StartAbility AbilityType = %{public}d", type); + TAG_LOGE(AAFwkTag::CONTEXT, "abilityType: %{public}d", type); return ERR_INVALID_VALUE; } ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StartAbility(want, abilityStartSetting, token_, requestCode); - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s. End calling ability_manager->StartAbility. ret=%{public}d", __func__, err); + TAG_LOGD(AAFwkTag::CONTEXT, "ret=%{public}d", err); return err; } @@ -80,29 +79,28 @@ ErrCode AbilityContext::TerminateAbility() { std::shared_ptr info = GetAbilityInfo(); if (info == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::TerminateAbility info == nullptr"); + TAG_LOGE(AAFwkTag::CONTEXT, "null info"); return ERR_NULL_OBJECT; } ErrCode err = ERR_OK; switch (info->type) { case AppExecFwk::AbilityType::PAGE: - TAG_LOGD(AAFwkTag::CONTEXT, "Terminate ability begin, type is page, ability is %{public}s.", - info->name.c_str()); + TAG_LOGD(AAFwkTag::CONTEXT, "page type, ability: %{public}s", info->name.c_str()); #ifdef SUPPORT_SCREEN if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { auto sessionToken = GetSessionToken(); if (sessionToken == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "sessionToken is nullptr."); + TAG_LOGE(AAFwkTag::CONTEXT, "null sessionToken"); return ERR_INVALID_VALUE; } sptr sessionInfo = new AAFwk::SessionInfo(); sessionInfo->want = resultWant_; sessionInfo->resultCode = resultCode_; - TAG_LOGI(AAFwkTag::CONTEXT, "FA TerminateAbility resultCode is %{public}d", sessionInfo->resultCode); + TAG_LOGI(AAFwkTag::CONTEXT, "resultCode: %{public}d", sessionInfo->resultCode); auto ifaceSessionToken = iface_cast(sessionToken); auto err = ifaceSessionToken->TerminateSession(sessionInfo); - TAG_LOGI(AAFwkTag::CONTEXT, "FA TerminateAbility. ret=%{public}d", err); + TAG_LOGI(AAFwkTag::CONTEXT, "ret: %{public}d", err); return static_cast(err); } else { err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, resultCode_, &resultWant_); @@ -110,17 +108,16 @@ ErrCode AbilityContext::TerminateAbility() #endif // SUPPORT_SCREEN break; case AppExecFwk::AbilityType::SERVICE: - TAG_LOGD(AAFwkTag::CONTEXT, "Terminate ability begin, type is service, ability is %{public}s.", - info->name.c_str()); + TAG_LOGD(AAFwkTag::CONTEXT, "service type, ability: %{public}s", info->name.c_str()); err = AAFwk::AbilityManagerClient::GetInstance()->TerminateAbility(token_, -1, nullptr); break; default: - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::TerminateAbility info type error is %{public}d", info->type); + TAG_LOGE(AAFwkTag::CONTEXT, "error type: %{public}d", info->type); break; } if (err != ERR_OK) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::TerminateAbility is failed %{public}d", err); + TAG_LOGE(AAFwkTag::CONTEXT, "failed %{public}d", err); } return err; } @@ -132,10 +129,10 @@ std::string AbilityContext::GetCallingBundle() std::shared_ptr AbilityContext::GetElementName() { - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "called"); std::shared_ptr info = GetAbilityInfo(); if (info == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::GetElementName info == nullptr"); + TAG_LOGE(AAFwkTag::CONTEXT, "null info"); return nullptr; } @@ -144,19 +141,19 @@ std::shared_ptr AbilityContext::GetElementName() elementName->SetBundleName(info->bundleName); elementName->SetDeviceID(info->deviceId); elementName->SetModuleName(info->moduleName); - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "end"); return elementName; } std::shared_ptr AbilityContext::GetCallingAbility() { - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "called"); std::shared_ptr elementName = std::make_shared(); elementName->SetAbilityName(callingAbilityName_); elementName->SetBundleName(callingBundleName_); elementName->SetDeviceID(callingDeviceId_); elementName->SetModuleName(callingModuleName_); - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "end"); return elementName; } @@ -167,24 +164,24 @@ bool AbilityContext::ConnectAbility(const Want &want, const sptr abilityInfo = GetAbilityInfo(); if (abilityInfo == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::ConnectAbility info == nullptr"); + TAG_LOGE(AAFwkTag::CONTEXT, "null info"); return false; } - TAG_LOGI(AAFwkTag::CONTEXT, "Connect ability begin, ability:%{public}s.", abilityInfo->name.c_str()); + TAG_LOGI(AAFwkTag::CONTEXT, "called, ability:%{public}s.", abilityInfo->name.c_str()); if (type != AppExecFwk::AbilityType::PAGE && type != AppExecFwk::AbilityType::SERVICE) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::ConnectAbility AbilityType = %{public}d", type); + TAG_LOGE(AAFwkTag::CONTEXT, "abilityType: %{public}d", type); return false; } ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->ConnectAbility(want, conn, token_); - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end ConnectAbility, ret=%{public}d", __func__, ret); + TAG_LOGD(AAFwkTag::CONTEXT, "ret=%{public}d", ret); bool value = ((ret == ERR_OK) ? true : false); if (!value) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::ConnectAbility ErrorCode = %{public}d", ret); + TAG_LOGE(AAFwkTag::CONTEXT, "errorCode = %{public}d", ret); } - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "end"); return value; } @@ -192,34 +189,34 @@ ErrCode AbilityContext::DisconnectAbility(const sptr { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); std::shared_ptr info = GetAbilityInfo(); - TAG_LOGI(AAFwkTag::CONTEXT, "Disconnect ability begin, caller:%{public}s.", + TAG_LOGI(AAFwkTag::CONTEXT, "called, caller:%{public}s", info == nullptr ? "" : info->name.c_str()); AppExecFwk::AbilityType type = GetAbilityInfoType(); if (type != AppExecFwk::AbilityType::PAGE && type != AppExecFwk::AbilityType::SERVICE) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::DisconnectAbility AbilityType = %{public}d", type); + TAG_LOGE(AAFwkTag::CONTEXT, "AbilityType = %{public}d", type); return ERR_INVALID_VALUE; } ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->DisconnectAbility(conn); if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::DisconnectAbility error, ret=%{public}d.", ret); + TAG_LOGE(AAFwkTag::CONTEXT, "error, ret=%{public}d", ret); } return ret; } bool AbilityContext::StopAbility(const AAFwk::Want &want) { - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "called"); AppExecFwk::AbilityType type = GetAbilityInfoType(); if (type != AppExecFwk::AbilityType::PAGE && type != AppExecFwk::AbilityType::SERVICE) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::StopAbility AbilityType = %{public}d", type); + TAG_LOGE(AAFwkTag::CONTEXT, "abilityType: %{public}d", type); return false; } ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->StopServiceAbility(want, token_); if (err != ERR_OK) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::StopAbility is failed %{public}d", err); + TAG_LOGE(AAFwkTag::CONTEXT, "failed %{public}d", err); return false; } @@ -235,7 +232,7 @@ AppExecFwk::AbilityType AbilityContext::GetAbilityInfoType() { std::shared_ptr info = GetAbilityInfo(); if (info == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::GetAbilityInfoType info == nullptr"); + TAG_LOGE(AAFwkTag::CONTEXT, "null info"); return AppExecFwk::AbilityType::UNKNOWN; } @@ -246,15 +243,15 @@ std::shared_ptr AbilityContext::GetResourceMa { std::shared_ptr appContext = GetApplicationContext(); if (appContext == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::GetResourceManager appContext is nullptr"); + TAG_LOGE(AAFwkTag::CONTEXT, "null appContext"); return nullptr; } - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s begin appContext->GetResourceManager.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "before getResourceManager"); std::shared_ptr resourceManager = appContext->GetResourceManager(); - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end appContext->GetResourceManager.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "after getResourceManager"); if (resourceManager == nullptr) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::GetResourceManager resourceManager is nullptr"); + TAG_LOGE(AAFwkTag::CONTEXT, "null resourceManager"); return nullptr; } return resourceManager; @@ -262,13 +259,12 @@ std::shared_ptr AbilityContext::GetResourceMa int AbilityContext::VerifyPermission(const std::string &permission, int pid, int uid) { - TAG_LOGI(AAFwkTag::CONTEXT, "%{public}s begin. permission=%{public}s, pid=%{public}d, uid=%{public}d", - __func__, + TAG_LOGI(AAFwkTag::CONTEXT, "permission=%{public}s, pid=%{public}d, uid=%{public}d", permission.c_str(), pid, uid); ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->VerifyPermission(permission, pid, uid); - TAG_LOGD(AAFwkTag::CONTEXT, "End calling VerifyPermission. ret=%{public}d", err); + TAG_LOGD(AAFwkTag::CONTEXT, "ret=%{public}d", err); if (err != ERR_OK) { return AppExecFwk::Constants::PERMISSION_NOT_GRANTED; } @@ -280,18 +276,18 @@ void AbilityContext::GetPermissionDes(const std::string &permissionName, std::st Security::AccessToken::PermissionDef permissionDef; int32_t ret = Security::AccessToken::AccessTokenKit::GetDefPermission(permissionName, permissionDef); if (ret == Security::AccessToken::AccessTokenKitRet::RET_SUCCESS) { - TAG_LOGD(AAFwkTag::CONTEXT, "GetPermissionDes %{public}s: RET_SUCCESS", permissionName.c_str()); + TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s: RET_SUCCESS", permissionName.c_str()); des = permissionDef.description; } - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end GetPermissionDef.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "end"); } void AbilityContext::RequestPermissionsFromUser(std::vector &permissions, std::vector &permissionsState, PermissionRequestTask &&task) { - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "called"); if (permissions.size() == 0) { - TAG_LOGE(AAFwkTag::CONTEXT, "AbilityContext::RequestPermissionsFromUser permissions is empty"); + TAG_LOGE(AAFwkTag::CONTEXT, "empty permissions"); return; } @@ -303,7 +299,7 @@ void AbilityContext::RequestPermissionsFromUser(std::vector &permis sptr remoteObject = new AbilityRuntime::AuthorizationResult(std::move(task)); want.SetParam(CALLBACK_KEY, remoteObject); StartAbility(want, -1); - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "end"); } void AbilityContext::SetCallingContext(const std::string &deviceId, const std::string &bundleName, @@ -320,7 +316,7 @@ void AbilityContext::StartAbilities(const std::vector &wants) for (auto want : wants) { StartAbility(want, ABILITY_CONTEXT_DEFAULT_REQUEST_CODE); } - TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "end"); } sptr AbilityContext::GetSessionToken() @@ -333,7 +329,7 @@ int32_t AbilityContext::AddFreeInstallObserver(const sptrAddFreeInstallObserver(token_, observer); if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::CONTEXT, "AddFreeInstallObserver error, ret: %{public}d", ret); + TAG_LOGE(AAFwkTag::CONTEXT, "add observer failed, ret: %{public}d", ret); } return ret; } diff --git a/frameworks/native/ability/native/ability_impl.cpp b/frameworks/native/ability/native/ability_impl.cpp index 0f22eaeca4..e36fe0f5ee 100644 --- a/frameworks/native/ability/native/ability_impl.cpp +++ b/frameworks/native/ability/native/ability_impl.cpp @@ -43,12 +43,10 @@ void AbilityImpl::Init(const std::shared_ptr &application, const sptr &token) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::init begin"); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if ((token == nullptr) || (application == nullptr) || (handler == nullptr) || (record == nullptr) || ability == nullptr) { - TAG_LOGE(AAFwkTag::ABILITY, - "AbilityImpl::init failed, token is nullptr, application is nullptr, handler is nullptr, record is " - "nullptr, ability is nullptr"); + TAG_LOGE(AAFwkTag::ABILITY, "null token or application or handler or record or ability"); return; } @@ -65,15 +63,15 @@ void AbilityImpl::Init(const std::shared_ptr &application, ability_->Init(record->GetAbilityInfo(), application, handler, token); lifecycleState_ = AAFwk::ABILITY_STATE_INITIAL; abilityLifecycleCallbacks_ = application; - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::init end"); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::Start(const Want &want, sptr sessionInfo) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) { - TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::Start ability_ or abilityLifecycleCallbacks_ is nullptr"); + TAG_LOGE(AAFwkTag::ABILITY, "null ability_ or abilityLifecycleCallbacks_"); return; } #ifdef SUPPORT_SCREEN @@ -87,7 +85,7 @@ void AbilityImpl::Start(const Want &want, sptr sessionInfo) ability_->HandleCreateAsRecovery(want); } #endif - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::Start"); + TAG_LOGD(AAFwkTag::ABILITY, "call onStart"); ability_->OnStart(want, sessionInfo); #ifdef SUPPORT_SCREEN if ((ability_->GetAbilityInfo()->type == AppExecFwk::AbilityType::PAGE) && @@ -104,12 +102,12 @@ void AbilityImpl::Start(const Want &want, sptr sessionInfo) } #endif - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::Stop() { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::Stop ability_ or abilityLifecycleCallbacks_ is nullptr"); return; @@ -117,12 +115,12 @@ void AbilityImpl::Stop() ability_->OnStop(); StopCallback(); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::Stop(bool &isAsyncCallback) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::Stop ability_ or abilityLifecycleCallbacks_ is nullptr"); isAsyncCallback = false; @@ -154,7 +152,7 @@ void AbilityImpl::Stop(bool &isAsyncCallback) AbilityTransactionCallbackInfo<>::Destroy(callbackInfo); } // else: callbackInfo will be destroyed after the async callback - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::StopCallback() @@ -178,7 +176,7 @@ void AbilityImpl::StopCallback() void AbilityImpl::Active() { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::Active ability_ or abilityLifecycleCallbacks_ is nullptr"); return; @@ -192,12 +190,12 @@ void AbilityImpl::Active() } #endif lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE; - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::Inactive() { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::Inactive ability_ or abilityLifecycleCallbacks_ is nullptr"); return; @@ -211,13 +209,13 @@ void AbilityImpl::Inactive() } #endif lifecycleState_ = AAFwk::ABILITY_STATE_INACTIVE; - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } int32_t AbilityImpl::Share(WantParams &wantParam) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::OnShare ability_ is nullptr "); return ERR_INVALID_VALUE; @@ -232,7 +230,7 @@ bool AbilityImpl::IsStageBasedModel() const void AbilityImpl::DispatchSaveAbilityState() { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || abilityLifecycleCallbacks_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::DispatchSaveAbilityState ability_ or abilityLifecycleCallbacks_ is nullptr"); @@ -240,12 +238,12 @@ void AbilityImpl::DispatchSaveAbilityState() } needSaveDate_ = true; - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::DispatchRestoreAbilityState(const PacMap &inState) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::DispatchRestoreAbilityState ability_ is nullptr"); return; @@ -253,7 +251,7 @@ void AbilityImpl::DispatchRestoreAbilityState(const PacMap &inState) hasSaveData_ = true; restoreData_ = inState; - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::HandleAbilityTransaction(const Want &want, const AAFwk::LifeCycleStateInfo &targetState, @@ -268,14 +266,14 @@ void AbilityImpl::AbilityTransactionCallback(const AAFwk::AbilityLifeCycleState sptr AbilityImpl::ConnectAbility(const Want &want) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::ConnectAbility ability_ is nullptr"); return nullptr; } sptr object = ability_->OnConnect(want); lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE; - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); return object; } @@ -292,14 +290,14 @@ void AbilityImpl::DisconnectAbility(const Want &want) void AbilityImpl::CommandAbility(const Want &want, bool restart, int startId) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::CommandAbility ability_ is nullptr"); return; } ability_->OnCommand(want, restart, startId); lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE; - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } #ifdef SUPPORT_SCREEN bool AbilityImpl::PrepareTerminateAbility() @@ -321,7 +319,7 @@ int AbilityImpl::GetCurrentState() void AbilityImpl::SendResult(int requestCode, int resultCode, const Want &resultData) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::SendResult ability_ is nullptr"); return; @@ -330,12 +328,12 @@ void AbilityImpl::SendResult(int requestCode, int resultCode, const Want &result ability_->OnAbilityResult(requestCode, resultCode, resultData); // for api5 FeatureAbility::startAbilityForResult ability_->OnFeatureAbilityResult(requestCode, resultCode, resultData); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::NewWant(const Want &want) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::NewWant ability_ is nullptr"); return; @@ -345,7 +343,7 @@ void AbilityImpl::NewWant(const Want &want) #ifdef SUPPORT_SCREEN ability_->ContinuationRestore(want); #endif - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } std::vector AbilityImpl::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter) @@ -419,13 +417,13 @@ int AbilityImpl::BatchInsert(const Uri &uri, const std::vectorSetUriString(uri); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::SetLifeCycleStateInfo(const AAFwk::LifeCycleStateInfo &info) @@ -503,7 +501,7 @@ Uri AbilityImpl::DenormalizeUri(const Uri &uri) void AbilityImpl::ScheduleUpdateConfiguration(const Configuration &config) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::ScheduleUpdateConfiguration ability_ is nullptr"); return; @@ -514,7 +512,7 @@ void AbilityImpl::ScheduleUpdateConfiguration(const Configuration &config) ability_->OnConfigurationUpdatedNotify(config); } - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } std::shared_ptr AbilityImpl::CreatePostEventTimeouter(std::string taskstr) @@ -688,27 +686,27 @@ void AbilityImpl::WindowLifeCycleImpl::AfterBackground() void AbilityImpl::WindowLifeCycleImpl::AfterFocused() { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); auto owner = owner_.lock(); if (owner) { owner->AfterFocused(); } - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::WindowLifeCycleImpl::AfterUnfocused() { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); auto owner = owner_.lock(); if (owner) { owner->AfterUnFocused(); } - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void AbilityImpl::WindowLifeCycleImpl::ForegroundFailed(int32_t type) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); PacMap restoreData; switch (type) { case static_cast(OHOS::Rosen::WMError::WM_ERROR_INVALID_OPERATION): { @@ -744,7 +742,7 @@ void AbilityImpl::WindowLifeCycleImpl::ForegroundFailed(int32_t type) void AbilityImpl::Foreground(const Want &want) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) { TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::Foreground ability_ or abilityLifecycleCallbacks_ is nullptr"); return; @@ -762,12 +760,12 @@ void AbilityImpl::Foreground(const Want &want) std::lock_guard lock(notifyForegroundLock_); notifyForegroundByAbility_ = true; } - TAG_LOGI(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::ABILITY, "end"); } void AbilityImpl::WindowLifeCycleImpl::BackgroundFailed(int32_t type) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (type == static_cast(OHOS::Rosen::WMError::WM_DO_NOTHING)) { PacMap restoreData; AbilityManagerClient::GetInstance()->AbilityTransitionDone(token_, @@ -777,9 +775,9 @@ void AbilityImpl::WindowLifeCycleImpl::BackgroundFailed(int32_t type) void AbilityImpl::Background() { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (ability_ == nullptr || ability_->GetAbilityInfo() == nullptr || abilityLifecycleCallbacks_ == nullptr) { - TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::Background ability_ or abilityLifecycleCallbacks_ is nullptr"); + TAG_LOGE(AAFwkTag::ABILITY, "null ability_ or abilityLifecycleCallbacks_"); return; } ability_->OnLeaveForeground(); @@ -795,17 +793,17 @@ void AbilityImpl::Background() void AbilityImpl::DoKeyDown(const std::shared_ptr& keyEvent) { - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::DoKeyDown called"); + TAG_LOGD(AAFwkTag::ABILITY, "called"); } void AbilityImpl::DoKeyUp(const std::shared_ptr& keyEvent) { - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::DoKeyUp called"); + TAG_LOGD(AAFwkTag::ABILITY, "called"); } void AbilityImpl::DoPointerEvent(std::shared_ptr& pointerEvent) { - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::DoPointerEvent called"); + TAG_LOGD(AAFwkTag::ABILITY, "called"); } void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr keyEvent) const @@ -813,10 +811,10 @@ void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptrGetKeyAction(); if (code == MMI::KeyEvent::KEY_ACTION_DOWN) { abilityImpl_->DoKeyDown(keyEvent); - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::OnKeyDown keyAction: %{public}d.", code); + TAG_LOGD(AAFwkTag::ABILITY, "keyAction: %{public}d", code); } else if (code == MMI::KeyEvent::KEY_ACTION_UP) { abilityImpl_->DoKeyUp(keyEvent); - TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::DoKeyUp keyAction: %{public}d.", code); + TAG_LOGD(AAFwkTag::ABILITY, "keyAction: %{public}d", code); } } diff --git a/frameworks/native/ability/native/ability_runtime/js_ability.cpp b/frameworks/native/ability/native/ability_runtime/js_ability.cpp index 3b16f0ac5e..19f093574f 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability.cpp @@ -276,7 +276,7 @@ void JsAbility::AddLifecycleEventAfterJSCall(FreezeUtil::TimeoutState state, con int32_t JsAbility::OnShare(WantParams &wantParam) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); HandleScope handleScope(jsRuntime_); auto env = jsRuntime_.GetNapiEnv(); if (jsAbilityObj_ == nullptr) { @@ -295,14 +295,14 @@ int32_t JsAbility::OnShare(WantParams &wantParam) }; CallObjectMethod("onShare", argv, ArraySize(argv)); OHOS::AppExecFwk::UnwrapWantParams(env, jsWantParams, wantParam); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); return ERR_OK; } void JsAbility::OnStop() { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITY, "OnStop begin."); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (abilityContext_) { TAG_LOGD(AAFwkTag::ABILITY, "OnStop, set terminating true."); abilityContext_->SetTerminating(true); @@ -323,7 +323,7 @@ void JsAbility::OnStop(AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInf } HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITY, "OnStop begin."); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (abilityContext_) { TAG_LOGD(AAFwkTag::ABILITY, "OnStop, set terminating true."); abilityContext_->SetTerminating(true); @@ -354,21 +354,21 @@ void JsAbility::OnStop(AppExecFwk::AbilityTransactionCallbackInfo<> *callbackInf TAG_LOGE(AAFwkTag::ABILITY, "Failed to call promise."); OnStopCallback(); } - TAG_LOGD(AAFwkTag::ABILITY, "OnStop end."); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void JsAbility::OnStopCallback() { auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator(); if (delegator) { - TAG_LOGD(AAFwkTag::ABILITY, "Call AbilityDelegator::PostPerformStop"); + TAG_LOGD(AAFwkTag::ABILITY, "call PostPerformStop"); delegator->PostPerformStop(CreateADelegatorAbilityProperty()); } bool ret = ConnectionManager::GetInstance().DisconnectCaller(AbilityContext::token_); if (ret) { ConnectionManager::GetInstance().ReportConnectionLeakEvent(getpid(), gettid()); - TAG_LOGD(AAFwkTag::ABILITY, "The service connection is not disconnected."); + TAG_LOGD(AAFwkTag::ABILITY, "service connection not disconnected"); } auto applicationContext = AbilityRuntime::Context::GetApplicationContext(); @@ -384,7 +384,7 @@ const std::string SUPPORT_CONTINUE_PAGE_STACK_PROPERTY_NAME = "ohos.extra.param. void JsAbility::OnSceneCreated() { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); - TAG_LOGD(AAFwkTag::ABILITY, "OnSceneCreated begin, ability is %{public}s.", GetAbilityName().c_str()); + TAG_LOGD(AAFwkTag::ABILITY, "ability: %{public}s", GetAbilityName().c_str()); Ability::OnSceneCreated(); auto jsAppWindowStage = CreateAppWindowStage(); if (jsAppWindowStage == nullptr) { @@ -414,7 +414,7 @@ void JsAbility::OnSceneCreated() applicationContext->DispatchOnWindowStageCreate(jsAbilityObj_, jsWindowStageObj_); } - TAG_LOGD(AAFwkTag::ABILITY, "OnSceneCreated end, ability is %{public}s.", GetAbilityName().c_str()); + TAG_LOGD(AAFwkTag::ABILITY, "end, ability: %{public}s", GetAbilityName().c_str()); } void JsAbility::OnSceneRestored() @@ -432,7 +432,7 @@ void JsAbility::OnSceneRestored() auto delegator = AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator(); if (delegator) { - TAG_LOGD(AAFwkTag::ABILITY, "Call AbilityDelegator::PostPerformScenceRestored"); + TAG_LOGD(AAFwkTag::ABILITY, "Call PostPerformScenceRestored"); delegator->PostPerformScenceRestored(CreateADelegatorAbilityProperty()); } @@ -664,7 +664,7 @@ void JsAbility::DoOnForeground(const Want &want) TAG_LOGI(AAFwkTag::ABILITY, "Move scene to foreground, sceneFlag_:%{public}d.", Ability::sceneFlag_); AddLifecycleEventBeforeJSCall(FreezeUtil::TimeoutState::FOREGROUND, METHOD_NAME); scene_->GoForeground(Ability::sceneFlag_); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end scene_->GoForeground.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } bool JsAbility::InitWindowScene(const Want &want) @@ -885,7 +885,7 @@ void JsAbility::UpdateContextConfiguration() void JsAbility::OnNewWant(const Want &want) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); Ability::OnNewWant(want); #ifdef SUPPORT_SCREEN @@ -923,12 +923,12 @@ void JsAbility::OnNewWant(const Want &want) CallObjectMethod("onNewWant", argv, ArraySize(argv)); AddLifecycleEventAfterJSCall(FreezeUtil::TimeoutState::FOREGROUND, methodName); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } void JsAbility::OnAbilityResult(int requestCode, int resultCode, const Want &resultData) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); Ability::OnAbilityResult(requestCode, resultCode, resultData); std::shared_ptr context = GetAbilityContext(); if (context == nullptr) { @@ -936,19 +936,19 @@ void JsAbility::OnAbilityResult(int requestCode, int resultCode, const Want &res return; } context->OnAbilityResult(requestCode, resultCode, resultData); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } sptr JsAbility::CallRequest() { - TAG_LOGD(AAFwkTag::ABILITY, "JsAbility::CallRequest begin."); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (jsAbilityObj_ == nullptr) { - TAG_LOGW(AAFwkTag::ABILITY, "JsAbility::CallRequest Obj is nullptr"); + TAG_LOGW(AAFwkTag::ABILITY, "Obj is nullptr"); return nullptr; } if (remoteCallee_ != nullptr) { - TAG_LOGD(AAFwkTag::ABILITY, "JsAbility::CallRequest get Callee remoteObj."); + TAG_LOGD(AAFwkTag::ABILITY, "get Callee remoteObj"); return remoteCallee_; } diff --git a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp index 8c0410801c..40d584478d 100644 --- a/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_ability_context.cpp @@ -512,7 +512,7 @@ napi_value JsAbilityContext::OnStartUIServiceExtension(napi_env env, NapiCallbac bool JsAbilityContext::UnwrapConnectUIServiceExtensionParam(napi_env env, NapiCallbackInfo& info, AAFwk::Want& want) { if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::UISERVC_EXT, "failed, not enough params."); + TAG_LOGE(AAFwkTag::UISERVC_EXT, "invalid argc"); ThrowTooFewParametersError(env); return false; } @@ -628,7 +628,7 @@ void JsAbilityContext::DoConnectUIServiceExtension(napi_env env, napi_value JsAbilityContext::OnDisconnectUIServiceExtension(napi_env env, NapiCallbackInfo& info) { if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UISERVC_EXT, "failed, not enough params."); + TAG_LOGE(AAFwkTag::UISERVC_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -1002,7 +1002,7 @@ bool JsAbilityContext::CheckStartAbilityByCallParams(napi_env env, NapiCallbackI napi_value JsAbilityContext::OnStartAbilityByCall(napi_env env, NapiCallbackInfo& info) { - TAG_LOGD(AAFwkTag::CONTEXT, "JsAbilityContext::%{public}s, called", __func__); + TAG_LOGD(AAFwkTag::CONTEXT, "called"); // 1. check params napi_value lastParam = nullptr; int32_t userId = DEFAULT_INVAL_VALUE; @@ -1381,7 +1381,7 @@ napi_value JsAbilityContext::OnTerminateSelfWithResult(napi_env env, NapiCallbac int resultCode = 0; AAFwk::Want want; if (!AppExecFwk::UnWrapAbilityResult(env, info.argv[INDEX_ZERO], resultCode, want)) { - TAG_LOGE(AAFwkTag::CONTEXT, "%s Failed to parse ability result!", __func__); + TAG_LOGE(AAFwkTag::CONTEXT, "failed to parse ability result"); ThrowInvalidParamError(env, "Parse param want failed, want must be Want."); return CreateJsUndefined(env); } @@ -1413,7 +1413,7 @@ napi_value JsAbilityContext::OnTerminateSelfWithResult(napi_env env, NapiCallbac napi_value result = nullptr; NapiAsyncTask::ScheduleHighQos("JsAbilityContext::OnTerminateSelfWithResult", env, CreateAsyncTaskWithLastParam(env, lastParam, nullptr, std::move(complete), &result)); - TAG_LOGD(AAFwkTag::CONTEXT, "OnTerminateSelfWithResult is called end"); + TAG_LOGD(AAFwkTag::CONTEXT, "end"); return result; } @@ -1422,7 +1422,7 @@ napi_value JsAbilityContext::OnConnectAbility(napi_env env, NapiCallbackInfo& in HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); // only support two params if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::CONTEXT, "Connect ability failed, not enough params."); + TAG_LOGE(AAFwkTag::CONTEXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } diff --git a/frameworks/native/ability/native/ability_runtime/js_caller_complex.cpp b/frameworks/native/ability/native/ability_runtime/js_caller_complex.cpp index 14108fdcc0..13b55a2c73 100644 --- a/frameworks/native/ability/native/ability_runtime/js_caller_complex.cpp +++ b/frameworks/native/ability/native/ability_runtime/js_caller_complex.cpp @@ -99,30 +99,26 @@ public: static void Finalizer(napi_env env, void* data, void* hint) { - TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::DEFAULT, "called"); if (data == nullptr) { - TAG_LOGE( - AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s is called, but input parameters is nullptr", __func__); + TAG_LOGE(AAFwkTag::DEFAULT, "null data"); return; } auto ptr = static_cast(data); if (!FindJsCallerComplex(ptr)) { - TAG_LOGE(AAFwkTag::DEFAULT, - "JsCallerComplex::%{public}s is called, but input parameters does not found", __func__); + TAG_LOGE(AAFwkTag::DEFAULT, "input parameters does not found"); return; } ReleaseObject(ptr); - TAG_LOGD(AAFwkTag::DEFAULT, "JsCallerComplex::%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::DEFAULT, "end"); } static napi_value JsReleaseCall(napi_env env, napi_callback_info info) { if (env == nullptr || info == nullptr) { - TAG_LOGE(AAFwkTag::DEFAULT, - "JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr", __func__, - ((env == nullptr) ? "env" : "info")); + TAG_LOGE(AAFwkTag::DEFAULT, "null %{public}s", ((env == nullptr) ? "env" : "info")); return nullptr; } GET_NAPI_INFO_AND_CALL(env, info, JsCallerComplex, ReleaseCallInner); @@ -131,9 +127,7 @@ public: static napi_value JsSetOnReleaseCallBack(napi_env env, napi_callback_info info) { if (env == nullptr || info == nullptr) { - TAG_LOGE(AAFwkTag::DEFAULT, - "JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr", __func__, - ((env == nullptr) ? "env" : "info")); + TAG_LOGE(AAFwkTag::DEFAULT, "null %{public}s", ((env == nullptr) ? "env" : "info")); return nullptr; } GET_NAPI_INFO_AND_CALL(env, info, JsCallerComplex, SetOnReleaseCallBackInner); @@ -142,9 +136,7 @@ public: static napi_value JsSetOnRemoteStateChanged(napi_env env, napi_callback_info info) { if (env == nullptr || info == nullptr) { - TAG_LOGE(AAFwkTag::DEFAULT, - "JsCallerComplex::%{public}s is called, but input parameters %{public}s is nullptr", __func__, - ((env == nullptr) ? "env" : "info")); + TAG_LOGE(AAFwkTag::DEFAULT, "null %{public}s", ((env == nullptr) ? "env" : "info")); return nullptr; } GET_NAPI_INFO_AND_CALL(env, info, JsCallerComplex, SetOnRemoteStateChangedInner); @@ -153,39 +145,38 @@ public: static bool AddJsCallerComplex(JsCallerComplex* ptr) { if (ptr == nullptr) { - TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__); + TAG_LOGE(AAFwkTag::DEFAULT, "null ptr"); return false; } std::lock_guard lck (jsCallerComplexMutex); auto iter = jsCallerComplexManagerList.find(ptr); if (iter != jsCallerComplexManagerList.end()) { - TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, address exists", __func__); + TAG_LOGE(AAFwkTag::DEFAULT, "address exist"); return false; } auto iterRet = jsCallerComplexManagerList.emplace(ptr); - TAG_LOGD(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, execution ends and retval is %{public}s", __func__, - iterRet.second ? "true" : "false"); + TAG_LOGD(AAFwkTag::DEFAULT, "retval: %{public}s", iterRet.second ? "true" : "false"); return iterRet.second; } static bool RemoveJsCallerComplex(JsCallerComplex* ptr) { if (ptr == nullptr) { - TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters is nullptr", __func__); + TAG_LOGE(AAFwkTag::DEFAULT, "null ptr"); return false; } std::lock_guard lck (jsCallerComplexMutex); auto iter = jsCallerComplexManagerList.find(ptr); if (iter == jsCallerComplexManagerList.end()) { - TAG_LOGE(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, input parameters not found", __func__); + TAG_LOGE(AAFwkTag::DEFAULT, "input parameters not found"); return false; } jsCallerComplexManagerList.erase(ptr); - TAG_LOGD(AAFwkTag::DEFAULT, "JsAbilityContext::%{public}s, called", __func__); + TAG_LOGD(AAFwkTag::DEFAULT, "end"); return true; } diff --git a/frameworks/native/ability/native/ability_window.cpp b/frameworks/native/ability/native/ability_window.cpp index 99d04ea9d4..9031143302 100644 --- a/frameworks/native/ability/native/ability_window.cpp +++ b/frameworks/native/ability/native/ability_window.cpp @@ -34,7 +34,7 @@ AbilityWindow::~AbilityWindow() */ void AbilityWindow::Init(std::shared_ptr& handler, std::shared_ptr ability) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s come.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); handler_ = handler; ability_ = std::weak_ptr(ability); windowScene_ = std::make_shared(); @@ -43,7 +43,7 @@ void AbilityWindow::Init(std::shared_ptr& handler, std::shared_p bool AbilityWindow::InitWindow(std::shared_ptr &abilityContext, sptr &listener, int32_t displayId, sptr option, bool isPrivacy) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); if (windowScene_ == nullptr) { windowScene_ = std::make_shared(); } @@ -55,13 +55,13 @@ bool AbilityWindow::InitWindow(std::shared_ptr & ret = windowScene_->Init(displayId, abilityContext, listener, option); } if (ret != OHOS::Rosen::WMError::WM_OK) { - TAG_LOGE(AAFwkTag::ABILITY, "%{public}s error. failed to init window scene!", __func__); + TAG_LOGE(AAFwkTag::ABILITY, "init window scene failed"); return false; } auto window = windowScene_->GetMainWindow(); if (!window) { - TAG_LOGE(AAFwkTag::ABILITY, "%{public}s window is nullptr.", __func__); + TAG_LOGE(AAFwkTag::ABILITY, "null window"); return false; } @@ -70,7 +70,7 @@ bool AbilityWindow::InitWindow(std::shared_ptr & } isWindowAttached = true; - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "end"); return true; } @@ -82,18 +82,17 @@ void AbilityWindow::OnPostAbilityBackground(uint32_t sceneFlag) { TAG_LOGD(AAFwkTag::ABILITY, "called"); if (!isWindowAttached) { - TAG_LOGE(AAFwkTag::ABILITY, "AbilityWindow::OnPostAbilityBackground window not attached."); + TAG_LOGE(AAFwkTag::ABILITY, "window not attached"); return; } if (windowScene_) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin windowScene_->GoBackground, sceneFlag:%{public}d.", - __func__, sceneFlag); + TAG_LOGD(AAFwkTag::ABILITY, "sceneFlag:%{public}d", sceneFlag); windowScene_->GoBackground(sceneFlag); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end windowScene_->GoBackground.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "go back end"); } - TAG_LOGD(AAFwkTag::ABILITY, "AbilityWindow::OnPostAbilityBackground end."); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } /** @@ -104,18 +103,17 @@ void AbilityWindow::OnPostAbilityForeground(uint32_t sceneFlag) { TAG_LOGD(AAFwkTag::ABILITY, "called"); if (!isWindowAttached) { - TAG_LOGE(AAFwkTag::ABILITY, "AbilityWindow::OnPostAbilityForeground window not attached."); + TAG_LOGE(AAFwkTag::ABILITY, "window not attached"); return; } if (windowScene_) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin windowScene_->GoForeground, sceneFlag:%{public}d.", - __func__, sceneFlag); + TAG_LOGD(AAFwkTag::ABILITY, "sceneFlag:%{public}d", sceneFlag); windowScene_->GoForeground(sceneFlag); - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s end windowScene_->GoForeground.", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "go fore end"); } - TAG_LOGD(AAFwkTag::ABILITY, "AbilityWindow::OnPostAbilityForeground end."); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } /** @@ -126,7 +124,7 @@ void AbilityWindow::OnPostAbilityStop() { TAG_LOGD(AAFwkTag::ABILITY, "called"); if (!isWindowAttached) { - TAG_LOGE(AAFwkTag::ABILITY, "AbilityWindow::OnPostAbilityStop window not attached."); + TAG_LOGE(AAFwkTag::ABILITY, "window not attached"); return; } @@ -134,7 +132,7 @@ void AbilityWindow::OnPostAbilityStop() windowScene_->GoDestroy(); } isWindowAttached = false; - TAG_LOGD(AAFwkTag::ABILITY, "AbilityWindow::OnPostAbilityStop end."); + TAG_LOGD(AAFwkTag::ABILITY, "end"); } /** @@ -145,7 +143,7 @@ void AbilityWindow::OnPostAbilityStop() const sptr AbilityWindow::GetWindow() { if (!isWindowAttached) { - TAG_LOGE(AAFwkTag::ABILITY, "AbilityWindow::GetWindow window not attached."); + TAG_LOGE(AAFwkTag::ABILITY, "window not attached"); return nullptr; } return windowScene_ ? windowScene_->GetMainWindow() : nullptr; @@ -154,16 +152,16 @@ const sptr AbilityWindow::GetWindow() #ifdef SUPPORT_GRAPHICS ErrCode AbilityWindow::SetMissionLabel(const std::string &label) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s start", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); auto window = GetWindow(); if (!window) { - TAG_LOGE(AAFwkTag::ABILITY, "get window failed."); + TAG_LOGE(AAFwkTag::ABILITY, "get window failed"); return -1; } auto ret = window->SetAPPWindowLabel(label); if (ret != OHOS::Rosen::WMError::WM_OK) { - TAG_LOGE(AAFwkTag::ABILITY, "SetAPPWindowLabel failed, errCode:%{public}d.", ret); + TAG_LOGE(AAFwkTag::ABILITY, "errCode:%{public}d", ret); return -1; } @@ -172,7 +170,7 @@ ErrCode AbilityWindow::SetMissionLabel(const std::string &label) ErrCode AbilityWindow::SetMissionIcon(const std::shared_ptr &icon) { - TAG_LOGD(AAFwkTag::ABILITY, "%{public}s start", __func__); + TAG_LOGD(AAFwkTag::ABILITY, "called"); auto window = GetWindow(); if (!window) { TAG_LOGE(AAFwkTag::ABILITY, "get window failed, will not set mission icon."); diff --git a/frameworks/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.cpp b/frameworks/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.cpp index 63c866f427..972924e5ed 100644 --- a/frameworks/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.cpp +++ b/frameworks/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.cpp @@ -25,7 +25,7 @@ void AutoFillExtensionContext::SetAutoFillExtensionCallback( autoFillExtensionCallback_ = autoFillExtensionCallback; } -void AutoFillExtensionContext::SetSessionInfo(const wptr &sessionInfo) +void AutoFillExtensionContext::SetSessionInfo(const sptr &sessionInfo) { sessionInfo_ = sessionInfo; } @@ -33,8 +33,7 @@ void AutoFillExtensionContext::SetSessionInfo(const wptr &se int32_t AutoFillExtensionContext::ReloadInModal(const CustomData &customData) { TAG_LOGD(AAFwkTag::AUTOFILL_EXT, "called"); - auto sessionInfo = sessionInfo_.promote(); - if (sessionInfo == nullptr) { + if (sessionInfo_ == nullptr) { TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "Session info is nullptr."); return ERR_NULL_OBJECT; } @@ -43,7 +42,7 @@ int32_t AutoFillExtensionContext::ReloadInModal(const CustomData &customData) TAG_LOGE(AAFwkTag::AUTOFILL_EXT, "Auto fill extension callback is nullptr."); return ERR_NULL_OBJECT; } - return autoFillExtensionCallback->OnReloadInModal(sessionInfo, customData); + return autoFillExtensionCallback->OnReloadInModal(sessionInfo_, customData); } } // namespace AbilityRuntime } // namespace OHOS diff --git a/frameworks/native/ability/native/auto_fill_extension_ability/js_auto_fill_extension.cpp b/frameworks/native/ability/native/auto_fill_extension_ability/js_auto_fill_extension.cpp index f35f42e673..6983127743 100644 --- a/frameworks/native/ability/native/auto_fill_extension_ability/js_auto_fill_extension.cpp +++ b/frameworks/native/ability/native/auto_fill_extension_ability/js_auto_fill_extension.cpp @@ -508,6 +508,7 @@ bool JsAutoFillExtension::HandleAutoFillCreate(const AAFwk::Want &want, const sp obj, std::shared_ptr(reinterpret_cast(ref))); CallJsOnRequest(want, sessionInfo, uiWindow); uiWindowMap_[obj] = uiWindow; + context->SetSessionInfo(sessionInfo); } return true; } @@ -525,7 +526,6 @@ void JsAutoFillExtension::ForegroundWindow(const AAFwk::Want &want, const sptrSetSessionInfo(sessionInfo); if (want.HasParameter(WANT_PARAMS_AUTO_FILL_POPUP_WINDOW_KEY)) { isPopup_ = want.GetBoolParam(WANT_PARAMS_AUTO_FILL_POPUP_WINDOW_KEY, false); diff --git a/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp b/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp index b848b7dd4c..431cd6517e 100644 --- a/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp +++ b/frameworks/native/ability/native/child_process_manager/child_process_manager.cpp @@ -326,6 +326,11 @@ std::unique_ptr ChildProcessManager::CreateRuntime(cons options.loadAce = true; options.jitEnabled = jitEnabled; + for (auto moduleItem : bundleInfo.hapModuleInfos) { + options.pkgContextInfoJsonStringMap[moduleItem.moduleName] = moduleItem.hapPath; + options.packageNameList[moduleItem.moduleName] = moduleItem.packageName; + } + std::shared_ptr eventRunner = fromAppSpawn ? AppExecFwk::EventRunner::GetMainEventRunner() : AppExecFwk::EventRunner::Create(); options.eventRunner = eventRunner; diff --git a/frameworks/native/ability/native/data_ability_impl.cpp b/frameworks/native/ability/native/data_ability_impl.cpp index e0f0c0967f..f78e4d8aed 100644 --- a/frameworks/native/ability/native/data_ability_impl.cpp +++ b/frameworks/native/ability/native/data_ability_impl.cpp @@ -454,7 +454,7 @@ bool DataAbilityImpl::CheckReadAndWritePermission(const std::string &permissionT { std::string permission = GetPermissionInfo(permissionType); if (permission.empty()) { - TAG_LOGD(AAFwkTag::DATA_ABILITY, "%{public}s, permission is empty", __func__); + TAG_LOGD(AAFwkTag::DATA_ABILITY, "empty permission"); return true; } @@ -462,8 +462,7 @@ bool DataAbilityImpl::CheckReadAndWritePermission(const std::string &permissionT int checkReadPermission = AccessTokenKit::VerifyAccessToken(tokenId, permission); if (checkReadPermission != ERR_OK) { std::shared_ptr abilityInfo = ability_->GetAbilityInfo(); - TAG_LOGD(AAFwkTag::DATA_ABILITY, "%{public}s do not have permission, bundleName: %{public}s", - __func__, abilityInfo->bundleName.c_str()); + TAG_LOGD(AAFwkTag::DATA_ABILITY, "no permission, bundleName: %{public}s", abilityInfo->bundleName.c_str()); return false; } @@ -472,10 +471,10 @@ bool DataAbilityImpl::CheckReadAndWritePermission(const std::string &permissionT std::string DataAbilityImpl::GetPermissionInfo(const std::string &permissionType) const { - TAG_LOGD(AAFwkTag::DATA_ABILITY, "%{public}s begin, permissionType:%{public}s", __func__, permissionType.c_str()); + TAG_LOGD(AAFwkTag::DATA_ABILITY, "permissionType:%{public}s", permissionType.c_str()); std::shared_ptr abilityInfo = ability_->GetAbilityInfo(); if (abilityInfo == nullptr) { - TAG_LOGW(AAFwkTag::DATA_ABILITY, "%{public}s abilityInfo is nullptr", __func__); + TAG_LOGW(AAFwkTag::DATA_ABILITY, "null abilityInfo"); return ""; } if (permissionType == READ) { @@ -483,8 +482,7 @@ std::string DataAbilityImpl::GetPermissionInfo(const std::string &permissionType } else if (permissionType == WRITE) { return abilityInfo->writePermission; } else { - TAG_LOGI(AAFwkTag::DATA_ABILITY, "%{public}s permissionType is not read or write, permissionType:%{public}s", - __func__, permissionType.c_str()); + TAG_LOGI(AAFwkTag::DATA_ABILITY, "invalid permissionType:%{public}s", permissionType.c_str()); return ""; } } diff --git a/frameworks/native/ability/native/extension_impl.cpp b/frameworks/native/ability/native/extension_impl.cpp index f37da6389c..148519befb 100644 --- a/frameworks/native/ability/native/extension_impl.cpp +++ b/frameworks/native/ability/native/extension_impl.cpp @@ -256,7 +256,7 @@ void ExtensionImpl::Stop(bool &isAsyncCallback, const Want &want, sptr::Destroy(callbackInfo); } // else: callbackInfo will be destroyed after the async callback - TAG_LOGD(AAFwkTag::EXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::EXT, "end"); } void ExtensionImpl::AbilityTransactionCallback(const AAFwk::AbilityLifeCycleState &state) @@ -303,7 +303,7 @@ sptr ExtensionImpl::ConnectExtension(const Want &want, bool &isAs sptr object = extension_->OnConnect(want); lifecycleState_ = AAFwk::ABILITY_STATE_ACTIVE; isAsyncCallback = false; - TAG_LOGI(AAFwkTag::EXT, "%{public}s end.", __func__); + TAG_LOGI(AAFwkTag::EXT, "end"); return object; } @@ -333,7 +333,7 @@ void ExtensionImpl::ConnectExtensionCallback(sptr &service) { ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->ScheduleConnectAbilityDone(token_, service); if (err != ERR_OK) { - TAG_LOGE(AAFwkTag::EXT, "AbilityThread::HandleConnectExtension failed err = %{public}d", err); + TAG_LOGE(AAFwkTag::EXT, "failed err = %{public}d", err); } } @@ -346,7 +346,7 @@ void ExtensionImpl::DisconnectExtension(const Want &want) { TAG_LOGD(AAFwkTag::EXT, "call"); if (extension_ == nullptr) { - TAG_LOGE(AAFwkTag::EXT, "ExtensionImpl::DisconnectAbility extension_ is nullptr"); + TAG_LOGE(AAFwkTag::EXT, "extension_ is nullptr"); return; } @@ -356,7 +356,7 @@ void ExtensionImpl::DisconnectExtension(const Want &want) void ExtensionImpl::DisconnectExtension(const Want &want, bool &isAsyncCallback) { - TAG_LOGD(AAFwkTag::EXT, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::EXT, "called"); if (extension_ == nullptr) { TAG_LOGE(AAFwkTag::EXT, "Failed to disconnect, extension_ is nullptr"); isAsyncCallback = false; @@ -385,14 +385,14 @@ void ExtensionImpl::DisconnectExtension(const Want &want, bool &isAsyncCallback) AppExecFwk::AbilityTransactionCallbackInfo<>::Destroy(callbackInfo); } // else: callbackInfo will be destroyed after the async callback - TAG_LOGD(AAFwkTag::EXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::EXT, "end"); } void ExtensionImpl::DisconnectExtensionCallback() { ErrCode err = AAFwk::AbilityManagerClient::GetInstance()->ScheduleDisconnectAbilityDone(token_); if (err != ERR_OK) { - TAG_LOGE(AAFwkTag::EXT, "ExtensionImpl::DisconnectExtensionCallback failed err = %{public}d", err); + TAG_LOGE(AAFwkTag::EXT, "failed err = %{public}d", err); } } diff --git a/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp b/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp index b5a21021da..e26e8a5158 100644 --- a/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp +++ b/frameworks/native/ability/native/form_runtime/js_form_extension_context.cpp @@ -105,7 +105,7 @@ private: { TAG_LOGI(AAFwkTag::FORM_EXT, "called"); if (info.argc < UPDATE_FORM_PARAMS_SIZE) { - TAG_LOGE(AAFwkTag::FORM_EXT, "Not enough params, not enough params"); + TAG_LOGE(AAFwkTag::FORM_EXT, "invalid argc"); return CreateJsUndefined(env); } @@ -257,7 +257,7 @@ private: return CreateJsUndefined(env); } if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::FORM_EXT, "Disconnect ability failed, not enough parameters."); + TAG_LOGE(AAFwkTag::FORM_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } diff --git a/frameworks/native/ability/native/insight_intent_host_client.cpp b/frameworks/native/ability/native/insight_intent_host_client.cpp index da5fb081a5..c60f4e2482 100644 --- a/frameworks/native/ability/native/insight_intent_host_client.cpp +++ b/frameworks/native/ability/native/insight_intent_host_client.cpp @@ -25,6 +25,9 @@ sptr InsightIntentHostClient::GetInstance() { std::call_once(singletonFlag_, []() { instance_ = new (std::nothrow) InsightIntentHostClient(); + if (instance_ == nullptr) { + TAG_LOGE(AAFwkTag::INTENT, "failed to create InsightIntentHostClient."); + } }); return instance_; } diff --git a/frameworks/native/ability/native/js_service_extension.cpp b/frameworks/native/ability/native/js_service_extension.cpp index 2906798f62..18ac8d0301 100644 --- a/frameworks/native/ability/native/js_service_extension.cpp +++ b/frameworks/native/ability/native/js_service_extension.cpp @@ -404,9 +404,9 @@ void JsServiceExtension::OnDisconnect(const AAFwk::Want &want) HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); HandleScope handleScope(jsRuntime_); Extension::OnDisconnect(want); - TAG_LOGD(AAFwkTag::SERVICE_EXT, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "called"); CallOnDisconnect(want, false); - TAG_LOGD(AAFwkTag::SERVICE_EXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "end"); } void JsServiceExtension::OnDisconnect(const AAFwk::Want &want, @@ -415,7 +415,7 @@ void JsServiceExtension::OnDisconnect(const AAFwk::Want &want, HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); HandleScope handleScope(jsRuntime_); Extension::OnDisconnect(want); - TAG_LOGD(AAFwkTag::SERVICE_EXT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "called"); napi_value result = CallOnDisconnect(want, true); bool isPromise = CheckPromise(result); if (!isPromise) { @@ -430,7 +430,7 @@ void JsServiceExtension::OnDisconnect(const AAFwk::Want &want, isAsyncCallback = true; } - TAG_LOGD(AAFwkTag::SERVICE_EXT, "%{public}s end.", __func__); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "end"); } void JsServiceExtension::OnCommand(const AAFwk::Want &want, bool restart, int startId) @@ -474,7 +474,7 @@ bool JsServiceExtension::HandleInsightIntent(const AAFwk::Want &want) executeParam->insightIntentName_.c_str(), executeParam->executeMode_, executeParam->insightIntentId_); auto asyncCallback = [weak = weak_from_this(), intentId = executeParam->insightIntentId_] (AppExecFwk::InsightIntentExecuteResult result) { - TAG_LOGD(AAFwkTag::SERVICE_EXT, "Execute insight intent finshed, intentId %{public}" PRIu64"", intentId); + TAG_LOGD(AAFwkTag::SERVICE_EXT, "intentId %{public}" PRIu64"", intentId); auto extension = weak.lock(); if (extension == nullptr) { TAG_LOGE(AAFwkTag::SERVICE_EXT, "extension is nullptr."); @@ -539,7 +539,7 @@ bool JsServiceExtension::OnInsightIntentExecuteDone(uint64_t intentId, } auto ret = AAFwk::AbilityManagerClient::GetInstance()->ExecuteInsightIntentDone(token, intentId, result); if (ret != ERR_OK) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Notify execute done faild."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "Notify execute done failed"); return false; } return true; diff --git a/frameworks/native/ability/native/js_service_extension_context.cpp b/frameworks/native/ability/native/js_service_extension_context.cpp index 02feef8365..70b1ba9135 100644 --- a/frameworks/native/ability/native/js_service_extension_context.cpp +++ b/frameworks/native/ability/native/js_service_extension_context.cpp @@ -228,7 +228,7 @@ private: HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::SERVICE_EXT, "StartAbility"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start ability failed, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -371,7 +371,7 @@ private: HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbilityAsCaller"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start ability as caller failed, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -436,7 +436,7 @@ private: { TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbilityByCall"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start ability by call failed, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -587,7 +587,7 @@ private: { TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartAbilityWithAccount"); if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start ability with account failed, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -684,7 +684,7 @@ private: TAG_LOGD(AAFwkTag::SERVICE_EXT, "called"); // Check params count if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Connect ability error, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -728,7 +728,7 @@ private: TAG_LOGI(AAFwkTag::SERVICE_EXT, "ConnectAbilityWithAccount"); // Check params count if (info.argc < ARGC_THREE) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Connect ability failed, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -801,7 +801,7 @@ private: { TAG_LOGD(AAFwkTag::SERVICE_EXT, "DisconnectAbility start"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Disconnect ability error, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -871,7 +871,7 @@ private: { TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartExtensionAbility"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::SERVICE_EXT, "Start extension failed, not enough params."); + TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -908,7 +908,7 @@ private: { TAG_LOGI(AAFwkTag::SERVICE_EXT, "OnStartUIServiceExtension is enter"); if (info.argc GetFilesDir(); - TAG_LOGD(AAFwkTag::RECOVERY, "AppRecovery GetSaveAppCachePath fileDir %{public}s.", fileDir.c_str()); + TAG_LOGD(AAFwkTag::RECOVERY, "fileDir %{public}s", fileDir.c_str()); if (fileDir.empty() || !OHOS::FileExists(fileDir)) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecovery GetSaveAppCachePath fileDir is empty or fileDir is not exists."); + TAG_LOGE(AAFwkTag::RECOVERY, "empty fileDir or fileDir not exist"); return ""; } diff --git a/frameworks/native/ability/native/recovery/app_recovery.cpp b/frameworks/native/ability/native/recovery/app_recovery.cpp index fedfc00bc2..7472b1482c 100644 --- a/frameworks/native/ability/native/recovery/app_recovery.cpp +++ b/frameworks/native/ability/native/recovery/app_recovery.cpp @@ -415,17 +415,16 @@ void AppRecovery::DeleteInValidMissionFiles() } std::string fileDir = context->GetFilesDir(); - TAG_LOGI(AAFwkTag::RECOVERY, "AppRecovery DeleteInValidMissionFiles fileDir: %{public}s", fileDir.c_str()); + TAG_LOGI(AAFwkTag::RECOVERY, "fileDir: %{public}s", fileDir.c_str()); if (fileDir.empty() || !OHOS::FileExists(fileDir)) { - TAG_LOGD(AAFwkTag::RECOVERY, - "AppRecovery DeleteInValidMissionFiles fileDir is empty or fileDir is not exists."); + TAG_LOGD(AAFwkTag::RECOVERY, "empty fileDir or fileDir not exist"); return; } std::vector missionIds; std::vector results; if (!GetMissionIds(fileDir, missionIds)) { - TAG_LOGE(AAFwkTag::RECOVERY, "AppRecovery get mssion file id error."); + TAG_LOGE(AAFwkTag::RECOVERY, "get mission id failed"); return; } if (missionIds.empty()) { diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 86a95b1a03..804a2274e2 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -45,7 +45,9 @@ constexpr char LAUNCHER_ABILITY_NAME[] = "com.ohos.launcher.MainAbility"; constexpr char SHOW_ON_LOCK_SCREEN[] = "ShowOnLockScreen"; #endif +#ifdef WITH_DLP constexpr char DLP_PARAMS_SECURITY_FLAG[] = "ohos.dlp.params.securityFlag"; +#endif // WITH_DLP constexpr char COMPONENT_STARTUP_NEW_RULES[] = "component.startup.newRules"; #ifdef SUPPORT_SCREEN constexpr int32_t ERR_INVALID_VALUE = -1; @@ -167,8 +169,10 @@ void UIAbility::OnStart(const AAFwk::Want &want, sptr sessio return; } +#ifdef WITH_DLP securityFlag_ = want.GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false); (const_cast(want)).RemoveParam(DLP_PARAMS_SECURITY_FLAG); +#endif // WITH_DLP SetWant(want); TAG_LOGD(AAFwkTag::UIABILITY, "Begin ability is %{public}s.", abilityInfo_->name.c_str()); #ifdef SUPPORT_SCREEN diff --git a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp index e4927b9569..25a0b51dee 100755 --- a/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp +++ b/frameworks/native/ability/native/ui_extension_ability/js_ui_extension_context.cpp @@ -189,7 +189,7 @@ napi_value JsUIExtensionContext::OnStartAbility(napi_env env, NapiCallbackInfo& HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::UI_EXT, "called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UI_EXT, "Start ability failed, not enough params"); + TAG_LOGE(AAFwkTag::UI_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -539,7 +539,7 @@ napi_value JsUIExtensionContext::OnConnectAbility(napi_env env, NapiCallbackInfo TAG_LOGD(AAFwkTag::UI_EXT, "called"); // Check params count if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::UI_EXT, "Connect ability failed, not enough params"); + TAG_LOGE(AAFwkTag::UI_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -581,7 +581,7 @@ napi_value JsUIExtensionContext::OnDisconnectAbility(napi_env env, NapiCallbackI { TAG_LOGD(AAFwkTag::UI_EXT, "start"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UI_EXT, "Disconnect ability error, not enough params"); + TAG_LOGE(AAFwkTag::UI_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -631,7 +631,7 @@ napi_value JsUIExtensionContext::OnStartUIServiceExtension(napi_env env, NapiCal HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGD(AAFwkTag::UI_EXT, "OnStartUIServiceExtension is called"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UI_EXT, "Start UIServiceExtension failed, not enough params."); + TAG_LOGE(AAFwkTag::UI_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } @@ -673,7 +673,7 @@ napi_value JsUIExtensionContext::OnStartUIServiceExtension(napi_env env, NapiCal bool JsUIExtensionContext::UnwrapConnectUIServiceExtensionParam(napi_env env, NapiCallbackInfo& info, AAFwk::Want& want) { if (info.argc < ARGC_TWO) { - TAG_LOGE(AAFwkTag::UISERVC_EXT, "failed, not enough params."); + TAG_LOGE(AAFwkTag::UISERVC_EXT, "invalid argc"); ThrowTooFewParametersError(env); return false; } @@ -789,7 +789,7 @@ void JsUIExtensionContext::DoConnectUIServiceExtension(napi_env env, napi_value JsUIExtensionContext::OnDisconnectUIServiceExtension(napi_env env, NapiCallbackInfo& info) { if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UISERVC_EXT, "failed, not enough params."); + TAG_LOGE(AAFwkTag::UISERVC_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } diff --git a/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_host_proxy.cpp b/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_host_proxy.cpp index 78258b96bb..f9004a08b2 100644 --- a/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_host_proxy.cpp +++ b/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_host_proxy.cpp @@ -104,7 +104,7 @@ napi_value JsUIServiceHostProxy::OnSendData(napi_env env, NapiCallbackInfo& info return CreateJsUndefined(env); } if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UISERVC_EXT, "failed, not enough params."); + TAG_LOGE(AAFwkTag::UISERVC_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } diff --git a/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_proxy.cpp b/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_proxy.cpp index 633f81e73d..6aa97203bd 100644 --- a/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_proxy.cpp +++ b/frameworks/native/ability/native/ui_service_extension_ability/connection/js_ui_service_proxy.cpp @@ -82,7 +82,7 @@ napi_value JsUIServiceProxy::OnSendData(napi_env env, NapiCallbackInfo& info) return CreateJsUndefined(env); } if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UISERVC_EXT, "failed, not enough params."); + TAG_LOGE(AAFwkTag::UISERVC_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } diff --git a/frameworks/native/ability/native/ui_service_extension_ability/js_ui_service_extension_context.cpp b/frameworks/native/ability/native/ui_service_extension_ability/js_ui_service_extension_context.cpp index 63ae5a8bc0..5c43a9d7f6 100644 --- a/frameworks/native/ability/native/ui_service_extension_ability/js_ui_service_extension_context.cpp +++ b/frameworks/native/ability/native/ui_service_extension_ability/js_ui_service_extension_context.cpp @@ -82,7 +82,7 @@ private: HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGI(AAFwkTag::UISERVC_EXT, "Call"); if (info.argc < ARGC_ONE) { - TAG_LOGE(AAFwkTag::UISERVC_EXT, "Start ability failed, not enough params."); + TAG_LOGE(AAFwkTag::UISERVC_EXT, "invalid argc"); ThrowTooFewParametersError(env); return CreateJsUndefined(env); } diff --git a/frameworks/native/appkit/BUILD.gn b/frameworks/native/appkit/BUILD.gn index 0dd3de6410..7e97334fa9 100644 --- a/frameworks/native/appkit/BUILD.gn +++ b/frameworks/native/appkit/BUILD.gn @@ -296,7 +296,6 @@ ohos_shared_library("app_context") { external_deps = [ "ability_base:extractortool", - "ability_base:session_info", "bundle_framework:appexecfwk_core", "c_utils:utils", "common_event_service:cesfwk_innerkits", @@ -311,6 +310,7 @@ ohos_shared_library("app_context") { ] public_external_deps = [ "ability_base:configuration", + "ability_base:session_info", "ability_base:want", "bundle_framework:appexecfwk_base", ] diff --git a/frameworks/native/appkit/ability_delegator/ability_delegator.cpp b/frameworks/native/appkit/ability_delegator/ability_delegator.cpp index ac7c433e22..327fcb511c 100644 --- a/frameworks/native/appkit/ability_delegator/ability_delegator.cpp +++ b/frameworks/native/appkit/ability_delegator/ability_delegator.cpp @@ -665,7 +665,7 @@ std::shared_ptr AbilityDelegator::FindPropertyByToken } if (token == it->token_) { - TAG_LOGI(AAFwkTag::DELEGATOR, "Property exists"); + TAG_LOGI(AAFwkTag::DELEGATOR, "Property exist"); return it; } } @@ -689,7 +689,7 @@ std::shared_ptr AbilityDelegator::FindPropertyByName( } if (name == it->fullName_) { - TAG_LOGI(AAFwkTag::DELEGATOR, "Property exists"); + TAG_LOGI(AAFwkTag::DELEGATOR, "Property exist"); return it; } } diff --git a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp index 54a6730bf8..5c78490e2d 100644 --- a/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp +++ b/frameworks/native/appkit/ability_runtime/app/js_ability_stage.cpp @@ -676,7 +676,7 @@ std::string JsAbilityStage::GetHapModuleProp(const std::string &propName) const bool JsAbilityStage::IsFileExisted(const std::string &filePath) { if (filePath.empty()) { - TAG_LOGE(AAFwkTag::APPKIT, "the file is not existed due to empty file path."); + TAG_LOGE(AAFwkTag::APPKIT, "the file is not exist due to empty file path."); return false; } @@ -690,7 +690,7 @@ bool JsAbilityStage::IsFileExisted(const std::string &filePath) bool JsAbilityStage::TransformFileToJsonString(const std::string &resPath, std::string &profile) { if (!IsFileExisted(resPath)) { - TAG_LOGE(AAFwkTag::APPKIT, "the file is not existed."); + TAG_LOGE(AAFwkTag::APPKIT, "the file is not exist"); return false; } std::fstream in; diff --git a/frameworks/native/appkit/ability_runtime/context/application_context.cpp b/frameworks/native/appkit/ability_runtime/context/application_context.cpp index cb10a3767f..e63adc1d78 100644 --- a/frameworks/native/appkit/ability_runtime/context/application_context.cpp +++ b/frameworks/native/appkit/ability_runtime/context/application_context.cpp @@ -49,7 +49,7 @@ void ApplicationContext::AttachContextImpl(const std::shared_ptr &c void ApplicationContext::RegisterAbilityLifecycleCallback( const std::shared_ptr &abilityLifecycleCallback) { - TAG_LOGD(AAFwkTag::APPKIT, "ApplicationContext RegisterAbilityLifecycleCallback"); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (abilityLifecycleCallback == nullptr) { return; } @@ -60,7 +60,7 @@ void ApplicationContext::RegisterAbilityLifecycleCallback( void ApplicationContext::UnregisterAbilityLifecycleCallback( const std::shared_ptr &abilityLifecycleCallback) { - TAG_LOGD(AAFwkTag::APPKIT, "ApplicationContext UnregisterAbilityLifecycleCallback"); + TAG_LOGD(AAFwkTag::APPKIT, "called"); std::lock_guard lock(callbackLock_); auto it = std::find(callbacks_.begin(), callbacks_.end(), abilityLifecycleCallback); if (it != callbacks_.end()) { @@ -77,7 +77,7 @@ bool ApplicationContext::IsAbilityLifecycleCallbackEmpty() void ApplicationContext::RegisterEnvironmentCallback( const std::shared_ptr &environmentCallback) { - TAG_LOGD(AAFwkTag::APPKIT, "ApplicationContext RegisterEnvironmentCallback"); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (environmentCallback == nullptr) { return; } @@ -88,7 +88,7 @@ void ApplicationContext::RegisterEnvironmentCallback( void ApplicationContext::UnregisterEnvironmentCallback( const std::shared_ptr &environmentCallback) { - TAG_LOGD(AAFwkTag::APPKIT, "ApplicationContext UnregisterEnvironmentCallback"); + TAG_LOGD(AAFwkTag::APPKIT, "called"); std::lock_guard lock(envCallbacksLock_); auto it = std::find(envCallbacks_.begin(), envCallbacks_.end(), environmentCallback); if (it != envCallbacks_.end()) { @@ -150,7 +150,7 @@ void ApplicationContext::DispatchOnWindowStageDestroy(const std::shared_ptr &ability, const std::shared_ptr &windowStage) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability || !windowStage) { TAG_LOGE(AAFwkTag::APPKIT, "ability or windowStage is null"); return; @@ -166,7 +166,7 @@ void ApplicationContext::DispatchWindowStageFocus(const std::shared_ptr &ability, const std::shared_ptr &windowStage) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s begin.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability || !windowStage) { TAG_LOGE(AAFwkTag::APPKIT, "ability or windowStage is nullptr"); return; @@ -303,7 +303,7 @@ void ApplicationContext::DispatchOnAbilityWillSaveState(const std::shared_ptr &ability) { - TAG_LOGD(AAFwkTag::APPKIT, "Dispatch onAbilitySaveState."); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (ability == nullptr) { TAG_LOGE(AAFwkTag::APPKIT, "Parameters invalid, ability is nullptr."); return; @@ -389,7 +389,7 @@ void ApplicationContext::DispatchOnNewWant(const std::shared_ptr &ability) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability) { TAG_LOGE(AAFwkTag::APPKIT, "ability is null"); return; @@ -405,7 +405,7 @@ void ApplicationContext::DispatchOnAbilityWillCreate(const std::shared_ptr &ability, const std::shared_ptr &windowStage) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability || !windowStage) { TAG_LOGE(AAFwkTag::APPKIT, "ability or windowStage is null"); return; @@ -421,7 +421,7 @@ void ApplicationContext::DispatchOnWindowStageWillCreate(const std::shared_ptr &ability, const std::shared_ptr &windowStage) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability || !windowStage) { TAG_LOGE(AAFwkTag::APPKIT, "ability or windowStage is null"); return; @@ -436,7 +436,7 @@ void ApplicationContext::DispatchOnWindowStageWillDestroy(const std::shared_ptr< void ApplicationContext::DispatchOnAbilityWillDestroy(const std::shared_ptr &ability) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability) { TAG_LOGE(AAFwkTag::APPKIT, "ability is null"); return; @@ -451,7 +451,7 @@ void ApplicationContext::DispatchOnAbilityWillDestroy(const std::shared_ptr &ability) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability) { TAG_LOGE(AAFwkTag::APPKIT, "ability is null"); return; @@ -466,7 +466,7 @@ void ApplicationContext::DispatchOnAbilityWillForeground(const std::shared_ptr &ability) { - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__); + TAG_LOGD(AAFwkTag::APPKIT, "called"); if (!ability) { TAG_LOGE(AAFwkTag::APPKIT, "ability is null"); return; diff --git a/frameworks/native/appkit/ability_runtime/context/context_impl.cpp b/frameworks/native/appkit/ability_runtime/context/context_impl.cpp index eda497be8f..4036e5dfe4 100644 --- a/frameworks/native/appkit/ability_runtime/context/context_impl.cpp +++ b/frameworks/native/appkit/ability_runtime/context/context_impl.cpp @@ -291,7 +291,7 @@ void ContextImpl::GetAllTempDir(std::vector &tempPaths) for (const auto &moudleItem: applicationInfo_->moduleInfos) { auto moudleTemp = baseDir + CONTEXT_HAPS + CONTEXT_FILE_SEPARATOR + moudleItem.moduleName + CONTEXT_TEMP; if (!OHOS::FileExists(moudleTemp)) { - TAG_LOGW(AAFwkTag::APPKIT, "moudle[%{public}s] temp path not exists,path is %{public}s", + TAG_LOGW(AAFwkTag::APPKIT, "moudle[%{public}s] temp path not exist,path: %{public}s", moudleItem.moduleName.c_str(), moudleTemp.c_str()); continue; } diff --git a/frameworks/native/appkit/app/ability_record_mgr.cpp b/frameworks/native/appkit/app/ability_record_mgr.cpp index 99c2375089..805f37ba96 100644 --- a/frameworks/native/appkit/app/ability_record_mgr.cpp +++ b/frameworks/native/appkit/app/ability_record_mgr.cpp @@ -64,7 +64,7 @@ void AbilityRecordMgr::SetEventRunner(const std::shared_ptr &eventR if (abilityInstance != nullptr) { abilityInstance->SetEventRunner(eventRunner); } else { - TAG_LOGW(AAFwkTag::APPKIT, "ability record is not exists"); + TAG_LOGW(AAFwkTag::APPKIT, "ability record not exist"); } } diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index 69054ad031..2bdd41f6da 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -1862,7 +1862,7 @@ void MainThread::CalcNativeLiabraryEntries(const BundleInfo &bundleInfo, std::st TAG_LOGD(AAFwkTag::APPKIT, "native library path = %{public}s", libPath.c_str()); if (!ScanDir(libPath, nativeFileEntries_)) { - TAG_LOGW(AAFwkTag::APPKIT, "%{public}s scanDir %{public}s not exits", __func__, libPath.c_str()); + TAG_LOGW(AAFwkTag::APPKIT, "scanDir %{public}s not exits", libPath.c_str()); } } @@ -1887,21 +1887,21 @@ void MainThread::LoadNativeLiabrary(const BundleInfo &bundleInfo, std::string &n handleAbilityLib = dlopen(fileEntry.c_str(), RTLD_NOW | RTLD_GLOBAL); if (handleAbilityLib == nullptr) { if (fileEntry.find("libformrender.z.so") == std::string::npos) { - TAG_LOGE(AAFwkTag::APPKIT, "%{public}s Fail to dlopen %{public}s, [%{public}s]", - __func__, fileEntry.c_str(), dlerror()); + TAG_LOGE(AAFwkTag::APPKIT, "fail to dlopen %{public}s, [%{public}s]", + fileEntry.c_str(), dlerror()); exit(-1); } else { TAG_LOGD(AAFwkTag::APPKIT, "Load libformrender.z.so from native lib path."); handleAbilityLib = dlopen(FORM_RENDER_LIB_PATH, RTLD_NOW | RTLD_GLOBAL); if (handleAbilityLib == nullptr) { - TAG_LOGE(AAFwkTag::APPKIT, "%{public}s Fail to dlopen %{public}s, [%{public}s]", - __func__, FORM_RENDER_LIB_PATH, dlerror()); + TAG_LOGE(AAFwkTag::APPKIT, "fail to dlopen %{public}s, [%{public}s]", + FORM_RENDER_LIB_PATH, dlerror()); exit(-1); } fileEntry = FORM_RENDER_LIB_PATH; } } - TAG_LOGD(AAFwkTag::APPKIT, "%{public}s Success to dlopen %{public}s", __func__, fileEntry.c_str()); + TAG_LOGD(AAFwkTag::APPKIT, "success to dlopen %{public}s", fileEntry.c_str()); handleAbilityLib_.emplace_back(handleAbilityLib); } } @@ -2064,7 +2064,7 @@ bool MainThread::PrepareAbilityDelegator(const std::shared_ptr & void MainThread::HandleLaunchAbility(const std::shared_ptr &abilityRecord) { TAG_LOGD(AAFwkTag::APPKIT, "called"); - CHECK_POINTER_LOG(abilityRecord, "MainThread::HandleLaunchAbility parameter(abilityRecord) is null"); + CHECK_POINTER_LOG(abilityRecord, "parameter(abilityRecord) is null"); std::string connector = "##"; std::string traceName = __PRETTY_FUNCTION__ + connector; if (abilityRecord->GetWant() != nullptr) { @@ -2073,11 +2073,11 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr & TAG_LOGE(AAFwkTag::APPKIT, "Want is nullptr, cant not get abilityName."); } HITRACE_METER_NAME(HITRACE_TAG_APP, traceName); - CHECK_POINTER_LOG(applicationImpl_, "MainThread::HandleLaunchAbility applicationImpl_ is null"); - CHECK_POINTER_LOG(abilityRecordMgr_, "MainThread::HandleLaunchAbility abilityRecordMgr_ is null"); + CHECK_POINTER_LOG(applicationImpl_, "applicationImpl_ is null"); + CHECK_POINTER_LOG(abilityRecordMgr_, "abilityRecordMgr_ is null"); auto abilityToken = abilityRecord->GetToken(); - CHECK_POINTER_LOG(abilityToken, "MainThread::HandleLaunchAbility failed. abilityRecord->GetToken failed"); + CHECK_POINTER_LOG(abilityToken, "abilityRecord->GetToken failed"); FreezeUtil::LifecycleFlow flow = { abilityToken, FreezeUtil::TimeoutState::LOAD }; std::string entry = std::to_string(AbilityRuntime::TimeUtil::SystemTimeMillisecond()) + "; MainThread::HandleLaunchAbility; the load lifecycle."; diff --git a/frameworks/native/appkit/app/ohos_application.cpp b/frameworks/native/appkit/app/ohos_application.cpp index fc8a969b40..930e0d10de 100644 --- a/frameworks/native/appkit/app/ohos_application.cpp +++ b/frameworks/native/appkit/app/ohos_application.cpp @@ -446,7 +446,6 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config) std::string language = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_LANGUAGE); std::string colorMode = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_COLORMODE); std::string fontSizeScal = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_SIZE_SCALE); - std::string fontWeightScale = config.GetItem(AAFwk::GlobalConfigurationKey::SYSTEM_FONT_WEIGHT_SCALE); std::string languageIsSetByApp = config.GetItem(AAFwk::GlobalConfigurationKey::LANGUAGE_IS_SET_BY_APP); std::string colorModeIsSetByApp = @@ -484,7 +483,7 @@ void OHOSApplication::OnConfigurationUpdated(Configuration config) return; } } - if (!fontSizeScal.empty() || !fontWeightScale.empty()) { + if (!fontSizeScal.empty()) { if (!globalFontFollowSysteme.empty() && globalFontFollowSysteme.compare(ConfigurationInner::IS_APP_FONT_FOLLOW_SYSTEM) != 0) { TAG_LOGW(AAFwkTag::APPKIT, "the font configured for the app does not take effect with the system"); @@ -799,7 +798,7 @@ bool OHOSApplication::AddAbilityStage(const AppExecFwk::HapModuleInfo &hapModule } if (abilityStages_.find(hapModuleInfo.moduleName) != abilityStages_.end()) { - TAG_LOGE(AAFwkTag::APPKIT, "object already exists "); + TAG_LOGE(AAFwkTag::APPKIT, "object exist"); return false; } diff --git a/frameworks/native/runtime/js_quickfix_callback.cpp b/frameworks/native/runtime/js_quickfix_callback.cpp index 097e0d83aa..03789fb074 100644 --- a/frameworks/native/runtime/js_quickfix_callback.cpp +++ b/frameworks/native/runtime/js_quickfix_callback.cpp @@ -15,6 +15,7 @@ #include "js_quickfix_callback.h" +#include "file_mapper.h" #include "file_path_utils.h" #include "hilog_tag_wrapper.h" #include "js_runtime.h" @@ -27,7 +28,7 @@ namespace { } bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patchFileName, - void **patchBuffer, size_t &patchSize) + uint8_t **patchBuffer, size_t &patchSize) { TAG_LOGD(AAFwkTag::JSRUNTIME, "baseFileName: %{private}s", baseFileName.c_str()); auto position = baseFileName.find(".abc"); @@ -56,13 +57,18 @@ bool JsQuickfixCallback::operator()(std::string baseFileName, std::string &patch TAG_LOGD(AAFwkTag::JSRUNTIME, "hqfFile: %{private}s, resolvedHqfFile: %{private}s", hqfFile.c_str(), resolvedHqfFile.c_str()); - if (!JsRuntime::GetFileBuffer(resolvedHqfFile, patchFileName, newpatchBuffer_)) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "GetFileBuffer failed"); + auto data = JsRuntime::GetSafeData(resolvedHqfFile, patchFileName); + if (data == nullptr) { + if (patchFileName.empty()) { + TAG_LOGI(AAFwkTag::JSRUNTIME, "No need to load patch cause no ets. path: %{private}s", + resolvedHqfFile.c_str()); + return true; + } return false; } - *patchBuffer = newpatchBuffer_.data(); + *patchBuffer = data->GetDataPtr(); TAG_LOGD(AAFwkTag::JSRUNTIME, "patchFileName: %{private}s", patchFileName.c_str()); - patchSize = newpatchBuffer_.size(); + patchSize = data->GetDataLen(); return true; } } // namespace AbilityRuntime diff --git a/frameworks/native/runtime/js_quickfix_callback.h b/frameworks/native/runtime/js_quickfix_callback.h index 01c810d527..7cff81c7b9 100644 --- a/frameworks/native/runtime/js_quickfix_callback.h +++ b/frameworks/native/runtime/js_quickfix_callback.h @@ -31,7 +31,7 @@ public: bool operator()(std::string baseFileName, std::string &patchFileName, - void **patchBuffer, + uint8_t **patchBuffer, size_t &patchSize); private: diff --git a/frameworks/native/runtime/js_runtime.cpp b/frameworks/native/runtime/js_runtime.cpp index 492e73b7e4..626329510d 100644 --- a/frameworks/native/runtime/js_runtime.cpp +++ b/frameworks/native/runtime/js_runtime.cpp @@ -33,6 +33,7 @@ #include "connect_server_manager.h" #include "ecmascript/napi/include/jsnapi.h" #include "extract_resource_manager.h" +#include "file_mapper.h" #include "file_path_utils.h" #include "hdc_register.h" #include "hilog_tag_wrapper.h" @@ -484,6 +485,33 @@ bool JsRuntime::GetFileBuffer(const std::string& filePath, std::string& fileFull return true; } +std::shared_ptr JsRuntime::GetSafeData(const std::string& path, std::string& fileFullName) +{ + bool newCreate = false; + auto extractor = ExtractorUtil::GetExtractor(path, newCreate, true); + if (extractor == nullptr) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "Get extractor failed. path: %{private}s", path.c_str()); + return nullptr; + } + + std::vector fileNames; + extractor->GetSpecifiedTypeFiles(fileNames, ".abc"); + if (fileNames.empty()) { + TAG_LOGI(AAFwkTag::JSRUNTIME, "There's no abc file in hap or hqf: %{private}s", path.c_str()); + return nullptr; + } + std::string fileName = fileNames.front(); + fileFullName = path + "/" + fileName; + + auto safeData = extractor->GetSafeData(fileName); + if (safeData == nullptr) { + TAG_LOGE(AAFwkTag::JSRUNTIME, "Get safe data failed. path: %{private}s", path.c_str()); + return nullptr; + } + + return safeData; +} + bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& hapPath) { TAG_LOGD(AAFwkTag::JSRUNTIME, "called"); @@ -493,16 +521,18 @@ bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& h InitSourceMap(hqfFile); std::string patchFile; - std::vector patchBuffer; - if (!GetFileBuffer(hqfFile, patchFile, patchBuffer)) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadRepairPatch, get patch file buffer failed."); + auto hqfSafeData = GetSafeData(hqfFile, patchFile); + if (hqfSafeData == nullptr) { + if (patchFile.empty()) { + TAG_LOGI(AAFwkTag::JSRUNTIME, "No need to load patch cause no ets. path: %{private}s", hqfFile.c_str()); + return true; + } return false; } std::string baseFile; - std::vector baseBuffer; - if (!GetFileBuffer(hapPath, baseFile, baseBuffer)) { - TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadRepairPatch, get base file buffer failed."); + auto hapSafeData = GetSafeData(hapPath, baseFile); + if (hapSafeData == nullptr) { return false; } @@ -519,8 +549,8 @@ bool JsRuntime::LoadRepairPatch(const std::string& hqfFile, const std::string& h TAG_LOGD(AAFwkTag::JSRUNTIME, "LoadRepairPatch, LoadPatch, patchFile: %{private}s, baseFile: %{private}s.", patchFile.c_str(), resolvedHapPath.c_str()); - auto ret = panda::JSNApi::LoadPatch(vm, patchFile, patchBuffer.data(), patchBuffer.size(), - resolvedHapPath, baseBuffer.data(), baseBuffer.size()); + auto ret = panda::JSNApi::LoadPatch(vm, patchFile, hqfSafeData->GetDataPtr(), hqfSafeData->GetDataLen(), + resolvedHapPath, hapSafeData->GetDataPtr(), hapSafeData->GetDataLen()); if (ret != panda::JSNApi::PatchErrorCode::SUCCESS) { TAG_LOGE(AAFwkTag::JSRUNTIME, "LoadPatch failed with %{public}d.", static_cast(ret)); return false; @@ -1481,15 +1511,15 @@ void JsRuntime::InitWorkerModule(const Options& options) { CHECK_POINTER(jsEnv_); std::shared_ptr workerInfo = std::make_shared(); - workerInfo->codePath = panda::panda_file::StringPacProtect(options.codePath); + workerInfo->codePath = options.codePath; workerInfo->isDebugVersion = options.isDebugVersion; workerInfo->isBundle = options.isBundle; workerInfo->packagePathStr = options.packagePathStr; workerInfo->assetBasePathStr = options.assetBasePathStr; - workerInfo->hapPath = panda::panda_file::StringPacProtect(options.hapPath); - workerInfo->isStageModel = panda::panda_file::BoolPacProtect(options.isStageModel); + workerInfo->hapPath = options.hapPath; + workerInfo->isStageModel = options.isStageModel; workerInfo->moduleName = options.moduleName; - workerInfo->apiTargetVersion = panda::panda_file::DataProtect(static_cast(options.apiTargetVersion)); + workerInfo->apiTargetVersion = options.apiTargetVersion; if (options.isJsFramework) { SetJsFramework(); } diff --git a/frameworks/native/runtime/js_worker.cpp b/frameworks/native/runtime/js_worker.cpp index 25368420c3..1696949612 100644 --- a/frameworks/native/runtime/js_worker.cpp +++ b/frameworks/native/runtime/js_worker.cpp @@ -193,7 +193,7 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf if (uri.find_first_of("/") == 0) { TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with /modulename"); realPath = uri.substr(1); - } else if (uri.find("../") == 0 && !GetIsStageModel()) { + } else if (uri.find("../") == 0 && !workerInfo_->isStageModel) { TAG_LOGD(AAFwkTag::JSRUNTIME, "uri start with ../"); realPath = uri.substr(PATH_THREE); } else if (uri.find_first_of("@") == 0) { @@ -207,10 +207,10 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf filePath = NormalizedFileName(realPath); TAG_LOGI(AAFwkTag::JSRUNTIME, "filePath %{private}s", filePath.c_str()); - if (!GetIsStageModel()) { + if (!workerInfo_->isStageModel) { GetAmi(ami, filePath); } else { - ami = (workerInfo_->codePath).GetOriginString() + filePath; + ami = workerInfo_->codePath + filePath; } TAG_LOGD(AAFwkTag::JSRUNTIME, "Get asset, ami: %{private}s", ami.c_str()); @@ -251,11 +251,10 @@ void AssetHelper::operator()(const std::string& uri, uint8_t** buff, size_t* buf filePath = NormalizedFileName(realPath); // for safe reason, filePath must starts with 'abcs/' in restricted env - if (isRestricted && filePath.find(RESTRICTED_PREFIX_PATH) - && (static_cast(workerInfo_->apiTargetVersion.GetOriginPointer())) >= API12) { + if (isRestricted && filePath.find(RESTRICTED_PREFIX_PATH) && workerInfo_->apiTargetVersion >= API12) { filePath = RESTRICTED_PREFIX_PATH + filePath; } - ami = (workerInfo_->codePath).GetOriginString() + filePath; + ami = workerInfo_->codePath + filePath; TAG_LOGD(AAFwkTag::JSRUNTIME, "Get asset, ami: %{private}s", ami.c_str()); if (ami.find(CACHE_DIRECTORY) != std::string::npos) { if (!ReadAmiData(ami, buff, buffSize, content, useSecureMem, isRestricted)) { @@ -316,10 +315,9 @@ bool AssetHelper::ReadAmiData(const std::string& ami, uint8_t** buff, size_t* bu bool& useSecureMem, bool isRestricted) { // Current function is a private, validity of workerInfo_ has been checked by caller. - int32_t apiTargetVersion = static_cast(workerInfo_->apiTargetVersion.GetOriginPointer()); - bool apiSatisfy = apiTargetVersion == 0 || apiTargetVersion > API8; - if (GetIsStageModel() && !isRestricted && apiSatisfy) { - if (apiTargetVersion >= API12) { + bool apiSatisfy = workerInfo_->apiTargetVersion == 0 || workerInfo_->apiTargetVersion > API8; + if (workerInfo_->isStageModel && !isRestricted && apiSatisfy) { + if (workerInfo_->apiTargetVersion >= API12) { useSecureMem = true; return GetSafeData(ami, buff, buffSize); } else if (GetSafeData(ami, buff, buffSize)) { @@ -383,8 +381,8 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff, std::string newHapPath; size_t pos = filePath.find('/'); - if (!GetIsStageModel()) { - newHapPath = (workerInfo_->hapPath).GetOriginString(); + if (!workerInfo_->isStageModel) { + newHapPath = workerInfo_->hapPath; } else { for (auto hapModuleInfo : bundleInfo.hapModuleInfos) { if (hapModuleInfo.moduleName == filePath.substr(0, pos)) { @@ -404,7 +402,7 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff, std::unique_ptr dataPtr = nullptr; std::string realfilePath; size_t fileLen = 0; - if (!GetIsStageModel()) { + if (!workerInfo_->isStageModel) { bool flag = false; for (const auto& basePath : workerInfo_->assetBasePathStr) { realfilePath = basePath + filePath; @@ -421,12 +419,11 @@ bool AssetHelper::ReadFilePathData(const std::string& filePath, uint8_t** buff, } else { realfilePath = filePath.substr(pos + 1); TAG_LOGD(AAFwkTag::JSRUNTIME, "realfilePath: %{private}s", realfilePath.c_str()); - int32_t apiTargetVersion = static_cast(workerInfo_->apiTargetVersion.GetOriginPointer()); - bool apiSatisfy = apiTargetVersion == 0 || apiTargetVersion > API8; - if (GetIsStageModel() && !isRestricted && apiSatisfy && !extractor->IsHapCompress(realfilePath)) { + bool apiSatisfy = workerInfo_->apiTargetVersion == 0 || workerInfo_->apiTargetVersion > API8; + if (workerInfo_->isStageModel && !isRestricted && apiSatisfy && !extractor->IsHapCompress(realfilePath)) { TAG_LOGD(AAFwkTag::JSRUNTIME, "Use secure mem."); auto safeData = extractor->GetSafeData(realfilePath); - if (apiTargetVersion >= API12) { + if (workerInfo_->apiTargetVersion >= API12) { useSecureMem = true; if (safeData == nullptr) { TAG_LOGE(AAFwkTag::JSRUNTIME, "Get secure mem failed, file %{private}s.", filePath.c_str()); @@ -466,7 +463,7 @@ void AssetHelper::GetAmi(std::string& ami, const std::string& filePath) std::string fileName = filePath.substr(slashPos + 1); std::string path = filePath.substr(0, slashPos + 1); - std::string loadPath = ExtractorUtil::GetLoadFilePath((workerInfo_->hapPath).GetOriginString()); + std::string loadPath = ExtractorUtil::GetLoadFilePath(workerInfo_->hapPath); bool newCreate = false; std::shared_ptr extractor = ExtractorUtil::GetExtractor(loadPath, newCreate); if (extractor == nullptr) { @@ -500,7 +497,7 @@ void AssetHelper::GetAmi(std::string& ami, const std::string& filePath) } } - TAG_LOGD(AAFwkTag::JSRUNTIME, "targetFilePath %{private}s", targetFilePath.c_str()); + TAG_LOGI(AAFwkTag::JSRUNTIME, "targetFilePath %{public}s", targetFilePath.c_str()); if (!flag) { TAG_LOGE(AAFwkTag::JSRUNTIME, "get targetFilePath failed!"); @@ -511,19 +508,12 @@ void AssetHelper::GetAmi(std::string& ami, const std::string& filePath) std::string filePathName = basePath + targetFilePath; bool hasFile = extractor->HasEntry(filePathName); if (hasFile) { - ami = (workerInfo_->hapPath).GetOriginString() + "/" + filePathName; + ami = workerInfo_->hapPath + "/" + filePathName; return; } } } -bool AssetHelper::GetIsStageModel() -{ - bool stageModule = workerInfo_->isStageModel.GetBool(); - TAG_LOGI(AAFwkTag::JSRUNTIME, "stagemodule: %{public}d", stageModule); - return stageModule; -} - int32_t GetContainerId() { #ifdef SUPPORT_SCREEN diff --git a/frameworks/native/runtime/js_worker.h b/frameworks/native/runtime/js_worker.h index a9f17439d6..d9cd7a6a05 100644 --- a/frameworks/native/runtime/js_worker.h +++ b/frameworks/native/runtime/js_worker.h @@ -35,9 +35,8 @@ class AssetHelper final { public: explicit AssetHelper(std::shared_ptr workerInfo) : workerInfo_(workerInfo) { - panda::panda_file::StringPacProtect codePath = panda::panda_file::StringPacProtect(workerInfo_->codePath); - if (!(codePath.GetOriginString()).empty() && (codePath.GetOriginString()).back() != '/') { - (workerInfo_->codePath).Append('/'); + if (!(workerInfo_->codePath).empty() && (workerInfo->codePath).back() != '/') { + (workerInfo_->codePath).append("/"); } } @@ -58,8 +57,6 @@ private: void GetAmi(std::string& ami, const std::string& filePath); bool GetSafeData(const std::string& ami, uint8_t** buff, size_t* buffSize); - - bool GetIsStageModel(); std::shared_ptr workerInfo_ = nullptr; int fd_ = -1; diff --git a/frameworks/native/runtime/native_runtime_impl.cpp b/frameworks/native/runtime/native_runtime_impl.cpp index 9b8bca5f67..95221ad491 100644 --- a/frameworks/native/runtime/native_runtime_impl.cpp +++ b/frameworks/native/runtime/native_runtime_impl.cpp @@ -314,13 +314,13 @@ void NativeRuntimeImpl::InitWorkerModule(const Options& options, const std::shar } std::shared_ptr workerInfo = std::make_shared(); - workerInfo->codePath = panda::panda_file::StringPacProtect(options.codePath); + workerInfo->codePath = options.codePath; workerInfo->isDebugVersion = options.isDebugVersion; workerInfo->isBundle = options.isBundle; workerInfo->packagePathStr = options.packagePathStr; workerInfo->assetBasePathStr = options.assetBasePathStr; - workerInfo->hapPath = panda::panda_file::StringPacProtect(options.hapPath); - workerInfo->isStageModel = panda::panda_file::BoolPacProtect(options.isStageModel); + workerInfo->hapPath = options.hapPath; + workerInfo->isStageModel = options.isStageModel; workerInfo->moduleName = options.moduleName; if (options.isJsFramework) { SetJsFramework(); diff --git a/frameworks/native/runtime/ohos_js_environment_impl.cpp b/frameworks/native/runtime/ohos_js_environment_impl.cpp index 203beea07c..23c754faf7 100644 --- a/frameworks/native/runtime/ohos_js_environment_impl.cpp +++ b/frameworks/native/runtime/ohos_js_environment_impl.cpp @@ -171,7 +171,7 @@ void OHOSJsEnvironmentImpl::InitWorkerModule(NativeEngine* engine, std::shared_p engine->SetInitWorkerFunc(InitWorkerFunc); engine->SetOffWorkerFunc(OffWorkerFunc); engine->SetGetAssetFunc(AssetHelper(workerInfo)); - engine->SetApiVersion(static_cast(workerInfo->apiTargetVersion.GetOriginPointer())); + engine->SetApiVersion(workerInfo->apiTargetVersion); engine->SetGetContainerScopeIdFunc(GetContainerId); engine->SetInitContainerScopeFunc(UpdateContainerScope); diff --git a/frameworks/simulator/ability_simulator/src/common_func.cpp b/frameworks/simulator/ability_simulator/src/common_func.cpp index 85b17e6019..277c8c3ad8 100644 --- a/frameworks/simulator/ability_simulator/src/common_func.cpp +++ b/frameworks/simulator/ability_simulator/src/common_func.cpp @@ -58,7 +58,7 @@ bool CommonFunc::ParsePropertyArray(napi_env env, napi_value args, const std::st bool hasKey = false; napi_has_named_property(env, args, propertyName.c_str(), &hasKey); if (!hasKey) { - TAG_LOGE(AAFwkTag::ABILITY_SIM, "%{public}s is not existed", propertyName.c_str()); + TAG_LOGE(AAFwkTag::ABILITY_SIM, "%{public}s is not exist", propertyName.c_str()); return true; } napi_value property = nullptr; diff --git a/interfaces/inner_api/ability_manager/BUILD.gn b/interfaces/inner_api/ability_manager/BUILD.gn index d987116005..55a55362dd 100644 --- a/interfaces/inner_api/ability_manager/BUILD.gn +++ b/interfaces/inner_api/ability_manager/BUILD.gn @@ -135,7 +135,6 @@ ohos_shared_library("ability_manager") { external_deps = [ "ability_base:base", - "ability_base:session_info", "bundle_framework:libappexecfwk_common", "c_utils:utils", "common_event_service:cesfwk_innerkits", @@ -153,6 +152,7 @@ ohos_shared_library("ability_manager") { public_external_deps = [ "ability_base:configuration", + "ability_base:session_info", "ability_base:want", "ability_base:zuri", "background_task_mgr:bgtaskmgr_innerkits", diff --git a/interfaces/inner_api/ability_manager/include/ability_manager_client.h b/interfaces/inner_api/ability_manager/include/ability_manager_client.h index 97e4e57dd9..7cafb0967a 100644 --- a/interfaces/inner_api/ability_manager/include/ability_manager_client.h +++ b/interfaces/inner_api/ability_manager/include/ability_manager_client.h @@ -1557,7 +1557,9 @@ private: sptr GetAbilityManager(); void ResetProxy(wptr remote); +#ifdef WITH_DLP void HandleDlpApp(Want &want); +#endif // WITH_DLP static std::once_flag singletonFlag_; std::recursive_mutex mutex_; diff --git a/interfaces/inner_api/app_manager/BUILD.gn b/interfaces/inner_api/app_manager/BUILD.gn index 523bbdc736..2fde06c872 100644 --- a/interfaces/inner_api/app_manager/BUILD.gn +++ b/interfaces/inner_api/app_manager/BUILD.gn @@ -139,6 +139,7 @@ ohos_shared_library("app_manager") { ] public_external_deps = [ "ability_base:configuration", + "ability_base:session_info", "ability_base:want", "bundle_framework:appexecfwk_base", "image_framework:image_native", diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h index f741d4ebc8..bd0cffcae5 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_interface.h @@ -342,6 +342,15 @@ public: return true; } + /** + * whether the abilities of process specified by pid type only UIAbility. + * @return Returns true is only UIAbility, otherwise return false + */ + virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) + { + return false; + } + enum class Message { LOAD_ABILITY = 0, TERMINATE_ABILITY, @@ -389,6 +398,7 @@ public: ATTACHED_TO_STATUS_BAR, BLOCK_PROCESS_CACHE_BY_PIDS, IS_KILLED_FOR_UPGRADE_WEB, + IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION, FORCE_KILL_APPLICATION, }; }; diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h index f6e3aba4d3..4e7931ee7f 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_proxy.h @@ -309,6 +309,12 @@ public: */ virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override; + /** + * whether the abilities of process specified by pid type only UIAbility. + * @return Returns true is only UIAbility, otherwise return false + */ + virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override; + private: bool WriteInterfaceToken(MessageParcel &data); int32_t SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option); diff --git a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h index fb7b896c79..e73b6c660a 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h +++ b/interfaces/inner_api/app_manager/include/appmgr/ams_mgr_stub.h @@ -95,6 +95,7 @@ private: MessageParcel &reply, MessageOption &option); int32_t HandleBlockProcessCacheByPids(MessageParcel &data, MessageParcel &reply); int32_t HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParcel &reply); + int32_t HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply); DISALLOW_COPY_AND_MOVE(AmsMgrStub); }; } // namespace AppExecFwk diff --git a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h index 50b52a3075..bc4a5cfbcc 100644 --- a/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h +++ b/interfaces/inner_api/app_manager/include/appmgr/app_mgr_client.h @@ -795,6 +795,12 @@ public: */ bool IsKilledForUpgradeWeb(const std::string &bundleName); + /** + * whether the abilities of process specified by pid type only UIAbility. + * @return Returns true is only UIAbility, otherwise return false + */ + bool IsProcessContainsOnlyUIAbility(const pid_t pid); + private: void SetServiceManager(std::unique_ptr serviceMgr); /** diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp index 8590c7d221..86dd82d878 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_proxy.cpp @@ -29,6 +29,27 @@ constexpr int32_t MAX_APP_DEBUG_COUNT = 100; AmsMgrProxy::AmsMgrProxy(const sptr &impl) : IRemoteProxy(impl) {} +bool AmsMgrProxy::IsProcessContainsOnlyUIAbility(const pid_t pid) +{ + TAG_LOGD(AAFwkTag::APPMGR, "IsProcessContainsOnlyUIAbility start"); + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_SYNC); + if (!WriteInterfaceToken(data)) { + return false; + } + data.WriteInt32(static_cast(pid)); + int32_t ret = + SendTransactCmd(static_cast( + IAmsMgr::Message::IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION), data, reply, option); + if (ret != NO_ERROR) { + TAG_LOGW(AAFwkTag::APPMGR, "SendRequest is failed, error code: %{public}d", ret); + return false; + } + TAG_LOGD(AAFwkTag::APPMGR, "IsProcessContainsOnlyUIAbility end"); + return reply.ReadBool(); +} + bool AmsMgrProxy::WriteInterfaceToken(MessageParcel &data) { if (!data.WriteInterfaceToken(AmsMgrProxy::GetDescriptor())) { diff --git a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp index 575c594f30..e4a946fe27 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/ams_mgr_stub.cpp @@ -190,6 +190,8 @@ int32_t AmsMgrStub::OnRemoteRequestInnerThird(uint32_t code, MessageParcel &data return HandleBlockProcessCacheByPids(data, reply); case static_cast(IAmsMgr::Message::IS_KILLED_FOR_UPGRADE_WEB): return HandleIsKilledForUpgradeWeb(data, reply); + case static_cast(IAmsMgr::Message::IS_PROCESS_CONTAINS_ONLY_UI_EXTENSION): + return HandleIsProcessContainsOnlyUIAbility(data, reply); case static_cast(IAmsMgr::Message::FORCE_KILL_APPLICATION): return HandleForceKillApplication(data, reply); } @@ -783,5 +785,17 @@ int32_t AmsMgrStub::HandleIsKilledForUpgradeWeb(MessageParcel &data, MessageParc } return NO_ERROR; } + +int32_t AmsMgrStub::HandleIsProcessContainsOnlyUIAbility(MessageParcel &data, MessageParcel &reply) +{ + auto pid = data.ReadUint32(); + + auto result = IsProcessContainsOnlyUIAbility(pid); + if (!reply.WriteBool(result)) { + TAG_LOGE(AAFwkTag::APPMGR, "Fail to write result in HandleIsProcessContainsOnlyUIAbility."); + return ERR_INVALID_VALUE; + } + return NO_ERROR; +} } // namespace AppExecFwk } // namespace OHOS diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp index 0cea759327..7e1a75808d 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_client.cpp @@ -490,6 +490,18 @@ AppMgrResultCode AppMgrClient::ConnectAppMgrService() return AppMgrResultCode::ERROR_SERVICE_NOT_READY; } +bool AppMgrClient::IsProcessContainsOnlyUIAbility(const pid_t pid) +{ + sptr service = iface_cast(mgrHolder_->GetRemoteObject()); + if (service != nullptr) { + sptr amsService = service->GetAmsMgr(); + if (amsService != nullptr) { + return amsService->IsProcessContainsOnlyUIAbility(pid); + } + } + return false; +} + void AppMgrClient::SetServiceManager(std::unique_ptr serviceMgr) { if (!mgrHolder_) { diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp index 5e2c34e997..df1c8a8e60 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_proxy.cpp @@ -45,6 +45,9 @@ void AppMgrProxy::AttachApplication(const sptr &obj) if (!WriteInterfaceToken(data)) { return; } + if (obj == nullptr || obj.GetRefPtr() == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "app scheduler null"); + } PARCEL_UTIL_WRITE_NORET(data, RemoteObject, obj.GetRefPtr()); PARCEL_UTIL_SENDREQ_NORET(AppMgrInterfaceCode::APP_ATTACH_APPLICATION, data, reply, option); diff --git a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp index bad3c0cab7..6f8e4b5365 100644 --- a/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp +++ b/interfaces/inner_api/app_manager/src/appmgr/app_mgr_stub.cpp @@ -343,6 +343,9 @@ int32_t AppMgrStub::HandleAttachApplication(MessageParcel &data, MessageParcel & { HITRACE_METER(HITRACE_TAG_APP); sptr client = data.ReadRemoteObject(); + if (client == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "remote object null"); + } AttachApplication(client); return NO_ERROR; } diff --git a/interfaces/inner_api/connectionobs_manager/include/connection_observer_client_impl.h b/interfaces/inner_api/connectionobs_manager/include/connection_observer_client_impl.h index aaccfb9460..0d84782dcf 100644 --- a/interfaces/inner_api/connectionobs_manager/include/connection_observer_client_impl.h +++ b/interfaces/inner_api/connectionobs_manager/include/connection_observer_client_impl.h @@ -20,7 +20,9 @@ #include #include "connection_observer.h" +#ifdef WITH_DLP #include "dlp_connection_info.h" +#endif // WITH_DLP #include "service_proxy_adapter.h" namespace OHOS { @@ -36,13 +38,16 @@ public: int32_t RegisterObserver(const std::shared_ptr &observer); int32_t UnregisterObserver(const std::shared_ptr &observer); - int32_t GetDlpConnectionInfos(std::vector &infos); int32_t GetConnectionData(std::vector &infos); void HandleExtensionConnected(const ConnectionData &data); void HandleExtensionDisconnected(const ConnectionData &data); + void HandleRemoteDied(const wptr &remote); + +#ifdef WITH_DLP + int32_t GetDlpConnectionInfos(std::vector &infos); void HandleDlpAbilityOpened(const DlpStateData &data); void HandleDlpAbilityClosed(const DlpStateData &data); - void HandleRemoteDied(const wptr &remote); +#endif // WITH_DLP private: class ServiceDeathRecipient : public IRemoteObject::DeathRecipient { diff --git a/interfaces/inner_api/connectionobs_manager/include/connection_observer_proxy.h b/interfaces/inner_api/connectionobs_manager/include/connection_observer_proxy.h index 1146384461..b29090921c 100644 --- a/interfaces/inner_api/connectionobs_manager/include/connection_observer_proxy.h +++ b/interfaces/inner_api/connectionobs_manager/include/connection_observer_proxy.h @@ -36,9 +36,11 @@ public: virtual void OnExtensionDisconnected(const ConnectionData &connectionData) override; +#ifdef WITH_DLP virtual void OnDlpAbilityOpened(const DlpStateData &dlpData) override; virtual void OnDlpAbilityClosed(const DlpStateData &dlpData) override; +#endif // WITH_DLP private: static inline BrokerDelegator delegator_; diff --git a/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub.h b/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub.h index d183286dfe..aae26331d3 100644 --- a/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub.h +++ b/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub.h @@ -40,8 +40,10 @@ private: int OnExtensionConnectedInner(MessageParcel &data, MessageParcel &reply); int OnExtensionDisconnectedInner(MessageParcel &data, MessageParcel &reply); +#ifdef WITH_DLP int OnDlpAbilityOpenedInner(MessageParcel &data, MessageParcel &reply); int OnDlpAbilityClosedInner(MessageParcel &data, MessageParcel &reply); +#endif // WITH_DLP }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub_impl.h b/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub_impl.h index 0bdb02d26c..fde354db4f 100644 --- a/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub_impl.h +++ b/interfaces/inner_api/connectionobs_manager/include/connection_observer_stub_impl.h @@ -34,9 +34,11 @@ public: void OnExtensionDisconnected(const ConnectionData &data) override; +#ifdef WITH_DLP void OnDlpAbilityOpened(const DlpStateData &data) override; void OnDlpAbilityClosed(const DlpStateData &data) override; +#endif // WITH_DLP private: std::weak_ptr owner_; diff --git a/interfaces/inner_api/connectionobs_manager/include/iconnection_observer.h b/interfaces/inner_api/connectionobs_manager/include/iconnection_observer.h index ed93683b94..7bfffa2e41 100644 --- a/interfaces/inner_api/connectionobs_manager/include/iconnection_observer.h +++ b/interfaces/inner_api/connectionobs_manager/include/iconnection_observer.h @@ -17,7 +17,11 @@ #define OHOS_ABILITYRUNTIME_ICONNECTION_OBSERVER_H #include "connection_data.h" + +#ifdef WITH_DLP #include "dlp_state_data.h" +#endif // WITH_DLP + #include "iremote_broker.h" namespace OHOS { @@ -44,6 +48,7 @@ public: */ virtual void OnExtensionDisconnected(const ConnectionData &data) = 0; +#ifdef WITH_DLP /** * called when dlp ability was started. * @@ -57,6 +62,7 @@ public: * @param data dlp state data. */ virtual void OnDlpAbilityClosed(const DlpStateData &data) = 0; +#endif // WITH_DLP enum ConnectionObserverCmd { // ipc id for OnExtensionConnected @@ -65,11 +71,13 @@ public: // ipc id for OnExtensionDisconnected ON_EXTENSION_DISCONNECTED, +#ifdef WITH_DLP // ipc id for OnDlpAbilityOpened ON_DLP_ABILITY_OPENED, // ipc id for OnExtensionDisconnected ON_DLP_ABILITY_CLOSED, +#endif // WITH_DLP // maximum of enum CMD_MAX diff --git a/interfaces/inner_api/connectionobs_manager/include/service_proxy_adapter.h b/interfaces/inner_api/connectionobs_manager/include/service_proxy_adapter.h index 4cc3ca2c29..6d9d21035b 100644 --- a/interfaces/inner_api/connectionobs_manager/include/service_proxy_adapter.h +++ b/interfaces/inner_api/connectionobs_manager/include/service_proxy_adapter.h @@ -16,7 +16,10 @@ #ifndef ABILITY_RUNTIME_SERVICE_PROXY_ADAPTER_H #define ABILITY_RUNTIME_SERVICE_PROXY_ADAPTER_H +#ifdef WITH_DLP #include "dlp_connection_info.h" +#endif // WITH_DLP + #include "iconnection_observer.h" namespace OHOS { @@ -39,7 +42,9 @@ public: int32_t UnregisterObserver(const sptr &observer); +#ifdef WITH_DLP int32_t GetDlpConnectionInfos(std::vector &infos); +#endif // WITH_DLP int32_t GetConnectionData(std::vector &infos); diff --git a/interfaces/inner_api/connectionobs_manager/src/connection_observer_client.cpp b/interfaces/inner_api/connectionobs_manager/src/connection_observer_client.cpp index 74bd40edaf..3117f55217 100644 --- a/interfaces/inner_api/connectionobs_manager/src/connection_observer_client.cpp +++ b/interfaces/inner_api/connectionobs_manager/src/connection_observer_client.cpp @@ -54,12 +54,16 @@ int32_t ConnectionObserverClient::UnregisterObserver(const std::shared_ptr &infos) { +#ifdef WITH_DLP if (!clientImpl_) { TAG_LOGE(AAFwkTag::CONNECTION, "ConnectionObserverClient::GetDlpConnectionInfos impl is nullptr."); return ERR_NO_CLIENT_IMPL; } return clientImpl_->GetDlpConnectionInfos(infos); +#else + return ERR_READ_INFO_FAILED; +#endif // WITH_DLP } int32_t ConnectionObserverClient::GetConnectionData(std::vector &connectionData) diff --git a/interfaces/inner_api/connectionobs_manager/src/connection_observer_client_impl.cpp b/interfaces/inner_api/connectionobs_manager/src/connection_observer_client_impl.cpp index 93c3dc4f5f..4c72f36ba0 100644 --- a/interfaces/inner_api/connectionobs_manager/src/connection_observer_client_impl.cpp +++ b/interfaces/inner_api/connectionobs_manager/src/connection_observer_client_impl.cpp @@ -59,6 +59,7 @@ int32_t ConnectionObserverClientImpl::UnregisterObserver(const std::shared_ptr &infos) { auto proxy = GetServiceProxy(); @@ -69,6 +70,7 @@ int32_t ConnectionObserverClientImpl::GetDlpConnectionInfos(std::vectorGetDlpConnectionInfos(infos); } +#endif // WITH_DLP int32_t ConnectionObserverClientImpl::GetConnectionData(std::vector &connectionData) { @@ -103,6 +105,7 @@ void ConnectionObserverClientImpl::HandleExtensionDisconnected(const ConnectionD } } +#ifdef WITH_DLP void ConnectionObserverClientImpl::HandleDlpAbilityOpened(const DlpStateData &data) { auto observers = GetObservers(); @@ -124,6 +127,7 @@ void ConnectionObserverClientImpl::HandleDlpAbilityClosed(const DlpStateData &da } } } +#endif // WITH_DLP bool ConnectionObserverClientImpl::RegisterObserverToServiceLocked(const std::shared_ptr &proxy) { diff --git a/interfaces/inner_api/connectionobs_manager/src/connection_observer_proxy.cpp b/interfaces/inner_api/connectionobs_manager/src/connection_observer_proxy.cpp index 8b874ed3ab..85c51c8796 100644 --- a/interfaces/inner_api/connectionobs_manager/src/connection_observer_proxy.cpp +++ b/interfaces/inner_api/connectionobs_manager/src/connection_observer_proxy.cpp @@ -69,6 +69,7 @@ void ConnectionObserverProxy::OnExtensionDisconnected(const ConnectionData& conn } } +#ifdef WITH_DLP void ConnectionObserverProxy::OnDlpAbilityOpened(const DlpStateData& dlpData) { MessageParcel data; @@ -116,6 +117,7 @@ void ConnectionObserverProxy::OnDlpAbilityClosed(const DlpStateData& dlpData) return; } } +#endif // WITH_DLP int32_t ConnectionObserverProxy::SendTransactCmd(uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) diff --git a/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub.cpp b/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub.cpp index 62a4dcb850..6083ec06a3 100644 --- a/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub.cpp +++ b/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub.cpp @@ -38,10 +38,12 @@ int ConnectionObserverStub::OnRemoteRequest( return OnExtensionConnectedInner(data, reply); case ON_EXTENSION_DISCONNECTED: return OnExtensionDisconnectedInner(data, reply); +#ifdef WITH_DLP case ON_DLP_ABILITY_OPENED: return OnDlpAbilityOpenedInner(data, reply); case ON_DLP_ABILITY_CLOSED: return OnDlpAbilityClosedInner(data, reply); +#endif // WITH_DLP } } return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -71,6 +73,7 @@ int ConnectionObserverStub::OnExtensionDisconnectedInner(MessageParcel &data, Me return NO_ERROR; } +#ifdef WITH_DLP int ConnectionObserverStub::OnDlpAbilityOpenedInner(MessageParcel &data, MessageParcel &reply) { std::unique_ptr dlpData(data.ReadParcelable()); @@ -94,5 +97,6 @@ int ConnectionObserverStub::OnDlpAbilityClosedInner(MessageParcel &data, Message OnDlpAbilityClosed(*dlpData); return NO_ERROR; } +#endif // WITH_DLP } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub_impl.cpp b/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub_impl.cpp index 19803e5973..2fe2ec0764 100644 --- a/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub_impl.cpp +++ b/interfaces/inner_api/connectionobs_manager/src/connection_observer_stub_impl.cpp @@ -37,6 +37,7 @@ void ConnectionObserverStubImpl::OnExtensionDisconnected(const ConnectionData &d owner->HandleExtensionDisconnected(data); } +#ifdef WITH_DLP void ConnectionObserverStubImpl::OnDlpAbilityOpened(const DlpStateData &data) { auto owner = owner_.lock(); @@ -54,5 +55,6 @@ void ConnectionObserverStubImpl::OnDlpAbilityClosed(const DlpStateData &data) } owner->HandleDlpAbilityClosed(data); } +#endif // WITH_DLP } // namespace AbilityRuntime } // namespace OHOS diff --git a/interfaces/inner_api/connectionobs_manager/src/service_proxy_adapter.cpp b/interfaces/inner_api/connectionobs_manager/src/service_proxy_adapter.cpp index c89b9619e7..843525809a 100644 --- a/interfaces/inner_api/connectionobs_manager/src/service_proxy_adapter.cpp +++ b/interfaces/inner_api/connectionobs_manager/src/service_proxy_adapter.cpp @@ -24,7 +24,9 @@ namespace { const std::u16string ABILITY_MGR_DESCRIPTOR = u"ohos.aafwk.AbilityManager"; constexpr uint32_t REGISTER_CONNECTION_OBSERVER = 2502; constexpr uint32_t UNREGISTER_CONNECTION_OBSERVER = 2503; +#ifdef WITH_DLP constexpr uint32_t GET_DLP_CONNECTION_INFOS = 2504; +#endif // WITH_DLP constexpr uint32_t GET_CONNECTION_DATA = 2505; constexpr int32_t CYCLE_LIMIT = 1000; } @@ -96,6 +98,7 @@ int32_t ServiceProxyAdapter::UnregisterObserver(const sptr return reply.ReadInt32(); } +#ifdef WITH_DLP int32_t ServiceProxyAdapter::GetDlpConnectionInfos(std::vector &infos) { if (!remoteObj_) { @@ -141,6 +144,7 @@ int32_t ServiceProxyAdapter::GetDlpConnectionInfos(std::vector &connectionData) { diff --git a/interfaces/inner_api/runtime/BUILD.gn b/interfaces/inner_api/runtime/BUILD.gn index 6c5033cfde..2b330c10ad 100644 --- a/interfaces/inner_api/runtime/BUILD.gn +++ b/interfaces/inner_api/runtime/BUILD.gn @@ -93,7 +93,6 @@ ohos_shared_library("runtime") { "ability_base:extractortool", "ability_base:extractresourcemanager", "ability_base:string_utils", - "ability_base:want", "access_token:libaccesstoken_sdk", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", @@ -118,6 +117,11 @@ ohos_shared_library("runtime") { "zlib:shared_libz", ] + public_external_deps = [ + "ability_base:session_info", + "ability_base:want", + ] + defines = [] if (cj_frontend) { diff --git a/interfaces/inner_api/runtime/include/js_runtime.h b/interfaces/inner_api/runtime/include/js_runtime.h index eadf52b2b1..7798fa28a8 100644 --- a/interfaces/inner_api/runtime/include/js_runtime.h +++ b/interfaces/inner_api/runtime/include/js_runtime.h @@ -39,6 +39,7 @@ class EventHandler; namespace AbilityBase { class Extractor; +class FileMapper; } // namespace AbilityBase namespace JsEnv { @@ -116,6 +117,7 @@ public: void RegisterQuickFixQueryFunc(const std::map& moduleAndPath) override; static bool GetFileBuffer(const std::string& filePath, std::string& fileFullName, std::vector& buffer, bool isABC = true); + static std::shared_ptr GetSafeData(const std::string& path, std::string& fileFullName); void InitSourceMap(const std::shared_ptr operatorImpl); void InitSourceMap(const std::string hqfFilePath); diff --git a/interfaces/inner_api/wantagent/BUILD.gn b/interfaces/inner_api/wantagent/BUILD.gn index 05f3013152..9defdd8b9b 100644 --- a/interfaces/inner_api/wantagent/BUILD.gn +++ b/interfaces/inner_api/wantagent/BUILD.gn @@ -74,7 +74,6 @@ ohos_shared_library("wantagent_innerkits") { ] external_deps = [ - "ability_base:session_info", "ability_base:want", "c_utils:utils", "hilog:libhilog", @@ -86,6 +85,7 @@ ohos_shared_library("wantagent_innerkits") { public_external_deps = [ "ability_base:configuration", + "ability_base:session_info", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", "eventhandler:libeventhandler", diff --git a/interfaces/kits/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.h b/interfaces/kits/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.h index 104348b084..c6b1709aa2 100755 --- a/interfaces/kits/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.h +++ b/interfaces/kits/native/ability/native/auto_fill_extension_ability/auto_fill_extension_context.h @@ -33,12 +33,12 @@ public: virtual ~AutoFillExtensionContext() = default; void SetAutoFillExtensionCallback(const std::weak_ptr &autoFillExtensionCallback); - void SetSessionInfo(const wptr &sessionInfo); + void SetSessionInfo(const sptr &sessionInfo); int32_t ReloadInModal(const CustomData &customData); private: std::weak_ptr autoFillExtensionCallback_; - wptr sessionInfo_; + sptr sessionInfo_; }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/js_environment/interfaces/inner_api/js_environment_impl.h b/js_environment/interfaces/inner_api/js_environment_impl.h index 7143eb4717..ebba2ab012 100644 --- a/js_environment/interfaces/inner_api/js_environment_impl.h +++ b/js_environment/interfaces/inner_api/js_environment_impl.h @@ -22,20 +22,18 @@ #include "native_engine/native_engine.h" -#include "data_protect.h" - namespace OHOS { namespace JsEnv { struct WorkerInfo { - panda::panda_file::StringPacProtect codePath; + std::string codePath; bool isDebugVersion = false; bool isBundle = true; std::string packagePathStr; std::vector assetBasePathStr; - panda::panda_file::StringPacProtect hapPath; - panda::panda_file::BoolPacProtect isStageModel = panda::panda_file::BoolPacProtect(true); + std::string hapPath; + bool isStageModel = true; std::string moduleName; - panda::panda_file::DataProtect apiTargetVersion = panda::panda_file::DataProtect(); + int32_t apiTargetVersion = 0; }; class JsEnvironmentImpl { diff --git a/services/abilitymgr/include/ability_manager_service.h b/services/abilitymgr/include/ability_manager_service.h index e1fea442c5..785a37020d 100644 --- a/services/abilitymgr/include/ability_manager_service.h +++ b/services/abilitymgr/include/ability_manager_service.h @@ -152,7 +152,7 @@ public: const sptr &callerToken, uint32_t specifyTokenId, int32_t userId = DEFAULT_INVAL_VALUE, - int requestCode = DEFAULT_INVAL_VALUE); + int requestCode = DEFAULT_INVAL_VALUE, bool isPendingWantCaller = false); /** * Starts a new ability with specific start options and specialId, send want to ability manager service. @@ -171,7 +171,7 @@ public: const sptr &callerToken, int32_t userId = DEFAULT_INVAL_VALUE, int requestCode = DEFAULT_INVAL_VALUE, - uint32_t specifyTokenId = 0); + uint32_t specifyTokenId = 0, bool isPendingWantCaller = false); /** * StartAbilityWithSpecifyTokenId with want and specialId, send want to ability manager service. @@ -857,7 +857,9 @@ public: virtual int UnregisterObserver(const sptr &observer) override; +#ifdef WITH_DLP virtual int GetDlpConnectionInfos(std::vector &infos) override; +#endif // WITH_DLP virtual int GetConnectionData(std::vector &connectionData) override; @@ -961,7 +963,7 @@ public: bool isStartAsCaller = false, uint32_t specifyTokenId = 0, bool isForegroundToRestartApp = false, - bool isImplicit = false); + bool isImplicit = false, bool isPendingWantCaller = false); int StartAbilityInner( const Want &want, @@ -971,7 +973,7 @@ public: bool isStartAsCaller = false, uint32_t specifyTokenId = 0, bool isForegroundToRestartApp = false, - bool isImplicit = false); + bool isImplicit = false, bool isPendingWantCaller = false); int StartExtensionAbilityInner( const Want &want, @@ -996,7 +998,7 @@ public: bool isStartAsCaller = false, uint32_t callerTokenId = 0, bool isImplicit = false, - bool isCallByShortcut = false); + bool isCallByShortcut = false, bool isPendingWantCaller = false); int StartAbilityForOptionInner( const Want &want, @@ -1007,7 +1009,7 @@ public: bool isStartAsCaller = false, uint32_t specifyTokenId = 0, bool isImplicit = false, - bool isCallByShortcut = false); + bool isCallByShortcut = false, bool isPendingWantCaller = false); int ImplicitStartAbility( const Want &want, @@ -2093,9 +2095,11 @@ private: AAFwk::EventInfo BuildEventInfo(const Want &want, int32_t userId); +#ifdef WITH_DLP int CheckDlpForExtension( const Want &want, const sptr &callerToken, int32_t userId, AAFwk::EventInfo &eventInfo, const EventName &eventName); +#endif // WITH_DLP void InitStartupFlag(); @@ -2188,7 +2192,7 @@ private: int StartUIAbilityForOptionWrap(const Want &want, const StartOptions &options, sptr callerToken, int32_t userId, int requestCode, uint32_t callerTokenId = 0, bool isImplicit = false, - bool isCallByShortcut = false); + bool isCallByShortcut = false, bool isPendingWantCaller = false); int32_t SetBackgroundCall(const AppExecFwk::RunningProcessInfo &processInfo, const AbilityRequest &abilityRequest, bool &isBackgroundCall) const; @@ -2282,6 +2286,8 @@ private: bool ShouldPreventStartAbility(const AbilityRequest &abilityRequest); + void PrintStartAbilityInfo(AppExecFwk::AbilityInfo callerInfo, AppExecFwk::AbilityInfo calledInfo); + bool IsInWhiteList(const std::string &callerBundleName, const std::string &calleeBundleName, const std::string &calleeAbilityName); diff --git a/services/abilitymgr/include/ability_manager_stub.h b/services/abilitymgr/include/ability_manager_stub.h index 3e68d530dc..315cbfd27d 100644 --- a/services/abilitymgr/include/ability_manager_stub.h +++ b/services/abilitymgr/include/ability_manager_stub.h @@ -20,8 +20,9 @@ #include #include - +#ifdef WITH_DLP #include "dlp_connection_info.h" +#endif // WITH_DLP #include "iconnection_observer.h" namespace OHOS { @@ -60,7 +61,9 @@ public: virtual int UnregisterObserver(const sptr &observer); +#ifdef WITH_DLP virtual int GetDlpConnectionInfos(std::vector &infos); +#endif // WITH_DLP virtual int GetConnectionData(std::vector &connectionData); @@ -188,7 +191,9 @@ private: int UpdateMissionSnapShotFromWMSInner(MessageParcel &data, MessageParcel &reply); int RegisterConnectionObserverInner(MessageParcel &data, MessageParcel &reply); int UnregisterConnectionObserverInner(MessageParcel &data, MessageParcel &reply); +#ifdef WITH_DLP int GetDlpConnectionInfosInner(MessageParcel &data, MessageParcel &reply); +#endif // WITH_DLP int GetConnectionDataInner(MessageParcel &data, MessageParcel &reply); int MoveAbilityToBackgroundInner(MessageParcel &data, MessageParcel &reply); int32_t MoveUIAbilityToBackgroundInner(MessageParcel &data, MessageParcel &reply); diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index bc446fcac5..c25a6253c4 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -540,8 +540,6 @@ public: std::shared_ptr &startOptions, const std::shared_ptr &callerAbility, uint32_t sceneFlag = 0); - bool GrantUriPermissionForServiceExtension(); - void ProcessForegroundAbility(const std::shared_ptr &callerAbility, bool needExit = true, uint32_t sceneFlag = 0); void NotifyAnimationFromTerminatingAbility() const; @@ -554,6 +552,8 @@ public: void SetColdStartFlag(bool isColdStart); #endif + bool GrantUriPermissionForServiceExtension(); + /** * check whether the ability is launcher. * @@ -1021,6 +1021,12 @@ public: void SetSpecifyTokenId(const uint32_t specifyTokenId); + void SaveConnectWant(const Want &want); + + void UpdateConnectWant(); + + void RemoveConnectWant(); + protected: void SendEvent(uint32_t msg, uint32_t timeOut, int32_t param = -1); @@ -1050,8 +1056,10 @@ private: bool IsSystemAbilityCall(const sptr &callerToken, uint32_t callingTokenId = 0); +#ifdef WITH_DLP void HandleDlpAttached(); void HandleDlpClosed(); +#endif // WITH_DLP void NotifyRemoveShellProcess(int32_t type); void NotifyAnimationAbilityDied(); inline void SetCallerAccessTokenId(uint32_t callerAccessTokenId) @@ -1237,6 +1245,9 @@ private: bool isRestartApp_ = false; // Only app calling RestartApp can be set to true uint32_t specifyTokenId_ = 0; + + std::shared_ptr connectWant_ = nullptr; + ffrt::mutex connectWantLock_; }; } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/include/ability_util.h b/services/abilitymgr/include/ability_util.h index 316d125233..f903b68462 100644 --- a/services/abilitymgr/include/ability_util.h +++ b/services/abilitymgr/include/ability_util.h @@ -37,6 +37,8 @@ namespace AbilityUtil { constexpr const char* SYSTEM_BASIC = "system_basic"; constexpr const char* SYSTEM_CORE = "system_core"; constexpr const char* DEFAULT_DEVICE_ID = ""; + +#ifdef WITH_DLP constexpr const char* DLP_BUNDLE_NAME = "com.ohos.dlpmanager"; constexpr const char* DLP_MODULE_NAME = "entry"; constexpr const char* DLP_ABILITY_NAME = "ViewAbility"; @@ -44,6 +46,7 @@ constexpr const char* DLP_PARAMS_SANDBOX = "ohos.dlp.params.sandbox"; constexpr const char* DLP_PARAMS_BUNDLE_NAME = "ohos.dlp.params.bundleName"; constexpr const char* DLP_PARAMS_MODULE_NAME = "ohos.dlp.params.moduleName"; constexpr const char* DLP_PARAMS_ABILITY_NAME = "ohos.dlp.params.abilityName"; +#endif // WITH_DLP constexpr const char* MARKET_BUNDLE_NAME = "com.huawei.hmsapp.appgallery"; constexpr const char* MARKET_CROWD_TEST_BUNDLE_PARAM = "crowd_test_bundle_name"; constexpr const char* BUNDLE_NAME_SELECTOR_DIALOG = "com.ohos.amsdialog"; @@ -211,6 +214,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi return ret == ERR_OK; } +#ifdef WITH_DLP [[maybe_unused]] static bool HandleDlpApp(Want &want) { const std::unordered_set whiteListDlpSet = { BUNDLE_NAME_SELECTOR_DIALOG }; @@ -232,6 +236,7 @@ static constexpr int64_t MICROSECONDS = 1000000; // MICROSECONDS mean 10^6 mi return false; } +#endif // WITH_DLP [[maybe_unused]] static bool IsStartIncludeAtomicService(const Want &want, const int32_t userId) { diff --git a/services/abilitymgr/include/app_scheduler.h b/services/abilitymgr/include/app_scheduler.h index 141532b8ed..d246435ffd 100644 --- a/services/abilitymgr/include/app_scheduler.h +++ b/services/abilitymgr/include/app_scheduler.h @@ -449,6 +449,12 @@ public: bool IsKilledForUpgradeWeb(const std::string &bundleName); + /** + * whether the abilities of process specified by pid type only UIAbility. + * @return Returns true is only UIAbility, otherwise return false + */ + bool IsProcessContainsOnlyUIAbility(const pid_t pid); + protected: /** * OnAbilityRequestDone, app manager service call this interface after ability request done. diff --git a/services/abilitymgr/include/connection_observer_controller.h b/services/abilitymgr/include/connection_observer_controller.h index 63afe18029..60bab43454 100644 --- a/services/abilitymgr/include/connection_observer_controller.h +++ b/services/abilitymgr/include/connection_observer_controller.h @@ -62,6 +62,7 @@ public: */ void NotifyExtensionDisconnected(const AbilityRuntime::ConnectionData& data); +#ifdef WITH_DLP /** * notify observers that dlp ability was opened. * @@ -75,6 +76,7 @@ public: * @param data dlp state data. */ void NotifyDlpAbilityClosed(const AbilityRuntime::DlpStateData& data); +#endif // WITH_DLP private: std::vector> GetObservers(); diff --git a/services/abilitymgr/include/connection_state_manager.h b/services/abilitymgr/include/connection_state_manager.h index 918a5e95a4..4fa539263f 100644 --- a/services/abilitymgr/include/connection_state_manager.h +++ b/services/abilitymgr/include/connection_state_manager.h @@ -24,8 +24,10 @@ #include "application_state_observer_stub.h" #include "connection_state_item.h" #include "connection_observer_controller.h" +#ifdef WITH_DLP #include "dlp_connection_info.h" #include "dlp_state_item.h" +#endif // WITH_DLP namespace OHOS { namespace AAFwk { @@ -113,6 +115,7 @@ public: */ void HandleDataAbilityCallerDied(int32_t callerPid); +#ifdef WITH_DLP /** * add dlp manager to manager. * @@ -140,6 +143,7 @@ public: * @param dlpAbility dlp manager record. */ void RemoveDlpAbility(const std::shared_ptr &dlpAbility); +#endif // WITH_DLP /** * handle app process died. @@ -148,12 +152,14 @@ public: */ void HandleAppDied(int32_t pid); +#ifdef WITH_DLP /** * get exist dlp connection infos. * * @param infos output dlp connection result. */ void GetDlpConnectionInfos(std::vector &infos); +#endif // WITH_DLP /** * Get exist connection data including Extension and Data connection. @@ -201,8 +207,12 @@ private: std::shared_ptr RemoveDiedCaller(int32_t callerPid); void HandleDataAbilityDiedInner(const sptr &abilityToken, std::vector &allData); + +#ifdef WITH_DLP bool HandleDlpAbilityInner(const std::shared_ptr &dlpAbility, bool isAdd, AbilityRuntime::DlpStateData &dlpData); +#endif // WITH_DLP + void InitAppStateObserver(); private: @@ -211,8 +221,10 @@ private: ffrt::mutex stateLock_; std::unordered_map> connectionStates_; +#ifdef WITH_DLP ffrt::mutex dlpLock_; std::unordered_map> dlpItems_; +#endif // WITH_DLP sptr appStateObserver_; std::shared_ptr handler_; diff --git a/services/abilitymgr/include/dlp_utils.h b/services/abilitymgr/include/dlp_utils.h index 8b447d0680..e9176f1365 100644 --- a/services/abilitymgr/include/dlp_utils.h +++ b/services/abilitymgr/include/dlp_utils.h @@ -71,6 +71,7 @@ using Dlp = Security::DlpPermission::DlpPermissionKit; return true; } +#ifdef WITH_DLP [[maybe_unused]]static bool OtherAppsAccessDlpCheck(const sptr &callerToken, const Want &want) { int32_t dlpIndex = want.GetIntParam(AbilityRuntime::ServerConstant::DLP_INDEX, 0); @@ -88,6 +89,7 @@ using Dlp = Security::DlpPermission::DlpPermissionKit; return PermissionVerification::GetInstance()->VerifyDlpPermission(const_cast(want)); } +#endif // WITH_DLP_ [[maybe_unused]]static bool SandboxAuthCheck(const AbilityRecord &callerRecord, const Want &want) { diff --git a/services/abilitymgr/include/start_ability_handler.h b/services/abilitymgr/include/start_ability_handler.h index e2f83728ff..54c511f025 100644 --- a/services/abilitymgr/include/start_ability_handler.h +++ b/services/abilitymgr/include/start_ability_handler.h @@ -45,9 +45,12 @@ struct StartAbilityParams { validUserId = value; } bool IsCallerSandboxApp(); + +#ifdef WITH_DLP bool OtherAppsAccessDlp(); bool DlpAccessOtherApps(); bool SandboxExternalAuth(); +#endif // WITH_DLP bool IsCallerSysApp(); std::shared_ptr GetCallerRecord(); int32_t GetCallerAppIndex(); @@ -55,8 +58,10 @@ struct StartAbilityParams { EventInfo BuildEventInfo(); private: int32_t validUserId = 0; +#ifdef WITH_DLP std::optional otherAppsAccessDlp; std::optional dlpAccessOtherApps; +#endif // WITH_DLP std::optional sandboxExternalAuth; std::optional isCallerSysApp; std::optional> callerRecord; diff --git a/services/abilitymgr/src/ability_connect_manager.cpp b/services/abilitymgr/src/ability_connect_manager.cpp index 4bef22cae2..62eaff264f 100644 --- a/services/abilitymgr/src/ability_connect_manager.cpp +++ b/services/abilitymgr/src/ability_connect_manager.cpp @@ -269,10 +269,12 @@ int AbilityConnectManager::StartAbilityLocked(const AbilityRequest &abilityReque if (IsUIExtensionAbility(targetService)) { targetService->SetLaunchReason(LaunchReason::LAUNCHREASON_START_ABILITY); } + targetService->GrantUriPermissionForServiceExtension(); LoadAbility(targetService); } else if (targetService->IsAbilityState(AbilityState::ACTIVE) && !IsUIExtensionAbility(targetService)) { // It may have been started through connect targetService->SetWant(abilityRequest.want); + targetService->GrantUriPermissionForServiceExtension(); CommandAbility(targetService); } else if (IsUIExtensionAbility(targetService)) { DoForegroundUIExtension(targetService, abilityRequest); @@ -684,7 +686,8 @@ int AbilityConnectManager::ConnectAbilityLocked(const AbilityRequest &abilityReq targetService->SetWant(abilityRequest.want); HandleActiveAbility(targetService, connectRecord); } else { - TAG_LOGD(AAFwkTag::ABILITYMGR, "Target service is activating, wait for callback"); + TAG_LOGI(AAFwkTag::ABILITYMGR, "Target service is activating, wait for callback"); + targetService->SaveConnectWant(abilityRequest.want); } auto token = targetService->GetToken(); @@ -1027,6 +1030,7 @@ int AbilityConnectManager::ScheduleConnectAbilityDoneLocked( abilityRecord->GetAbilityState()); return INVALID_CONNECTION_STATE; } + abilityRecord->RemoveConnectWant(); if (abilityRecord->GetAbilityInfo().type == AbilityType::SERVICE) { DelayedSingleton::GetInstance()->UpdateAbilityState( @@ -1695,6 +1699,7 @@ int AbilityConnectManager::DispatchInactive(const std::shared_ptr CommandAbility(abilityRecord); if (abilityRecord->GetConnectRecordList().size() > 0) { // It means someone called connectAbility when service was loading + abilityRecord->UpdateConnectWant(); ConnectAbility(abilityRecord); } } diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index 6539b4750e..014cb1e3e8 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -56,7 +56,9 @@ #include "connection_state_manager.h" #include "display_manager.h" #include "distributed_client.h" +#ifdef WITH_DLP #include "dlp_utils.h" +#endif // WITH_DLP #include "errors.h" #include "extension_config.h" #include "freeze_util.h" @@ -596,7 +598,7 @@ int AbilityManagerService::StartAbilityWithSpecifyTokenId(const Want &want, cons } int AbilityManagerService::StartAbilityWithSpecifyTokenIdInner(const Want &want, const sptr &callerToken, - uint32_t specifyTokenId, int32_t userId, int requestCode) + uint32_t specifyTokenId, int32_t userId, int requestCode, bool isPendingWantCaller) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); InsightIntentExecuteParam::RemoveInsightIntent(const_cast(want)); @@ -615,7 +617,7 @@ int AbilityManagerService::StartAbilityWithSpecifyTokenIdInner(const Want &want, "Start ability come, ability is %{public}s, userId is %{public}d, specifyTokenId is %{public}u.", want.GetElement().GetAbilityName().c_str(), userId, specifyTokenId); - int32_t ret = StartAbilityWrap(want, callerToken, requestCode, userId, false, specifyTokenId); + int32_t ret = StartAbilityWrap(want, callerToken, requestCode, userId, false, specifyTokenId, isPendingWantCaller); if (ret != ERR_OK) { eventInfo.errCode = ret; SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); @@ -624,11 +626,13 @@ int AbilityManagerService::StartAbilityWithSpecifyTokenIdInner(const Want &want, } int AbilityManagerService::StartAbilityWithSpecifyTokenIdInner(const Want &want, const StartOptions &startOptions, - const sptr &callerToken, int32_t userId, int requestCode, uint32_t callerTokenId) + const sptr &callerToken, int32_t userId, int requestCode, + uint32_t callerTokenId, bool isPendingWantCaller) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Start ability with startOptions by trigger."); AbilityUtil::RemoveShowModeKey(const_cast(want)); - return StartUIAbilityForOptionWrap(want, startOptions, callerToken, userId, requestCode, callerTokenId); + return StartUIAbilityForOptionWrap(want, startOptions, + callerToken, userId, requestCode, callerTokenId, isPendingWantCaller); } int32_t AbilityManagerService::StartAbilityByInsightIntent(const Want &want, const sptr &callerToken, @@ -841,7 +845,7 @@ bool AbilityManagerService::StartAbilityInChain(StartAbilityParams ¶ms, int int AbilityManagerService::StartAbilityWrap(const Want &want, const sptr &callerToken, int requestCode, int32_t userId, bool isStartAsCaller, uint32_t specifyToken, - bool isForegroundToRestartApp, bool isImplicit) + bool isForegroundToRestartApp, bool isImplicit, bool isPendingWantCaller) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); StartAbilityParams startParams(const_cast(want)); @@ -857,7 +861,7 @@ int AbilityManagerService::StartAbilityWrap(const Want &want, const sptr &callerToken, int requestCode, int32_t userId, bool isStartAsCaller, uint32_t specifyTokenId, - bool isForegroundToRestartApp, bool isImplicit) + bool isForegroundToRestartApp, bool isImplicit, bool isPendingWantCaller) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); // prevent the app from dominating the screen @@ -990,6 +994,7 @@ int AbilityManagerService::StartAbilityInner(const Want &want, const sptr(want)); @@ -1299,6 +1305,7 @@ int AbilityManagerService::StartAbilityDetails(const Want &want, const AbilitySt EventInfo eventInfo = BuildEventInfo(want, userId); SendAbilityEvent(EventName::START_ABILITY, HiSysEventType::BEHAVIOR, eventInfo); +#ifdef WITH_DLP if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, want) || VerifyAccountPermission(userId) == CHECK_PERMISSION_FAILED || !DlpUtils::DlpAccessOtherAppsCheck(callerToken, want)) { @@ -1307,6 +1314,7 @@ int AbilityManagerService::StartAbilityDetails(const Want &want, const AbilitySt SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); return CHECK_PERMISSION_FAILED; } +#endif // WITH_DLP if (callerToken != nullptr && !VerificationAllToken(callerToken)) { eventInfo.errCode = ERR_INVALID_VALUE; @@ -1483,7 +1491,7 @@ int AbilityManagerService::ImplicitStartAbility(const Want &want, const StartOpt int AbilityManagerService::StartUIAbilityForOptionWrap(const Want &want, const StartOptions &options, sptr callerToken, int32_t userId, int requestCode, uint32_t callerTokenId, bool isImplicit, - bool isCallByShortcut) + bool isCallByShortcut, bool isPendingWantCaller) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); auto ret = CheckProcessOptions(want, options, userId); @@ -1491,7 +1499,7 @@ int AbilityManagerService::StartUIAbilityForOptionWrap(const Want &want, const S return ret; } return StartAbilityForOptionWrap(want, options, callerToken, userId, requestCode, false, - callerTokenId, isImplicit, isCallByShortcut); + callerTokenId, isImplicit, isCallByShortcut, isPendingWantCaller); } int AbilityManagerService::StartAbilityAsCaller(const Want &want, const StartOptions &startOptions, @@ -1538,7 +1546,7 @@ int AbilityManagerService::StartAbilityForResultAsCaller(const Want &want, const int AbilityManagerService::StartAbilityForOptionWrap(const Want &want, const StartOptions &startOptions, const sptr &callerToken, int32_t userId, int requestCode, bool isStartAsCaller, - uint32_t callerTokenId, bool isImplicit, bool isCallByShortcut) + uint32_t callerTokenId, bool isImplicit, bool isCallByShortcut, bool isPendingWantCaller) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); StartAbilityParams startParams(const_cast(want)); @@ -1555,12 +1563,12 @@ int AbilityManagerService::StartAbilityForOptionWrap(const Want &want, const Sta } return StartAbilityForOptionInner(want, startOptions, callerToken, userId, requestCode, isStartAsCaller, - callerTokenId, isImplicit, isCallByShortcut); + callerTokenId, isImplicit, isCallByShortcut, isPendingWantCaller); } int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const StartOptions &startOptions, const sptr &callerToken, int32_t userId, int requestCode, bool isStartAsCaller, - uint32_t specifyTokenId, bool isImplicit, bool isCallByShortcut) + uint32_t specifyTokenId, bool isImplicit, bool isCallByShortcut, bool isPendingWantCaller) { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); bool startWithAccount = want.GetBoolParam(START_ABILITY_TYPE, false); @@ -1572,6 +1580,7 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St EventInfo eventInfo = BuildEventInfo(want, userId); SendAbilityEvent(EventName::START_ABILITY, HiSysEventType::BEHAVIOR, eventInfo); +#ifdef WITH_DLP if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, want) || VerifyAccountPermission(userId) == CHECK_PERMISSION_FAILED || !DlpUtils::DlpAccessOtherAppsCheck(callerToken, want)) { @@ -1580,6 +1589,7 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St SendAbilityEvent(EventName::START_ABILITY_ERROR, HiSysEventType::FAULT, eventInfo); return CHECK_PERMISSION_FAILED; } +#endif // WITH_DLP if (callerToken != nullptr && !VerificationAllToken(callerToken)) { eventInfo.errCode = ERR_INVALID_VALUE; @@ -1850,6 +1860,7 @@ int32_t AbilityManagerService::RequestDialogServiceInner(const Want &want, const } { +#ifdef WITH_DLP HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, "CHECK_DLP"); if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, want) || !DlpUtils::DlpAccessOtherAppsCheck(callerToken, want)) { @@ -1861,6 +1872,7 @@ int32_t AbilityManagerService::RequestDialogServiceInner(const Want &want, const TAG_LOGE(AAFwkTag::ABILITYMGR, "Cannot handle dlp by RequestDialogService."); return ERR_WRONG_INTERFACE_CALL; } +#endif // WITH_DLP } AbilityUtil::RemoveShowModeKey(const_cast(want)); @@ -2644,12 +2656,15 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp } EventInfo eventInfo = BuildEventInfo(want, userId); eventInfo.extensionType = static_cast(extensionType); - - auto result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::START_EXTENSION_ERROR); + + int result; +#ifdef WITH_DLP + result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::START_EXTENSION_ERROR); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "CheckDlpForExtension error."); return result; } +#endif // WITH_DLP if (callerToken != nullptr && !VerificationAllToken(callerToken)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s VerificationAllToken failed.", __func__); @@ -2713,6 +2728,7 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp TAG_LOGD(AAFwkTag::ABILITYMGR, "userId is : %{public}d, singleton is : %{public}d", validUserId, static_cast(abilityInfo.applicationInfo.singleton)); +#ifdef WITH_DLP result = isDlp ? IN_PROCESS_CALL( CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, isImplicit)) : CheckOptExtensionAbility(want, abilityRequest, validUserId, extensionType, isImplicit); @@ -2722,6 +2738,7 @@ int AbilityManagerService::StartExtensionAbilityInner(const Want &want, const sp EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return result; } +#endif // WITH_DLP AbilityInterceptorParam afterCheckParam = AbilityInterceptorParam(abilityRequest.want, 0, GetUserId(), false, callerToken, std::make_shared(abilityInfo)); @@ -2902,6 +2919,7 @@ int AbilityManagerService::StartUIExtensionAbility(const sptr &exte sptr callerToken = extensionSessionInfo->callerToken; +#ifdef WITH_DLP if (!DlpUtils::OtherAppsAccessDlpCheck(callerToken, extensionSessionInfo->want) || VerifyAccountPermission(userId) == CHECK_PERMISSION_FAILED || !DlpUtils::DlpAccessOtherAppsCheck(callerToken, extensionSessionInfo->want)) { @@ -2910,6 +2928,7 @@ int AbilityManagerService::StartUIExtensionAbility(const sptr &exte EventReport::SendExtensionEvent(EventName::START_EXTENSION_ERROR, HiSysEventType::FAULT, eventInfo); return CHECK_PERMISSION_FAILED; } +#endif // WITH_DLP if (callerToken != nullptr && !VerificationAllToken(callerToken)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "StartUIExtensionAbility VerificationAllToken failed."); @@ -3035,12 +3054,15 @@ int AbilityManagerService::StopExtensionAbility(const Want &want, const sptr(extensionType); - - auto result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::STOP_EXTENSION_ERROR); + + int result; +#ifdef WITH_DLP + result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::STOP_EXTENSION_ERROR); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "CheckDlpForExtension error."); return result; } +#endif // WITH_DLP if (callerToken != nullptr && !VerificationAllToken(callerToken)) { TAG_LOGE(AAFwkTag::ABILITYMGR, "%{public}s VerificationAllToken failed.", __func__); @@ -3635,14 +3657,17 @@ int AbilityManagerService::ConnectAbilityCommon( CHECK_CALLER_IS_SYSTEM_APP; } EventInfo eventInfo = BuildEventInfo(want, userId); - - auto result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::CONNECT_SERVICE_ERROR); + + int result; +#ifdef WITH_DLP + result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::CONNECT_SERVICE_ERROR); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "CheckDlpForExtension error."); eventInfo.errCode = result; EventReport::SendExtensionEvent(EventName::CONNECT_SERVICE_ERROR, HiSysEventType::FAULT, eventInfo); return result; } +#endif // WITH_DLP AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, 0, GetUserId(), false, nullptr); result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE : @@ -3747,14 +3772,17 @@ int AbilityManagerService::ConnectUIExtensionAbility(const Want &want, const spt EventReport::SendExtensionEvent(EventName::CONNECT_SERVICE_ERROR, HiSysEventType::FAULT, eventInfo); return ERR_INVALID_CALLER; } - - auto result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::CONNECT_SERVICE_ERROR); + + int result; +#ifdef WITH_DLP + result = CheckDlpForExtension(want, callerToken, userId, eventInfo, EventName::CONNECT_SERVICE_ERROR); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "CheckDlpForExtension error."); eventInfo.errCode = result; EventReport::SendExtensionEvent(EventName::CONNECT_SERVICE_ERROR, HiSysEventType::FAULT, eventInfo); return result; } +#endif // WITH_DLP AbilityInterceptorParam interceptorParam = AbilityInterceptorParam(want, 0, GetUserId(), false, nullptr); result = interceptorExecuter_ == nullptr ? ERR_INVALID_VALUE : @@ -4196,6 +4224,7 @@ int AbilityManagerService::UnregisterObserver(const sptr::GetInstance()->UnregisterObserver(observer); } +#ifdef WITH_DLP int AbilityManagerService::GetDlpConnectionInfos(std::vector &infos) { if (!AAFwk::PermissionVerification::GetInstance()->IsSACall()) { @@ -4206,6 +4235,7 @@ int AbilityManagerService::GetDlpConnectionInfos(std::vector &connectionData) { @@ -7989,18 +8019,25 @@ void AbilityManagerService::UpdateCallerInfo(Want& want, const sptrGetNameForUid(callerUid, bundleName)); } + if (bundleName == "") { + Security::AccessToken::NativeTokenInfo nativeTokenInfo; + int32_t result = Security::AccessToken::AccessTokenKit::GetNativeTokenInfo(tokenId, nativeTokenInfo); + if (result == ERR_OK) { + bundleName = "_" + nativeTokenInfo.processName; + } + } want.RemoveParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME); want.SetParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME, bundleName); want.RemoveParam(Want::PARAM_RESV_CALLER_ABILITY_NAME); want.SetParam(Want::PARAM_RESV_CALLER_ABILITY_NAME, std::string("")); - } else { - std::string callerBundleName = abilityRecord->GetAbilityInfo().bundleName; - want.RemoveParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME); - want.SetParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME, callerBundleName); - std::string callerAbilityName = abilityRecord->GetAbilityInfo().name; - want.RemoveParam(Want::PARAM_RESV_CALLER_ABILITY_NAME); - want.SetParam(Want::PARAM_RESV_CALLER_ABILITY_NAME, callerAbilityName); + return; } + std::string callerBundleName = abilityRecord->GetAbilityInfo().bundleName; + want.RemoveParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME); + want.SetParam(Want::PARAM_RESV_CALLER_BUNDLE_NAME, callerBundleName); + std::string callerAbilityName = abilityRecord->GetAbilityInfo().name; + want.RemoveParam(Want::PARAM_RESV_CALLER_ABILITY_NAME); + want.SetParam(Want::PARAM_RESV_CALLER_ABILITY_NAME, callerAbilityName); } void AbilityManagerService::UpdateAsCallerSourceInfo(Want& want, sptr asCallerSourceToken, @@ -9037,6 +9074,14 @@ int AbilityManagerService::CheckCallServiceExtensionPermission(const AbilityRequ verificationInfo.visible = abilityRequest.abilityInfo.visible; verificationInfo.withContinuousTask = IsBackgroundTaskUid(IPCSkeleton::GetCallingUid()); verificationInfo.isBackgroundCall = false; + if (isParamStartAbilityEnable_) { + bool stopContinuousTaskFlag = ShouldPreventStartAbility(abilityRequest); + if (stopContinuousTaskFlag) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "Do not have permission to start ServiceExtension"); + return CHECK_PERMISSION_FAILED; + } + } + int result = AAFwk::PermissionVerification::GetInstance()->CheckCallServiceExtensionPermission(verificationInfo); if (result != ERR_OK) { TAG_LOGE(AAFwkTag::ABILITYMGR, "Do not have permission to start ServiceExtension or DataShareExtension"); @@ -9395,6 +9440,7 @@ int AbilityManagerService::AddStartControlParam(Want &want, const sptr &callerToken, int32_t userId, EventInfo &eventInfo, const EventName &eventName) @@ -9417,6 +9463,7 @@ int AbilityManagerService::CheckDlpForExtension( } return ERR_OK; } +#endif // WITH_DLP bool AbilityManagerService::JudgeSelfCalled(const std::shared_ptr &abilityRecord) { @@ -9614,11 +9661,13 @@ int32_t AbilityManagerService::NotifySaveAsResult(const Want &want, int resultCo { TAG_LOGD(AAFwkTag::ABILITYMGR, "requestCode is %{public}d.", requestCode); +#ifdef WITH_DLP //caller check if (!DlpUtils::CheckCallerIsDlpManager(GetBundleManager())) { TAG_LOGW(AAFwkTag::ABILITYMGR, "caller check failed"); return CHECK_PERMISSION_FAILED; } +#endif // WITH_DLP for (const auto &item : startAbilityChain_) { if (item.second->GetHandlerName() == StartAbilitySandboxSavefile::handlerName_) { @@ -10797,15 +10846,20 @@ bool AbilityManagerService::ShouldPreventStartAbility(const AbilityRequest &abil TAG_LOGD(AAFwkTag::ABILITYMGR, "No matched token pass"); return false; } + auto abilityInfo = abilityRequest.abilityInfo; + auto callerAbilityInfo = abilityRecord->GetAbilityInfo(); + PrintStartAbilityInfo(callerAbilityInfo, abilityInfo); if (abilityRecord->GetApplicationInfo().apiTargetVersion % API_VERSION_MOD < API12) { TAG_LOGD(AAFwkTag::ABILITYMGR, "API version %{public}d pass", abilityRecord->GetApplicationInfo().apiTargetVersion % API_VERSION_MOD); return false; } - auto abilityInfo = abilityRequest.abilityInfo; - auto callerAbilityInfo = abilityRecord->GetAbilityInfo(); - bool continuousFlag = false; - continuousFlag = IsBackgroundTaskUid(IPCSkeleton::GetCallingUid()); + bool continuousFlag = IsBackgroundTaskUid(IPCSkeleton::GetCallingUid()); + if(!IN_PROCESS_CALL(DelayedSingleton::GetInstance()-> + IsProcessContainsOnlyUIAbility(abilityRecord->GetPid()))) { + TAG_LOGD(AAFwkTag::ABILITYMGR, "Process has other extension except UIAbility, pass"); + return false; + } if (abilityInfo.extensionAbilityType != AppExecFwk::ExtensionAbilityType::DATASHARE && abilityInfo.extensionAbilityType != AppExecFwk::ExtensionAbilityType::SERVICE) { TAG_LOGD(AAFwkTag::ABILITYMGR, "Process did not call service or datashare extension Pass"); @@ -10837,6 +10891,44 @@ bool AbilityManagerService::ShouldPreventStartAbility(const AbilityRequest &abil return true; } +void AbilityManagerService::PrintStartAbilityInfo(AppExecFwk::AbilityInfo callerInfo, AppExecFwk::AbilityInfo calledInfo) +{ + TAG_LOGD(AAFwkTag::ABILITYMGR, "calledAbilityInfo toString: " + "calledUid is: %{public}d, " + "name is: %{public}s, " + "bundleName is: %{public}s, " + "type is: %{public}d, " + "extensionAbilityType is: %{public}d, " + "moduleName is: %{public}s, " + "applicationName is: %{public}s", + calledInfo.applicationInfo.uid, + calledInfo.name.c_str(), + calledInfo.bundleName.c_str(), + static_cast(calledInfo.type), + static_cast(calledInfo.extensionAbilityType), + calledInfo.moduleName.c_str(), + calledInfo.applicationName.c_str()); + + + TAG_LOGD(AAFwkTag::ABILITYMGR, "callerAbilityInfo toString: " + "callerUid is: %{public}d, " + "callerPid is: %{public}d, " + "name is: %{public}s, " + "bundleName is: %{public}s, " + "type is: %{public}d, " + "extensionAbilityType is: %{public}d, " + "moduleName is: %{public}s, " + "applicationName is: %{public}s", + IPCSkeleton::GetCallingUid(), + IPCSkeleton::GetCallingPid(), + callerInfo.name.c_str(), + callerInfo.bundleName.c_str(), + static_cast(callerInfo.type), + static_cast(callerInfo.extensionAbilityType), + callerInfo.moduleName.c_str(), + callerInfo.applicationName.c_str()); +} + void AbilityManagerService::ReportPreventStartAbilityResult(const AppExecFwk::AbilityInfo &callerAbilityInfo, const AppExecFwk::AbilityInfo &abilityInfo) { diff --git a/services/abilitymgr/src/ability_manager_stub.cpp b/services/abilitymgr/src/ability_manager_stub.cpp index 4ab0bb3829..16bfb2d041 100644 --- a/services/abilitymgr/src/ability_manager_stub.cpp +++ b/services/abilitymgr/src/ability_manager_stub.cpp @@ -519,9 +519,11 @@ int AbilityManagerStub::OnRemoteRequestInnerThirteenth(uint32_t code, MessagePar if (interfaceCode == AbilityManagerInterfaceCode::UNREGISTER_CONNECTION_OBSERVER) { return UnregisterConnectionObserverInner(data, reply); } +#ifdef WITH_DLP if (interfaceCode == AbilityManagerInterfaceCode::GET_DLP_CONNECTION_INFOS) { return GetDlpConnectionInfosInner(data, reply); } +#endif // WITH_DLP if (interfaceCode == AbilityManagerInterfaceCode::MOVE_ABILITY_TO_BACKGROUND) { return MoveAbilityToBackgroundInner(data, reply); } @@ -2623,11 +2625,13 @@ int AbilityManagerStub::UnregisterObserver(const sptr &infos) { // should implement in child return NO_ERROR; } +#endif // WITH_DLP int AbilityManagerStub::GetConnectionData(std::vector &infos) { @@ -2919,6 +2923,7 @@ int AbilityManagerStub::UnregisterConnectionObserverInner(MessageParcel &data, M return UnregisterObserver(observer); } +#ifdef WITH_DLP int AbilityManagerStub::GetDlpConnectionInfosInner(MessageParcel &data, MessageParcel &reply) { std::vector infos; @@ -2942,6 +2947,7 @@ int AbilityManagerStub::GetDlpConnectionInfosInner(MessageParcel &data, MessageP return ERR_OK; } +#endif // WITH_DLP int AbilityManagerStub::GetConnectionDataInner(MessageParcel &data, MessageParcel &reply) { diff --git a/services/abilitymgr/src/ability_record.cpp b/services/abilitymgr/src/ability_record.cpp index 49791e11a7..1008ccbe6e 100644 --- a/services/abilitymgr/src/ability_record.cpp +++ b/services/abilitymgr/src/ability_record.cpp @@ -84,7 +84,9 @@ const std::string DMS_SRC_NETWORK_ID = "dmsSrcNetworkId"; const std::string ABILITY_OWNER_USERID = "AbilityMS_Owner_UserId"; const std::u16string SYSTEM_ABILITY_TOKEN_CALLBACK = u"ohos.aafwk.ISystemAbilityTokenCallback"; const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen"; +#ifdef WITH_DLP const std::string DLP_BUNDLE_NAME = "com.ohos.dlpmanager"; +#endif // WITH_DLP const std::string COMPONENT_STARTUP_NEW_RULES = "component.startup.newRules"; const std::string KEY_MISSION_ID = "ohos.anco.param.missionId"; const std::string NEED_STARTINGWINDOW = "ohos.ability.NeedStartingWindow"; @@ -1256,7 +1258,9 @@ int AbilityRecord::TerminateAbility() { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); TAG_LOGI(AAFwkTag::ABILITYMGR, "ability:%{public}s.", abilityInfo_.name.c_str()); +#ifdef WITH_DLP HandleDlpClosed(); +#endif // WITH_DLP AAFwk::EventInfo eventInfo; eventInfo.bundleName = GetAbilityInfo().bundleName; eventInfo.abilityName = GetAbilityInfo().name; @@ -1440,7 +1444,9 @@ void AbilityRecord::SetScheduler(const sptr &scheduler) pid_ = static_cast(IPCSkeleton::GetCallingPid()); // set pid when ability attach to service. // add collaborator mission bind pid NotifyMissionBindPid(); +#ifdef WITH_DLP HandleDlpAttached(); +#endif // WITH_DLP } else { TAG_LOGE(AAFwkTag::ABILITYMGR, "scheduler is nullptr"); isReady_ = false; @@ -1598,7 +1604,9 @@ void AbilityRecord::Terminate(const Closure &task) } else { TAG_LOGI(AAFwkTag::ABILITYMGR, "Is debug mode, no need to handle time out."); } +#ifdef WITH_DLP HandleDlpClosed(); +#endif // WITH_DLP // schedule background after updating AbilityState and sending timeout message to avoid ability async callback // earlier than above actions. #ifdef SUPPORT_SCREEN @@ -1627,9 +1635,7 @@ void AbilityRecord::ConnectAbility() if (isConnected) { TAG_LOGW(AAFwkTag::ABILITYMGR, "connect state error."); } -#ifdef SUPPORT_SCREEN GrantUriPermissionForServiceExtension(); -#endif // SUPPORT_SCREEN lifecycleDeal_->ConnectAbility(GetWant()); isConnected = true; } @@ -1641,9 +1647,7 @@ void AbilityRecord::ConnectUIServiceExtAbility(const Want &want) if (isConnected) { TAG_LOGW(AAFwkTag::ABILITYMGR, "connect state error."); } -#ifdef SUPPORT_SCREEN GrantUriPermissionForServiceExtension(); -#endif // SUPPORT_SCREEN lifecycleDeal_->ConnectAbility(want); isConnected = true; } @@ -1674,7 +1678,6 @@ void AbilityRecord::DisconnectUIServiceExtAbility(const Want &want) } } -#ifdef SUPPORT_SCREEN bool AbilityRecord::GrantUriPermissionForServiceExtension() { if (abilityInfo_.extensionAbilityType == AppExecFwk::ExtensionAbilityType::SERVICE) { @@ -1688,14 +1691,11 @@ bool AbilityRecord::GrantUriPermissionForServiceExtension() } return false; } -#endif // SUPPORT_SCREEN + void AbilityRecord::CommandAbility() { TAG_LOGD(AAFwkTag::ABILITYMGR, "startId_:%{public}d.", startId_); CHECK_POINTER(lifecycleDeal_); -#ifdef SUPPORT_SCREEN - GrantUriPermissionForServiceExtension(); -#endif // SUPPORT_SCREEN lifecycleDeal_->CommandAbility(GetWant(), false, startId_); } @@ -2440,7 +2440,9 @@ void AbilityRecord::OnSchedulerDied(const wptr &remote) #ifdef SUPPORT_GRAPHICS NotifyAnimationAbilityDied(); #endif +#ifdef WITH_DLP HandleDlpClosed(); +#endif // WITH_DLP NotifyRemoveShellProcess(CollaboratorType::RESERVE_TYPE); NotifyRemoveShellProcess(CollaboratorType::OTHERS_TYPE); FreezeUtil::GetInstance().DeleteLifecycleEvent(object); @@ -2475,7 +2477,9 @@ void AbilityRecord::OnProcessDied() #ifdef SUPPORT_GRAPHICS NotifyAnimationAbilityDied(); #endif +#ifdef WITH_DLP HandleDlpClosed(); +#endif // WITH_DLP NotifyRemoveShellProcess(CollaboratorType::RESERVE_TYPE); NotifyRemoveShellProcess(CollaboratorType::OTHERS_TYPE); } @@ -3266,6 +3270,7 @@ void AbilityRecord::RevokeUriPermission() } } +#ifdef WITH_DLP void AbilityRecord::HandleDlpAttached() { if (abilityInfo_.bundleName == DLP_BUNDLE_NAME) { @@ -3287,6 +3292,7 @@ void AbilityRecord::HandleDlpClosed() DelayedSingleton::GetInstance()->RemoveDlpAbility(shared_from_this()); } } +#endif // WITH_DLP void AbilityRecord::NotifyRemoveShellProcess(int32_t type) { @@ -3573,5 +3579,27 @@ void AbilityRecord::SetDebugAppByWaitingDebugFlag(Want &requestWant, const std:: DelayedSingleton::GetInstance()->ClearNonPersistWaitingDebugFlag()); } } + +void AbilityRecord::SaveConnectWant(const Want &want) +{ + std::lock_guard guard(connectWantLock_); + if (connectWant_ == nullptr) { + connectWant_ = std::make_shared(want); + } +} + +void AbilityRecord::UpdateConnectWant() +{ + std::lock_guard guard(connectWantLock_); + if (connectWant_ != nullptr) { + SetWant(*connectWant_); + } +} + +void AbilityRecord::RemoveConnectWant() +{ + std::lock_guard guard(connectWantLock_); + connectWant_.reset(); +} } // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/app_scheduler.cpp b/services/abilitymgr/src/app_scheduler.cpp index 0109f3187f..e89b45b599 100644 --- a/services/abilitymgr/src/app_scheduler.cpp +++ b/services/abilitymgr/src/app_scheduler.cpp @@ -630,5 +630,13 @@ bool AppScheduler::IsKilledForUpgradeWeb(const std::string &bundleName) } return appMgrClient_->IsKilledForUpgradeWeb(bundleName); } -} // namespace AAFwk +bool AppScheduler::IsProcessContainsOnlyUIAbility(const pid_t pid) +{ + if (!appMgrClient_) { + TAG_LOGE(AAFwkTag::ABILITYMGR, "appMgrClient is nullptr"); + return false; + } + return appMgrClient_->IsProcessContainsOnlyUIAbility(pid); +} +} // namespace AAFwk } // namespace OHOS diff --git a/services/abilitymgr/src/connection_observer_controller.cpp b/services/abilitymgr/src/connection_observer_controller.cpp index 52cbe86dab..6a6602cc4e 100644 --- a/services/abilitymgr/src/connection_observer_controller.cpp +++ b/services/abilitymgr/src/connection_observer_controller.cpp @@ -82,6 +82,7 @@ void ConnectionObserverController::NotifyExtensionDisconnected(const AbilityRunt CallObservers(&AbilityRuntime::IConnectionObserver::OnExtensionDisconnected, data); } +#ifdef WITH_DLP void ConnectionObserverController::NotifyDlpAbilityOpened(const AbilityRuntime::DlpStateData& data) { CallObservers(&AbilityRuntime::IConnectionObserver::OnDlpAbilityOpened, data); @@ -91,6 +92,7 @@ void ConnectionObserverController::NotifyDlpAbilityClosed(const AbilityRuntime:: { CallObservers(&AbilityRuntime::IConnectionObserver::OnDlpAbilityClosed, data); } +#endif // WITH_DLP std::vector> ConnectionObserverController::GetObservers() { diff --git a/services/abilitymgr/src/connection_state_manager.cpp b/services/abilitymgr/src/connection_state_manager.cpp index 790d5315a3..24db3de340 100644 --- a/services/abilitymgr/src/connection_state_manager.cpp +++ b/services/abilitymgr/src/connection_state_manager.cpp @@ -230,6 +230,7 @@ void ConnectionStateManager::HandleDataAbilityCallerDied(int32_t callerPid) HandleCallerDied(callerPid); } +#ifdef WITH_DLP void ConnectionStateManager::AddDlpManager(const std::shared_ptr &dlpManger) { if (!dlpManger) { @@ -283,12 +284,14 @@ void ConnectionStateManager::RemoveDlpAbility(const std::shared_ptrNotifyDlpAbilityClosed(dlpData); } +#endif // WITH_DLP void ConnectionStateManager::HandleAppDied(int32_t pid) { HandleCallerDied(pid); } +#ifdef WITH_DLP void ConnectionStateManager::GetDlpConnectionInfos(std::vector &infos) { std::lock_guard guard(dlpLock_); @@ -304,6 +307,7 @@ void ConnectionStateManager::GetDlpConnectionInfos(std::vector &connectionData) { @@ -478,6 +482,7 @@ void ConnectionStateManager::HandleDataAbilityDiedInner(const sptr &dlpAbility, bool isAdd, AbilityRuntime::DlpStateData &dlpData) { @@ -510,6 +515,7 @@ bool ConnectionStateManager::HandleDlpAbilityInner(const std::shared_ptrRemoveDlpConnectionState(dlpAbility, dlpData); } +#endif // WITH_DLP void ConnectionStateManager::InitAppStateObserver() { diff --git a/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp b/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp index 06170ed9ed..df95d3b5ee 100644 --- a/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp +++ b/services/abilitymgr/src/dialog_session/dialog_session_manager.cpp @@ -307,7 +307,7 @@ int DialogSessionManager::CreateCloneSelectorModalDialog(AbilityRequest &ability parameters.SetParam("appselector.selectorType", AAFwk::Integer::Box(static_cast(SelectorType::APP_CLONR_SELECTOR))); if (replaceWant != "") { - parameters.SetParam("replaceWant", AAFwk::String::Box(replaceWant)); + parameters.SetParam("ecological.replaceWant", AAFwk::String::Box(replaceWant)); } std::string dialogSessionId = GenerateDialogSessionRecordCommon(abilityRequest, userId, parameters, @@ -376,6 +376,7 @@ int DialogSessionManager::HandleErmsResult(AbilityRequest &abilityRequest, int32 TAG_LOGE(AAFwkTag::ABILITYMGR, "abilityMgr is nullptr."); return INNER_ERR; } + (const_cast(replaceWant)).RemoveParam("ecological_experience_original_target"); return abilityMgr->CreateCloneSelectorDialog(abilityRequest, userId, replaceWant.ToString()); } diff --git a/services/abilitymgr/src/implicit_start_processor.cpp b/services/abilitymgr/src/implicit_start_processor.cpp index 16ded7359a..03be99e743 100644 --- a/services/abilitymgr/src/implicit_start_processor.cpp +++ b/services/abilitymgr/src/implicit_start_processor.cpp @@ -264,6 +264,7 @@ std::string ImplicitStartProcessor::MatchTypeAndUri(const AAFwk::Want &want) return ""; } type = uri.substr(suffixIndex); +#ifdef WITH_DLP if (type == ".dlp") { auto suffixDlpIndex = uri.rfind('.', suffixIndex - 1); if (suffixDlpIndex == std::string::npos) { @@ -272,6 +273,7 @@ std::string ImplicitStartProcessor::MatchTypeAndUri(const AAFwk::Want &want) } type = uri.substr(suffixDlpIndex, suffixIndex - suffixDlpIndex); } +#endif // WITH_DLP } return type; } diff --git a/services/abilitymgr/src/pending_want_manager.cpp b/services/abilitymgr/src/pending_want_manager.cpp index 12f8371013..edc16bc770 100644 --- a/services/abilitymgr/src/pending_want_manager.cpp +++ b/services/abilitymgr/src/pending_want_manager.cpp @@ -252,7 +252,7 @@ int32_t PendingWantManager::DeviceIdDetermine(const Want &want, const sptr::GetInstance()->StartAbilityWithSpecifyTokenIdInner( - want, callerToken, callerTokenId, requestCode, callerUid); + want, callerToken, callerTokenId, requestCode, callerUid, true); } else { TAG_LOGD(AAFwkTag::WANTAGENT, "StartOptions windowMode:%{public}d displayId:%{public}d \ withAnimation:%{public}d windowLeft:%{public}d windowTop:%{public}d windowWidth:%{public}d \ @@ -261,7 +261,7 @@ int32_t PendingWantManager::DeviceIdDetermine(const Want &want, const sptrGetWindowLeft(), startOptions->GetWindowTop(), startOptions->GetWindowWidth(), startOptions->GetWindowHeight()); result = DelayedSingleton::GetInstance()->StartAbilityWithSpecifyTokenIdInner( - want, *startOptions, callerToken, requestCode, callerUid, callerTokenId); + want, *startOptions, callerToken, requestCode, callerUid, callerTokenId, true); } if (result != ERR_OK && result != START_ABILITY_WAITING) { diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index fdea506f03..f988a23515 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -172,7 +172,6 @@ std::shared_ptr UIAbilityLifecycleManager::CreateAbilityRecord(Ab TAG_LOGD(AAFwkTag::ABILITYMGR, "user id: %{public}d.", userId_); uiAbilityRecord->SetOwnerMissionUserId(userId_); SetRevicerInfo(abilityRequest, uiAbilityRecord); - SetLastExitReason(uiAbilityRecord); return uiAbilityRecord; } @@ -234,6 +233,7 @@ int UIAbilityLifecycleManager::AttachAbilityThread(const sptr auto&& abilityRecord = Token::GetAbilityRecordByToken(token); CHECK_POINTER_AND_RETURN(abilityRecord, ERR_INVALID_VALUE); TAG_LOGI(AAFwkTag::ABILITYMGR, "Lifecycle: name is %{public}s.", abilityRecord->GetAbilityInfo().name.c_str()); + SetLastExitReason(abilityRecord); auto handler = DelayedSingleton::GetInstance()->GetEventHandler(); CHECK_POINTER_AND_RETURN_LOG(handler, ERR_INVALID_VALUE, "Fail to get AbilityEventHandler."); @@ -832,7 +832,6 @@ int UIAbilityLifecycleManager::CallAbilityLocked(const AbilityRequest &abilityRe uiAbilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); uiAbilityRecord->SetOwnerMissionUserId(userId_); SetRevicerInfo(abilityRequest, uiAbilityRecord); - SetLastExitReason(uiAbilityRecord); } else { uiAbilityRecord = sessionAbilityMap_.at(persistentId); } diff --git a/services/abilitymgr/src/start_ability_handler.cpp b/services/abilitymgr/src/start_ability_handler.cpp index 8a46063123..e8430434fc 100644 --- a/services/abilitymgr/src/start_ability_handler.cpp +++ b/services/abilitymgr/src/start_ability_handler.cpp @@ -15,7 +15,9 @@ #include "start_ability_handler.h" +#ifdef WITH_DLP #include "dlp_utils.h" +#endif // WITH_DLP namespace OHOS { namespace AAFwk { @@ -24,6 +26,7 @@ bool StartAbilityParams::IsCallerSandboxApp() return GetCallerAppIndex() > 0; } +#ifdef WITH_DLP bool StartAbilityParams::OtherAppsAccessDlp() { if (otherAppsAccessDlp.has_value()) { @@ -55,6 +58,7 @@ bool StartAbilityParams::SandboxExternalAuth() sandboxExternalAuth = DlpUtils::SandboxAuthCheck(*record, want); return sandboxExternalAuth.value(); } +#endif // WITH_DLP bool StartAbilityParams::IsCallerSysApp() { diff --git a/services/abilitymgr/src/start_ability_handler/start_ability_sandbox_savefile.cpp b/services/abilitymgr/src/start_ability_handler/start_ability_sandbox_savefile.cpp index a9f53d6071..f5b53310eb 100644 --- a/services/abilitymgr/src/start_ability_handler/start_ability_sandbox_savefile.cpp +++ b/services/abilitymgr/src/start_ability_handler/start_ability_sandbox_savefile.cpp @@ -25,8 +25,10 @@ namespace OHOS { namespace AAFwk { namespace { +#ifdef WITH_DLP const std::string DLP_BUNDLE_NAME = "com.ohos.dlpmanager"; const std::string DLP_ABILITY_NAME = "SaveAsAbility"; +#endif // WITH_DLP class EmptyConnection : public IRemoteStub { public: @@ -51,10 +53,12 @@ bool StartAbilitySandboxSavefile::MatchStartRequest(StartAbilityParams ¶ms) } auto element = params.want.GetElement(); +#ifdef WITH_DLP if (element.GetBundleName() == DLP_BUNDLE_NAME && element.GetAbilityName() == DLP_ABILITY_NAME && !ContainRecord(params.requestCode)) { return true; } +#endif // WITH_DLP return false; } @@ -68,14 +72,18 @@ int StartAbilitySandboxSavefile::HandleStartRequest(StartAbilityParams ¶ms) return CHECK_PERMISSION_FAILED; } +#ifdef WITH_DLP if (!params.SandboxExternalAuth()) { TAG_LOGW(AAFwkTag::ABILITYMGR, "sandbox external auth failed"); return CHECK_PERMISSION_FAILED; } +#endif // WITH_DLP auto reqCode = PushRecord(params.requestCode, callerRecord); auto &want = params.want; +#ifdef WITH_DLP want.SetElementName(DLP_BUNDLE_NAME, DLP_ABILITY_NAME); +#endif // WITH_DLP want.SetParam("requestCode", reqCode); want.SetParam("startMode", std::string("save_redirect")); diff --git a/services/appmgr/BUILD.gn b/services/appmgr/BUILD.gn index 397b7a04dd..f7b5ea6ba2 100644 --- a/services/appmgr/BUILD.gn +++ b/services/appmgr/BUILD.gn @@ -142,6 +142,11 @@ ohos_shared_library("libappms") { external_deps += [ "netmanager_base:net_conn_manager_if" ] } + if (ability_runtime_feature_sandboxmanager) { + external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] + defines += [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ] + } + if (ability_runtime_graphics) { defines += [ "SUPPORT_GRAPHICS", diff --git a/services/appmgr/include/ams_mgr_scheduler.h b/services/appmgr/include/ams_mgr_scheduler.h index 74dd5b6a32..b9d094f716 100644 --- a/services/appmgr/include/ams_mgr_scheduler.h +++ b/services/appmgr/include/ams_mgr_scheduler.h @@ -317,6 +317,12 @@ public: */ virtual bool IsKilledForUpgradeWeb(const std::string &bundleName) override; + /** + * whether the abilities of process specified by pid type only UIAbility. + * @return Returns true is only UIAbility, otherwise return false + */ + virtual bool IsProcessContainsOnlyUIAbility(const pid_t pid) override; + private: /** * @brief Judge whether the application service is ready. diff --git a/services/appmgr/include/app_mgr_service_inner.h b/services/appmgr/include/app_mgr_service_inner.h index 578d97eb65..75c74592b3 100644 --- a/services/appmgr/include/app_mgr_service_inner.h +++ b/services/appmgr/include/app_mgr_service_inner.h @@ -1125,7 +1125,7 @@ public: * @return Returns ERR_OK is test ability, others is not test ability. */ int32_t CheckCallingIsUserTestModeInner(const pid_t pid, bool &isUserTest); - + bool GetSceneBoardAttachFlag() const; void SetSceneBoardAttachFlag(bool flag); @@ -1151,6 +1151,8 @@ public: bool IsKilledForUpgradeWeb(const std::string &bundleName) const; + bool IsProcessContainsOnlyUIAbility(const pid_t pid); + private: int32_t ForceKillApplicationInner(const std::string &bundleName, const int userId = -1, const int appIndex = 0); @@ -1511,6 +1513,7 @@ private: AAFwk::EventInfo BuildEventInfo(std::shared_ptr appRecord) const; + void NotifyAppAttachFailed(std::shared_ptr appRecord); private: /** * Notify application status. @@ -1521,8 +1524,8 @@ private: * * @return */ - void NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t userId, const int32_t callerUid, - const std::string &eventData); + void NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t tokenId, const int32_t userId, + const int32_t callerUid, const std::string &eventData); void SendHiSysEvent(const int32_t innerEventId, const int64_t eventId); int FinishUserTestLocked( const std::string &msg, const int64_t &resultCode, const std::shared_ptr &appRecord); diff --git a/services/appmgr/include/utils/appspawn_util.h b/services/appmgr/include/utils/appspawn_util.h index 259f945252..422e39c2bc 100644 --- a/services/appmgr/include/utils/appspawn_util.h +++ b/services/appmgr/include/utils/appspawn_util.h @@ -33,9 +33,11 @@ static uint32_t BuildStartFlags(const AAFwk::Want &want, const ApplicationInfo & startFlags = startFlags | (START_FLAG_BASE << StartFlags::COLD_START); } +#ifdef WITH_DLP if (want.GetIntParam(DLP_PARAMS_INDEX, 0) != 0) { startFlags = startFlags | (START_FLAG_BASE << StartFlags::DLP_MANAGER); } +#endif // WITH_DLP if (applicationInfo.debug) { startFlags = startFlags | (START_FLAG_BASE << StartFlags::DEBUGGABLE); diff --git a/services/appmgr/src/ams_mgr_scheduler.cpp b/services/appmgr/src/ams_mgr_scheduler.cpp index ec7455f1d9..52ea48fd41 100644 --- a/services/appmgr/src/ams_mgr_scheduler.cpp +++ b/services/appmgr/src/ams_mgr_scheduler.cpp @@ -666,5 +666,19 @@ bool AmsMgrScheduler::IsKilledForUpgradeWeb(const std::string &bundleName) } return amsMgrServiceInner_->IsKilledForUpgradeWeb(bundleName); } -} // namespace AppExecFwk +bool AmsMgrScheduler::IsProcessContainsOnlyUIAbility(const pid_t pid) +{ + if (!IsReady()) { + TAG_LOGE(AAFwkTag::APPMGR, "AmsMgrService is not ready."); + return false; + } + pid_t callingPid = IPCSkeleton::GetCallingPid(); + pid_t procPid = getprocpid(); + if (callingPid != procPid) { + TAG_LOGE(AAFwkTag::APPMGR, "Not allow other process to call."); + return false; + } + return amsMgrServiceInner_->IsProcessContainsOnlyUIAbility(pid); +} +} // namespace AppExecFwk } // namespace OHOS diff --git a/services/appmgr/src/app_mgr_service.cpp b/services/appmgr/src/app_mgr_service.cpp index 299b7abe32..4c0eeb179d 100644 --- a/services/appmgr/src/app_mgr_service.cpp +++ b/services/appmgr/src/app_mgr_service.cpp @@ -186,8 +186,12 @@ void AppMgrService::AttachApplication(const sptr &app) } pid_t pid = IPCSkeleton::GetCallingPid(); - std::function attachApplicationFunc = [appMgrServiceInner = appMgrServiceInner_, pid, app]() { - appMgrServiceInner->AttachApplication(pid, iface_cast(app)); + auto appScheduler = iface_cast(app); + if (appScheduler == nullptr) { + TAG_LOGE(AAFwkTag::APPMGR, "appScheduler null"); + } + std::function attachApplicationFunc = [appMgrServiceInner = appMgrServiceInner_, pid, appScheduler]() { + appMgrServiceInner->AttachApplication(pid, appScheduler); }; taskHandler_->SubmitTask(attachApplicationFunc, AAFwk::TaskAttribute{ .taskName_ = TASK_ATTACH_APPLICATION, @@ -350,9 +354,12 @@ int32_t AppMgrService::ClearUpApplicationData(const std::string &bundleName, int return AAFwk::CHECK_PERMISSION_FAILED; } } + if (appCloneIndex < 0 || appCloneIndex > AbilityRuntime::GlobalConstant::MAX_APP_CLONE_INDEX) { + TAG_LOGE(AAFwkTag::APPMGR, "appCloneIndex is invalid."); + return AAFwk::ERR_APP_CLONE_INDEX_INVALID; + } pid_t pid = IPCSkeleton::GetCallingPid(); - appMgrServiceInner_->ClearUpApplicationData(bundleName, callingUid, pid, appCloneIndex, userId); - return ERR_OK; + return appMgrServiceInner_->ClearUpApplicationData(bundleName, callingUid, pid, appCloneIndex, userId); } int32_t AppMgrService::ClearUpApplicationDataBySelf(int32_t userId) @@ -708,7 +715,7 @@ int AppMgrService::DumpIpcWithPidInner(const AppMgrService::DumpIpcKey key, TAG_LOGE(AAFwkTag::APPMGR, "invalid pid: %{public}s", optionPid.c_str()); return DumpErrorCode::ERR_INVALID_PID_ERROR; } - + switch (key) { case KEY_DUMP_IPC_START: return DumpIpcStart(pid, result); @@ -800,7 +807,7 @@ int AppMgrService::DumpIpc(const std::vector& args, std::string& std::string optionPid = Str16ToStr8(args[INDEX_PID]); TAG_LOGD(AAFwkTag::APPMGR, "option pid:%{public}s, option cmd:%{public}s", optionPid.c_str(), optionCmd.c_str()); - + DumpIpcKey key; if (!GetDumpIpcKeyByOption(optionCmd, key)) { result.append(MSG_DUMP_FAIL, strlen(MSG_DUMP_FAIL)) diff --git a/services/appmgr/src/app_mgr_service_inner.cpp b/services/appmgr/src/app_mgr_service_inner.cpp index c78c9083ae..ff4798cd3e 100644 --- a/services/appmgr/src/app_mgr_service_inner.cpp +++ b/services/appmgr/src/app_mgr_service_inner.cpp @@ -70,6 +70,9 @@ #include "render_state_observer_manager.h" #include "startup_util.h" #include "string_ex.h" +#ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER +#include "sandbox_manager_kit.h" +#endif #include "system_ability_definition.h" #include "time_util.h" #include "ui_extension_utils.h" @@ -134,6 +137,8 @@ constexpr int REGISTER_VISIBILITY_DELAY = 5000; // Max render process number limitation for phone device. constexpr int PHONE_MAX_RENDER_PROCESS_NUM = 40; constexpr int PROCESS_RESTART_MARGIN_MICRO_SECONDS = 2000; +constexpr const int32_t API10 = 10; +constexpr const int32_t API_VERSION_MOD = 100; constexpr const char* CLASS_NAME = "ohos.app.MainThread"; constexpr const char* FUNC_NAME = "main"; constexpr const char* RENDER_PARAM = "invalidparam"; @@ -146,7 +151,11 @@ constexpr const char* ENTER_SANDBOX = "sandboxApp"; constexpr const char* PERMISSION_INTERNET = "ohos.permission.INTERNET"; constexpr const char* PERMISSION_MANAGE_VPN = "ohos.permission.MANAGE_VPN"; constexpr const char* PERMISSION_ACCESS_BUNDLE_DIR = "ohos.permission.ACCESS_BUNDLE_DIR"; + +#ifdef WITH_DLP constexpr const char* DLP_PARAMS_SECURITY_FLAG = "ohos.dlp.params.securityFlag"; +#endif // WITH_DLP + constexpr const char* SUPPORT_ISOLATION_MODE = "persist.bms.supportIsolationMode"; constexpr const char* SUPPORT_SERVICE_EXT_MULTI_PROCESS = "component.startup.extension.multiprocess.enable"; constexpr const char* SERVICE_EXT_MULTI_PROCESS_WHITE_LIST = "component.startup.extension.multiprocess.whitelist"; @@ -166,6 +175,7 @@ constexpr const char* GPU_PROCESS_NAME = ":gpu"; constexpr const char* GPU_PROCESS_TYPE = "gpu"; constexpr const char* FONT_WGHT_SCALE = "persist.sys.font_wght_scale_for_user0"; constexpr const char* FONT_SCALE = "persist.sys.font_scale_for_user0"; +const std::string TOKEN_ID = "TOKEN_ID"; const int32_t SIGNAL_KILL = 9; constexpr int32_t USER_SCALE = 200000; #define ENUM_TO_STRING(s) #s @@ -856,7 +866,12 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr appDeathRecipient = new (std::nothrow) AppDeathRecipient(); CHECK_POINTER_AND_RETURN_LOG(appDeathRecipient, "Failed to create death recipient."); @@ -884,6 +899,23 @@ void AppMgrServiceInner::AttachApplication(const pid_t pid, const sptr appRecord) +{ + CHECK_POINTER_AND_RETURN_LOG(appRecord, "AppRecord null."); + std::vector> abilityTokens; + for (const auto &token : appRecord->GetAbilities()) { + abilityTokens.emplace_back(token.first); + } + TAG_LOGI(AAFwkTag::APPMGR, "Attach failed name: %{public}s %{public}zu", appRecord->GetProcessName().c_str(), + abilityTokens.size()); + std::lock_guard lock(appStateCallbacksLock_); + for (const auto &callback : appStateCallbacks_) { + if (callback != nullptr) { + callback->OnAppRemoteDied(abilityTokens); + } + } +} + void AppMgrServiceInner::LaunchApplication(const std::shared_ptr &appRecord) { if (!appRecord) { @@ -1401,7 +1433,7 @@ int32_t AppMgrServiceInner::ClearUpApplicationData(const std::string &bundleName if (userId == DEFAULT_INVAL_VALUE) { newUserId = GetUserIdByUid(callerUid); } - TAG_LOGI(AAFwkTag::APPMGR, "userId:%{public}d", userId); + TAG_LOGI(AAFwkTag::APPMGR, "userId:%{public}d, appIndex:%{public}d", newUserId, appCloneIndex); return ClearUpApplicationDataByUserId(bundleName, callerUid, callerPid, appCloneIndex, newUserId); } @@ -1443,7 +1475,7 @@ int32_t AppMgrServiceInner::ClearUpApplicationDataByUserId(const std::string &bu int32_t result = AccessToken::AccessTokenKit::ClearUserGrantedPermissionState(tokenId); if (result) { TAG_LOGE(AAFwkTag::APPMGR, "ClearUserGrantedPermissionState failed, ret:%{public}d", result); - return ERR_PERMISSION_DENIED; + return AAFwk::ERR_APP_CLONE_INDEX_INVALID; } // 2.delete bundle side user data if (!IN_PROCESS_CALL(bundleMgrHelper->CleanBundleDataFiles(bundleName, userId, appCloneIndex))) { @@ -1468,7 +1500,7 @@ int32_t AppMgrServiceInner::ClearUpApplicationDataByUserId(const std::string &bu TAG_LOGW( AAFwkTag::APPMGR, "Distributeddata clear app storage failed, bundleName:%{public}s", bundleName.c_str()); } - NotifyAppStatusByCallerUid(bundleName, userId, callerUid, + NotifyAppStatusByCallerUid(bundleName, tokenId, userId, callerUid, EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_DATA_CLEARED); return ERR_OK; } @@ -1972,7 +2004,9 @@ std::shared_ptr AppMgrServiceInner::CreateAppRunningRecord(spt int32_t appIndex = 0; (void)AbilityRuntime::StartupUtil::GetAppIndex(*want, appIndex); appRecord->SetAppIndex(appIndex); +#ifdef WITH_DLP appRecord->SetSecurityFlag(want->GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false)); +#endif // WITH_DLP appRecord->SetRequestProcCode(want->GetIntParam(Want::PARAM_RESV_REQUEST_PROC_CODE, 0)); appRecord->SetCallerPid(want->GetIntParam(Want::PARAM_RESV_CALLER_PID, -1)); appRecord->SetCallerUid(want->GetIntParam(Want::PARAM_RESV_CALLER_UID, -1)); @@ -2298,7 +2332,9 @@ void AppMgrServiceInner::StartAbility(sptr token, sptrSetParam(DLP_PARAMS_SECURITY_FLAG, appRecord->GetSecurityFlag()); +#endif // WITH_DLP auto isDebugApp = want->GetBoolParam(DEBUG_APP, false); if (isDebugApp && !appRecord->IsDebugApp()) { @@ -2890,6 +2926,17 @@ void AppMgrServiceInner::StartProcess(const std::string &appName, const std::str appRunningManager_->RemoveAppRunningRecordById(appRecord->GetRecordId()); return; } + + #ifdef ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER + bool checkApiVersion = (appInfo && (appInfo->apiTargetVersion % API_VERSION_MOD == API10)); + TAG_LOGD(AAFwkTag::APPMGR, "version of api is %{public}d", appInfo->apiTargetVersion % API_VERSION_MOD); + if (checkApiVersion && AAFwk::AppUtils::GetInstance().IsGrantPersistUriPermission()) { + uint32_t tokenId = appInfo->accessTokenId; + auto sandboxRet = AccessControl::SandboxManager::SandboxManagerKit::StartAccessingByTokenId(tokenId); + TAG_LOGI(AAFwkTag::APPMGR, "tokenId = %{public}u, ret = %{public}d", tokenId, sandboxRet); + } + #endif + TAG_LOGI(AAFwkTag::APPMGR, "Start process success, pid: %{public}d, processName: %{public}s.", pid, processName.c_str()); SetRunningSharedBundleList(bundleName, startMsg.hspList); @@ -3583,17 +3630,18 @@ void AppMgrServiceInner::NotifyAppStatus(const std::string &bundleName, const st EventFwk::CommonEventManager::PublishCommonEvent(commonData); } -void AppMgrServiceInner::NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t userId, - const int32_t callerUid, const std::string &eventData) +void AppMgrServiceInner::NotifyAppStatusByCallerUid(const std::string &bundleName, const int32_t tokenId, + const int32_t userId, const int32_t callerUid, const std::string &eventData) { TAG_LOGI(AAFwkTag::APPMGR, - "%{public}s called, bundle name is %{public}s, , userId is %{public}d, event is %{public}s", __func__, + "%{public}s called, bundle name is %{public}s, userId is %{public}d, event is %{public}s", __func__, bundleName.c_str(), userId, eventData.c_str()); Want want; want.SetAction(eventData); ElementName element; element.SetBundleName(bundleName); want.SetElement(element); + want.SetParam(TOKEN_ID, tokenId); want.SetParam(Constants::USER_ID, userId); want.SetParam(Constants::UID, callerUid); EventFwk::CommonEventData commonData {want}; @@ -7193,5 +7241,30 @@ bool AppMgrServiceInner::IsKilledForUpgradeWeb(const std::string &bundleName) co } return ExitResidentProcessManager::GetInstance().IsKilledForUpgradeWeb(bundleName); } -} // namespace AppExecFwk +bool AppMgrServiceInner::IsProcessContainsOnlyUIAbility(const pid_t pid) +{ + auto appRecord = GetAppRunningRecordByPid(pid); + if (appRecord == nullptr) { + return false; + } + + auto abilityRecordList = appRecord->GetAbilities(); + + for (auto it = abilityRecordList.begin(); it != abilityRecordList.end(); ++it) { + if (it->second == nullptr) { + return false; + } + auto abilityInfo = it->second->GetAbilityInfo(); + if (abilityInfo == nullptr) { + return false; + } + + bool isUIAbility = (abilityInfo->type == AppExecFwk::AbilityType::PAGE); + if (!isUIAbility) { + return false; + } + } + return true; +} +} // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/services/common/src/permission_verification.cpp b/services/common/src/permission_verification.cpp index 52feb1cba2..f14b0626b8 100644 --- a/services/common/src/permission_verification.cpp +++ b/services/common/src/permission_verification.cpp @@ -54,6 +54,8 @@ bool PermissionVerification::VerifyCallingPermission( const std::string &permissionName, const uint32_t specifyTokenId) const { HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__); + TAG_LOGD(AAFwkTag::DEFAULT, "VerifyCallingPermission permission %{public}s, specifyTokenId is %{public}u", + permissionName.c_str(), specifyTokenId); auto callerToken = specifyTokenId == 0 ? GetCallingTokenID() : specifyTokenId; TAG_LOGD(AAFwkTag::DEFAULT, "callerToken is %{public}u", callerToken); int32_t ret = Security::AccessToken::AccessTokenKit::VerifyAccessToken(callerToken, permissionName, false); diff --git a/test/fuzztest/BUILD.gn b/test/fuzztest/BUILD.gn index 9ba018af56..69d3e2d026 100644 --- a/test/fuzztest/BUILD.gn +++ b/test/fuzztest/BUILD.gn @@ -17,13 +17,19 @@ group("fuzztest") { testonly = true deps = [ + "abilityappdebuginfo_fuzzer:fuzztest", + "abilityappdebugmanager_fuzzer:fuzztest", "abilityappdfrapplicationanrlistener_fuzzer:fuzztest", + "abilityappjsheapmeminfo_fuzzer:fuzztest", "abilityappmgrapprunningmanager_fuzzer:fuzztest", + "abilityappmgrevent_fuzzer:fuzztest", "abilityappmgrpagestatedata_fuzzer:fuzztest", "abilityappmgrrenderstatedata_fuzzer:fuzztest", "abilityappmgrrenderstateobservermanager_fuzzer:fuzztest", "abilityappmgrrunningmultiinfo_fuzzer:fuzztest", + "abilityapppreloader_fuzzer:fuzztest", "abilityattachtimeout_fuzzer:fuzztest", + "abilityautostartupdatamanager_fuzzer:fuzztest", "abilityautostartupdatamanagera_fuzzer:fuzztest", "abilityautostartupdatamanagerb_fuzzer:fuzztest", "abilityautostartupservicea_fuzzer:fuzztest", @@ -31,6 +37,8 @@ group("fuzztest") { "abilitybackgroundconnection_fuzzer:fuzztest", "abilitycachemanagera_fuzzer:fuzztest", "abilitychildprocessinfo_fuzzer:fuzztest", + "abilitychildprocessinfo_fuzzer:fuzztest", + "abilitychildprocessrecord_fuzzer:fuzztest", "abilitychildprocessrecord_fuzzer:fuzztest", "abilityconnectionstub_fuzzer:fuzztest", "abilitycontext_fuzzer:fuzztest", @@ -42,10 +50,16 @@ group("fuzztest") { "abilityframeworksnativejsworker_fuzzer:fuzztest", "abilityframeworksnativeohosjsenvlogger_fuzzer:fuzztest", "abilityinterfacesappmanageramsmgrstub_fuzzer:fuzztest", + "abilityinterfacesappmanageramsmgrstub_fuzzer:fuzztest", "abilityinterfacesappmgrabilitydebugresponseproxy_fuzzer:fuzztest", "abilityinterfacesappmgrappdebuglistenerproxy_fuzzer:fuzztest", + "abilityinterfacesappmgrappdebuglistenerstub_fuzzer:fuzztest", + "abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer:fuzztest", "abilityinterfacesappmgrchildschedulerproxy_fuzzer:fuzztest", + "abilityinterfacesappmgrchildschedulerstub_fuzzer:fuzztest", "abilityinterfacesappmgrnativechildnotifyproxy_fuzzer:fuzztest", + "abilityinterfacesappmgrnativechildnotifystub_fuzzer:fuzztest", + "abilityinterfacesappmgrrenderstateobserverstub_fuzzer:fuzztest", "abilitymanagereventsubscriber_fuzzer:fuzztest", "abilitymanagerserviceb_fuzzer:fuzztest", "abilitymanagerservicec_fuzzer:fuzztest", @@ -60,6 +74,7 @@ group("fuzztest") { "abilitymanagerservicesecond_fuzzer:fuzztest", "abilitymanagerservicesixth_fuzzer:fuzztest", "abilitymanagerservicethird_fuzzer:fuzztest", + "abilitymemorylevelinfo_fuzzer:fuzztest", "abilitymgrabilitymanagerstub_fuzzer:fuzztest", "abilitymgrappexitreasonhelper_fuzzer:fuzztest", "abilitymgrcontrolinterceptor_fuzzer:fuzztest", @@ -76,6 +91,7 @@ group("fuzztest") { "abilitymgrrest_fuzzer:fuzztest", "abilitymgrrestartappmanager_fuzzer:fuzztest", "abilitymgruiextensionrecord_fuzzer:fuzztest", + "abilitymgruiextensionrecord_fuzzer:fuzztest", "abilitymgruiextensionsessioninfo_fuzzer:fuzztest", "abilityrunningrecord_fuzzer:fuzztest", "abilitystubabilityrecovery_fuzzer:fuzztest", @@ -222,6 +238,7 @@ group("fuzztest") { "assertfaultcallbackdeathmgr_fuzzer:fuzztest", "attachabilitythread_fuzzer:fuzztest", "attachrenderprocess_fuzzer:fuzztest", + "autostartupinfo_fuzzer:fuzztest", "blockability_fuzzer:fuzztest", "blockamsservice_fuzzer:fuzztest", "blockappservice_fuzzer:fuzztest", @@ -243,12 +260,15 @@ group("fuzztest") { "crowdtestinterceptor_fuzzer:fuzztest", "dataabilitymanager_fuzzer:fuzztest", "delegatordoabilityforeground_fuzzer:fuzztest", + "disposedobserver_fuzzer:fuzztest", "doabilitybackground_fuzzer:fuzztest", "doabilityforeground_fuzzer:fuzztest", "dumpabilityinfodone_fuzzer:fuzztest", "dumpstate_fuzzer:fuzztest", "dumpsysstate_fuzzer:fuzztest", + "extensionconfig_fuzzer:fuzztest", "extensioncontrolinterceptor_fuzzer:fuzztest", + "extensionrecordfactory_fuzzer:fuzztest", "extensionrecordmanagera_fuzzer:fuzztest", "faultdata_fuzzer:fuzztest", "forcetimeoutfortest_fuzzer:fuzztest", @@ -264,6 +284,7 @@ group("fuzztest") { "getrunningprocessinfobytoken_fuzzer:fuzztest", "getwantsender_fuzzer:fuzztest", "handledlpapp_fuzzer:fuzztest", + "insightintentexecutecallbackstub_fuzzer:fuzztest", "isramconstraineddevice_fuzzer:fuzztest", "jsabilityautostartupmanager_fuzzer:fuzztest", "jsabilityautostartupmanager_fuzzer:fuzztest", @@ -328,6 +349,7 @@ group("fuzztest") { "terminateability_fuzzer:fuzztest", "uiabilitylifecyclemanagera_fuzzer:fuzztest", "uiabilitylifecyclemanagerb_fuzzer:fuzztest", + "uiextensionrecordfactory_fuzzer:fuzztest", "unlockmissionforcleanup_fuzzer:fuzztest", "unregisterabilitylifecyclecallback_fuzzer:fuzztest", "unregisterapplicationstateobserver_fuzzer:fuzztest", @@ -336,6 +358,7 @@ group("fuzztest") { "updateabilitystate_fuzzer:fuzztest", "updateconfiguration_fuzzer:fuzztest", "updateextensionstate_fuzzer:fuzztest", + "usercallbackstub_fuzzer:fuzztest", "wantagenthelperstring_fuzzer:fuzztest", "wantagenthelpertrigger_fuzzer:fuzztest", "wantsenderstub_fuzzer:fuzztest", diff --git a/test/fuzztest/abilityappjsheapmeminfo_fuzzer/abilityappjsheapmeminfo_fuzzer.cpp b/test/fuzztest/abilityappjsheapmeminfo_fuzzer/abilityappjsheapmeminfo_fuzzer.cpp index 177223104a..9fc94a3322 100644 --- a/test/fuzztest/abilityappjsheapmeminfo_fuzzer/abilityappjsheapmeminfo_fuzzer.cpp +++ b/test/fuzztest/abilityappjsheapmeminfo_fuzzer/abilityappjsheapmeminfo_fuzzer.cpp @@ -17,7 +17,6 @@ #include #include - #define private public #define protected public #include "app_jsheap_mem_info.h" @@ -27,9 +26,7 @@ #include #include "securec.h" #include "configuration.h" - using namespace OHOS::AppExecFwk; - namespace OHOS { namespace { constexpr int INPUT_ZERO = 0; @@ -50,8 +47,6 @@ uint32_t GetU32Data(const char* ptr) ptr[INPUT_THREE]; } - - bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { JsHeapDumpInfo js; diff --git a/test/fuzztest/abilityappmgrevent_fuzzer/abilityappmgrevent_fuzzer.cpp b/test/fuzztest/abilityappmgrevent_fuzzer/abilityappmgrevent_fuzzer.cpp index 7041cc428e..a03cbe4687 100644 --- a/test/fuzztest/abilityappmgrevent_fuzzer/abilityappmgrevent_fuzzer.cpp +++ b/test/fuzztest/abilityappmgrevent_fuzzer/abilityappmgrevent_fuzzer.cpp @@ -45,15 +45,15 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) AppMgrEventUtil::SendCreateAtomicServiceProcessEvent(callerAppRecord, appRecord, stringParam, stringParam); AAFwk::EventInfo eventInfo; - AppMgrEventUtil::SendProcessStartEvent(callerAppRecord,appRecord,eventInfo); + AppMgrEventUtil::SendProcessStartEvent(callerAppRecord, appRecord, eventInfo); int32_t appUid = static_cast(GetU32Data(data)); int64_t restartTime = static_cast(GetU32Data(data)); AppMgrEventUtil::SendReStartProcessEvent(eventInfo, appUid, restartTime); - AppMgrEventUtil:: GetCallerPid(callerAppRecord); + AppMgrEventUtil::GetCallerPid(callerAppRecord); std::shared_ptr abilityInfo; int32_t abilityType = static_cast(GetU32Data(data)); int32_t extensionType = static_cast(GetU32Data(data)); - AppMgrEventUtil:: UpdateStartupType(abilityInfo, abilityType,extensionType); + AppMgrEventUtil::UpdateStartupType(abilityInfo, abilityType, extensionType); return true; } } diff --git a/test/fuzztest/abilityapppreloader_fuzzer/BUILD.gn b/test/fuzztest/abilityapppreloader_fuzzer/BUILD.gn new file mode 100644 index 0000000000..16cebd138a --- /dev/null +++ b/test/fuzztest/abilityapppreloader_fuzzer/BUILD.gn @@ -0,0 +1,73 @@ +# Copyright (c) 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +##############################fuzztest########################################## +module_output_path = "ability_runtime/appmgrservice" +ohos_fuzztest("AbilityAppPreloaderFuzzTest") { + module_out_path = module_output_path + fuzz_config_file = + "${ability_runtime_test_path}/fuzztest/abilityapppreloader_fuzzer" + include_dirs = [ + "${ability_runtime_services_path}/appmgr/include", + "${ability_runtime_path}/interfaces/kits/native/appkit/ability_bundle_manager_helper", + ] + + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ + "${ability_runtime_services_path}/appmgr/src/app_preloader.cpp", + "abilityapppreloader_fuzzer.cpp", + ] + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/appkit:appkit_manager_helper", + "${ability_runtime_path}/utils/server/startup:startup_util", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:task_handler_wrap", + ] + + external_deps = [ + "ability_base:want", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "ffrt:libffrt", + "hilog:libhilog", + "hitrace:hitrace_meter", + "init:libbegetutil", + "ipc:ipc_core", + "resource_schedule_service:ressched_client", + "samgr:samgr_proxy", + "window_manager:libwm", + ] +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityAppPreloaderFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityapppreloader_fuzzer/abilityapppreloader_fuzzer.cpp b/test/fuzztest/abilityapppreloader_fuzzer/abilityapppreloader_fuzzer.cpp new file mode 100644 index 0000000000..235c944bc3 --- /dev/null +++ b/test/fuzztest/abilityapppreloader_fuzzer/abilityapppreloader_fuzzer.cpp @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "abilityapppreloader_fuzzer.h" + +#include +#include + +#define private public +#define protected public +#include "app_preloader.h" +#include "bundle_mgr_helper.h" +#undef protected +#undef private +#include "parcel.h" +#include +#include "securec.h" +#include "configuration.h" + +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +} + +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + std::shared_ptr remoteClientManager = std::make_shared(); + auto bundleMgrHelper = std::make_shared(); + remoteClientManager->SetBundleManagerHelper(bundleMgrHelper); + auto appPreloader = std::make_shared(remoteClientManager); + std::string bundleName(data, size); + int32_t userId = static_cast(GetU32Data(data)); + int32_t appIndex = static_cast(GetU32Data(data)); + PreloadRequest request; + appPreloader->GeneratePreloadRequest(bundleName, userId, appIndex, request); + appPreloader->GetBundleManagerHelper(); + AbilityInfo abilityInfo; + appPreloader->CheckPreloadConditions(abilityInfo); + AAFwk::Want launchWant; + appPreloader->GetLaunchWant(bundleName, userId, launchWant); + appPreloader->GetLaunchAbilityInfo(launchWant, userId, abilityInfo); + appPreloader->PreCheck(bundleName, PreloadMode::PRE_MAKE); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + return 0; + } + + /* Validate the length of size */ + if (size < OHOS::U32_AT_SIZE || size > OHOS::FOO_MAX_LEN) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityapppreloader_fuzzer/abilityapppreloader_fuzzer.h b/test/fuzztest/abilityapppreloader_fuzzer/abilityapppreloader_fuzzer.h new file mode 100644 index 0000000000..fce277feb8 --- /dev/null +++ b/test/fuzztest/abilityapppreloader_fuzzer/abilityapppreloader_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYAPPPRELOADER_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYAPPPRELOADER_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityapppreloader_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYAPPPRELOADER_FUZZER_H diff --git a/test/fuzztest/abilityapppreloader_fuzzer/corpus/init b/test/fuzztest/abilityapppreloader_fuzzer/corpus/init new file mode 100644 index 0000000000..8eb5a7d6eb --- /dev/null +++ b/test/fuzztest/abilityapppreloader_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/abilityapppreloader_fuzzer/project.xml b/test/fuzztest/abilityapppreloader_fuzzer/project.xml new file mode 100644 index 0000000000..6e8ad2cfde --- /dev/null +++ b/test/fuzztest/abilityapppreloader_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityautostartupdatamanager_fuzzer/BUILD.gn b/test/fuzztest/abilityautostartupdatamanager_fuzzer/BUILD.gn index 35de92d307..395521956d 100644 --- a/test/fuzztest/abilityautostartupdatamanager_fuzzer/BUILD.gn +++ b/test/fuzztest/abilityautostartupdatamanager_fuzzer/BUILD.gn @@ -66,6 +66,7 @@ ohos_fuzztest("AbilityAutoStartupDataManagerFuzzTest") { "ffrt:libffrt", "hilog:libhilog", "hitrace:hitrace_meter", + "init:libbegetutil", "ipc:ipc_core", "kv_store:distributeddata_inner", "napi:ace_napi", diff --git a/test/fuzztest/abilitychildprocessinfo_fuzzer/abilitychildprocessinfo_fuzzer.cpp b/test/fuzztest/abilitychildprocessinfo_fuzzer/abilitychildprocessinfo_fuzzer.cpp index 3219216e52..5c26e7dc7e 100644 --- a/test/fuzztest/abilitychildprocessinfo_fuzzer/abilitychildprocessinfo_fuzzer.cpp +++ b/test/fuzztest/abilitychildprocessinfo_fuzzer/abilitychildprocessinfo_fuzzer.cpp @@ -27,9 +27,7 @@ #include #include "securec.h" #include "configuration.h" - using namespace OHOS::AppExecFwk; - namespace OHOS { namespace { constexpr int INPUT_ZERO = 0; diff --git a/test/fuzztest/abilitychildprocessrecord_fuzzer/abilitychildprocessrecord_fuzzer.cpp b/test/fuzztest/abilitychildprocessrecord_fuzzer/abilitychildprocessrecord_fuzzer.cpp index 26dc9044b6..34674107f8 100644 --- a/test/fuzztest/abilitychildprocessrecord_fuzzer/abilitychildprocessrecord_fuzzer.cpp +++ b/test/fuzztest/abilitychildprocessrecord_fuzzer/abilitychildprocessrecord_fuzzer.cpp @@ -40,18 +40,17 @@ uint32_t GetU32Data(const char* ptr) return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3]; } - bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { int32_t hostPid = static_cast(GetU32Data(data)); ChildProcessRequest request; std::shared_ptr hostRecord; - ChildProcessRecord::CreateChildProcessRecord(hostPid,request,hostRecord); + ChildProcessRecord::CreateChildProcessRecord(hostPid, request, hostRecord); std::string stringParam(data, size); - sptr mainProcessCb; - int32_t childProcessCount =static_cast(GetU32Data(data)); - bool isStartWithDebug = *data % ENABLE; - ChildProcessRecord::CreateNativeChildProcessRecord(hostPid,stringParam,hostRecord,mainProcessCb,childProcessCount,isStartWithDebug); + sptr mP; + int32_t cd = static_cast(GetU32Data(data)); + bool flag = *data % ENABLE; + ChildProcessRecord::CreateNativeChildProcessRecord(hostPid, stringParam, hostRecord, mP, cd, flag); std::shared_ptr appInfo = std::make_shared(); int32_t RECORD_ID = static_cast(GetU32Data(data)); auto appRecord = std::make_shared(appInfo, RECORD_ID, stringParam); diff --git a/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp b/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp index 0d890c3032..73a433b75b 100644 --- a/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp +++ b/test/fuzztest/abilityframeworksnativejsworker_fuzzer/abilityframeworksnativejsworker_fuzzer.cpp @@ -66,9 +66,9 @@ sptr GetFuzzAbilityToken() bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { std::shared_ptr workerInfo = std::make_shared(); - workerInfo->codePath = panda::panda_file::StringPacProtect("/data/test/codePath"); + workerInfo->codePath = "/data/test/codePath"; workerInfo->packagePathStr = "/data/test/packagePath"; - workerInfo->hapPath = panda::panda_file::StringPacProtect("/data/test/hapPath"); + workerInfo->hapPath = "/data/test/hapPath"; workerInfo->moduleName = "moduleName"; AbilityRuntime::AssetHelper helper = AbilityRuntime::AssetHelper(workerInfo); std::string jsonStr(data, size); diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/BUILD.gn new file mode 100644 index 0000000000..de7aac55e4 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppMgrAppDebugListenerStubFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilityinterfacesappmgrappdebuglistenerstub_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppMgrAppDebugListenerStubFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/abilityinterfacesappmgrappdebuglistenerstub_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/abilityinterfacesappmgrappdebuglistenerstub_fuzzer.cpp new file mode 100644 index 0000000000..9664f664d2 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/abilityinterfacesappmgrappdebuglistenerstub_fuzzer.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "abilityinterfacesappmgrappdebuglistenerstub_fuzzer.h" + +#include +#include + +#define private public +#include "app_debug_listener_stub.h" +#include "app_debug_listener_interface.h" +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string AMSMGR_INTERFACE_TOKEN = u"ohos.appexecfwk.IAmsMgr"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} +class AppDebugListenerStubFUZZ : public AppDebugListenerStub { +public: + explicit AppDebugListenerStubFUZZ() {}; + virtual ~ AppDebugListenerStubFUZZ() {}; + int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override{ return 0; }; + void OnAppDebugStarted(const std::vector &debugInfos) override{}; + void OnAppDebugStoped(const std::vector &debugInfos) override{}; +}; + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + uint32_t codeOne = static_cast(IAppDebugListener::Message::ON_APP_DEBUG_STARTED); + MessageParcel parcel; + parcel.WriteInterfaceToken(AMSMGR_INTERFACE_TOKEN); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + MessageParcel reply; + MessageOption option; + std::shared_ptr abmsOne = std::make_shared(); + abmsOne->OnRemoteRequest(codeOne, parcel, reply, option); + uint32_t codeTwo = static_cast(IAppDebugListener::Message::ON_APP_DEBUG_STOPED); + abmsOne->OnRemoteRequest(codeTwo, parcel, reply, option); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/abilityinterfacesappmgrappdebuglistenerstub_fuzzer.h b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/abilityinterfacesappmgrappdebuglistenerstub_fuzzer.h new file mode 100644 index 0000000000..4c0f8e09bb --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/abilityinterfacesappmgrappdebuglistenerstub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTENERSTUB_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTENERSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmgrappdebuglistenerstub_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPDEBUGLISTENERSTUB_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappdebuglistenerstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/BUILD.gn new file mode 100644 index 0000000000..8d18a46612 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/BUILD.gn @@ -0,0 +1,83 @@ +# Copyright (c) 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppMgrAppForegroundStateObserverStubFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = + [ "abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppMgrAppForegroundStateObserverStubFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.cpp new file mode 100644 index 0000000000..fed703c2e1 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.cpp @@ -0,0 +1,132 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.h" + +#include +#include + +#define private public +#include "app_foreground_state_observer_stub.h" +#include "app_foreground_state_observer_interface.h" +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string IA_APP_FOREGROUND_STATE_OBSERVER_TOKEN = u"ohos.appexecfwk.IAppForegroundStateObserver"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +class AppForegroundStateObserverStubFUZZ : public AppForegroundStateObserverStub { +public: + explicit AppForegroundStateObserverStubFUZZ() {}; + virtual ~ AppForegroundStateObserverStubFUZZ() {}; + int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override{ return 0; }; + void OnAppStateChanged(const AppStateData &appStateData) override{}; +}; + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + uint32_t code = static_cast(IAppForegroundStateObserver::Message::ON_APP_STATE_CHANGED); + MessageParcel parcel; + parcel.WriteInterfaceToken(IA_APP_FOREGROUND_STATE_OBSERVER_TOKEN); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + MessageParcel reply; + MessageOption option; + std::shared_ptr abms = + std::make_shared(); + abms->OnRemoteRequest(code, parcel, reply, option); + using RemoteDiedHandler = std::function &)>; + RemoteDiedHandler handler; + std::shared_ptr infos = + std::make_shared(handler); + wptr remote; + infos->OnRemoteDied(remote); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.h b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.h new file mode 100644 index 0000000000..f9bc04b2f6 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPFOREGROUNDSTATEOBSERVERSTUB_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPFOREGROUNDSTATEOBSERVERSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRAPPFOREGROUNDSTATEOBSERVERSTUB_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrappforegroundstateobserverstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/BUILD.gn new file mode 100644 index 0000000000..ec60c224bb --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppMgrChildSchedulerStubFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilityinterfacesappmgrchildschedulerstub_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppMgrChildSchedulerStubFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/abilityinterfacesappmgrchildschedulerstub_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/abilityinterfacesappmgrchildschedulerstub_fuzzer.cpp new file mode 100644 index 0000000000..4c213c7ffd --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/abilityinterfacesappmgrchildschedulerstub_fuzzer.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "abilityinterfacesappmgrchildschedulerstub_fuzzer.h" + +#include +#include + +#define private public +#include "child_scheduler_stub.h" +#include "child_scheduler_interface.h" +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string CHILD_SCHEDULER_TOKEN = u"ohos.appexecfwk.ChildScheduler"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +class ChildSchedulerStubFUZZ : public ChildSchedulerStub { +public: + explicit ChildSchedulerStubFUZZ() {}; + virtual ~ ChildSchedulerStubFUZZ() {}; + int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override{ return 0; }; + bool ScheduleLoadJs() override{ return true; }; + bool ScheduleExitProcessSafely() override{ return true; }; + bool ScheduleRunNativeProc(const sptr &mainProcessCb) override{ return true; }; +}; + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + uint32_t code = static_cast(IChildScheduler::Message::SCHEDULE_LOAD_JS); + MessageParcel parcel; + parcel.WriteInterfaceToken(CHILD_SCHEDULER_TOKEN); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + MessageParcel reply; + MessageOption option; + std::shared_ptr abms = std::make_shared(); + abms->OnRemoteRequest(code, parcel, reply, option); + code = static_cast(IChildScheduler::Message::SCHEDULE_EXIT_PROCESS_SAFELY); + abms->OnRemoteRequest(code, parcel, reply, option); + code = static_cast(IChildScheduler::Message::SCHEDULE_RUN_NATIVE_PROC); + abms->OnRemoteRequest(code, parcel, reply, option); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/abilityinterfacesappmgrchildschedulerstub_fuzzer.h b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/abilityinterfacesappmgrchildschedulerstub_fuzzer.h new file mode 100644 index 0000000000..445724a1c6 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/abilityinterfacesappmgrchildschedulerstub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRCHILDSCHEDULERSTUB_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRCHILDSCHEDULERSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmgrchildschedulerstub_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRCHILDSCHEDULERSTUB_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrchildschedulerstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/BUILD.gn new file mode 100644 index 0000000000..f74f096bab --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppMgrNativeChildNotifyStubFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppMgrNativeChildNotifyStubFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp new file mode 100644 index 0000000000..28c4dd326a --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.cpp @@ -0,0 +1,130 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "abilityinterfacesappmgrnativechildnotifystub_fuzzer.h" + +#include +#include + +#define private public +#define protected public +#include "native_child_notify_stub.h" +#include "native_child_notify_interface.h" +#undef protected +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string NATIVE_CHILD_NOTIFY_TOKEN = u"ohos.appexecfwk.NativeChildNotify"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} + +class NativeChildNotifyStubFUZZ : public NativeChildNotifyStub { +public: + explicit NativeChildNotifyStubFUZZ() {}; + virtual ~ NativeChildNotifyStubFUZZ() {}; + int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override{ return 0; }; + void OnNativeChildStarted(const sptr &nativeChild) override{}; + void OnError(int32_t errCode) override{}; +}; + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + uint32_t code = static_cast(INativeChildNotify::IPC_ID_ON_NATIVE_CHILD_STARTED); + MessageParcel parcel; + parcel.WriteInterfaceToken(NATIVE_CHILD_NOTIFY_TOKEN); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + MessageParcel reply; + MessageOption option; + std::shared_ptr abms = std::make_shared(); + abms->OnRemoteRequest(code, parcel, reply, option); + code = static_cast(INativeChildNotify::IPC_ID_ON_ERROR); + abms->OnRemoteRequest(code, parcel, reply, option); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.h b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.h new file mode 100644 index 0000000000..61c9f09489 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/abilityinterfacesappmgrnativechildnotifystub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRNATIVECHILDNOTIFYSTUB_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRNATIVECHILDNOTIFYSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmgrnativechildnotifystub_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRNATIVECHILDNOTIFYSTUB_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrnativechildnotifystub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/BUILD.gn b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/BUILD.gn new file mode 100644 index 0000000000..4f0d0d3d08 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/BUILD.gn @@ -0,0 +1,82 @@ +# Copyright (c) 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +#####################hydra-fuzz################### +import("//build/config/features.gni") +import("//build/ohos.gni") +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") +module_output_path = "ability_runtime/abilitymgr" + +##############################fuzztest########################################## +ohos_fuzztest("AbilityInterfacesAppMgrRenderStateObserverStubFuzzTest") { + module_out_path = module_output_path + + cflags_cc = [] + fuzz_config_file = "${ability_runtime_test_path}/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer" + include_dirs = [ "${ability_runtime_services_path}/appmgr/include" ] + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + ] + sources = [ "abilityinterfacesappmgrrenderstateobserverstub_fuzzer.cpp" ] + + configs = [ "${ability_runtime_services_path}/abilitymgr:abilityms_config" ] + + cflags = [] + if (target_cpu == "arm") { + cflags += [ "-DBINDER_IPC_32BIT" ] + } + + deps = [ + "${ability_runtime_innerkits_path}/app_manager:app_manager", + "${ability_runtime_native_path}/ability/native:abilitykit_native", + "${ability_runtime_services_path}/abilitymgr:abilityms", + "${ability_runtime_services_path}/appmgr:libappms", + "${ability_runtime_services_path}/common:perm_verification", + ] + + external_deps = [ + "ability_base:session_info", + "ability_base:want", + "ability_base:zuri", + "appspawn:appspawn_client", + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "common_event_service:cesfwk_innerkits", + "ffrt:libffrt", + "init:libbegetutil", + "ipc:ipc_core", + "napi:ace_napi", + "safwk:system_ability_fwk", + "samgr:samgr_proxy", + ] + + if (ability_runtime_graphics) { + external_deps += [ "input:libmmi-client" ] + } +} + +############################################################################### +group("fuzztest") { + testonly = true + deps = [] + deps += [ + # deps file + ":AbilityInterfacesAppMgrRenderStateObserverStubFuzzTest", + ] +} +############################################################################### diff --git a/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/abilityinterfacesappmgrrenderstateobserverstub_fuzzer.cpp b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/abilityinterfacesappmgrrenderstateobserverstub_fuzzer.cpp new file mode 100644 index 0000000000..45185994cb --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/abilityinterfacesappmgrrenderstateobserverstub_fuzzer.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "abilityinterfacesappmgrrenderstateobserverstub_fuzzer.h" + +#include +#include + +#define private public +#include "render_state_observer_stub.h" +#undef private + +#include "securec.h" +#include "parcel.h" +#include "ability_record.h" + +using namespace OHOS::AAFwk; +using namespace OHOS::AppExecFwk; + +namespace OHOS { +namespace { +constexpr int INPUT_ZERO = 0; +constexpr int INPUT_ONE = 1; +constexpr int INPUT_TWO = 2; +constexpr int INPUT_THREE = 3; +constexpr size_t FOO_MAX_LEN = 1024; +constexpr size_t U32_AT_SIZE = 4; +constexpr size_t OFFSET_ZERO = 24; +constexpr size_t OFFSET_ONE = 16; +constexpr size_t OFFSET_TWO = 8; +constexpr uint8_t ENABLE = 2; +} +const std::u16string IR_ENDER_STATE_OBSERVER_TOKEN = u"ohos.appexecfwk.IRenderStateObserver"; +uint32_t GetU32Data(const char* ptr) +{ + // convert fuzz input data to an integer + return (ptr[INPUT_ZERO] << OFFSET_ZERO) | (ptr[INPUT_ONE] << OFFSET_ONE) | (ptr[INPUT_TWO] << OFFSET_TWO) | + ptr[INPUT_THREE]; +} +class RenderStateObserverStubFUZZ : public RenderStateObserverStub { +public: + explicit RenderStateObserverStubFUZZ() {}; + virtual ~ RenderStateObserverStubFUZZ() {}; + int OnRemoteRequest( + uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override{ return 0; }; + void OnRenderStateChanged(const RenderStateData &renderStateData) override{}; +}; + +sptr GetFuzzAbilityToken() +{ + sptr token = nullptr; + AbilityRequest abilityRequest; + abilityRequest.appInfo.bundleName = "com.example.fuzzTest"; + abilityRequest.abilityInfo.name = "MainAbility"; + abilityRequest.abilityInfo.type = AbilityType::DATA; + std::shared_ptr abilityRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + if (abilityRecord) { + token = abilityRecord->GetToken(); + } + return token; +} + +bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) +{ + uint32_t code = static_cast(IRenderStateObserver::ON_RENDER_STATE_CHANGED); + MessageParcel parcel; + parcel.WriteInterfaceToken(IR_ENDER_STATE_OBSERVER_TOKEN); + parcel.WriteBuffer(data, size); + parcel.RewindRead(0); + MessageParcel reply; + MessageOption option; + std::shared_ptr abms = std::make_shared(); + abms->OnRemoteRequest(code, parcel, reply, option); + return true; +} +} + +/* Fuzzer entry point */ +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + /* Run your code on data */ + if (data == nullptr) { + std::cout << "invalid data" << std::endl; + return 0; + } + + /* Validate the length of size */ + if (size > OHOS::FOO_MAX_LEN || size < OHOS::U32_AT_SIZE) { + return 0; + } + + char* ch = (char*)malloc(size + 1); + if (ch == nullptr) { + std::cout << "malloc failed." << std::endl; + return 0; + } + + (void)memset_s(ch, size + 1, 0x00, size + 1); + if (memcpy_s(ch, size + 1, data, size) != EOK) { + std::cout << "copy failed." << std::endl; + free(ch); + ch = nullptr; + return 0; + } + + OHOS::DoSomethingInterestingWithMyAPI(ch, size); + free(ch); + ch = nullptr; + return 0; +} + diff --git a/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/abilityinterfacesappmgrrenderstateobserverstub_fuzzer.h b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/abilityinterfacesappmgrrenderstateobserverstub_fuzzer.h new file mode 100644 index 0000000000..a332fb4dff --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/abilityinterfacesappmgrrenderstateobserverstub_fuzzer.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRRENDERSTATEOBSERVERSTUB_FUZZER_H +#define FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRRENDERSTATEOBSERVERSTUB_FUZZER_H + +#define FUZZ_PROJECT_NAME "abilityinterfacesappmgrrenderstateobserverstub_fuzzer" + +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYINTERFACESAPPMGRRENDERSTATEOBSERVERSTUB_FUZZER_H diff --git a/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/corpus/init b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/corpus/init new file mode 100644 index 0000000000..6198079a28 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/corpus/init @@ -0,0 +1,16 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +FUZZ \ No newline at end of file diff --git a/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/project.xml b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/project.xml new file mode 100644 index 0000000000..7133b2b924 --- /dev/null +++ b/test/fuzztest/abilityinterfacesappmgrrenderstateobserverstub_fuzzer/project.xml @@ -0,0 +1,25 @@ + + + + + + 1000 + + 300 + + 4096 + + diff --git a/test/fuzztest/abilitymanagerservicefirst_fuzzer/abilitymanagerservicefirst_fuzzer.cpp b/test/fuzztest/abilitymanagerservicefirst_fuzzer/abilitymanagerservicefirst_fuzzer.cpp index b3120b5832..ac802e6dd8 100755 --- a/test/fuzztest/abilitymanagerservicefirst_fuzzer/abilitymanagerservicefirst_fuzzer.cpp +++ b/test/fuzztest/abilitymanagerservicefirst_fuzzer/abilitymanagerservicefirst_fuzzer.cpp @@ -134,8 +134,10 @@ void DoSomethingInterestingWithMyAPI2(AbilityManagerService &abilityms, Want& wa sptr observer; abilityms.RegisterObserver(observer); abilityms.UnregisterObserver(observer); +#ifdef WITH_DLP std::vector infos; abilityms.GetDlpConnectionInfos(infos); +#endif // WITH_DLP std::vector connectionData; abilityms.GetConnectionData(connectionData); diff --git a/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.cpp b/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.cpp index 6ab1c5050b..3163b806d3 100644 --- a/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.cpp +++ b/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.cpp @@ -27,9 +27,7 @@ #include #include "securec.h" #include "configuration.h" - using namespace OHOS::AppExecFwk; - namespace OHOS { namespace { constexpr int INPUT_ZERO = 0; @@ -52,8 +50,7 @@ uint32_t GetU32Data(const char* ptr) bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { - - std::shared_ptrmemLevelInfo = std::make_shared(); + std::shared_ptr memLevelInfo = std::make_shared(); if (memLevelInfo == nullptr) { return false; } diff --git a/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.h b/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.h index af781c52c6..973a384f62 100644 --- a/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.h +++ b/test/fuzztest/abilitymemorylevelinfo_fuzzer/abilitymemorylevelinfo_fuzzer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 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,4 +18,4 @@ #define FUZZ_PROJECT_NAME "abilitymemorylevelinfo_fuzzer" -#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMANAGERSERVICEA_FUZZER_H +#endif // FUZZTEST_OHOS_ABILITY_RUNTIME_ABILITYMEMORYLEVELINFO_FUZZER_H diff --git a/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/abilitystubgetdlpconnectioninfos_fuzzer.cpp b/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/abilitystubgetdlpconnectioninfos_fuzzer.cpp index d197bff817..f584365c3b 100644 --- a/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/abilitystubgetdlpconnectioninfos_fuzzer.cpp +++ b/test/fuzztest/abilitystubgetdlpconnectioninfos_fuzzer/abilitystubgetdlpconnectioninfos_fuzzer.cpp @@ -35,7 +35,9 @@ const std::u16string ABILITYMGR_INTERFACE_TOKEN = u"ohos.aafwk.AbilityManager"; bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) { +#ifdef WITH_DLP uint32_t code = static_cast(AbilityManagerInterfaceCode::GET_DLP_CONNECTION_INFOS); +#endif // WITH_DLP MessageParcel parcel; parcel.WriteInterfaceToken(ABILITYMGR_INTERFACE_TOKEN); @@ -47,7 +49,9 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) std::make_shared(nullptr, nullptr); DelayedSingleton::GetInstance()->subManagersHelper_->currentUIAbilityManager_ = std::make_shared(); +#ifdef WITH_DLP DelayedSingleton::GetInstance()->OnRemoteRequest(code, parcel, reply, option); +#endif // WITH_DLP return true; } diff --git a/test/fuzztest/appmgrservicefirst_fuzzer/appmgrservicefirst_fuzzer.cpp b/test/fuzztest/appmgrservicefirst_fuzzer/appmgrservicefirst_fuzzer.cpp index b70126f06c..5bb18ed7f2 100644 --- a/test/fuzztest/appmgrservicefirst_fuzzer/appmgrservicefirst_fuzzer.cpp +++ b/test/fuzztest/appmgrservicefirst_fuzzer/appmgrservicefirst_fuzzer.cpp @@ -105,7 +105,7 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) appMgrService->Dump(fd, args); std::string result(data, size); appMgrService->Dump(args, result); - appMgrService->ShowHelp(result); + appMgrService->ShowHelp(args, result); std::string flag(data, size); appMgrService->ScheduleAcceptWantDone(recordId, *want, flag); Configuration config; diff --git a/test/fuzztest/connectionobserverclient_fuzzer/connectionobserverclient_fuzzer.cpp b/test/fuzztest/connectionobserverclient_fuzzer/connectionobserverclient_fuzzer.cpp index 8ff97f6178..02438a4181 100755 --- a/test/fuzztest/connectionobserverclient_fuzzer/connectionobserverclient_fuzzer.cpp +++ b/test/fuzztest/connectionobserverclient_fuzzer/connectionobserverclient_fuzzer.cpp @@ -61,10 +61,12 @@ public: {} void OnExtensionDisconnected(const ConnectionData& data) override {} +#ifdef WITH_DLP void OnDlpAbilityOpened(const DlpStateData& data) override {} void OnDlpAbilityClosed(const DlpStateData& data) override {} +#endif // WITH_DLP sptr AsObject() override { return {}; diff --git a/test/fuzztest/connectionobserverclientimpl_fuzzer/connectionobserverclientimpl_fuzzer.cpp b/test/fuzztest/connectionobserverclientimpl_fuzzer/connectionobserverclientimpl_fuzzer.cpp index e551477109..cb1c200d65 100755 --- a/test/fuzztest/connectionobserverclientimpl_fuzzer/connectionobserverclientimpl_fuzzer.cpp +++ b/test/fuzztest/connectionobserverclientimpl_fuzzer/connectionobserverclientimpl_fuzzer.cpp @@ -70,9 +70,11 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) AbilityRuntime::ConnectionData connectionData; connectionObserverClientImpl->HandleExtensionConnected(connectionData); connectionObserverClientImpl->HandleExtensionDisconnected(connectionData); +#ifdef WITH_DLP AbilityRuntime::DlpStateData dlpStateData; connectionObserverClientImpl->HandleDlpAbilityOpened(dlpStateData); connectionObserverClientImpl->HandleDlpAbilityClosed(dlpStateData); +#endif // WITH_DLP sptr remoteObj; auto serviceProxyAdapter = std::make_shared(remoteObj); connectionObserverClientImpl->UnregisterFromServiceLocked(serviceProxyAdapter); diff --git a/test/fuzztest/connectionstatemanager_fuzzer/connectionstatemanager_fuzzer.cpp b/test/fuzztest/connectionstatemanager_fuzzer/connectionstatemanager_fuzzer.cpp index c874abb472..043e9c1408 100755 --- a/test/fuzztest/connectionstatemanager_fuzzer/connectionstatemanager_fuzzer.cpp +++ b/test/fuzztest/connectionstatemanager_fuzzer/connectionstatemanager_fuzzer.cpp @@ -61,10 +61,12 @@ public: {} void OnExtensionDisconnected(const ConnectionData& data) override {} +#ifdef WITH_DLP void OnDlpAbilityOpened(const DlpStateData& data) override {} void OnDlpAbilityClosed(const DlpStateData& data) override {} +#endif // WITH_DLP sptr AsObject() override { return {}; @@ -128,9 +130,11 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) connectionObserverController->RemoveObserver(observer); connectionObserverController->NotifyExtensionConnected(connectionData); connectionObserverController->NotifyExtensionDisconnected(connectionData); +#ifdef WITH_DLP AbilityRuntime::DlpStateData dlpStateData; connectionObserverController->NotifyDlpAbilityOpened(dlpStateData); connectionObserverController->NotifyDlpAbilityClosed(dlpStateData); +#endif // WITH_DLP connectionObserverController->GetObservers(); wptr remote; connectionObserverController->HandleRemoteDied(remote); @@ -198,14 +202,18 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) connectionStateManager->CheckDataAbilityConnectionParams(dataCaller, dataAbility); connectionStateManager->HandleDataAbilityDied(dataAbility); connectionStateManager->HandleDataAbilityCallerDied(int32Param); +#ifdef WITH_DLP std::shared_ptr dlpManger = GetFuzzAbilityRecord(); connectionStateManager->AddDlpManager(dlpManger); connectionStateManager->RemoveDlpManager(dlpManger); connectionStateManager->AddDlpAbility(dlpManger); connectionStateManager->RemoveDlpAbility(dlpManger); +#endif // WITH_DLP connectionStateManager->HandleAppDied(int32Param); +#ifdef WITH_DLP std::vector infos; connectionStateManager->GetDlpConnectionInfos(infos); +#endif // WITH_DLP connectionStateManager->AddConnectionInner(connectionRecord, connectionData); connectionStateManager->RemoveConnectionInner(connectionRecord, connectionData); connectionStateManager->HandleCallerDied(int32Param); @@ -213,8 +221,10 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) connectionStateManager->AddDataAbilityConnectionInner(dataCaller, dataAbility, connectionData); connectionStateManager->RemoveDataAbilityConnectionInner(dataCaller, dataAbility, connectionData); connectionStateManager->HandleDataAbilityDiedInner(token, datas); +#ifdef WITH_DLP AbilityRuntime::DlpStateData dlpData; connectionStateManager->HandleDlpAbilityInner(dlpManger, boolParam, dlpData); +#endif // WITH_DLP connectionStateManager->InitAppStateObserver(); if (want) { delete want; diff --git a/test/fuzztest/extensionrecordfactory_fuzzer/BUILD.gn b/test/fuzztest/extensionrecordfactory_fuzzer/BUILD.gn index 21e2f35b54..59880c8336 100644 --- a/test/fuzztest/extensionrecordfactory_fuzzer/BUILD.gn +++ b/test/fuzztest/extensionrecordfactory_fuzzer/BUILD.gn @@ -64,6 +64,7 @@ ohos_fuzztest("ExtensionRecordFactoryFuzzTest") { "ffrt:libffrt", "hilog:libhilog", "hitrace:hitrace_meter", + "init:libbegetutil", "ipc:ipc_core", "napi:ace_napi", "safwk:system_ability_fwk", diff --git a/test/fuzztest/handledlpapp_fuzzer/handledlpapp_fuzzer.cpp b/test/fuzztest/handledlpapp_fuzzer/handledlpapp_fuzzer.cpp index 8d103ef66e..8986fd642f 100755 --- a/test/fuzztest/handledlpapp_fuzzer/handledlpapp_fuzzer.cpp +++ b/test/fuzztest/handledlpapp_fuzzer/handledlpapp_fuzzer.cpp @@ -44,7 +44,9 @@ bool DoSomethingInterestingWithMyAPI(const char* data, size_t size) if (wantParcel.WriteBuffer(data, size)) { want = Want::Unmarshalling(wantParcel); if (want) { +#ifdef WITH_DLP abilitymgr->HandleDlpApp(*want); +#endif // WITH_DLP delete want; want = nullptr; } diff --git a/test/fuzztest/uiextensionrecordfactory_fuzzer/BUILD.gn b/test/fuzztest/uiextensionrecordfactory_fuzzer/BUILD.gn index 89810bba5f..df78d71143 100644 --- a/test/fuzztest/uiextensionrecordfactory_fuzzer/BUILD.gn +++ b/test/fuzztest/uiextensionrecordfactory_fuzzer/BUILD.gn @@ -65,6 +65,7 @@ ohos_fuzztest("UIExtensionRecordFactoryFuzzTest") { "ffrt:libffrt", "hilog:libhilog", "hitrace:hitrace_meter", + "init:libbegetutil", "ipc:ipc_core", "napi:ace_napi", "safwk:system_ability_fwk", diff --git a/test/mock/ability_manager_collaborator/mock_ability_manager_collaborator.h b/test/mock/ability_manager_collaborator/mock_ability_manager_collaborator.h index 80625feb28..6b30555674 100644 --- a/test/mock/ability_manager_collaborator/mock_ability_manager_collaborator.h +++ b/test/mock/ability_manager_collaborator/mock_ability_manager_collaborator.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h index df48c6a532..cd51b78392 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ability_manager_client.h @@ -18,17 +18,16 @@ #include #include - -#include "ability_connect_callback_interface.h" -#include "ability_manager_errors.h" -#include "ability_manager_interface.h" -#include "ability_scheduler_interface.h" #include "abs_shared_result_set.h" #include "data_ability_predicates.h" +#include "values_bucket.h" +#include "ability_connect_callback_interface.h" +#include "ability_manager_errors.h" #include "fa_ability_context.h" +#include "ability_manager_interface.h" +#include "ability_scheduler_interface.h" #include "iremote_object.h" #include "iremote_stub.h" -#include "values_bucket.h" #include "want.h" #define OPENFILENUM (1246) diff --git a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h index 61926301f7..639aae47e4 100644 --- a/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h +++ b/test/mock/frameworks_kits_ability_native_test/include/mock_ui_content.h @@ -56,7 +56,6 @@ public: MOCK_METHOD3(UpdateViewportConfig, void(const ViewportConfig &config, OHOS::Rosen::WindowSizeChangeReason reason, const std::shared_ptr &rsTransaction)); MOCK_METHOD2(UpdateWindowMode, void(OHOS::Rosen::WindowMode mode, bool hasDeco)); - MOCK_METHOD1(NotifyWindowMode, void(OHOS::Rosen::WindowMode mode)); MOCK_METHOD2(UpdateTitleInTargetPos, void(bool isShow, int32_t height)); MOCK_METHOD2(UpdateDecorVisible, void(bool visible, bool hasDeco)); MOCK_METHOD3(HideWindowTitleButton, void(bool hideSplit, bool hideMaximize, bool hideMinimize)); diff --git a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h index 91948e2146..814a75f345 100644 --- a/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h +++ b/test/mock/frameworks_kits_appkit_test/include/mock_app_mgr_service.h @@ -83,9 +83,9 @@ public: MOCK_METHOD1(RegisterRenderStateObserver, int32_t(const sptr &observer)); MOCK_METHOD1(UnregisterRenderStateObserver, int32_t(const sptr &observer)); MOCK_METHOD2(UpdateRenderState, int32_t(pid_t renderPid, int32_t state)); - MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupported)); MOCK_METHOD2(GetRunningMultiAppInfoByBundleName, int32_t(const std::string &bundleName, RunningMultiAppInfo &info)); + MOCK_METHOD1(SetSupportedProcessCacheSelf, int32_t(bool isSupported)); MOCK_METHOD3(StartNativeChildProcess, int32_t(const std::string &libName, int32_t childProcessCount, const sptr &callback)); diff --git a/test/mock/frameworks_kits_runtime_test/mock_runtime.h b/test/mock/frameworks_kits_runtime_test/mock_runtime.h index d2ff739231..f8250b441e 100644 --- a/test/mock/frameworks_kits_runtime_test/mock_runtime.h +++ b/test/mock/frameworks_kits_runtime_test/mock_runtime.h @@ -120,8 +120,7 @@ public: void DoCleanWorkAfterStageCleaned() override {} void DumpHeapSnapshot(uint32_t tid, bool isFullGC) override {} void ForceFullGC(uint32_t tid) override {} - - void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override {}; + void UpdatePkgContextInfoJson(std::string moduleName, std::string hapPath, std::string packageName) override {} public: Language language; }; diff --git a/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h b/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h index bb1715ec72..1670a91eae 100644 --- a/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h +++ b/test/mock/prepare_terminate_callback/mock_prepare_terminate_callback.h @@ -1,6 +1,6 @@ /* * Copyright (c) 2023 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); + * 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 * diff --git a/test/mock/services_appmgr_test/include/mock_app_scheduler.h b/test/mock/services_appmgr_test/include/mock_app_scheduler.h index 14a2e97ed0..ab2957c17f 100644 --- a/test/mock/services_appmgr_test/include/mock_app_scheduler.h +++ b/test/mock/services_appmgr_test/include/mock_app_scheduler.h @@ -65,9 +65,9 @@ public: MOCK_METHOD1(ScheduleDumpIpcStart, int32_t(std::string &result)); MOCK_METHOD1(ScheduleDumpIpcStop, int32_t(std::string &result)); MOCK_METHOD1(ScheduleDumpIpcStat, int32_t(std::string &result)); - MOCK_METHOD0(IsMemorySizeSufficent, bool()); MOCK_METHOD1(ScheduleDumpFfrt, int32_t(std::string& result)); MOCK_METHOD0(ScheduleClearPageStack, void()); + MOCK_METHOD0(IsMemorySizeSufficent, bool()); MOCK_METHOD0(ScheduleCacheProcess, void()); }; } // namespace AppExecFwk diff --git a/test/mock/services_appmgr_test/include/mock_application.h b/test/mock/services_appmgr_test/include/mock_application.h index c5a14c15e6..1d19080d02 100644 --- a/test/mock/services_appmgr_test/include/mock_application.h +++ b/test/mock/services_appmgr_test/include/mock_application.h @@ -50,7 +50,6 @@ public: MOCK_METHOD1(ScheduleNotifyAppFault, int32_t(const FaultData &faultData)); MOCK_METHOD0(AttachAppDebug, void()); MOCK_METHOD0(DetachAppDebug, void()); - MOCK_METHOD1(ScheduleJsHeapMemory, void(OHOS::AppExecFwk::JsHeapDumpInfo &info)); MOCK_METHOD2(SetAppWaitingDebug, int32_t(const std::string &bundleName, bool isPersist)); MOCK_METHOD0(CancelAppWaitingDebug, int32_t()); MOCK_METHOD1(GetWaitingDebugApp, int32_t(std::vector &debugInfoList)); @@ -60,6 +59,7 @@ public: MOCK_METHOD1(ScheduleDumpIpcStop, int32_t(std::string &result)); MOCK_METHOD1(ScheduleDumpIpcStat, int32_t(std::string &result)); MOCK_METHOD0(IsMemorySizeSufficent, bool()); + MOCK_METHOD1(ScheduleJsHeapMemory, void(OHOS::AppExecFwk::JsHeapDumpInfo &info)); MOCK_METHOD1(ScheduleDumpFfrt, int32_t(std::string& result)); MOCK_METHOD0(ScheduleClearPageStack, void()); MOCK_METHOD0(ScheduleCacheProcess, void()); diff --git a/test/moduletest/ability_delegator_test/ability_delegator_module_test.cpp b/test/moduletest/ability_delegator_test/ability_delegator_module_test.cpp index 5e3cda2168..4c11434a78 100644 --- a/test/moduletest/ability_delegator_test/ability_delegator_module_test.cpp +++ b/test/moduletest/ability_delegator_test/ability_delegator_module_test.cpp @@ -31,11 +31,11 @@ #include "mock_iability_monitor.h" #include "mock_test_observer_stub.h" #include "ohos_application.h" -#include "scene_board_judgement.h" #include "test_observer_stub.h" #include "test_observer.h" #include "test_runner.h" #include "want.h" +#include "scene_board_judgement.h" using namespace testing::ext; using namespace OHOS; diff --git a/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp b/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp index c54cd3648f..cd31741a1f 100644 --- a/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp +++ b/test/moduletest/common/ams/ability_running_record_test/ams_ability_running_record_module_test.cpp @@ -203,6 +203,9 @@ public: return 0; } + void ScheduleCacheProcess() override + {} + int32_t ScheduleDumpFfrt(std::string& result) override { return 0; @@ -210,8 +213,6 @@ public: void ScheduleClearPageStack() override {} - void ScheduleCacheProcess() override - {} private: int abilityLaunchTime = 0; diff --git a/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp b/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp index 4d4f0b2580..2895a543f1 100644 --- a/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp +++ b/test/moduletest/common/ams/app_mgr_service_test/ams_app_mgr_service_module_test.cpp @@ -124,14 +124,15 @@ public: return 0; } + void ScheduleCacheProcess() override + {} + int32_t ScheduleDumpFfrt(std::string& result) override { return 0; } - void ScheduleClearPageStack() override - {} - void ScheduleCacheProcess() override + void ScheduleClearPageStack() override {} }; class AppMgrServiceModuleTest : public testing::Test { diff --git a/test/sample/demo_ui_extension/native/demo_ui_extension_ability/src/js_demo_ui_extension.cpp b/test/sample/demo_ui_extension/native/demo_ui_extension_ability/src/js_demo_ui_extension.cpp index cc0ad23d01..54347d66ff 100644 --- a/test/sample/demo_ui_extension/native/demo_ui_extension_ability/src/js_demo_ui_extension.cpp +++ b/test/sample/demo_ui_extension/native/demo_ui_extension_ability/src/js_demo_ui_extension.cpp @@ -15,6 +15,7 @@ #include "js_demo_ui_extension.h" +#include "hilog_tag_wrapper.h" #include "js_ui_extension_base.h" #include "js_demo_ui_extension_context.h" diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index ea14f61259..4944fdb825 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -466,6 +466,7 @@ group("unittest") { "event_report_test:unittest", "extension_config_mgr_test:unittest", "extension_manager_client_test:unittest", + "extension_permissions_util_test:unittest", "fault_data:unittest", "file_path_utils_test:unittest", "frameworks_kits_ability_ability_runtime_test:unittest", diff --git a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp index 60430f59ca..7f15247be4 100644 --- a/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp +++ b/test/unittest/ability_manager_client_branch_test/ability_manager_client_branch_test.cpp @@ -1749,6 +1749,7 @@ HWTEST_F(AbilityManagerClientBranchTest, StartAbilityByUIContentSession_0200, Te GTEST_LOG_(INFO) << "StartUIExtensionAbility_0200 end"; } +#ifdef WITH_DLP /** * @tc.number: NotifySaveAsResult_0100 * @tc.name: NotifySaveAsResult @@ -1760,6 +1761,7 @@ HWTEST_F(AbilityManagerClientBranchTest, NotifySaveAsResult_0100, TestSize.Level auto result = client_->NotifySaveAsResult(want, 0, 0); EXPECT_EQ(result, ERR_OK); } +#endif // WITH_DLP /** * @tc.number: PrepareTerminateAbility_0100 @@ -1787,6 +1789,7 @@ HWTEST_F(AbilityManagerClientBranchTest, PrepareTerminateAbilityBySCB_0100, Test EXPECT_EQ(result, ERR_OK); } +#ifdef WITH_DLP /** * @tc.number: UpdateMissionSnapShot_0100 * @tc.name: UpdateMissionSnapShot @@ -1799,6 +1802,7 @@ HWTEST_F(AbilityManagerClientBranchTest, UpdateMissionSnapShot_0100, TestSize.Le auto pixelMap = std::shared_ptr(); client_->UpdateMissionSnapShot(token, pixelMap); } +#endif // WITH_DLP /** * @tc.name: AbilityManagerClient_RegisterSessionHandler_0100 @@ -2578,36 +2582,6 @@ HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_GetAbilityStateByP GTEST_LOG_(INFO) << "AbilityManagerClient_GetAbilityStateByPersistentId_0100 end"; } -/** - * @tc.name: AbilityManagerClient_RegisterStatusBarDelegate_0100 - * @tc.desc: RegisterStatusBarDelegate - * @tc.type: FUNC - */ -HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_RegisterStatusBarDelegate_0100, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AbilityManagerClient_RegisterStatusBarDelegate_0100 start"; - ErrCode ret = client_->RegisterStatusBarDelegate(nullptr); - EXPECT_EQ(ret, ERR_OK); - GTEST_LOG_(INFO) << "AbilityManagerClient_RegisterStatusBarDelegate_0100 end"; -} - -#ifdef SUPPORT_GRAPHICS -/** - * @tc.name: AbilityManagerClient_SetMissionLabel_0100 - * @tc.desc: SetMissionLabel - * @tc.type: FUNC - */ -HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_SetMissionLabel_0100, TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AbilityManagerClient_SetMissionLabel_0100 start"; - sptr token = nullptr; - std::string label = "label"; - ErrCode ret = client_->SetMissionLabel(token, label); - EXPECT_EQ(ret, ERR_OK); - GTEST_LOG_(INFO) << "AbilityManagerClient_SetMissionLabel_0100 end"; -} -#endif - /** * @tc.name: AbilityManagerClient_TransferAbilityResultForExtension_0100 * @tc.desc: TransferAbilityResult @@ -2637,5 +2611,35 @@ HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_SetResidentProcess EXPECT_TRUE(client_ != nullptr); GTEST_LOG_(INFO) << "AbilityManagerClient_SetResidentProcessEnabled_0100 end"; } + +/** + * @tc.name: AbilityManagerClient_RegisterStatusBarDelegate_0100 + * @tc.desc: RegisterStatusBarDelegate + * @tc.type: FUNC + */ +HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_RegisterStatusBarDelegate_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AbilityManagerClient_RegisterStatusBarDelegate_0100 start"; + ErrCode ret = client_->RegisterStatusBarDelegate(nullptr); + EXPECT_EQ(ret, ERR_OK); + GTEST_LOG_(INFO) << "AbilityManagerClient_RegisterStatusBarDelegate_0100 end"; +} + +#ifdef SUPPORT_GRAPHICS +/** + * @tc.name: AbilityManagerClient_SetMissionLabel_0100 + * @tc.desc: SetMissionLabel + * @tc.type: FUNC + */ +HWTEST_F(AbilityManagerClientBranchTest, AbilityManagerClient_SetMissionLabel_0100, TestSize.Level1) +{ + GTEST_LOG_(INFO) << "AbilityManagerClient_SetMissionLabel_0100 start"; + sptr token = nullptr; + std::string label = "label"; + ErrCode ret = client_->SetMissionLabel(token, label); + EXPECT_EQ(ret, ERR_OK); + GTEST_LOG_(INFO) << "AbilityManagerClient_SetMissionLabel_0100 end"; +} +#endif } // namespace AAFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp index 3837abf974..7570287266 100644 --- a/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp +++ b/test/unittest/ability_manager_service_first_test/ability_manager_service_first_test.cpp @@ -176,10 +176,6 @@ HWTEST_F(AbilityManagerServiceFirstTest, CheckCallAbilityPermission_001, TestSiz abilityMs_->startUpNewRule_ = true; EXPECT_EQ(abilityMs_->CheckCallAbilityPermission(abilityRequest_), ERR_OK); - - MyFlag::flag_ = 1; - EXPECT_EQ(abilityMs_->CheckCallAbilityPermission(abilityRequest_), 1); - MyFlag::flag_ = 0; TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFirstTest CheckCallAbilityPermission_001 end"); } @@ -236,6 +232,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, CheckStartByCallPermission_002, TestSiz TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFirstTest CheckStartByCallPermission_002 end"); } +#ifdef WITH_DLP /* * Feature: AbilityManagerService * Function: GetDlpConnectionInfos @@ -255,6 +252,7 @@ HWTEST_F(AbilityManagerServiceFirstTest, GetDlpConnectionInfos_001, TestSize.Lev MyFlag::flag_ = 0; TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFirstTest GetDlpConnectionInfos_001 end"); } +#endif // WITH_DLP /* * Feature: AbilityManagerService @@ -1472,10 +1470,9 @@ HWTEST_F(AbilityManagerServiceFirstTest, UnregisterAppDebugListener_001, TestSiz HWTEST_F(AbilityManagerServiceFirstTest, AttachAppDebug_001, TestSize.Level1) { auto abilityMs_ = std::make_shared(); - EXPECT_NE(abilityMs_, nullptr); std::string bundleName; - auto result = abilityMs_->AttachAppDebug(bundleName); - EXPECT_EQ(result, CHECK_PERMISSION_FAILED); + abilityMs_->AttachAppDebug(bundleName); + EXPECT_NE(abilityMs_, nullptr); } /** diff --git a/test/unittest/ability_manager_service_first_test/mock/src/mock_permission_verification.cpp b/test/unittest/ability_manager_service_first_test/mock/src/mock_permission_verification.cpp index c5507513b5..a084b6676e 100644 --- a/test/unittest/ability_manager_service_first_test/mock/src/mock_permission_verification.cpp +++ b/test/unittest/ability_manager_service_first_test/mock/src/mock_permission_verification.cpp @@ -42,10 +42,12 @@ bool PermissionVerification::VerifyControllerPerm() const { return !!(MyFlag::flag_); } +#ifdef WITH_DLP bool PermissionVerification::VerifyDlpPermission(Want &want) const { return !!(MyFlag::flag_); } +#endif // WITH_DLP int PermissionVerification::VerifyAccountPermission() const { return MyFlag::flag_; diff --git a/test/unittest/ability_manager_service_fourth_test/BUILD.gn b/test/unittest/ability_manager_service_fourth_test/BUILD.gn index 8558ddb766..0248894758 100644 --- a/test/unittest/ability_manager_service_fourth_test/BUILD.gn +++ b/test/unittest/ability_manager_service_fourth_test/BUILD.gn @@ -22,6 +22,7 @@ ohos_unittest("ability_manager_service_fourth_test") { cfi = true cfi_cross_dso = true debug = false + blocklist = "../../cfi_blocklist.txt" } branch_protector_ret = "pac_ret" @@ -47,6 +48,7 @@ ohos_unittest("ability_manager_service_fourth_test") { "${ability_runtime_services_path}/abilitymgr/src/ability_event_util.cpp", "${ability_runtime_services_path}/abilitymgr/src/auto_startup_info.cpp", "${ability_runtime_services_path}/abilitymgr/src/exit_reason.cpp", + "${ability_runtime_services_path}/abilitymgr/src/insight_intent_execute_manager.cpp", "${ability_runtime_services_path}/common/src/ffrt_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/queue_task_handler_wrap.cpp", "${ability_runtime_services_path}/common/src/task_handler_wrap.cpp", @@ -54,6 +56,7 @@ ohos_unittest("ability_manager_service_fourth_test") { "mock/src/mock_ability_interceptor_executer.cpp", "mock/src/mock_ipc_skeleton.cpp", "mock/src/mock_my_flag.cpp", + "mock/src/mock_parameters.cpp", "mock/src/mock_permission_verification.cpp", ] @@ -72,6 +75,7 @@ ohos_unittest("ability_manager_service_fourth_test") { ] external_deps = [ + "ability_base:configuration", "ability_base:session_info", "ability_base:want", "ability_base:zuri", diff --git a/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp b/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp index e4e5cc4abd..2bc6512ff0 100644 --- a/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp +++ b/test/unittest/ability_manager_service_fourth_test/ability_manager_service_fourth_test.cpp @@ -21,7 +21,9 @@ #include "mock_ipc_skeleton.h" #include "mock_permission_verification.h" #include "mock_my_flag.h" +#include "mock_parameters.h" #include "ability_manager_service.h" +#include "insight_intent_execute_manager.h" #undef private #undef protected #include "hilog_tag_wrapper.h" @@ -29,6 +31,7 @@ #include "ability_bundle_event_callback.h" #include "session/host/include/session.h" #include "system_ability_definition.h" +#include "ability_util.h" using namespace testing; using namespace testing::ext; @@ -427,8 +430,12 @@ HWTEST_F(AbilityManagerServiceFourthTest, InitDeepLinkReserve_001, TestSize.Leve HWTEST_F(AbilityManagerServiceFourthTest, InitInterceptor_001, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest InitInterceptor_001 start"); + OHOS::system::SetBoolParameter(OHOS::AppExecFwk::PARAMETER_APP_JUMP_INTERCEPTOR_ENABLE, false); auto abilityMs_ = std::make_shared(); abilityMs_->InitInterceptor(); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest InitInterceptor_001 mid"); + OHOS::system::SetBoolParameter(OHOS::AppExecFwk::PARAMETER_APP_JUMP_INTERCEPTOR_ENABLE, true); + abilityMs_->InitInterceptor(); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest InitInterceptor_001 end"); } @@ -484,12 +491,28 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbility_001, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbility_001 start"); Want want; - auto callerToken = MockToken(AbilityType::PAGE); + int32_t userId{0}; + int requestCode{0}; auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbility(want, 0, 0); + abilityMs_->StartAbility(want, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbility_001 part 1 end"); + want.SetParam(DEBUG_APP, true); - want.SetParam(DEVELOPER_MODE_STATE, false); - abilityMs_->StartAbility(want, 0, 0); + system::SetBoolParameter(DEVELOPER_MODE_STATE, false); + abilityMs_->StartAbility(want, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbility_001 part 2 end"); + + want.SetParam(DEBUG_APP, false); + want.SetParam(START_ABILITY_TYPE, true); + abilityMs_->StartAbility(want, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbility_001 part 3 end"); + + want.SetParam(DEBUG_APP, false); + want.SetParam(START_ABILITY_TYPE, false); + want.SetParam(Want::PARAM_RESV_WINDOW_LEFT, 1); + system::SetBoolParameter(DEVELOPER_MODE_STATE, true); + abilityMs_->StartAbility(want, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbility_001 part 4 end"); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbility_001 end"); } @@ -519,12 +542,24 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityByFreeInstall_001, TestSiz { TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByFreeInstall_001 start"); Want want; + int32_t userId{0}; + int requestCode{0}; want.SetParam(START_ABILITY_TYPE, true); auto callerToken = MockToken(AbilityType::PAGE); auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityByFreeInstall(want, callerToken, 0, 0); + abilityMs_->StartAbilityByFreeInstall(want, callerToken, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByFreeInstall_001 part 1 end"); + + want.SetParam(START_ABILITY_TYPE, false); - abilityMs_->StartAbilityByFreeInstall(want, callerToken, 0, 0); + want.AddFlags(Want::FLAG_ABILITY_CONTINUATION); + abilityMs_->StartAbilityByFreeInstall(want, callerToken, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByFreeInstall_001 part 2 end"); + + want.SetParam(START_ABILITY_TYPE, false); + want.RemoveFlags(Want::FLAG_ABILITY_CONTINUATION); + abilityMs_->StartAbilityByFreeInstall(want, callerToken, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByFreeInstall_001 part 3 end"); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByFreeInstall_001 end"); } @@ -538,9 +573,19 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityWithSpecifyTokenIdInner_00 { TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityWithSpecifyTokenIdInner_001 start"); Want want; + uint32_t specifyTokenId{0}; + int32_t userId{0}; + int requestCode{0}; auto callerToken = MockToken(AbilityType::PAGE); auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityWithSpecifyTokenIdInner(want, callerToken, 0, 0, 0); + want.AddFlags(Want::FLAG_ABILITY_CONTINUATION); + abilityMs_->StartAbilityWithSpecifyTokenIdInner(want, callerToken, specifyTokenId, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityWithSpecifyTokenIdInner_001 part 1 end"); + + want.RemoveFlags(Want::FLAG_ABILITY_CONTINUATION); + abilityMs_->StartAbilityWithSpecifyTokenIdInner(want, callerToken, specifyTokenId, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityWithSpecifyTokenIdInner_001 part 2 end"); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityWithSpecifyTokenIdInner_001 end"); } @@ -556,8 +601,12 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityWithSpecifyTokenIdInner_00 Want want; StartOptions startOptions; auto callerToken = MockToken(AbilityType::PAGE); + int32_t userId{0}; + int requestCode{0}; + uint32_t callerTokenId{0}; auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityWithSpecifyTokenIdInner(want, startOptions, callerToken, 0, 0, 0); + abilityMs_->StartAbilityWithSpecifyTokenIdInner( + want, startOptions, callerToken, userId, requestCode, callerTokenId); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityWithSpecifyTokenIdInner_002 end"); } @@ -572,8 +621,13 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityByInsightIntent_001, TestS TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByInsightIntent_001 start"); Want want; auto callerToken = MockToken(AbilityType::PAGE); + uint64_t key{0}; + std::string bundleName{""}; + uint64_t intentId{1}; + int32_t userId{0}; + DelayedSingleton::GetInstance()->AddRecord(key, callerToken, bundleName, intentId); auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityByInsightIntent(want, callerToken, 0, 0); + abilityMs_->StartAbilityByInsightIntent(want, callerToken, intentId, userId); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByInsightIntent_001 end"); } @@ -586,10 +640,20 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityByInsightIntent_001, TestS HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityByUIContentSession_001, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByUIContentSession_001 start"); + Want want; auto callerToken = MockToken(AbilityType::PAGE); + sptr sessionInfo{nullptr}; + int32_t userId{0}; + int requestCode{0}; auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityByUIContentSession(want, callerToken, MockSessionInfo(0), 0, 0); + abilityMs_->StartAbilityByUIContentSession(want, callerToken, sessionInfo, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByUIContentSession_001 part 1 end"); + + sessionInfo = MockSessionInfo(0); + abilityMs_->StartAbilityByUIContentSession(want, callerToken, sessionInfo, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByUIContentSession_001 part 2 end"); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByUIContentSession_001 end"); } @@ -605,8 +669,16 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityByUIContentSession_002, Te Want want; StartOptions startOptions; auto callerToken = MockToken(AbilityType::PAGE); + sptr sessionInfo{nullptr}; + int32_t userId{0}; + int requestCode{0}; auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityByUIContentSession(want, startOptions, callerToken, MockSessionInfo(0), 0, 0); + abilityMs_->StartAbilityByUIContentSession(want, startOptions, callerToken, sessionInfo, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByUIContentSession_002 part 1 end"); + + sessionInfo = MockSessionInfo(0); + abilityMs_->StartAbilityByUIContentSession(want, startOptions, callerToken, sessionInfo, userId, requestCode); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByUIContentSession_002 part 2 end"); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityByUIContentSession_002 end"); } @@ -621,8 +693,10 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityAsCaller_001, TestSize.Lev TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityAsCaller_001 start"); Want want; auto callerToken = MockToken(AbilityType::PAGE); + int32_t userId{0}; + int requestCode{0}; auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityAsCaller(want, callerToken, callerToken, 0, 0); + abilityMs_->StartAbilityAsCaller(want, callerToken, callerToken, userId, requestCode); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityAsCaller_001 end"); } @@ -637,8 +711,10 @@ HWTEST_F(AbilityManagerServiceFourthTest, ImplicitStartAbilityAsCaller_001, Test TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ImplicitStartAbilityAsCaller_001 start"); Want want; auto callerToken = MockToken(AbilityType::PAGE); + int32_t userId{0}; + int requestCode{0}; auto abilityMs_ = std::make_shared(); - abilityMs_->ImplicitStartAbilityAsCaller(want, callerToken, callerToken, 0, 0); + abilityMs_->ImplicitStartAbilityAsCaller(want, callerToken, callerToken, userId, requestCode); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest ImplicitStartAbilityAsCaller_001 end"); } @@ -652,9 +728,25 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityAsCallerDetails_001, TestS { TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityAsCallerDetails_001 start"); Want want; + want.AddFlags(Want::FLAG_ABILITY_CONTINUATION); auto callerToken = MockToken(AbilityType::PAGE); + auto asCallerSourceToken = MockToken(AbilityType::PAGE); + int32_t userId{0}; + int requestCode{0}; + bool isImplicit{true}; auto abilityMs_ = std::make_shared(); - abilityMs_->StartAbilityAsCallerDetails(want, callerToken, callerToken, 0, 0, true); + abilityMs_->StartAbilityAsCallerDetails(want, callerToken, asCallerSourceToken, userId, requestCode, isImplicit); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityAsCallerDetails_001 part 1 end"); + + want.RemoveFlags(Want::FLAG_ABILITY_CONTINUATION); + abilityMs_->StartAbilityAsCallerDetails(want, callerToken, asCallerSourceToken, userId, requestCode, isImplicit); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityAsCallerDetails_001 part 2 end"); + + string callerPkg{"test"}; + want.SetParam(AbilityUtil::JUMP_INTERCEPTOR_DIALOG_CALLER_PKG, callerPkg); + want.SetElementName("com.ohos.sceneboard", "com.ohos.sceneboard.systemdialog"); + abilityMs_->StartAbilityAsCallerDetails(want, callerToken, asCallerSourceToken, userId, requestCode, isImplicit); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityAsCallerDetails_001 part 3 end"); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest StartAbilityAsCallerDetails_001 end"); } @@ -699,7 +791,7 @@ HWTEST_F(AbilityManagerServiceFourthTest, StartAbilityPrechainInterceptor_001, T HWTEST_F(AbilityManagerServiceFourthTest, SetReserveInfo_001, TestSize.Level1) { TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest SetReserveInfo_001 start"); - std::string linkString; + std::string linkString{""}; auto abilityMs_ = std::make_shared(); abilityMs_->SetReserveInfo(linkString); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest SetReserveInfo_001 end"); @@ -750,8 +842,14 @@ HWTEST_F(AbilityManagerServiceFourthTest, CheckBrokerCallPermission_001, TestSiz Want want; AbilityRequest abilityRequest; AppExecFwk::AbilityInfo abilityInfo; + abilityInfo.visible = false; auto abilityMs_ = std::make_shared(); abilityMs_->CheckBrokerCallPermission(abilityRequest, abilityInfo); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest CheckBrokerCallPermission_001 part 1 end"); + + abilityInfo.visible = true; + abilityMs_->CheckBrokerCallPermission(abilityRequest, abilityInfo); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest CheckBrokerCallPermission_001 part 2 end"); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest CheckBrokerCallPermission_001 end"); } @@ -766,8 +864,9 @@ HWTEST_F(AbilityManagerServiceFourthTest, CheckAbilityCallPermission_001, TestSi TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest CheckAbilityCallPermission_001 start"); AbilityRequest abilityRequest; AppExecFwk::AbilityInfo abilityInfo; + uint32_t specifyTokenId{0}; auto abilityMs_ = std::make_shared(); - abilityMs_->CheckAbilityCallPermission(abilityRequest, abilityInfo, 0); + abilityMs_->CheckAbilityCallPermission(abilityRequest, abilityInfo, specifyTokenId); TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceFourthTest CheckAbilityCallPermission_001 end"); } diff --git a/test/unittest/ability_manager_service_fourth_test/mock/include/mock_parameters.h b/test/unittest/ability_manager_service_fourth_test/mock/include/mock_parameters.h new file mode 100644 index 0000000000..a920a04936 --- /dev/null +++ b/test/unittest/ability_manager_service_fourth_test/mock/include/mock_parameters.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MOCK_PARAMETERS_H +#define MOCK_PARAMETERS_H + +#include + +namespace OHOS { +namespace system { + +void SetBoolParameter(const std::string& key, bool def); + +bool GetBoolParameter(const std::string& key, bool def); + +} // namespace system +} // namespace OHOS + +#endif // MOCK_PARAMETERS_H diff --git a/test/unittest/ability_manager_service_fourth_test/mock/include/mock_permission_verification.h b/test/unittest/ability_manager_service_fourth_test/mock/include/mock_permission_verification.h index e8e1cebee2..d0b5a8b5e8 100644 --- a/test/unittest/ability_manager_service_fourth_test/mock/include/mock_permission_verification.h +++ b/test/unittest/ability_manager_service_fourth_test/mock/include/mock_permission_verification.h @@ -51,7 +51,9 @@ public: bool VerifyControllerPerm() const; +#ifdef WITH_DLP bool VerifyDlpPermission(Want &want) const; +#endif // WITH_DLP int VerifyAccountPermission() const; diff --git a/test/unittest/ability_manager_service_fourth_test/mock/src/mock_parameters.cpp b/test/unittest/ability_manager_service_fourth_test/mock/src/mock_parameters.cpp new file mode 100644 index 0000000000..01fa1d3cf3 --- /dev/null +++ b/test/unittest/ability_manager_service_fourth_test/mock/src/mock_parameters.cpp @@ -0,0 +1,34 @@ +/* + * 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "parameters.h" + +namespace OHOS { +namespace system { + +bool g_returnFlag{false}; + +void SetBoolParameter(const std::string& key, bool def) +{ + g_returnFlag = def; +} + +bool GetBoolParameter(const std::string& key, bool def) +{ + return g_returnFlag; +} + +} // namespace system +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/ability_manager_service_fourth_test/mock/src/mock_permission_verification.cpp b/test/unittest/ability_manager_service_fourth_test/mock/src/mock_permission_verification.cpp index 1180db7452..e05c7af097 100644 --- a/test/unittest/ability_manager_service_fourth_test/mock/src/mock_permission_verification.cpp +++ b/test/unittest/ability_manager_service_fourth_test/mock/src/mock_permission_verification.cpp @@ -42,10 +42,12 @@ bool PermissionVerification::VerifyControllerPerm() const { return !!(MyFlag::flag_); } +#ifdef WITH_DLP bool PermissionVerification::VerifyDlpPermission(Want &want) const { return !!(MyFlag::flag_); } +#endif // WITH_DLP int PermissionVerification::VerifyAccountPermission() const { return MyFlag::flag_; diff --git a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp index 171ef9597b..2d0c9972c4 100644 --- a/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp +++ b/test/unittest/ability_manager_service_third_test/ability_manager_service_third_test.cpp @@ -2208,6 +2208,7 @@ HWTEST_F(AbilityManagerServiceThirdTest, ChangeUIAbilityVisibilityBySCB_001, Tes EXPECT_EQ(result, ERR_WRONG_INTERFACE_CALL); } +#ifdef WITH_DLP /* * Feature: AbilityManagerService * Function: StartExtensionAbilityInner @@ -2268,6 +2269,36 @@ HWTEST_F(AbilityManagerServiceThirdTest, StartExtensionAbilityInner_003, TestSiz EXPECT_EQ(result, ERR_INVALID_CALLER); } +/* + * Feature: AbilityManagerService + * Function: StartExtensionAbilityInner + * FunctionPoints: AbilityManagerService StartExtensionAbilityInner + */ +HWTEST_F(AbilityManagerServiceThirdTest, StartExtensionAbilityInner_004, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartExtensionAbilityInner_004 start"); + auto abilityMs = std::make_shared(); + Want want; + sptr callerToken = nullptr; + int32_t userId = 0; + AppExecFwk::ExtensionAbilityType extensionType = AppExecFwk::ExtensionAbilityType::VPN; + bool checkSystemCaller = true; + bool isImplicit = true; + bool isDlp = true; + abilityMs->interceptorExecuter_ = std::make_shared(); + abilityMs->subManagersHelper_ = std::make_shared(nullptr, nullptr); + auto result = abilityMs->StartExtensionAbilityInner(want, callerToken, userId, extensionType, checkSystemCaller, + isImplicit, isDlp); + EXPECT_EQ(result, ERR_IMPLICIT_START_ABILITY_FAIL); + + abilityMs-> implicitStartProcessor_ = std::make_shared(); + result = abilityMs->StartExtensionAbilityInner(want, callerToken, userId, extensionType, checkSystemCaller, + isImplicit, isDlp); + EXPECT_EQ(result, ERR_IMPLICIT_START_ABILITY_FAIL); + TAG_LOGI(AAFwkTag::TEST, "AbilityManagerServiceThirdTest StartExtensionAbilityInner_004 end"); +} +#endif // WITH_DLP + /* * Feature: AbilityManagerService * Function: MoveAbilityToBackground diff --git a/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp b/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp index 9ef2da5edb..6aa86ff97a 100644 --- a/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp +++ b/test/unittest/ability_manager_stub_test/ability_manager_stub_test.cpp @@ -2338,6 +2338,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_UnregisterObserver_001, Test EXPECT_EQ(res, NO_ERROR); } +#ifdef WITH_DLP /* * Feature: AbilityManagerService * Function: GetDlpConnectionInfos @@ -2352,6 +2353,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_GetDlpConnectionInfos_001, T auto res = stub_->GetDlpConnectionInfos(infos); EXPECT_EQ(res, NO_ERROR); } +#endif // WITH_DLP /* * Feature: AbilityManagerService @@ -2665,6 +2667,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_UnregisterConnectionObserver EXPECT_EQ(res, ERR_NULL_OBJECT); } +#ifdef WITH_DLP /* * Feature: AbilityManagerService * Function: GetDlpConnectionInfosInner @@ -2680,6 +2683,7 @@ HWTEST_F(AbilityManagerStubTest, AbilityManagerStub_GetDlpConnectionInfosInner_0 auto res = stub_->GetDlpConnectionInfosInner(data, reply); EXPECT_EQ(res, ERR_OK); } +#endif // WITH_DLP /* * Feature: AbilityManagerService diff --git a/test/unittest/ability_record_test/ability_record_test.cpp b/test/unittest/ability_record_test/ability_record_test.cpp index 9f4d65ecab..a15a25c7cc 100644 --- a/test/unittest/ability_record_test/ability_record_test.cpp +++ b/test/unittest/ability_record_test/ability_record_test.cpp @@ -51,7 +51,9 @@ namespace OHOS { namespace AAFwk { namespace { const std::string DEBUG_APP = "debugApp"; +#ifdef WITH_DLP const std::string DLP_BUNDLE_NAME = "com.ohos.dlpmanager"; +#endif // WITH_DLP const std::string SHELL_ASSISTANT_BUNDLENAME = "com.huawei.shell_assistant"; const std::string SHOW_ON_LOCK_SCREEN = "ShowOnLockScreen"; const std::string URI_PERMISSION_TABLE_NAME = "uri_permission"; @@ -2292,6 +2294,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_RevokeUriPermission_001, TestSize.Leve abilityRecord->RevokeUriPermission(); } +#ifdef WITH_DLP /* * Feature: AbilityRecord * Function: HandleDlpClosed @@ -2308,6 +2311,7 @@ HWTEST_F(AbilityRecordTest, AbilityRecord_HandleDlpClosed_001, TestSize.Level1) abilityRecord->appIndex_ = 1; abilityRecord->HandleDlpClosed(); } +#endif // WITH_DLP /* * Feature: AbilityRecord diff --git a/test/unittest/ability_record_test/mock/include/mock_permission_verification.h b/test/unittest/ability_record_test/mock/include/mock_permission_verification.h index 392c2cc273..db67b81ff8 100644 --- a/test/unittest/ability_record_test/mock/include/mock_permission_verification.h +++ b/test/unittest/ability_record_test/mock/include/mock_permission_verification.h @@ -51,7 +51,9 @@ struct VerificationInfo { bool VerifyControllerPerm() const; +#ifdef WITH_DLP bool VerifyDlpPermission(Want &want) const; +#endif // WITH_DLP int VerifyAccountPermission() const; diff --git a/test/unittest/ability_record_test/mock/src/mock_permission_verification.cpp b/test/unittest/ability_record_test/mock/src/mock_permission_verification.cpp index 3c19788640..35e81b7695 100644 --- a/test/unittest/ability_record_test/mock/src/mock_permission_verification.cpp +++ b/test/unittest/ability_record_test/mock/src/mock_permission_verification.cpp @@ -42,10 +42,12 @@ bool PermissionVerification::VerifyControllerPerm() const { return !!(MyFlag::flag_); } +#ifdef WITH_DLP bool PermissionVerification::VerifyDlpPermission(Want &want) const { return !!(MyFlag::flag_); } +#endif // WITH_DLP int PermissionVerification::VerifyAccountPermission() const { return MyFlag::flag_; diff --git a/test/unittest/ams_ability_running_record_test/BUILD.gn b/test/unittest/ams_ability_running_record_test/BUILD.gn index 29c0891ac0..84efbfc0c4 100644 --- a/test/unittest/ams_ability_running_record_test/BUILD.gn +++ b/test/unittest/ams_ability_running_record_test/BUILD.gn @@ -90,6 +90,11 @@ ohos_unittest("AmsAbilityRunningRecordTest") { if (ability_runtime_graphics) { external_deps += [ "window_manager:libwm" ] } + + if (ability_runtime_feature_sandboxmanager) { + external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] + defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ] + } } group("unittest") { diff --git a/test/unittest/ams_ability_running_record_test/ams_ability_running_record_test.cpp b/test/unittest/ams_ability_running_record_test/ams_ability_running_record_test.cpp index 8be4b8c60f..066c381e22 100644 --- a/test/unittest/ams_ability_running_record_test/ams_ability_running_record_test.cpp +++ b/test/unittest/ams_ability_running_record_test/ams_ability_running_record_test.cpp @@ -234,7 +234,6 @@ HWTEST_F(AmsAbilityRunningRecordTest, UpdateAbilityRunningRecord_001, TestSize.L EXPECT_EQ(abilityRunningRecord->GetState(), AbilityState::ABILITY_STATE_FOREGROUND) << "execute fail!"; appRunningRecord->SetState(ApplicationState::APP_STATE_FOREGROUND); - EXPECT_CALL(*mockedAppClient_, ScheduleBackgroundApplication()).Times(1); appRunningRecord->UpdateAbilityState(token, AbilityState::ABILITY_STATE_BACKGROUND); EXPECT_EQ(abilityRunningRecord->GetState(), AbilityState::ABILITY_STATE_BACKGROUND) << "execute fail!"; TAG_LOGD(AAFwkTag::TEST, "UpdateAbilityRunningRecord_001 end."); @@ -434,8 +433,6 @@ HWTEST_F(AmsAbilityRunningRecordTest, UpdateAbilityRunningRecord_006, TestSize.L anotherAbilityRunningRecord->SetState(AbilityState::ABILITY_STATE_FOREGROUND); appRunningRecord->SetState(ApplicationState::APP_STATE_FOREGROUND); abilityRunningRecord->SetState(AbilityState::ABILITY_STATE_FOREGROUND); - - EXPECT_CALL(*mockedAppClient_, ScheduleBackgroundApplication()).Times(2); appRunningRecord->UpdateAbilityState(anotherToken, AbilityState::ABILITY_STATE_FOREGROUND); auto abilities = appRunningRecord->GetAbilities(); diff --git a/test/unittest/ams_ipc_interface_test/BUILD.gn b/test/unittest/ams_ipc_interface_test/BUILD.gn index 60b9d774c4..322611ae57 100644 --- a/test/unittest/ams_ipc_interface_test/BUILD.gn +++ b/test/unittest/ams_ipc_interface_test/BUILD.gn @@ -33,6 +33,7 @@ ohos_unittest("AmsIpcAppSchedulerInterfaceTest") { external_deps = [ "ability_base:base", "ability_base:configuration", + "ability_base:want", "ability_base:zuri", "hilog:libhilog", "ipc:ipc_core", diff --git a/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h index fe2bcb25d5..5594cf86ba 100644 --- a/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h +++ b/test/unittest/ams_mgr_scheduler_test/mock/include/mock_permission_verification.h @@ -51,7 +51,9 @@ struct VerificationInfo { bool VerifyControllerPerm() const; +#ifdef WITH_DLP bool VerifyDlpPermission(Want &want) const; +#endif // WITH_DLP int VerifyAccountPermission() const; diff --git a/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp index 5539591709..dd3dd25396 100644 --- a/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp +++ b/test/unittest/ams_mgr_scheduler_test/mock/src/mock_permission_verification.cpp @@ -44,10 +44,12 @@ bool PermissionVerification::VerifyControllerPerm() const { return !!(MyFlag::flag_); } +#ifdef WITH_DLP bool PermissionVerification::VerifyDlpPermission(Want &want) const { return !!(MyFlag::flag_); } +#endif // WITH_DLP int PermissionVerification::VerifyAccountPermission() const { return MyFlag::flag_; diff --git a/test/unittest/ams_service_load_ability_process_test/BUILD.gn b/test/unittest/ams_service_load_ability_process_test/BUILD.gn index 5da2d9ef83..7c4a6f2f8a 100644 --- a/test/unittest/ams_service_load_ability_process_test/BUILD.gn +++ b/test/unittest/ams_service_load_ability_process_test/BUILD.gn @@ -107,6 +107,11 @@ ohos_unittest("AmsServiceLoadAbilityProcessTest") { "window_manager:libwsutils", ] } + + if (ability_runtime_feature_sandboxmanager) { + external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] + defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ] + } } group("unittest") { diff --git a/test/unittest/ams_service_startup_test/BUILD.gn b/test/unittest/ams_service_startup_test/BUILD.gn index 0c22400abd..c9e025f3c8 100644 --- a/test/unittest/ams_service_startup_test/BUILD.gn +++ b/test/unittest/ams_service_startup_test/BUILD.gn @@ -95,6 +95,11 @@ ohos_unittest("AmsServiceStartupTest") { if (ability_runtime_graphics) { external_deps += [ "window_manager:libwm" ] } + + if (ability_runtime_feature_sandboxmanager) { + external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] + defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ] + } } group("unittest") { diff --git a/test/unittest/app_mgr_service_event_handler_test/BUILD.gn b/test/unittest/app_mgr_service_event_handler_test/BUILD.gn index 4ba9bc5b9c..d89c0e7679 100644 --- a/test/unittest/app_mgr_service_event_handler_test/BUILD.gn +++ b/test/unittest/app_mgr_service_event_handler_test/BUILD.gn @@ -102,6 +102,11 @@ ohos_unittest("AMSEventHandlerTest") { "window_manager:libwsutils", ] } + + if (ability_runtime_feature_sandboxmanager) { + external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] + defines = [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ] + } } group("unittest") { diff --git a/test/unittest/app_mgr_service_inner_test/BUILD.gn b/test/unittest/app_mgr_service_inner_test/BUILD.gn index b70803417d..0d3a3e3fa7 100644 --- a/test/unittest/app_mgr_service_inner_test/BUILD.gn +++ b/test/unittest/app_mgr_service_inner_test/BUILD.gn @@ -84,6 +84,11 @@ ohos_unittest("AppMgrServiceInnerTest") { if (background_task_mgr_continuous_task_enable) { defines += [ "BGTASKMGR_CONTINUOUS_TASK_ENABLE" ] } + + if (ability_runtime_feature_sandboxmanager) { + external_deps += [ "sandbox_manager:libsandbox_manager_sdk" ] + defines += [ "ABILITY_RUNTIME_FEATURE_SANDBOXMANAGER" ] + } } group("unittest") { diff --git a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp index 20098d2cb1..f566b3698a 100644 --- a/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp +++ b/test/unittest/app_mgr_service_inner_test/app_mgr_service_inner_test.cpp @@ -2293,7 +2293,7 @@ HWTEST_F(AppMgrServiceInnerTest, NotifyAppStatusByCallerUid_001, TestSize.Level0 std::string bundleName = "test_bundle_name"; std::string eventData = "test_event_data"; - appMgrServiceInner->NotifyAppStatusByCallerUid(bundleName, 0, 0, eventData); + appMgrServiceInner->NotifyAppStatusByCallerUid(bundleName, 0, 0, 0, eventData); TAG_LOGI(AAFwkTag::TEST, "NotifyAppStatusByCallerUid_001 end"); } @@ -3149,6 +3149,7 @@ HWTEST_F(AppMgrServiceInnerTest, AttachRenderProcess_002, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "AttachRenderProcess_002 end"); } +#ifdef WITH_DLP /** * @tc.name: BuildStartFlags_001 * @tc.desc: build start flags. @@ -3171,6 +3172,7 @@ HWTEST_F(AppMgrServiceInnerTest, BuildStartFlags_001, TestSize.Level0) TAG_LOGI(AAFwkTag::TEST, "BuildStartFlags_001 end"); } +#endif // WITH_DLP /** * @tc.name: RegisterFocusListener_001 @@ -4101,7 +4103,6 @@ HWTEST_F(AppMgrServiceInnerTest, IsAppRunning_002, TestSize.Level1) EXPECT_FALSE(isRunning); } - /** * @tc.name: RegisterAbilityForegroundStateObserver_0100 * @tc.desc: Verify it when observer is nullptr. diff --git a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp index c6fa4bdcae..e26ff37981 100644 --- a/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp +++ b/test/unittest/app_mgr_service_test/app_mgr_service_test.cpp @@ -1184,7 +1184,7 @@ HWTEST_F(AppMgrServiceTest, SetContinuousTaskProcess_002, TestSize.Level0) appMgrService->taskHandler_ = taskHandler_; appMgrService->eventHandler_ = std::make_shared(taskHandler_, appMgrService->appMgrServiceInner_); int32_t res = appMgrService->SetContinuousTaskProcess(pid, isContinuousTask); - EXPECT_NE(res, ERR_INVALID_OPERATION); + EXPECT_EQ(res, ERR_INVALID_OPERATION); } #endif @@ -1378,28 +1378,6 @@ HWTEST_F(AppMgrServiceTest, ChangeAppGcState_001, TestSize.Level1) appMgrService->appMgrServiceInner_ = nullptr; } -/** - * @tc.name: IsApplicationRunning_001 - * @tc.desc: Determine that the application is running by returning a value. - * @tc.type: FUNC - */ -HWTEST_F(AppMgrServiceTest, IsApplicationRunning_001, TestSize.Level1) -{ - AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); - sptr appMgrService = new (std::nothrow) AppMgrService(); - ASSERT_NE(appMgrService, nullptr); - appMgrService->SetInnerService(nullptr); - - appMgrService->SetInnerService(std::make_shared()); - appMgrService->taskHandler_ = taskHandler_; - appMgrService->eventHandler_ = std::make_shared(taskHandler_, appMgrService->appMgrServiceInner_); - - std::string bundleName = "test_bundleName"; - bool isRunning = false; - int32_t res = appMgrService->IsApplicationRunning(bundleName, isRunning); - EXPECT_EQ(res, ERR_OK); -} - /** * @tc.name: IsAppRunning_001 * @tc.desc: Determine that the application is running by returning a value. @@ -1423,6 +1401,52 @@ HWTEST_F(AppMgrServiceTest, IsAppRunning_001, TestSize.Level1) EXPECT_EQ(res, AAFwk::ERR_APP_CLONE_INDEX_INVALID); } +/** + * @tc.name: StartChildProcess_001 + * @tc.desc: verify StartChildProcess calls works. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceTest, StartChildProcess_001, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "StartChildProcess_001 called."); + sptr appMgrService = new (std::nothrow) AppMgrService(); + ASSERT_NE(appMgrService, nullptr); + + appMgrService->SetInnerService(mockAppMgrServiceInner_); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = eventHandler_; + + EXPECT_CALL(*mockAppMgrServiceInner_, StartChildProcess(_, _, _)) + .Times(1) + .WillOnce(Return(ERR_OK)); + pid_t pid = 0; + ChildProcessRequest request; + int32_t res = appMgrService->StartChildProcess(pid, request); + EXPECT_EQ(res, ERR_OK); +} + +/** + * @tc.name: IsApplicationRunning_001 + * @tc.desc: Determine that the application is running by returning a value. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceTest, IsApplicationRunning_001, TestSize.Level1) +{ + AAFwk::IsMockSaCall::IsMockSaCallWithPermission(); + sptr appMgrService = new (std::nothrow) AppMgrService(); + ASSERT_NE(appMgrService, nullptr); + appMgrService->SetInnerService(nullptr); + + appMgrService->SetInnerService(std::make_shared()); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = std::make_shared(taskHandler_, appMgrService->appMgrServiceInner_); + + std::string bundleName = "test_bundleName"; + bool isRunning = false; + int32_t res = appMgrService->IsApplicationRunning(bundleName, isRunning); + EXPECT_EQ(res, ERR_OK); +} + /** * @tc.name: RegisterAbilityForegroundStateObserver_0100 * @tc.desc: Verify it when judgments is ready and observer is nullptr. @@ -1453,30 +1477,6 @@ HWTEST_F(AppMgrServiceTest, UnregisterAbilityForegroundStateObserver_0100, TestS EXPECT_EQ(res, ERR_INVALID_VALUE); } -/** - * @tc.name: StartChildProcess_001 - * @tc.desc: verify StartChildProcess calls works. - * @tc.type: FUNC - */ -HWTEST_F(AppMgrServiceTest, StartChildProcess_001, TestSize.Level1) -{ - TAG_LOGD(AAFwkTag::TEST, "StartChildProcess_001 called."); - sptr appMgrService = new (std::nothrow) AppMgrService(); - ASSERT_NE(appMgrService, nullptr); - - appMgrService->SetInnerService(mockAppMgrServiceInner_); - appMgrService->taskHandler_ = taskHandler_; - appMgrService->eventHandler_ = eventHandler_; - - EXPECT_CALL(*mockAppMgrServiceInner_, StartChildProcess(_, _, _)) - .Times(1) - .WillOnce(Return(ERR_OK)); - pid_t pid = 0; - ChildProcessRequest request; - int32_t res = appMgrService->StartChildProcess(pid, request); - EXPECT_EQ(res, ERR_OK); -} - /** * @tc.name: GetChildProcessInfoForSelf_001 * @tc.desc: verify GetChildProcessInfoForSelf works. @@ -1752,31 +1752,6 @@ HWTEST_F(AppMgrServiceTest, SetSupportedProcessCacheSelf_002, TestSize.Level0) EXPECT_EQ(res, AAFwk::ERR_CAPABILITY_NOT_SUPPORT); } -/** - * @tc.name: StartNativeChildProcess_0100 - * @tc.desc: Start native child process. - * @tc.type: FUNC - */ -HWTEST_F(AppMgrServiceTest, StartNativeChildProcess_0100, TestSize.Level1) -{ - TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcess_0100 called."); - sptr appMgrService = new (std::nothrow) AppMgrService(); - ASSERT_NE(appMgrService, nullptr); - - appMgrService->SetInnerService(mockAppMgrServiceInner_); - appMgrService->taskHandler_ = taskHandler_; - appMgrService->eventHandler_ = eventHandler_; - - EXPECT_CALL(*mockAppMgrServiceInner_, StartNativeChildProcess(_, _, _, _)) - .Times(1) - .WillOnce(Return(ERR_OK)); - - pid_t pid = 0; - sptr callback; - int32_t res = appMgrService->StartNativeChildProcess("test.so", 1, callback); - EXPECT_EQ(res, ERR_OK); -} - /* * Feature: AppMgrService * Function: GetRunningMultiAppInfoByBundleName @@ -1819,5 +1794,30 @@ HWTEST_F(AppMgrServiceTest, GetRunningMultiAppInfoByBundleName_002, TestSize.Lev int32_t ret = appMgrService->GetRunningMultiAppInfoByBundleName(bundleName, info); EXPECT_NE(ret, ERR_OK); } + +/** + * @tc.name: StartNativeChildProcess_0100 + * @tc.desc: Start native child process. + * @tc.type: FUNC + */ +HWTEST_F(AppMgrServiceTest, StartNativeChildProcess_0100, TestSize.Level1) +{ + TAG_LOGD(AAFwkTag::TEST, "StartNativeChildProcess_0100 called."); + sptr appMgrService = new (std::nothrow) AppMgrService(); + ASSERT_NE(appMgrService, nullptr); + + appMgrService->SetInnerService(mockAppMgrServiceInner_); + appMgrService->taskHandler_ = taskHandler_; + appMgrService->eventHandler_ = eventHandler_; + + EXPECT_CALL(*mockAppMgrServiceInner_, StartNativeChildProcess(_, _, _, _)) + .Times(1) + .WillOnce(Return(ERR_OK)); + + pid_t pid = 0; + sptr callback; + int32_t res = appMgrService->StartNativeChildProcess("test.so", 1, callback); + EXPECT_EQ(res, ERR_OK); +} } // namespace AppExecFwk } // namespace OHOS \ No newline at end of file diff --git a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp index 1dfb8464fa..e328e68a14 100644 --- a/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp +++ b/test/unittest/bundle_mgr_helper_test/bundle_mgr_helper_test.cpp @@ -29,7 +29,9 @@ const int32_t ABILITY_INFO_FLAG = 4; const int32_t DEFAULT_USERID = 100; const int32_t FIRST_APP_INDEX = 1000; const int32_t SECOND_APP_INDEX = 2000; +#ifdef WITH_DLP const int32_t ERR_COD1 = 8519801; +#endif // WITH_DLP const int32_t ERR_COD3 = 8519802; const int32_t ERR_COD4 = 8519921; const int32_t ERR_COD5 = 8519816; @@ -507,6 +509,7 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_GetDefaultAppProxy_001, TestSi EXPECT_NE(ret, nullptr); } +#ifdef WITH_DLP /** * @tc.name: BundleMgrHelperTest_InstallSandboxApp_001 * @tc.desc: InstallSandboxApp @@ -536,6 +539,7 @@ HWTEST_F(BundleMgrHelperTest, BundleMgrHelperTest_InstallSandboxApp_002, TestSiz auto ret = bundleMgrHelper->InstallSandboxApp(bundleName, dlpType, userId, appIndex); EXPECT_EQ(ret, ERR_COD1); } +#endif // WITH_DLP /** * @tc.name: BundleMgrHelperTest_UninstallSandboxApp_001 diff --git a/test/unittest/call_container_test/BUILD.gn b/test/unittest/call_container_test/BUILD.gn index e83238c0a0..b384341f48 100644 --- a/test/unittest/call_container_test/BUILD.gn +++ b/test/unittest/call_container_test/BUILD.gn @@ -24,6 +24,7 @@ ohos_unittest("call_container_test") { debug = false } branch_protector_ret = "pac_ret" + include_dirs = [ "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/appexecfwk_core/include", "${ability_runtime_test_path}/mock/services_abilitymgr_test/libs/ability_scheduler_mock", diff --git a/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp b/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp index 30974d3832..3781a8d276 100755 --- a/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp +++ b/test/unittest/connection_observer_controller_test/connection_observer_controller_test.cpp @@ -106,6 +106,7 @@ HWTEST_F(ConnectionObserverControllerTest, NotifyExtensionDisconnected_001, Test connectionObserverController->NotifyExtensionDisconnected(data); } +#ifdef WITH_DLP /* * Feature: ConnectionObserverController * Function: NotifyDlpAbilityOpened @@ -137,6 +138,7 @@ HWTEST_F(ConnectionObserverControllerTest, NotifyDlpAbilityClosed_001, TestSize. DlpStateData data; connectionObserverController->NotifyDlpAbilityClosed(data); } +#endif // WITH_DLP /* * Feature: ConnectionObserverController diff --git a/test/unittest/connection_observer_test/connection_observer_test.cpp b/test/unittest/connection_observer_test/connection_observer_test.cpp index 58623fe0cc..5a5eb22e7f 100644 --- a/test/unittest/connection_observer_test/connection_observer_test.cpp +++ b/test/unittest/connection_observer_test/connection_observer_test.cpp @@ -23,7 +23,9 @@ #include "connection_data.h" #include "connection_observer_client.h" #include "connection_observer_client_impl.h" +#ifdef WITH_DLP #include "dlp_state_data.h" +#endif // WITH_DLP #include "hilog_tag_wrapper.h" #include "mock_native_token.h" #include "parcel.h" @@ -162,6 +164,7 @@ HWTEST_F(ConnectionObserverTest, ConnectionObserver_Data_0100, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "ConnectionObserver_Data_0100 end"); } +#ifdef WITH_DLP /** * @tc.name: ConnectionObserver_Data_0200 * @tc.desc: DlpState data test. @@ -298,5 +301,6 @@ HWTEST_F(ConnectionObserverTest, ConnectionObserver_Observer_0200, TestSize.Leve SetSelfTokenID(currentID); TAG_LOGI(AAFwkTag::TEST, "ConnectionObserver_Observer_0200 end"); } +#endif // WITH_DLP } // namespace AbilityRuntime } // namespace OHOS diff --git a/test/unittest/connection_state_manager_test/connection_state_manager_test.cpp b/test/unittest/connection_state_manager_test/connection_state_manager_test.cpp index 34d52a0b0b..23748bd187 100755 --- a/test/unittest/connection_state_manager_test/connection_state_manager_test.cpp +++ b/test/unittest/connection_state_manager_test/connection_state_manager_test.cpp @@ -21,7 +21,9 @@ #include "ability_record.h" #include "connection_observer_errors.h" #include "data_ability_record.h" +#ifdef WITH_DLP #include "dlp_state_item.h" +#endif // WITH_DLP using namespace testing::ext; using namespace OHOS::AbilityRuntime; @@ -409,6 +411,7 @@ HWTEST_F(ConnectionStateManagerTest, HandleDataAbilityCallerDied_002, TestSize.L manager_->HandleDataAbilityCallerDied(callerPid); } +#ifdef WITH_DLP /* * Feature: ConnectionStateManager * Function: AddDlpManager @@ -544,6 +547,7 @@ HWTEST_F(ConnectionStateManagerTest, RemoveDlpAbility_002, TestSize.Level1) manager_->Init(); manager_->RemoveDlpAbility(abilityRecord); } +#endif // WITH_DLP /* * Feature: ConnectionStateManager @@ -560,6 +564,7 @@ HWTEST_F(ConnectionStateManagerTest, HandleAppDied_001, TestSize.Level1) manager_->HandleAppDied(pid); } +#ifdef WITH_DLP /* * Feature: ConnectionStateManager * Function: GetDlpConnectionInfos @@ -576,6 +581,7 @@ HWTEST_F(ConnectionStateManagerTest, GetDlpConnectionInfos_001, TestSize.Level1) manager_->dlpItems_[1] = nullptr; manager_->GetDlpConnectionInfos(infos); } +#endif // WITH_DLP /* * Feature: ConnectionStateManager @@ -706,6 +712,7 @@ HWTEST_F(ConnectionStateManagerTest, HandleDataAbilityDiedInner_001, TestSize.Le manager_->HandleDataAbilityDiedInner(abilityToken, allData); } +#ifdef WITH_DLP /* * Feature: ConnectionStateManager * Function: HandleDlpAbilityInner @@ -821,5 +828,6 @@ HWTEST_F(ConnectionStateManagerTest, HandleDlpAbilityInner_006, TestSize.Level1) bool res = manager_->HandleDlpAbilityInner(dlpAbility, isAdd, dlpData); EXPECT_FALSE(res); } +#endif // WITH_DLP } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/dfr_test/watchdog_test/BUILD.gn b/test/unittest/dfr_test/watchdog_test/BUILD.gn index 0c9afbb19d..6d44086aa8 100644 --- a/test/unittest/dfr_test/watchdog_test/BUILD.gn +++ b/test/unittest/dfr_test/watchdog_test/BUILD.gn @@ -72,6 +72,7 @@ ohos_unittest("watchdog_test") { external_deps = [ "ability_base:base", + "ability_base:session_info", "ability_base:want", "bundle_framework:appexecfwk_base", "bundle_framework:appexecfwk_core", diff --git a/test/unittest/dlp_utils_test/dlp_utils_test.cpp b/test/unittest/dlp_utils_test/dlp_utils_test.cpp index 7a090abc78..823bda5b2e 100644 --- a/test/unittest/dlp_utils_test/dlp_utils_test.cpp +++ b/test/unittest/dlp_utils_test/dlp_utils_test.cpp @@ -42,6 +42,7 @@ void DlpUtilsTest::SetUp() void DlpUtilsTest::TearDown() {} +#ifdef WITH_DLP /** * @tc.name: OtherAppsAccessDlpCheck_0100 * @tc.desc: OtherAppsAccessDlpCheck Test @@ -90,5 +91,6 @@ HWTEST_F(DlpUtilsTest, DlpAccessOtherAppsCheck_0100, TestSize.Level0) bool result = DlpUtils::DlpAccessOtherAppsCheck(abilityRecord->GetToken(), want); EXPECT_TRUE(result); } +#endif // WITH_DLP } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/extension_permissions_util_test/BUILD.gn b/test/unittest/extension_permissions_util_test/BUILD.gn new file mode 100644 index 0000000000..ddf978284f --- /dev/null +++ b/test/unittest/extension_permissions_util_test/BUILD.gn @@ -0,0 +1,58 @@ +# Copyright (c) 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import("//foundation/ability/ability_runtime/ability_runtime.gni") + +module_output_path = "ability_runtime/abilitymgr" + +ohos_unittest("extension_permissions_util_test") { + module_out_path = module_output_path + sanitize = { + cfi = true + cfi_cross_dso = true + debug = false + blocklist = "../../cfi_blocklist.txt" + } + branch_protector_ret = "pac_ret" + include_dirs = [ + "mock/include", + "${ability_runtime_services_path}/abilitymgr/include/utils", + "${ability_runtime_services_path}/abilitymgr/include", + "${ability_runtime_services_path}/common/include", + ] + + sources = [ + "${ability_runtime_services_path}/abilitymgr/src/utils/extension_permissions_util.cpp", + "extension_permissions_util_test.cpp", + "mock/src/mock_my_flag.cpp", + "mock/src/permission_verification.cpp", + ] + + deps = [ + "//third_party/googletest:gmock_main", + "//third_party/googletest:gtest_main", + ] + + external_deps = [ + "bundle_framework:appexecfwk_base", + "bundle_framework:appexecfwk_core", + "c_utils:utils", + "hilog:libhilog", + ] +} + +group("unittest") { + testonly = true + deps = [ ":extension_permissions_util_test" ] +} diff --git a/test/unittest/extension_permissions_util_test/extension_permissions_util_test.cpp b/test/unittest/extension_permissions_util_test/extension_permissions_util_test.cpp new file mode 100644 index 0000000000..2721d4b27b --- /dev/null +++ b/test/unittest/extension_permissions_util_test/extension_permissions_util_test.cpp @@ -0,0 +1,122 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "extension_permissions_util.h" +#include "hilog_tag_wrapper.h" +#include "permission_verification.h" + +using namespace testing; +using namespace testing::ext; +using OHOS::AppExecFwk::ExtensionAbilityType; + +namespace OHOS { +namespace AAFwk { +class ExtensionPermissionsUtilTest : public testing::Test { +public: + static void SetUpTestCase(); + static void TearDownTestCase(); + void SetUp(); + void TearDown(); +}; + +void ExtensionPermissionsUtilTest::SetUpTestCase() {} + +void ExtensionPermissionsUtilTest::TearDownTestCase() {} + +void ExtensionPermissionsUtilTest::SetUp() {} + +void ExtensionPermissionsUtilTest::TearDown() {} + +/* + * Feature: ExtensionPermissionsUtil + * Function: CheckSAPermission + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckSAPermission + */ +HWTEST_F(ExtensionPermissionsUtilTest, CheckSAPermission_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermission_001 start"); + MyFlag::flag_ = 0; + EXPECT_TRUE(ExtensionPermissionsUtil::CheckSAPermission(ExtensionAbilityType::FORM)); + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermission_001 end"); +} + +/* + * Feature: ExtensionPermissionsUtil + * Function: CheckSAPermission + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckSAPermission + */ +HWTEST_F(ExtensionPermissionsUtilTest, CheckSAPermission_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermission_002 start"); + + MyFlag::flag_ = 1; + MyFlag::hasPerm_ = true; + EXPECT_TRUE(ExtensionPermissionsUtil::CheckSAPermission(ExtensionAbilityType::FORM)); + MyFlag::flag_ = 0; + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermission_002 end"); +} + +/* + * Feature: ExtensionPermissionsUtil + * Function: CheckSAPermission + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckSAPermission + */ +HWTEST_F(ExtensionPermissionsUtilTest, CheckSAPermission_003, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermission_002 start"); + + MyFlag::flag_ = 1; + MyFlag::hasPerm_ = false; + EXPECT_FALSE(ExtensionPermissionsUtil::CheckSAPermission(ExtensionAbilityType::FORM)); + MyFlag::flag_ = 0; + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermission_002 end"); +} + +/* + * Feature: ExtensionPermissionsUtil + * Function: CheckSAPermission + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckSAPermissionMore + */ +HWTEST_F(ExtensionPermissionsUtilTest, CheckSAPermissionMore_001, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermissionMore_001 start"); + + MyFlag::hasPerm_ = true; + EXPECT_TRUE(ExtensionPermissionsUtil::CheckSAPermissionMore(ExtensionAbilityType::FILEACCESS_EXTENSION)); + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermissionMore_001 end"); +} + +/* + * Feature: ExtensionPermissionsUtil + * Function: CheckSAPermission + * SubFunction: NA + * FunctionPoints: AbilityManagerService CheckSAPermissionMore + */ +HWTEST_F(ExtensionPermissionsUtilTest, CheckSAPermissionMore_002, TestSize.Level1) +{ + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermissionMore_001 start"); + + MyFlag::hasPerm_ = false; + EXPECT_FALSE(ExtensionPermissionsUtil::CheckSAPermissionMore(ExtensionAbilityType::FILEACCESS_EXTENSION)); + TAG_LOGI(AAFwkTag::TEST, "ExtensionPermissionsUtilTest CheckSAPermissionMore_001 end"); +} +} // namespace AAFwk +} // namespace OHOS diff --git a/test/unittest/extension_permissions_util_test/mock/include/mock_my_flag.h b/test/unittest/extension_permissions_util_test/mock/include/mock_my_flag.h new file mode 100644 index 0000000000..18262b5ce8 --- /dev/null +++ b/test/unittest/extension_permissions_util_test/mock/include/mock_my_flag.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MOCK_MY_FLAG_H +#define MOCK_MY_FLAG_H +namespace OHOS { +namespace AAFwk { +class MyFlag { +public: + enum FLAG { + IS_SA_CALL = 1, + IS_SHELL_CALL, + IS_SA_AND_SHELL_CALL, + }; + static int flag_; + static bool hasPerm_; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // MOCK_MY_FLAG_H \ No newline at end of file diff --git a/test/unittest/extension_permissions_util_test/mock/include/permission_verification.h b/test/unittest/extension_permissions_util_test/mock/include/permission_verification.h new file mode 100644 index 0000000000..11398be212 --- /dev/null +++ b/test/unittest/extension_permissions_util_test/mock/include/permission_verification.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H +#define OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H + +#include + +#include "singleton.h" +#include "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { + +class PermissionVerification : public DelayedSingleton { +public: + PermissionVerification() = default; + ~PermissionVerification() = default; + + bool VerifyCallingPermission(const std::string &permissionName) const; + bool IsSACall() const; +}; +} // namespace AAFwk +} // namespace OHOS +#endif // OHOS_ABILITY_RUNTIME_PERMISSION_VERIFICATION_H \ No newline at end of file diff --git a/test/unittest/extension_permissions_util_test/mock/src/mock_my_flag.cpp b/test/unittest/extension_permissions_util_test/mock/src/mock_my_flag.cpp new file mode 100644 index 0000000000..f20555b6e0 --- /dev/null +++ b/test/unittest/extension_permissions_util_test/mock/src/mock_my_flag.cpp @@ -0,0 +1,23 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "mock_my_flag.h" + +namespace OHOS { +namespace AAFwk { +int MyFlag::flag_ = 0; +bool MyFlag::hasPerm_ = false; +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/extension_permissions_util_test/mock/src/permission_verification.cpp b/test/unittest/extension_permissions_util_test/mock/src/permission_verification.cpp new file mode 100644 index 0000000000..1cb3910502 --- /dev/null +++ b/test/unittest/extension_permissions_util_test/mock/src/permission_verification.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "permission_verification.h" + +namespace OHOS { +namespace AAFwk { +bool PermissionVerification::VerifyCallingPermission(const std::string &permissionName) const +{ + return MyFlag::hasPerm_; +} +bool PermissionVerification::IsSACall() const +{ + return (MyFlag::flag_ & MyFlag::FLAG::IS_SA_CALL); +} +} // namespace AAFwk +} // namespace OHOS \ No newline at end of file diff --git a/test/unittest/frameworks_kits_ability_ability_runtime_test/ability_context_impl_test.cpp b/test/unittest/frameworks_kits_ability_ability_runtime_test/ability_context_impl_test.cpp index 380f9b7fcc..ee2950237e 100644 --- a/test/unittest/frameworks_kits_ability_ability_runtime_test/ability_context_impl_test.cpp +++ b/test/unittest/frameworks_kits_ability_ability_runtime_test/ability_context_impl_test.cpp @@ -231,7 +231,7 @@ HWTEST_F(AbilityContextImplTest, Ability_Context_Impl_SetMissionContinueState_01 g_mockAbilityMs->SetCommonMockResult(true); ret = context_->SetMissionContinueState(state); if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { - EXPECT_EQ(ret, 0); + EXPECT_EQ(ret, ERR_INVALID_VALUE); } } @@ -254,7 +254,7 @@ HWTEST_F(AbilityContextImplTest, Ability_Context_Impl_SetMissionContinueState_02 g_mockAbilityMs->SetCommonMockResult(true); ret = context_->SetMissionContinueState(state); if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { - EXPECT_EQ(ret, 0); + EXPECT_EQ(ret, ERR_INVALID_VALUE); } } diff --git a/test/unittest/frameworks_kits_ability_native_test/data_ability_helper_test.cpp b/test/unittest/frameworks_kits_ability_native_test/data_ability_helper_test.cpp index f32a3e2693..1685fe5e28 100644 --- a/test/unittest/frameworks_kits_ability_native_test/data_ability_helper_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/data_ability_helper_test.cpp @@ -56,13 +56,17 @@ void DataAbilityHelperForObserverTest::SetUpTestCase(void) {} void DataAbilityHelperForObserverTest::TearDownTestCase(void) -{} +{ + MockAbilitySchedulerTools::GetInstance()->SetMockStatus(true); +} void DataAbilityHelperForObserverTest::SetUp(void) {} void DataAbilityHelperForObserverTest::TearDown(void) -{} +{ + MockAbilitySchedulerTools::DestoryInstance(); +} /** * @tc.number: AaFwk_DataAbilityHelper_GetFileTypes_0100 diff --git a/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp b/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp index 5c3acf9a63..4d3ef797ea 100644 --- a/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp +++ b/test/unittest/frameworks_kits_ability_native_test/ui_ability_test.cpp @@ -75,6 +75,18 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_Name_0100, Function | MediumTest | Le std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); ability_->Init(abilityRecord, application, handler, token); EXPECT_STREQ(abilityInfo->name.c_str(), ability_->GetAbilityName().c_str()); + + std::shared_ptr abilityRecord2 = std::make_shared(nullptr, abilityToken); + ability_->Init(abilityRecord2, application, handler, token); + EXPECT_EQ("", ability_->GetAbilityName()); + + ability_->Init(nullptr, application, handler, token); + + auto prevAbilityContext = ability_->GetAbilityContext(); + auto abilityContextNew = std::make_shared(); + ability_->AttachAbilityContext(abilityContextNew); + ability_->Init(abilityRecord, application, handler, token); + ability_->AttachAbilityContext(prevAbilityContext); GTEST_LOG_(INFO) << "AbilityRuntime_Name_0100 end"; } @@ -100,6 +112,31 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_GetAbilityName_0100, Function | Mediu GTEST_LOG_(INFO) << "AbilityRuntime_GetAbilityName_0100 end"; } +/** + * @tc.number: AbilityRuntime_GetModuleName_0100 + * @tc.name: GetModuleName + * @tc.desc: Verify that the GetModuleName return value is correct. + */ +HWTEST_F(UIAbilityBaseTest, AbilityRuntime_GetModuleName_0100, Function | MediumTest | Level1) +{ + std::shared_ptr abilityInfo = std::make_shared(); + std::shared_ptr application = std::make_shared(); + std::shared_ptr eventRunner = EventRunner::Create(abilityInfo->name); + std::shared_ptr handler = std::make_shared(eventRunner); + sptr token = nullptr; + std::string name = "LOL"; + abilityInfo->moduleName = name; + sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); + std::shared_ptr abilityRecord = std::make_shared(nullptr, abilityToken); + ability_->Init(abilityRecord, application, handler, token); + EXPECT_EQ(ability_->GetModuleName(), ""); + + std::shared_ptr abilityRecord2 = std::make_shared(abilityInfo, + abilityToken); + ability_->Init(abilityRecord2, application, handler, token); + EXPECT_STREQ(ability_->GetModuleName().c_str(), name.c_str()); +} + /** * @tc.number: AbilityRuntime_GetLifecycle_0100 * @tc.name: GetLifecycle @@ -429,7 +466,12 @@ HWTEST_F(UIAbilityBaseTest, AbilityRuntime_OnForeground_0100, Function | MediumT std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); ability_->Init(abilityRecord, application, handler, token); Want want; + bool prevSilentForground = ability_->CheckIsSilentForeground(); + ability_->SetIsSilentForeground(true); ability_->OnForeground(want); + ability_->SetIsSilentForeground(prevSilentForground); + ability_->OnForeground(want); + AbilityLifecycleExecutor::LifecycleState state = ability_->GetState(); std::shared_ptr lifeCycle = ability_->GetLifecycle(); LifeCycle::Event lifeCycleState = lifeCycle->GetLifecycleState(); @@ -661,6 +703,11 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityContinuation_0100, TestSize.Level1) // branch when contentStorage_ is nullptr ret = ability->IsRestoredInContinuation(); EXPECT_EQ(ret, false); + + launchParam.launchReason = LaunchReason::LAUNCHREASON_CONTINUATION; + ability->SetLaunchParam(launchParam); + ret = ability->IsRestoredInContinuation(); + EXPECT_EQ(ret, true); TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } @@ -689,6 +736,12 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityContinuation_0200, TestSize.Level1) ability->HandleCreateAsRecovery(want); ret = ability->ShouldRecoverState(want); EXPECT_EQ(ret, false); + + ability->EnableAbilityRecovery(nullptr, false); + ret = ability->ShouldRecoverState(want); + EXPECT_EQ(ret, false); + ability->EnableAbilityRecovery(abilityRecovery, false); + auto abilityContext = std::make_shared(); ability->AttachAbilityContext(abilityContext); @@ -707,6 +760,22 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityContinuation_0200, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } +/** + * @tc.name: ShouldDefaultRecoverState_0200 + * @tc.desc: UIAbility ShouldDefaultRecoverState test. + * @tc.type: FUNC + * @tc.require: issueI60B7N + */ +HWTEST_F(UIAbilityBaseTest, ShouldDefaultRecoverState_0100, TestSize.Level1) +{ + std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); + + // branch when abilityRecovery_ is nullptr + Want want; + ability->ShouldDefaultRecoverState(want); +} + /** * @tc.name: UIAbilityContinuation_0300 * @tc.desc: UIAbility NotifyContinuationResult test. @@ -820,6 +889,9 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityVirtualFunc_0200, TestSize.Level1) bool ret = ability->OnStartContinuation(); EXPECT_EQ(ret, false); WantParams data; + ability->OnContinue(data); + uint32_t verCode = 0; + ability->ContinueAbilityWithStack("", verCode); ret = ability->OnSaveData(data); EXPECT_EQ(ret, false); ret = ability->OnRestoreData(data); @@ -835,6 +907,81 @@ HWTEST_F(UIAbilityBaseTest, UIAbilityVirtualFunc_0200, TestSize.Level1) TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } +/** + * @tc.name: OnSceneWillDestroy_0200 + * @tc.desc: UIAbility virtual function test, such as OnSceneWillDestroy. + * @tc.type: FUNC + * @tc.require: issueI60B7N + */ +HWTEST_F(UIAbilityBaseTest, OnSceneWillDestroy_0200, TestSize.Level1) +{ + std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); + ability->OnSceneWillDestroy(); +} + +/** + * @tc.name: GetWindowRect_0100 + * @tc.desc: UIAbility virtual function test, such as GetWindowRect. + * @tc.type: FUNC + * @tc.require: issueI60B7N + */ +HWTEST_F(UIAbilityBaseTest, GetWindowRect_0100, TestSize.Level1) +{ + std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); + int32_t left = 0; + int32_t top = 0; + int32_t width = 0; + int32_t height = 0; + ability->GetWindowRect(left, top, width, height); + ability->GetUIContent(); + ability->scene_ = std::make_shared(); + ability->GetWindowRect(left, top, width, height); + ability->GetUIContent(); +} + +/** + * @tc.name: OnDisplayInfoChange_0100 + * @tc.desc: UIAbility virtual function test, such as OnDisplayInfoChange. + * @tc.type: FUNC + * @tc.require: issueI60B7N + */ +HWTEST_F(UIAbilityBaseTest, OnDisplayInfoChange_0100, TestSize.Level1) +{ + std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); + sptr token = nullptr; + Rosen::DisplayId toDisplayId = 0; + float density = 0.8; + + ability->OnDisplayInfoChange(token, toDisplayId, density, Rosen::DisplayOrientation::PORTRAIT); + int32_t displayId = 2; + sptr option = new Rosen::WindowOption(); + ability->InitWindow(displayId, option); +} + +/** + * @tc.name: EraseUIExtension_0200 + * @tc.desc: UIAbility EraseUIExtension test SetIdentityToken GetIdentityToken IsStartByScb etc. + * @tc.type: FUNC + * @tc.require: issueI60B7N + */ +HWTEST_F(UIAbilityBaseTest, EraseUIExtension_0100, TestSize.Level1) +{ + std::shared_ptr ability = std::make_shared(); + ASSERT_NE(ability, nullptr); + int32_t sessionId = 10008; + ability->EraseUIExtension(sessionId); + auto abilityContext = std::make_shared(); + ability->AttachAbilityContext(abilityContext); + ability->EraseUIExtension(sessionId); + ability->SetIdentityToken(""); + EXPECT_EQ("", ability->GetIdentityToken()); + ability->CheckDefaultRecoveryEnabled(); + ability->IsStartByScb(); +} + /** * @tc.name: DispatchLifecycleOnForeground_0200 * @tc.desc: UIAbility DispatchLifecycleOnForeground test. @@ -849,6 +996,11 @@ HWTEST_F(UIAbilityBaseTest, DispatchLifecycleOnForeground_0100, TestSize.Level1) // lifecycle executor is nullptr Want want; + ability->ContinuationRestore(want); + ability->CallOnForegroundFunc(want); + ability->ExecuteInsightIntentRepeateForeground(want, nullptr, nullptr); + ability->ExecuteInsightIntentMoveToForeground(want, nullptr, nullptr); + ability->ExecuteInsightIntentBackground(want, nullptr, nullptr); ability->DispatchLifecycleOnForeground(want); // lifecycle is nullptr and lifecycle executor is not nullptr @@ -1163,6 +1315,18 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_OnConfigurationUpdatedNotify_0100, TestSiz Configuration configuration; ability_->OnConfigurationUpdatedNotify(configuration); EXPECT_NE(ability_, nullptr); + + std::shared_ptr abilityInfo = std::make_shared(); + std::shared_ptr application = std::make_shared(); + std::shared_ptr handler = nullptr; + sptr token = nullptr; + sptr abilityToken = sptr(new AbilityRuntime::FAAbilityThread()); + std::shared_ptr abilityRecord = std::make_shared(abilityInfo, abilityToken); + ability_->Init(abilityRecord, application, handler, token); + auto abilityContext = std::make_shared(); + ability_->AttachAbilityContext(abilityContext); + ability_->OnConfigurationUpdatedNotify(configuration); + TAG_LOGI(AAFwkTag::TEST, "%{public}s end.", __func__); } @@ -1324,6 +1488,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_RegisterAbilityLifecycleObserver_0100, Fun std::shared_ptr observer = std::make_shared(); EXPECT_EQ(LifeCycle::Event::UNDEFINED, observer->GetLifecycleState()); ability->RegisterAbilityLifecycleObserver(observer); + ability_->RegisterAbilityLifecycleObserver(nullptr); // mock UIAbility lifecycle events, expecting that observer can observe them. Want want; @@ -1335,6 +1500,7 @@ HWTEST_F(UIAbilityBaseTest, UIAbility_RegisterAbilityLifecycleObserver_0100, Fun // unregister lifecycle observer on UIAbility, expecting that observer remains in the previous state, // can not observe later lifecycle events anymore. ability->UnregisterAbilityLifecycleObserver(observer); + ability->UnregisterAbilityLifecycleObserver(nullptr); ability->OnStop(); EXPECT_EQ(LifeCycle::Event::ON_STOP, lifeCycle->GetLifecycleState()); EXPECT_EQ(finalObservedState, observer->GetLifecycleState()); diff --git a/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/ability_delegator_test.cpp b/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/ability_delegator_test.cpp index 0be170a4d0..e3530d6cf1 100644 --- a/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/ability_delegator_test.cpp +++ b/test/unittest/frameworks_kits_appkit_native_test/ability_delegator/ability_delegator_test.cpp @@ -35,11 +35,11 @@ #include "mock_test_observer_stub.h" #include "mock_test_runner.h" #include "ohos_application.h" -#include "scene_board_judgement.h" #include "test_observer_stub.h" #include "test_observer.h" #include "test_runner.h" #include "want.h" +#include "scene_board_judgement.h" using namespace testing; using namespace testing::ext; diff --git a/test/unittest/free_install_manager_test/free_install_manager_test.cpp b/test/unittest/free_install_manager_test/free_install_manager_test.cpp index fc0aea65a7..514f11014f 100644 --- a/test/unittest/free_install_manager_test/free_install_manager_test.cpp +++ b/test/unittest/free_install_manager_test/free_install_manager_test.cpp @@ -121,7 +121,7 @@ HWTEST_F(FreeInstallTest, FreeInstall_StartFreeInstall_002, TestSize.Level1) const sptr callerToken = nullptr; // NotTopAbility int res = freeInstallManager_->StartFreeInstall(want, userId, requestCode, callerToken); - EXPECT_EQ(res, 0x500001); + EXPECT_EQ(res, UNKNOWN_EXCEPTION); } /** diff --git a/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp b/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp index 1927179832..b861c4f66f 100644 --- a/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp +++ b/test/unittest/mission_list_manager_test/mission_list_manager_test.cpp @@ -33,7 +33,9 @@ using namespace OHOS::AppExecFwk; namespace OHOS { namespace AAFwk { namespace { +#ifdef WITH_DLP const std::string DLP_INDEX = "ohos.dlp.params.index"; +#endif // WITH_DLP } class MissionListManagerTest : public testing::Test { public: @@ -958,6 +960,7 @@ HWTEST_F(MissionListManagerTest, CreateOrReusedMissionInfo_007, TestSize.Level1) missionListManager.reset(); } +#ifdef WITH_DLP /* * Feature: MissionListManager * Function: BuildInnerMissionInfo @@ -1004,6 +1007,7 @@ HWTEST_F(MissionListManagerTest, BuildInnerMissionInfo_002, TestSize.Level1) missionListManager->BuildInnerMissionInfo(info, missionName, abilityRequest); missionListManager.reset(); } +#endif // WITH_DLP /* * Feature: MissionListManager diff --git a/test/unittest/pending_want_manager_test/pending_want_manager_test.cpp b/test/unittest/pending_want_manager_test/pending_want_manager_test.cpp index 5c3920923b..5632b8c192 100644 --- a/test/unittest/pending_want_manager_test/pending_want_manager_test.cpp +++ b/test/unittest/pending_want_manager_test/pending_want_manager_test.cpp @@ -56,7 +56,7 @@ public: WantSenderInfo MakeWantSenderInfo(Want& want, int32_t flags, int32_t userId, int32_t type = 1); WantSenderInfo MakeWantSenderInfo(std::vector& wants, int32_t flags, int32_t userId, int32_t type = 1); std::shared_ptr MakeWantKey(WantSenderInfo& wantSenderInfo); - static constexpr int defaultCount = 100; + static constexpr int DEFAULT_COUNT = 100; static constexpr int TEST_WAIT_TIME = 100000; class CancelReceiver : public AAFwk::WantReceiverStub { @@ -82,12 +82,12 @@ int PendingWantManagerTest::CancelReceiver::sendCount = 0; void PendingWantManagerTest::CancelReceiver::Send(const int32_t resultCode) { - sendCount = defaultCount; + sendCount = DEFAULT_COUNT; } void PendingWantManagerTest::CancelReceiver::PerformReceive(const AAFwk::Want& want, int resultCode, const std::string& data, const AAFwk::WantParams& extras, bool serialized, bool sticky, int sendingUser) { - performReceiveCount = defaultCount; + performReceiveCount = DEFAULT_COUNT; } void PendingWantManagerTest::SetUpTestCase() diff --git a/test/unittest/permission_verification_test/permission_verification_test.cpp b/test/unittest/permission_verification_test/permission_verification_test.cpp index dcef3860e5..95bc1001bd 100755 --- a/test/unittest/permission_verification_test/permission_verification_test.cpp +++ b/test/unittest/permission_verification_test/permission_verification_test.cpp @@ -24,7 +24,9 @@ using namespace OHOS::AppExecFwk; namespace OHOS { namespace AAFwk { namespace { +#ifdef WITH_DLP const std::string DLP_PARAMS_INDEX = "ohos.dlp.params.index"; +#endif // WITH_DLP } class PermissionVerificationTest : public testing::Test { public: @@ -158,6 +160,7 @@ HWTEST_F(PermissionVerificationTest, VerifyControllerPerm_0100, TestSize.Level0) EXPECT_FALSE(result); } +#ifdef WITH_DLP /** * @tc.name: VerifyDlpPermission_0100 * @tc.desc: VerifyDlpPermission Test @@ -171,6 +174,7 @@ HWTEST_F(PermissionVerificationTest, VerifyDlpPermission_0100, TestSize.Level0) bool result = AAFwk::PermissionVerification::GetInstance()->VerifyDlpPermission(want); EXPECT_FALSE(result); } +#endif // WITH_DLP /** * @tc.name: VerifyMissionPermission_0100 diff --git a/test/unittest/runtime_test/hdc_register_test.cpp b/test/unittest/runtime_test/hdc_register_test.cpp index ce2e3a3986..324e36faa5 100644 --- a/test/unittest/runtime_test/hdc_register_test.cpp +++ b/test/unittest/runtime_test/hdc_register_test.cpp @@ -57,7 +57,7 @@ HWTEST_F(HdcRegisterTest, HdcRegisterTest_0100, TestSize.Level0) const std::string bundleName = ""; bool debugApp = true; auto &pHdcRegister = AbilityRuntime::HdcRegister::Get(); - + pHdcRegister.StartHdcRegister(bundleName, processName, debugApp, nullptr); EXPECT_TRUE(true); diff --git a/test/unittest/runtime_test/js_quickfix_callback_test.cpp b/test/unittest/runtime_test/js_quickfix_callback_test.cpp index 675017b689..5266b2535d 100644 --- a/test/unittest/runtime_test/js_quickfix_callback_test.cpp +++ b/test/unittest/runtime_test/js_quickfix_callback_test.cpp @@ -57,7 +57,7 @@ HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0100, TestSize.Level0) std::string baseFileName = ""; std::string patchFileName; - void* patchBuffer = nullptr; + uint8_t* patchBuffer = nullptr; size_t patchSize = 0; bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize); EXPECT_FALSE(res); @@ -78,7 +78,7 @@ HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0200, TestSize.Level0) std::string baseFileName = "baseFileName.abc"; std::string patchFileName; - void* patchBuffer = nullptr; + uint8_t* patchBuffer = nullptr; size_t patchSize = 0; bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize); EXPECT_FALSE(res); @@ -99,7 +99,7 @@ HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0300, TestSize.Level0) std::string baseFileName = "/data/storage/el1/bundle/entry/ets/modules.abc"; std::string patchFileName; - void* patchBuffer = nullptr; + uint8_t* patchBuffer = nullptr; size_t patchSize = 0; bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize); EXPECT_FALSE(res); @@ -120,7 +120,7 @@ HWTEST_F(JsQuickfixCallbackTest, JsQuickfixCallbackTest_0400, TestSize.Level0) std::string baseFileName = "/data/storage/el1/bundle/bundle/ets/modules.abc"; std::string patchFileName; - void* patchBuffer = nullptr; + uint8_t* patchBuffer = nullptr; size_t patchSize = 0; bool res = jsQuickfixCallback(baseFileName, patchFileName, &patchBuffer, patchSize); EXPECT_FALSE(res); diff --git a/test/unittest/runtime_test/js_runtime_test.cpp b/test/unittest/runtime_test/js_runtime_test.cpp index 0e266604e5..e574c578c0 100755 --- a/test/unittest/runtime_test/js_runtime_test.cpp +++ b/test/unittest/runtime_test/js_runtime_test.cpp @@ -278,7 +278,6 @@ HWTEST_F(JsRuntimeTest, JsRuntimeRunSandboxScriptTest_0100, TestSize.Level0) std::string hapPath = ""; jsRuntime->RunSandboxScript(path, hapPath); EXPECT_TRUE(jsRuntime != nullptr); - jsRuntime.reset(); std::this_thread::sleep_for(std::chrono::milliseconds(200)); TAG_LOGI(AAFwkTag::TEST, "RunSandboxScript end"); diff --git a/test/unittest/runtime_test/js_worker_test.cpp b/test/unittest/runtime_test/js_worker_test.cpp index 787951acec..3517f5fd84 100644 --- a/test/unittest/runtime_test/js_worker_test.cpp +++ b/test/unittest/runtime_test/js_worker_test.cpp @@ -74,9 +74,9 @@ GetAssetFunc JsWorkerTest::TestGetGetAssetFunc() const HWTEST_F(JsWorkerTest, AssetHelper_0100, TestSize.Level1) { std::shared_ptr workerInfo = std::make_shared(); - workerInfo->codePath = panda::panda_file::StringPacProtect("/data/test/codePath"); + workerInfo->codePath = "/data/test/codePath"; workerInfo->packagePathStr = "/data/test/packagePath"; - workerInfo->hapPath = panda::panda_file::StringPacProtect("/data/test/hapPath"); + workerInfo->hapPath = "/data/test/hapPath"; workerInfo->moduleName = "moduleName"; TestSetGetAssetFunc(AssetHelper(workerInfo)); @@ -101,9 +101,9 @@ HWTEST_F(JsWorkerTest, AssetHelper_0100, TestSize.Level1) HWTEST_F(JsWorkerTest, AssetHelper_0200, TestSize.Level1) { std::shared_ptr workerInfo = std::make_shared(); - workerInfo->codePath = panda::panda_file::StringPacProtect("/data/test/codePath"); + workerInfo->codePath = "/data/test/codePath"; workerInfo->packagePathStr = "/data/test/packagePath"; - workerInfo->hapPath = panda::panda_file::StringPacProtect("/data/test/hapPath"); + workerInfo->hapPath = "/data/test/hapPath"; workerInfo->moduleName = "moduleName"; AssetHelper helper = AssetHelper(workerInfo); diff --git a/test/unittest/runtime_test/mock_js_runtime.h b/test/unittest/runtime_test/mock_js_runtime.h index 482811c08c..ace5c3078a 100644 --- a/test/unittest/runtime_test/mock_js_runtime.h +++ b/test/unittest/runtime_test/mock_js_runtime.h @@ -89,8 +89,7 @@ public: return true; } void DumpHeapSnapshot(bool isPrivate) - { - } + {} }; } // namespace AbilityRuntime } // namespace OHOS diff --git a/test/unittest/services/ability_util_test/ability_util_test.cpp b/test/unittest/services/ability_util_test/ability_util_test.cpp index 60388d5946..e25c2acf50 100644 --- a/test/unittest/services/ability_util_test/ability_util_test.cpp +++ b/test/unittest/services/ability_util_test/ability_util_test.cpp @@ -44,6 +44,7 @@ void AbilityUtilTest::SetUp() void AbilityUtilTest::TearDown() {} +#ifdef WITH_DLP /** * @tc.name: HandleDlpApp_0100 * @tc.desc: HandleDlpApp Test @@ -130,6 +131,7 @@ HWTEST_F(AbilityUtilTest, HandleDlpApp_0600, TestSize.Level0) bool result = AbilityUtil::HandleDlpApp(want); EXPECT_FALSE(result); } +#endif // WITH_DLP /** * @tc.name: ProcessWindowMode_0100 diff --git a/test/unittest/services/ability_util_test/mock/include/mock_permission_verification.h b/test/unittest/services/ability_util_test/mock/include/mock_permission_verification.h index cf44284aa0..affe10a5f1 100644 --- a/test/unittest/services/ability_util_test/mock/include/mock_permission_verification.h +++ b/test/unittest/services/ability_util_test/mock/include/mock_permission_verification.h @@ -50,7 +50,9 @@ public: bool VerifyControllerPerm() const; +#ifdef WITH_DLP bool VerifyDlpPermission(Want &want) const; +#endif // WITH_DLP int VerifyAccountPermission() const; diff --git a/test/unittest/services/ability_util_test/mock/src/mock_permission_verification.cpp b/test/unittest/services/ability_util_test/mock/src/mock_permission_verification.cpp index 1497318fd1..ab021010d0 100644 --- a/test/unittest/services/ability_util_test/mock/src/mock_permission_verification.cpp +++ b/test/unittest/services/ability_util_test/mock/src/mock_permission_verification.cpp @@ -41,10 +41,12 @@ bool PermissionVerification::VerifyControllerPerm() const { return !!(MyFlag::flag_); } +#ifdef WITH_DLP bool PermissionVerification::VerifyDlpPermission(Want &want) const { return !!(MyFlag::flag_); } +#endif // WITH_DLP int PermissionVerification::VerifyAccountPermission() const { return MyFlag::flag_; diff --git a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp index 8ade21a1d1..ff88875e15 100644 --- a/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp +++ b/test/unittest/ui_ability_lifecycle_manager_test/ui_ability_lifecycle_manager_test.cpp @@ -38,7 +38,9 @@ using namespace testing::ext; namespace OHOS { namespace AAFwk { namespace { +#ifdef WITH_DLP const std::string DLP_INDEX = "ohos.dlp.params.index"; +#endif // WITH_DLP constexpr int32_t TEST_UID = 20010001; }; class UIAbilityLifecycleManagerTest : public testing::Test { @@ -2295,6 +2297,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, OnAcceptWantResponse_001, TestSize.Level uiAbilityLifecycleManager.reset(); } +#ifdef WITH_DLP /** * @tc.name: UIAbilityLifecycleManager_OnAcceptWantResponse_0200 * @tc.desc: OnAcceptWantResponse @@ -2335,6 +2338,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, OnAcceptWantResponse_002, TestSize.Level uiAbilityLifecycleManager->OnAcceptWantResponse(want, flag); uiAbilityLifecycleManager.reset(); } +#endif // WITH_DLP /** * @tc.name: UIAbilityLifecycleManager_StartSpecifiedAbilityBySCB_0100 @@ -2886,6 +2890,26 @@ HWTEST_F(UIAbilityLifecycleManagerTest, GetActiveAbilityList_002, TestSize.Level uiAbilityLifecycleManager.reset(); } +/** + * @tc.name: UIAbilityLifecycleManager_IsAbilityStarted_0100 + * @tc.desc: IsAbilityStarted + * @tc.type: FUNC + */ +HWTEST_F(UIAbilityLifecycleManagerTest, IsAbilityStarted_001, TestSize.Level1) +{ + auto uiAbilityLifecycleManager = std::make_unique(); + ASSERT_NE(uiAbilityLifecycleManager, nullptr); + AbilityRequest abilityRequest; + Rosen::SessionInfo info; + sptr sessionInfo(new SessionInfo()); + sessionInfo->sessionToken = new Rosen::Session(info); + sessionInfo->persistentId = 0; + abilityRequest.sessionInfo = sessionInfo; + auto targetRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); + uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, targetRecord); + EXPECT_EQ(uiAbilityLifecycleManager->IsAbilityStarted(abilityRequest, targetRecord), false); +} + /** * @tc.name: UIAbilityLifecycleManager_PrepareTerminateAbility_0100 * @tc.desc: PrepareTerminateAbility @@ -3264,26 +3288,6 @@ HWTEST_F(UIAbilityLifecycleManagerTest, MoveMissionToFront_004, TestSize.Level1) EXPECT_EQ(uiAbilityLifecycleManager->MoveMissionToFront(sessionId, startOptions), ERR_OK); } -/** - * @tc.name: UIAbilityLifecycleManager_IsAbilityStarted_0100 - * @tc.desc: IsAbilityStarted - * @tc.type: FUNC - */ -HWTEST_F(UIAbilityLifecycleManagerTest, IsAbilityStarted_001, TestSize.Level1) -{ - auto uiAbilityLifecycleManager = std::make_unique(); - ASSERT_NE(uiAbilityLifecycleManager, nullptr); - AbilityRequest abilityRequest; - Rosen::SessionInfo info; - sptr sessionInfo(new SessionInfo()); - sessionInfo->sessionToken = new Rosen::Session(info); - sessionInfo->persistentId = 0; - abilityRequest.sessionInfo = sessionInfo; - auto targetRecord = AbilityRecord::CreateAbilityRecord(abilityRequest); - uiAbilityLifecycleManager->sessionAbilityMap_.emplace(sessionInfo->persistentId, targetRecord); - EXPECT_EQ(uiAbilityLifecycleManager->IsAbilityStarted(abilityRequest, targetRecord), false); -} - /** * @tc.name: UIAbilityLifecycleManager_IsAbilityStarted_0200 * @tc.desc: IsAbilityStarted @@ -3875,6 +3879,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, DispatchBackground_002, TestSize.Level1) EXPECT_EQ(uiAbilityLifecycleManager->DispatchBackground(abilityRecord), ERR_INVALID_VALUE); } +#ifdef WITH_DLP /** * @tc.name: UIAbilityLifecycleManager_CheckProperties_0100 * @tc.desc: CheckProperties @@ -3946,6 +3951,7 @@ HWTEST_F(UIAbilityLifecycleManagerTest, CheckProperties_003, TestSize.Level1) auto ret = uiAbilityLifecycleManager->CheckProperties(abilityRecord, abilityRequest, launchMode); EXPECT_EQ(ret, true); } +#endif // WITH_DLP /** * @tc.name: UIAbilityLifecycleManager_ResolveAbility_0100 diff --git a/test/unittest/ui_extension/ui_extension_get_host_info_test/ui_extension_get_host_info_test.cpp b/test/unittest/ui_extension/ui_extension_get_host_info_test/ui_extension_get_host_info_test.cpp index 68951f703d..78f979301a 100644 --- a/test/unittest/ui_extension/ui_extension_get_host_info_test/ui_extension_get_host_info_test.cpp +++ b/test/unittest/ui_extension/ui_extension_get_host_info_test/ui_extension_get_host_info_test.cpp @@ -95,7 +95,6 @@ HWTEST_F(UIExtensionGetHostInfoTest, GetUIExtensionRootHostInfo_0300, TestSize.L if (!Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { auto ret = AbilityManagerClient::GetInstance()->GetTopAbility(token); EXPECT_EQ(ret, ERR_OK); - UIExtensionHostInfo hostInfo; ret = AAFwk::AbilityManagerClient::GetInstance()->GetUIExtensionRootHostInfo(token, hostInfo); // cause top ability isn't a uiextension ability. diff --git a/test/unittest/unlock_screen_test/BUILD.gn b/test/unittest/unlock_screen_test/BUILD.gn index 531e7d312e..5d89c54ba6 100644 --- a/test/unittest/unlock_screen_test/BUILD.gn +++ b/test/unittest/unlock_screen_test/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2022 Huawei Device Co., Ltd. +# Copyright (c) 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 diff --git a/test/unittest/uri_permission_impl_test/mock/include/mock_my_flag.h b/test/unittest/uri_permission_impl_test/mock/include/mock_my_flag.h index 1f90b164cd..31ed85dfba 100644 --- a/test/unittest/uri_permission_impl_test/mock/include/mock_my_flag.h +++ b/test/unittest/uri_permission_impl_test/mock/include/mock_my_flag.h @@ -51,10 +51,9 @@ public: enum FLAG { IS_SA_CALL = 1, IS_SHELL_CALL, - IS_SA_AND_SHELL_CALL + IS_SA_AND_SHELL_CALL, }; static int flag_; - static bool isSACall_; static bool permissionFileAccessManager_; static bool permissionWriteImageVideo_; static bool permissionReadImageVideo_; diff --git a/test/unittest/uri_permission_impl_test/mock/include/mock_permission_verification.h b/test/unittest/uri_permission_impl_test/mock/include/mock_permission_verification.h index da34cd1f0e..b1397b27f5 100644 --- a/test/unittest/uri_permission_impl_test/mock/include/mock_permission_verification.h +++ b/test/unittest/uri_permission_impl_test/mock/include/mock_permission_verification.h @@ -53,7 +53,9 @@ struct VerificationInfo { bool VerifyControllerPerm() const; +#ifdef WITH_DLP bool VerifyDlpPermission(Want &want) const; +#endif // WITH_DLP int VerifyAccountPermission() const; diff --git a/test/unittest/uri_permission_impl_test/mock/src/mock_permission_verification.cpp b/test/unittest/uri_permission_impl_test/mock/src/mock_permission_verification.cpp index a10c1a030a..7f3a3a92d4 100644 --- a/test/unittest/uri_permission_impl_test/mock/src/mock_permission_verification.cpp +++ b/test/unittest/uri_permission_impl_test/mock/src/mock_permission_verification.cpp @@ -79,10 +79,12 @@ bool PermissionVerification::VerifyControllerPerm() const { return !!(MyFlag::flag_); } +#ifdef WITH_DLP bool PermissionVerification::VerifyDlpPermission(Want &want) const { return !!(MyFlag::flag_); } +#endif // WITH_DLP int PermissionVerification::VerifyAccountPermission() const { return MyFlag::flag_; diff --git a/tools/aa/BUILD.gn b/tools/aa/BUILD.gn index 488bdcaa85..387c550b6e 100644 --- a/tools/aa/BUILD.gn +++ b/tools/aa/BUILD.gn @@ -62,7 +62,6 @@ ohos_static_library("tools_aa_source_set") { external_deps = [ "ability_base:base", - "ability_base:session_info", "ability_base:want", "bundle_framework:appexecfwk_core", "c_utils:utils", @@ -72,6 +71,7 @@ ohos_static_library("tools_aa_source_set") { "ipc:ipc_core", ] public_external_deps = [ + "ability_base:session_info", "bundle_framework:appexecfwk_base", "graphic_2d:color_manager", "image_framework:image_native", diff --git a/utils/server/startup/src/startup_util.cpp b/utils/server/startup/src/startup_util.cpp index 3a292a49b2..0560d8f4c8 100644 --- a/utils/server/startup/src/startup_util.cpp +++ b/utils/server/startup/src/startup_util.cpp @@ -89,5 +89,4 @@ void StartupUtil::InitAbilityInfoFromExtension(AppExecFwk::ExtensionAbilityInfo abilityInfo.hapPath = extensionInfo.hapPath; } } - } // namespace OHOS::AbilityRuntime