delegator日志整改

Signed-off-by: songjindian <songjindian1@huawei.com>
This commit is contained in:
songjindian 2024-08-01 11:15:35 +08:00
parent 5392d2d36e
commit 2f7a8edd1d
13 changed files with 190 additions and 218 deletions

View File

@ -43,7 +43,7 @@ std::shared_ptr<AbilityRuntime::ApplicationContext> CJAbilityDelegator::GetAppCo
{
auto context = delegator_->GetAppContext();
if (context == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "Failed to get AppContext from cj delegator.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null context");
return nullptr;
}
return context->GetApplicationContext();
@ -74,7 +74,7 @@ int64_t FFIAbilityDelegatorRegistryGetAbilityDelegator()
{
auto delegator = OHOS::AppExecFwk::AbilityDelegatorRegistry::GetAbilityDelegator();
if (delegator == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "delegator is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegator");
return INVALID_CODE;
}
auto cjDelegator = FFI::FFIData::Create<CJAbilityDelegator>(delegator);
@ -85,7 +85,7 @@ int32_t FFIAbilityDelegatorStartAbility(int64_t id, WantHandle want)
{
auto cjDelegator = FFI::FFIData::GetData<CJAbilityDelegator>(id);
if (cjDelegator == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj delegator is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegator");
return INVALID_CODE;
}
auto actualWant = reinterpret_cast<AAFwk::Want*>(want);
@ -96,7 +96,7 @@ int32_t FFIAbilityDelegatorExecuteShellCommand(int64_t id, const char* cmd, int6
{
auto cjDelegator = FFI::FFIData::GetData<CJAbilityDelegator>(id);
if (cjDelegator == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj delegator is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegator");
return INVALID_CODE;
}
auto cJShellCmdResult = FFI::FFIData::Create<CJShellCmdResult>(cjDelegator->ExecuteShellCommand(cmd, timeoutSec));
@ -107,7 +107,7 @@ int32_t FFIGetExitCode(int64_t id)
{
auto cjShellCmdResult = FFI::FFIData::GetData<CJShellCmdResult>(id);
if (cjShellCmdResult == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj shell command result is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj shellcommand result");
return INVALID_CODE;
}
return cjShellCmdResult->GetExitCode();
@ -117,7 +117,7 @@ const char* FFIGetStdResult(int64_t id)
{
auto cjShellCmdResult = FFI::FFIData::GetData<CJShellCmdResult>(id);
if (cjShellCmdResult == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj shell command result is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj shellcommand result");
return nullptr;
}
const char* res = CreateCStringFromString(cjShellCmdResult->GetStdResult());
@ -128,7 +128,7 @@ const char* FFIDump(int64_t id)
{
auto cjShellCmdResult = FFI::FFIData::GetData<CJShellCmdResult>(id);
if (cjShellCmdResult == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj shell command result is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj shellcommand result");
return nullptr;
}
const char* dump = CreateCStringFromString(cjShellCmdResult->Dump());
@ -139,12 +139,12 @@ int32_t FFIAbilityDelegatorApplicationContext(int64_t id)
{
auto cjDelegator = FFI::FFIData::GetData<CJAbilityDelegator>(id);
if (cjDelegator == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj delegator is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegator");
return INVALID_CODE;
}
auto appContext = FFI::FFIData::Create<ApplicationContextCJ::CJApplicationContext>(cjDelegator->GetAppContext());
if (appContext == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "app context is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null app context");
return INVALID_CODE;
}
return appContext->GetID();
@ -154,7 +154,7 @@ void FFIAbilityDelegatorFinishTest(int64_t id, const char* msg, int64_t code)
{
auto cjDelegator = FFI::FFIData::GetData<CJAbilityDelegator>(id);
if (cjDelegator == nullptr) {
TAG_LOGE(AAFwkTag::CONTEXT, "cj delegator is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cj delegator");
}
cjDelegator->FinishTest(msg, code);
}

View File

@ -41,8 +41,6 @@ void AbilityMonitor::OnAbilityStart(const std::weak_ptr<NativeReference> &abilit
}
jsMonitor_->OnAbilityCreate(abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnAbilityForeground(const std::weak_ptr<NativeReference> &abilityObj)
@ -54,8 +52,6 @@ void AbilityMonitor::OnAbilityForeground(const std::weak_ptr<NativeReference> &a
}
jsMonitor_->OnAbilityForeground(abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnAbilityBackground(const std::weak_ptr<NativeReference> &abilityObj)
@ -67,8 +63,6 @@ void AbilityMonitor::OnAbilityBackground(const std::weak_ptr<NativeReference> &a
}
jsMonitor_->OnAbilityBackground(abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnAbilityStop(const std::weak_ptr<NativeReference> &abilityObj)
@ -80,8 +74,6 @@ void AbilityMonitor::OnAbilityStop(const std::weak_ptr<NativeReference> &ability
}
jsMonitor_->OnAbilityDestroy(abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnWindowStageCreate(const std::weak_ptr<NativeReference> &abilityObj)
@ -94,8 +86,6 @@ void AbilityMonitor::OnWindowStageCreate(const std::weak_ptr<NativeReference> &a
}
jsMonitor_->OnWindowStageCreate(abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnWindowStageRestore(const std::weak_ptr<NativeReference> &abilityObj)
@ -107,8 +97,6 @@ void AbilityMonitor::OnWindowStageRestore(const std::weak_ptr<NativeReference> &
}
jsMonitor_->OnWindowStageRestore(abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void AbilityMonitor::OnWindowStageDestroy(const std::weak_ptr<NativeReference> &abilityObj)
@ -120,8 +108,6 @@ void AbilityMonitor::OnWindowStageDestroy(const std::weak_ptr<NativeReference> &
}
jsMonitor_->OnWindowStageDestroy(abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
} // namespace AbilityDelegatorJs
} // namespace OHOS

View File

@ -258,7 +258,7 @@ napi_value JSAbilityDelegator::OnAddAbilityMonitor(napi_env env, NapiCallbackInf
std::shared_ptr<AbilityMonitor> monitor = nullptr;
if (!ParseAbilityMonitorPara(env, info, monitor, false)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse param monitor failed, monitor must be Monitor.");
}
@ -287,7 +287,7 @@ napi_value JSAbilityDelegator::OnAddAbilityMonitorSync(napi_env env, NapiCallbac
std::shared_ptr<AbilityMonitor> monitor = nullptr;
if (!ParseAbilityMonitorPara(env, info, monitor, true)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse param monitor failed, monitor must be Monitor.");
}
@ -307,7 +307,7 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitor(napi_env env, NapiCallba
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> monitor = nullptr;
if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, false)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse parameters failed, monitor must be Monitor and isExited must be boolean.");
}
@ -341,7 +341,7 @@ napi_value JSAbilityDelegator::OnAddAbilityStageMonitorSync(napi_env env, NapiCa
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> monitor = nullptr;
if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, true)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse param monitor failed, monitor must be Monitor.");
}
@ -363,7 +363,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityMonitor(napi_env env, NapiCallback
std::shared_ptr<AbilityMonitor> monitor = nullptr;
if (!ParseAbilityMonitorPara(env, info, monitor, false)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse monitor failed, removeAbilityMonitor must be Monitor.");
}
@ -407,7 +407,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityMonitorSync(napi_env env, NapiCall
std::shared_ptr<AbilityMonitor> monitor = nullptr;
if (!ParseAbilityMonitorPara(env, info, monitor, true)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse monitor failed, removeAbilityMonitor must be Monitor.");
}
@ -436,7 +436,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitor(napi_env env, NapiCal
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> monitor = nullptr;
if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, false)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse monitor failed, removeAbilityMonitor must be Monitor.");
}
@ -472,7 +472,7 @@ napi_value JSAbilityDelegator::OnRemoveAbilityStageMonitorSync(napi_env env, Nap
bool isExisted = false;
std::shared_ptr<AbilityStageMonitor> monitor = nullptr;
if (!ParseAbilityStageMonitorPara(env, info, monitor, isExisted, true)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityStageMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse monitor failed, removeAbilityMonitor must be Monitor.");
}
@ -497,7 +497,7 @@ napi_value JSAbilityDelegator::OnWaitAbilityMonitor(napi_env env, NapiCallbackIn
TimeoutCallback opt {false, false};
int64_t timeout = 0;
if (!ParseWaitAbilityMonitorPara(env, info, monitor, opt, timeout)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse waitAbilityMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse monitor want failed, removeAbilityMonitor must be Monitor.");
}
@ -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, "complete called");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (abilityObjectBox && !abilityObjectBox->object_.expired()) {
ResolveWithNoError(env, task, abilityObjectBox->object_.lock()->GetNapiValue());
} else {
@ -557,7 +557,7 @@ napi_value JSAbilityDelegator::OnWaitAbilityStageMonitor(napi_env env, NapiCallb
TimeoutCallback opt {false, false};
int64_t timeout = 0;
if (!ParseWaitAbilityStageMonitorPara(env, info, monitor, opt, timeout)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse waitAbilityStageMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse monitor failed, removeAbilityMonitor must be Monitor.");
}
@ -578,7 +578,7 @@ napi_value JSAbilityDelegator::OnWaitAbilityStageMonitor(napi_env env, NapiCallb
result = opt.hasTimeoutPara ?
delegator->WaitAbilityStageMonitor(monitor, timeout) : delegator->WaitAbilityStageMonitor(monitor);
if (!result || result->object_.expired()) {
TAG_LOGE(AAFwkTag::DELEGATOR, "WaitAbilityStageMonitor failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "waitAbilityStageMonitor failed");
return;
}
abilityStageObjBox->object_ = result->object_;
@ -608,7 +608,7 @@ napi_value JSAbilityDelegator::OnPrint(napi_env env, NapiCallbackInfo& info)
std::string msg;
if (!ParsePrintPara(env, info, msg)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse print param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse parameters msg failed, msg must be string.");
}
@ -637,7 +637,7 @@ napi_value JSAbilityDelegator::OnPrintSync(napi_env env, NapiCallbackInfo& info)
std::string msg;
if (!ParsePrintPara(env, info, msg)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse print param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse msg failed, msg must be string.");
}
@ -660,7 +660,7 @@ napi_value JSAbilityDelegator::OnExecuteShellCommand(napi_env env, NapiCallbackI
TimeoutCallback opt {false, false};
int64_t timeoutSecs = 0;
if (!ParseExecuteShellCommandPara(env, info, cmd, opt, timeoutSecs)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse executeShellCommand param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse parameters failed, cmd must be string and timeout must be number.");
}
@ -749,7 +749,7 @@ napi_value JSAbilityDelegator::OnGetAbilityState(napi_env env, NapiCallbackInfo&
sptr<OHOS::IRemoteObject> remoteObject = nullptr;
if (!ParseAbilityPara(env, info.argv[INDEX_ZERO], remoteObject)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse ability param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return CreateJsUndefined(env);
}
@ -769,7 +769,7 @@ napi_value JSAbilityDelegator::OnGetCurrentTopAbility(napi_env env, NapiCallback
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 callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS, "Parse callback failed, callback must be function");
}
@ -841,7 +841,7 @@ napi_value JSAbilityDelegator::OnDoAbilityForeground(napi_env env, NapiCallbackI
sptr<OHOS::IRemoteObject> remoteObject = nullptr;
if (!ParseAbilityCommonPara(env, info, remoteObject)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityCommon param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse remoteObject failed, remoteObject must be RemoteObject.");
}
@ -873,7 +873,7 @@ napi_value JSAbilityDelegator::OnDoAbilityBackground(napi_env env, NapiCallbackI
sptr<OHOS::IRemoteObject> remoteObject = nullptr;
if (!ParseAbilityCommonPara(env, info, remoteObject)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse abilityCommon param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse remoteObject failed, remoteObject must be RemoteObject.");
}
@ -906,7 +906,7 @@ napi_value JSAbilityDelegator::OnFinishTest(napi_env env, NapiCallbackInfo& info
std::string msg;
int64_t code = 0;
if (!ParseFinishTestPara(env, info, msg, code)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse finishTest param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse parameters failed, msg must be string and code must be number.");
}
@ -934,7 +934,7 @@ napi_value JSAbilityDelegator::OnSetMockList(napi_env env, NapiCallbackInfo& inf
std::map<std::string, std::string> mockList;
if (!ParseMockListPara(env, info, mockList)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse mockList param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return ThrowJsError(env, INCORRECT_PARAMETERS,
"Parse mockList failed, mockList must be MockList.");
}
@ -1132,7 +1132,7 @@ napi_value JSAbilityDelegator::ParseAbilityMonitorPara(
}
if (!ParseMonitorPara(env, info.argv[INDEX_ZERO], monitor)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse monitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
@ -1159,7 +1159,7 @@ napi_value JSAbilityDelegator::ParseAbilityStageMonitorPara(napi_env env, NapiCa
}
if (!ParseStageMonitorPara(env, info.argv[INDEX_ZERO], monitor, isExisted)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse stage monitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
@ -1169,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, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid callback ");
return nullptr;
}
}
@ -1186,12 +1186,12 @@ napi_value JSAbilityDelegator::ParseWaitAbilityMonitorPara(napi_env env, NapiCal
}
if (!ParseMonitorPara(env, info.argv[INDEX_ZERO], monitor)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "monitor parse param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
if (!ParseTimeoutCallbackPara(env, info, opt, timeout)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid callback");
return nullptr;
}
return CreateJsNull(env);
@ -1208,11 +1208,11 @@ napi_value JSAbilityDelegator::ParseWaitAbilityStageMonitorPara(napi_env env, Na
bool isExisted = false;
if (!ParseStageMonitorPara(env, info.argv[INDEX_ZERO], monitor, isExisted)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse stageMonitor param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
if (!ParseTimeoutCallbackPara(env, info, opt, timeout)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid calback");
return nullptr;
}
if (!isExisted) {
@ -1224,7 +1224,7 @@ napi_value JSAbilityDelegator::ParseWaitAbilityStageMonitorPara(napi_env env, Na
napi_value JSAbilityDelegator::ParseTimeoutCallbackPara(
napi_env env, NapiCallbackInfo& info, TimeoutCallback &opt, int64_t &timeout)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
opt.hasCallbackPara = false;
opt.hasTimeoutPara = false;
@ -1266,13 +1266,13 @@ napi_value JSAbilityDelegator::ParsePrintPara(napi_env env, NapiCallbackInfo& in
}
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], msg)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "convert msg failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
if (info.argc > ARGC_ONE) {
if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid callback");
return nullptr;
}
}
@ -1282,18 +1282,18 @@ napi_value JSAbilityDelegator::ParsePrintPara(napi_env env, NapiCallbackInfo& in
napi_value JSAbilityDelegator::ParseExecuteShellCommandPara(
napi_env env, NapiCallbackInfo& info, std::string &cmd, TimeoutCallback &opt, int64_t &timeout)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (info.argc < ARGC_ONE) {
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc");
return nullptr;
}
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], cmd)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "convert cmd failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
if (!ParseTimeoutCallbackPara(env, info, opt, timeout)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid callback");
return nullptr;
}
return CreateJsNull(env);
@ -1302,20 +1302,20 @@ napi_value JSAbilityDelegator::ParseExecuteShellCommandPara(
napi_value JSAbilityDelegator::ParseAbilityCommonPara(
napi_env env, NapiCallbackInfo& info, sptr<OHOS::IRemoteObject> &remoteObject)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (info.argc < ARGC_ONE) {
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc");
return nullptr;
}
if (!ParseAbilityPara(env, info.argv[INDEX_ZERO], remoteObject)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse ability param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
if (info.argc > ARGC_ONE) {
if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid callbacl");
return nullptr;
}
}
@ -1325,20 +1325,20 @@ napi_value JSAbilityDelegator::ParseAbilityCommonPara(
napi_value JSAbilityDelegator::ParseStartAbilityPara(
napi_env env, NapiCallbackInfo& info, AAFwk::Want &want)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (info.argc < ARGC_ONE) {
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc");
return nullptr;
}
if (!OHOS::AppExecFwk::UnwrapWant(env, info.argv[INDEX_ZERO], want)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse want param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid params");
return nullptr;
}
if (info.argc > ARGC_ONE) {
if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_ONE], napi_function)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid callback");
return nullptr;
}
}
@ -1348,25 +1348,25 @@ napi_value JSAbilityDelegator::ParseStartAbilityPara(
napi_value JSAbilityDelegator::ParseFinishTestPara(
napi_env env, NapiCallbackInfo& info, std::string &msg, int64_t &code)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (info.argc < ARGC_TWO) {
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid argc");
return nullptr;
}
if (!ConvertFromJsValue(env, info.argv[INDEX_ZERO], msg)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "convert msg failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid msg");
return nullptr;
}
if (!ConvertFromJsValue(env, info.argv[INDEX_ONE], code)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "convert code failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid code");
return nullptr;
}
if (info.argc > ARGC_TWO) {
if (!AppExecFwk::IsTypeForNapiValue(env, info.argv[INDEX_TWO], napi_function)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "parse callback param failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid callback");
return nullptr;
}
}
@ -1397,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, "parse propNames failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid propNames");
return false;
}

View File

@ -33,55 +33,47 @@ void JSAbilityMonitor::OnAbilityCreate(const std::weak_ptr<NativeReference> &abi
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
CallLifecycleCBFunction("onAbilityCreate", abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void JSAbilityMonitor::OnAbilityForeground(const std::weak_ptr<NativeReference> &abilityObj)
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
CallLifecycleCBFunction("onAbilityForeground", abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void JSAbilityMonitor::OnAbilityBackground(const std::weak_ptr<NativeReference> &abilityObj)
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
CallLifecycleCBFunction("onAbilityBackground", abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void JSAbilityMonitor::OnAbilityDestroy(const std::weak_ptr<NativeReference> &abilityObj)
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
CallLifecycleCBFunction("onAbilityDestroy", abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void JSAbilityMonitor::OnWindowStageCreate(const std::weak_ptr<NativeReference> &abilityObj)
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
CallLifecycleCBFunction("onWindowStageCreate", abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void JSAbilityMonitor::OnWindowStageRestore(const std::weak_ptr<NativeReference> &abilityObj)
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
CallLifecycleCBFunction("onWindowStageRestore", abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void JSAbilityMonitor::OnWindowStageDestroy(const std::weak_ptr<NativeReference> &abilityObj)
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
CallLifecycleCBFunction("onWindowStageDestroy", abilityObj);
TAG_LOGD(AAFwkTag::DELEGATOR, "end");
}
void JSAbilityMonitor::SetJsAbilityMonitor(napi_value jsAbilityMonitor)
{
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
napi_ref ref = nullptr;
napi_create_reference(env_, jsAbilityMonitor, 1, &ref);
jsAbilityMonitor_ = std::unique_ptr<NativeReference>(reinterpret_cast<NativeReference*>(ref));

View File

@ -554,7 +554,7 @@ void GetDisplayOrientationExecuteCallback(napi_env env, void *data)
bool UnwrapParamGetDisplayOrientationWrap(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 = 1;
if (argc > argcMax || argc < argcMax - 1) {
TAG_LOGE(AAFwkTag::JSNAPI, "invalid argc");

View File

@ -34,14 +34,14 @@ AbilityDelegator::~AbilityDelegator()
void AbilityDelegator::AddAbilityMonitor(const std::shared_ptr<IAbilityMonitor> &monitor)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
std::unique_lock<std::mutex> lck(mutexMonitor_);
auto pos = std::find(abilityMonitors_.begin(), abilityMonitors_.end(), monitor);
if (pos != abilityMonitors_.end()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Monitor has been added");
TAG_LOGW(AAFwkTag::DELEGATOR, "monitor has been added");
return;
}
@ -51,13 +51,13 @@ void AbilityDelegator::AddAbilityMonitor(const std::shared_ptr<IAbilityMonitor>
void AbilityDelegator::AddAbilityStageMonitor(const std::shared_ptr<IAbilityStageMonitor> &monitor)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
std::unique_lock<std::mutex> lck(mutexStageMonitor_);
auto pos = std::find(abilityStageMonitors_.begin(), abilityStageMonitors_.end(), monitor);
if (pos != abilityStageMonitors_.end()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Stage monitor has been added");
TAG_LOGW(AAFwkTag::DELEGATOR, "stage monitor added");
return;
}
abilityStageMonitors_.emplace_back(monitor);
@ -66,7 +66,7 @@ void AbilityDelegator::AddAbilityStageMonitor(const std::shared_ptr<IAbilityStag
void AbilityDelegator::RemoveAbilityMonitor(const std::shared_ptr<IAbilityMonitor> &monitor)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -80,7 +80,7 @@ void AbilityDelegator::RemoveAbilityMonitor(const std::shared_ptr<IAbilityMonito
void AbilityDelegator::RemoveAbilityStageMonitor(const std::shared_ptr<IAbilityStageMonitor> &monitor)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
std::unique_lock<std::mutex> lck(mutexStageMonitor_);
@ -113,7 +113,7 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::WaitAbilityMonitor(
const std::shared_ptr<IAbilityMonitor> &monitor)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return {};
}
@ -121,7 +121,7 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::WaitAbilityMonitor(
auto obtainedAbility = monitor->WaitForAbility();
if (!obtainedAbility) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid obtained ability");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid obtained ability");
return {};
}
@ -132,14 +132,14 @@ std::shared_ptr<DelegatorAbilityStageProperty> AbilityDelegator::WaitAbilityStag
const std::shared_ptr<IAbilityStageMonitor> &monitor)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid monitor for waiting abilityStage");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid monitor");
return nullptr;
}
AddAbilityStageMonitor(monitor);
auto stage = monitor->WaitForAbilityStage();
if (!stage) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid obtained abilityStage");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid abilityStage");
return nullptr;
}
return stage;
@ -149,7 +149,7 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::WaitAbilityMonitor(
const std::shared_ptr<IAbilityMonitor> &monitor, const int64_t timeoutMs)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return {};
}
@ -157,7 +157,7 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::WaitAbilityMonitor(
auto obtainedAbility = monitor->WaitForAbility(timeoutMs);
if (!obtainedAbility) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid obtained ability");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid obtained ability");
return {};
}
@ -168,13 +168,13 @@ std::shared_ptr<DelegatorAbilityStageProperty> AbilityDelegator::WaitAbilityStag
const std::shared_ptr<IAbilityStageMonitor> &monitor, const int64_t timeoutMs)
{
if (!monitor) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid monitor for waiting abilityStage with timeout");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid monitor");
return nullptr;
}
AddAbilityStageMonitor(monitor);
auto stage = monitor->WaitForAbilityStage(timeoutMs);
if (!stage) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid obtained abilityStage");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid obtained abilityStage");
return nullptr;
}
return stage;
@ -188,14 +188,14 @@ std::shared_ptr<AbilityRuntime::Context> AbilityDelegator::GetAppContext() const
AbilityDelegator::AbilityState AbilityDelegator::GetAbilityState(const sptr<IRemoteObject> &token)
{
if (!token) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return AbilityDelegator::AbilityState::UNINITIALIZED;
}
std::unique_lock<std::mutex> lck(mutexAbilityProperties_);
auto existedProperty = FindPropertyByToken(token);
if (!existedProperty) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Unknown ability token");
TAG_LOGW(AAFwkTag::DELEGATOR, "unknown ability token");
return AbilityDelegator::AbilityState::UNINITIALIZED;
}
@ -208,7 +208,7 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::GetCurrentTopAbilit
std::string bundleName = elementName.GetBundleName();
std::string abilityName = elementName.GetAbilityName();
if (abilityName.empty()) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get top ability");
TAG_LOGE(AAFwkTag::DELEGATOR, "get topAbility failed");
return {};
}
@ -222,7 +222,7 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::GetCurrentTopAbilit
std::unique_lock<std::mutex> lck(mutexAbilityProperties_);
auto existedProperty = FindPropertyByName(abilityName);
if (!existedProperty) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Unknown ability name");
TAG_LOGW(AAFwkTag::DELEGATOR, "unknown ability name");
return {};
}
@ -238,24 +238,24 @@ void AbilityDelegator::Prepare()
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
if (!testRunner_) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid TestRunner");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid TestRunner");
return;
}
TAG_LOGI(AAFwkTag::DELEGATOR, "Call TestRunner::Prepare()");
TAG_LOGD(AAFwkTag::DELEGATOR, "call js onPrepare()");
testRunner_->Prepare();
if (!delegatorThread_) {
delegatorThread_ = std::make_unique<DelegatorThread>(true);
if (!delegatorThread_) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Create delegatorThread failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "create delegatorThread failed");
return;
}
}
auto runTask = [this]() { this->OnRun(); };
if (!delegatorThread_->Run(runTask)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Run task on delegatorThread failed");
TAG_LOGE(AAFwkTag::DELEGATOR, "run task on delegatorThread failed");
}
}
@ -263,13 +263,12 @@ void AbilityDelegator::OnRun()
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
if (!testRunner_) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid TestRunner");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid TestRunner");
return;
}
TAG_LOGI(AAFwkTag::DELEGATOR, "Call TestRunner::Run(), Start run");
TAG_LOGD(AAFwkTag::DELEGATOR, "call js onRun()");
testRunner_->Run();
TAG_LOGI(AAFwkTag::DELEGATOR, "Run finished");
}
ErrCode AbilityDelegator::StartAbility(const AAFwk::Want &want)
@ -279,7 +278,7 @@ ErrCode AbilityDelegator::StartAbility(const AAFwk::Want &want)
auto realWant(want);
auto delegatorArgs = AbilityDelegatorRegistry::GetArguments();
if (delegatorArgs && delegatorArgs->FindDebugFlag()) {
TAG_LOGI(AAFwkTag::DELEGATOR, "Set Debug to the want which used for starting the ability");
TAG_LOGI(AAFwkTag::DELEGATOR, "start with debug");
realWant.SetParam("debugApp", true);
}
realWant.SetParam(IS_DELEGATOR_CALL, true);
@ -289,16 +288,16 @@ ErrCode AbilityDelegator::StartAbility(const AAFwk::Want &want)
bool AbilityDelegator::DoAbilityForeground(const sptr<IRemoteObject> &token)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!token) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return false;
}
auto ret = AAFwk::AbilityManagerClient::GetInstance()->DelegatorDoAbilityForeground(token);
if (ret) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to call DelegatorDoAbilityForeground, reson : %{public}d", ret);
TAG_LOGE(AAFwkTag::DELEGATOR, "call DelegatorDoAbilityForeground failed, reson: %{public}d", ret);
return false;
}
@ -310,13 +309,13 @@ bool AbilityDelegator::DoAbilityBackground(const sptr<IRemoteObject> &token)
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
if (!token) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return false;
}
auto ret = AAFwk::AbilityManagerClient::GetInstance()->DelegatorDoAbilityBackground(token);
if (ret) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to call DelegatorDoAbilityBackground, reson : %{public}d", ret);
TAG_LOGE(AAFwkTag::DELEGATOR, "call doAbilityBackground failed, reson: %{public}d", ret);
return false;
}
@ -328,13 +327,13 @@ std::unique_ptr<ShellCmdResult> AbilityDelegator::ExecuteShellCommand(const std:
TAG_LOGI(AAFwkTag::DELEGATOR, "command : %{public}s, timeout : %{public}" PRId64, cmd.data(), timeoutSec);
if (cmd.empty()) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid cmd");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid cmd");
return {};
}
auto testObserver = iface_cast<ITestObserver>(observer_);
if (!testObserver) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid testObserver");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid testObserver");
return {};
}
@ -348,13 +347,13 @@ void AbilityDelegator::Print(const std::string &msg)
auto testObserver = iface_cast<ITestObserver>(observer_);
if (!testObserver) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid testObserver");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid testObserver");
return;
}
auto realMsg(msg);
if (realMsg.length() > DELEGATOR_PRINT_MAX_LENGTH) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Too long message");
TAG_LOGW(AAFwkTag::DELEGATOR, "too long message");
realMsg.resize(DELEGATOR_PRINT_MAX_LENGTH);
}
TAG_LOGI(AAFwkTag::DELEGATOR, "message to print : %{public}s", realMsg.data());
@ -364,10 +363,10 @@ void AbilityDelegator::Print(const std::string &msg)
void AbilityDelegator::PostPerformStart(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -375,7 +374,7 @@ void AbilityDelegator::PostPerformStart(const std::shared_ptr<ADelegatorAbilityP
std::unique_lock<std::mutex> lck(mutexMonitor_);
if (abilityMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Empty abilityMonitors");
TAG_LOGW(AAFwkTag::DELEGATOR, "empty abilityMonitors");
return;
}
@ -392,15 +391,15 @@ void AbilityDelegator::PostPerformStart(const std::shared_ptr<ADelegatorAbilityP
void AbilityDelegator::PostPerformStageStart(const std::shared_ptr<DelegatorAbilityStageProperty> &abilityStage)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!abilityStage) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
std::unique_lock<std::mutex> lck(mutexStageMonitor_);
if (abilityStageMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Empty abilityStageMonitors");
TAG_LOGW(AAFwkTag::DELEGATOR, "null abilityStageMonitors");
return;
}
@ -414,10 +413,10 @@ void AbilityDelegator::PostPerformStageStart(const std::shared_ptr<DelegatorAbil
void AbilityDelegator::PostPerformScenceCreated(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -425,7 +424,7 @@ void AbilityDelegator::PostPerformScenceCreated(const std::shared_ptr<ADelegator
std::unique_lock<std::mutex> lck(mutexMonitor_);
if (abilityMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Empty abilityMonitors.");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid abilityMonitors");
return;
}
@ -442,10 +441,10 @@ void AbilityDelegator::PostPerformScenceCreated(const std::shared_ptr<ADelegator
void AbilityDelegator::PostPerformScenceRestored(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -453,7 +452,7 @@ void AbilityDelegator::PostPerformScenceRestored(const std::shared_ptr<ADelegato
std::unique_lock<std::mutex> lck(mutexMonitor_);
if (abilityMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "abilityMonitors is Empty");
TAG_LOGW(AAFwkTag::DELEGATOR, "null abilityMonitors");
return;
}
@ -470,10 +469,10 @@ void AbilityDelegator::PostPerformScenceRestored(const std::shared_ptr<ADelegato
void AbilityDelegator::PostPerformScenceDestroyed(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -481,7 +480,7 @@ void AbilityDelegator::PostPerformScenceDestroyed(const std::shared_ptr<ADelegat
std::unique_lock<std::mutex> lck(mutexMonitor_);
if (abilityMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "abilityMonitors is empty");
TAG_LOGW(AAFwkTag::DELEGATOR, "null abilityMonitors");
return;
}
@ -498,10 +497,10 @@ void AbilityDelegator::PostPerformScenceDestroyed(const std::shared_ptr<ADelegat
void AbilityDelegator::PostPerformForeground(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -509,7 +508,7 @@ void AbilityDelegator::PostPerformForeground(const std::shared_ptr<ADelegatorAbi
std::unique_lock<std::mutex> lck(mutexMonitor_);
if (abilityMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "abilityMonitors is Empty.");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid abilityMonitors");
return;
}
@ -526,10 +525,10 @@ void AbilityDelegator::PostPerformForeground(const std::shared_ptr<ADelegatorAbi
void AbilityDelegator::PostPerformBackground(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -537,7 +536,7 @@ void AbilityDelegator::PostPerformBackground(const std::shared_ptr<ADelegatorAbi
std::unique_lock<std::mutex> lck(mutexMonitor_);
if (abilityMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "abilityMonitors is empty.");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid abilityMonitors");
return;
}
@ -557,7 +556,7 @@ void AbilityDelegator::PostPerformStop(const std::shared_ptr<ADelegatorAbilityPr
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return;
}
@ -565,7 +564,7 @@ void AbilityDelegator::PostPerformStop(const std::shared_ptr<ADelegatorAbilityPr
std::unique_lock<std::mutex> lck(mutexMonitor_);
if (abilityMonitors_.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Empty abilityMonitors");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid abilityMonitors");
return;
}
@ -613,7 +612,7 @@ void AbilityDelegator::ProcessAbilityProperties(const std::shared_ptr<ADelegator
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid ability property");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid ability property");
return;
}
@ -633,10 +632,10 @@ void AbilityDelegator::ProcessAbilityProperties(const std::shared_ptr<ADelegator
void AbilityDelegator::RemoveAbilityProperty(const std::shared_ptr<ADelegatorAbilityProperty> &ability)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGD(AAFwkTag::DELEGATOR, "called");
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid ability property");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid ability property");
return;
}
@ -654,18 +653,18 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::FindPropertyByToken
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
if (!token) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return {};
}
for (const auto &it : abilityProperties_) {
if (!it) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid ability property");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid ability property");
continue;
}
if (token == it->token_) {
TAG_LOGI(AAFwkTag::DELEGATOR, "Property exist");
TAG_LOGD(AAFwkTag::DELEGATOR, "property exist");
return it;
}
}
@ -675,21 +674,21 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::FindPropertyByToken
std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::FindPropertyByName(const std::string &name)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Find property by %{public}s.", name.c_str());
TAG_LOGI(AAFwkTag::DELEGATOR, "find property by %{public}s", name.c_str());
if (name.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid params");
return {};
}
for (const auto &it : abilityProperties_) {
if (!it) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid ability property");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid ability property");
continue;
}
if (name == it->fullName_) {
TAG_LOGI(AAFwkTag::DELEGATOR, "Property exist");
TAG_LOGI(AAFwkTag::DELEGATOR, "property exist");
return it;
}
}
@ -699,29 +698,29 @@ std::shared_ptr<ADelegatorAbilityProperty> AbilityDelegator::FindPropertyByName(
void AbilityDelegator::FinishUserTest(const std::string &msg, const int64_t resultCode)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter, msg : %{public}s, code : %{public}" PRId64, msg.data(), resultCode);
TAG_LOGI(AAFwkTag::DELEGATOR, "msg: %{public}s, code: %{public}" PRId64, msg.data(), resultCode);
if (!observer_) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid observer");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid observer");
return;
}
auto delegatorArgs = AbilityDelegatorRegistry::GetArguments();
if (!delegatorArgs) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid delegator args");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid args");
return;
}
auto realMsg(msg);
if (realMsg.length() > INFORMATION_MAX_LENGTH) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Too long message");
TAG_LOGW(AAFwkTag::DELEGATOR, "too long message");
realMsg.resize(INFORMATION_MAX_LENGTH);
}
const auto &bundleName = delegatorArgs->GetTestBundleName();
auto err = AAFwk::AbilityManagerClient::GetInstance()->FinishUserTest(realMsg, resultCode, bundleName);
if (err) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to call FinishUserTest : %{public}d", err);
TAG_LOGE(AAFwkTag::DELEGATOR, "call FinishUserTest failed: %{public}d", err);
}
}
@ -729,7 +728,7 @@ void AbilityDelegator::RegisterClearFunc(ClearFunc func)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
if (!func) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid func");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid func");
return;
}

