diff --git a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn index eed5ae7066..477aeb266d 100644 --- a/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn +++ b/frameworks/js/napi/ability_auto_startup_callback/BUILD.gn @@ -18,6 +18,7 @@ ohos_shared_library("autostartupcallback") { include_dirs = [ "./", "${ability_runtime_napi_path}/inner/napi_common/", + "${ability_runtime_utils_path}/global/constant", ] sources = [ diff --git a/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp b/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp index 7e88a776b1..523c73494d 100644 --- a/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp +++ b/frameworks/js/napi/ability_auto_startup_callback/js_ability_auto_startup_manager_utils.cpp @@ -14,6 +14,8 @@ */ #include "js_ability_auto_startup_manager_utils.h" + +#include "global_constant.h" #include "hilog_tag_wrapper.h" #include "napi_common_util.h" @@ -127,7 +129,7 @@ napi_value CreateJsAutoStartupInfo(napi_env env, const AutoStartupInfo &info) TAG_LOGE(AAFwkTag::AUTO_STARTUP, "Create js AutoStartupInfo failed."); return nullptr; } - if (info.appCloneIndex != -1) { + 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."); diff --git a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp index a19672fa09..c1640cbd1b 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -948,6 +948,8 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr &ses (sessionInfo->want).GetIntParam(Want::PARAM_RESV_WINDOW_HEIGHT, 0), (sessionInfo->want).GetIntParam(Want::PARAM_RESV_WINDOW_WIDTH, 0), (sessionInfo->want).GetIntParam(Want::PARAM_RESV_WINDOW_MODE, 0)); + TAG_LOGI(AAFwkTag::ABILITYMGR, "appCloneIndex: %{public}d.", + (sessionInfo->want).GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0)); auto abilityRecord = GetAbilityRecordByToken(abilityRequest.callerToken); if (abilityRecord != nullptr && !abilityRecord->GetRestartAppFlag()) { auto callerSessionInfo = abilityRecord->GetSessionInfo(); diff --git a/services/abilitymgr/src/start_ability_utils.cpp b/services/abilitymgr/src/start_ability_utils.cpp index d1d1ac7ca0..81c39edd36 100644 --- a/services/abilitymgr/src/start_ability_utils.cpp +++ b/services/abilitymgr/src/start_ability_utils.cpp @@ -50,6 +50,7 @@ bool StartAbilityUtils::GetAppIndex(const Want &want, sptr caller appIndex = abilityRecord->GetAppIndex(); return true; } + TAG_LOGI(AAFwkTag::ABILITYMGR, "appCloneIndex: %{public}d.", want.GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0)); return AbilityRuntime::StartupUtil::GetAppIndex(want, appIndex); } diff --git a/utils/server/startup/src/startup_util.cpp b/utils/server/startup/src/startup_util.cpp index eeec9b65e5..3a292a49b2 100644 --- a/utils/server/startup/src/startup_util.cpp +++ b/utils/server/startup/src/startup_util.cpp @@ -25,13 +25,17 @@ namespace OHOS::AbilityRuntime { bool StartupUtil::GetAppIndex(const AAFwk::Want &want, int32_t &appIndex) { appIndex = want.GetIntParam(ServerConstant::DLP_INDEX, 0); + if (appIndex > GlobalConstant::MAX_APP_CLONE_INDEX) { + return true; + } if (appIndex == 0) { appIndex = want.GetIntParam(AAFwk::Want::PARAM_APP_CLONE_INDEX_KEY, 0); if (appIndex < 0 || appIndex > GlobalConstant::MAX_APP_CLONE_INDEX) { return false; } + return true; } - return true; + return false; } int32_t StartupUtil::BuildAbilityInfoFlag()