Merge branch 'master' of gitee.com:openharmony/ability_ability_runtime into devlog_jsnapi

Signed-off-by: sodanotgreen <limengzheng@huawei.com>
This commit is contained in:
sodanotgreen 2024-07-25 07:14:24 +00:00 committed by Gitee
commit 25c58b4c21
247 changed files with 4878 additions and 1896 deletions

View File

@ -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<std::mutex> 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<std::mutex> 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<JsAbilityAutoStartupCallBack> 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<std::mutex> 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_ptr<Nati
napi_value value)
{
if (callback == nullptr) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Invalid jsCallback.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null callback");
return false;
}
auto object = callback->GetNapiValue();
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;
}

View File

@ -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<AutoStar
for (size_t i = 0; i < infoList.size(); ++i) {
auto object = CreateJsAutoStartupInfo(env, infoList.at(i));
if (object == nullptr) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert object failed.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null obj");
return nullptr;
}
if (napi_set_element(env, arrayObj, i, object) != napi_ok) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Insert object to array failed.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "insert object failed");
return nullptr;
}
}
@ -94,31 +94,31 @@ napi_value CreateJsAutoStartupInfo(napi_env env, const AutoStartupInfo &info)
TAG_LOGD(AAFwkTag::AUTO_STARTUP, "called");
napi_value object = AppExecFwk::CreateJSObject(env);
if (object == nullptr) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "object is nullptr.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null object");
return nullptr;
}
napi_value bundleName = AppExecFwk::WrapStringToJS(env, info.bundleName);
if (bundleName == nullptr) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert bundle name failed.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null bundleName");
return nullptr;
}
napi_value abilityName = AppExecFwk::WrapStringToJS(env, info.abilityName);
if (abilityName == nullptr) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert ability name failed.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null abilityName");
return nullptr;
}
napi_value moduleName = AppExecFwk::WrapStringToJS(env, info.moduleName);
if (moduleName == nullptr) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert module name failed.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null moduleName");
return nullptr;
}
napi_value abilityTypeName = AppExecFwk::WrapStringToJS(env, info.abilityTypeName);
if (abilityTypeName == nullptr) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Convert ability type name failed.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "null abilityTypeName");
return nullptr;
}
@ -126,17 +126,17 @@ napi_value CreateJsAutoStartupInfo(napi_env env, const AutoStartupInfo &info)
AppExecFwk::SetPropertyValueByPropertyName(env, object, "abilityName", abilityName) &&
AppExecFwk::SetPropertyValueByPropertyName(env, object, "moduleName", moduleName) &&
AppExecFwk::SetPropertyValueByPropertyName(env, object, "abilityTypeName", abilityTypeName))) {
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Create js AutoStartupInfo failed.");
TAG_LOGE(AAFwkTag::AUTO_STARTUP, "create js AutoStartupInfo failed");
return nullptr;
}
if (info.appCloneIndex >= 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;
}
}

View File

@ -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<int32_t>(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<int32_t>(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<std::vector<AutoStartupInfo>>();
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

View File

@ -172,49 +172,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;
}
@ -230,7 +230,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;
}

View File