View File

@ -32,12 +32,12 @@ DelegatorThread::DelegatorThread(bool isMain)
bool DelegatorThread::Run(const DTask &task)
{
if (!task) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid input parameter");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid input params");
return false;
}
if (!handler_) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid EventHandler");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid EventHandler");
return false;
}

View File

@ -30,35 +30,35 @@ IAbilityMonitor::IAbilityMonitor(const std::string &abilityName,
bool IAbilityMonitor::Match(const std::shared_ptr<ADelegatorAbilityProperty> &ability, bool isNotify)
{
if (!ability) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid ability property");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid ability property");
return false;
}
const auto &aName = ability->name_;
if (abilityName_.empty() || aName.empty()) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Invalid name");
TAG_LOGW(AAFwkTag::DELEGATOR, "invalid name");
return false;
}
if (abilityName_.compare(aName)) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Different name");
TAG_LOGW(AAFwkTag::DELEGATOR, "different name");
return false;
}
const auto &aModuleName = ability->moduleName_;
if (!moduleName_.empty() && moduleName_.compare(aModuleName) != 0) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Different moduleName, %{public}s and %{public}s.",
TAG_LOGE(AAFwkTag::DELEGATOR, "different moduleName, %{public}s and %{public}s",
moduleName_.c_str(), aModuleName.c_str());
return false;
}
TAG_LOGI(AAFwkTag::DELEGATOR, "Matched : ability name : %{public}s, isNotify : %{public}s",
TAG_LOGI(AAFwkTag::DELEGATOR, "ability name : %{public}s, isNotify : %{public}s",
abilityName_.data(), (isNotify ? "true" : "false"));
if (isNotify) {
TAG_LOGI(AAFwkTag::DELEGATOR, "Matched : notify ability matched");
TAG_LOGI(AAFwkTag::DELEGATOR, "notify ability matched");
{
std::lock_guard<std::mutex> matchLock(mMatch_);
matchedAbility_ = ability;
@ -78,7 +78,7 @@ std::shared_ptr<ADelegatorAbilityProperty> IAbilityMonitor::WaitForAbility(const
{
auto realTime = timeoutMs;
if (timeoutMs <= 0) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Timeout should be a positive number");
TAG_LOGW(AAFwkTag::DELEGATOR, "timeout should not number");
realTime = MAX_TIME_OUT;
}
@ -86,7 +86,7 @@ std::shared_ptr<ADelegatorAbilityProperty> IAbilityMonitor::WaitForAbility(const
auto condition = [this] { return this->matchedAbility_ != nullptr; };
if (!cvMatch_.wait_for(matchLock, realTime * 1ms, condition)) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Wait ability timeout");
TAG_LOGW(AAFwkTag::DELEGATOR, "wait ability timeout");
}
return matchedAbility_;

View File

@ -24,11 +24,11 @@ IAbilityStageMonitor::IAbilityStageMonitor(const std::string &moduleName, const
bool IAbilityStageMonitor::Match(const std::shared_ptr<DelegatorAbilityStageProperty> &abilityStage, bool isNotify)
{
if (!abilityStage) {
TAG_LOGE(AAFwkTag::DELEGATOR, "abilityStage to match is null");
TAG_LOGE(AAFwkTag::DELEGATOR, "null abilityStage");
return false;
}
if (moduleName_.compare(abilityStage->moduleName_) != 0 || srcEntrance_.compare(abilityStage->srcEntrance_) != 0) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Different abilityStage");
TAG_LOGW(AAFwkTag::DELEGATOR, "different abilityStage");
return false;
}
@ -55,7 +55,7 @@ std::shared_ptr<DelegatorAbilityStageProperty> IAbilityStageMonitor::WaitForAbil
{
auto realTime = timeoutMs;
if (timeoutMs <= 0) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Timeout should be a positive number");
TAG_LOGW(AAFwkTag::DELEGATOR, "timeout not positive number");
realTime = MAX_TIME_OUT;
}
@ -63,7 +63,7 @@ std::shared_ptr<DelegatorAbilityStageProperty> IAbilityStageMonitor::WaitForAbil
auto condition = [this] { return this->matchedAbilityStage_ != nullptr; };
if (!cvMatch_.wait_for(matchLock, std::chrono::milliseconds(realTime), condition)) {
TAG_LOGW(AAFwkTag::DELEGATOR, "Wait abilityStage timeout");
TAG_LOGW(AAFwkTag::DELEGATOR, "wait abilityStage timeout");
}
return matchedAbilityStage_;
}

View File

@ -27,26 +27,26 @@ namespace RunnerRuntime {
std::unique_ptr<TestRunner> CJTestRunner::Create(const std::unique_ptr<Runtime> &runtime,
const std::shared_ptr<AbilityDelegatorArgs> &args, const AppExecFwk::BundleInfo &bundleInfo)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "CJTestRunner::Create start.");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (!runtime) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid runtime");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid runtime");
return nullptr;
}
auto cjRuntime = static_cast<CJRuntime*>(runtime.get());
if (!cjRuntime->IsAppLibLoaded()) {
TAG_LOGE(AAFwkTag::DELEGATOR, "CJTestRunner: AppLib Not Loaded");
TAG_LOGE(AAFwkTag::DELEGATOR, "appLib not loaded");
return nullptr;
}
if (!args) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid ability delegator args");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid args");
return nullptr;
}
auto pTestRunner = new (std::nothrow) CJTestRunner(*cjRuntime, args, bundleInfo);
if (!pTestRunner) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to create test runner");
TAG_LOGE(AAFwkTag::DELEGATOR, "create testrunner failed");
return nullptr;
}
@ -65,11 +65,11 @@ CJTestRunner::~CJTestRunner() = default;
bool CJTestRunner::Initialize()
{
if (!cjRuntime_.IsAppLibLoaded()) {
TAG_LOGE(AAFwkTag::DELEGATOR, "CJTestRunner: AppLib Not Loaded");
TAG_LOGE(AAFwkTag::DELEGATOR, "appLib not loaded");
return false;
}
if (!cjTestRunnerObj_) {
TAG_LOGE(AAFwkTag::DELEGATOR, "CJTestRunnerObj does not exist, Initialize failed.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cjTestRunnerObj_, initialize failed");
return false;
}
return true;
@ -77,14 +77,13 @@ bool CJTestRunner::Initialize()
void CJTestRunner::Prepare()
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
TestRunner::Prepare();
if (!cjTestRunnerObj_) {
TAG_LOGE(AAFwkTag::DELEGATOR, "CJTestRunnerObj does not exist, Prepare failed.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cjTestRunnerObj_, initialize failed");
return;
}
cjTestRunnerObj_->OnPrepare();
TAG_LOGI(AAFwkTag::DELEGATOR, "End");
}
void CJTestRunner::Run()
@ -92,11 +91,10 @@ void CJTestRunner::Run()
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TestRunner::Run();
if (!cjTestRunnerObj_) {
TAG_LOGE(AAFwkTag::DELEGATOR, "CJTestRunnerObj does not exist, OnRun failed.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null cjTestRunnerObj_, initialize failed");
return;
}
cjTestRunnerObj_->OnRun();
TAG_LOGI(AAFwkTag::DELEGATOR, "End");
}
void CJTestRunner::ReportFinished(const std::string &msg)
@ -104,7 +102,7 @@ void CJTestRunner::ReportFinished(const std::string &msg)
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
if (!delegator) {
TAG_LOGE(AAFwkTag::DELEGATOR, "delegator is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator");
return;
}
@ -113,10 +111,10 @@ void CJTestRunner::ReportFinished(const std::string &msg)
void CJTestRunner::ReportStatus(const std::string &msg)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGD(AAFwkTag::DELEGATOR, "Enter");
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
if (!delegator) {
TAG_LOGE(AAFwkTag::DELEGATOR, "delegator is null.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator");
return;
}

