From c2a464b1d1ec61f721110ab07b5430e6c09b1e1f Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Tue, 2 Jul 2024 11:16:49 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- bundle.json | 3 +- .../pattern/window_scene/BUILD.gn | 5 + .../window_scene/scene/window_pattern.cpp | 159 ++++++++++++++++++ .../window_scene/scene/window_pattern.h | 5 + .../core/pattern/ui_extension/BUILD.gn | 1 + 5 files changed, 172 insertions(+), 1 deletion(-) diff --git a/bundle.json b/bundle.json index b38193317dc..3d6a9424c5e 100644 --- a/bundle.json +++ b/bundle.json @@ -91,7 +91,8 @@ "zlib", "skia", "libuv", - "background_task_mgr" + "background_task_mgr", + "atomicservice_basic_engine" ], "third_party": [] }, diff --git a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn index b6bcc5551c2..2c14adfcf6c 100644 --- a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn +++ b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn @@ -17,6 +17,10 @@ import( if (is_ohos_standard_system) { config("window_scene_config") { visibility = [ ":*" ] + + include_dirs = [ + "//vendor/huawei/atomicservicedistribution/hag_serviceability/interface/innerkits/include", + ] } } @@ -58,6 +62,7 @@ build_component_ng("window_scene") { "window_manager:scene_session_manager", "window_manager:screen_session", "window_manager:screen_session_manager_client", + "atomicservice_basic_engine:hagserviceability_client", ] } } diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp index e3e57291291..fb8437d49cc 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp @@ -20,16 +20,33 @@ #include "adapter/ohos/entrance/mmi_event_convertor.h" #include "base/utils/system_properties.h" +#include "core/components_ng/pattern/text/text_pattern.h" +#include "core/components_ng/pattern/text/text_styles.h" #include "core/components_ng/image_provider/image_utils.h" #include "core/components_ng/pattern/image/image_pattern.h" #include "core/components_ng/pattern/window_scene/scene/window_event_process.h" #include "core/components_ng/render/adapter/rosen_render_context.h" #include "core/components_v2/inspector/inspector_constants.h" +#include "hag_serviceability_client.h" + +using namespace OHOS::AppExecFwk::AtomicserviceEcologicalRuleManager; namespace OHOS::Ace::NG { namespace { constexpr uint32_t COLOR_BLACK = 0xff000000; constexpr uint32_t COLOR_WHITE = 0xffffffff; + +constexpr float HALF_PERCENT_TAG = 0.5f; +constexpr float BASE_X_OFFSET = 0.25f; +constexpr float BASE_Y_OFFSET = 0.4f; +constexpr float ROTATION_ANGLE = 360.0f; +constexpr uint32_t TEXT_NODE_HEIGHT = 42; +constexpr uint32_t TEXT_OFFSET_Y = 44; +constexpr uint32_t TEXT_NODE_FONT_SIZE = 16; +constexpr uint32_t TEXT_MAX_LINE = 2; +constexpr uint32_t IMAGE_NODE_SIZE = 72; +constexpr uint32_t IMAGE_NODE_OFFSET = -36; +constexpr uint32_t ANIMATION_DURATION = 1750; } // namespace class LifecycleListener : public Rosen::ILifecycleListener { @@ -192,8 +209,150 @@ void WindowPattern::CreateAppWindow() } } +RefPtr WindowPattern::BuildTextNode(std::string appNameInfo) { + auto textNode = FrameNode::CreateFrameNode( + V2::TEXT_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + CHECK_NULL_RETURN(textNode, nullptr); + auto textLayoutProperty = textNode->GetLayoutProperty(); + CHECK_NULL_RETURN(textLayoutProperty, nullptr); + auto textContext = AceType::DynamicCast(textNode->GetRenderContext()); + CHECK_NULL_RETURN(textContext, nullptr); + // set size + auto textNodeHeight = CalcLength(Dimension(TEXT_NODE_HEIGHT, DimensionUnit::VP)); + auto textNodeWidth = CalcLength(Dimension(HALF_PERCENT_TAG, DimensionUnit::PERCENT)); + textLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(textNodeWidth, textNodeHeight)); + // set position + double textOffsetY = Dimension(TEXT_OFFSET_Y, DimensionUnit::VP).ConvertToPx(); + auto basePositionX = Dimension(BASE_X_OFFSET, DimensionUnit::PERCENT); + auto basePositionY = Dimension(BASE_Y_OFFSET, DimensionUnit::PERCENT); + textContext->UpdatePosition(OffsetT(basePositionX, basePositionY)); + textContext->SetTranslate(0, textOffsetY, 0); + // set basic attributions + textLayoutProperty->UpdateContent(appNameInfo); + textLayoutProperty->UpdateAlignment(Alignment::TOP_CENTER); + textLayoutProperty->UpdateFontSize(Dimension(TEXT_NODE_FONT_SIZE, DimensionUnit::FP)); + textLayoutProperty->UpdateFontWeight(FontWeight::MEDIUM); + textLayoutProperty->UpdateMaxLines(TEXT_MAX_LINE); + textLayoutProperty->UpdateTextOverflow(TextOverflow::ELLIPSIS); + textLayoutProperty->UpdateTextAlign(TextAlign::CENTER); + textNode->MarkModifyDone(); + return textNode; +} + +RefPtr WindowPattern::BuildAnimateNode(std::string base64Resource) { + const auto& sessionInfo = session_->GetSessionInfo(); + auto testImageSource = ImageSourceInfo( + base64Resource, sessionInfo.bundleName_, sessionInfo.moduleName_); + auto animateNode = FrameNode::CreateFrameNode( + V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + CHECK_NULL_RETURN(animateNode, nullptr); + auto animateLayoutProperty = animateNode->GetLayoutProperty(); + CHECK_NULL_RETURN(animateLayoutProperty, nullptr); + animateLayoutProperty->UpdateMeasureType(MeasureType::MATCH_PARENT); + animateLayoutProperty->UpdateImageSourceInfo(testImageSource); + animateLayoutProperty->UpdateImageFit(ImageFit::FILL); + auto animateContext = AceType::DynamicCast(animateNode->GetRenderContext()); + CHECK_NULL_RETURN(animateContext, nullptr); + auto animateRSNode = animateContext->GetRSNode(); + CHECK_NULL_RETURN(animateRSNode, nullptr); + auto animatePaintProperty = animateNode->GetPaintProperty(); + CHECK_NULL_RETURN(animatePaintProperty, nullptr); + animatePaintProperty->UpdateImageInterpolation(ImageInterpolation::HIGH); + // set position + auto animateOffsetX = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); + auto animateOffsetY = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); + auto basePositionX = Dimension(HALF_PERCENT_TAG, DimensionUnit::PERCENT); + auto basePositionY = Dimension(BASE_Y_OFFSET, DimensionUnit::PERCENT); + animateContext->UpdatePosition(OffsetT(basePositionX, basePositionY)); + animateContext->SetTranslate(animateOffsetX, animateOffsetY, 0); + // set size + auto animateNodeHeight = CalcLength(Dimension(IMAGE_NODE_SIZE, DimensionUnit::VP)); + auto animateNodeWidth = CalcLength(Dimension(IMAGE_NODE_SIZE, DimensionUnit::VP)); + animateLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(animateNodeWidth, animateNodeHeight)); + // set animation + Rosen::RSAnimationTimingProtocol protocol; + animateContext->UpdateTransformRotate(Vector5F(0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); + protocol.SetDuration(ANIMATION_DURATION); + protocol.SetRepeatCount(-1); + auto curve = Rosen::RSAnimationTimingCurve::CreateCubicCurve(0.40, 0.08, 0.60, 0.92); + Rosen::RSNode::Animate(protocol, curve, [animateContext] { + animateContext->UpdateTransformRotate(Vector5F(0.0f, 0.0f, 1.0f, ROTATION_ANGLE, 0.0f)); + }); + animateNode->MarkModifyDone(); + return animateNode; +} + +RefPtr WindowPattern::BuildStaticImageNode(std::string base64Resource) { + const auto& sessionInfo = session_->GetSessionInfo(); + auto testImageSource = ImageSourceInfo( + base64Resource, sessionInfo.bundleName_, sessionInfo.moduleName_); + auto staticNode = FrameNode::CreateFrameNode( + V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + CHECK_NULL_RETURN(staticNode, nullptr); + auto staticLayoutProperty = staticNode->GetLayoutProperty(); + CHECK_NULL_RETURN(staticLayoutProperty, nullptr); + staticLayoutProperty->UpdateMeasureType(MeasureType::MATCH_PARENT); + staticLayoutProperty->UpdateImageSourceInfo(testImageSource); + staticLayoutProperty->UpdateImageFit(ImageFit::CONTAIN); + // set size + auto staticNodeHeight = CalcLength(Dimension(IMAGE_NODE_SIZE, DimensionUnit::VP)); + auto staticNodeWidth = CalcLength(Dimension(IMAGE_NODE_SIZE, DimensionUnit::VP)); + staticLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(staticNodeWidth, staticNodeHeight)); + // get context and property + auto staticContext = AceType::DynamicCast(staticNode->GetRenderContext()); + CHECK_NULL_RETURN(staticContext, nullptr); + staticContext->UpdatePosition(OffsetT(0.0_vp, 0.0_vp)); + auto staticPaintProperty = staticNode->GetPaintProperty(); + CHECK_NULL_RETURN(staticPaintProperty, nullptr); + staticPaintProperty->UpdateImageInterpolation(ImageInterpolation::HIGH); + // set position + auto staticOffsetX = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); + auto staticOffsetY = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); + auto basePositionX = Dimension(HALF_PERCENT_TAG, DimensionUnit::PERCENT); + auto basePositionY = Dimension(BASE_Y_OFFSET, DimensionUnit::PERCENT); + staticContext->UpdatePosition(OffsetT(basePositionX, basePositionY)); + staticContext->SetTranslate(staticOffsetX, staticOffsetY, 0); + staticNode->MarkModifyDone(); + return staticNode; +} + +void WindowPattern::CreateASStartingWindow() { + auto host = GetHost(); + CHECK_NULL_VOID(host); + ACE_SCOPED_TRACE("CreateASStartingWindow[id:%d][self:%d]", session_->GetPersistentId(), host->GetId()); + + const auto& sessionInfo = session_->GetSessionInfo(); + // get atomic service resources + AtomicserviceIconInfo atomicserviceIconInfo; + HagServiceablityClient::GetInstance()->GetAtomicserviceIconInfo(sessionInfo.bundleName_, atomicserviceIconInfo); + auto appNameInfo = atomicserviceIconInfo.GetAppName(); + auto eyelashRingIcon = atomicserviceIconInfo.GetEyelashRingIcon(); + auto circleIcon = atomicserviceIconInfo.GetCircleIcon(); + + startingWindow_ = FrameNode::CreateFrameNode( + V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + auto asStartingLayoutProperty = startingWindow_->GetLayoutProperty(); + asStartingLayoutProperty->UpdateMeasureType(MeasureType::MATCH_PARENT); + startingWindow_->SetHitTestMode(HitTestMode::HTMNONE); + startingWindow_->GetRenderContext()->UpdateBackgroundColor(SystemProperties::GetColorMode() == ColorMode::DARK ? Color::BLACK : Color::WHITE); + + auto staticNode = BuildStaticImageNode(circleIcon); + auto animateNode = BuildAnimateNode(eyelashRingIcon); + auto textNode = BuildTextNode(appNameInfo); + + startingWindow_->AddChild(staticNode); + startingWindow_->AddChild(animateNode); + startingWindow_->AddChild(textNode); + startingWindow_->MarkModifyDone(); +} + void WindowPattern::CreateStartingWindow() { + if (sessionInfo.isAtomicService) { + CreateASStartingWindow(); + return; + } + auto host = GetHost(); CHECK_NULL_VOID(host); ACE_SCOPED_TRACE("CreateStartingWindow[id:%d][self:%d]", session_->GetPersistentId(), host->GetId()); diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h index d1582bd03ee..ffec1f14e05 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h @@ -53,6 +53,11 @@ protected: void RegisterLifecycleListener(); void UnregisterLifecycleListener(); + RefPtr BuildTextNode(std::string appNameInfo); + RefPtr BuildAnimateNode(std::string base64Resource); + RefPtr BuildStaticImageNode(std::string base64Resource); + void CreateASStartingWindow(); + void CreateAppWindow(); void CreateBlankWindow(); void CreateStartingWindow(); diff --git a/test/unittest/core/pattern/ui_extension/BUILD.gn b/test/unittest/core/pattern/ui_extension/BUILD.gn index 8d9426a662c..c239b4730c3 100644 --- a/test/unittest/core/pattern/ui_extension/BUILD.gn +++ b/test/unittest/core/pattern/ui_extension/BUILD.gn @@ -57,6 +57,7 @@ ace_unittest("ui_extension_component_test_ng") { "window_manager:libwm", "window_manager:scene_session", "window_manager:scene_session_manager", + "atomicservice_basic_engine:hagserviceability_client", ] } } -- Gitee From e37f76121a4a1ef084d8a704459f78f29694e97b Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Tue, 2 Jul 2024 11:53:34 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- .../window_scene/scene/window_pattern.cpp | 44 ++++++++++++------- .../window_scene/scene/window_pattern.h | 6 +-- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp index fb8437d49cc..8aa7de71dd6 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp @@ -47,6 +47,9 @@ constexpr uint32_t TEXT_MAX_LINE = 2; constexpr uint32_t IMAGE_NODE_SIZE = 72; constexpr uint32_t IMAGE_NODE_OFFSET = -36; constexpr uint32_t ANIMATION_DURATION = 1750; + +constexpr uint32_t COLOR_TRANSLUCENT_WHITE = 0x66ffffff; +constexpr Dimension SNAPSHOT_RADIUS = 16.0_vp; } // namespace class LifecycleListener : public Rosen::ILifecycleListener { @@ -209,24 +212,17 @@ void WindowPattern::CreateAppWindow() } } -RefPtr WindowPattern::BuildTextNode(std::string appNameInfo) { +RefPtr WindowPattern::BuildTextNode(const std::string& appNameInfo) +{ auto textNode = FrameNode::CreateFrameNode( V2::TEXT_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); CHECK_NULL_RETURN(textNode, nullptr); + // set size auto textLayoutProperty = textNode->GetLayoutProperty(); CHECK_NULL_RETURN(textLayoutProperty, nullptr); - auto textContext = AceType::DynamicCast(textNode->GetRenderContext()); - CHECK_NULL_RETURN(textContext, nullptr); - // set size auto textNodeHeight = CalcLength(Dimension(TEXT_NODE_HEIGHT, DimensionUnit::VP)); auto textNodeWidth = CalcLength(Dimension(HALF_PERCENT_TAG, DimensionUnit::PERCENT)); textLayoutProperty->UpdateUserDefinedIdealSize(CalcSize(textNodeWidth, textNodeHeight)); - // set position - double textOffsetY = Dimension(TEXT_OFFSET_Y, DimensionUnit::VP).ConvertToPx(); - auto basePositionX = Dimension(BASE_X_OFFSET, DimensionUnit::PERCENT); - auto basePositionY = Dimension(BASE_Y_OFFSET, DimensionUnit::PERCENT); - textContext->UpdatePosition(OffsetT(basePositionX, basePositionY)); - textContext->SetTranslate(0, textOffsetY, 0); // set basic attributions textLayoutProperty->UpdateContent(appNameInfo); textLayoutProperty->UpdateAlignment(Alignment::TOP_CENTER); @@ -235,12 +231,23 @@ RefPtr WindowPattern::BuildTextNode(std::string appNameInfo) { textLayoutProperty->UpdateMaxLines(TEXT_MAX_LINE); textLayoutProperty->UpdateTextOverflow(TextOverflow::ELLIPSIS); textLayoutProperty->UpdateTextAlign(TextAlign::CENTER); + // set position + double textOffsetY = Dimension(TEXT_OFFSET_Y, DimensionUnit::VP).ConvertToPx(); + auto basePositionX = Dimension(BASE_X_OFFSET, DimensionUnit::PERCENT); + auto basePositionY = Dimension(BASE_Y_OFFSET, DimensionUnit::PERCENT); + auto textContext = AceType::DynamicCast(textNode->GetRenderContext()); + CHECK_NULL_RETURN(textContext, nullptr); + textContext->UpdatePosition(OffsetT(basePositionX, basePositionY)); + textContext->SetTranslate(0, textOffsetY, 0); textNode->MarkModifyDone(); return textNode; } -RefPtr WindowPattern::BuildAnimateNode(std::string base64Resource) { +RefPtr WindowPattern::BuildAnimateNode(const std::string& base64Resource) +{ + CHECK_NULL_RETURN(session_, nullptr); const auto& sessionInfo = session_->GetSessionInfo(); + CHECK_NULL_RETURN(sessionInfo, nullptr); auto testImageSource = ImageSourceInfo( base64Resource, sessionInfo.bundleName_, sessionInfo.moduleName_); auto animateNode = FrameNode::CreateFrameNode( @@ -282,8 +289,11 @@ RefPtr WindowPattern::BuildAnimateNode(std::string base64Resource) { return animateNode; } -RefPtr WindowPattern::BuildStaticImageNode(std::string base64Resource) { +RefPtr WindowPattern::BuildStaticImageNode(const std::string& base64Resource) +{ + CHECK_NULL_RETURN(session_, nullptr); const auto& sessionInfo = session_->GetSessionInfo(); + CHECK_NULL_RETURN(sessionInfo, nullptr); auto testImageSource = ImageSourceInfo( base64Resource, sessionInfo.bundleName_, sessionInfo.moduleName_); auto staticNode = FrameNode::CreateFrameNode( @@ -316,12 +326,15 @@ RefPtr WindowPattern::BuildStaticImageNode(std::string base64Resource return staticNode; } -void WindowPattern::CreateASStartingWindow() { +void WindowPattern::CreateASStartingWindow() +{ auto host = GetHost(); CHECK_NULL_VOID(host); ACE_SCOPED_TRACE("CreateASStartingWindow[id:%d][self:%d]", session_->GetPersistentId(), host->GetId()); - + + CHECK_NULL_RETURN(session_, nullptr); const auto& sessionInfo = session_->GetSessionInfo(); + CHECK_NULL_RETURN(sessionInfo, nullptr); // get atomic service resources AtomicserviceIconInfo atomicserviceIconInfo; HagServiceablityClient::GetInstance()->GetAtomicserviceIconInfo(sessionInfo.bundleName_, atomicserviceIconInfo); @@ -334,7 +347,8 @@ void WindowPattern::CreateASStartingWindow() { auto asStartingLayoutProperty = startingWindow_->GetLayoutProperty(); asStartingLayoutProperty->UpdateMeasureType(MeasureType::MATCH_PARENT); startingWindow_->SetHitTestMode(HitTestMode::HTMNONE); - startingWindow_->GetRenderContext()->UpdateBackgroundColor(SystemProperties::GetColorMode() == ColorMode::DARK ? Color::BLACK : Color::WHITE); + startingWindow_->GetRenderContext()->UpdateBackgroundColor( + SystemProperties::GetColorMode() == ColorMode::DARK ? Color::BLACK : Color::WHITE); auto staticNode = BuildStaticImageNode(circleIcon); auto animateNode = BuildAnimateNode(eyelashRingIcon); diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h index ffec1f14e05..6532d303532 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h @@ -53,9 +53,9 @@ protected: void RegisterLifecycleListener(); void UnregisterLifecycleListener(); - RefPtr BuildTextNode(std::string appNameInfo); - RefPtr BuildAnimateNode(std::string base64Resource); - RefPtr BuildStaticImageNode(std::string base64Resource); + RefPtr BuildTextNode(const std::string& appNameInfo); + RefPtr BuildAnimateNode(const std::string& base64Resource); + RefPtr BuildStaticImageNode(const std::string& base64Resource); void CreateASStartingWindow(); void CreateAppWindow(); -- Gitee From 9b182fae6e8c8ed71a96d8d164da1fe2e755c2ec Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Tue, 2 Jul 2024 14:35:45 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- .../pattern/window_scene/scene/window_pattern.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp index 675caa698dc..b7e29416f75 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp @@ -332,19 +332,22 @@ void WindowPattern::CreateASStartingWindow() CHECK_NULL_VOID(host); ACE_SCOPED_TRACE("CreateASStartingWindow[id:%d][self:%d]", session_->GetPersistentId(), host->GetId()); - CHECK_NULL_RETURN(session_, nullptr); + CHECK_NULL_VOID(session_); const auto& sessionInfo = session_->GetSessionInfo(); - CHECK_NULL_RETURN(sessionInfo, nullptr); + CHECK_NULL_VOID(sessionInfo); // get atomic service resources AtomicserviceIconInfo atomicserviceIconInfo; HagServiceablityClient::GetInstance()->GetAtomicserviceIconInfo(sessionInfo.bundleName_, atomicserviceIconInfo); + CHECK_NULL_VOID(atomicserviceIconInfo); auto appNameInfo = atomicserviceIconInfo.GetAppName(); auto eyelashRingIcon = atomicserviceIconInfo.GetEyelashRingIcon(); auto circleIcon = atomicserviceIconInfo.GetCircleIcon(); startingWindow_ = FrameNode::CreateFrameNode( V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); + CHECK_NULL_VOID(startingWindow_); auto asStartingLayoutProperty = startingWindow_->GetLayoutProperty(); + CHECK_NULL_VOID(asStartingLayoutProperty); asStartingLayoutProperty->UpdateMeasureType(MeasureType::MATCH_PARENT); startingWindow_->SetHitTestMode(HitTestMode::HTMNONE); startingWindow_->GetRenderContext()->UpdateBackgroundColor( @@ -362,6 +365,7 @@ void WindowPattern::CreateASStartingWindow() void WindowPattern::CreateStartingWindow() { + CHECK_NULL_VOID(sessionInfo); if (sessionInfo.isAtomicService) { CreateASStartingWindow(); return; -- Gitee From 0cfc638cfad0e4344a40436ec29ebebc39d8b9db Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Tue, 2 Jul 2024 14:42:12 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- .../pattern/window_scene/scene/window_pattern.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp index b7e29416f75..121707279f8 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp @@ -47,6 +47,8 @@ constexpr uint32_t TEXT_MAX_LINE = 2; constexpr uint32_t IMAGE_NODE_SIZE = 72; constexpr uint32_t IMAGE_NODE_OFFSET = -36; constexpr uint32_t ANIMATION_DURATION = 1750; +const Rosen::RSAnimationTimingCurve NODE_ANIMATION_TIMING_CURVE = + Rosen::RSAnimationTimingCurve::CreateCubicCurve(0.40f, 0.08f, 0.60f, 0.92f); constexpr uint32_t COLOR_TRANSLUCENT_WHITE = 0x66ffffff; constexpr Dimension SNAPSHOT_RADIUS = 16.0_vp; @@ -281,8 +283,7 @@ RefPtr WindowPattern::BuildAnimateNode(const std::string& base64Resou animateContext->UpdateTransformRotate(Vector5F(0.0f, 0.0f, 1.0f, 0.0f, 0.0f)); protocol.SetDuration(ANIMATION_DURATION); protocol.SetRepeatCount(-1); - auto curve = Rosen::RSAnimationTimingCurve::CreateCubicCurve(0.40, 0.08, 0.60, 0.92); - Rosen::RSNode::Animate(protocol, curve, [animateContext] { + Rosen::RSNode::Animate(protocol, NODE_ANIMATION_TIMING_CURVE, [animateContext] { animateContext->UpdateTransformRotate(Vector5F(0.0f, 0.0f, 1.0f, ROTATION_ANGLE, 0.0f)); }); animateNode->MarkModifyDone(); -- Gitee From dd951c0508817ff8e7643002e3de2363e86ab212 Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Tue, 2 Jul 2024 15:15:00 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- .../pattern/window_scene/scene/window_pattern.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp index 121707279f8..716066e9ae8 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp @@ -366,8 +366,7 @@ void WindowPattern::CreateASStartingWindow() void WindowPattern::CreateStartingWindow() { - CHECK_NULL_VOID(sessionInfo); - if (sessionInfo.isAtomicService) { + if (sessionInfo && sessionInfo.isAtomicService) { CreateASStartingWindow(); return; } -- Gitee From e49f00cba221887d13398110e95829d34fd4925a Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Wed, 3 Jul 2024 14:53:27 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- .../pattern/window_scene/BUILD.gn | 14 +++++--- .../window_scene/scene/window_pattern.cpp | 35 +++++++++---------- .../core/pattern/ui_extension/BUILD.gn | 7 +++- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn index 2c14adfcf6c..09d64f65f58 100644 --- a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn +++ b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn @@ -18,9 +18,10 @@ if (is_ohos_standard_system) { config("window_scene_config") { visibility = [ ":*" ] - include_dirs = [ - "//vendor/huawei/atomicservicedistribution/hag_serviceability/interface/innerkits/include", - ] + if (defined(global_parts_info) && + defined(global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { + include_dirs = [ "//vendor/huawei/atomicservicedistribution/hag_serviceability/interface/innerkits/include" ] + } } } @@ -62,7 +63,12 @@ build_component_ng("window_scene") { "window_manager:scene_session_manager", "window_manager:screen_session", "window_manager:screen_session_manager_client", - "atomicservice_basic_engine:hagserviceability_client", ] } + + if (defined(global_parts_info) && + defined(global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { + external_deps += [ "atomicservice_basic_engine:hagserviceability_client" ] + defines = [ "ATOMIC_SERVICE_ATTRIBUTION_ENABLE" ] + } } diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp index 716066e9ae8..11bce3f6396 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.cpp @@ -27,15 +27,17 @@ #include "core/components_ng/pattern/window_scene/scene/window_event_process.h" #include "core/components_ng/render/adapter/rosen_render_context.h" #include "core/components_v2/inspector/inspector_constants.h" +#ifdef ATOMIC_SERVICE_ATTRIBUTION_ENABLE #include "hag_serviceability_client.h" - using namespace OHOS::AppExecFwk::AtomicserviceEcologicalRuleManager; +#endif namespace OHOS::Ace::NG { namespace { constexpr uint32_t COLOR_BLACK = 0xff000000; constexpr uint32_t COLOR_WHITE = 0xffffffff; +#ifdef ATOMIC_SERVICE_ATTRIBUTION_ENABLE constexpr float HALF_PERCENT_TAG = 0.5f; constexpr float BASE_X_OFFSET = 0.25f; constexpr float BASE_Y_OFFSET = 0.4f; @@ -45,10 +47,11 @@ constexpr uint32_t TEXT_OFFSET_Y = 44; constexpr uint32_t TEXT_NODE_FONT_SIZE = 16; constexpr uint32_t TEXT_MAX_LINE = 2; constexpr uint32_t IMAGE_NODE_SIZE = 72; -constexpr uint32_t IMAGE_NODE_OFFSET = -36; constexpr uint32_t ANIMATION_DURATION = 1750; +constexpr Dimension IMAGE_NODE_OFFSET = Dimension(-36, DimensionUnit::VP); const Rosen::RSAnimationTimingCurve NODE_ANIMATION_TIMING_CURVE = Rosen::RSAnimationTimingCurve::CreateCubicCurve(0.40f, 0.08f, 0.60f, 0.92f); +#endif constexpr uint32_t COLOR_TRANSLUCENT_WHITE = 0x66ffffff; constexpr Dimension SNAPSHOT_RADIUS = 16.0_vp; @@ -214,6 +217,7 @@ void WindowPattern::CreateAppWindow() } } +#ifdef ATOMIC_SERVICE_ATTRIBUTION_ENABLE RefPtr WindowPattern::BuildTextNode(const std::string& appNameInfo) { auto textNode = FrameNode::CreateFrameNode( @@ -249,7 +253,6 @@ RefPtr WindowPattern::BuildAnimateNode(const std::string& base64Resou { CHECK_NULL_RETURN(session_, nullptr); const auto& sessionInfo = session_->GetSessionInfo(); - CHECK_NULL_RETURN(sessionInfo, nullptr); auto testImageSource = ImageSourceInfo( base64Resource, sessionInfo.bundleName_, sessionInfo.moduleName_); auto animateNode = FrameNode::CreateFrameNode( @@ -268,12 +271,10 @@ RefPtr WindowPattern::BuildAnimateNode(const std::string& base64Resou CHECK_NULL_RETURN(animatePaintProperty, nullptr); animatePaintProperty->UpdateImageInterpolation(ImageInterpolation::HIGH); // set position - auto animateOffsetX = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); - auto animateOffsetY = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); auto basePositionX = Dimension(HALF_PERCENT_TAG, DimensionUnit::PERCENT); auto basePositionY = Dimension(BASE_Y_OFFSET, DimensionUnit::PERCENT); animateContext->UpdatePosition(OffsetT(basePositionX, basePositionY)); - animateContext->SetTranslate(animateOffsetX, animateOffsetY, 0); + animateContext->SetTranslate(IMAGE_NODE_OFFSET.ConvertToPx(), IMAGE_NODE_OFFSET.ConvertToPx(), 0); // set size auto animateNodeHeight = CalcLength(Dimension(IMAGE_NODE_SIZE, DimensionUnit::VP)); auto animateNodeWidth = CalcLength(Dimension(IMAGE_NODE_SIZE, DimensionUnit::VP)); @@ -294,7 +295,6 @@ RefPtr WindowPattern::BuildStaticImageNode(const std::string& base64R { CHECK_NULL_RETURN(session_, nullptr); const auto& sessionInfo = session_->GetSessionInfo(); - CHECK_NULL_RETURN(sessionInfo, nullptr); auto testImageSource = ImageSourceInfo( base64Resource, sessionInfo.bundleName_, sessionInfo.moduleName_); auto staticNode = FrameNode::CreateFrameNode( @@ -312,17 +312,14 @@ RefPtr WindowPattern::BuildStaticImageNode(const std::string& base64R // get context and property auto staticContext = AceType::DynamicCast(staticNode->GetRenderContext()); CHECK_NULL_RETURN(staticContext, nullptr); - staticContext->UpdatePosition(OffsetT(0.0_vp, 0.0_vp)); auto staticPaintProperty = staticNode->GetPaintProperty(); CHECK_NULL_RETURN(staticPaintProperty, nullptr); staticPaintProperty->UpdateImageInterpolation(ImageInterpolation::HIGH); // set position - auto staticOffsetX = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); - auto staticOffsetY = Dimension(IMAGE_NODE_OFFSET, DimensionUnit::VP).ConvertToPx(); auto basePositionX = Dimension(HALF_PERCENT_TAG, DimensionUnit::PERCENT); auto basePositionY = Dimension(BASE_Y_OFFSET, DimensionUnit::PERCENT); staticContext->UpdatePosition(OffsetT(basePositionX, basePositionY)); - staticContext->SetTranslate(staticOffsetX, staticOffsetY, 0); + staticContext->SetTranslate(IMAGE_NODE_OFFSET.ConvertToPx(), IMAGE_NODE_OFFSET.ConvertToPx(), 0); staticNode->MarkModifyDone(); return staticNode; } @@ -335,14 +332,12 @@ void WindowPattern::CreateASStartingWindow() CHECK_NULL_VOID(session_); const auto& sessionInfo = session_->GetSessionInfo(); - CHECK_NULL_VOID(sessionInfo); // get atomic service resources AtomicserviceIconInfo atomicserviceIconInfo; HagServiceablityClient::GetInstance()->GetAtomicserviceIconInfo(sessionInfo.bundleName_, atomicserviceIconInfo); - CHECK_NULL_VOID(atomicserviceIconInfo); - auto appNameInfo = atomicserviceIconInfo.GetAppName(); - auto eyelashRingIcon = atomicserviceIconInfo.GetEyelashRingIcon(); - auto circleIcon = atomicserviceIconInfo.GetCircleIcon(); + const auto& appNameInfo = atomicserviceIconInfo.GetAppName(); + const auto& eyelashRingIcon = atomicserviceIconInfo.GetEyelashRingIcon(); + const auto& circleIcon = atomicserviceIconInfo.GetCircleIcon(); startingWindow_ = FrameNode::CreateFrameNode( V2::IMAGE_ETS_TAG, ElementRegister::GetInstance()->MakeUniqueId(), AceType::MakeRefPtr()); @@ -363,13 +358,17 @@ void WindowPattern::CreateASStartingWindow() startingWindow_->AddChild(textNode); startingWindow_->MarkModifyDone(); } +#endif void WindowPattern::CreateStartingWindow() { - if (sessionInfo && sessionInfo.isAtomicService) { + const auto& sessionInfo = session_->GetSessionInfo(); +#ifdef ATOMIC_SERVICE_ATTRIBUTION_ENABLE + if (sessionInfo.isAtomicService) { CreateASStartingWindow(); return; } +#endif auto host = GetHost(); CHECK_NULL_VOID(host); @@ -382,9 +381,7 @@ void WindowPattern::CreateStartingWindow() std::string startupPagePath; auto backgroundColor = SystemProperties::GetColorMode() == ColorMode::DARK ? COLOR_BLACK : COLOR_WHITE; - const auto& sessionInfo = session_->GetSessionInfo(); Rosen::SceneSessionManager::GetInstance().GetStartupPage(sessionInfo, startupPagePath, backgroundColor); - startingWindow_->GetRenderContext()->UpdateBackgroundColor(Color(backgroundColor)); imageLayoutProperty->UpdateImageSourceInfo( ImageSourceInfo(startupPagePath, sessionInfo.bundleName_, sessionInfo.moduleName_)); diff --git a/test/unittest/core/pattern/ui_extension/BUILD.gn b/test/unittest/core/pattern/ui_extension/BUILD.gn index c239b4730c3..7fee6352f46 100644 --- a/test/unittest/core/pattern/ui_extension/BUILD.gn +++ b/test/unittest/core/pattern/ui_extension/BUILD.gn @@ -57,7 +57,12 @@ ace_unittest("ui_extension_component_test_ng") { "window_manager:libwm", "window_manager:scene_session", "window_manager:scene_session_manager", - "atomicservice_basic_engine:hagserviceability_client", ] } + + if (defined(global_parts_info) && + defined(global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { + external_deps += [ "atomicservice_basic_engine:hagserviceability_client" ] + defines += [ "ATOMIC_SERVICE_ATTRIBUTION_ENABLE" ] + } } -- Gitee From 7498f0a407b30108dbc25faf9efbb7141be5836e Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Wed, 3 Jul 2024 14:55:13 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- .../components_ng/pattern/window_scene/scene/window_pattern.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h index 5b78b0b24b1..755678dd7d5 100644 --- a/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h +++ b/frameworks/core/components_ng/pattern/window_scene/scene/window_pattern.h @@ -53,10 +53,12 @@ protected: void RegisterLifecycleListener(); void UnregisterLifecycleListener(); +#ifdef ATOMIC_SERVICE_ATTRIBUTION_ENABLE RefPtr BuildTextNode(const std::string& appNameInfo); RefPtr BuildAnimateNode(const std::string& base64Resource); RefPtr BuildStaticImageNode(const std::string& base64Resource); void CreateASStartingWindow(); +#endif void CreateAppWindow(); void CreateBlankWindow(); -- Gitee From 5467aec8eb8e3d05d5c99d3758eb68d1c9e1171d Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Wed, 3 Jul 2024 15:48:50 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- .../core/components_ng/pattern/window_scene/BUILD.gn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn index 09d64f65f58..90e4b225d5f 100644 --- a/frameworks/core/components_ng/pattern/window_scene/BUILD.gn +++ b/frameworks/core/components_ng/pattern/window_scene/BUILD.gn @@ -18,8 +18,8 @@ if (is_ohos_standard_system) { config("window_scene_config") { visibility = [ ":*" ] - if (defined(global_parts_info) && - defined(global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { + if (defined(global_parts_info) && defined( + global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { include_dirs = [ "//vendor/huawei/atomicservicedistribution/hag_serviceability/interface/innerkits/include" ] } } @@ -66,8 +66,8 @@ build_component_ng("window_scene") { ] } - if (defined(global_parts_info) && - defined(global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { + if (defined(global_parts_info) && defined( + global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { external_deps += [ "atomicservice_basic_engine:hagserviceability_client" ] defines = [ "ATOMIC_SERVICE_ATTRIBUTION_ENABLE" ] } -- Gitee From 4c0523ac5b9b52201f1f8084e69e69bef2956b0b Mon Sep 17 00:00:00 2001 From: LancelotOnTheLake Date: Wed, 3 Jul 2024 16:10:07 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E5=85=83=E6=9C=8D=E5=8A=A1=E5=90=AF?= =?UTF-8?q?=E5=8A=A8=E5=8A=A8=E6=95=88=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: LancelotOnTheLake --- test/unittest/core/pattern/ui_extension/BUILD.gn | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unittest/core/pattern/ui_extension/BUILD.gn b/test/unittest/core/pattern/ui_extension/BUILD.gn index 7fee6352f46..29bbd6eee4b 100644 --- a/test/unittest/core/pattern/ui_extension/BUILD.gn +++ b/test/unittest/core/pattern/ui_extension/BUILD.gn @@ -59,9 +59,9 @@ ace_unittest("ui_extension_component_test_ng") { "window_manager:scene_session_manager", ] } - - if (defined(global_parts_info) && - defined(global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { + + if (defined(global_parts_info) && defined( + global_parts_info.atomicservicedistribution_atomicservice_basic_engine)) { external_deps += [ "atomicservice_basic_engine:hagserviceability_client" ] defines += [ "ATOMIC_SERVICE_ATTRIBUTION_ENABLE" ] } -- Gitee