@ -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<JSAbilityForegroundStateObserver> jsObserver = this;
@ -37,7 +37,7 @@ void JSAbilityForegroundStateObserver::OnAbilityStateChanged(const AbilityStateD
[jsObserver, abilityStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
sptr<JSAbilityForegroundStateObserver> 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<NativeReference> 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;
}

View File

@ -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<JsAbilityManager>(static_cast<JsAbilityManager*>(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<std::string::const_iterator> 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<AAFwk::UserStatus>(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<AAFwk::AbilityRunningInfo> 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<int32_t>(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<AbilityRuntime::AbilityContext>(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);
}

View File

@ -42,7 +42,7 @@ void AbilityMonitor::OnAbilityStart(const std::weak_ptr<NativeReference> &abilit
jsMonitor_->OnAbilityCreate(abilityObj);
TAG_LOGI(AAFwkTag::DELEGATOR, "end");
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnAbilityForeground(const std::weak_ptr<NativeReference> &abilityObj)
@ -55,7 +55,7 @@ void AbilityMonitor::OnAbilityForeground(const std::weak_ptr<NativeReference> &a
jsMonitor_->OnAbilityForeground(abilityObj);
TAG_LOGI(AAFwkTag::DELEGATOR, "end");
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnAbilityBackground(const std::weak_ptr<NativeReference> &abilityObj)
@ -68,7 +68,7 @@ void AbilityMonitor::OnAbilityBackground(const std::weak_ptr<NativeReference> &a
jsMonitor_->OnAbilityBackground(abilityObj);
TAG_LOGI(AAFwkTag::DELEGATOR, "end");
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnAbilityStop(const std::weak_ptr<NativeReference> &abilityObj)
@ -81,7 +81,7 @@ void AbilityMonitor::OnAbilityStop(const std::weak_ptr<NativeReference> &ability
jsMonitor_->OnAbilityDestroy(abilityObj);
TAG_LOGI(AAFwkTag::DELEGATOR, "end");
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnWindowStageCreate(const std::weak_ptr<NativeReference> &abilityObj)
@ -95,7 +95,7 @@ void AbilityMonitor::OnWindowStageCreate(const std::weak_ptr<NativeReference> &a
jsMonitor_->OnWindowStageCreate(abilityObj);
TAG_LOGI(AAFwkTag::DELEGATOR, "end");
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnWindowStageRestore(const std::weak_ptr<NativeReference> &abilityObj)
@ -108,7 +108,7 @@ void AbilityMonitor::OnWindowStageRestore(const std::weak_ptr<NativeReference> &
jsMonitor_->OnWindowStageRestore(abilityObj);
TAG_LOGI(AAFwkTag::DELEGATOR, "end");
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnWindowStageDestroy(const std::weak_ptr<NativeReference> &abilityObj)
@ -121,7 +121,7 @@ void AbilityMonitor::OnWindowStageDestroy(const std::weak_ptr<NativeReference> &
jsMonitor_->OnWindowStageDestroy(abilityObj);
TAG_LOGI(AAFwkTag::DELEGATOR, "end");
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
} // namespace AbilityDelegatorJs
} // namespace OHOS

View File

@ -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<std::weak_ptr<AbilityRuntime::Context>*>(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<AbilityRuntime::Context>(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<std::weak_ptr<AbilityRuntime::Context> *>(data);
}, nullptr, nullptr);
return object;
@ -121,9 +121,9 @@ JSAbilityDelegator::JSAbilityDelegator()
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
if (delegator) {
auto clearFunc = [](const std::shared_ptr<ADelegatorAbilityProperty> &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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
std::shared_ptr<AbilityMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
std::shared_ptr<AbilityMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
std::shared_ptr<AbilityMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
std::shared_ptr<AbilityMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
std::shared_ptr<AbilityMonitor> 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<AbilityObjectBox>();
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<ADelegatorAbilityProperty> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
std::shared_ptr<AbilityStageMonitor> 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<AbilityStageObjBox>();
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<DelegatorAbilityStageProperty> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<ShellCmdResultBox>();
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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<AbilityRuntime::Context> 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<AbilityRuntime::Context>(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<std::weak_ptr<AbilityRuntime::Context> *>(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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<OHOS::IRemoteObject> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
sptr<OHOS::IRemoteObject> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
sptr<OHOS::IRemoteObject> 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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(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<int32_t>(info.argc));
TAG_LOGI(AAFwkTag::DELEGATOR, "argc: %{public}d", static_cast<int32_t>(info.argc));
std::map<std::string, std::string> 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<AbilityMonitor> &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<NativeReference> 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<AbilityStageMonitor> &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<OHOS::IRemoteObject> &remoteObject)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
std::unique_lock<std::mutex> 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<IRemoteObject> &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<IRem
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 obj");
return nullptr;
}
@ -1105,7 +1102,7 @@ napi_value JSAbilityDelegator::CreateAbilityObject(napi_env env, const sptr<IRem
void JSAbilityDelegator::AbilityLifecycleStateToJs(
const AbilityDelegator::AbilityState &lifeState, AbilityLifecycleState &abilityLifeState)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "enter and lifeState = %{public}d", static_cast<int32_t>(lifeState));
TAG_LOGI(AAFwkTag::DELEGATOR, "lifeState: %{public}d", static_cast<int32_t>(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<AbilityMonitor> &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<AbilityStageMonitor> &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<AbilityMonitor> &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<AbilityStageMonitor> &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<std::string, std::string> &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<std::string> &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<AbilityStageMonitor> &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<NativeReference> reference = nullptr;
@ -1478,17 +1475,17 @@ void JSAbilityDelegator::AddStageMonitorRecord(
std::unique_lock<std::mutex> 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<std::mutex> 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;
}
}

View File

@ -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<AppExecFwk::AbilityDelegatorArgs> 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",

View File

@ -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<std::st
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;
}
@ -94,7 +94,7 @@ napi_value CreateJsAbilityDelegatorArguments(
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 CreateJsNull(env);
}
@ -115,14 +115,14 @@ napi_value CreateJsShellCmdResult(napi_env env, std::unique_ptr<ShellCmdResult>
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;
}

View File

@ -31,70 +31,56 @@ JSAbilityMonitor::JSAbilityMonitor(const std::string &abilityName, const std::st
void JSAbilityMonitor::OnAbilityCreate(const std::weak_ptr<NativeReference> &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<NativeReference> &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<NativeReference> &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<NativeReference> &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<NativeReference> &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<NativeReference> &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<NativeReference> &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<NativeReference> &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;
}

View File

@ -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<int32_t>(observerId));
TAG_LOGD(AAFwkTag::APPMGR, "observer exist:%{public}d", static_cast<int32_t>(observerId));
} else {
TAG_LOGD(AAFwkTag::APPMGR, "not find observer, observer:%{public}d", static_cast<int32_t>(observerId));
TAG_LOGD(AAFwkTag::APPMGR, "observer not exist:%{public}d", static_cast<int32_t>(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> 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<AppExecFwk::AppStateData> 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> 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<AppExecFwk::AppStateData> 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<AppExecFwk::RunningProcessInfo> 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> 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<AppExecFwk::RunningProcessInfo> 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> 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<OHOS::AAFwk::IAbilityManager> 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> 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> 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> 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> 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> 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<OHOS::AAFwk::IAbilityManager> 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;
}

View File

@ -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;
}

View File

@ -92,7 +92,7 @@ void JSAppStateObserver::OnExtensionStateChanged(const AbilityStateData &ability
([jsObserver, abilityStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
sptr<JSAppStateObserver> 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<JSAppStateObserver> 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<NativeReference>(reinterpret_cast<NativeReference*>(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;
}

View File

@ -141,7 +141,7 @@ public:
static void Finalizer(napi_env env, void* data, void* hint)
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
TAG_LOGI(AAFwkTag::JSNAPI, "finalizer called");
std::unique_ptr<JsErrorManager>(static_cast<JsErrorManager*>(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 nullptr");
TAG_LOGD(AAFwkTag::JSNAPI, "null observer_");
// create observer
observer_ = std::make_shared<JsErrorObserver>(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, "called");
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<NapiAsyncTask::CompleteCallback> complete = std::make_unique<NapiAsyncTask::CompleteCallback>
([number](napi_env env, NapiAsyncTask &task, int32_t status) {
if (loopObserver_ == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "loopObserver_ is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null loopObserver_");
return;
}
if (loopObserver_->env == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "env is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null env");
return;
}
if (loopObserver_->observerObject == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "observerObject is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null observer");
return;
}
napi_value jsValue[] = { CreateJsValue(loopObserver_->env, number) };
@ -494,17 +494,17 @@ private:
napi_value OnSetLoopWatch(napi_env env, size_t argc, napi_value* argv)
{
if (argc != ARGC_THREE) {
TAG_LOGE(AAFwkTag::JSNAPI, "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, "parse timeout failed");
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, "parse observer failed");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid param");
ThrowInvalidParamError(env, "Parameter error: Failed to parse observer, must be a LoopObserver.");
return CreateJsUndefined(env);
}
@ -515,7 +515,7 @@ private:
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;
}
@ -575,14 +575,14 @@ napi_value JsErrorManagerInit(napi_env env, napi_value exportObj)
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (env == nullptr || exportObj == nullptr) {
TAG_LOGI(AAFwkTag::JSNAPI, "env or exportObj nullptr");
TAG_LOGI(AAFwkTag::JSNAPI, "null env or exportObj");
return nullptr;
}
std::unique_ptr<JsErrorManager> jsErrorManager = std::make_unique<JsErrorManager>();
jsErrorManager->SetRejectionCallback(env);
napi_wrap(env, exportObj, jsErrorManager.release(), JsErrorManager::Finalizer, nullptr, nullptr);
TAG_LOGI(AAFwkTag::JSNAPI, "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);

View File

@ -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");
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;
@ -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));

View File

@ -35,7 +35,7 @@ void JSAbilityFirstFrameStateObserver::OnAbilityFirstFrameState(
[self, abilityFirstFrameStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
sptr<JSAbilityFirstFrameStateObserver> 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<JSAbilityFirstFrameStateObserver> observer)
{
if (observer == nullptr || observer->GetNativeReference() == nullptr) {
TAG_LOGE(AAFwkTag::ABILITYMGR, "Observer is null.");
TAG_LOGE(AAFwkTag::ABILITYMGR, "null observer");
return;
}
std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> lock(observerListLock_);
@ -155,7 +155,7 @@ void JSAbilityFirstFrameStateObserverManager::RemoveJsObserverObject(
std::shared_ptr<NativeReference> 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<NativeReference> 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<std::mutex> 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<NativeReference> 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;
}

View File

@ -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<JSAppForegroundStateObserver> self = this;
@ -37,7 +37,7 @@ void JSAppForegroundStateObserver::OnAppStateChanged(const AppStateData &appStat
[self, appStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
sptr<JSAppForegroundStateObserver> 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<NativeReference>(reinterpret_cast<NativeReference *>(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<NativeReference> 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<std::mutex> 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;
}

View File

@ -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<JsAppManager>(static_cast<JsAppManager*>(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<OHOS::AppExecFwk::IAppMgr> appMgr = appManager.promote();
if (appMgr == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "App manager is nullptr.");
TAG_LOGE(AAFwkTag::APPMGR, "null appmgr");
*innerErrorCode = static_cast<int32_t>(AbilityErrorCode::ERROR_CODE_INNER);
return;
}
@ -1341,7 +1341,7 @@ private:
[param, innerErrorCode, weak]() {
sptr<OHOS::AppExecFwk::IAppMgr> appMgr = weak.promote();
if (appMgr == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "PreloadApplication appMgr is nullptr.");
TAG_LOGE(AAFwkTag::APPMGR, "null appMgr");
*innerErrorCode = static_cast<int32_t>(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;
}

View File

@ -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;
}

View File

@ -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<JSAppStateObserver> jsObserver = this;
@ -39,7 +39,7 @@ void JSAppStateObserver::OnForegroundApplicationChanged(const AppStateData &appS
([jsObserver, appStateData](napi_env env, NapiAsyncTask &task, int32_t status) {
sptr<JSAppStateObserver> 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;

View File

@ -88,7 +88,7 @@ private:
napi_typeof(env, argv[i], &paramType);
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<AAFwk::Want> want = std::make_shared<AAFwk::Want>();
@ -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;
}

View File

@ -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<JsContext>(static_cast<JsContext*>(data));
@ -79,14 +79,14 @@ napi_value CreateJsBaseContextFromSendable(napi_env env, void* wrapped)
{
JsContext *sendableContext = static_cast<JsContext*>(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> 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<JsContext*>(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<JsContext*>(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<JsContext*>(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> context = weakContext.lock();
if (context == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "Context invalid.");
TAG_LOGE(AAFwkTag::CONTEXT, "null ontext");
return nullptr;
}
auto uiAbilityContext = Context::ConvertTo<AbilityContext>(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<JsSendableContextManager>(static_cast<JsSendableContextManager*>(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);
}

View File

@ -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<JsStartupTaskResult> jsResult = std::static_pointer_cast<JsStartupTaskResult>(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);
}

View File

@ -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<int32_t>(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<JsAutoSaveRequestCallback>(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;
}

View File

@ -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_ptr<NativeReferen
auto object = callback->GetNapiValue();
if (object == nullptr) {
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "Failed to get object.");
TAG_LOGE(AAFwkTag::AUTOFILLMGR, "null obj");
return false;
}

View File

@ -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<RequestInfo*>(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> 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;

View File

@ -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<JsFeatureAbility>(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<AsyncCallbackInfo *>(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<AsyncCallbackInfo *>(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<void *>(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<AsyncCallbackInfo *>(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<AsyncCallbackInfo *>(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<void *>(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<OnAbilityCallback *>(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<void *>(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 &param, 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 &param, 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 &param, 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 &param, 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, &param.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<void *>(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<void *>(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<DataAbilityHelperCB *>(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<DataAbilityHelperCB *>(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<AsyncCallbackInfo *>(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<AsyncCallbackInfo *>(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<void *>(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<AsyncCallbackInfo *>(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<AsyncCallbackInfo *>(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<void *>(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

View File

@ -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);

View File

@ -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<DAHelperOnOffCB *>(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;
}

View File

@ -27,18 +27,18 @@ void NAPIDataAbilityObserver::ReleaseJSCallback()
{
std::lock_guard<std::mutex> 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<DelRefCallbackInfo*>(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<std::mutex> 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

View File

@ -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<JsFeatureAbility>(static_cast<JsFeatureAbility*>(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<void **>(&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;
}

View File

@ -100,14 +100,14 @@ napi_value JsNapiCommon::JsConnectAbility(napi_env env, napi_callback_info info,
napi_value argv[ARGS_MAX_COUNT] = {nullptr};
napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr);
if (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);
}
std::lock_guard<std::mutex> 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<int32_t> &erro
execute = [obj = this, value = errorVal, abilityType, abilityConnection] () {
if (obj->ability_ == nullptr) {
*value = static_cast<int32_t>(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<NAPIAbilityConnection> JsNapiCommon::FindConnectionLocked(const Want &want, int64_t &id)
{
TAG_LOGD(AAFwkTag::JSNAPI, "called uri:%{public}s", 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();
@ -310,7 +310,7 @@ napi_value JsNapiCommon::JsGetFilesDir(napi_env env, napi_callback_info info, co
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);
}
@ -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<int32_t>(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)) {
@ -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<int32_t>(NAPI_ERR_ABILITY_CALL_INVALID);
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the abilitycontext is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null abilityContext");
return;
}
dir->name = context->GetFilesDir();
@ -359,7 +359,7 @@ napi_value JsNapiCommon::JsIsUpdatingConfigurations(
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);
}
@ -368,7 +368,7 @@ napi_value JsNapiCommon::JsIsUpdatingConfigurations(
auto execute = [obj = this, data = config, value = errorVal, abilityType] () {
if (obj->ability_ == nullptr) {
*value = static_cast<int32_t>(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)) {
@ -377,7 +377,7 @@ napi_value JsNapiCommon::JsIsUpdatingConfigurations(
}
if (data == nullptr) {
*value = static_cast<int32_t>(NAPI_ERR_ABILITY_CALL_INVALID);
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, param is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null data");
return;
}
data->status = obj->ability_->IsUpdatingConfigurations();
@ -408,7 +408,7 @@ napi_value JsNapiCommon::JsPrintDrawnCompleted(
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);
}
@ -417,7 +417,7 @@ napi_value JsNapiCommon::JsPrintDrawnCompleted(
auto execute = [obj = this, data = drawComplete, value = errorVal, abilityType] () {
if (obj->ability_ == nullptr) {
*value = static_cast<int32_t>(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)) {
@ -426,7 +426,7 @@ napi_value JsNapiCommon::JsPrintDrawnCompleted(
}
if (data == nullptr) {
*value = static_cast<int32_t>(NAPI_ERR_ABILITY_CALL_INVALID);
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, data is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null data");
return;
}
data->status = obj->ability_->PrintDrawnCompleted();
@ -456,7 +456,7 @@ napi_value JsNapiCommon::JsGetCacheDir(napi_env env, napi_callback_info info, co
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);
}
@ -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<int32_t>(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)) {
@ -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<int32_t>(NAPI_ERR_ABILITY_CALL_INVALID);
TAG_LOGE(AAFwkTag::JSNAPI, "task execute error, the ability context is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null context");
return;
}
dir->name = context->GetCacheDir();
@ -507,7 +507,7 @@ napi_value JsNapiCommon::JsGetCtxAppType(
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<int32_t>(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)) {
@ -555,7 +555,7 @@ napi_value JsNapiCommon::JsGetCtxHapModuleInfo(
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<int32_t>(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<int32_t>(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<int32_t>(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<int32_t>(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)) {
@ -949,7 +949,7 @@ napi_value JsNapiCommon::CreateAbilityInfo(napi_env env, const AbilityInfo &abil
napi_value objContext = nullptr;
napi_create_object(env, &objContext);
if (objContext == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "CreateObject failed");
TAG_LOGE(AAFwkTag::JSNAPI, "null objContext");
return CreateJsUndefined(env);
}
if (!CheckTypeForNapiValue(env, objContext, napi_object)) {
@ -1148,7 +1148,7 @@ napi_value JsNapiCommon::JsGetWant(napi_env env, napi_callback_info info, const
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);
}
@ -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<int32_t>(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<JsWant> &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);
@ -1207,7 +1207,7 @@ napi_value JsNapiCommon::JsTerminateAbility(napi_env env, NapiCallbackInfo& info
{
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, "Wrong argument type");
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, "jsWant == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null jsWant");
return false;
}
@ -1265,7 +1265,7 @@ bool UnwrapParamForWant(napi_env env, napi_value args, AbilityType, CallAbilityP
if (!UnwrapAbilityStartSetting(env, jsSettingObj, *(param.setting))) {
TAG_LOGE(AAFwkTag::JSNAPI, "unwrap abilityStartSetting failed");
}
TAG_LOGD(AAFwkTag::JSNAPI, "abilityStartSetting");
TAG_LOGI(AAFwkTag::JSNAPI, "abilityStartSetting");
}
TAG_LOGI(AAFwkTag::JSNAPI, "end");
@ -1283,7 +1283,7 @@ void JsNapiCommon::SetJsStartAbilityExecuteCallback(std::shared_ptr<int32_t> &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;
}
@ -1335,11 +1335,11 @@ napi_value JsNapiCommon::JsStartAbility(napi_env env, napi_callback_info info, A
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;
}
}
@ -1382,13 +1382,13 @@ napi_value JsNapiCommon::JsGetExternalCacheDir(napi_env env, napi_callback_info
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);
}
auto complete = [obj = this, abilityType](napi_env env, NapiAsyncTask &task, int32_t status) {
if (obj->ability_ == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "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, "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));

View File

@ -282,14 +282,14 @@ static void SetWakeUpScreenAsyncCompleteCB(napi_env env, napi_status status, voi
TAG_LOGI(AAFwkTag::JSNAPI, "called");
SetWakeUpScreenCB *setWakeUpScreenCB = static_cast<SetWakeUpScreenCB *>(data);
if (setWakeUpScreenCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "input param WakeUpScreenCB is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null callback");
return;
}
do {
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
if (setWakeUpScreenCB->cbBase.ability == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "input param cbBase ability is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null ability");
setWakeUpScreenCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
break;
}
@ -343,7 +343,7 @@ static napi_value SetWakeUpScreenAsync(napi_env env, napi_value *args, SetWakeUp
nullptr,
resourceName,
[](napi_env env, void *data) {
TAG_LOGI(AAFwkTag::JSNAPI, "worker pool thread execute");
TAG_LOGI(AAFwkTag::JSNAPI, "execute called");
},
SetWakeUpScreenAsyncCompleteCB,
static_cast<void *>(cbData),
@ -356,9 +356,9 @@ static napi_value SetWakeUpScreenAsync(napi_env env, napi_value *args, SetWakeUp
napi_value SetWakeUpScreenPromise(napi_env env, SetWakeUpScreenCB *cbData)
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
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;
@ -373,14 +373,14 @@ napi_value SetWakeUpScreenPromise(napi_env env, SetWakeUpScreenCB *cbData)
nullptr,
resourceName,
[](napi_env env, void *data) {
TAG_LOGI(AAFwkTag::JSNAPI, "worker pool thread execute");
TAG_LOGI(AAFwkTag::JSNAPI, "execute called");
},
[](napi_env env, napi_status status, void *data) {
TAG_LOGI(AAFwkTag::JSNAPI, "main event thread complete");
TAG_LOGI(AAFwkTag::JSNAPI, "complete called");
SetWakeUpScreenCB *setWakeUpScreenCB = static_cast<SetWakeUpScreenCB *>(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
@ -397,7 +397,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, "main event thread complete end");
TAG_LOGI(AAFwkTag::JSNAPI, "complete end");
},
static_cast<void *>(cbData),
&cbData->cbBase.asyncWork);
@ -785,11 +785,11 @@ struct OnRequestPermissionsData {
{
TAG_LOGD(AAFwkTag::JSNAPI, "called");
if (work == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "work is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null work");
return;
}
if (work->data == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "work data is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null data");
return;
}
std::unique_ptr<OnRequestPermissionsData> data{static_cast<OnRequestPermissionsData *>(work->data)};
@ -812,26 +812,26 @@ void CallOnRequestPermissionsFromUserResult(int requestCode, const std::vector<s
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (permissions.empty()) {
TAG_LOGE(AAFwkTag::JSNAPI, "the string vector permissions is empty");
TAG_LOGE(AAFwkTag::JSNAPI, "empty permissions");
return;
}
if (permissions.size() != grantResults.size()) {
TAG_LOGE(AAFwkTag::JSNAPI, "the size of permissions not equal the size of grantResults");
TAG_LOGE(AAFwkTag::JSNAPI, "permissions size not match");
return;
}
if (callbackInfo.env == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "callbackInfo.env is nullptr.");
TAG_LOGE(AAFwkTag::JSNAPI, "null env");
return;
}
if (callbackInfo.napiAsyncTask == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "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, "loop is nullptr.");
TAG_LOGE(AAFwkTag::JSNAPI, "null loop");
return;
}
@ -903,12 +903,12 @@ bool UnwrapVerifyPermissionOptions(napi_env env, napi_value argv, AsyncJSCallbac
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo is null");
TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo");
return false;
}
if (!IsTypeForNapiValue(env, argv, napi_object)) {
TAG_LOGE(AAFwkTag::JSNAPI, "type of parameter is error");
TAG_LOGI(AAFwkTag::JSNAPI, "wrong param type");
return false;
}
@ -926,42 +926,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, "called, argc=%{public}zu", argc);
TAG_LOGI(AAFwkTag::JSNAPI, "argc=%{public}zu", argc);
const size_t argcMax = ARGS_THREE;
if (argc > argcMax || argc < 1) {
TAG_LOGE(AAFwkTag::JSNAPI, "Params number is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "invalid argc");
return false;
}
std::string permission("");
if (!UnwrapStringFromJS2(env, argv[PARAM0], permission)) {
TAG_LOGE(AAFwkTag::JSNAPI, "the first parameter is invalid");
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_LOGE(AAFwkTag::JSNAPI, "the second parameter is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "invalid argv[PARAM2]");
return false;
}
if (!UnwrapVerifyPermissionOptions(env, argv[PARAM1], asyncCallbackInfo)) {
TAG_LOGE(AAFwkTag::JSNAPI, "the first parameter is invalid");
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_LOGE(AAFwkTag::JSNAPI, "the only parameter is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "invalid argv[PARAM1]");
return false;
}
}
} else if (argc == ARGS_ONE) {
asyncCallbackInfo->cbInfo.callback = nullptr;
} else {
TAG_LOGE(AAFwkTag::JSNAPI, "the parameter is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "invalid argc");
return false;
}
return true;
@ -973,7 +973,7 @@ void VerifyPermissionExecuteCallback(napi_env env, void *data)
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo is null");
TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo");
return;
}
@ -1010,7 +1010,7 @@ 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_LOGE(AAFwkTag::JSNAPI, "Invoke UnwrapParamVerifyPermission fail");
TAG_LOGI(AAFwkTag::JSNAPI, "unwrapParamVerifyPermission failed");
return nullptr;
}
@ -1037,7 +1037,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_LOGE(AAFwkTag::JSNAPI, "Invoke CreateAsyncJSCallbackInfo failed");
TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo");
return WrapVoidToJS(env);
}
@ -1051,12 +1051,12 @@ napi_value NAPI_VerifyPermission(napi_env env, napi_callback_info info)
void GetAppInfoExecuteCB(napi_env env, void *data)
{
TAG_LOGI(AAFwkTag::JSNAPI, "worker pool thread execute");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
AppInfoCB *appInfoCB = static_cast<AppInfoCB *>(data);
appInfoCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
if (appInfoCB->cbBase.ability == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "ability == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null ability");
appInfoCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
return;
}
@ -1065,15 +1065,15 @@ void GetAppInfoExecuteCB(napi_env env, void *data)
if (appInfoPtr != nullptr) {
appInfoCB->appInfo = *appInfoPtr;
} else {
TAG_LOGE(AAFwkTag::JSNAPI, "appInfoPtr == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoPtr");
appInfoCB->cbBase.errCode = NAPI_ERR_ABILITY_CALL_INVALID;
}
TAG_LOGI(AAFwkTag::JSNAPI, "worker pool thread execute end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
}
void GetAppInfoAsyncCompleteCB(napi_env env, napi_status status, void *data)
{
TAG_LOGI(AAFwkTag::JSNAPI, "main event thread complete");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
AppInfoCB *appInfoCB = static_cast<AppInfoCB *>(data);
napi_value callback = nullptr;
napi_value undefined = nullptr;
@ -1095,14 +1095,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, "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, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (args == nullptr || appInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null param");
return nullptr;
}
napi_value resourceName = nullptr;
@ -1124,16 +1124,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, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return result;
}
void GetAppInfoPromiseCompleteCB(napi_env env, napi_status status, void *data)
{
TAG_LOGI(AAFwkTag::JSNAPI, "main event thread complete");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
AppInfoCB *appInfoCB = static_cast<AppInfoCB *>(data);
if (appInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "appInfoCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB");
return;
}
@ -1149,14 +1149,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, "main event thread complete end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
}
napi_value GetApplicationInfoPromise(napi_env env, AppInfoCB *appInfoCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "promise");
if (appInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB");
return nullptr;
}
napi_value resourceName = nullptr;
@ -1175,15 +1175,15 @@ napi_value GetApplicationInfoPromise(napi_env env, AppInfoCB *appInfoCB)
static_cast<void *>(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, "promise end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return promise;
}
napi_value GetApplicationInfoWrap(napi_env env, napi_callback_info info, AppInfoCB *appInfoCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (appInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "appInfoCB == null");
TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB");
return nullptr;
}
@ -1195,7 +1195,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, "Wrong parameter count");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc");
return nullptr;
}
@ -1204,7 +1204,7 @@ napi_value GetApplicationInfoWrap(napi_env env, napi_callback_info info, AppInfo
} else {
ret = GetApplicationInfoPromise(env, appInfoCB);
}
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return ret;
}
@ -1222,7 +1222,7 @@ AppInfoCB *CreateAppInfoCBInfo(napi_env env)
AppInfoCB *appInfoCB = new (std::nothrow) AppInfoCB;
if (appInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "appInfoCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB");
return nullptr;
}
appInfoCB->cbBase.cbInfo.env = env;
@ -1241,21 +1241,21 @@ void GetBundleNameExecuteCallback(napi_env env, void *data)
TAG_LOGI(AAFwkTag::JSNAPI, "called");
AsyncJSCallbackInfo *asyncCallbackInfo = static_cast<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo is null");
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, "ability == nullptr");
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, "end bundleName=%{public}s",
TAG_LOGI(AAFwkTag::JSNAPI, "bundleName=%{public}s",
asyncCallbackInfo->native_data.str_value.c_str());
}
@ -1270,13 +1270,13 @@ 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_LOGE(AAFwkTag::JSNAPI, "parameters is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "invalid argc");
return nullptr;
}
if (argc == ARGS_ONE) {
if (!CreateAsyncCallback(env, args[PARAM0], asyncCallbackInfo)) {
TAG_LOGE(AAFwkTag::JSNAPI, "the first parameter is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "invalid args[PARAM0]");
return nullptr;
}
}
@ -1303,7 +1303,7 @@ napi_value WrapProcessInfo(napi_env env, ProcessInfoCB *processInfoCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (processInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "Invalid param(processInfoCB == nullptr)");
TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB");
return nullptr;
}
napi_value result = nullptr;
@ -1374,9 +1374,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, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (args == nullptr || processInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null param");
return nullptr;
}
napi_value resourceName = nullptr;
@ -1398,7 +1398,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, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return result;
}
@ -1423,9 +1423,9 @@ void GetProcessInfoPromiseCompleteCB(napi_env env, napi_status status, void *dat
napi_value GetProcessInfoPromise(napi_env env, ProcessInfoCB *processInfoCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "promise");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (processInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB");
return nullptr;
}
napi_value resourceName = nullptr;
@ -1444,7 +1444,7 @@ napi_value GetProcessInfoPromise(napi_env env, ProcessInfoCB *processInfoCB)
static_cast<void *>(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, "promise end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return promise;
}
@ -1452,7 +1452,7 @@ napi_value GetProcessInfoWrap(napi_env env, napi_callback_info info, ProcessInfo
{
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback");
if (processInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "processInfoCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB");
return nullptr;
}
@ -1464,7 +1464,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, "argument count fail");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc");
return nullptr;
}
@ -1473,7 +1473,7 @@ napi_value GetProcessInfoWrap(napi_env env, napi_callback_info info, ProcessInfo
} else {
ret = GetProcessInfoPromise(env, processInfoCB);
}
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return ret;
}
@ -1491,7 +1491,7 @@ ProcessInfoCB *CreateProcessInfoCBInfo(napi_env env)
ProcessInfoCB *processInfoCB = new (std::nothrow) ProcessInfoCB;
if (processInfoCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "processInfoCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null processInfoCB");
return nullptr;
}
processInfoCB->cbBase.cbInfo.env = env;
@ -1517,7 +1517,7 @@ ElementNameCB *CreateElementNameCBInfo(napi_env env)
ElementNameCB *elementNameCB = new (std::nothrow) ElementNameCB;
if (elementNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "elementNameCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null elementNameCB");
return nullptr;
}
elementNameCB->cbBase.cbInfo.env = env;
@ -1533,7 +1533,7 @@ napi_value WrapElementName(napi_env env, const ElementNameCB *elementNameCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (elementNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "Invalid param(appInfoCB = nullptr)");
TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB");
return nullptr;
}
napi_value result = nullptr;
@ -1561,18 +1561,18 @@ void GetElementNameExecuteCB(napi_env env, void *data)
{
TAG_LOGI(AAFwkTag::JSNAPI, "worker pool thread execute");
if (data == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "data == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null data");
return;
}
ElementNameCB *elementNameCB = static_cast<ElementNameCB *>(data);
if (elementNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "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, "ability == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null ability");
elementNameCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
return;
}
@ -1587,7 +1587,7 @@ void GetElementNameExecuteCB(napi_env env, void *data)
} else {
elementNameCB->cbBase.errCode = NAPI_ERR_ABILITY_CALL_INVALID;
}
TAG_LOGI(AAFwkTag::JSNAPI, "worker pool thread execute end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
}
void GetElementNameAsyncCompleteCB(napi_env env, napi_status status, void *data)
@ -1638,9 +1638,9 @@ void GetElementNamePromiseCompleteCB(napi_env env, napi_status status, void *dat
napi_value GetElementNamePromise(napi_env env, ElementNameCB *elementNameCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "promise");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (elementNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null elementNameCB");
return nullptr;
}
napi_value resourceName = nullptr;
@ -1659,15 +1659,15 @@ napi_value GetElementNamePromise(napi_env env, ElementNameCB *elementNameCB)
static_cast<void *>(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, "promise end");
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, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (args == nullptr || elementNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null param");
return nullptr;
}
napi_value resourceName = nullptr;
@ -1689,15 +1689,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, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return result;
}
napi_value GetElementNameWrap(napi_env env, napi_callback_info info, ElementNameCB *elementNameCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (elementNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "appInfoCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null appInfoCB");
return nullptr;
}
@ -1709,7 +1709,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, "argument count fail");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc");
return nullptr;
}
@ -1718,7 +1718,7 @@ napi_value GetElementNameWrap(napi_env env, napi_callback_info info, ElementName
} else {
ret = GetElementNamePromise(env, elementNameCB);
}
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return ret;
}
@ -1736,7 +1736,7 @@ ProcessNameCB *CreateProcessNameCBInfo(napi_env env)
ProcessNameCB *processNameCB = new (std::nothrow) ProcessNameCB;
if (processNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "processNameCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null processNameCB");
return nullptr;
}
processNameCB->cbBase.cbInfo.env = env;
@ -1750,22 +1750,22 @@ ProcessNameCB *CreateProcessNameCBInfo(napi_env env)
void GetProcessNameExecuteCB(napi_env env, void *data)
{
TAG_LOGI(AAFwkTag::JSNAPI, "worker pool thread execute");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
ProcessNameCB *processNameCB = static_cast<ProcessNameCB *>(data);
if (processNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "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, "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, "worker pool thread execute end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
}
napi_value WrapProcessName(napi_env env, const ProcessNameCB *processNameCB)
@ -1829,7 +1829,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, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (args == nullptr || processNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
return nullptr;
@ -1853,7 +1853,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, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return result;
}
@ -1880,13 +1880,13 @@ napi_value GetProcessNamePromise(napi_env env, ProcessNameCB *processNameCB)
static_cast<void *>(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, "promise end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return promise;
}
napi_value GetProcessNameWrap(napi_env env, napi_callback_info info, ProcessNameCB *processNameCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (processNameCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "processNameCB == nullptr");
return nullptr;
@ -1909,7 +1909,7 @@ napi_value GetProcessNameWrap(napi_env env, napi_callback_info info, ProcessName
} else {
ret = GetProcessNamePromise(env, processNameCB);
}
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return ret;
}
@ -2021,7 +2021,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, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (args == nullptr || callingBundleCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
return nullptr;
@ -2045,7 +2045,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, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return result;
}
@ -2072,13 +2072,13 @@ napi_value GetCallingBundlePromise(napi_env env, CallingBundleCB *callingBundleC
static_cast<void *>(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, "promise end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return promise;
}
napi_value GetCallingBundleWrap(napi_env env, napi_callback_info info, CallingBundleCB *callingBundleCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (callingBundleCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "callingBundleCB == nullptr");
return nullptr;
@ -2101,7 +2101,7 @@ napi_value GetCallingBundleWrap(napi_env env, napi_callback_info info, CallingBu
} else {
ret = GetCallingBundlePromise(env, callingBundleCB);
}
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return ret;
}
@ -2221,7 +2221,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, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (args == nullptr || getOrCreateLocalDirCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "param == nullptr");
return nullptr;
@ -2246,7 +2246,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, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return result;
}
@ -2279,7 +2279,7 @@ napi_value GetOrCreateLocalDirPromise(napi_env env, GetOrCreateLocalDirCB *getOr
napi_value GetOrCreateLocalDirWrap(napi_env env, napi_callback_info info, GetOrCreateLocalDirCB *getOrCreateLocalDirCB)
{
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback");
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (getOrCreateLocalDirCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "getOrCreateLocalDirCB == nullptr");
return nullptr;
@ -2302,7 +2302,7 @@ napi_value GetOrCreateLocalDirWrap(napi_env env, napi_callback_info info, GetOrC
} else {
ret = GetOrCreateLocalDirPromise(env, getOrCreateLocalDirCB);
}
TAG_LOGI(AAFwkTag::JSNAPI, "asyncCallback end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return ret;
}
@ -2583,13 +2583,13 @@ napi_value GetPreferencesDirWrap(napi_env env, napi_callback_info info, Preferen
{
TAG_LOGI(AAFwkTag::JSNAPI, "called");
if (getPreferencesDirCB == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "getPreferencesDirCB == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null getPreferencesDirCB");
return nullptr;
}
getPreferencesDirCB->cbBase.errCode = NAPI_ERR_NO_ERROR;
if (getPreferencesDirCB->cbBase.ability == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "ability == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null ability");
getPreferencesDirCB->cbBase.errCode = NAPI_ERR_ACE_ABILITY;
return nullptr;
}
@ -2607,16 +2607,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,
"dirWithModuleName is not exits:%{public}s, do nothing and return null",
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, "GetDir preferencesDir:%{public}s",
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);
}
@ -2645,7 +2642,7 @@ napi_value NAPI_GetPreferencesDirSync(napi_env env, napi_callback_info info)
if (ret == nullptr) {
ret = WrapVoidToJS(env);
TAG_LOGE(AAFwkTag::JSNAPI, "ret == nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null ret");
} else {
TAG_LOGI(AAFwkTag::JSNAPI, "end");
}
@ -2677,7 +2674,7 @@ napi_value NAPI_SetDisplayOrientation(napi_env env, napi_callback_info info)
AsyncJSCallbackInfo *asyncCallbackInfo = CreateAsyncJSCallbackInfo(env);
if (asyncCallbackInfo == nullptr) {
TAG_LOGW(AAFwkTag::JSNAPI, "Invoke CreateAsyncJSCallbackInfo failed");
TAG_LOGW(AAFwkTag::JSNAPI, "null asyncCallbackInfo");
return WrapVoidToJS(env);
}
@ -2769,7 +2766,7 @@ napi_value NAPI_SetWakeUpScreen(napi_env env, napi_callback_info info)
TAG_LOGE(AAFwkTag::JSNAPI, "setWakeUpScreenCB run failed, delete resource");
ret = WrapVoidToJS(env);
}
TAG_LOGI(AAFwkTag::JSNAPI, "called end");
TAG_LOGI(AAFwkTag::JSNAPI, "end");
return ret;
#else
return nullptr;

View File

@ -97,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_LOGE(AAFwkTag::JSNAPI, "Params is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "not napi_object");
return false;
}

View File

@ -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_LOGE(AAFwkTag::JSNAPI, "Params is invalid");
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_LOGE(AAFwkTag::JSNAPI, "Params is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "not napi_object");
return false;
}
napi_value jsValue = GetPropertyValueByPropertyName(env, param, "parameters", napi_object);

View File

@ -864,7 +864,7 @@ AsyncJSCallbackInfo *CreateAsyncJSCallbackInfo(napi_env env)
AsyncJSCallbackInfo *asyncCallbackInfo = new (std::nothrow) AsyncJSCallbackInfo;
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo == nullptr");
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_LOGE(AAFwkTag::JSNAPI, "param or callback is null");
TAG_LOGI(AAFwkTag::JSNAPI, "null param or callback");
return false;
}
callback->cbInfo.callback = CreateCallbackRefFromJS(env, param);
if (callback->cbInfo.callback == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "create ref failed");
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_LOGE(AAFwkTag::JSNAPI, "env or param is null");
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_LOGE(AAFwkTag::JSNAPI, "Param is invalid");
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_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo or param is null");
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_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo or param is null");
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<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo is nullptr");
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<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo is null");
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<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo is nullptr");
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<AsyncJSCallbackInfo *>(data);
if (asyncCallbackInfo == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "asyncCallbackInfo is null");
TAG_LOGI(AAFwkTag::JSNAPI, "null asyncCallbackInfo");
return;
}
napi_value result = nullptr;
@ -1217,7 +1217,7 @@ std::vector<std::string> ConvertStringVector(napi_env env, napi_value jsValue)
size_t offset = 0;
NAPI_CALL_BASE(env, napi_get_typedarray_info(env, jsValue, &type, &length, nullptr, &buffer, &offset), {});
if (type != napi_uint8_array) {
TAG_LOGE(AAFwkTag::JSNAPI, "napi_uint8_array is nullptr");
TAG_LOGE(AAFwkTag::JSNAPI, "null napi_uint8_array");
return {};
}
std::string *data = nullptr;

View File

@ -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, "called key=%{public}s", 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, "called key=%{public}s", 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, "remoteObjectIWrap is nullptr");
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, "jsValue is nullptr");
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<AAFwk::IArray> &ao)
{
TAG_LOGD(AAFwkTag::JSNAPI, "called key=%{public}s", 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, "Property name=%{public}s.", 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, "size is invalid, this object is not fd object");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid size, not fd object");
return false;
}
@ -968,7 +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, "value property is invalid, this object is not fd object");
TAG_LOGE(AAFwkTag::JSNAPI, "invalid value property, not fd object");
return false;
}
@ -1004,7 +1004,7 @@ bool HandleRemoteObject(napi_env env, napi_value param, std::string &strProName,
sptr<IRemoteObject> remoteObject = NAPI_ohos_rpc_getNativeRemoteObject(env, jsProValue);
if (remoteObject == nullptr) {
TAG_LOGE(AAFwkTag::JSNAPI, "transfer to remoteObject fail");
TAG_LOGE(AAFwkTag::JSNAPI, "null remoteObject");
return false;
}
@ -1070,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, "Invoke WrapElementName failed");
TAG_LOGI(AAFwkTag::JSNAPI, "null jsElementName");
return nullptr;
}
@ -1119,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, "Params is invalid");
TAG_LOGI(AAFwkTag::JSNAPI, "not napi_object");
return false;
}
@ -1289,7 +1289,7 @@ bool InnerWrapJsWantParamsWantParams(
bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr<AAFwk::IArray> &ao)
{
TAG_LOGI(AAFwkTag::JSNAPI, "called key=%{public}s", key.c_str());
TAG_LOGI(AAFwkTag::JSNAPI, "key=%{public}s", key.c_str());
if (AAFwk::Array::IsStringArray(ao)) {
return InnerWrapWantParamsArray<AAFwk::IString, AAFwk::String, std::string>(
env, object, key, ao);

View File

@ -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);
}

View File

@ -57,7 +57,7 @@ private:
{
TAG_LOGD(AAFwkTag::DIALOG, "argc = %{public}d", static_cast<int32_t>(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<int32_t>(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);
}

View File

@ -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;
}

View File

@ -140,7 +140,7 @@ bool InnerWrapJsWantParamsWantParams(
bool WrapJsWantParamsArray(napi_env env, napi_value object, const std::string &key, sptr<AAFwk::IArray> &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<AAFwk::IString, AAFwk::String, std::string>(
env, object, key, ao);

View File

@ -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<JsParticleAbility>(static_cast<JsParticleAbility*>(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<void **>(&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

View File

@ -98,11 +98,13 @@ napi_value WantConstantInit(napi_env env, napi_value exports)
#ifdef ENABLE_ERRCODE
napi_value params = nullptr;
napi_create_object(env, &params);
#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");

View File

@ -29,10 +29,10 @@ constexpr int32_t DIED = -1;
void AbilityConnection::OnAbilityConnectDone(
const AppExecFwk::ElementName& element, const sptr<IRemoteObject>& 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>& abilityConnectCallback)

View File

@ -23,7 +23,7 @@ void AuthorizationResult::GrantResultsCallback(const std::vector<std::string>& 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);
}
}

View File

@ -215,10 +215,10 @@ void LocalCallContainer::DumpCalls(std::vector<std::string>& 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);

View File

@ -186,8 +186,7 @@ bool LocalCallRecord::IsSameObject(const sptr<IRemoteObject>& 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;
}

View File

@ -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",
]

View File

@ -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<AbilityRuntime::Runtime>& runtime)
@ -163,8 +165,10 @@ void Ability::OnStart(const Want &want, sptr<AAFwk::SessionInfo> sessionInfo)
return;
}
#ifdef WITH_DLP
securityFlag_ = want.GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false);
(const_cast<Want &>(want)).RemoveParam(DLP_PARAMS_SECURITY_FLAG);
#endif // WITH_DLP
SetWant(want);
#ifdef SUPPORT_SCREEN
if (sessionInfo != nullptr) {

View File

@ -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<AbilityInfo> 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<AAFwk::SessionInfo> 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<Rosen::ISession>(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<int32_t>(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<ElementName> AbilityContext::GetElementName()
{
TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::CONTEXT, "called");
std::shared_ptr<AbilityInfo> 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<ElementName> 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<ElementName> AbilityContext::GetCallingAbility()
{
TAG_LOGD(AAFwkTag::CONTEXT, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::CONTEXT, "called");
std::shared_ptr<ElementName> elementName = std::make_shared<ElementName>();
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<AAFwk::IAbility
std::shared_ptr<AbilityInfo> 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<AAFwk::IAbilityConnection>
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
std::shared_ptr<AbilityInfo> 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<AbilityInfo> 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<Global::Resource::ResourceManager> AbilityContext::GetResourceMa
{
std::shared_ptr<Context> 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<Global::Resource::ResourceManager> 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<Global::Resource::ResourceManager> 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<std::string> &permissions,
std::vector<int> &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<std::string> &permis
sptr<IRemoteObject> 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<AAFwk::Want> &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<IRemoteObject> AbilityContext::GetSessionToken()
@ -333,7 +329,7 @@ int32_t AbilityContext::AddFreeInstallObserver(const sptr<AbilityRuntime::IFreeI
{
ErrCode ret = AAFwk::AbilityManagerClient::GetInstance()->AddFreeInstallObserver(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;
}

View File

@ -43,12 +43,10 @@ void AbilityImpl::Init(const std::shared_ptr<OHOSApplication> &application,
const sptr<IRemoteObject> &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<OHOSApplication> &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<AAFwk::SessionInfo> 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<AAFwk::SessionInfo> 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<AAFwk::SessionInfo> 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<IRemoteObject> 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<IRemoteObject> 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<std::string> AbilityImpl::GetFileTypes(const Uri &uri, const std::string &mimeTypeFilter)
@ -419,13 +417,13 @@ int AbilityImpl::BatchInsert(const Uri &uri, const std::vector<NativeRdb::Values
void AbilityImpl::SetUriString(const std::string &uri)
{
TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::ABILITY, "called");
if (ability_ == nullptr) {
TAG_LOGE(AAFwkTag::ABILITY, "AbilityImpl::SetUriString ability_ is nullptr");
return;
}
ability_->SetUriString(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<AbilityPostEventTimeout> 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<int32_t>(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<std::mutex> 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<int32_t>(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<MMI::KeyEvent>& keyEvent)
{
TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::DoKeyDown called");
TAG_LOGD(AAFwkTag::ABILITY, "called");
}
void AbilityImpl::DoKeyUp(const std::shared_ptr<MMI::KeyEvent>& keyEvent)
{
TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::DoKeyUp called");
TAG_LOGD(AAFwkTag::ABILITY, "called");
}
void AbilityImpl::DoPointerEvent(std::shared_ptr<MMI::PointerEvent>& pointerEvent)
{
TAG_LOGD(AAFwkTag::ABILITY, "AbilityImpl::DoPointerEvent called");
TAG_LOGD(AAFwkTag::ABILITY, "called");
}
void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::KeyEvent> keyEvent) const
@ -813,10 +811,10 @@ void AbilityImpl::InputEventConsumerImpl::OnInputEvent(std::shared_ptr<MMI::KeyE
int32_t code = keyEvent->GetKeyAction();
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);
}
}

View File

@ -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<AbilityRuntime::AbilityContext> 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<IRemoteObject> 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_;
}

View File

@ -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);
}

View File

@ -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<JsCallerComplex*>(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<std::mutex> 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<std::mutex> 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;
}

View File

@ -34,7 +34,7 @@ AbilityWindow::~AbilityWindow()
*/
void AbilityWindow::Init(std::shared_ptr<AbilityHandler>& handler, std::shared_ptr<Ability> ability)
{
TAG_LOGD(AAFwkTag::ABILITY, "%{public}s come.", __func__);
TAG_LOGD(AAFwkTag::ABILITY, "called");
handler_ = handler;
ability_ = std::weak_ptr<IAbilityEvent>(ability);
windowScene_ = std::make_shared<Rosen::WindowScene>();
@ -43,7 +43,7 @@ void AbilityWindow::Init(std::shared_ptr<AbilityHandler>& handler, std::shared_p
bool AbilityWindow::InitWindow(std::shared_ptr<AbilityRuntime::AbilityContext> &abilityContext,
sptr<Rosen::IWindowLifeCycle> &listener, int32_t displayId, sptr<Rosen::WindowOption> option, bool isPrivacy)
{
TAG_LOGD(AAFwkTag::ABILITY, "%{public}s begin.", __func__);
TAG_LOGD(AAFwkTag::ABILITY, "called");
if (windowScene_ == nullptr) {
windowScene_ = std::make_shared<Rosen::WindowScene>();
}
@ -55,13 +55,13 @@ bool AbilityWindow::InitWindow(std::shared_ptr<AbilityRuntime::AbilityContext> &
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<AbilityRuntime::AbilityContext> &
}
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<Rosen::Window> 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<Rosen::Window> 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<OHOS::Media::PixelMap> &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.");

View File

@ -326,6 +326,11 @@ std::unique_ptr<AbilityRuntime::Runtime> 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<AppExecFwk::EventRunner> eventRunner =
fromAppSpawn ? AppExecFwk::EventRunner::GetMainEventRunner() : AppExecFwk::EventRunner::Create();
options.eventRunner = eventRunner;

View File

@ -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> 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> 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 "";
}
}

View File

@ -256,7 +256,7 @@ void ExtensionImpl::Stop(bool &isAsyncCallback, const Want &want, sptr<AAFwk::Se
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::AbilityTransactionCallback(const AAFwk::AbilityLifeCycleState &state)
@ -303,7 +303,7 @@ sptr<IRemoteObject> ExtensionImpl::ConnectExtension(const Want &want, bool &isAs
sptr<IRemoteObject> 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<IRemoteObject> &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);
}
}

View File

@ -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);
}

View File

@ -19,18 +19,16 @@ namespace OHOS {
namespace AbilityRuntime {
sptr<InsightIntentHostClient> InsightIntentHostClient::instance_ = nullptr;
std::mutex InsightIntentHostClient::instanceMutex_;
std::once_flag InsightIntentHostClient::singletonFlag_;
sptr<InsightIntentHostClient> InsightIntentHostClient::GetInstance()
{
if (instance_ == nullptr) {
std::lock_guard<std::mutex> lock_l(instanceMutex_);
std::call_once(singletonFlag_, []() {
instance_ = new (std::nothrow) InsightIntentHostClient();
if (instance_ == nullptr) {
instance_ = new (std::nothrow) InsightIntentHostClient();
if (instance_ == nullptr) {
TAG_LOGE(AAFwkTag::INTENT, "failed to create InsightIntentHostClient.");
}
TAG_LOGE(AAFwkTag::INTENT, "failed to create InsightIntentHostClient.");
}
}
});
return instance_;
}

View File

@ -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;

View File

@ -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 <ARGC_TWO) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "OnStartUIServiceExtension failed, not enough params.");
TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
@ -947,7 +947,7 @@ private:
{
TAG_LOGI(AAFwkTag::SERVICE_EXT, "StartExtensionAbilityWithAccount");
if (info.argc < ARGC_TWO) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Stop extension error, not enough params.");
TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}
@ -985,7 +985,7 @@ private:
{
TAG_LOGI(AAFwkTag::SERVICE_EXT, "StopExtensionAbility");
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);
}
@ -1022,7 +1022,7 @@ private:
{
TAG_LOGI(AAFwkTag::SERVICE_EXT, "StopExtensionAbilityWithAccount");
if (info.argc < ARGC_TWO) {
TAG_LOGE(AAFwkTag::SERVICE_EXT, "Stop extension failed, not enough params.");
TAG_LOGE(AAFwkTag::SERVICE_EXT, "invalid argc");
ThrowTooFewParametersError(env);
return CreateJsUndefined(env);
}

View File

@ -49,9 +49,9 @@ static std::string GetSaveAppCachePath(int32_t savedStateId)
}
std::string fileDir = context->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 "";
}
@ -247,6 +247,7 @@ bool AbilityRecovery::ReadSerializeDataFromFile(int32_t savedStateId, WantParams
bool AbilityRecovery::ScheduleSaveAbilityState(StateReason reason)
{
HITRACE_METER_NAME(HITRACE_TAG_ABILITY_MANAGER, __PRETTY_FUNCTION__);
TAG_LOGD(AAFwkTag::RECOVERY, "AppRecovery ScheduleSaveAbilityState.");
if (!isEnable_) {
TAG_LOGE(AAFwkTag::RECOVERY, "AppRecovery not enable");
return false;
@ -276,6 +277,10 @@ bool AbilityRecovery::ScheduleSaveAbilityState(StateReason reason)
return false;
}
abilityMgr->EnableRecoverAbility(token);
if (reason == StateReason::LIFECYCLE && DefaultRecovery()) {
TAG_LOGD(AAFwkTag::RECOVERY, "AppRecovery ScheduleSaveAbilityState SubmitSaveRecoveryInfo");
abilityMgr->SubmitSaveRecoveryInfo(token);
}
}
return ret;
}

View File

@ -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<int32_t> missionIds;
std::vector<MissionValidResult> 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()) {

View File

@ -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<AAFwk::SessionInfo> sessio
return;
}
#ifdef WITH_DLP
securityFlag_ = want.GetBoolParam(DLP_PARAMS_SECURITY_FLAG, false);
(const_cast<AAFwk::Want &>(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

View File

@ -732,7 +732,8 @@ void JsUIExtension::ForegroundWindow(const AAFwk::Want &want, const sptr<AAFwk::
return;
}
std::lock_guard<std::mutex> lock(uiWindowMutex_);
TAG_LOGD(AAFwkTag::UI_EXT, "UIExtension component id: %{public}" PRId64 ".", sessionInfo->uiExtensionComponentId);
TAG_LOGI(AAFwkTag::UI_EXT, "Before window show UIExtcomponent id: %{public}" PRId64,
sessionInfo->uiExtensionComponentId);
auto componentId = sessionInfo->uiExtensionComponentId;
auto& uiWindow = uiWindowMap_[componentId];
if (uiWindow) {
@ -750,13 +751,14 @@ void JsUIExtension::BackgroundWindow(const sptr<AAFwk::SessionInfo> &sessionInfo
return;
}
std::lock_guard<std::mutex> lock(uiWindowMutex_);
TAG_LOGD(AAFwkTag::UI_EXT, "UIExtension component id: %{public}" PRId64 ".", sessionInfo->uiExtensionComponentId);
auto componentId = sessionInfo->uiExtensionComponentId;
if (uiWindowMap_.find(componentId) == uiWindowMap_.end()) {
TAG_LOGE(AAFwkTag::UI_EXT, "Fail to find uiWindow");
return;
}
auto& uiWindow = uiWindowMap_[componentId];
TAG_LOGI(AAFwkTag::UI_EXT, "Befor window hide UIExtcomponent id: %{public}" PRId64,
sessionInfo->uiExtensionComponentId);
if (uiWindow) {
uiWindow->Hide();
foregroundWindows_.erase(componentId);
@ -772,7 +774,6 @@ void JsUIExtension::DestroyWindow(const sptr<AAFwk::SessionInfo> &sessionInfo)
return;
}
std::lock_guard<std::mutex> lock(uiWindowMutex_);
TAG_LOGD(AAFwkTag::UI_EXT, "UIExtension component id: %{public}" PRId64 ".", sessionInfo->uiExtensionComponentId);
auto componentId = sessionInfo->uiExtensionComponentId;
if (uiWindowMap_.find(componentId) == uiWindowMap_.end()) {
TAG_LOGE(AAFwkTag::UI_EXT, "Wrong to find uiWindow");
@ -788,6 +789,8 @@ void JsUIExtension::DestroyWindow(const sptr<AAFwk::SessionInfo> &sessionInfo)
CallObjectMethod("onSessionDestroy", argv, ARGC_ONE);
}
}
TAG_LOGI(AAFwkTag::UI_EXT, "Befor window destory, UIExtcomponent id: %{public}" PRId64,
sessionInfo->uiExtensionComponentId);
auto uiWindow = uiWindowMap_[componentId];
if (uiWindow) {
uiWindow->Destroy();

View File

@ -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, "OnStartAbility is 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, "DisconnectAbility 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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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",
]

View File

@ -665,7 +665,7 @@ std::shared_ptr<ADelegatorAbilityProperty> 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<ADelegatorAbilityProperty> AbilityDelegator::FindPropertyByName(
}
if (name == it->fullName_) {
TAG_LOGI(AAFwkTag::DELEGATOR, "Property exists");
TAG_LOGI(AAFwkTag::DELEGATOR, "Property exist");
return it;
}
}

View File

@ -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;

View File

@ -49,7 +49,7 @@ void ApplicationContext::AttachContextImpl(const std::shared_ptr<ContextImpl> &c
void ApplicationContext::RegisterAbilityLifecycleCallback(
const std::shared_ptr<AbilityLifecycleCallback> &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> &abilityLifecycleCallback)
{
TAG_LOGD(AAFwkTag::APPKIT, "ApplicationContext UnregisterAbilityLifecycleCallback");
TAG_LOGD(AAFwkTag::APPKIT, "called");
std::lock_guard<std::recursive_mutex> 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> &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> &environmentCallback)
{
TAG_LOGD(AAFwkTag::APPKIT, "ApplicationContext UnregisterEnvironmentCallback");
TAG_LOGD(AAFwkTag::APPKIT, "called");
std::lock_guard<std::recursive_mutex> 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<Nati
void ApplicationContext::DispatchWindowStageFocus(const std::shared_ptr<NativeReference> &ability,
const std::shared_ptr<NativeReference> &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<NativeRe
void ApplicationContext::DispatchWindowStageUnfocus(const std::shared_ptr<NativeReference> &ability,
const std::shared_ptr<NativeReference> &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<Na
void ApplicationContext::DispatchOnAbilitySaveState(const std::shared_ptr<NativeReference> &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<NativeReference
void ApplicationContext::DispatchOnAbilityWillCreate(const std::shared_ptr<NativeReference> &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<Nativ
void ApplicationContext::DispatchOnWindowStageWillCreate(const std::shared_ptr<NativeReference> &ability,
const std::shared_ptr<NativeReference> &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<N
void ApplicationContext::DispatchOnWindowStageWillDestroy(const std::shared_ptr<NativeReference> &ability,
const std::shared_ptr<NativeReference> &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<NativeReference> &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<Nati
void ApplicationContext::DispatchOnAbilityWillForeground(const std::shared_ptr<NativeReference> &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<N
void ApplicationContext::DispatchOnAbilityWillBackground(const std::shared_ptr<NativeReference> &ability)
{
TAG_LOGD(AAFwkTag::APPKIT, "%{public}s start.", __func__);
TAG_LOGD(AAFwkTag::APPKIT, "called");
if (!ability) {
TAG_LOGE(AAFwkTag::APPKIT, "ability is null");
return;

View File

@ -291,7 +291,7 @@ void ContextImpl::GetAllTempDir(std::vector<std::string> &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;
}

View File

@ -64,7 +64,7 @@ void AbilityRecordMgr::SetEventRunner(const std::shared_ptr<EventRunner> &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");
}
}

View File

@ -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<UserTestRecord> &
void MainThread::HandleLaunchAbility(const std::shared_ptr<AbilityLocalRecord> &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<AbilityLocalRecord> &
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.";

View File

@ -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;
}

View File

@ -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

View File

@ -31,7 +31,7 @@ public:
bool operator()(std::string baseFileName,
std::string &patchFileName,
void **patchBuffer,
uint8_t **patchBuffer,
size_t &patchSize);
private:

View File

@ -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<AbilityBase::FileMapper> 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<std::string> 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<uint8_t> 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<uint8_t> 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<int32_t>(ret));
return false;
@ -1628,7 +1658,7 @@ void JsRuntime::GetPkgContextInfoListMap(const std::map<std::string, std::string
}
std::ostringstream outStream;
if (!extractor->ExtractByName("pkgContextInfo.json", outStream)) {
TAG_LOGW(AAFwkTag::JSRUNTIME, "moduleName: %{public}s get pkgContextInfo failed", it->first.c_str());
TAG_LOGD(AAFwkTag::JSRUNTIME, "moduleName: %{public}s get pkgContextInfo failed", it->first.c_str());
continue;
}
auto jsonObject = nlohmann::json::parse(outStream.str(), nullptr, false);

View File

@ -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;

View File

@ -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",

View File

@ -1162,6 +1162,13 @@ public:
*/
void EnableRecoverAbility(sptr<IRemoteObject> token);
/**
* @brief Submit save recovery info.
*
* @param token Ability identify.
*/
void SubmitSaveRecoveryInfo(sptr<IRemoteObject> token);
/**
* @brief Schedule recovery ability.
*
@ -1550,7 +1557,9 @@ private:
sptr<IAbilityManager> GetAbilityManager();
void ResetProxy(wptr<IRemoteObject> remote);
#ifdef WITH_DLP
void HandleDlpApp(Want &want);
#endif // WITH_DLP
static std::once_flag singletonFlag_;
std::recursive_mutex mutex_;

View File

@ -1161,6 +1161,7 @@ public:
}
virtual void EnableRecoverAbility(const sptr<IRemoteObject>& token) {};
virtual void SubmitSaveRecoveryInfo(const sptr<IRemoteObject>& token) {};
virtual void ScheduleRecoverAbility(const sptr<IRemoteObject> &token, int32_t reason,
const Want *want = nullptr) {};

View File

@ -485,6 +485,8 @@ enum class AbilityManagerInterfaceCode {
CLEAR_RECOVERY_PAGE_STACK = 3014,
ABILITY_RECOVERY_SUBMITINFO = 3015,
ACQUIRE_SHARE_DATA = 4001,
SHARE_DATA_DONE = 4002,

View File

@ -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",

View File

@ -45,6 +45,9 @@ void AppMgrProxy::AttachApplication(const sptr<IRemoteObject> &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);

View File

@ -343,6 +343,9 @@ int32_t AppMgrStub::HandleAttachApplication(MessageParcel &data, MessageParcel &
{
HITRACE_METER(HITRACE_TAG_APP);
sptr<IRemoteObject> client = data.ReadRemoteObject();
if (client == nullptr) {
TAG_LOGE(AAFwkTag::APPMGR, "remote object null");
}
AttachApplication(client);
return NO_ERROR;
}

View File

@ -20,7 +20,9 @@
#include <unordered_set>
#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<ConnectionObserver> &observer);
int32_t UnregisterObserver(const std::shared_ptr<ConnectionObserver> &observer);
int32_t GetDlpConnectionInfos(std::vector<DlpConnectionInfo> &infos);
int32_t GetConnectionData(std::vector<ConnectionData> &infos);
void HandleExtensionConnected(const ConnectionData &data);
void HandleExtensionDisconnected(const ConnectionData &data);
void HandleRemoteDied(const wptr<IRemoteObject> &remote);
#ifdef WITH_DLP
int32_t GetDlpConnectionInfos(std::vector<DlpConnectionInfo> &infos);
void HandleDlpAbilityOpened(const DlpStateData &data);
void HandleDlpAbilityClosed(const DlpStateData &data);
void HandleRemoteDied(const wptr<IRemoteObject> &remote);
#endif // WITH_DLP
private:
class ServiceDeathRecipient : public IRemoteObject::DeathRecipient {

View File

@ -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<ConnectionObserverProxy> delegator_;

View File

@ -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

View File

@ -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<ConnectionObserverClientImpl> owner_;

View File

@ -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

View File

@ -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<IConnectionObserver> &observer);
#ifdef WITH_DLP
int32_t GetDlpConnectionInfos(std::vector<DlpConnectionInfo> &infos);
#endif // WITH_DLP
int32_t GetConnectionData(std::vector<ConnectionData> &infos);

View File

@ -54,12 +54,16 @@ int32_t ConnectionObserverClient::UnregisterObserver(const std::shared_ptr<Conne
int32_t ConnectionObserverClient::GetDlpConnectionInfos(std::vector<DlpConnectionInfo> &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> &connectionData)

View File

@ -59,6 +59,7 @@ int32_t ConnectionObserverClientImpl::UnregisterObserver(const std::shared_ptr<C
return ret;
}
#ifdef WITH_DLP
int32_t ConnectionObserverClientImpl::GetDlpConnectionInfos(std::vector<DlpConnectionInfo> &infos)
{
auto proxy = GetServiceProxy();
@ -69,6 +70,7 @@ int32_t ConnectionObserverClientImpl::GetDlpConnectionInfos(std::vector<DlpConne
return proxy->GetDlpConnectionInfos(infos);
}
#endif // WITH_DLP
int32_t ConnectionObserverClientImpl::GetConnectionData(std::vector<ConnectionData> &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<ServiceProxyAdapter> &proxy)
{

View File

@ -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)

Some files were not shown because too many files have changed in this diff Show More