add log and fixed app index

Signed-off-by: yuwenze <yuwenze1@huawei.com>
Change-Id: Id0f9a864469eddc8fcccd9407a65782f4dfc627d
This commit is contained in:
yuwenze 2024-07-18 16:29:51 +08:00
parent 237eb545b3
commit 67aa0a51fc
5 changed files with 12 additions and 2 deletions

View File

@ -18,6 +18,7 @@ ohos_shared_library("autostartupcallback") {
include_dirs = [
"./",
"${ability_runtime_napi_path}/inner/napi_common/",
"${ability_runtime_utils_path}/global/constant",
]
sources = [

View File

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

View File

@ -947,6 +947,8 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr<SessionInfo> &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();

View File

@ -47,6 +47,7 @@ bool StartAbilityUtils::GetAppIndex(const Want &want, sptr<IRemoteObject> 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);
}

View File

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