From 9a86f3012ebf8575798fdd670425d68dd95ea0ea Mon Sep 17 00:00:00 2001 From: liusensen Date: Mon, 22 Jul 2024 19:48:28 +0800 Subject: [PATCH 01/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- .../session/host/src/keyboard_session.cpp | 13 +++++++++++++ window_scene/session/host/src/scene_session.cpp | 16 ++++++++++++++++ window_scene/session/host/src/session.cpp | 13 +++++++++++++ window_scene/session/host/src/sub_session.cpp | 14 ++++++++++++++ window_scene/session/host/src/system_session.cpp | 13 +++++++++++++ 5 files changed, 69 insertions(+) diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 88e23d63d1..3160278af0 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -67,6 +67,12 @@ SessionGravity KeyboardSession::GetKeyboardGravity() const WSError KeyboardSession::Show(sptr property) { + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); if (!session) { @@ -86,6 +92,13 @@ WSError KeyboardSession::Show(sptr property) WSError KeyboardSession::Hide() { + if (GetSessionProperty() && + GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); if (!session) { diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 3937fd4cc6..56c2a97035 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -146,6 +146,12 @@ WSError SceneSession::Reconnect(const sptr& sessionStage, const s WSError SceneSession::Foreground(sptr property, bool isFromClient) { // return when screen is locked and show without ShowWhenLocked flag + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } if (false && GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED) && !IsShowWhenLocked() && sessionInfo_.bundleName_.find("startupguide") == std::string::npos && @@ -204,6 +210,13 @@ WSError SceneSession::Foreground(sptr property, bool isFr WSError SceneSession::Background(bool isFromClient) { + if (GetSessionProperty() && + GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } if (isFromClient && SessionHelper::IsMainWindow(GetWindowType())) { int32_t callingPid = IPCSkeleton::GetCallingPid(); if (callingPid != -1 && callingPid != GetCallingPid()) { @@ -2752,6 +2765,9 @@ static bool IsNeedSystemPermissionByAction(WSPropertyChangeAction action, case WSPropertyChangeAction::ACTION_UPDATE_RAISEENABLED: case WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: return true; + case WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG: + return (property != nullptr) && + (property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)); case WSPropertyChangeAction::ACTION_UPDATE_FLAGS: { uint32_t oldFlags = sessionProperty->GetWindowFlags(); uint32_t flags = property->GetWindowFlags(); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 272311fbaf..14ed7dd712 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -939,6 +939,12 @@ WSError Session::Reconnect(const sptr& sessionStage, const sptr property, bool isFromClient) { + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } HandleDialogForeground(); SessionState state = GetSessionState(); TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d, state:%{public}u", @@ -1016,6 +1022,13 @@ void Session::HandleDialogForeground() WSError Session::Background(bool isFromClient) { + if (GetSessionProperty() && + GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } HandleDialogBackground(); SessionState state = GetSessionState(); TLOGI(WmsLogTag::WMS_LIFE, "Background session, id: %{public}d, state: %{public}" PRIu32, GetPersistentId(), diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index 890dbe7340..0cfaefd012 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -16,6 +16,7 @@ #include "session/host/include/sub_session.h" #include "screen_session_manager/include/screen_session_manager_client.h" +#include "common/include/session_permission.h" #include "key_event.h" #include "window_helper.h" #include "parameters.h" @@ -47,6 +48,12 @@ SubSession::~SubSession() WSError SubSession::Show(sptr property) { + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); if (!session) { @@ -71,6 +78,13 @@ WSError SubSession::Show(sptr property) WSError SubSession::Hide() { + if (GetSessionProperty() && + GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); if (!session) { diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index 0d2ef86280..b4a9fde7c6 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -75,6 +75,12 @@ void SystemSession::UpdateCameraWindowStatus(bool isShowing) WSError SystemSession::Show(sptr property) { + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } auto type = GetWindowType(); if (((type == WindowType::WINDOW_TYPE_TOAST) || (type == WindowType::WINDOW_TYPE_FLOAT)) && !SessionPermission::IsSystemCalling()) { @@ -110,6 +116,13 @@ WSError SystemSession::Show(sptr property) WSError SystemSession::Hide() { + if (GetSessionProperty() && + GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } auto type = GetWindowType(); if (NeedSystemPermission(type)) { // Do not need to verify the permission to hide the input method status bar. -- Gitee From 12f0cfc099885e3c381ac9a7d42b2531884fe6e3 Mon Sep 17 00:00:00 2001 From: liusensen Date: Mon, 22 Jul 2024 20:34:36 +0800 Subject: [PATCH 02/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/src/scene_session.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 56c2a97035..be59e1c669 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2766,8 +2766,7 @@ static bool IsNeedSystemPermissionByAction(WSPropertyChangeAction action, case WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: return true; case WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG: - return (property != nullptr) && - (property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)); + return (property != nullptr) && (property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)); case WSPropertyChangeAction::ACTION_UPDATE_FLAGS: { uint32_t oldFlags = sessionProperty->GetWindowFlags(); uint32_t flags = property->GetWindowFlags(); -- Gitee From ffe5f62fb5340f7b531f5fb3f5f20767cfef9e3c Mon Sep 17 00:00:00 2001 From: liusensen Date: Tue, 23 Jul 2024 10:41:50 +0800 Subject: [PATCH 03/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/include/scene_session.h | 1 + window_scene/session/host/src/scene_session.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index b4a50a4793..ea6ea9d237 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -146,6 +146,7 @@ public: const std::shared_ptr& surfaceNode, sptr property = nullptr, sptr token = nullptr, int32_t pid = -1, int32_t uid = -1); WSError Foreground(sptr property, bool isFromClient = false) override; + WSError ForegroundTask(sptr property); WSError Background(bool isFromClient = false) override; WSError BackgroundTask(const bool isSaveSnapshot = true); WSError Disconnect(bool isFromClient = false) override; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index be59e1c669..8362d576dd 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -169,7 +169,11 @@ WSError SceneSession::Foreground(sptr property, bool isFr return WSError::WS_OK; } } + return ForegroundTask(property); +} +WSError SceneSession::ForegroundTask(sptr property) +{ auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); if (!session) { @@ -2766,7 +2770,8 @@ static bool IsNeedSystemPermissionByAction(WSPropertyChangeAction action, case WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: return true; case WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG: - return (property != nullptr) && (property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)); + return (property != nullptr) && + (property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)); case WSPropertyChangeAction::ACTION_UPDATE_FLAGS: { uint32_t oldFlags = sessionProperty->GetWindowFlags(); uint32_t flags = property->GetWindowFlags(); -- Gitee From 6af066f7449046e5e89e282e9bb2e02f2cd30233 Mon Sep 17 00:00:00 2001 From: liusensen Date: Tue, 23 Jul 2024 17:19:54 +0800 Subject: [PATCH 04/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/src/keyboard_session.cpp | 4 ++-- window_scene/session/host/src/scene_session.cpp | 4 ++-- window_scene/session/host/src/session.cpp | 4 ++-- window_scene/session/host/src/sub_session.cpp | 4 ++-- window_scene/session/host/src/system_session.cpp | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 3160278af0..a80e0d1641 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -92,8 +92,8 @@ WSError KeyboardSession::Show(sptr property) WSError KeyboardSession::Hide() { - if (GetSessionProperty() && - GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + auto property = GetSessionProperty(); + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); return WSError::WS_ERROR_NOT_SYSTEM_APP; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 8362d576dd..31a68e8496 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -214,8 +214,8 @@ WSError SceneSession::ForegroundTask(sptr property) WSError SceneSession::Background(bool isFromClient) { - if (GetSessionProperty() && - GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + auto property = GetSessionProperty(); + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); return WSError::WS_ERROR_NOT_SYSTEM_APP; diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 14ed7dd712..17cc03abf2 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1022,8 +1022,8 @@ void Session::HandleDialogForeground() WSError Session::Background(bool isFromClient) { - if (GetSessionProperty() && - GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + auto property = GetSessionProperty(); + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); return WSError::WS_ERROR_NOT_SYSTEM_APP; diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index 0cfaefd012..b8984fd657 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -78,8 +78,8 @@ WSError SubSession::Show(sptr property) WSError SubSession::Hide() { - if (GetSessionProperty() && - GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + auto property = GetSessionProperty(); + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); return WSError::WS_ERROR_NOT_SYSTEM_APP; diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index b4a9fde7c6..ee07de4b27 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -116,8 +116,8 @@ WSError SystemSession::Show(sptr property) WSError SystemSession::Hide() { - if (GetSessionProperty() && - GetSessionProperty()->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + auto property = GetSessionProperty(); + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); return WSError::WS_ERROR_NOT_SYSTEM_APP; -- Gitee From a489f651a1eeb31b67fa6186ecd58ee468f7bbd7 Mon Sep 17 00:00:00 2001 From: liusensen Date: Tue, 23 Jul 2024 19:59:20 +0800 Subject: [PATCH 05/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/include/session.h | 1 + .../session/host/src/keyboard_session.cpp | 16 ++++------ .../session/host/src/scene_session.cpp | 16 ++++------ window_scene/session/host/src/session.cpp | 31 +++++++++++++------ window_scene/session/host/src/sub_session.cpp | 16 ++++------ .../session/host/src/system_session.cpp | 16 ++++------ 6 files changed, 46 insertions(+), 50 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 176722a9d0..bc0e740dfb 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -437,6 +437,7 @@ protected: virtual void UpdateSessionState(SessionState state); void NotifySessionStateChange(const SessionState& state); void UpdateSessionTouchable(bool touchable); + WSError IsAnimationBySystemCallingOrHdcd(sptr property); WSRectF UpdateTopBottomArea(const WSRectF& rect, MMI::WindowArea area); WSRectF UpdateLeftRightArea(const WSRectF& rect, MMI::WindowArea area); diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index a80e0d1641..0ed192271b 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -67,11 +67,9 @@ SessionGravity KeyboardSession::GetKeyboardGravity() const WSError KeyboardSession::Show(sptr property) { - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); @@ -93,11 +91,9 @@ WSError KeyboardSession::Show(sptr property) WSError KeyboardSession::Hide() { auto property = GetSessionProperty(); - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 31a68e8496..357c3b7ae6 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -146,11 +146,9 @@ WSError SceneSession::Reconnect(const sptr& sessionStage, const s WSError SceneSession::Foreground(sptr property, bool isFromClient) { // return when screen is locked and show without ShowWhenLocked flag - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } if (false && GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED) && !IsShowWhenLocked() && @@ -215,11 +213,9 @@ WSError SceneSession::ForegroundTask(sptr property) WSError SceneSession::Background(bool isFromClient) { auto property = GetSessionProperty(); - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } if (isFromClient && SessionHelper::IsMainWindow(GetWindowType())) { int32_t callingPid = IPCSkeleton::GetCallingPid(); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 17cc03abf2..8ed1a2a891 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -444,6 +444,21 @@ void Session::UpdateSessionTouchable(bool touchable) NotifySessionTouchableChange(touchable); } +WSError Session::IsAnimationBySystemCallingOrHdcd(sptr property) +{ + if (property == nullptr) { + TLOGE(WmsLogTag::WMS_LIFE, "property is null"); + return WSError::WS_ERROR_NULLPTR; + } + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); + return WSError::WS_ERROR_NOT_SYSTEM_APP; + } + } + return WSError::WS_OK; +} + WSError Session::SetFocusable(bool isFocusable) { WLOGFI("SetFocusable id: %{public}d, focusable: %{public}d", GetPersistentId(), isFocusable); @@ -939,11 +954,9 @@ WSError Session::Reconnect(const sptr& sessionStage, const sptr property, bool isFromClient) { - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } HandleDialogForeground(); SessionState state = GetSessionState(); @@ -1023,11 +1036,9 @@ void Session::HandleDialogForeground() WSError Session::Background(bool isFromClient) { auto property = GetSessionProperty(); - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } HandleDialogBackground(); SessionState state = GetSessionState(); diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index b8984fd657..001c8c6707 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -48,11 +48,9 @@ SubSession::~SubSession() WSError SubSession::Show(sptr property) { - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); @@ -79,11 +77,9 @@ WSError SubSession::Show(sptr property) WSError SubSession::Hide() { auto property = GetSessionProperty(); - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index ee07de4b27..1a6ddd2636 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -75,11 +75,9 @@ void SystemSession::UpdateCameraWindowStatus(bool isShowing) WSError SystemSession::Show(sptr property) { - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } auto type = GetWindowType(); if (((type == WindowType::WINDOW_TYPE_TOAST) || (type == WindowType::WINDOW_TYPE_FLOAT)) && @@ -117,11 +115,9 @@ WSError SystemSession::Show(sptr property) WSError SystemSession::Hide() { auto property = GetSessionProperty(); - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } + WSError errCode = IsAnimationBySystemCallingOrHdcd(property); + if (errCode != WSError::WS_OK) { + return errCode; } auto type = GetWindowType(); if (NeedSystemPermission(type)) { -- Gitee From 9f3e9c311bc83527cb67d00e3192bb3b95d024ae Mon Sep 17 00:00:00 2001 From: liusensen Date: Tue, 23 Jul 2024 20:33:06 +0800 Subject: [PATCH 06/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/include/session.h | 2 +- .../session/host/src/keyboard_session.cpp | 11 ++++------ .../session/host/src/scene_session.cpp | 11 ++++------ window_scene/session/host/src/session.cpp | 21 +++++++------------ window_scene/session/host/src/sub_session.cpp | 11 ++++------ .../session/host/src/system_session.cpp | 11 ++++------ 6 files changed, 24 insertions(+), 43 deletions(-) diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index bc0e740dfb..448be696bb 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -437,7 +437,7 @@ protected: virtual void UpdateSessionState(SessionState state); void NotifySessionStateChange(const SessionState& state); void UpdateSessionTouchable(bool touchable); - WSError IsAnimationBySystemCallingOrHdcd(sptr property); + bool CheckPermissionWithPropertyAnimation(sptr property) const; WSRectF UpdateTopBottomArea(const WSRectF& rect, MMI::WindowArea area); WSRectF UpdateLeftRightArea(const WSRectF& rect, MMI::WindowArea area); diff --git a/window_scene/session/host/src/keyboard_session.cpp b/window_scene/session/host/src/keyboard_session.cpp index 0ed192271b..370599002b 100644 --- a/window_scene/session/host/src/keyboard_session.cpp +++ b/window_scene/session/host/src/keyboard_session.cpp @@ -67,9 +67,8 @@ SessionGravity KeyboardSession::GetKeyboardGravity() const WSError KeyboardSession::Show(sptr property) { - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(property)) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); @@ -90,10 +89,8 @@ WSError KeyboardSession::Show(sptr property) WSError KeyboardSession::Hide() { - auto property = GetSessionProperty(); - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 357c3b7ae6..df6cdd32de 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -146,9 +146,8 @@ WSError SceneSession::Reconnect(const sptr& sessionStage, const s WSError SceneSession::Foreground(sptr property, bool isFromClient) { // return when screen is locked and show without ShowWhenLocked flag - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(property)) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } if (false && GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED) && !IsShowWhenLocked() && @@ -212,10 +211,8 @@ WSError SceneSession::ForegroundTask(sptr property) WSError SceneSession::Background(bool isFromClient) { - auto property = GetSessionProperty(); - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } if (isFromClient && SessionHelper::IsMainWindow(GetWindowType())) { int32_t callingPid = IPCSkeleton::GetCallingPid(); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 8ed1a2a891..fddd2b5047 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -444,19 +444,15 @@ void Session::UpdateSessionTouchable(bool touchable) NotifySessionTouchableChange(touchable); } -WSError Session::IsAnimationBySystemCallingOrHdcd(sptr property) +bool Session::CheckPermissionWithPropertyAnimation(sptr property) const { - if (property == nullptr) { - TLOGE(WmsLogTag::WMS_LIFE, "property is null"); - return WSError::WS_ERROR_NULLPTR; - } if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return WSError::WS_ERROR_NOT_SYSTEM_APP; + return false; } } - return WSError::WS_OK; + return true; } WSError Session::SetFocusable(bool isFocusable) @@ -954,9 +950,8 @@ WSError Session::Reconnect(const sptr& sessionStage, const sptr property, bool isFromClient) { - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(property)) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } HandleDialogForeground(); SessionState state = GetSessionState(); @@ -1035,10 +1030,8 @@ void Session::HandleDialogForeground() WSError Session::Background(bool isFromClient) { - auto property = GetSessionProperty(); - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } HandleDialogBackground(); SessionState state = GetSessionState(); diff --git a/window_scene/session/host/src/sub_session.cpp b/window_scene/session/host/src/sub_session.cpp index 001c8c6707..745fd96263 100644 --- a/window_scene/session/host/src/sub_session.cpp +++ b/window_scene/session/host/src/sub_session.cpp @@ -48,9 +48,8 @@ SubSession::~SubSession() WSError SubSession::Show(sptr property) { - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(property)) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); @@ -76,10 +75,8 @@ WSError SubSession::Show(sptr property) WSError SubSession::Hide() { - auto property = GetSessionProperty(); - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } auto task = [weakThis = wptr(this)]() { auto session = weakThis.promote(); diff --git a/window_scene/session/host/src/system_session.cpp b/window_scene/session/host/src/system_session.cpp index 1a6ddd2636..a979ede0ec 100644 --- a/window_scene/session/host/src/system_session.cpp +++ b/window_scene/session/host/src/system_session.cpp @@ -75,9 +75,8 @@ void SystemSession::UpdateCameraWindowStatus(bool isShowing) WSError SystemSession::Show(sptr property) { - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(property)) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } auto type = GetWindowType(); if (((type == WindowType::WINDOW_TYPE_TOAST) || (type == WindowType::WINDOW_TYPE_FLOAT)) && @@ -114,10 +113,8 @@ WSError SystemSession::Show(sptr property) WSError SystemSession::Hide() { - auto property = GetSessionProperty(); - WSError errCode = IsAnimationBySystemCallingOrHdcd(property); - if (errCode != WSError::WS_OK) { - return errCode; + if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { + return WSError::WS_ERROR_NOT_SYSTEM_APP; } auto type = GetWindowType(); if (NeedSystemPermission(type)) { -- Gitee From b5060ac6af259cc4f1cc89fd9f6aa42552eb9e75 Mon Sep 17 00:00:00 2001 From: liusensen Date: Tue, 23 Jul 2024 21:33:45 +0800 Subject: [PATCH 07/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- utils/src/permission.cpp | 5 ++--- .../session/host/include/scene_session.h | 2 +- window_scene/session/host/include/session.h | 2 +- .../session/host/src/scene_session.cpp | 4 ++-- window_scene/session/host/src/session.cpp | 22 +++++++++---------- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/utils/src/permission.cpp b/utils/src/permission.cpp index bae17d6dc1..5fbc2b7180 100644 --- a/utils/src/permission.cpp +++ b/utils/src/permission.cpp @@ -63,10 +63,9 @@ bool Permission::IsSystemCalling(bool isLocalSysCalling) if (IsSystemServiceCalling(false, isLocalSysCalling)) { return true; } - uint64_t accessTokenIDEx = isLocalSysCalling ? + uint64_t tokenId = isLocalSysCalling ? IPCSkeleton::GetSelfTokenID() : IPCSkeleton::GetCallingFullTokenID(); - bool isSystemApp = Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(accessTokenIDEx); - return isSystemApp; + return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(tokenId); } bool Permission::CheckCallingPermission(const std::string& permission) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index ea6ea9d237..b80504f653 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -146,7 +146,6 @@ public: const std::shared_ptr& surfaceNode, sptr property = nullptr, sptr token = nullptr, int32_t pid = -1, int32_t uid = -1); WSError Foreground(sptr property, bool isFromClient = false) override; - WSError ForegroundTask(sptr property); WSError Background(bool isFromClient = false) override; WSError BackgroundTask(const bool isSaveSnapshot = true); WSError Disconnect(bool isFromClient = false) override; @@ -376,6 +375,7 @@ private: void GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea); void HandleStyleEvent(MMI::WindowArea area) override; WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY); + WSError ForegroundTask(const sptr& property); WSError HandlePointerStyle(const std::shared_ptr& pointerEvent); #ifdef DEVICE_STATUS_ENABLE diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 448be696bb..d25ac29a08 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -437,7 +437,7 @@ protected: virtual void UpdateSessionState(SessionState state); void NotifySessionStateChange(const SessionState& state); void UpdateSessionTouchable(bool touchable); - bool CheckPermissionWithPropertyAnimation(sptr property) const; + bool CheckPermissionWithPropertyAnimation(const sptr& property) const; WSRectF UpdateTopBottomArea(const WSRectF& rect, MMI::WindowArea area); WSRectF UpdateLeftRightArea(const WSRectF& rect, MMI::WindowArea area); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index df6cdd32de..0a93fab6da 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -145,10 +145,10 @@ WSError SceneSession::Reconnect(const sptr& sessionStage, const s WSError SceneSession::Foreground(sptr property, bool isFromClient) { - // return when screen is locked and show without ShowWhenLocked flag if (!CheckPermissionWithPropertyAnimation(property)) { return WSError::WS_ERROR_NOT_SYSTEM_APP; } + // return when screen is locked and show without ShowWhenLocked flag if (false && GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && GetStateFromManager(ManagerState::MANAGER_STATE_SCREEN_LOCKED) && !IsShowWhenLocked() && sessionInfo_.bundleName_.find("startupguide") == std::string::npos && @@ -169,7 +169,7 @@ WSError SceneSession::Foreground(sptr property, bool isFr return ForegroundTask(property); } -WSError SceneSession::ForegroundTask(sptr property) +WSError SceneSession::ForegroundTask(const sptr& property) { auto task = [weakThis = wptr(this), property]() { auto session = weakThis.promote(); diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index fddd2b5047..4669e18beb 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -444,17 +444,6 @@ void Session::UpdateSessionTouchable(bool touchable) NotifySessionTouchableChange(touchable); } -bool Session::CheckPermissionWithPropertyAnimation(sptr property) const -{ - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no right"); - return false; - } - } - return true; -} - WSError Session::SetFocusable(bool isFocusable) { WLOGFI("SetFocusable id: %{public}d, focusable: %{public}d", GetPersistentId(), isFocusable); @@ -2902,4 +2891,15 @@ std::shared_ptr Session::GetSnapshotPixelMap(const float oriSca } return nullptr; } + +bool Session::CheckPermissionWithPropertyAnimation(const sptr& property) const +{ + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no permission"); + return false; + } + } + return true; +} } // namespace OHOS::Rosen -- Gitee From 09c164a706e10041af8adb434da6134d1c079fd7 Mon Sep 17 00:00:00 2001 From: liusensen Date: Tue, 23 Jul 2024 22:24:58 +0800 Subject: [PATCH 08/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/src/scene_session.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 0a93fab6da..ded0d6f90e 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2763,8 +2763,7 @@ static bool IsNeedSystemPermissionByAction(WSPropertyChangeAction action, case WSPropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO: return true; case WSPropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG: - return (property != nullptr) && - (property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)); + return property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM); case WSPropertyChangeAction::ACTION_UPDATE_FLAGS: { uint32_t oldFlags = sessionProperty->GetWindowFlags(); uint32_t flags = property->GetWindowFlags(); -- Gitee From b06b84bba4147e7703102e5df5923ee9840b3835 Mon Sep 17 00:00:00 2001 From: liusensen Date: Wed, 24 Jul 2024 11:13:16 +0800 Subject: [PATCH 09/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- .../session/host/include/scene_session.h | 5 ++++- window_scene/session/host/include/session.h | 1 - window_scene/session/host/src/scene_session.cpp | 11 +++++++++++ window_scene/session/host/src/session.cpp | 17 ----------------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index b80504f653..9b3554311f 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -351,6 +351,7 @@ protected: void SetMoveDragCallback(); std::string GetRatioPreferenceKey(); WSError NotifyClientToUpdateRectTask(std::shared_ptr rsTransaction); + bool CheckPermissionWithPropertyAnimation(const sptr& property) const; std::string GetRectInfo(const WSRect& rect) { @@ -375,9 +376,11 @@ private: void GetAINavigationBarArea(WSRect rect, AvoidArea& avoidArea); void HandleStyleEvent(MMI::WindowArea area) override; WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY); - WSError ForegroundTask(const sptr& property); WSError HandlePointerStyle(const std::shared_ptr& pointerEvent); + //session lifecycle funcs + WSError ForegroundTask(const sptr& property); + #ifdef DEVICE_STATUS_ENABLE void RotateDragWindow(std::shared_ptr rsTransaction); #endif // DEVICE_STATUS_ENABLE diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index d25ac29a08..176722a9d0 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -437,7 +437,6 @@ protected: virtual void UpdateSessionState(SessionState state); void NotifySessionStateChange(const SessionState& state); void UpdateSessionTouchable(bool touchable); - bool CheckPermissionWithPropertyAnimation(const sptr& property) const; WSRectF UpdateTopBottomArea(const WSRectF& rect, MMI::WindowArea area); WSRectF UpdateLeftRightArea(const WSRectF& rect, MMI::WindowArea area); diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index ded0d6f90e..878c31eb5e 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -3896,4 +3896,15 @@ int32_t SceneSession::GetStatusBarHeight() TLOGD(WmsLogTag::WMS_IMMS, "StatusBarVectorHeight is %{public}d", height); return height; } + +bool SceneSession::CheckPermissionWithPropertyAnimation(const sptr& property) const +{ + if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { + TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no permission"); + return false; + } + } + return true; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index 4669e18beb..272311fbaf 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -939,9 +939,6 @@ WSError Session::Reconnect(const sptr& sessionStage, const sptr property, bool isFromClient) { - if (!CheckPermissionWithPropertyAnimation(property)) { - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } HandleDialogForeground(); SessionState state = GetSessionState(); TLOGI(WmsLogTag::WMS_LIFE, "id:%{public}d, state:%{public}u", @@ -1019,9 +1016,6 @@ void Session::HandleDialogForeground() WSError Session::Background(bool isFromClient) { - if (!CheckPermissionWithPropertyAnimation(GetSessionProperty())) { - return WSError::WS_ERROR_NOT_SYSTEM_APP; - } HandleDialogBackground(); SessionState state = GetSessionState(); TLOGI(WmsLogTag::WMS_LIFE, "Background session, id: %{public}d, state: %{public}" PRIu32, GetPersistentId(), @@ -2891,15 +2885,4 @@ std::shared_ptr Session::GetSnapshotPixelMap(const float oriSca } return nullptr; } - -bool Session::CheckPermissionWithPropertyAnimation(const sptr& property) const -{ - if (property && property->GetAnimationFlag() == static_cast(WindowAnimation::CUSTOM)) { - if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { - TLOGE(WmsLogTag::WMS_LIFE, "Not system app, no permission"); - return false; - } - } - return true; -} } // namespace OHOS::Rosen -- Gitee From 5b5c3c7b3b0100762039bb44716fc7a95944e040 Mon Sep 17 00:00:00 2001 From: liusensen Date: Wed, 24 Jul 2024 12:37:37 +0800 Subject: [PATCH 10/10] =?UTF-8?q?SystemApi=E6=96=B0=E5=A2=9E=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E7=AB=AF=E6=9D=83=E9=99=90=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: liusensen --- window_scene/session/host/include/scene_session.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index 9b3554311f..7912549321 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -378,7 +378,7 @@ private: WSError HandleEnterWinwdowArea(int32_t windowX, int32_t windowY); WSError HandlePointerStyle(const std::shared_ptr& pointerEvent); - //session lifecycle funcs + // session lifecycle funcs WSError ForegroundTask(const sptr& property); #ifdef DEVICE_STATUS_ENABLE -- Gitee