From 4d4f78d678afafc3ba7fdc328eb7cb00965477da Mon Sep 17 00:00:00 2001 From: donglin Date: Sat, 21 Sep 2024 11:34:57 +0000 Subject: [PATCH] =?UTF-8?q?=E7=AA=97=E5=8F=A3displayId=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donglin Change-Id: Iecf4a12c1eb6f0210f3d192b40c2bbbbf5fa8a0c --- frameworks/native/ability/native/ui_ability.cpp | 6 ++++++ frameworks/native/appkit/app/main_thread.cpp | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/frameworks/native/ability/native/ui_ability.cpp b/frameworks/native/ability/native/ui_ability.cpp index 5b438dea81..8a227a10c8 100644 --- a/frameworks/native/ability/native/ui_ability.cpp +++ b/frameworks/native/ability/native/ui_ability.cpp @@ -227,6 +227,9 @@ void UIAbility::OnStop() return; } lifecycle_->DispatchLifecycle(AppExecFwk::LifeCycle::Event::ON_STOP); +#ifdef SUPPORT_SCREEN + Rosen::DisplayManager::GetInstance().RemoveDisplayIdFromAms(token_); +#endif TAG_LOGD(AAFwkTag::UIABILITY, "end"); } @@ -1036,6 +1039,9 @@ void UIAbility::OnStartForSupportGraphics(const AAFwk::Want &want) int32_t displayId = want.GetIntParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, defualtDisplayId); TAG_LOGD(AAFwkTag::UIABILITY, "abilityName: %{public}s, displayId: %{public}d", abilityInfo_->name.c_str(), displayId); +#ifdef SUPPORT_SCREEN + Rosen::DisplayManager::GetInstance().AddDisplayIdFromAms(displayId, token_); +#endif auto option = GetWindowOption(want); InitWindow(displayId, option); diff --git a/frameworks/native/appkit/app/main_thread.cpp b/frameworks/native/appkit/app/main_thread.cpp index ce54b27005..7d3b0e737a 100644 --- a/frameworks/native/appkit/app/main_thread.cpp +++ b/frameworks/native/appkit/app/main_thread.cpp @@ -2058,6 +2058,15 @@ void MainThread::HandleLaunchAbility(const std::shared_ptr & AbilityThread::AbilityThreadMain(application, abilityRecord, mainHandler_->GetEventRunner(), stageContext); #endif }; +#ifdef SUPPORT_SCREEN + Rosen::DisplayId defaultDisplayId = Rosen::DisplayManager::GetInstance().GetDefaultDisplayId(); + Rosen::DisplayId displayId = defaultDisplayId; + if (abilityRecord->GetWant() != nullptr) { + displayId = abilityRecord->GetWant()->GetIntParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, defaultDisplayId); + } + Rosen::DisplayManager::GetInstance().AddDisplayIdFromAms(displayId, abilityRecord->GetToken()); + TAG_LOGD(AAFwkTag::APPKIT, "add displayId: %{public}" PRIu64, displayId); +#endif bool isAsyncCallback = false; std::shared_ptr stageContext = application_->AddAbilityStage( abilityRecord, callback, isAsyncCallback);