View File

@ -28,20 +28,19 @@ CJTestRunnerFuncs* g_cjTestRunnerFuncs = nullptr;
void RegisterCJTestRunnerFuncs(void (*registerFunc)(CJTestRunnerFuncs*))
{
TAG_LOGI(AAFwkTag::DELEGATOR, "RegisterCJTestRunnerFuncs start.");
TAG_LOGI(AAFwkTag::DELEGATOR, "called");
if (g_cjTestRunnerFuncs != nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Repeated registration for cj functions of CJTestRunner.");
TAG_LOGE(AAFwkTag::DELEGATOR, "repeated registration");
return;
}
if (registerFunc == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "RegisterCJTestRunnerFuncs failed, registerFunc is nullptr.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null registerFunc");
return;
}
g_cjTestRunnerFuncs = new CJTestRunnerFuncs();
registerFunc(g_cjTestRunnerFuncs);
TAG_LOGI(AAFwkTag::DELEGATOR, "RegisterCJTestRunnerFuncs end.");
}
namespace OHOS {
@ -49,13 +48,13 @@ namespace RunnerRuntime {
std::shared_ptr<CJTestRunnerObject> CJTestRunnerObject::LoadModule(const std::string& name)
{
if (g_cjTestRunnerFuncs == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "cj functions for CJTestRunner are not registered");
TAG_LOGE(AAFwkTag::DELEGATOR, "null g_cjTestRunnerFuncs");
return nullptr;
}
auto id = g_cjTestRunnerFuncs->cjTestRunnerCreate(name.c_str());
if (id == 0) {
TAG_LOGE(AAFwkTag::DELEGATOR,
"Failed to invoke CJTestRunnerObject::LoadModule. Ability: %{public}s is not registered.", name.c_str());
"failed to invoke, ability: %{public}s is not registered", name.c_str());
return nullptr;
}
return std::make_shared<CJTestRunnerObject>(id);
@ -70,7 +69,7 @@ CJTestRunnerObject::~CJTestRunnerObject()
void CJTestRunnerObject::OnRun() const
{
if (g_cjTestRunnerFuncs == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "cj functions for CJTestRunner are not registered");
TAG_LOGE(AAFwkTag::DELEGATOR, "null g_cjTestRunnerFuncs");
return;
}
g_cjTestRunnerFuncs->cjTestRunnerOnRun(id_);
@ -79,7 +78,7 @@ void CJTestRunnerObject::OnRun() const
void CJTestRunnerObject::OnPrepare() const
{
if (g_cjTestRunnerFuncs == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "cj functions for CJTestRunner are not registered");
TAG_LOGE(AAFwkTag::DELEGATOR, "null g_cjTestRunnerFuncs");
return;
}
g_cjTestRunnerFuncs->cjTestRunnerOnPrepare(id_);

View File

@ -31,19 +31,19 @@ std::unique_ptr<TestRunner> JsTestRunner::Create(const std::unique_ptr<Runtime>
const std::shared_ptr<AbilityDelegatorArgs> &args, const AppExecFwk::BundleInfo &bundleInfo, bool isFaJsModel)
{
if (!runtime) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid runtime");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid runtime");
return nullptr;
}
if (!args) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid ability delegator args");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid args");
return nullptr;
}
auto pTestRunner = new (std::nothrow) JsTestRunner(static_cast<JsRuntime &>(*runtime), args, bundleInfo,
isFaJsModel);
if (!pTestRunner) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to create test runner");
TAG_LOGE(AAFwkTag::DELEGATOR, "create testrunner failed");
return nullptr;
}
@ -73,7 +73,7 @@ JsTestRunner::JsTestRunner(
srcPath.append(".abc");
srcPath_ = srcPath;
}
TAG_LOGD(AAFwkTag::DELEGATOR, "JsTestRunner srcPath is %{public}s", srcPath_.c_str());
TAG_LOGD(AAFwkTag::DELEGATOR, "srcPath: %{public}s", srcPath_.c_str());
if (!moduleName.empty()) {
for (auto hapModuleInfo : bundleInfo.hapModuleInfos) {
@ -86,7 +86,7 @@ JsTestRunner::JsTestRunner(
} else {
hapPath_ = bundleInfo.hapModuleInfos.back().hapPath;
}
TAG_LOGD(AAFwkTag::DELEGATOR, "JsTestRunner hapPath is %{public}s", hapPath_.c_str());
TAG_LOGD(AAFwkTag::DELEGATOR, "hapPath: %{public}s", hapPath_.c_str());
if (isFaJsModel) {
return;
@ -96,10 +96,10 @@ JsTestRunner::JsTestRunner(
jsTestRunnerObj_ = jsRuntime_.LoadModule(moduleName, srcPath_, hapPath_,
bundleInfo.hapModuleInfos.back().compileMode == AppExecFwk::CompileMode::ES_MODULE);
if (!jsTestRunnerObj_ && srcPath_.find(LOWERCASETESTRUNNER) != std::string::npos) {
TAG_LOGD(AAFwkTag::DELEGATOR, "Not found %{public}s , retry load capital address", srcPath_.c_str());
TAG_LOGI(AAFwkTag::DELEGATOR, "not found %{public}s , retry load capital address", srcPath_.c_str());
std::regex src_pattern(LOWERCASETESTRUNNER);
srcPath_ = std::regex_replace(srcPath_, src_pattern, CAPITALTESTRUNNER);
TAG_LOGD(AAFwkTag::DELEGATOR, "Capital address is %{public}s", srcPath_.c_str());
TAG_LOGD(AAFwkTag::DELEGATOR, "capital address is %{public}s", srcPath_.c_str());
jsTestRunnerObj_ = jsRuntime_.LoadModule(moduleName, srcPath_, hapPath_,
bundleInfo.hapModuleInfos.back().compileMode == AppExecFwk::CompileMode::ES_MODULE);
}
@ -111,17 +111,17 @@ bool JsTestRunner::Initialize()
{
if (isFaJsModel_) {
if (!jsRuntime_.RunScript("/system/etc/strip.native.min.abc", "")) {
TAG_LOGE(AAFwkTag::DELEGATOR, "RunScript err");
TAG_LOGE(AAFwkTag::DELEGATOR, "runscript err");
return false;
}
if (!jsRuntime_.RunScript("/system/etc/abc/ability/delegator_mgmt.abc", "")) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Run delegator failed.");
TAG_LOGE(AAFwkTag::DELEGATOR, "run delegator failed");
return false;
}
if (!jsRuntime_.RunSandboxScript(srcPath_, hapPath_)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "RunScript srcPath_ err");
TAG_LOGE(AAFwkTag::DELEGATOR, "runScript srcPath_ err");
return false;
}
@ -129,19 +129,19 @@ bool JsTestRunner::Initialize()
napi_value object = nullptr;
napi_get_global(env, &object);
if (object == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get global object");
TAG_LOGE(AAFwkTag::DELEGATOR, "get globalobject get");
return false;
}
napi_value mainEntryFunc = nullptr;
napi_get_named_property(env, object, "___mainEntry___", &mainEntryFunc);
if (mainEntryFunc == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get mainEntryFunc");
TAG_LOGE(AAFwkTag::DELEGATOR, "get mainEntryFunc failed");
return false;
}
napi_value value = nullptr;
napi_get_global(env, &value);
if (value == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get global");
TAG_LOGE(AAFwkTag::DELEGATOR, "get global failed");
return false;
}
napi_call_function(env, value, mainEntryFunc, 1, &value, nullptr);
@ -154,7 +154,6 @@ void JsTestRunner::Prepare()
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TestRunner::Prepare();
CallObjectMethod("onPrepare");
TAG_LOGI(AAFwkTag::DELEGATOR, "End");
}
void JsTestRunner::Run()
@ -162,12 +161,11 @@ void JsTestRunner::Run()
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TestRunner::Run();
CallObjectMethod("onRun");
TAG_LOGI(AAFwkTag::DELEGATOR, "End");
}
void JsTestRunner::CallObjectMethod(const char *name, napi_value const *argv, size_t argc)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "JsTestRunner::CallObjectMethod(%{public}s)", name);
TAG_LOGI(AAFwkTag::DELEGATOR, "callJsMethod(%{public}s)", name);
auto env = jsRuntime_.GetNapiEnv();
if (isFaJsModel_) {
napi_value global = nullptr;
@ -175,21 +173,21 @@ void JsTestRunner::CallObjectMethod(const char *name, napi_value const *argv, si
napi_value exportObject = nullptr;
napi_get_named_property(env, global, "exports", &exportObject);
if (!CheckTypeForNapiValue(env, exportObject, napi_object)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get exportObject");
TAG_LOGE(AAFwkTag::DELEGATOR, "get exportObject failed");
return;
}
napi_value defaultObject = nullptr;
napi_get_named_property(env, exportObject, "default", &defaultObject);
if (!CheckTypeForNapiValue(env, defaultObject, napi_object)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get defaultObject");
TAG_LOGE(AAFwkTag::DELEGATOR, "get defaultObject failed");
return;
}
napi_value func = nullptr;
napi_get_named_property(env, defaultObject, name, &func);
if (!CheckTypeForNapiValue(env, func, napi_function)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "CallRequest func is %{public}s", func == nullptr ? "nullptr" : "not func");
TAG_LOGE(AAFwkTag::DELEGATOR, "callRequest func:%{public}s", func == nullptr ? "nullptr" : "not func");
return;
}
napi_call_function(env, CreateJsUndefined(env), func, argc, argv, nullptr);
@ -197,7 +195,7 @@ void JsTestRunner::CallObjectMethod(const char *name, napi_value const *argv, si
}
if (!jsTestRunnerObj_) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Not found %{public}s", srcPath_.c_str());
TAG_LOGE(AAFwkTag::DELEGATOR, "not found %{public}s", srcPath_.c_str());
ReportFinished("Not found " + srcPath_);
return;
}
@ -205,7 +203,7 @@ void JsTestRunner::CallObjectMethod(const char *name, napi_value const *argv, si
HandleScope handleScope(jsRuntime_);
napi_value obj = jsTestRunnerObj_->GetNapiValue();
if (!CheckTypeForNapiValue(env, obj, napi_object)) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get Test Runner object");
TAG_LOGE(AAFwkTag::DELEGATOR, "get TestRunner object failed");
ReportFinished("Failed to get Test Runner object");
return;
}
@ -213,7 +211,7 @@ void JsTestRunner::CallObjectMethod(const char *name, napi_value const *argv, si
napi_value methodOnCreate = nullptr;
napi_get_named_property(env, obj, name, &methodOnCreate);
if (methodOnCreate == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get '%{public}s' from Test Runner object", name);
TAG_LOGE(AAFwkTag::DELEGATOR, "get '%{public}s' from TestRunner object failed", name);
ReportStatus("Failed to get " + std::string(name) + " from Test Runner object");
return;
}
@ -222,10 +220,10 @@ void JsTestRunner::CallObjectMethod(const char *name, napi_value const *argv, si
void JsTestRunner::ReportFinished(const std::string &msg)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
if (!delegator) {
TAG_LOGE(AAFwkTag::DELEGATOR, "delegator is null");
TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator");
return;
}
@ -234,10 +232,10 @@ void JsTestRunner::ReportFinished(const std::string &msg)
void JsTestRunner::ReportStatus(const std::string &msg)
{
TAG_LOGI(AAFwkTag::DELEGATOR, "Enter");
TAG_LOGI(AAFwkTag::DELEGATOR, "enter");
auto delegator = AbilityDelegatorRegistry::GetAbilityDelegator();
if (!delegator) {
TAG_LOGE(AAFwkTag::DELEGATOR, "delegator is null");
TAG_LOGE(AAFwkTag::DELEGATOR, "null delegator");
return;
}

View File

@ -35,12 +35,12 @@ std::unique_ptr<TestRunner> TestRunner::Create(const std::unique_ptr<AbilityRunt
auto bundleMgrHelper = DelayedSingleton<BundleMgrHelper>::GetInstance();
if (bundleMgrHelper == nullptr) {
TAG_LOGE(AAFwkTag::DELEGATOR, "The bundleMgrHelper is nullptr.");
TAG_LOGE(AAFwkTag::DELEGATOR, "null bundleMgrHelper");
return nullptr;
}
if (!args) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Invalid ability delegator args.");
TAG_LOGE(AAFwkTag::DELEGATOR, "invalid args");
return nullptr;
}
@ -53,7 +53,7 @@ std::unique_ptr<TestRunner> TestRunner::Create(const std::unique_ptr<AbilityRunt
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION) +
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_SIGNATURE_INFO) +
static_cast<int32_t>(GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_METADATA)), bundleInfo) != ERR_OK) {
TAG_LOGE(AAFwkTag::DELEGATOR, "Failed to get bundle info.");
TAG_LOGE(AAFwkTag::DELEGATOR, "get bundle info failed");
return nullptr;
}