diff --git a/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp b/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp index ae40836eeb787ca3ffcc7a9289f07c9bd2616705..009034216ed368a70f3128d9f834039e73f6af2b 100644 --- a/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp +++ b/frameworks/js/napi/inner/napi_common/napi_common_start_options.cpp @@ -217,6 +217,11 @@ bool UnwrapStartOptions(napi_env env, napi_value param, AAFwk::StartOptions &sta if (UnwrapBooleanByPropertyName(env, param, "windowFocused", windowFocused)) { startOptions.SetWindowFocused(windowFocused); } + + bool hideStartWindow = false; + if (UnwrapBooleanByPropertyName(env, param, "hideStartWindow", hideStartWindow)) { + startOptions.SetHideStartWindow(hideStartWindow); + } std::vector supportWindowModes; if (UnwrapInt32ArrayByPropertyName(env, param, "supportWindowModes", supportWindowModes)) { diff --git a/interfaces/inner_api/ability_manager/include/start_options.h b/interfaces/inner_api/ability_manager/include/start_options.h index 78235c65b42d31b3de17cd7f13436b5dd03ea7ea..83390c35fc2acd79f0de26ef95358cd1f5304d2c 100644 --- a/interfaces/inner_api/ability_manager/include/start_options.h +++ b/interfaces/inner_api/ability_manager/include/start_options.h @@ -64,6 +64,9 @@ public: void SetWindowFocused(bool windowFocused); int32_t GetWindowFocused() const; + void SetHideStartWindow(bool hideStartWindow); + bool GetHideStartWindow() const; + void SetWindowLeft(int32_t windowLeft); int32_t GetWindowLeft() const; @@ -90,6 +93,7 @@ public: private: bool withAnimation_ = true; bool windowFocused_ = true; + bool hideStartWindow_ = false; int32_t windowMode_ = AbilityWindowConfiguration::MULTI_WINDOW_DISPLAY_UNDEFINED; int32_t displayId_ = -1; int32_t windowLeft_ = 0; diff --git a/services/abilitymgr/include/ability_record.h b/services/abilitymgr/include/ability_record.h index 4843aa5922cc76ab51d0ddc0f9287c36cd6a1f7b..a40368a383549ca924b5ec667099bf46f8ab072d 100644 --- a/services/abilitymgr/include/ability_record.h +++ b/services/abilitymgr/include/ability_record.h @@ -253,6 +253,7 @@ struct AbilityRequest { bool isQueryERMS = false; bool isEmbeddedAllowed = false; bool callSpecifiedFlagTimeout = false; + bool hideStartWindow = false; int32_t restartCount = -1; int32_t uid = 0; int32_t collaboratorType = CollaboratorType::DEFAULT_TYPE; diff --git a/services/abilitymgr/src/ability_manager_service.cpp b/services/abilitymgr/src/ability_manager_service.cpp index c5e3ccdc9ba15788d51d76d8e7d446170798a0d8..96acb08c9371775c237db967264bd78a2ba368a5 100644 --- a/services/abilitymgr/src/ability_manager_service.cpp +++ b/services/abilitymgr/src/ability_manager_service.cpp @@ -2142,6 +2142,11 @@ int AbilityManagerService::StartAbilityForOptionInner(const Want &want, const St abilityRequest.startWindowOption = startOptions.startWindowOption; } abilityRequest.supportWindowModes = startOptions.supportWindowModes_; + auto abilityRecord = Token::GetAbilityRecordByToken(callerToken); + CHECK_POINTER_AND_RETURN_LOG(abilityRecord, ERR_INVALID_VALUE, "ability record is nullptr."); + if (JudgeSelfCalled(abilityRecord)) { + abilityRequest.hideStartWindow = startOptions.GetHideStartWindow(); + } auto uiAbilityManager = GetUIAbilityManagerByUserId(oriValidUserId); CHECK_POINTER_AND_RETURN(uiAbilityManager, ERR_NULL_UI_ABILITY_MANAGER); return uiAbilityManager->NotifySCBToStartUIAbility(abilityRequest); 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 effb97b13411599c9d46965a8519b7439d394ca1..380f8075f6da7d04a169e81e138966f789cdf5c7 100644 --- a/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp +++ b/services/abilitymgr/src/scene_board/ui_ability_lifecycle_manager.cpp @@ -1352,9 +1352,8 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr &ses errMsg = "sessionInfo is nullptr"; return ERR_INVALID_VALUE; } - TAG_LOGD(AAFwkTag::ABILITYMGR, "windowLeft=%{public}d,windowTop=%{public}d,windowHeight=%{public}d," + TAG_LOGD(AAFwkTag::ABILITYMGR, "windowTop=%{public}d,windowHeight=%{public}d," "windowWidth=%{public}d,windowMode=%{public}d,supportWindowModes.size=%{public}zu,specifiedFlag=%{public}s", - (sessionInfo->want).GetIntParam(Want::PARAM_RESV_WINDOW_LEFT, 0), (sessionInfo->want).GetIntParam(Want::PARAM_RESV_WINDOW_TOP, 0), (sessionInfo->want).GetIntParam(Want::PARAM_RESV_WINDOW_HEIGHT, 0), (sessionInfo->want).GetIntParam(Want::PARAM_RESV_WINDOW_WIDTH, 0), @@ -1364,10 +1363,11 @@ int UIAbilityLifecycleManager::NotifySCBPendingActivation(sptr &ses bool hasStartWindow = hasStartWindowOption ? sessionInfo->startWindowOption->hasStartWindow : false; std::string backgroundColor = hasStartWindowOption ? sessionInfo->startWindowOption->startWindowBackgroundColor : ""; + sessionInfo->hideStartWindow = abilityRequest.hideStartWindow; TAG_LOGI(AAFwkTag::ABILITYMGR, "appCloneIndex:%{public}d, instanceKey:%{public}s, " - "hasStartWindow:%{public}d, backgroundColor:%{public}s", + "hasStartWindow:%{public}d, backgroundColor:%{public}s, hideStartWindow: %{public}d", (sessionInfo->want).GetIntParam(Want::PARAM_APP_CLONE_INDEX_KEY, 0), sessionInfo->instanceKey.c_str(), - hasStartWindow, backgroundColor.c_str()); + hasStartWindow, backgroundColor.c_str(), sessionInfo->hideStartWindow); auto abilityRecord = GetAbilityRecordByToken(abilityRequest.callerToken); if (abilityRecord != nullptr && !abilityRecord->GetRestartAppFlag()) { auto callerSessionInfo = abilityRecord->GetSessionInfo(); diff --git a/services/abilitymgr/src/start_options.cpp b/services/abilitymgr/src/start_options.cpp index faf92aa8c9267d09dafbafac1d16a0171843e3ab..0e04701455b294709041289c9fc2b0cae14a670a 100644 --- a/services/abilitymgr/src/start_options.cpp +++ b/services/abilitymgr/src/start_options.cpp @@ -46,6 +46,7 @@ StartOptions::StartOptions(const StartOptions &other) maxWindowHeightUsed_ = other.maxWindowHeightUsed_; processOptions = other.processOptions; windowFocused_ = other.windowFocused_; + hideStartWindow_ = other.hideStartWindow_; startWindowOption = other.startWindowOption; supportWindowModes_ = other.supportWindowModes_; requestId_ = other.requestId_; @@ -75,6 +76,7 @@ StartOptions &StartOptions::operator=(const StartOptions &other) maxWindowHeightUsed_ = other.maxWindowHeightUsed_; processOptions = other.processOptions; windowFocused_ = other.windowFocused_; + hideStartWindow_ = other.hideStartWindow_; startWindowOption = other.startWindowOption; supportWindowModes_ = other.supportWindowModes_; requestId_ = other.requestId_; @@ -96,6 +98,7 @@ bool StartOptions::ReadFromParcel(Parcel &parcel) SetMaxWindowWidth(parcel.ReadInt32()); SetMaxWindowHeight(parcel.ReadInt32()); SetWindowFocused(parcel.ReadBool()); + SetHideStartWindow(parcel.ReadBool()); windowLeftUsed_ = parcel.ReadBool(); windowTopUsed_ = parcel.ReadBool(); windowWidthUsed_ = parcel.ReadBool(); @@ -147,6 +150,7 @@ bool StartOptions::Marshalling(Parcel &parcel) const parcel.WriteInt32(GetMaxWindowWidth()); parcel.WriteInt32(GetMaxWindowHeight()); parcel.WriteBool(GetWindowFocused()); + parcel.WriteBool(GetHideStartWindow()); parcel.WriteBool(windowLeftUsed_); parcel.WriteBool(windowTopUsed_); parcel.WriteBool(windowWidthUsed_); @@ -296,5 +300,16 @@ int32_t StartOptions::GetWindowFocused() const { return windowFocused_; } + +void StartOptions::SetHideStartWindow(bool hideStartWindow) +{ + hideStartWindow_ = hideStartWindow; +} + +bool StartOptions::GetHideStartWindow() const +{ + return hideStartWindow_; +} + } // namespace AAFwk } // namespace OHOS diff --git a/test/unittest/start_options_test/start_options_test.cpp b/test/unittest/start_options_test/start_options_test.cpp index a8ad63f60af472c5a19793d5aed2b680c94e421e..8832c0bce019037cfb20f8942a1ceb764c3675f1 100755 --- a/test/unittest/start_options_test/start_options_test.cpp +++ b/test/unittest/start_options_test/start_options_test.cpp @@ -122,5 +122,43 @@ HWTEST_F(StartOptionsTest, start_options_test_003, TestSize.Level1) StartOptions secondStartOptions = firstStartOptions; EXPECT_EQ(secondStartOptions.GetWindowMode(), firstStartOptions.windowMode_); } + +/** + * @tc.name: start_options_test_004 + * @tc.desc: test class StartOptions HideStartWindow = false + * @tc.type: FUNC + */ +HWTEST_F(StartOptionsTest, start_options_test_004, TestSize.Level1) +{ + StartOptions startOptions; + bool hideStartWindow = false; + startOptions.SetHideStartWindow(hideStartWindow); + EXPECT_EQ(startOptions.GetHideStartWindow(), hideStartWindow); + + Parcel parcel; + bool marshallResult = startOptions.Marshalling(parcel); + EXPECT_EQ(marshallResult, true); + auto unmarshallResult = startOptions.Unmarshalling(parcel); + EXPECT_EQ(unmarshallResult->GetHideStartWindow(), hideStartWindow); +} + +/** + * @tc.name: start_options_test_005 + * @tc.desc: test class StartOptions HideStartWindow = true + * @tc.type: FUNC + */ +HWTEST_F(StartOptionsTest, start_options_test_005, TestSize.Level1) +{ + StartOptions startOptions; + bool hideStartWindow = true; + startOptions.SetHideStartWindow(hideStartWindow); + EXPECT_EQ(startOptions.GetHideStartWindow(), hideStartWindow); + + Parcel parcel; + bool marshallResult = startOptions.Marshalling(parcel); + EXPECT_EQ(marshallResult, true); + auto unmarshallResult = startOptions.Unmarshalling(parcel); + EXPECT_EQ(unmarshallResult->GetHideStartWindow(), hideStartWindow); +} } // namespace AppExecFwk } // namespace OHOS