diff --git a/interfaces/innerkits/wm/window_manager.h b/interfaces/innerkits/wm/window_manager.h index f6a182fdd593b3242db23edf1f7ce6ffacb3cc1b..6d2256c80f03fa21f93a47616549ee4a2bb0ce02 100644 --- a/interfaces/innerkits/wm/window_manager.h +++ b/interfaces/innerkits/wm/window_manager.h @@ -815,7 +815,7 @@ public: * @param focusInfo Focus window info. * @return FocusChangeInfo object about focus window. */ - void GetFocusWindowInfo(FocusChangeInfo& focusInfo); + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID); /** * @brief Dump all session info diff --git a/interfaces/innerkits/wm/window_manager_lite.h b/interfaces/innerkits/wm/window_manager_lite.h index 9f47ad185eee876d808f562cf1b4df8c8bc3ddac..14c7c6b40e5fc8be6c985dc98274400ba2edcedc 100644 --- a/interfaces/innerkits/wm/window_manager_lite.h +++ b/interfaces/innerkits/wm/window_manager_lite.h @@ -87,7 +87,7 @@ public: * @param focusInfo Focus window info. * @return FocusChangeInfo object about focus window. */ - void GetFocusWindowInfo(FocusChangeInfo& focusInfo); + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID); /** * @brief Register drawingcontent changed listener. diff --git a/test/common/mock/mock_window_adapter_lite.h b/test/common/mock/mock_window_adapter_lite.h index 59b021d13a6e4cb8d966eb5e21ab6f89e54e5ff4..65770a9196deea872786d2e26844aeacba832e02 100644 --- a/test/common/mock/mock_window_adapter_lite.h +++ b/test/common/mock/mock_window_adapter_lite.h @@ -23,7 +23,7 @@ namespace OHOS { namespace Rosen { class MockWindowAdapterLite : public WindowAdapterLite { public: - MOCK_METHOD(void, GetFocusWindowInfo, (FocusChangeInfo& focusInfo)); + MOCK_METHOD(void, GetFocusWindowInfo, (FocusChangeInfo& focusInfo, DisplayId displayId)); MOCK_METHOD(void, ClearWindowAdapter, ()); MOCK_METHOD2(RegisterWindowManagerAgent, WMError(WindowManagerAgentType type, const sptr& windowManagerAgent)); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp index 4023247865335e860aebf62f7d10a45d1921b029..f8837814a40761675a641a4f831e3ab7b3e97b80 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.cpp @@ -449,16 +449,18 @@ void JsSceneSessionManager::OnOutsideDownEvent(int32_t x, int32_t y) taskScheduler_->PostMainThreadTask(task, info); } -void JsSceneSessionManager::OnShiftFocus(int32_t persistentId) +void JsSceneSessionManager::OnShiftFocus(int32_t persistentId, DisplayId displayGroupId) { - TLOGD(WmsLogTag::WMS_FOCUS, "[NAPI]"); + TLOGD(WmsLogTag::WMS_FOCUS, "persistentId: %{public}d, displayGroupId: %{public}" PRIu64, + persistentId, displayGroupId); - auto task = [this, persistentId, jsCallBack = GetJSCallback(SHIFT_FOCUS_CB), env = env_]() { + auto task = [this, persistentId, jsCallBack = GetJSCallback(SHIFT_FOCUS_CB), env = env_, displayGroupId]() { if (jsCallBack == nullptr) { TLOGNE(WmsLogTag::WMS_FOCUS, "jsCallBack is nullptr"); return; } - napi_value argv[] = {CreateJsValue(env, persistentId)}; + napi_value argv[] = { CreateJsValue(env, persistentId), + CreateJsValue(env, static_cast(displayGroupId)) }; napi_call_function(env, NapiGetUndefined(env), jsCallBack->GetNapiValue(), ArraySize(argv), argv, nullptr); }; taskScheduler_->PostMainThreadTask(task, "OnShiftFocus, PID:" + std::to_string(persistentId)); @@ -570,9 +572,9 @@ void JsSceneSessionManager::ProcessOutsideDownEvent() void JsSceneSessionManager::ProcessShiftFocus() { - ProcessShiftFocusFunc func = [this](int32_t persistentId) { + ProcessShiftFocusFunc func = [this](int32_t persistentId, DisplayId displayGroupId) { TLOGND(WmsLogTag::WMS_FOCUS, "ProcessShiftFocus called"); - this->OnShiftFocus(persistentId); + this->OnShiftFocus(persistentId, displayGroupId); }; NotifySCBAfterUpdateFocusFunc focusedCallback = [this]() { TLOGND(WmsLogTag::WMS_FOCUS, "scb uicontent focus"); diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h index ded1b66e93f744b8bda7c42ab72ef6a3dc912108..4afdcba243e0da3afda4443b40574eadf232af40 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session_manager.h @@ -130,7 +130,7 @@ public: static napi_value GetInstanceCount(napi_env env, napi_callback_info info); static napi_value GetLastInstanceKey(napi_env env, napi_callback_info info); static napi_value RefreshAppInfo(napi_env env, napi_callback_info info); - + /* * Window Immersive */ @@ -243,7 +243,7 @@ private: void OnCreateKeyboardSession(const sptr& keyboardSession, const sptr& panelSession); void OnOutsideDownEvent(int32_t x, int32_t y); void OnStartUIAbilityError(const uint32_t errorCode); - void OnShiftFocus(int32_t persistentId); + void OnShiftFocus(int32_t persistentId, DisplayId displayGroupId); void OnCallingSessionIdChange(uint32_t callingSessionId); void ProcessCreateSystemSessionRegister(); void ProcessCreateKeyboardSessionRegister(); diff --git a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h index 937497e1c0037c628a8aef1b46435849b8560453..f50acb5a235a143cb16a5a8debb7df3664eb7f98 100644 --- a/window_scene/screen_session_manager_client/include/screen_session_manager_client.h +++ b/window_scene/screen_session_manager_client/include/screen_session_manager_client.h @@ -39,12 +39,19 @@ public: virtual void OnScreenDisconnected(const sptr& screenSession) = 0; }; +class IScreenConnectionChangeListener : public RefBase { +public: + virtual void OnScreenConnected(const sptr& screenSession) = 0; + virtual void OnScreenDisconnected(const sptr& screenSession) = 0; +}; + class ScreenSessionManagerClient : public ScreenSessionManagerClientStub { WM_DECLARE_SINGLE_INSTANCE_BASE(ScreenSessionManagerClient) public: void RegisterScreenConnectionListener(IScreenConnectionListener* listener); void RegisterDisplayChangeListener(const sptr& listener); + void RegisterScreenConnectionChangeListener(const sptr& listener); sptr GetScreenSession(ScreenId screenId) const; std::map GetAllScreensProperties() const; @@ -112,6 +119,9 @@ private: void SetDisplayNodeScreenId(ScreenId screenId, ScreenId displayNodeScreenId) override; void ScreenCaptureNotify(ScreenId mainScreenId, int32_t uid, const std::string& clientName) override; + void NotifyScreenConnect(const sptr& screenSession); + void NotifyScreenDisconnect(const sptr& screenSession); + mutable std::mutex screenSessionMapMutex_; std::map> screenSessionMap_; std::function switchingToAnotherUserFunc_ = nullptr; @@ -119,6 +129,7 @@ private: sptr screenSessionManager_; IScreenConnectionListener* screenConnectionListener_; + sptr screenConnectionChangeListener_; sptr displayChangeListener_; FoldDisplayMode displayMode_ = FoldDisplayMode::UNKNOWN; }; diff --git a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp index f77f25462bd966d61f7d86aa211e0ddb9d6a3b3a..3aef15a33f357e20ea0ad3fd087c646ad924e461 100644 --- a/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp +++ b/window_scene/screen_session_manager_client/src/screen_session_manager_client.cpp @@ -78,6 +78,37 @@ void ScreenSessionManagerClient::RegisterScreenConnectionListener(IScreenConnect WLOGFI("Success to register screen connection listener"); } +void ScreenSessionManagerClient::RegisterScreenConnectionChangeListener( + const sptr& listener) +{ + if (listener == nullptr) { + TLOGE(WmsLogTag::DMS, "Failed: listener is null"); + return; + } + screenConnectionChangeListener_ = listener; + TLOGI(WmsLogTag::DMS, "Success"); +} + +void ScreenSessionManagerClient::NotifyScreenConnect(const sptr& screenSession) +{ + if (screenConnectionListener_) { + screenConnectionListener_->OnScreenConnected(screenSession); + } + if (screenConnectionChangeListener_) { + screenConnectionChangeListener_->OnScreenConnected(screenSession); + } +} + +void ScreenSessionManagerClient::NotifyScreenDisconnect(const sptr& screenSession) +{ + if (screenConnectionListener_) { + screenConnectionListener_->OnScreenDisconnected(screenSession); + } + if (screenConnectionChangeListener_) { + screenConnectionChangeListener_->OnScreenDisconnected(screenSession); + } +} + bool ScreenSessionManagerClient::CheckIfNeedConnectScreen(ScreenId screenId, ScreenId rsId, const std::string& name) { if (rsId == SCREEN_ID_INVALID) { @@ -124,8 +155,8 @@ void ScreenSessionManagerClient::OnScreenConnectionChanged(ScreenId screenId, Sc screenSessionMap_.emplace(screenId, screenSession); } screenSession->SetIsExtend(isExtend); + NotifyScreenConnect(screenSession); if (screenConnectionListener_) { - screenConnectionListener_->OnScreenConnected(screenSession); WLOGFI("screenId: %{public}" PRIu64 " density: %{public}f ", screenId, config.property.GetDensity()); screenSession->SetScreenSceneDpi(config.property.GetDensity()); @@ -140,9 +171,7 @@ void ScreenSessionManagerClient::OnScreenConnectionChanged(ScreenId screenId, Sc return; } screenSession->DestroyScreenScene(); - if (screenConnectionListener_) { - screenConnectionListener_->OnScreenDisconnected(screenSession); - } + NotifyScreenDisconnect(screenSession); { std::lock_guard lock(screenSessionMapMutex_); screenSessionMap_.erase(screenId); diff --git a/window_scene/session_manager/BUILD.gn b/window_scene/session_manager/BUILD.gn index a118e4729871ee25d70ecc42d31f96705db04ec7..6a5f6d3b531baa6135320715f0d172ad162fd445 100644 --- a/window_scene/session_manager/BUILD.gn +++ b/window_scene/session_manager/BUILD.gn @@ -76,6 +76,7 @@ ohos_shared_library("scene_session_manager") { "src/scene_system_ability_listener.cpp", "src/session_listener_controller.cpp", "src/session_manager_agent_controller.cpp", + "src/window_focus_controller.cpp", "src/window_scene_config.cpp", "src/zidl/scene_session_manager_lite_stub.cpp", "src/zidl/scene_session_manager_stub.cpp", diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index 51f06a07d3f99c7a9b983016e4bca8da662ff71c..5051175b42032e3d4a506cabbfccd20d1fcfcb25 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -27,30 +27,32 @@ #ifndef SUPPORT_SCREEN #define SUPPORT_SCREEN #endif -#include "mission_snapshot.h" -#include "transaction/rs_interfaces.h" +#include "ability_info.h" #include "agent_death_recipient.h" +#include "app_debug_listener_interface.h" +#include "app_mgr_client.h" #include "common/include/task_scheduler.h" +#include "display_change_info.h" +#include "display_change_listener.h" +#include "display_info.h" #include "future.h" +#include "include/core/SkRegion.h" #include "interfaces/include/ws_common.h" -#include "session_listener_controller.h" -#include "scene_session_converter.h" +#include "mission_snapshot.h" #include "scb_session_handler.h" -#include "session/host/include/root_scene_session.h" +#include "scene_session_converter.h" +#include "screen_fold_data.h" +#include "screen_session_manager_client.h" #include "session/host/include/keyboard_session.h" +#include "session/host/include/root_scene_session.h" +#include "session_listener_controller.h" #include "session_manager/include/zidl/scene_session_manager_stub.h" -#include "wm_single_instance.h" -#include "window_scene_config.h" -#include "display_info.h" -#include "display_change_info.h" -#include "display_change_listener.h" -#include "app_debug_listener_interface.h" -#include "app_mgr_client.h" -#include "include/core/SkRegion.h" -#include "ability_info.h" -#include "screen_fold_data.h" #include "thread_safety_annotations.h" +#include "transaction/rs_interfaces.h" +#include "window_focus_controller.h" +#include "window_scene_config.h" +#include "wm_single_instance.h" namespace OHOS::AAFwk { class SessionInfo; @@ -108,7 +110,7 @@ using ProcessStatusBarEnabledChangeFunc = std::function; using ProcessOutsideDownEventFunc = std::function; -using ProcessShiftFocusFunc = std::function; +using ProcessShiftFocusFunc = std::function; using NotifySetFocusSessionFunc = std::function& session)>; using DumpRootSceneElementInfoFunc = std::function& params, std::vector& infos)>; @@ -157,6 +159,12 @@ public: void OnScreenFoldStatusChanged(const std::vector& screenFoldInfo) override; }; +class ScreenConnectionChangeListener : public IScreenConnectionChangeListener { +public: + void OnScreenConnected(const sptr& screenSession) override; + void OnScreenDisconnected(const sptr& screenSession) override; +}; + class SceneSessionManager : public SceneSessionManagerStub { WM_DECLARE_SINGLE_INSTANCE_BASE(SceneSessionManager) public: @@ -257,8 +265,8 @@ public: /* * Window Focus */ - WSError SetFocusedSessionId(int32_t persistentId); - int32_t GetFocusedSessionId() const; + WSError SetFocusedSessionId(const int32_t persistentId, const DisplayId displayId); + int32_t GetFocusedSessionId(DisplayId displayId = DEFAULT_DISPLAY_ID) const; FocusChangeReason GetFocusChangeReason() const { return focusChangeReason_; } WMError RequestFocusStatus(int32_t persistentId, bool isFocused, bool byForeground = true, FocusChangeReason reason = FocusChangeReason::DEFAULT) override; @@ -267,9 +275,11 @@ public: void RequestAllAppSessionUnfocus(); WSError UpdateFocus(int32_t persistentId, bool isFocused); WSError ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) override; - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; - WSError GetFocusSessionToken(sptr& token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override; + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override; + WSError GetFocusSessionToken(sptr& token, DisplayId displayId = DEFAULT_DISPLAY_ID) override; + WSError GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId = DEFAULT_DISPLAY_ID) override; + WSError AddFocusGroup(DisplayId displayId); + WSError RemoveFocusGroup(DisplayId displayId); WSError UpdateWindowMode(int32_t persistentId, int32_t windowMode); WSError SendTouchEvent(const std::shared_ptr& pointerEvent, uint32_t zIndex); @@ -679,43 +689,49 @@ private: void ResetWantInfo(const sptr& sceneSession); void ResetSceneSessionInfoWant(const sptr& sceneSessionInfo); - /* - * Window Focus - */ std::vector>> GetSceneSessionVector(CmpFunc cmp); void TraverseSessionTree(TraverseFunc func, bool isFromTopToBottom); void TraverseSessionTreeFromTopToBottom(TraverseFunc func); void TraverseSessionTreeFromBottomToTop(TraverseFunc func); + + /* + * Window Focus + */ WSError RequestSessionFocus(int32_t persistentId, bool byForeground = true, FocusChangeReason reason = FocusChangeReason::DEFAULT); WSError RequestSessionFocusImmediately(int32_t persistentId); WSError RequestSessionUnfocus(int32_t persistentId, FocusChangeReason reason = FocusChangeReason::DEFAULT); WSError RequestAllAppSessionUnfocusInner(); - WSError RequestFocusBasicCheck(int32_t persistentId); - bool CheckLastFocusedAppSessionFocus(sptr& focusedSession, sptr& nextSession); - WSError RequestFocusSpecificCheck(sptr& sceneSession, bool byForeground, + WSError RequestFocusBasicCheck(int32_t persistentId, const sptr& focusGroup); + bool CheckLastFocusedAppSessionFocus(const sptr& focusedSession, + const sptr& nextSession); + WSError RequestFocusSpecificCheck(DisplayId displayId, const sptr& sceneSession, bool byForeground, FocusChangeReason reason = FocusChangeReason::DEFAULT); - bool CheckTopmostWindowFocus(sptr& focusedSession, sptr& sceneSession); - bool CheckRequestFocusImmdediately(sptr& sceneSession); - bool CheckFocusIsDownThroughBlockingType(sptr& requestSceneSession, - sptr& focusedSession, bool includingAppSession); + bool CheckTopmostWindowFocus(const sptr& focusedSession, const sptr& sceneSession); + bool CheckRequestFocusImmdediately(const sptr& sceneSession); + bool CheckFocusIsDownThroughBlockingType(const sptr& requestSceneSession, + const sptr& focusedSession, bool includingAppSession); bool CheckClickFocusIsDownThroughFullScreen(const sptr& focusedSession, const sptr& sceneSession, FocusChangeReason reason); bool IsParentSessionVisible(const sptr& session); - sptr GetNextFocusableSession(int32_t persistentId); - sptr GetTopNearestBlockingFocusSession(uint32_t zOrder, bool includingAppSession); + sptr GetNextFocusableSession(DisplayId displayId, int32_t persistentId); + sptr GetTopNearestBlockingFocusSession(DisplayId displayId, uint32_t zOrder, + bool includingAppSession); sptr GetTopFocusableNonAppSession(); - WSError ShiftFocus(sptr& nextSession, FocusChangeReason reason = FocusChangeReason::DEFAULT); - void UpdateFocusStatus(sptr& sceneSession, bool isFocused); - void NotifyFocusStatus(sptr& sceneSession, bool isFocused); - int32_t NotifyRssThawApp(const int32_t uid, const std::string& bundleName, - const std::string& reason); - void NotifyFocusStatusByMission(sptr& prevSession, sptr& currSession); - void NotifyUnFocusedByMission(sptr& sceneSession); - bool MissionChanged(sptr& prevSession, sptr& currSession); + WSError ShiftFocus(DisplayId displayId, const sptr& nextSession, + FocusChangeReason reason = FocusChangeReason::DEFAULT); + void UpdateFocusStatus(DisplayId displayId, const sptr& sceneSession, bool isFocused); + void NotifyFocusStatus(const sptr& sceneSession, bool isFocused, + const sptr& focusGroup); + int32_t NotifyRssThawApp(const int32_t uid, const std::string& bundleName, const std::string& reason); + void NotifyFocusStatusByMission(const sptr& prevSession, const sptr& currSession); + void NotifyUnFocusedByMission(const sptr& sceneSession); + bool MissionChanged(const sptr& prevSession, const sptr& currSession); std::string GetAllSessionFocusInfo(); - void RegisterRequestFocusStatusNotifyManagerFunc(sptr& sceneSession); + void RegisterRequestFocusStatusNotifyManagerFunc(const sptr& sceneSession); void ProcessUpdateLastFocusedAppId(const std::vector& zOrderList); + WSError ProcessDialogRequestFocusImmdediately(const sptr& sceneSession); + WSError ProcessModalTopmostRequestFocusImmdediately(const sptr& sceneSession); void RegisterGetStateFromManagerFunc(sptr& sceneSession); void RegisterSessionChangeByActionNotifyManagerFunc(sptr& sceneSession); @@ -941,22 +957,24 @@ private: NotifyStartPiPFailedFunc startPiPFailedFunc_; SystemSessionConfig systemConfig_; - FocusChangeReason focusChangeReason_ = FocusChangeReason::DEFAULT; float snapshotScale_ = 0.5; - int32_t focusedSessionId_ = INVALID_SESSION_ID; - int32_t lastFocusedSessionId_ = INVALID_SESSION_ID; - int32_t lastFocusedAppSessionId_ = INVALID_SESSION_ID; int32_t brightnessSessionId_ = INVALID_SESSION_ID; float displayBrightness_ = UNDEFINED_BRIGHTNESS; - bool isScreenLocked_ {false}; - bool needBlockNotifyFocusStatusUntilForeground_ {false}; - bool needBlockNotifyUnfocusStatus_ {false}; - bool isPrepareTerminateEnable_ {false}; + bool isScreenLocked_ { false }; + bool isPrepareTerminateEnable_ { false }; + + /* + * Window Focus + */ + sptr windowFocusController_; + FocusChangeReason focusChangeReason_ = FocusChangeReason::DEFAULT; + bool needBlockNotifyFocusStatusUntilForeground_ { false }; + bool needBlockNotifyUnfocusStatus_ { false }; /* * DFX */ - bool openDebugTrace_ {false}; + bool openDebugTrace_ { false }; std::atomic enableInputEvent_ = true; std::vector alivePersistentIds_ = {}; @@ -1004,8 +1022,6 @@ private: void ProcessFocusWhenForegroundScbCore(sptr& sceneSession); void ProcessSubSessionForeground(sptr& sceneSession); void ProcessSubSessionBackground(sptr& sceneSession); - WSError ProcessDialogRequestFocusImmdediately(sptr& sceneSession); - WSError ProcessModalTopmostRequestFocusImmdediately(sptr& sceneSession); sptr FindSessionByToken(const sptr& token); void CheckAndNotifyWaterMarkChangedResult(); @@ -1163,6 +1179,7 @@ private: std::shared_ptr scbDumpSubscriber_; RunnableFuture> dumpInfoFuture_; void DumpSessionInfo(const sptr& session, std::ostringstream& oss); + void DumpFocusInfo(std::ostringstream& oss); void DumpSessionElementInfo(const sptr& session, const std::vector& params, std::string& dumpInfo); void DumpAllSessionFocusableInfo(int32_t persistentId); diff --git a/window_scene/session_manager/include/scene_session_manager_lite.h b/window_scene/session_manager/include/scene_session_manager_lite.h index 54a415993681ff395b0e711566049f8dec8d171c..0344a2b55aed0e3c54625bd8c54be8092125a953 100644 --- a/window_scene/session_manager/include/scene_session_manager_lite.h +++ b/window_scene/session_manager/include/scene_session_manager_lite.h @@ -30,8 +30,8 @@ public: WSError PendingSessionToForeground(const sptr& token) override; WSError PendingSessionToBackgroundForDelegator(const sptr& token, bool shouldBackToCaller = true) override; - WSError GetFocusSessionToken(sptr& token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override; + WSError GetFocusSessionToken(sptr& token, DisplayId displayId = DEFAULT_DISPLAY_ID) override; + WSError GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId = DEFAULT_DISPLAY_ID) override; WSError RegisterSessionListener(const sptr& listener, bool isRecover = false) override; WSError UnRegisterSessionListener(const sptr& listener) override; WSError GetSessionInfos(const std::string& deviceId, int32_t numMax, @@ -52,7 +52,7 @@ public: WSError MoveSessionsToForeground(const std::vector& sessionIds, int32_t topSessionId) override; WSError MoveSessionsToBackground(const std::vector& sessionIds, std::vector& result) override; - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override; WMError RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h index 29b8dd9b82ae0d46371461368fbfd56cbb4c681a..f79e0b058fb0f5e89ee939a084703fcbce0045d9 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_interface.h @@ -137,8 +137,9 @@ public: virtual WSError PendingSessionToForeground(const sptr& token) = 0; virtual WSError PendingSessionToBackgroundForDelegator(const sptr& token, bool shouldBackToCaller = true) = 0; - virtual WSError GetFocusSessionToken(sptr& token) = 0; - virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element) = 0; + virtual WSError GetFocusSessionToken(sptr& token, DisplayId displayId = DEFAULT_DISPLAY_ID) = 0; + virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element, + DisplayId displayId = DEFAULT_DISPLAY_ID) = 0; virtual WSError RegisterSessionListener(const sptr& listener) = 0; virtual WSError UnRegisterSessionListener(const sptr& listener) = 0; @@ -277,7 +278,7 @@ public: std::vector>& targets) override { return WMError::WM_OK; } void SetMaximizeMode(MaximizeMode maximizeMode) override {} MaximizeMode GetMaximizeMode() override { return MaximizeMode::MODE_AVOID_SYSTEM_BAR; } - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override {} + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override {} /** * @brief Raise a window to screen top by id of window. diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h index 16b793af413ea2df09e59a16cb85baf2a12edd65..fc488ac4e2198d1ab0ca9c478afc8d4e74c58550 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_interface.h @@ -114,10 +114,10 @@ public: virtual WSError GetSessionInfoByContinueSessionId(const std::string& continueSessionId, SessionInfoBean& sessionInfo) = 0; virtual WSError SetSessionContinueState(const sptr& token, const ContinueState& continueState) = 0; - virtual WSError IsValidSessionIds(const std::vector& sessionIds, std::vector& results) = 0; - virtual WSError GetFocusSessionToken(sptr& token) = 0; - virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element) = 0; + virtual WSError GetFocusSessionToken(sptr& token, DisplayId displayId = DEFAULT_DISPLAY_ID) = 0; + virtual WSError GetFocusSessionElement(AppExecFwk::ElementName& element, + DisplayId displayId = DEFAULT_DISPLAY_ID) = 0; virtual WSError GetSessionSnapshot(const std::string& deviceId, int32_t persistentId, SessionSnapshot& snapshot, bool isLowResolution) = 0; virtual WSError LockSession(int32_t sessionId) = 0; diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h index 227e5a35bc9757bb91a039270bde850db37358f5..117a325f0c8d45e0af6df459b39788d2f9bce709 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_lite_proxy.h @@ -33,8 +33,8 @@ public: WSError PendingSessionToForeground(const sptr& token) override; WSError PendingSessionToBackgroundForDelegator(const sptr& token, bool shouldBackToCaller = true) override; - WSError GetFocusSessionToken(sptr& token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override; + WSError GetFocusSessionToken(sptr& token, DisplayId displayId = DEFAULT_DISPLAY_ID) override; + WSError GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId = DEFAULT_DISPLAY_ID) override; WSError RegisterSessionListener(const sptr& listener, bool isRecover = false) override; WSError UnRegisterSessionListener(const sptr& listener) override; WSError GetSessionInfos(const std::string& deviceId, int32_t numMax, @@ -62,8 +62,7 @@ public: WSError MoveSessionsToBackground(const std::vector& sessionIds, std::vector& result) override; WSError ClearSession(int32_t persistentId) override; WSError ClearAllSessions() override; - - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override; WMError RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, @@ -93,7 +92,6 @@ public: WMError LockSessionByAbilityInfo(const AbilityInfoBase& abilityInfo, bool isLock) override; WMError HasFloatingWindowForeground(const sptr& abilityToken, bool& hasOrNot) override; - private: template WSError GetParcelableInfos(MessageParcel& reply, std::vector& parcelableInfos); diff --git a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h index ed54a6ca7f92efcf42e789e53616f343d8b47d6b..7791d2d09682876773e125f5a9795a7033119ccb 100644 --- a/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h +++ b/window_scene/session_manager/include/zidl/scene_session_manager_proxy.h @@ -51,7 +51,7 @@ public: WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) override; WMError SetGestureNavigationEnabled(bool enable) override; - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override; WSError SetSessionLabel(const sptr& token, const std::string& label) override; WSError SetSessionIcon(const sptr& token, const std::shared_ptr& icon) override; WSError IsValidSessionIds(const std::vector& sessionIds, std::vector& results) override; @@ -62,8 +62,8 @@ public: bool shouldBackToCaller = true) override; WMError GetSessionSnapshotById(int32_t persistentId, SessionSnapshot& snapshot) override; WMError GetSnapshotByWindowId(int32_t persistentId, std::shared_ptr& pixelMap) override; - WSError GetFocusSessionToken(sptr& token) override; - WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override; + WSError GetFocusSessionToken(sptr& token, DisplayId displayId = DEFAULT_DISPLAY_ID) override; + WSError GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId = DEFAULT_DISPLAY_ID) override; WMError CheckWindowId(int32_t windowId, int32_t& pid) override; WSError RegisterSessionListener(const sptr& listener) override; diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 6cf9a5a05b639d41173b4148212fc8740cdc019b..6300c342b1211becfb2849011e80c95fa1a0749f 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -317,6 +317,7 @@ SceneSessionManager::SceneSessionManager() : rsInterface_(RSInterfaces::GetInsta scbDumpSubscriber_ = ScbDumpSubscriber::Subscribe(); listenerController_ = std::make_shared(); + windowFocusController_ = sptr::MakeSptr(); } SceneSessionManager::~SceneSessionManager() @@ -343,6 +344,8 @@ void SceneSessionManager::Init() InitPrepareTerminateConfig(); ScreenSessionManagerClient::GetInstance().RegisterDisplayChangeListener(sptr::MakeSptr()); + ScreenSessionManagerClient::GetInstance().RegisterScreenConnectionChangeListener( + sptr::MakeSptr()); // create handler for inner command at server eventLoop_ = AppExecFwk::EventRunner::Create(WINDOW_INFO_REPORT_THREAD); @@ -2469,7 +2472,9 @@ WSError SceneSessionManager::RequestSceneSessionBackground(const sptrGetSessionProperty()->GetDisplayId(); + auto focusedSessionId = windowFocusController_->GetFocusedSessionId(displayId); + UpdateBrightness(focusedSessionId); } if (IsPcSceneSessionLifecycle(sceneSession)) { TLOGNI(WmsLogTag::WMS_MAIN, "Notify session background: %{public}d", persistentId); @@ -3856,14 +3861,21 @@ void SceneSessionManager::UpdateRotateAnimationConfig(const RotateAnimationConfi WSError SceneSessionManager::ProcessBackEvent() { taskScheduler_->PostAsyncTask([this]() { - auto session = GetSceneSession(focusedSessionId_); + auto focusGroup = windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + if (focusGroup == nullptr) { + TLOGNE(WmsLogTag::WMS_MAIN, "focus group is nullptr: %{public}" PRIu64, DEFAULT_DISPLAY_ID); + return WSError::WS_ERROR_NULLPTR; + } + auto focusedSessionId = focusGroup->GetFocusedSessionId(); + auto needBlockNotifyFocusStatusUntilForeground = focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground(); + auto session = GetSceneSession(focusedSessionId); if (!session) { - TLOGNE(WmsLogTag::WMS_MAIN, "session is nullptr: %{public}d", focusedSessionId_); + TLOGNE(WmsLogTag::WMS_MAIN, "session is nullptr: %{public}d", focusedSessionId); return WSError::WS_ERROR_INVALID_SESSION; } TLOGNI(WmsLogTag::WMS_MAIN, "ProcessBackEvent session persistentId:%{public}d needBlock:%{public}d", - focusedSessionId_, needBlockNotifyFocusStatusUntilForeground_); - if (needBlockNotifyFocusStatusUntilForeground_) { + focusedSessionId, needBlockNotifyFocusStatusUntilForeground); + if (needBlockNotifyFocusStatusUntilForeground) { TLOGND(WmsLogTag::WMS_MAIN, "RequestSessionBack when start session"); if (session->GetSessionInfo().abilityInfo != nullptr && session->GetSessionInfo().abilityInfo->unclearableMission) { @@ -4647,33 +4659,32 @@ WMError SceneSessionManager::SetGestureNavigationEnabled(bool enable) return taskScheduler_->PostSyncTask(task, "SetGestureNavigationEnabled"); } -WSError SceneSessionManager::SetFocusedSessionId(int32_t persistentId) +WSError SceneSessionManager::SetFocusedSessionId(const int32_t persistentId, const DisplayId displayId) { - if (focusedSessionId_ == persistentId) { - WLOGI("Focus scene not change, id: %{public}d", focusedSessionId_); - return WSError::WS_DO_NOTHING; - } - lastFocusedSessionId_ = focusedSessionId_; - focusedSessionId_ = persistentId; - return WSError::WS_OK; + return windowFocusController_->UpdateFocusedSessionId(displayId, persistentId); } -int32_t SceneSessionManager::GetFocusedSessionId() const +int32_t SceneSessionManager::GetFocusedSessionId(DisplayId displayId) const { - return focusedSessionId_; + return windowFocusController_->GetFocusedSessionId(displayId); } -void SceneSessionManager::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void SceneSessionManager::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { if (!SessionPermission::IsSACalling()) { TLOGE(WmsLogTag::WMS_FOCUS, "permission denied!"); return; } - taskScheduler_->PostSyncTask([this, &focusInfo] { - if (auto sceneSession = GetSceneSession(focusedSessionId_)) { + taskScheduler_->PostSyncTask([this, &focusInfo, displayId] { + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return WSError::WS_ERROR_DESTROYED_OBJECT; + } + if (auto sceneSession = GetSceneSession(focusGroup->GetFocusedSessionId())) { TLOGND(WmsLogTag::WMS_FOCUS, "Get focus session info success"); focusInfo.windowId_ = sceneSession->GetWindowId(); - focusInfo.displayId_ = static_cast(0); + focusInfo.displayId_ = focusGroup->GetDisplayGroupId(); focusInfo.pid_ = sceneSession->GetCallingPid(); focusInfo.uid_ = sceneSession->GetCallingUid(); focusInfo.windowType_ = sceneSession->GetWindowType(); @@ -4684,6 +4695,16 @@ void SceneSessionManager::GetFocusWindowInfo(FocusChangeInfo& focusInfo) }, __func__); } +WSError SceneSessionManager::AddFocusGroup(DisplayId displayId) +{ + return windowFocusController_->AddFocusGroup(displayId); +} + +WSError SceneSessionManager::RemoveFocusGroup(DisplayId displayId) +{ + return windowFocusController_->RemoveFocusGroup(displayId); +} + static bool IsValidDigitString(const std::string& windowIdStr) { if (windowIdStr.empty()) { @@ -4981,6 +5002,18 @@ void SceneSessionManager::DumpSessionInfo(const sptr& session, std << std::endl; } +void SceneSessionManager::DumpFocusInfo(std::ostringstream& oss) +{ + oss << "Focus window: " << std::endl; + std::vector> allFocusedSessionList = + windowFocusController_->GetAllFocusedSessionList(); + if (allFocusedSessionList.size() > 0) { + for (const auto& focusState : allFocusedSessionList) { + oss << "DisplayId: " << focusState.first << " Focus window: " << focusState.second << std::endl; + } + } +} + WSError SceneSessionManager::GetAllSessionDumpInfo(std::string& dumpInfo) { int32_t screenGroupId = 0; @@ -5025,7 +5058,7 @@ WSError SceneSessionManager::GetAllSessionDumpInfo(std::string& dumpInfo) DumpSessionInfo(session, oss); count++; } - oss << "Focus window: " << GetFocusedSessionId() << std::endl; + DumpFocusInfo(oss); oss << "SingleHand: X[" << singleHandTransform_.posX << "] Y[" << singleHandTransform_.posY << "] scale[" << singleHandTransform_.scaleX << "]" << std::endl; oss << "Total window num: " << sceneSessionMapCopy.size() << std::endl; @@ -5237,7 +5270,7 @@ bool SceneSessionManager::GetStatusBarDefaultVisibilityByDisplayId(DisplayId dis statusBarDefaultVisibilityPerDisplay_[displayId] : true; } -void FocusIDChange(int32_t persistentId, sptr& sceneSession) +void FocusIDChange(int32_t persistentId, const sptr& sceneSession) { // notify RS WLOGFD("current focus session: windowId: %{public}d, windowName: %{public}s, bundleName: %{public}s, " @@ -5408,16 +5441,22 @@ void SceneSessionManager::RequestAllAppSessionUnfocus() WSError SceneSessionManager::RequestSessionFocusImmediately(int32_t persistentId) { TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); - // base block - WSError basicCheckRet = RequestFocusBasicCheck(persistentId); - if (basicCheckRet != WSError::WS_OK) { - return basicCheckRet; - } auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { WLOGFE("[WMSComm]session is nullptr"); return WSError::WS_ERROR_INVALID_SESSION; } + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return WSError::WS_ERROR_NULLPTR; + } + // base block + WSError basicCheckRet = RequestFocusBasicCheck(persistentId, focusGroup); + if (basicCheckRet != WSError::WS_OK) { + return basicCheckRet; + } if (!sceneSession->CheckFocusable()) { TLOGD(WmsLogTag::WMS_FOCUS, "session is not focusable!"); return WSError::WS_DO_NOTHING; @@ -5429,16 +5468,16 @@ WSError SceneSessionManager::RequestSessionFocusImmediately(int32_t persistentId // specific block FocusChangeReason reason = FocusChangeReason::SCB_START_APP; - WSError specificCheckRet = RequestFocusSpecificCheck(sceneSession, true, reason); + WSError specificCheckRet = RequestFocusSpecificCheck(displayId, sceneSession, true, reason); if (specificCheckRet != WSError::WS_OK) { return specificCheckRet; } - - needBlockNotifyUnfocusStatus_ = needBlockNotifyFocusStatusUntilForeground_; + auto needBlockNotifyFocusStatusUntilForeground = focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground(); + focusGroup->SetNeedBlockNotifyUnfocusStatus(needBlockNotifyFocusStatusUntilForeground); if (!sceneSession->GetSessionInfo().isSystem_ && !IsSessionVisibleForeground(sceneSession)) { - needBlockNotifyFocusStatusUntilForeground_ = true; + focusGroup->SetNeedBlockNotifyFocusStatusUntilForeground(true); } - ShiftFocus(sceneSession, reason); + ShiftFocus(displayId, sceneSession, reason); return WSError::WS_OK; } @@ -5446,15 +5485,21 @@ WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byFo { TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d, by foreground: %{public}d, reason: %{public}d", persistentId, byForeground, reason); - WSError basicCheckRet = RequestFocusBasicCheck(persistentId); - if (basicCheckRet != WSError::WS_OK) { - return basicCheckRet; - } auto sceneSession = GetSceneSession(persistentId); if (sceneSession == nullptr) { WLOGFE("[WMSComm]session is nullptr"); return WSError::WS_ERROR_INVALID_SESSION; } + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return WSError::WS_ERROR_NULLPTR; + } + WSError basicCheckRet = RequestFocusBasicCheck(persistentId, focusGroup); + if (basicCheckRet != WSError::WS_OK) { + return basicCheckRet; + } if (!sceneSession->CheckFocusable() || !IsSessionVisibleForeground(sceneSession)) { TLOGD(WmsLogTag::WMS_FOCUS, "session is not focusable or not visible!"); return WSError::WS_DO_NOTHING; @@ -5479,14 +5524,13 @@ WSError SceneSessionManager::RequestSessionFocus(int32_t persistentId, bool byFo return WSError::WS_DO_NOTHING; } // specific block - WSError specificCheckRet = RequestFocusSpecificCheck(sceneSession, byForeground, reason); + WSError specificCheckRet = RequestFocusSpecificCheck(displayId, sceneSession, byForeground, reason); if (specificCheckRet != WSError::WS_OK) { return specificCheckRet; } - - needBlockNotifyUnfocusStatus_ = needBlockNotifyFocusStatusUntilForeground_; - needBlockNotifyFocusStatusUntilForeground_ = false; - ShiftFocus(sceneSession, reason); + focusGroup->SetNeedBlockNotifyUnfocusStatus(focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground()); + focusGroup->SetNeedBlockNotifyFocusStatusUntilForeground(false); + ShiftFocus(displayId, sceneSession, reason); return WSError::WS_OK; } @@ -5494,65 +5538,84 @@ WSError SceneSessionManager::RequestSessionUnfocus(int32_t persistentId, FocusCh { TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); if (persistentId == INVALID_SESSION_ID) { - WLOGFE("id is invalid"); + TLOGE(WmsLogTag::WMS_FOCUS, "id is invalid: %{public}d", persistentId); + return WSError::WS_ERROR_INVALID_SESSION; + } + auto sceneSession = GetSceneSession(persistentId); + if (sceneSession == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "session is nullptr: %{public}d", persistentId); return WSError::WS_ERROR_INVALID_SESSION; } - auto focusedSession = GetSceneSession(focusedSessionId_); - if (persistentId != focusedSessionId_ && + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return WSError::WS_ERROR_NULLPTR; + } + auto focusedSession = GetSceneSession(focusGroup->GetFocusedSessionId()); + if (persistentId != focusGroup->GetFocusedSessionId() && !(focusedSession && focusedSession->GetParentPersistentId() == persistentId)) { TLOGD(WmsLogTag::WMS_FOCUS, "session unfocused!"); return WSError::WS_DO_NOTHING; } // if pop menu created by desktop request unfocus, back to desktop - auto lastSession = GetSceneSession(lastFocusedSessionId_); + auto lastSession = GetSceneSession(focusGroup->GetLastFocusedSessionId()); if (focusedSession && focusedSession->GetWindowType() == WindowType::WINDOW_TYPE_SYSTEM_FLOAT && lastSession && lastSession->GetWindowType() == WindowType::WINDOW_TYPE_DESKTOP && - RequestSessionFocus(lastFocusedSessionId_, false) == WSError::WS_OK) { + RequestSessionFocus(focusGroup->GetLastFocusedSessionId(), false) == WSError::WS_OK) { TLOGD(WmsLogTag::WMS_FOCUS, "focus is back to desktop"); return WSError::WS_OK; } - auto nextSession = GetNextFocusableSession(persistentId); + auto nextSession = GetNextFocusableSession(displayId, persistentId); if (nextSession == nullptr) { DumpAllSessionFocusableInfo(persistentId); } - - needBlockNotifyUnfocusStatus_ = needBlockNotifyFocusStatusUntilForeground_; - needBlockNotifyFocusStatusUntilForeground_ = false; + focusGroup->SetNeedBlockNotifyUnfocusStatus(focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground()); + focusGroup->SetNeedBlockNotifyFocusStatusUntilForeground(false); if (CheckLastFocusedAppSessionFocus(focusedSession, nextSession)) { return WSError::WS_OK; } - return ShiftFocus(nextSession, reason); + return ShiftFocus(displayId, nextSession, reason); } WSError SceneSessionManager::RequestAllAppSessionUnfocusInner() { TLOGI(WmsLogTag::WMS_FOCUS, "in"); - auto focusedSession = GetSceneSession(focusedSessionId_); + auto focusGroup = windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, DEFAULT_DISPLAY_ID); + return WSError::WS_ERROR_NULLPTR; + } + auto focusedSession = GetSceneSession(focusGroup->GetFocusedSessionId()); if (!focusedSession) { TLOGE(WmsLogTag::WMS_FOCUS, "focused session is null"); return WSError::WS_DO_NOTHING; } if (!focusedSession->IsAppSession()) { - WLOGW("[WMFocus]Focused session is non app session: %{public}d", focusedSessionId_); + TLOGW(WmsLogTag::WMS_FOCUS, "Focused session is non app: %{public}d", focusGroup->GetFocusedSessionId()); return WSError::WS_DO_NOTHING; } auto nextSession = GetTopFocusableNonAppSession(); - needBlockNotifyUnfocusStatus_ = needBlockNotifyFocusStatusUntilForeground_; - needBlockNotifyFocusStatusUntilForeground_ = false; - return ShiftFocus(nextSession, FocusChangeReason::WIND); + focusGroup->SetNeedBlockNotifyUnfocusStatus(focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground()); + focusGroup->SetNeedBlockNotifyFocusStatusUntilForeground(false); + return ShiftFocus(DEFAULT_DISPLAY_ID, nextSession, FocusChangeReason::WIND); } -WSError SceneSessionManager::RequestFocusBasicCheck(int32_t persistentId) +WSError SceneSessionManager::RequestFocusBasicCheck(int32_t persistentId, const sptr& focusGroup) { // basic focus rule if (persistentId == INVALID_SESSION_ID) { TLOGE(WmsLogTag::WMS_FOCUS, "id is invalid!"); return WSError::WS_ERROR_INVALID_SESSION; } - if (persistentId == focusedSessionId_) { + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr"); + return WSError::WS_ERROR_NULLPTR; + } + if (persistentId == focusGroup->GetFocusedSessionId()) { TLOGD(WmsLogTag::WMS_FOCUS, "request id has been focused!"); return WSError::WS_DO_NOTHING; } @@ -5563,17 +5626,23 @@ WSError SceneSessionManager::RequestFocusBasicCheck(int32_t persistentId) * @note @window.focus * When high zOrder System Session unfocus, check if the last focused app window can focus. */ -bool SceneSessionManager::CheckLastFocusedAppSessionFocus( - sptr& focusedSession, sptr& nextSession) +bool SceneSessionManager::CheckLastFocusedAppSessionFocus(const sptr& focusedSession, + const sptr& nextSession) { if (focusedSession == nullptr || nextSession == nullptr) { return false; } - + auto displayId = focusedSession->GetSessionProperty()->GetDisplayId(); + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return false; + } + auto lastFocusedAppSessionId = focusGroup->GetLastFocusedAppSessionId(); TLOGI(WmsLogTag::WMS_FOCUS, "lastFocusedAppSessionId: %{public}d, nextSceneSession: %{public}d", - lastFocusedAppSessionId_, nextSession->GetPersistentId()); + lastFocusedAppSessionId, nextSession->GetPersistentId()); - if (lastFocusedAppSessionId_ == INVALID_SESSION_ID || nextSession->GetPersistentId() == lastFocusedAppSessionId_) { + if (lastFocusedAppSessionId == INVALID_SESSION_ID || nextSession->GetPersistentId() == lastFocusedAppSessionId) { return false; } @@ -5586,11 +5655,11 @@ bool SceneSessionManager::CheckLastFocusedAppSessionFocus( if (nextSession->IsAppSession() && (mode == WindowMode::WINDOW_MODE_SPLIT_PRIMARY || mode == WindowMode::WINDOW_MODE_SPLIT_SECONDARY || mode == WindowMode::WINDOW_MODE_FLOATING)) { - if (RequestSessionFocus(lastFocusedAppSessionId_, false, FocusChangeReason::LAST_FOCUSED_APP) == + if (RequestSessionFocus(lastFocusedAppSessionId, false, FocusChangeReason::LAST_FOCUSED_APP) == WSError::WS_OK) { return true; } - lastFocusedAppSessionId_ = INVALID_SESSION_ID; + focusGroup->SetLastFocusedAppSessionId(INVALID_SESSION_ID); } return false; } @@ -5600,15 +5669,16 @@ bool SceneSessionManager::CheckLastFocusedAppSessionFocus( * * @return true: traversed downwards, false: not. */ -bool SceneSessionManager::CheckFocusIsDownThroughBlockingType(sptr& requestSceneSession, - sptr& focusedSession, bool includingAppSession) +bool SceneSessionManager::CheckFocusIsDownThroughBlockingType(const sptr& requestSceneSession, + const sptr& focusedSession, bool includingAppSession) { uint32_t requestSessionZOrder = requestSceneSession->GetZOrder(); uint32_t focusedSessionZOrder = focusedSession->GetZOrder(); + auto displayId = requestSceneSession->GetSessionProperty()->GetDisplayId(); TLOGD(WmsLogTag::WMS_FOCUS, "requestSessionZOrder: %{public}d, focusedSessionZOrder: %{public}d", requestSessionZOrder, focusedSessionZOrder); if (requestSessionZOrder < focusedSessionZOrder) { - auto topNearestBlockingFocusSession = GetTopNearestBlockingFocusSession(requestSessionZOrder, + auto topNearestBlockingFocusSession = GetTopNearestBlockingFocusSession(displayId, requestSessionZOrder, includingAppSession); uint32_t topNearestBlockingZOrder = 0; if (topNearestBlockingFocusSession) { @@ -5626,7 +5696,8 @@ bool SceneSessionManager::CheckFocusIsDownThroughBlockingType(sptr return false; } -bool SceneSessionManager::CheckTopmostWindowFocus(sptr& focusedSession, sptr& sceneSession) +bool SceneSessionManager::CheckTopmostWindowFocus(const sptr& focusedSession, + const sptr& sceneSession) { bool isFocusedMainSessionTopmost = focusedSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && focusedSession->IsTopmost(); @@ -5640,7 +5711,7 @@ bool SceneSessionManager::CheckTopmostWindowFocus(sptr& focusedSes return false; } -bool SceneSessionManager::CheckRequestFocusImmdediately(sptr& sceneSession) +bool SceneSessionManager::CheckRequestFocusImmdediately(const sptr& sceneSession) { if ((sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW || (SessionHelper::IsSubWindow(sceneSession->GetWindowType()) && !sceneSession->IsModal())) && @@ -5665,8 +5736,8 @@ bool SceneSessionManager::CheckClickFocusIsDownThroughFullScreen(const sptrGetZOrder() < focusedSession->GetZOrder(); } -WSError SceneSessionManager::RequestFocusSpecificCheck(sptr& sceneSession, bool byForeground, - FocusChangeReason reason) +WSError SceneSessionManager::RequestFocusSpecificCheck(DisplayId displayId, const sptr& sceneSession, + bool byForeground, FocusChangeReason reason) { TLOGD(WmsLogTag::WMS_FOCUS, "FocusChangeReason: %{public}d", reason); int32_t persistentId = sceneSession->GetPersistentId(); @@ -5679,7 +5750,8 @@ WSError SceneSessionManager::RequestFocusSpecificCheck(sptr& scene return WSError::WS_DO_NOTHING; } // blocking-type session will block lower zOrder request focus - auto focusedSession = GetSceneSession(focusedSessionId_); + auto focusedSessionId = windowFocusController_->GetFocusedSessionId(displayId); + auto focusedSession = GetSceneSession(focusedSessionId); if (focusedSession) { TLOGD(WmsLogTag::WMS_FOCUS, "reason: %{public}d, byForeground: %{public}d", reason, byForeground); @@ -5750,15 +5822,18 @@ void SceneSessionManager::DumpAllSessionFocusableInfo(int32_t persistentId) TraverseSessionTree(func, true); } -sptr SceneSessionManager::GetNextFocusableSession(int32_t persistentId) +sptr SceneSessionManager::GetNextFocusableSession(DisplayId displayId, int32_t persistentId) { TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", persistentId); bool previousFocusedSessionFound = false; sptr ret = nullptr; - auto func = [this, persistentId, &previousFocusedSessionFound, &ret](sptr session) { + auto func = [this, persistentId, &previousFocusedSessionFound, &ret, displayId](sptr session) { if (session == nullptr) { return false; } + if (session->GetSessionProperty()->GetDisplayId() != displayId) { + return false; + } if (session->GetForceHideState() != ForceHideState::NOT_HIDDEN) { TLOGND(WmsLogTag::WMS_FOCUS, "the window hide id: %{public}d", persistentId); return false; @@ -5781,13 +5856,17 @@ sptr SceneSessionManager::GetNextFocusableSession(int32_t persiste * Find the session through the specific zOrder, it is located abve it, its' blockingFocus attribute is true, * and it is the closest; */ -sptr SceneSessionManager::GetTopNearestBlockingFocusSession(uint32_t zOrder, bool includingAppSession) +sptr SceneSessionManager::GetTopNearestBlockingFocusSession(DisplayId displayId, uint32_t zOrder, + bool includingAppSession) { sptr ret = nullptr; - auto func = [this, &ret, zOrder, includingAppSession](sptr session) { + auto func = [this, &ret, zOrder, includingAppSession, displayId](sptr session) { if (session == nullptr) { return false; } + if (session->GetSessionProperty()->GetDisplayId() != displayId) { + return false; + } uint32_t sessionZOrder = session->GetZOrder(); if (sessionZOrder <= zOrder) { // must be above the target session return false; @@ -5825,6 +5904,9 @@ sptr SceneSessionManager::GetTopFocusableNonAppSession() if (session == nullptr) { return false; } + if (session->GetSessionProperty()->GetDisplayId() != DEFAULT_DISPLAY_ID) { + return false; + } if (session->IsAppSession()) { return true; } @@ -5876,22 +5958,27 @@ void SceneSessionManager::SetAbilityManagerCollaboratorRegisteredFunc( taskScheduler_->PostAsyncTask(task, __func__); } -WSError SceneSessionManager::ShiftFocus(sptr& nextSession, FocusChangeReason reason) +WSError SceneSessionManager::ShiftFocus(DisplayId displayId, const sptr& nextSession, + FocusChangeReason reason) { // unfocus - int32_t focusedId = focusedSessionId_; - auto focusedSession = GetSceneSession(focusedSessionId_); - UpdateFocusStatus(focusedSession, false); + auto focusedSessionId = windowFocusController_->GetFocusedSessionId(displayId); + int32_t focusedId = focusedSessionId; + auto focusedSession = GetSceneSession(focusedSessionId); + UpdateFocusStatus(displayId, focusedSession, false); // focus int32_t nextId = INVALID_SESSION_ID; if (nextSession == nullptr) { std::string sessionLog(GetAllSessionFocusInfo()); TLOGW(WmsLogTag::WMS_FOCUS, "next session nullptr! id: %{public}d, info: %{public}s", - focusedSessionId_, sessionLog.c_str()); + focusedSessionId, sessionLog.c_str()); } else { nextId = nextSession->GetPersistentId(); } - UpdateFocusStatus(nextSession, true); + UpdateFocusStatus(displayId, nextSession, true); + if (shiftFocusFunc_ != nullptr) { + shiftFocusFunc_(nextId, displayId); + } bool scbPrevFocus = focusedSession && focusedSession->GetSessionInfo().isSystem_; bool scbCurrFocus = nextSession && nextSession->GetSessionInfo().isSystem_; if (!scbPrevFocus && scbCurrFocus) { @@ -5903,45 +5990,59 @@ WSError SceneSessionManager::ShiftFocus(sptr& nextSession, FocusCh notifySCBAfterUnfocusedFunc_(); } } - TLOGI(WmsLogTag::WMS_FOCUS, "focusedId: %{public}d, nextId: %{public}d, reason: %{public}d", - focusedId, nextId, reason); + TLOGI(WmsLogTag::WMS_FOCUS, "displayId: %{public}" PRIu64 + ", focusedId: %{public}d, nextId: %{public}d, reason: %{public}d", displayId, focusedId, nextId, reason); return WSError::WS_OK; } -void SceneSessionManager::UpdateFocusStatus(sptr& sceneSession, bool isFocused) +void SceneSessionManager::UpdateFocusStatus(DisplayId displayId, const sptr& sceneSession, + bool isFocused) { + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return; + } + bool needBlockNotifyFocusStatusUntilForeground = focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground(); + bool needBlockNotifyUnfocusStatus = focusGroup->GetNeedBlockNotifyUnfocusStatus(); if (sceneSession == nullptr) { if (isFocused) { - SetFocusedSessionId(INVALID_SESSION_ID); - lastFocusedAppSessionId_ = INVALID_SESSION_ID; - if (!needBlockNotifyFocusStatusUntilForeground_) { - auto prevSession = GetSceneSession(lastFocusedSessionId_); + SetFocusedSessionId(INVALID_SESSION_ID, displayId); + focusGroup->SetLastFocusedAppSessionId(INVALID_SESSION_ID); + if (!needBlockNotifyFocusStatusUntilForeground) { + auto prevSession = GetSceneSession(focusGroup->GetLastFocusedSessionId()); NotifyUnFocusedByMission(prevSession); } } return; } - TLOGD(WmsLogTag::WMS_FOCUS, "name: %{public}s, id: %{public}d, isFocused: %{public}d", - sceneSession->GetWindowNameAllType().c_str(), sceneSession->GetPersistentId(), isFocused); + TLOGD(WmsLogTag::WMS_FOCUS, "name: %{public}s, id: %{public}d, isFocused: %{public}d, displayId: %{public}" PRIu64, + sceneSession->GetWindowNameAllType().c_str(), sceneSession->GetPersistentId(), isFocused, displayId); // set focused if (isFocused) { - SetFocusedSessionId(sceneSession->GetPersistentId()); + SetFocusedSessionId(sceneSession->GetPersistentId(), displayId); if (sceneSession->IsAppOrLowerSystemSession()) { - lastFocusedAppSessionId_ = sceneSession->GetPersistentId(); + focusGroup->SetLastFocusedAppSessionId(sceneSession->GetPersistentId()); } } sceneSession->UpdateFocus(isFocused); - if ((isFocused && !needBlockNotifyFocusStatusUntilForeground_) || (!isFocused && !needBlockNotifyUnfocusStatus_)) { - NotifyFocusStatus(sceneSession, isFocused); + if ((isFocused && !needBlockNotifyFocusStatusUntilForeground) || (!isFocused && !needBlockNotifyUnfocusStatus)) { + NotifyFocusStatus(sceneSession, isFocused, focusGroup); } } -void SceneSessionManager::NotifyFocusStatus(sptr& sceneSession, bool isFocused) +void SceneSessionManager::NotifyFocusStatus(const sptr& sceneSession, bool isFocused, + const sptr& focusGroup) { + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr"); + return; + } + auto lastFocusedSessionId = focusGroup->GetLastFocusedSessionId(); if (sceneSession == nullptr) { WLOGFE("[WMSComm]session is nullptr"); if (isFocused) { - auto prevSession = GetSceneSession(lastFocusedSessionId_); + auto prevSession = GetSceneSession(lastFocusedSessionId); NotifyUnFocusedByMission(prevSession); } return; @@ -5958,16 +6059,13 @@ void SceneSessionManager::NotifyFocusStatus(sptr& sceneSession, bo if (IsSessionVisibleForeground(sceneSession)) { NotifyWindowInfoChange(persistentId, WindowUpdateType::WINDOW_UPDATE_FOCUSED); } - UpdateBrightness(focusedSessionId_); + UpdateBrightness(focusGroup->GetFocusedSessionId()); FocusIDChange(sceneSession->GetPersistentId(), sceneSession); - if (shiftFocusFunc_ != nullptr) { - shiftFocusFunc_(persistentId); - } } // notify window manager sptr focusChangeInfo = sptr::MakeSptr( sceneSession->GetWindowId(), - static_cast(0), + static_cast(focusGroup->GetDisplayGroupId()), sceneSession->GetCallingPid(), sceneSession->GetCallingUid(), sceneSession->GetWindowType(), @@ -5976,20 +6074,8 @@ void SceneSessionManager::NotifyFocusStatus(sptr& sceneSession, bo SceneSessionManager::NotifyRssThawApp(focusChangeInfo->uid_, "", "THAW_BY_FOCUS_CHANGED"); SessionManagerAgentController::GetInstance().UpdateFocusChangeInfo(focusChangeInfo, isFocused); sceneSession->NotifyFocusStatus(isFocused); - std::string sName = "FoucusWindow:"; - if (sceneSession->GetSessionInfo().isSystem_) { - sName += sceneSession->GetSessionInfo().abilityName_; - } else { - sName += sceneSession->GetWindowName(); - } - if (isFocused) { - StartAsyncTrace(HITRACE_TAG_WINDOW_MANAGER, sName, sceneSession->GetPersistentId()); - } else { - FinishAsyncTrace(HITRACE_TAG_WINDOW_MANAGER, sName, sceneSession->GetPersistentId()); - } - // notify listenerController - auto prevSession = GetSceneSession(lastFocusedSessionId_); + auto prevSession = GetSceneSession(lastFocusedSessionId); if (isFocused && MissionChanged(prevSession, sceneSession)) { NotifyFocusStatusByMission(prevSession, sceneSession); } @@ -6007,7 +6093,8 @@ int32_t SceneSessionManager::NotifyRssThawApp(const int32_t uid, const std::stri return ResourceSchedule::ResSchedClient::GetInstance().ReportSyncEvent(resType, 0, payload, reply); } -void SceneSessionManager::NotifyFocusStatusByMission(sptr& prevSession, sptr& currSession) +void SceneSessionManager::NotifyFocusStatusByMission(const sptr& prevSession, + const sptr& currSession) { if (prevSession && !prevSession->GetSessionInfo().isSystem_) { TLOGD(WmsLogTag::WMS_FOCUS, "Unfocused, id: %{public}d", prevSession->GetMissionId()); @@ -6019,7 +6106,7 @@ void SceneSessionManager::NotifyFocusStatusByMission(sptr& prevSes } } -void SceneSessionManager::NotifyUnFocusedByMission(sptr& sceneSession) +void SceneSessionManager::NotifyUnFocusedByMission(const sptr& sceneSession) { if (sceneSession && !sceneSession->GetSessionInfo().isSystem_) { TLOGD(WmsLogTag::WMS_FOCUS, "id: %{public}d", sceneSession->GetMissionId()); @@ -6027,7 +6114,7 @@ void SceneSessionManager::NotifyUnFocusedByMission(sptr& sceneSess } } -bool SceneSessionManager::MissionChanged(sptr& prevSession, sptr& currSession) +bool SceneSessionManager::MissionChanged(const sptr& prevSession, const sptr& currSession) { if (prevSession == nullptr && currSession == nullptr) { return false; @@ -6066,12 +6153,14 @@ WSError SceneSessionManager::UpdateFocus(int32_t persistentId, bool isFocused) TLOGNI(WmsLogTag::WMS_FOCUS, "UpdateFocus, name: %{public}s, id: %{public}d, isFocused: %{public}u", sceneSession->GetWindowName().c_str(), persistentId, static_cast(isFocused)); // focusId change + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusedSessionId = windowFocusController_->GetFocusedSessionId(displayId); if (isFocused) { - SetFocusedSessionId(persistentId); - UpdateBrightness(focusedSessionId_); + SetFocusedSessionId(displayId, persistentId); + UpdateBrightness(focusedSessionId); FocusIDChange(persistentId, sceneSession); } else if (persistentId == GetFocusedSessionId()) { - SetFocusedSessionId(INVALID_SESSION_ID); + SetFocusedSessionId(displayId, INVALID_SESSION_ID); } // notify window manager sptr focusChangeInfo = sptr::MakeSptr( @@ -6429,7 +6518,7 @@ void SceneSessionManager::RegisterSessionInfoChangeNotifyManagerFunc(sptr& sceneSession) +void SceneSessionManager::RegisterRequestFocusStatusNotifyManagerFunc(const sptr& sceneSession) { if (sceneSession == nullptr) { WLOGFE("session is nullptr"); @@ -6567,12 +6656,20 @@ __attribute__((no_sanitize("cfi"))) void SceneSessionManager::OnSessionStateChan void SceneSessionManager::ProcessFocusWhenForeground(sptr& sceneSession) { auto persistentId = sceneSession->GetPersistentId(); + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return; + } + bool needBlockNotifyFocusStatusUntilForeground = focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground(); + bool needBlockNotifyUnfocusStatus = focusGroup->GetNeedBlockNotifyUnfocusStatus(); if (sceneSession->GetWindowType() == WindowType::WINDOW_TYPE_APP_MAIN_WINDOW && - persistentId == focusedSessionId_) { - if (needBlockNotifyFocusStatusUntilForeground_) { - needBlockNotifyUnfocusStatus_ = false; - needBlockNotifyFocusStatusUntilForeground_ = false; - NotifyFocusStatus(sceneSession, true); + persistentId == focusGroup->GetFocusedSessionId()) { + if (focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground()) { + focusGroup->SetNeedBlockNotifyFocusStatusUntilForeground(false); + focusGroup->SetNeedBlockNotifyUnfocusStatus(false); + NotifyFocusStatus(sceneSession, true, focusGroup); } } else if (!sceneSession->IsFocusedOnShow()) { if (IsSessionVisibleForeground(sceneSession)) { @@ -6749,16 +6846,24 @@ void SceneSessionManager::ProcessSubSessionForeground(sptr& sceneS continue; } NotifyWindowInfoChange(modal->GetPersistentId(), WindowUpdateType::WINDOW_UPDATE_ADDED); - if (modal->GetPersistentId() == focusedSessionId_ && needBlockNotifyFocusStatusUntilForeground_) { - needBlockNotifyUnfocusStatus_ = false; - needBlockNotifyFocusStatusUntilForeground_ = false; - NotifyFocusStatus(modalSession, true); + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return; + } + auto focusedSessionId = focusGroup->GetFocusedSessionId(); + bool needBlockNotifyFocusStatusUntilForeground = focusGroup->GetNeedBlockNotifyFocusStatusUntilForeground(); + if (modal->GetPersistentId() == focusedSessionId && needBlockNotifyFocusStatusUntilForeground) { + focusGroup->SetNeedBlockNotifyFocusStatusUntilForeground(false); + focusGroup->SetNeedBlockNotifyUnfocusStatus(false); + NotifyFocusStatus(modalSession, true, focusGroup); } HandleKeepScreenOn(modalSession, modalSession->IsKeepScreenOn()); } } -WSError SceneSessionManager::ProcessModalTopmostRequestFocusImmdediately(sptr& sceneSession) +WSError SceneSessionManager::ProcessModalTopmostRequestFocusImmdediately(const sptr& sceneSession) { // focus must on modal topmost subwindow when APP_MAIN_WINDOW or sub winodw request focus sptr mainSession = nullptr; @@ -6778,11 +6883,14 @@ WSError SceneSessionManager::ProcessModalTopmostRequestFocusImmdediately(sptr& iter) { return iter && iter->GetPersistentId() == focusedSessionId_; }) - != topmostVec.end()) { - TLOGND(WmsLogTag::WMS_SUB, "modal topmost subwindow id: %{public}d has been focused!", focusedSessionId_); - return WSError::WS_OK; + auto displayId = mainSession->GetSessionProperty()->GetDisplayId(); + auto focusedSessionId = windowFocusController_->GetFocusedSessionId(displayId); + auto conditionFunc = [this, focusedSessionId](const sptr& iter) { + return iter && iter->GetPersistentId() == focusedSessionId; + }; + if (std::find_if(topmostVec.begin(), topmostVec.end(), std::move(conditionFunc)) != topmostVec.end()) { + TLOGD(WmsLogTag::WMS_SUB, "modal topmost subwindow id: %{public}d has been focused!", focusedSessionId); + return WSError::WS_OK; } WSError ret = WSError::WS_DO_NOTHING; for (auto topmostSession : topmostVec) { @@ -6797,7 +6905,7 @@ WSError SceneSessionManager::ProcessModalTopmostRequestFocusImmdediately(sptr& sceneSession) +WSError SceneSessionManager::ProcessDialogRequestFocusImmdediately(const sptr& sceneSession) { // focus must on dialog when APP_MAIN_WINDOW or sub winodw request focus sptr mainSession = nullptr; @@ -6811,11 +6919,14 @@ WSError SceneSessionManager::ProcessDialogRequestFocusImmdediately(sptr> dialogVec = mainSession->GetDialogVector(); - if (std::find_if(dialogVec.begin(), dialogVec.end(), - [this](sptr& iter) { return iter && iter->GetPersistentId() == focusedSessionId_; }) - != dialogVec.end()) { - TLOGND(WmsLogTag::WMS_DIALOG, "dialog id: %{public}d has been focused!", focusedSessionId_); - return WSError::WS_OK; + auto displayId = mainSession->GetSessionProperty()->GetDisplayId(); + auto focusedSessionId = windowFocusController_->GetFocusedSessionId(displayId); + auto conditionFunc = [this, focusedSessionId](const sptr& iter) { + return iter && iter->GetPersistentId() == focusedSessionId; + }; + if (std::find_if(dialogVec.begin(), dialogVec.end(), std::move(conditionFunc)) != dialogVec.end()) { + TLOGD(WmsLogTag::WMS_DIALOG, "dialog id: %{public}d has been focused!", focusedSessionId); + return WSError::WS_OK; } WSError ret = WSError::WS_DO_NOTHING; for (auto dialog : dialogVec) { @@ -8234,7 +8345,8 @@ bool SceneSessionManager::FillWindowInfo(std::vectoruiNodeId_ = sceneSession->GetUINodeId(); WSRect wsrect = sceneSession->GetSessionGlobalRect(); // only accessability and mmi need global info->windowRect_ = {wsrect.posX_, wsrect.posY_, wsrect.width_, wsrect.height_ }; - info->focused_ = sceneSession->GetPersistentId() == focusedSessionId_; + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + info->focused_ = sceneSession->GetPersistentId() == GetFocusedSessionId(displayId); info->type_ = sceneSession->GetWindowType(); info->mode_ = sceneSession->GetWindowMode(); info->layer_ = sceneSession->GetZOrder(); @@ -8877,15 +8989,21 @@ void SceneSessionManager::ClearDisplayStatusBarTemporarilyFlags() } } -WSError SceneSessionManager::GetFocusSessionToken(sptr& token) +WSError SceneSessionManager::GetFocusSessionToken(sptr& token, DisplayId displayId) { if (!SessionPermission::IsSACalling()) { WLOGFE("permission denied!"); return WSError::WS_ERROR_INVALID_PERMISSION; } - return taskScheduler_->PostSyncTask([this, &token, where = __func__]() { - TLOGND(WmsLogTag::WMS_FOCUS, "%{public}s with focusedSessionId: %{public}d", where, focusedSessionId_); - if (auto sceneSession = GetSceneSession(focusedSessionId_)) { + return taskScheduler_->PostSyncTask([this, &token, where = __func__, displayId]() { + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGNE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return WSError::WS_ERROR_INVALID_SESSION; + } + TLOGND(WmsLogTag::WMS_FOCUS, "%{public}s with focusedSessionId: %{public}d", + where, focusGroup->GetFocusedSessionId()); + if (auto sceneSession = GetSceneSession(focusGroup->GetFocusedSessionId())) { token = sceneSession->GetAbilityToken(); if (token == nullptr) { TLOGNE(WmsLogTag::WMS_FOCUS, "token is nullptr"); @@ -8897,7 +9015,7 @@ WSError SceneSessionManager::GetFocusSessionToken(sptr& token) }, __func__); } -WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName& element) +WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId) { auto pid = IPCSkeleton::GetCallingRealPid(); AppExecFwk::RunningProcessInfo info; @@ -8906,9 +9024,15 @@ WSError SceneSessionManager::GetFocusSessionElement(AppExecFwk::ElementName& ele WLOGFE("permission denied!"); return WSError::WS_ERROR_INVALID_PERMISSION; } - return taskScheduler_->PostSyncTask([this, &element, where = __func__]() { - TLOGND(WmsLogTag::WMS_FOCUS, "%{public}s with focusedSessionId: %{public}d", where, focusedSessionId_); - if (auto sceneSession = GetSceneSession(focusedSessionId_)) { + return taskScheduler_->PostSyncTask([this, &element, where = __func__, displayId]() { + auto focusGroup = windowFocusController_->GetFocusGroup(displayId); + if (focusGroup == nullptr) { + TLOGNE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, displayId); + return WSError::WS_ERROR_INVALID_SESSION; + } + TLOGND(WmsLogTag::WMS_FOCUS, "%{public}s with focusedSessionId: %{public}d", + where, focusGroup->GetFocusedSessionId()); + if (auto sceneSession = GetSceneSession(focusGroup->GetFocusedSessionId())) { const auto& sessionInfo = sceneSession->GetSessionInfo(); element = AppExecFwk::ElementName("", sessionInfo.bundleName_, sessionInfo.abilityName_, sessionInfo.moduleName_); @@ -9464,6 +9588,42 @@ void DisplayChangeListener::OnDisplayStateChange(DisplayId defaultDisplayId, spt } } +bool CheckIfNeedMultipleFocus(const std::string& name, const ScreenType& screenType) +{ + if (screenType == ScreenType::VIRTUAL && (name == "HiCar" || name == "SuperLauncher" || name == "CeliaView")) { + return true; + } + return false; +} + +void ScreenConnectionChangeListener::OnScreenConnected(const sptr& screenSession) +{ + if (screenSession == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "screenSession is nullptr"); + return; + } + TLOGI(WmsLogTag::WMS_FOCUS, "name: %{public}s, screenId: %{public}" PRIu64 ", screenType: %{public}u", + screenSession->GetName().c_str(), screenSession->GetScreenId(), + screenSession->GetScreenProperty().GetScreenType()); + if (CheckIfNeedMultipleFocus(screenSession->GetName(), screenSession->GetScreenProperty().GetScreenType())) { + SceneSessionManager::GetInstance().AddFocusGroup(screenSession->GetScreenId()); + } +} + +void ScreenConnectionChangeListener::OnScreenDisconnected(const sptr& screenSession) +{ + if (screenSession == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "screenSession is nullptr"); + return; + } + TLOGI(WmsLogTag::WMS_FOCUS, "name: %{public}s, screenId: %{public}" PRIu64 ", screenType: %{public}u", + screenSession->GetName().c_str(), screenSession->GetScreenId(), + screenSession->GetScreenProperty().GetScreenType()); + if (CheckIfNeedMultipleFocus(screenSession->GetName(), screenSession->GetScreenProperty().GetScreenType())) { + SceneSessionManager::GetInstance().RemoveFocusGroup(screenSession->GetScreenId()); + } +} + void DisplayChangeListener::OnScreenshot(DisplayId displayId) { SceneSessionManager::GetInstance().OnScreenshot(displayId); @@ -10192,12 +10352,18 @@ void SceneSessionManager::FlushUIParams(ScreenId screenId, std::unordered_map& zOrderList) { - TLOGD(WmsLogTag::WMS_FOCUS, "last focused app: %{public}d, list size %{public}zu", lastFocusedAppSessionId_, - zOrderList.size()); - if (lastFocusedAppSessionId_ == INVALID_SESSION_ID || zOrderList.empty()) { + auto focusGroup = windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + if (focusGroup == nullptr) { + TLOGE(WmsLogTag::WMS_FOCUS, "focus group is nullptr: %{public}" PRIu64, DEFAULT_DISPLAY_ID); + return; + } + auto lastFocusedAppSessionId = focusGroup->GetLastFocusedAppSessionId(); + TLOGD(WmsLogTag::WMS_FOCUS, "last focused app: %{public}d, list size %{public}zu", + lastFocusedAppSessionId, zOrderList.size()); + if (lastFocusedAppSessionId == INVALID_SESSION_ID || zOrderList.empty()) { return; } - auto lastFocusedAppSession = GetSceneSession(lastFocusedAppSessionId_); + auto lastFocusedAppSession = GetSceneSession(lastFocusedAppSessionId); if (lastFocusedAppSession == nullptr) { return; } @@ -10207,7 +10373,7 @@ void SceneSessionManager::ProcessUpdateLastFocusedAppId(const std::vectorSetLastFocusedAppSessionId(INVALID_SESSION_ID); } } @@ -10220,7 +10386,8 @@ void SceneSessionManager::ProcessFocusZOrderChange(uint32_t dirty) return; } TLOGD(WmsLogTag::WMS_FOCUS, "has zOrder dirty"); - auto focusedSession = GetSceneSession(focusedSessionId_); + auto focusedSessionId = GetFocusedSessionId(DEFAULT_DISPLAY_ID); + auto focusedSession = GetSceneSession(focusedSessionId); // only when it's from a high zOrder to a low zOrder if (focusedSession == nullptr || focusedSession->GetWindowType() == WindowType::WINDOW_TYPE_VOICE_INTERACTION || focusedSession->GetLastZOrder() <= focusedSession->GetZOrder()) { @@ -10265,18 +10432,20 @@ void SceneSessionManager::PostProcessFocus() std::sort(processingSessions.begin(), processingSessions.end(), cmp); // only change focus one time - bool focusChanged = false; + std::unordered_set focusChangedSet; for (auto iter = processingSessions.begin(); iter != processingSessions.end(); ++iter) { auto session = iter->second; if (session == nullptr) { WLOGFE("session is nullptr"); continue; } + auto displayId = session->GetSessionProperty()->GetDisplayId(); + auto displayGroupId = windowFocusController_->GetDisplayGroupId(displayId); TLOGD(WmsLogTag::WMS_PIPELINE, "id: %{public}d, isFocused: %{public}d, reason: %{public}d, focusableOnShow: %{public}d", session->GetPersistentId(), session->GetPostProcessFocusState().isFocused_, session->GetPostProcessFocusState().reason_, session->IsFocusableOnShow()); - if (focusChanged) { + if (focusChangedSet.find(displayGroupId) != focusChangedSet.end()) { session->ResetPostProcessFocusState(); continue; } @@ -10308,7 +10477,7 @@ void SceneSessionManager::PostProcessFocus() session->ResetPostProcessFocusState(); // if succeed then end process if (ret == WSError::WS_OK) { - focusChanged = true; + focusChangedSet.insert(displayGroupId); } } } @@ -10417,15 +10586,7 @@ WSError SceneSessionManager::RaiseWindowToTop(int32_t persistentId) WSError SceneSessionManager::ShiftAppWindowFocus(int32_t sourcePersistentId, int32_t targetPersistentId) { - WLOGFI("from id: %{public}d to id: %{public}d", sourcePersistentId, targetPersistentId); - if (sourcePersistentId != focusedSessionId_) { - WLOGFE("source session need be focused"); - return WSError::WS_ERROR_INVALID_OPERATION; - } - if (targetPersistentId == focusedSessionId_) { - WLOGFE("target session has been focused"); - return WSError::WS_DO_NOTHING; - } + TLOGI(WmsLogTag::WMS_FOCUS, "from id: %{public}d to id: %{public}d", sourcePersistentId, targetPersistentId); sptr sourceSession = nullptr; WSError ret = GetAppMainSceneSession(sourceSession, sourcePersistentId); if (ret != WSError::WS_OK) { @@ -10436,8 +10597,19 @@ WSError SceneSessionManager::ShiftAppWindowFocus(int32_t sourcePersistentId, int if (ret != WSError::WS_OK) { return ret; } + auto displayId = sourceSession->GetSessionProperty()->GetDisplayId(); + auto focusedSessionId = GetFocusedSessionId(displayId); + if (sourcePersistentId != focusedSessionId) { + TLOGE(WmsLogTag::WMS_FOCUS, "source session need be focused, focusedSessionId: %{public}d", focusedSessionId); + return WSError::WS_ERROR_INVALID_OPERATION; + } + if (targetPersistentId == focusedSessionId) { + TLOGE(WmsLogTag::WMS_FOCUS, "target session has been focused, focusedSessionId: %{public}d", focusedSessionId); + return WSError::WS_DO_NOTHING; + } + if (sourceSession->GetSessionInfo().bundleName_ != targetSession->GetSessionInfo().bundleName_) { - WLOGFE("verify bundle failed, source name is %{public}s but target name is %{public}s)", + TLOGE(WmsLogTag::WMS_FOCUS, "verify bundle failed, source name is %{public}s but target name is %{public}s)", sourceSession->GetSessionInfo().bundleName_.c_str(), targetSession->GetSessionInfo().bundleName_.c_str()); return WSError::WS_ERROR_INVALID_CALLING; } @@ -11490,14 +11662,15 @@ WMError SceneSessionManager::GetCallingWindowWindowStatus(int32_t persistentId, TLOGE(WmsLogTag::WMS_KEYBOARD, "sceneSession is null, persistentId: %{public}d", persistentId); return WMError::WM_ERROR_NULLPTR; } - + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusedSessionId = GetFocusedSessionId(displayId); TLOGD(WmsLogTag::WMS_KEYBOARD, "persistentId: %{public}d, windowType: %{public}d", persistentId, sceneSession->GetWindowType()); uint32_t callingWindowId = sceneSession->GetSessionProperty()->GetCallingSessionId(); auto callingSession = GetSceneSession(callingWindowId); if (callingSession == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "callingsSession is null"); - callingSession = GetSceneSession(focusedSessionId_); + callingSession = GetSceneSession(focusedSessionId); if (callingSession == nullptr) { TLOGE(WmsLogTag::WMS_KEYBOARD, "callingsSession obtained through focusedSession fail"); return WMError::WM_ERROR_INVALID_WINDOW; @@ -11525,13 +11698,15 @@ WMError SceneSessionManager::GetCallingWindowRect(int32_t persistentId, Rect& re TLOGE(WmsLogTag::WMS_KEYBOARD, "sceneSession is null, persistentId: %{public}d", persistentId); return WMError::WM_ERROR_NULLPTR; } + auto displayId = sceneSession->GetSessionProperty()->GetDisplayId(); + auto focusedSessionId = GetFocusedSessionId(displayId); TLOGD(WmsLogTag::WMS_KEYBOARD, "persistentId: %{public}d, windowType: %{public}d", persistentId, sceneSession->GetWindowType()); uint32_t callingWindowId = sceneSession->GetSessionProperty()->GetCallingSessionId(); auto callingSession = GetSceneSession(callingWindowId); if (callingSession == nullptr) { TLOGI(WmsLogTag::WMS_KEYBOARD, "callingsSession is null"); - callingSession = GetSceneSession(focusedSessionId_); + callingSession = GetSceneSession(focusedSessionId); if (callingSession == nullptr) { TLOGE(WmsLogTag::WMS_KEYBOARD, "callingsSession obtained through focusedSession fail"); return WMError::WM_ERROR_INVALID_WINDOW; @@ -11813,7 +11988,7 @@ WMError SceneSessionManager::MakeScreenFoldData(const std::vector& } AppExecFwk::ElementName element = {}; WSError ret = GetFocusSessionElement(element); - auto sceneSession = GetSceneSession(focusedSessionId_); + auto sceneSession = GetSceneSession(windowFocusController_->GetFocusedSessionId(DEFAULT_DISPLAY_ID)); if (sceneSession == nullptr || ret != WSError::WS_OK) { TLOGI(WmsLogTag::DMS, "Error: fail to get focused package name."); return WMError::WM_DO_NOTHING; @@ -12513,7 +12688,7 @@ WMError SceneSessionManager::ShiftAppWindowPointerEvent(int32_t sourcePersistent return WMError::WM_ERROR_INVALID_CALLING; } if (sourceSession->GetSessionInfo().bundleName_ != targetSession->GetSessionInfo().bundleName_) { - TLOGE(WmsLogTag::WMS_PC, "verify bundle failed, source name is %{public}s but target name is %{public}s)", + TLOGE(WmsLogTag::WMS_PC, "verify bundle failed, source name is %{public}s but target name is %{public}s", sourceSession->GetSessionInfo().bundleName_.c_str(), targetSession->GetSessionInfo().bundleName_.c_str()); return WMError::WM_ERROR_INVALID_CALLING; } diff --git a/window_scene/session_manager/src/scene_session_manager_lite.cpp b/window_scene/session_manager/src/scene_session_manager_lite.cpp index 63ba18106e52c3e69a591123d13ad3fe4e736299..e97ed30f31370b3c41fc711fbc054d6a98de02eb 100644 --- a/window_scene/session_manager/src/scene_session_manager_lite.cpp +++ b/window_scene/session_manager/src/scene_session_manager_lite.cpp @@ -119,16 +119,16 @@ WSError SceneSessionManagerLite::PendingSessionToBackgroundForDelegator(const sp return SceneSessionManager::GetInstance().PendingSessionToBackgroundForDelegator(token, shouldBackToCaller); } -WSError SceneSessionManagerLite::GetFocusSessionToken(sptr& token) +WSError SceneSessionManagerLite::GetFocusSessionToken(sptr& token, DisplayId displayId) { WLOGFD("in"); - return SceneSessionManager::GetInstance().GetFocusSessionToken(token); + return SceneSessionManager::GetInstance().GetFocusSessionToken(token, displayId); } -WSError SceneSessionManagerLite::GetFocusSessionElement(AppExecFwk::ElementName& element) +WSError SceneSessionManagerLite::GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId) { WLOGFD("in"); - return SceneSessionManager::GetInstance().GetFocusSessionElement(element); + return SceneSessionManager::GetInstance().GetFocusSessionElement(element, displayId); } WSError SceneSessionManagerLite::ClearSession(int32_t persistentId) @@ -168,9 +168,9 @@ WSError SceneSessionManagerLite::MoveSessionsToBackground(const std::vector %{public}d", focusedSessionId_, persistentId); if (focusedSessionId_ == persistentId) { - TLOGD(WmsLogTag::WMS_FOCUS, "Focus scene not change, id: %{public}d", focusedSessionId_); + TLOGD(WmsLogTag::WMS_FOCUS, "focus scene not change, id: %{public}d", focusedSessionId_); return WSError::WS_DO_NOTHING; } lastFocusedSessionId_ = focusedSessionId_; diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp index 0e1c6372e6c42eaaa64ab9cb27b21a589409be8e..803b001c11935dd97ff3e18611654330bb123702 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_proxy.cpp @@ -452,7 +452,7 @@ WSError SceneSessionManagerLiteProxy::TerminateSessionNew(const sptr(reply.ReadInt32()); } -WSError SceneSessionManagerLiteProxy::GetFocusSessionToken(sptr& token) +WSError SceneSessionManagerLiteProxy::GetFocusSessionToken(sptr& token, DisplayId displayId) { WLOGFD("run SceneSessionManagerLiteProxy::GetFocusSessionToken"); MessageParcel data; @@ -462,7 +462,10 @@ WSError SceneSessionManagerLiteProxy::GetFocusSessionToken(sptr& WLOGFE("Write interfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; } - + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "write displayId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -480,7 +483,7 @@ WSError SceneSessionManagerLiteProxy::GetFocusSessionToken(sptr& return static_cast(reply.ReadInt32()); } -WSError SceneSessionManagerLiteProxy::GetFocusSessionElement(AppExecFwk::ElementName& element) +WSError SceneSessionManagerLiteProxy::GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId) { WLOGFD("run SceneSessionManagerLiteProxy::GetFocusSessionElement"); MessageParcel data; @@ -490,6 +493,10 @@ WSError SceneSessionManagerLiteProxy::GetFocusSessionElement(AppExecFwk::Element WLOGFE("Write interfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; } + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "write displayId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -760,7 +767,7 @@ WSError SceneSessionManagerLiteProxy::ClearAllSessions() return static_cast(reply.ReadInt32()); } -void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { WLOGFD("get focus Winow info lite proxy"); MessageParcel data; @@ -770,7 +777,10 @@ void SceneSessionManagerLiteProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo WLOGFE("WriteInterfaceToken failed"); return; } - + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "write displayId failed"); + return; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -981,7 +991,6 @@ WMError SceneSessionManagerLiteProxy::GetWindowModeType(WindowModeType& windowMo WLOGFE("WriteInterfaceToken failed"); return WMError::WM_ERROR_IPC_FAILED; } - MessageParcel reply; MessageOption option; sptr remote = Remote(); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp index c6828890af19e72fb6412594a1b7a6067e0532cc..92ff36763dfeb27dd08959092778700f1f32dd9f 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_lite_stub.cpp @@ -369,9 +369,14 @@ int SceneSessionManagerLiteStub::HandleTerminateSessionNew(MessageParcel& data, int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel& data, MessageParcel& reply) { - WLOGFD("run HandleGetFocusSessionToken!"); + TLOGD(WmsLogTag::WMS_FOCUS, "run"); + uint64_t displayId = 0; + if (!data.ReadUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId"); + return ERR_INVALID_DATA; + } sptr token = nullptr; - WSError errCode = GetFocusSessionToken(token); + WSError errCode = GetFocusSessionToken(token, displayId); reply.WriteRemoteObject(token); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; @@ -379,9 +384,14 @@ int SceneSessionManagerLiteStub::HandleGetFocusSessionToken(MessageParcel& data, int SceneSessionManagerLiteStub::HandleGetFocusSessionElement(MessageParcel& data, MessageParcel& reply) { - WLOGFD("run HandleGetFocusSessionElement!"); + TLOGD(WmsLogTag::WMS_FOCUS, "run"); + uint64_t displayId = 0; + if (!data.ReadUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId"); + return ERR_INVALID_DATA; + } AppExecFwk::ElementName element; - WSError errCode = GetFocusSessionElement(element); + WSError errCode = GetFocusSessionElement(element, displayId); reply.WriteParcelable(&element); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; @@ -510,9 +520,14 @@ int SceneSessionManagerLiteStub::HandleMoveSessionsToBackground(MessageParcel& d int SceneSessionManagerLiteStub::HandleGetFocusSessionInfo(MessageParcel& data, MessageParcel& reply) { - WLOGFD("run"); + TLOGD(WmsLogTag::WMS_FOCUS, "run"); + uint64_t displayId = 0; + if (!data.ReadUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId"); + return ERR_INVALID_DATA; + } FocusChangeInfo focusInfo; - GetFocusWindowInfo(focusInfo); + GetFocusWindowInfo(focusInfo, displayId); reply.WriteParcelable(&focusInfo); return ERR_NONE; } diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp index 6cb27697e12c6d032120d66d35375342d5d197cd..badcac33bda37bf20feb9a28e8afc5089a3aabe3 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_proxy.cpp @@ -618,7 +618,7 @@ WMError SceneSessionManagerProxy::SetGestureNavigationEnabled(bool enable) return static_cast(ret); } -void SceneSessionManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void SceneSessionManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { MessageParcel data; MessageParcel reply; @@ -627,7 +627,10 @@ void SceneSessionManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo) WLOGFE("WriteInterfaceToken failed"); return; } - + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "write displayId failed"); + return; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -1161,7 +1164,7 @@ WSError SceneSessionManagerProxy::TerminateSessionNew(const sptr(reply.ReadInt32()); } -WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr& token) +WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr& token, DisplayId displayId) { WLOGFD("run SceneSessionManagerProxy::GetFocusSessionToken"); MessageParcel data; @@ -1171,7 +1174,10 @@ WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr& toke WLOGFE("Write interfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; } - + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -1189,7 +1195,7 @@ WSError SceneSessionManagerProxy::GetFocusSessionToken(sptr& toke return static_cast(reply.ReadInt32()); } -WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName& element) +WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId) { WLOGFD("run SceneSessionManagerProxy::GetFocusSessionElement"); MessageParcel data; @@ -1199,6 +1205,10 @@ WSError SceneSessionManagerProxy::GetFocusSessionElement(AppExecFwk::ElementName WLOGFE("Write interfaceToken failed"); return WSError::WS_ERROR_IPC_FAILED; } + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "write displayId failed"); + return WSError::WS_ERROR_IPC_FAILED; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); diff --git a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp index 6f69893a87205634a4a23934d8a6eaa07ccbc826..ccf283c3cc00483812670e222877a94346b7809d 100644 --- a/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp +++ b/window_scene/session_manager/src/zidl/scene_session_manager_stub.cpp @@ -421,7 +421,12 @@ int SceneSessionManagerStub::HandleGetFocusSessionInfo(MessageParcel& data, Mess { WLOGFD("run HandleGetFocusSessionInfo!"); FocusChangeInfo focusInfo; - GetFocusWindowInfo(focusInfo); + uint64_t displayId = 0; + if (!data.ReadUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId"); + return ERR_INVALID_DATA; + } + GetFocusWindowInfo(focusInfo, displayId); reply.WriteParcelable(&focusInfo); return ERR_NONE; } @@ -661,7 +666,12 @@ int SceneSessionManagerStub::HandleGetFocusSessionToken(MessageParcel& data, Mes { WLOGFD("run HandleGetFocusSessionToken!"); sptr token = nullptr; - WSError errCode = GetFocusSessionToken(token); + uint64_t displayId = 0; + if (!data.ReadUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId"); + return ERR_INVALID_DATA; + } + WSError errCode = GetFocusSessionToken(token, displayId); reply.WriteRemoteObject(token); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; @@ -671,7 +681,12 @@ int SceneSessionManagerStub::HandleGetFocusSessionElement(MessageParcel& data, M { WLOGFD("run HandleGetFocusSessionElement!"); AppExecFwk::ElementName element; - WSError errCode = GetFocusSessionElement(element); + uint64_t displayId = 0; + if (!data.ReadUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId"); + return ERR_INVALID_DATA; + } + WSError errCode = GetFocusSessionElement(element, displayId); reply.WriteParcelable(&element); reply.WriteInt32(static_cast(errCode)); return ERR_NONE; diff --git a/window_scene/test/unittest/intention_event_manager_test.cpp b/window_scene/test/unittest/intention_event_manager_test.cpp index 75c8c27af3de4b021d0ac2ffbd0052aaadf54174..421fe279e88e1ee6731a3aee48e09e9fef6dd9c1 100644 --- a/window_scene/test/unittest/intention_event_manager_test.cpp +++ b/window_scene/test/unittest/intention_event_manager_test.cpp @@ -156,11 +156,11 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent1, Function | MediumTest | Level inputEventListener_->OnInputEvent(keyEvent); SceneSessionManager::GetInstance().SetEnableInputEvent(true); - SceneSessionManager::GetInstance().SetFocusedSessionId(INVALID_SESSION_ID); + SceneSessionManager::GetInstance().SetFocusedSessionId(INVALID_SESSION_ID, DEFAULT_DISPLAY_ID); EXPECT_EQ(INVALID_SESSION_ID, SceneSessionManager::GetInstance().GetFocusedSessionId()); inputEventListener_->OnInputEvent(keyEvent); - SceneSessionManager::GetInstance().SetFocusedSessionId(1); + SceneSessionManager::GetInstance().SetFocusedSessionId(1, DEFAULT_DISPLAY_ID); inputEventListener_->OnInputEvent(keyEvent); SessionInfo info; @@ -180,7 +180,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent1, Function | MediumTest | Level sptr sceneSession1 = sptr::MakeSptr(info, callback); EXPECT_NE(nullptr, sceneSession1); SceneSessionManager::GetInstance().sceneSessionMap_.emplace(std::make_pair(2, sceneSession1)); - SceneSessionManager::GetInstance().SetFocusedSessionId(2); + SceneSessionManager::GetInstance().SetFocusedSessionId(2, DEFAULT_DISPLAY_ID); EXPECT_EQ(2, SceneSessionManager::GetInstance().GetFocusedSessionId()); auto focusedSceneSession = SceneSessionManager::GetInstance().GetSceneSession(2); inputEventListener_->OnInputEvent(keyEvent); @@ -197,7 +197,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent2, Function | MediumTest | Level std::shared_ptr keyEvent = MMI::KeyEvent::Create(); EXPECT_NE(nullptr, keyEvent); SceneSessionManager::GetInstance().SetEnableInputEvent(true); - SceneSessionManager::GetInstance().SetFocusedSessionId(1); + SceneSessionManager::GetInstance().SetFocusedSessionId(1, DEFAULT_DISPLAY_ID); SessionInfo info; info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; @@ -235,7 +235,7 @@ HWTEST_F(IntentionEventManagerTest, OnInputEvent3, Function | MediumTest | Level std::shared_ptr keyEvent = MMI::KeyEvent::Create(); EXPECT_NE(nullptr, keyEvent); SceneSessionManager::GetInstance().SetEnableInputEvent(true); - SceneSessionManager::GetInstance().SetFocusedSessionId(1); + SceneSessionManager::GetInstance().SetFocusedSessionId(1, DEFAULT_DISPLAY_ID); SessionInfo info; info.bundleName_ = "IntentionEventManager"; info.moduleName_ = "InputEventListener"; diff --git a/window_scene/test/unittest/scene_input_manager_test.cpp b/window_scene/test/unittest/scene_input_manager_test.cpp index a60d2f73c4bddb47f9fc9108b9ab036f8c370be3..490f0e522883b836d44920e1c835f42e7b36d411 100644 --- a/window_scene/test/unittest/scene_input_manager_test.cpp +++ b/window_scene/test/unittest/scene_input_manager_test.cpp @@ -345,7 +345,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate1, Function | SmallTest | Level3) std::vector displayInfos; std::vector windowInfoList; int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId); + Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); SceneInputManager::GetInstance().lastFocusId_ = 1; bool ret1 = SceneInputManager::GetInstance().CheckNeedUpdate(displayInfos, windowInfoList); ASSERT_TRUE(ret1); @@ -376,7 +376,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate2, Function | SmallTest | Level3) displayInfos.emplace_back(displayinfo); MMI::WindowInfo windowinfo; int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId); + Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); SceneInputManager::GetInstance().lastFocusId_ = 0; SceneInputManager::GetInstance().lastDisplayInfos_ = displayInfos; SceneInputManager::GetInstance().lastWindowInfoList_ = windowInfoList; @@ -442,7 +442,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate3, Function | SmallTest | Level3) MMI::WindowInfo windowinfo; windowInfoList.emplace_back(windowinfo); int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId); + Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); SceneInputManager::GetInstance().lastFocusId_ = 0; SceneInputManager::GetInstance().lastDisplayInfos_ = displayInfos; SceneInputManager::GetInstance().lastWindowInfoList_ = windowInfoList; @@ -498,7 +498,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate4, Function | SmallTest | Level3) MMI::WindowInfo windowinfo; windowInfoList.emplace_back(windowinfo); int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId); + Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); SceneInputManager::GetInstance().lastFocusId_ = 0; SceneInputManager::GetInstance().lastDisplayInfos_ = displayInfos; SceneInputManager::GetInstance().lastWindowInfoList_ = windowInfoList; @@ -551,7 +551,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate5, Function | SmallTest | Level3) MMI::WindowInfo windowinfo; windowInfoList.emplace_back(windowinfo); int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId); + Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); SceneInputManager::GetInstance().lastFocusId_ = 0; SceneInputManager::GetInstance().lastDisplayInfos_ = displayInfos; SceneInputManager::GetInstance().lastWindowInfoList_ = windowInfoList; @@ -603,7 +603,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate6, Function | SmallTest | Level3) MMI::WindowInfo windowinfo; windowInfoList.emplace_back(windowinfo); int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId); + Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); SceneInputManager::GetInstance().lastFocusId_ = 0; SceneInputManager::GetInstance().lastDisplayInfos_ = displayInfos; SceneInputManager::GetInstance().lastWindowInfoList_ = windowInfoList; @@ -659,7 +659,7 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate7, Function | SmallTest | Level3) MMI::WindowInfo windowinfo; windowInfoList.emplace_back(windowinfo); int32_t focusId = 0; - Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId); + Rosen::SceneSessionManager::GetInstance().SetFocusedSessionId(focusId, DEFAULT_DISPLAY_ID); SceneInputManager::GetInstance().lastFocusId_ = 0; SceneInputManager::GetInstance().lastDisplayInfos_ = displayInfos; SceneInputManager::GetInstance().lastWindowInfoList_ = windowInfoList; diff --git a/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp b/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp index 101345632861d57a3610424be1a68dd82025ec01..d83300c5dd02439b222dc96f39407da8f911e83d 100644 --- a/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp +++ b/window_scene/test/unittest/scene_session_dirty_manager_test2.cpp @@ -595,7 +595,8 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithSameInfo, Function | Sm std::vector currWindowInfoList; currDisplayInfos.emplace_back(currDisplayedInfo); currWindowInfoList.emplace_back(currWindowInfo); - ssm_->focusedSessionId_ = focusedSession; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(focusedSession); bool checkNeedUpdateFlag = true; // check the same information checkNeedUpdateFlag = sim_->CheckNeedUpdate(currDisplayInfos, currWindowInfoList); @@ -631,7 +632,8 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithPidDiff, Function | Sma std::vector currWindowInfoList; currDisplayInfos.emplace_back(currDisplayedInfo); currWindowInfoList.emplace_back(currWindowInfo); - ssm_->focusedSessionId_ = focusedSession; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(focusedSession); bool checkNeedUpdateFlag = false; checkNeedUpdateFlag = sim_->CheckNeedUpdate(currDisplayInfos, currWindowInfoList); ASSERT_EQ(checkNeedUpdateFlag, true); @@ -666,7 +668,8 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithAreaDiff, Function | Sm std::vector currWindowInfoList; currDisplayInfos.emplace_back(currDisplayedInfo); currWindowInfoList.emplace_back(currWindowInfo); - ssm_->focusedSessionId_ = focusedSession; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(focusedSession); bool checkNeedUpdateFlag = false; checkNeedUpdateFlag = sim_->CheckNeedUpdate(currDisplayInfos, currWindowInfoList); ASSERT_EQ(checkNeedUpdateFlag, true); @@ -701,7 +704,8 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithzOrderDiff, Function | std::vector currWindowInfoList; currDisplayInfos.emplace_back(currDisplayedInfo); currWindowInfoList.emplace_back(currWindowInfo); - ssm_->focusedSessionId_ = focusedSession; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(focusedSession); bool checkNeedUpdateFlag = false; checkNeedUpdateFlag = sim_->CheckNeedUpdate(currDisplayInfos, currWindowInfoList); ASSERT_EQ(checkNeedUpdateFlag, true); diff --git a/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp b/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp index 8819d0698360fb5b6f9157a795d50141006fd165..ff8c8101a97a558992c35231b898ecf2084b5a1c 100644 --- a/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp +++ b/window_scene/test/unittest/scene_session_manager_lifecycle_test2.cpp @@ -137,7 +137,8 @@ HWTEST_F(SceneSessionManagerLifecycleTest2, OnSessionStateChange, Function | Sma sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END); ASSERT_NE(nullptr, ssm_); ssm_->OnSessionStateChange(1, state); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->OnSessionStateChange(1, state); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ASSERT_NE(nullptr, ssm_); @@ -146,7 +147,7 @@ HWTEST_F(SceneSessionManagerLifecycleTest2, OnSessionStateChange, Function | Sma ASSERT_NE(nullptr, ssm_); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; ssm_->OnSessionStateChange(1, state); - ssm_->focusedSessionId_ = 0; + focusGroup->SetFocusedSessionId(0); ASSERT_NE(nullptr, ssm_); ssm_->OnSessionStateChange(1, state); } diff --git a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp index b2ec09a5053e8494ef5531454f71d24cc4028ba3..48d28e4f95abf05879a4cbfe3b43f8f33ebc570c 100644 --- a/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp +++ b/window_scene/test/unittest/scene_session_manager_lite_stub_test.cpp @@ -44,11 +44,11 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { { return WSError::WS_OK; } - WSError GetFocusSessionToken(sptr& token) override + WSError GetFocusSessionToken(sptr& token, DisplayId displayId) override { return WSError::WS_OK; } - WSError GetFocusSessionElement(AppExecFwk::ElementName& element) override + WSError GetFocusSessionElement(AppExecFwk::ElementName& element, DisplayId displayId) override { return WSError::WS_OK; } @@ -127,7 +127,7 @@ class MockSceneSessionManagerLiteStub : public SceneSessionManagerLiteStub { { return WMError::WM_OK; } - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) override { } WMError CheckWindowId(int32_t windowId, int32_t& pid) override diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index af3deeb7177299e9ac09089420715a0f3037cef3..00961184731c162bf4c024cf19dcaaf356a46567 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -356,7 +356,8 @@ HWTEST_F(SceneSessionManagerTest10, TestCheckLastFocusedAppSessionFocus_01, Func sptr nextSession = sptr::MakeSptr(info2, nullptr); ASSERT_NE(nextSession, nullptr); - ssm_->lastFocusedAppSessionId_ = nextSession->GetPersistentId(); + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetLastFocusedAppSessionId(nextSession->GetPersistentId()); ASSERT_EQ(false, ssm_->CheckLastFocusedAppSessionFocus(focusedSession, nextSession)); } @@ -381,13 +382,14 @@ HWTEST_F(SceneSessionManagerTest10, TestCheckLastFocusedAppSessionFocus_02, Func info2.windowType_ = 1; sptr nextSession = sptr::MakeSptr(info2, nullptr); - ssm_->lastFocusedAppSessionId_ = 124; + ssm_->windowFocusController_->UpdateFocusedAppSessionId(DEFAULT_DISPLAY_ID, 124); focusedSession->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG); ASSERT_EQ(false, ssm_->CheckLastFocusedAppSessionFocus(focusedSession, nextSession)); nextSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY); ASSERT_EQ(false, ssm_->CheckLastFocusedAppSessionFocus(focusedSession, nextSession)); - ASSERT_EQ(0, ssm_->lastFocusedAppSessionId_); + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + ASSERT_EQ(0, focusGroup->GetLastFocusedAppSessionId()); } /** @@ -558,7 +560,8 @@ HWTEST_F(SceneSessionManagerTest10, ProcessFocusZOrderChange, Function | SmallTe sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); ssm_->sceneSessionMap_.emplace(1, sceneSession); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->ProcessFocusZOrderChange(97); sceneSession->lastZOrder_ = 2203; @@ -897,7 +900,7 @@ HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | Sm { ssm_->sceneSessionMap_.clear(); std::vector zOrderList; - ssm_->lastFocusedAppSessionId_ = INVALID_SESSION_ID; + ssm_->windowFocusController_->UpdateFocusedAppSessionId(DEFAULT_DISPLAY_ID, INVALID_SESSION_ID); ssm_->ProcessUpdateLastFocusedAppId(zOrderList); SessionInfo sessionInfo; @@ -905,15 +908,16 @@ HWTEST_F(SceneSessionManagerTest10, ProcessUpdateLastFocusedAppId, Function | Sm sessionInfo.abilityName_ = "lastFocusedAppSession"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ssm_->sceneSessionMap_.emplace(1, sceneSession); - ssm_->lastFocusedAppSessionId_ = 1; + ssm_->windowFocusController_->UpdateFocusedAppSessionId(DEFAULT_DISPLAY_ID, 1); sceneSession->zOrder_ = 101; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); ssm_->ProcessUpdateLastFocusedAppId(zOrderList); - ASSERT_EQ(1, ssm_->lastFocusedAppSessionId_); + ASSERT_EQ(1, focusGroup->GetLastFocusedAppSessionId()); zOrderList.push_back(103); ssm_->ProcessUpdateLastFocusedAppId(zOrderList); - ASSERT_EQ(INVALID_SESSION_ID, ssm_->lastFocusedAppSessionId_); + ASSERT_EQ(INVALID_SESSION_ID, focusGroup->GetLastFocusedAppSessionId()); } /** @@ -982,7 +986,6 @@ HWTEST_F(SceneSessionManagerTest10, TestIsNeedSkipWindowModeTypeCheck_04, Functi sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); sceneSession->SetRSVisible(true); sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); - DisplayId displayId = 1001; sceneSession->property_->SetDisplayId(displayId); auto ret = ssm_->IsNeedSkipWindowModeTypeCheck(sceneSession, true); diff --git a/window_scene/test/unittest/scene_session_manager_test3.cpp b/window_scene/test/unittest/scene_session_manager_test3.cpp index 24cb0409a64d4350b826b1deefc75778bfd76475..3f1af7f14ef39ef6cdd31e57ca107356c9ac7764 100644 --- a/window_scene/test/unittest/scene_session_manager_test3.cpp +++ b/window_scene/test/unittest/scene_session_manager_test3.cpp @@ -1319,10 +1319,10 @@ HWTEST_F(SceneSessionManagerTest3, SetFocusedSessionId, Function | SmallTest | L int32_t focusedSession = ssm_->GetFocusedSessionId(); EXPECT_EQ(focusedSession, INVALID_SESSION_ID); int32_t persistentId = INVALID_SESSION_ID; - WSError result01 = ssm_->SetFocusedSessionId(persistentId); + WSError result01 = ssm_->SetFocusedSessionId(persistentId, DEFAULT_DISPLAY_ID); EXPECT_EQ(result01, WSError::WS_DO_NOTHING); persistentId = 10086; - WSError result02 = ssm_->SetFocusedSessionId(persistentId); + WSError result02 = ssm_->SetFocusedSessionId(persistentId, DEFAULT_DISPLAY_ID); EXPECT_EQ(result02, WSError::WS_OK); ASSERT_EQ(ssm_->GetFocusedSessionId(), 10086); } @@ -1386,10 +1386,10 @@ HWTEST_F(SceneSessionManagerTest3, NotifyRequestFocusStatusNotifyManager, Functi HWTEST_F(SceneSessionManagerTest3, GetTopNearestBlockingFocusSession, Function | SmallTest | Level3) { uint32_t zOrder = 9999; - sptr session = ssm_->GetTopNearestBlockingFocusSession(zOrder, true); + sptr session = ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, zOrder, true); EXPECT_EQ(session, nullptr); - session = ssm_->GetTopNearestBlockingFocusSession(zOrder, false); + session = ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, zOrder, false); EXPECT_EQ(session, nullptr); } @@ -1421,16 +1421,29 @@ HWTEST_F(SceneSessionManagerTest3, ShiftAppWindowFocus, Function | SmallTest | L { int32_t focusedSession = ssm_->GetFocusedSessionId(); EXPECT_EQ(focusedSession, 10086); - int32_t sourcePersistentId = INVALID_SESSION_ID; - int32_t targetPersistentId = INVALID_SESSION_ID; + int32_t sourcePersistentId = 1; + int32_t targetPersistentId = 10086; WSError result01 = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); + EXPECT_EQ(result01, WSError::WS_ERROR_INVALID_SESSION); + SessionInfo info; + info.abilityName_ = "ShiftAppWindowFocus"; + info.bundleName_ = "ShiftAppWindowFocus"; + auto sourceSceneSession = sptr::MakeSptr(info, nullptr); + sourceSceneSession->persistentId_ = 1; + sourceSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + ssm_->sceneSessionMap_.insert(std::make_pair(1, sourceSceneSession)); + result01 = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); + EXPECT_EQ(result01, WSError::WS_ERROR_INVALID_SESSION); + + auto targetSceneSession = sptr::MakeSptr(info, nullptr); + targetSceneSession->persistentId_ = 10086; + targetSceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + ssm_->sceneSessionMap_.insert(std::make_pair(10086, targetSceneSession)); + result01 = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); EXPECT_EQ(result01, WSError::WS_ERROR_INVALID_OPERATION); - targetPersistentId = 1; + sourcePersistentId = 10086; WSError result02 = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); - EXPECT_EQ(result02, WSError::WS_ERROR_INVALID_OPERATION); - sourcePersistentId = 1; - WSError result03 = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); - EXPECT_EQ(result03, WSError::WS_ERROR_INVALID_OPERATION); + EXPECT_EQ(result02, WSError::WS_DO_NOTHING); } /** diff --git a/window_scene/test/unittest/scene_session_manager_test4.cpp b/window_scene/test/unittest/scene_session_manager_test4.cpp index 1ff4c23b2226be1b63ce1c185c2d2e4b3bbabc13..b1115c0a65af0c65aa283cf0e91848b95dca56c9 100644 --- a/window_scene/test/unittest/scene_session_manager_test4.cpp +++ b/window_scene/test/unittest/scene_session_manager_test4.cpp @@ -499,8 +499,8 @@ HWTEST_F(SceneSessionManagerTest4, ReportWindowProfileInfos, Function | SmallTes sceneSession->sessionInfo_.isSystem_ = false; ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->ReportWindowProfileInfos(); - - ssm_->focusedSessionId_ = 123; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(123); ssm_->ReportWindowProfileInfos(); EXPECT_EQ(WSError::WS_ERROR_INVALID_SESSION, ssm_->HandleSecureSessionShouldHide(nullptr)); } @@ -1233,23 +1233,18 @@ HWTEST_F(SceneSessionManagerTest4, GetAccessibilityWindowInfo, Function | SmallT HWTEST_F(SceneSessionManagerTest4, ShiftAppWindowFocus02, Function | SmallTest | Level3) { ASSERT_NE(ssm_, nullptr); - ssm_->SetFocusedSessionId(INVALID_SESSION_ID); + ssm_->SetFocusedSessionId(INVALID_SESSION_ID, DEFAULT_DISPLAY_ID); int32_t sourcePersistentId = INVALID_SESSION_ID; - int32_t targetPersistentId = INVALID_SESSION_ID; - auto result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); - EXPECT_EQ(result, WSError::WS_DO_NOTHING); + int32_t targetPersistentId = 1; - targetPersistentId = 1; - result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); + auto result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION); SessionInfo info; info.abilityName_ = "abilityName"; info.bundleName_ = "bundleName"; sptr sceneSession = sptr::MakeSptr(info, nullptr); - ASSERT_NE(sceneSession, nullptr); ssm_->sceneSessionMap_.insert(std::make_pair(INVALID_SESSION_ID, sceneSession)); - ASSERT_NE(sceneSession->property_, nullptr); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION); @@ -1258,9 +1253,7 @@ HWTEST_F(SceneSessionManagerTest4, ShiftAppWindowFocus02, Function | SmallTest | info01.abilityName_ = "abilityName01"; info01.bundleName_ = "bundleName01"; sptr sceneSession01 = sptr::MakeSptr(info01, nullptr); - ASSERT_NE(sceneSession01, nullptr); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession01)); - ASSERT_NE(sceneSession01->property_, nullptr); sceneSession01->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); result = ssm_->ShiftAppWindowFocus(sourcePersistentId, targetPersistentId); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_CALLING); @@ -1765,7 +1758,7 @@ HWTEST_F(SceneSessionManagerTest4, GetNextFocusableSession, Function | SmallTest ssm_->sceneSessionMap_.insert(std::make_pair(3, sceneSession03)); ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04)); ssm_->sceneSessionMap_.insert(std::make_pair(5, sceneSession05)); - sptr result = ssm_->GetNextFocusableSession(1); + sptr result = ssm_->GetNextFocusableSession(DEFAULT_DISPLAY_ID, 1); EXPECT_EQ(result, sceneSession); } @@ -1815,10 +1808,10 @@ HWTEST_F(SceneSessionManagerTest4, GetTopNearestBlockingFocusSession, Function | ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession04)); ssm_->sceneSessionMap_.insert(std::make_pair(8, parentSceneSession)); - sptr ret = ssm_->GetTopNearestBlockingFocusSession(0, true); + sptr ret = ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 0, true); EXPECT_EQ(ret, sceneSession01); - ret = ssm_->GetTopNearestBlockingFocusSession(10, true); + ret = ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 10, true); EXPECT_EQ(ret, nullptr); } @@ -1837,7 +1830,7 @@ HWTEST_F(SceneSessionManagerTest4, RequestFocusSpecificCheck, Function | SmallTe bool byForeground = true; FocusChangeReason reason = FocusChangeReason::CLIENT_REQUEST; sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED); - WSError result = ssm_->RequestFocusSpecificCheck(sceneSession, byForeground, reason); + WSError result = ssm_->RequestFocusSpecificCheck(DEFAULT_DISPLAY_ID, sceneSession, byForeground, reason); EXPECT_EQ(result, WSError::WS_ERROR_INVALID_OPERATION); sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN); @@ -1845,7 +1838,7 @@ HWTEST_F(SceneSessionManagerTest4, RequestFocusSpecificCheck, Function | SmallTe ASSERT_NE(sceneSession01, nullptr); ssm_->sceneSessionMap_.insert(std::make_pair(0, sceneSession01)); sceneSession01->parentSession_ = sceneSession; - result = ssm_->RequestFocusSpecificCheck(sceneSession, byForeground, reason); + result = ssm_->RequestFocusSpecificCheck(DEFAULT_DISPLAY_ID, sceneSession, byForeground, reason); EXPECT_EQ(result, WSError::WS_OK); } diff --git a/window_scene/test/unittest/scene_session_manager_test5.cpp b/window_scene/test/unittest/scene_session_manager_test5.cpp index 1a74b26db284f8f8a510313ef57ebf616238f3aa..4707dc5abfdbf02756b96a81c2fe8ea804f2d721 100644 --- a/window_scene/test/unittest/scene_session_manager_test5.cpp +++ b/window_scene/test/unittest/scene_session_manager_test5.cpp @@ -558,11 +558,12 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocus, Function | SmallTest | L sceneSession1->focusedOnShow_ = true; sceneSession1->property_->focusable_ = true; sceneSession1->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - ssm_->focusedSessionId_ = 2; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(2); ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); ret = ssm_->RequestSessionFocus(1, true, reason); ASSERT_EQ(ret, WSError::WS_OK); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); ssm_->sceneSessionMap_.clear(); } @@ -608,14 +609,15 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusClient, Function | SmallTest | Le ssm_->sceneSessionMap_.insert({sceneSession2->GetPersistentId(), sceneSession2}); FocusChangeReason reason = FocusChangeReason::CLIENT_REQUEST; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); ssm_->RequestSessionFocus(1, false, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); ssm_->RequestSessionFocus(2, false, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 2); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 2); ssm_->RequestSessionUnfocus(2, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); ssm_->RequestSessionUnfocus(1, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 0); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 0); ssm_->sceneSessionMap_.clear(); } @@ -680,15 +682,16 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusClient01, Function | SmallTest | FocusChangeReason reason = FocusChangeReason::CLIENT_REQUEST; ssm_->RequestSessionFocus(1, false, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); ssm_->RequestSessionFocus(3, false, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 3); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 3); ssm_->RequestSessionFocus(2, false, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 2); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 2); auto ret = ssm_->RequestSessionUnfocus(3, reason); ASSERT_EQ(WSError::WS_DO_NOTHING, ret); ssm_->RequestSessionUnfocus(2, reason); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); ssm_->sceneSessionMap_.clear(); } @@ -705,7 +708,7 @@ HWTEST_F(SceneSessionManagerTest5, SetShiftFocusListener, Function | SmallTest | info.bundleName_ = "test2"; FocusChangeReason reason = FocusChangeReason::SPLIT_SCREEN; sptr sceneSession = nullptr; - ssm_->ShiftFocus(sceneSession, reason); + ssm_->ShiftFocus(DEFAULT_DISPLAY_ID, sceneSession, reason); info.isSystem_ = true; sptr property = sptr::MakeSptr(); ASSERT_NE(property, nullptr); @@ -720,7 +723,7 @@ HWTEST_F(SceneSessionManagerTest5, SetShiftFocusListener, Function | SmallTest | ssm_->SetCallingSessionIdSessionListenser(func1); ProcessStartUIAbilityErrorFunc func2; ssm_->SetStartUIAbilityErrorListener(func2); - ssm_->ShiftFocus(sceneSession1, reason); + ssm_->ShiftFocus(DEFAULT_DISPLAY_ID, sceneSession1, reason); } /** @@ -735,13 +738,36 @@ HWTEST_F(SceneSessionManagerTest5, UpdateFocusStatus, Function | SmallTest | Lev info.abilityName_ = "test1"; info.bundleName_ = "test2"; sptr sceneSession = nullptr; - ssm_->UpdateFocusStatus(sceneSession, false); - ssm_->UpdateFocusStatus(sceneSession, true); + ssm_->UpdateFocusStatus(DEFAULT_DISPLAY_ID, sceneSession, false); + ssm_->UpdateFocusStatus(DEFAULT_DISPLAY_ID, sceneSession, true); sptr sceneSession1 = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession1, nullptr); - ssm_->UpdateFocusStatus(sceneSession1, true); - ssm_->UpdateFocusStatus(sceneSession1, false); + ssm_->UpdateFocusStatus(DEFAULT_DISPLAY_ID, sceneSession1, true); + ssm_->UpdateFocusStatus(DEFAULT_DISPLAY_ID, sceneSession1, false); +} + +/** + * @tc.name: UpdateFocusStatus01 + * @tc.desc: UpdateFocusStatus + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest5, UpdateFocusStatus01, Function | SmallTest | Level3) +{ + ASSERT_NE(ssm_, nullptr); + sptr sceneSession = nullptr; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); + + ssm_->UpdateFocusStatus(DEFAULT_DISPLAY_ID, sceneSession, false); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); + ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; + ssm_->UpdateFocusStatus(DEFAULT_DISPLAY_ID, sceneSession, true); + ASSERT_NE(focusGroup->GetFocusedSessionId(), 1); + focusGroup->SetFocusedSessionId(1); + ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; + ssm_->UpdateFocusStatus(DEFAULT_DISPLAY_ID, sceneSession, true); + ASSERT_NE(focusGroup->GetFocusedSessionId(), 1); } /** @@ -770,12 +796,13 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionUnfocus, Function | SmallTest | sceneSession1->persistentId_ = 1; focusedSession->persistentId_ = 2; focusedSession->property_->parentPersistentId_ = 1; - ssm_->focusedSessionId_ = 1; + ssm_->windowFocusController_->UpdateFocusedSessionId(DEFAULT_DISPLAY_ID, 1); ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); ssm_->sceneSessionMap_.insert({focusedSession->GetPersistentId(), focusedSession}); ret = ssm_->RequestSessionUnfocus(1, reason); ASSERT_EQ(ret, WSError::WS_OK); - ASSERT_NE(ssm_->focusedSessionId_, 1); + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + ASSERT_NE(focusGroup->GetFocusedSessionId(), 1); ssm_->sceneSessionMap_.clear(); } @@ -796,11 +823,11 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusSpecificCheck, Function | SmallTe ASSERT_NE(sceneSession1, nullptr); FocusChangeReason reason = FocusChangeReason::MOVE_UP; property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - WSError ret = ssm_->RequestFocusSpecificCheck(sceneSession1, true, reason); + WSError ret = ssm_->RequestFocusSpecificCheck(DEFAULT_DISPLAY_ID, sceneSession1, true, reason); EXPECT_EQ(ret, WSError::WS_OK); FocusChangeReason reason1 = FocusChangeReason::SPLIT_SCREEN; property->SetWindowType(WindowType::APP_WINDOW_BASE); - ret = ssm_->RequestFocusSpecificCheck(sceneSession1, true, reason1); + ret = ssm_->RequestFocusSpecificCheck(DEFAULT_DISPLAY_ID, sceneSession1, true, reason1); EXPECT_EQ(ret, WSError::WS_OK); } @@ -815,12 +842,13 @@ HWTEST_F(SceneSessionManagerTest5, NotifyFocusStatus, Function | SmallTest | Lev info.abilityName_ = "test1"; info.bundleName_ = "test2"; sptr sceneSession = nullptr; - ssm_->NotifyFocusStatus(sceneSession, true); + auto focusGroup = sptr::MakeSptr(DEFAULT_DISPLAY_ID); + ssm_->NotifyFocusStatus(sceneSession, true, focusGroup); sptr sceneSession1 = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession1, nullptr); - ssm_->NotifyFocusStatus(sceneSession1, false); + ssm_->NotifyFocusStatus(sceneSession1, false, focusGroup); info.isSystem_ = true; - ssm_->NotifyFocusStatus(sceneSession1, true); + ssm_->NotifyFocusStatus(sceneSession1, true, focusGroup); } /** @@ -882,12 +910,13 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocusImmediately, Function | Sm sptr sceneSession = nullptr; WSError ret = ssm_->RequestSessionFocusImmediately(0); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); - ssm_->RequestFocusBasicCheck(0); + auto focusGroup = sptr::MakeSptr(DEFAULT_DISPLAY_ID); + ssm_->RequestFocusBasicCheck(0, focusGroup); sptr sceneSession1 = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession1, nullptr); ret = ssm_->RequestSessionFocusImmediately(1); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); - ssm_->RequestFocusBasicCheck(1); + ssm_->RequestFocusBasicCheck(1, focusGroup); } /** @@ -897,12 +926,16 @@ HWTEST_F(SceneSessionManagerTest5, RequestSessionFocusImmediately, Function | Sm */ HWTEST_F(SceneSessionManagerTest5, RequestFocusBasicCheck, Function | SmallTest | Level3) { - ssm_->focusedSessionId_ = 1; - WSError ret = ssm_->RequestFocusBasicCheck(0); + sptr focusGroup = nullptr; + WSError ret = ssm_->RequestFocusBasicCheck(0, focusGroup); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); - ret = ssm_->RequestFocusBasicCheck(1); + ret = ssm_->RequestFocusBasicCheck(1, focusGroup); + ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); + focusGroup = sptr::MakeSptr(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); + ret = ssm_->RequestFocusBasicCheck(1, focusGroup); ASSERT_EQ(ret, WSError::WS_DO_NOTHING); - ret = ssm_->RequestFocusBasicCheck(2); + ret = ssm_->RequestFocusBasicCheck(2, focusGroup); ASSERT_EQ(ret, WSError::WS_OK); } @@ -1004,7 +1037,7 @@ HWTEST_F(SceneSessionManagerTest5, CheckRequestFocusImmdediately, Function | Sma sptr session = sptr::MakeSptr(info); session->persistentId_ = 1; sceneSession->dialogVec_.push_back(session); - ssm_->focusedSessionId_ = 1; + ssm_->windowFocusController_->UpdateFocusedSessionId(DEFAULT_DISPLAY_ID, 1); ret = ssm_->CheckRequestFocusImmdediately(sceneSession); ASSERT_EQ(ret, true); } @@ -1024,13 +1057,13 @@ HWTEST_F(SceneSessionManagerTest5, GetNextFocusableSession, Function | SmallTest sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - sptr result = ssm_->GetNextFocusableSession(persistentId); + sptr result = ssm_->GetNextFocusableSession(DEFAULT_DISPLAY_ID, persistentId); ASSERT_EQ(result, nullptr); sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); persistentId = 1; - result = ssm_->GetNextFocusableSession(persistentId); + result = ssm_->GetNextFocusableSession(DEFAULT_DISPLAY_ID, persistentId); ASSERT_EQ(result, nullptr); } @@ -1046,19 +1079,19 @@ HWTEST_F(SceneSessionManagerTest5, GetTopNearestBlockingFocusSession, Function | info.abilityName_ = "test1"; info.bundleName_ = "test2"; - ssm_->GetTopNearestBlockingFocusSession(2, true); + ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 2, true); sptr sceneSession = sptr::MakeSptr(info, nullptr); ASSERT_NE(sceneSession, nullptr); - ssm_->GetTopNearestBlockingFocusSession(0, true); + ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 0, true); Session session = Session(info); session.property_ = nullptr; - ssm_->GetTopNearestBlockingFocusSession(0, true); + ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 0, true); sptr session_ = nullptr; - ssm_->GetTopNearestBlockingFocusSession(0, true); + ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 0, true); session_ = sptr::MakeSptr(info, nullptr); ASSERT_NE(session_, nullptr); - ssm_->GetTopNearestBlockingFocusSession(0, true); + ssm_->GetTopNearestBlockingFocusSession(DEFAULT_DISPLAY_ID, 0, true); } /** @@ -1575,18 +1608,54 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusStatusBySCB, Function | SmallTest ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); FocusChangeReason reason = FocusChangeReason::FOREGROUND; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); ssm_->RequestFocusStatusBySCB(1, true, false, reason); usleep(WAIT_SYNC_IN_NS); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); reason = FocusChangeReason::CLICK; ssm_->RequestFocusStatusBySCB(1, true, false, reason); usleep(WAIT_SYNC_IN_NS); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); +} + +/** + * @tc.name: RequestFocusStatusBySCB01 + * @tc.desc: SceneSessionManager request focus status from SCB + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionManagerTest5, RequestFocusStatusBySCB01, Function | SmallTest | Level3) +{ + ssm_->sceneSessionMap_.clear(); + SessionInfo info; + info.abilityName_ = "RequestFocusTest"; + info.bundleName_ = "RequestFocusTest"; + sptr property = sptr::MakeSptr(); + property->SetFocusable(true); + property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sptr sceneSession = sptr::MakeSptr(info, nullptr); + sceneSession->property_ = property; + sceneSession->persistentId_ = 1; + sceneSession->isVisible_ = true; + sceneSession->state_ = SessionState::STATE_ACTIVE; + ssm_->sceneSessionMap_.insert({sceneSession->GetPersistentId(), sceneSession}); + + sptr sceneSession1 = sptr::MakeSptr(info, nullptr); + sceneSession1->property_->SetFocusable(true); + sceneSession1->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); + sceneSession1->persistentId_ = 2; + sceneSession1->isVisible_ = true; + sceneSession1->state_ = SessionState::STATE_ACTIVE; + ssm_->sceneSessionMap_.insert({sceneSession1->GetPersistentId(), sceneSession1}); + FocusChangeReason reason = FocusChangeReason::FOREGROUND; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + ssm_->RequestFocusStatusBySCB(2, true, false, reason); + usleep(WAIT_SYNC_IN_NS); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 2); ssm_->RequestFocusStatusBySCB(1, false, false, reason); usleep(WAIT_SYNC_IN_NS); - ASSERT_NE(ssm_->focusedSessionId_, 1); + ASSERT_NE(focusGroup->GetFocusedSessionId(), 1); reason = FocusChangeReason::MOVE_UP; ssm_->RequestFocusStatusBySCB(1, true, false, reason); @@ -1597,7 +1666,7 @@ HWTEST_F(SceneSessionManagerTest5, RequestFocusStatusBySCB, Function | SmallTest reason = FocusChangeReason::DEFAULT; ssm_->RequestFocusStatusBySCB(1, true, false, reason); usleep(WAIT_SYNC_IN_NS); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); } } diff --git a/window_scene/test/unittest/scene_session_manager_test6.cpp b/window_scene/test/unittest/scene_session_manager_test6.cpp index 3bf0ba29bc915f6ed9e8f4ca4bb1f9f0a499230a..55a04efdd1c3e8a0ff9a77ada058fb0e00b94bcd 100644 --- a/window_scene/test/unittest/scene_session_manager_test6.cpp +++ b/window_scene/test/unittest/scene_session_manager_test6.cpp @@ -727,7 +727,8 @@ HWTEST_F(SceneSessionManagerTest6, OnSessionStateChange, Function | SmallTest | sceneSession->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END); ASSERT_NE(nullptr, ssm_); ssm_->OnSessionStateChange(1, state); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->OnSessionStateChange(1, state); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ASSERT_NE(nullptr, ssm_); @@ -736,7 +737,7 @@ HWTEST_F(SceneSessionManagerTest6, OnSessionStateChange, Function | SmallTest | ASSERT_NE(nullptr, ssm_); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; ssm_->OnSessionStateChange(1, state); - ssm_->focusedSessionId_ = 0; + focusGroup->SetFocusedSessionId(0); ASSERT_NE(nullptr, ssm_); ssm_->OnSessionStateChange(1, state); } @@ -1530,7 +1531,8 @@ HWTEST_F(SceneSessionManagerTest6, SetRootSceneProcessBackEventFunc, Function | ASSERT_NE(nullptr, sceneSession); ASSERT_NE(nullptr, ssm_); ssm_->sceneSessionMap_.insert(std::make_pair(sceneSession->GetPersistentId(), sceneSession)); - ssm_->focusedSessionId_ = sceneSession->GetPersistentId(); + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(sceneSession->GetPersistentId()); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; ssm_->ProcessBackEvent(); @@ -1642,7 +1644,7 @@ HWTEST_F(SceneSessionManagerTest6, GetSceneSessionBySessionInfo, Function | Smal info4.persistentId_ = 0; info4.isPersistentRecover_ = false; ASSERT_EQ(ssm_->GetSceneSessionBySessionInfo(info4), nullptr); - + SessionInfo info5; info5.persistentId_ = 5; info5.isPersistentRecover_ = true; @@ -1966,7 +1968,6 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession04, Function | SmallTest | sptr collaborator = iface_cast(nullptr); ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); - auto ret3 = ssm_->CheckIfReuseSession(sessionInfo); ASSERT_EQ(ret3, BrokerStates::BROKER_UNKOWN); ssm_->abilityInfoMap_.erase(list); @@ -2003,7 +2004,6 @@ HWTEST_F(SceneSessionManagerTest6, CheckIfReuseSession05, Function | SmallTest | sptr collaborator = iface_cast(nullptr); ssm_->collaboratorMap_.insert(std::make_pair(1, collaborator)); - auto ret4 = ssm_->CheckIfReuseSession(sessionInfo); ASSERT_EQ(ret4, BrokerStates::BROKER_UNKOWN); ssm_->abilityInfoMap_.erase(list); diff --git a/window_scene/test/unittest/scene_session_manager_test7.cpp b/window_scene/test/unittest/scene_session_manager_test7.cpp index 4add14ad49ef4b617de8470117fdaed3b093d7cc..834f952b1a2aa9ea8319f75570d440c2b4497a81 100644 --- a/window_scene/test/unittest/scene_session_manager_test7.cpp +++ b/window_scene/test/unittest/scene_session_manager_test7.cpp @@ -294,7 +294,8 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent, Function | SmallTest | Leve ASSERT_NE(nullptr, sceneSession); ASSERT_NE(nullptr, ssm_); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; auto ret = ssm_->ProcessBackEvent(); EXPECT_EQ(ret, WSError::WS_OK); @@ -966,7 +967,8 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent01, Function | SmallTest | Le sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); ASSERT_NE(nullptr, ssm_); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; auto ret = ssm_->ProcessBackEvent(); @@ -987,7 +989,8 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent02, Function | SmallTest | Le ASSERT_NE(nullptr, sceneSession); sceneSession->sessionInfo_.isSystem_ = true; ASSERT_NE(nullptr, ssm_); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; ssm_->rootSceneProcessBackEventFunc_ = nullptr; @@ -1009,7 +1012,8 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent03, Function | SmallTest | Le ASSERT_NE(nullptr, sceneSession); sceneSession->sessionInfo_.isSystem_ = true; ASSERT_NE(nullptr, ssm_); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; RootSceneProcessBackEventFunc func = [](){}; @@ -1033,7 +1037,8 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent04, Function | SmallTest | Le ASSERT_NE(nullptr, sceneSession); sceneSession->sessionInfo_.isSystem_ = false; ASSERT_NE(nullptr, ssm_); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; ssm_->rootSceneProcessBackEventFunc_ = nullptr; @@ -1055,7 +1060,8 @@ HWTEST_F(SceneSessionManagerTest7, ProcessBackEvent05, Function | SmallTest | Le ASSERT_NE(nullptr, sceneSession); sceneSession->sessionInfo_.isSystem_ = false; ASSERT_NE(nullptr, ssm_); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; RootSceneProcessBackEventFunc func = [](){}; diff --git a/window_scene/test/unittest/scene_session_manager_test8.cpp b/window_scene/test/unittest/scene_session_manager_test8.cpp index 33cbc88d1d381e0a403ea60fb8596042a7b221d9..3452905cbd05322e62e5ac3d3578b92571c9acc0 100644 --- a/window_scene/test/unittest/scene_session_manager_test8.cpp +++ b/window_scene/test/unittest/scene_session_manager_test8.cpp @@ -50,7 +50,7 @@ void SceneSessionManagerTest8::TearDownTestCase() void SceneSessionManagerTest8::SetUp() { - ssm_ = sptr::MakeSptr(); + ssm_ = &SceneSessionManager::GetInstance(); EXPECT_NE(nullptr, ssm_); ssm_->sceneSessionMap_.clear(); } @@ -164,7 +164,8 @@ HWTEST_F(SceneSessionManagerTest8, PostProcessFocus, Function | SmallTest | Leve HWTEST_F(SceneSessionManagerTest8, PostProcessFocus01, Function | SmallTest | Level3) { ssm_->sceneSessionMap_.clear(); - ssm_->focusedSessionId_ = 0; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(0); SessionInfo sessionInfo; sessionInfo.bundleName_ = "PostProcessFocus01"; @@ -180,7 +181,7 @@ HWTEST_F(SceneSessionManagerTest8, PostProcessFocus01, Function | SmallTest | Le ssm_->sceneSessionMap_.emplace(1, sceneSession); ssm_->PostProcessFocus(); - EXPECT_NE(1, ssm_->focusedSessionId_); + EXPECT_NE(1, focusGroup->GetFocusedSessionId()); } /** @@ -556,7 +557,7 @@ HWTEST_F(SceneSessionManagerTest8, SetBrightness, Function | SmallTest | Level3) ssm_->Init(); ASSERT_NE(nullptr, ssm_->eventHandler_); - ssm_->SetFocusedSessionId(2024); + ssm_->SetFocusedSessionId(2024, DEFAULT_DISPLAY_ID); EXPECT_EQ(2024, ssm_->GetFocusedSessionId()); ret = ssm_->SetBrightness(sceneSession, 3.15f); @@ -890,7 +891,6 @@ HWTEST_F(SceneSessionManagerTest8, OnSessionStateChange01, Function | SmallTest property->SetWindowType(WindowType::APP_MAIN_WINDOW_END); ssm_->OnSessionStateChange(100, state); - auto ret = ssm_->UpdateMaximizeMode(1, true); EXPECT_EQ(WSError::WS_OK, ret); constexpr uint32_t NOT_WAIT_SYNC_IN_NS = 500000; diff --git a/window_scene/test/unittest/scene_session_manager_test9.cpp b/window_scene/test/unittest/scene_session_manager_test9.cpp index 40c421a525bb3a781cb61394d4bd7f6c0c357462..4cdf582fd258ac287a8fffef817011fbc7c4c76f 100644 --- a/window_scene/test/unittest/scene_session_manager_test9.cpp +++ b/window_scene/test/unittest/scene_session_manager_test9.cpp @@ -208,7 +208,6 @@ HWTEST_F(SceneSessionManagerTest9, TestRequestSessionFocusImmediately_04, Functi sessionInfo.bundleName_ = "SceneSessionManagerTest9"; sessionInfo.abilityName_ = "RequestSessionFocusImmediately02"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - sceneSession->SetFocusable(true); sceneSession->SetFocusedOnShow(false); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); @@ -230,7 +229,6 @@ HWTEST_F(SceneSessionManagerTest9, TestRequestSessionFocusImmediately_05, Functi sessionInfo.bundleName_ = "SceneSessionManagerTest9"; sessionInfo.abilityName_ = "RequestSessionFocusImmediately02"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - sceneSession->SetFocusable(true); sceneSession->SetFocusedOnShow(true); sceneSession->SetForceHideState(ForceHideState::HIDDEN_WHEN_FOCUSED); @@ -253,7 +251,6 @@ HWTEST_F(SceneSessionManagerTest9, TestRequestSessionFocusImmediately_06, Functi sessionInfo.bundleName_ = "SceneSessionManagerTest9"; sessionInfo.abilityName_ = "RequestSessionFocusImmediately02"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - sceneSession->SetFocusable(true); sceneSession->SetFocusedOnShow(true); sceneSession->SetForceHideState(ForceHideState::NOT_HIDDEN); @@ -499,15 +496,16 @@ HWTEST_F(SceneSessionManagerTest9, RequestSessionUnfocus02, Function | SmallTest ssm_->sceneSessionMap_.clear(); WSError ret = ssm_->RequestSessionUnfocus(0, FocusChangeReason::DEFAULT); ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION); - ret = ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT); - ASSERT_EQ(ret, WSError::WS_DO_NOTHING); SessionInfo sessionInfo; sessionInfo.bundleName_ = "SceneSessionManagerTest9"; sessionInfo.abilityName_ = "RequestSessionUnfocus02"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); - ASSERT_NE(nullptr, sceneSession); - ssm_->focusedSessionId_ = 2; + ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); + ssm_->windowFocusController_->UpdateFocusedSessionId(DEFAULT_DISPLAY_ID, 0); + ret = ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT); + ASSERT_EQ(ret, WSError::WS_DO_NOTHING); + ssm_->windowFocusController_->UpdateFocusedSessionId(DEFAULT_DISPLAY_ID, 2); sceneSession->persistentId_ = 1; sceneSession->SetZOrder(50); sceneSession->state_ = SessionState::STATE_FOREGROUND; @@ -523,9 +521,10 @@ HWTEST_F(SceneSessionManagerTest9, RequestSessionUnfocus02, Function | SmallTest ssm_->sceneSessionMap_.insert(std::make_pair(2, sceneSession1)); ret = ssm_->RequestSessionUnfocus(2, FocusChangeReason::DEFAULT); ASSERT_EQ(ret, WSError::WS_OK); - ASSERT_EQ(ssm_->focusedSessionId_, 1); + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); - ssm_->lastFocusedSessionId_ = 4; + focusGroup->SetLastFocusedSessionId(4); sceneSession1->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT); SessionInfo sessionInfo2; sptr sceneSession2 = sptr::MakeSptr(sessionInfo2, nullptr); @@ -538,7 +537,7 @@ HWTEST_F(SceneSessionManagerTest9, RequestSessionUnfocus02, Function | SmallTest ssm_->sceneSessionMap_.insert(std::make_pair(4, sceneSession2)); ret = ssm_->RequestSessionUnfocus(1, FocusChangeReason::DEFAULT); ASSERT_EQ(ret, WSError::WS_OK); - ASSERT_EQ(ssm_->focusedSessionId_, 4); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 4); } /** @@ -557,7 +556,8 @@ HWTEST_F(SceneSessionManagerTest9, RequestAllAppSessionUnfocusInner, Function | sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); ASSERT_NE(nullptr, sceneSession); sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); ssm_->RequestAllAppSessionUnfocusInner(); @@ -581,7 +581,8 @@ HWTEST_F(SceneSessionManagerTest9, UpdateFocus04, Function | SmallTest | Level3) ASSERT_NE(nullptr, sceneSession); sceneSession->GetSessionProperty()->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ssm_->sceneSessionMap_.insert(std::make_pair(1, sceneSession)); - ssm_->focusedSessionId_ = 0; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(0); sceneSession->UpdateFocus(false); ssm_->UpdateFocus(1, false); @@ -593,7 +594,7 @@ HWTEST_F(SceneSessionManagerTest9, UpdateFocus04, Function | SmallTest | Level3) ssm_->UpdateFocus(1, true); sessionInfo.isSystem_ = false; - ssm_->focusedSessionId_ = 1; + focusGroup->SetFocusedSessionId(1); sceneSession->UpdateFocus(true); ssm_->UpdateFocus(1, false); @@ -617,7 +618,8 @@ HWTEST_F(SceneSessionManagerTest9, ProcessFocusWhenForeground, Function | SmallT sceneSession->persistentId_ = 1; ASSERT_NE(nullptr, sceneSession->property_); sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; ssm_->ProcessFocusWhenForeground(sceneSession); @@ -639,7 +641,8 @@ HWTEST_F(SceneSessionManagerTest9, ProcessFocusWhenForeground01, Function | Smal sessionInfo.abilityName_ = "ProcessFocusWhenForeground"; sptr sceneSession = sptr::MakeSptr(sessionInfo, nullptr); sceneSession->persistentId_ = 1; - ssm_->focusedSessionId_ = 2; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(2); sceneSession->SetFocusedOnShow(false); ssm_->ProcessFocusWhenForeground(sceneSession); EXPECT_EQ(sceneSession->IsFocusedOnShow(), false); @@ -673,7 +676,8 @@ HWTEST_F(SceneSessionManagerTest9, ProcessSubSessionForeground03, Function | Sma sceneSession->GetSubSession().push_back(subSceneSession); ssm_->sceneSessionMap_.insert(std::make_pair(1, subSceneSession)); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; SessionInfo subSessionInfo1; @@ -705,7 +709,7 @@ HWTEST_F(SceneSessionManagerTest9, ProcessSubSessionForeground03, Function | Sma ssm_->needBlockNotifyFocusStatusUntilForeground_ = false; ssm_->ProcessSubSessionForeground(sceneSession); - ssm_->focusedSessionId_ = 2; + focusGroup->SetFocusedSessionId(2); ssm_->ProcessSubSessionForeground(sceneSession); } @@ -717,7 +721,8 @@ HWTEST_F(SceneSessionManagerTest9, ProcessSubSessionForeground03, Function | Sma HWTEST_F(SceneSessionManagerTest9, ProcessFocusWhenForegroundScbCore, Function | SmallTest | Level3) { ASSERT_NE(nullptr, ssm_); - ssm_->focusedSessionId_ = 0; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(0); SessionInfo sessionInfo; sessionInfo.bundleName_ = "SceneSessionManagerTest9"; sessionInfo.abilityName_ = "ProcessFocusWhenForegroundScbCore"; @@ -728,7 +733,7 @@ HWTEST_F(SceneSessionManagerTest9, ProcessFocusWhenForegroundScbCore, Function | sceneSession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW); ssm_->ProcessFocusWhenForegroundScbCore(sceneSession); ASSERT_EQ(sceneSession->GetPostProcessFocusState().isFocused_, false); - ASSERT_EQ(ssm_->focusedSessionId_, 0); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 0); sceneSession->SetFocusableOnShow(true); ssm_->ProcessFocusWhenForegroundScbCore(sceneSession); // SetPostProcessFocusState @@ -737,7 +742,7 @@ HWTEST_F(SceneSessionManagerTest9, ProcessFocusWhenForegroundScbCore, Function | sceneSession->isVisible_ = true; sceneSession->SetSessionState(SessionState::STATE_FOREGROUND); ssm_->ProcessFocusWhenForegroundScbCore(sceneSession); // RequestSessionFocus - ASSERT_EQ(ssm_->focusedSessionId_, 1); + ASSERT_EQ(focusGroup->GetFocusedSessionId(), 1); } /** @@ -765,7 +770,8 @@ HWTEST_F(SceneSessionManagerTest9, ProcessModalTopmostRequestFocusImmdediately02 sceneSession->GetSubSession().push_back(subSceneSession); ssm_->sceneSessionMap_.insert(std::make_pair(1, subSceneSession)); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; SessionInfo subSessionInfo1; @@ -829,7 +835,8 @@ HWTEST_F(SceneSessionManagerTest9, ProcessDialogRequestFocusImmdediately02, Func sceneSession->GetDialogVector().push_back(dialogSceneSession); ssm_->sceneSessionMap_.insert(std::make_pair(1, dialogSceneSession)); - ssm_->focusedSessionId_ = 1; + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); ssm_->needBlockNotifyFocusStatusUntilForeground_ = true; SessionInfo dialogSessionInfo1; @@ -1059,11 +1066,10 @@ HWTEST_F(SceneSessionManagerTest9, CheckClickFocusIsDownThroughFullScreen, Funct ASSERT_NE(sceneSession, nullptr); bool ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, FocusChangeReason::DEFAULT); ASSERT_EQ(ret, false); - + focusedSession->property_->SetWindowType(WindowType::WINDOW_TYPE_GLOBAL_SEARCH); ret = ssm_->CheckClickFocusIsDownThroughFullScreen(focusedSession, sceneSession, FocusChangeReason::DEFAULT); ASSERT_EQ(ret, false); - sceneSession->SetZOrder(50); focusedSession->SetZOrder(100); focusedSession->blockingFocus_ = true; @@ -1091,8 +1097,9 @@ HWTEST_F(SceneSessionManagerTest9, ShiftFocus, Function | SmallTest | Level3) nextSession->persistentId_ = 4; ssm_->sceneSessionMap_.insert({1, focusedSession}); ssm_->sceneSessionMap_.insert({4, nextSession}); - ssm_->focusedSessionId_ = 1; - WSError ret = ssm_->ShiftFocus(nextSession, FocusChangeReason::DEFAULT); + auto focusGroup = ssm_->windowFocusController_->GetFocusGroup(DEFAULT_DISPLAY_ID); + focusGroup->SetFocusedSessionId(1); + WSError ret = ssm_->ShiftFocus(DEFAULT_DISPLAY_ID, nextSession, FocusChangeReason::DEFAULT); ASSERT_EQ(ret, WSError::WS_OK); ASSERT_EQ(focusedSession->isFocused_, false); ASSERT_EQ(nextSession->isFocused_, true); diff --git a/wm/include/window_adapter.h b/wm/include/window_adapter.h index 5edecc5325304426b718878c386dd7fd8c801b84..41826999e78db29ce95505df328678e3e7e7bbe8 100644 --- a/wm/include/window_adapter.h +++ b/wm/include/window_adapter.h @@ -94,7 +94,7 @@ public: std::vector>& targets); virtual void SetMaximizeMode(MaximizeMode maximizeMode); virtual MaximizeMode GetMaximizeMode(); - virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo); + virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID); virtual WMError UpdateSessionAvoidAreaListener(int32_t persistentId, bool haveListener); virtual WMError UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener); virtual WMError NotifyWindowExtensionVisibilityChange(int32_t pid, int32_t uid, bool visible); diff --git a/wm/include/window_adapter_lite.h b/wm/include/window_adapter_lite.h index 3df7a12affd7a28e7062a63bb8f07fd812015803..85e052f600e5e557eee4290e92ff1f2fb7abb95e 100644 --- a/wm/include/window_adapter_lite.h +++ b/wm/include/window_adapter_lite.h @@ -36,7 +36,7 @@ class WindowAdapterLite { WM_DECLARE_SINGLE_INSTANCE(WindowAdapterLite); public: using WMSConnectionChangedCallbackFunc = std::function; - virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo); + virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID); virtual WMError RegisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent); virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, diff --git a/wm/src/window_adapter.cpp b/wm/src/window_adapter.cpp index 5280938ae31ecde13887dcd17ab8fae90963fe11..e0281fc0af1a946d215ace703834c8395fe19eb6 100644 --- a/wm/src/window_adapter.cpp +++ b/wm/src/window_adapter.cpp @@ -686,13 +686,17 @@ MaximizeMode WindowAdapter::GetMaximizeMode() return wmsProxy->GetMaximizeMode(); } -void WindowAdapter::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void WindowAdapter::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { INIT_PROXY_CHECK_RETURN(); auto wmsProxy = GetWindowManagerServiceProxy(); CHECK_PROXY_RETURN_IF_NULL(wmsProxy); - wmsProxy->GetFocusWindowInfo(focusInfo); + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + wmsProxy->GetFocusWindowInfo(focusInfo, displayId); + } else { + wmsProxy->GetFocusWindowInfo(focusInfo); + } } WMError WindowAdapter::UpdateSessionAvoidAreaListener(int32_t persistentId, bool haveListener) diff --git a/wm/src/window_adapter_lite.cpp b/wm/src/window_adapter_lite.cpp index 2363cf449e272173295cc708bcefb86dd9dd3d75..7a7f65ee9960c683072d1384452edfe88877fd3e 100644 --- a/wm/src/window_adapter_lite.cpp +++ b/wm/src/window_adapter_lite.cpp @@ -195,14 +195,18 @@ void WMSDeathRecipient::OnRemoteDied(const wptr& wptrDeath) SingletonContainer::Get().ClearSessionManagerProxy(); } -void WindowAdapterLite::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void WindowAdapterLite::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { INIT_PROXY_CHECK_RETURN(); WLOGFD("use Foucus window info proxy"); auto wmsProxy = GetWindowManagerServiceProxy(); CHECK_PROXY_RETURN_IF_NULL(wmsProxy); - wmsProxy->GetFocusWindowInfo(focusInfo); + if (Rosen::SceneBoardJudgement::IsSceneBoardEnabled()) { + wmsProxy->GetFocusWindowInfo(focusInfo, displayId); + } else { + wmsProxy->GetFocusWindowInfo(focusInfo); + } } WMError WindowAdapterLite::GetWindowModeType(WindowModeType& windowModeType) diff --git a/wm/src/window_manager.cpp b/wm/src/window_manager.cpp index 77eaf6998a2ad18ef70236088df2d28566cc3efa..c6018ee00eb02611de6dc861f8de92d35f44cc8b 100644 --- a/wm/src/window_manager.cpp +++ b/wm/src/window_manager.cpp @@ -1033,9 +1033,9 @@ WMError WindowManager::NotifyDisplayInfoChange(const sptr& token, return WMError::WM_OK; } -void WindowManager::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void WindowManager::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { - SingletonContainer::Get().GetFocusWindowInfo(focusInfo); + SingletonContainer::Get().GetFocusWindowInfo(focusInfo, displayId); } void WindowManager::OnWMSConnectionChanged(int32_t userId, int32_t screenId, bool isConnected) const diff --git a/wm/src/window_manager_lite.cpp b/wm/src/window_manager_lite.cpp index 7964ae82d1036bfe9799608871acf98e456ac882..aaf93a14f8bbd4fc4fe3eb112ac488ae6d0a6a3a 100644 --- a/wm/src/window_manager_lite.cpp +++ b/wm/src/window_manager_lite.cpp @@ -389,10 +389,10 @@ WMError WindowManagerLite::UnregisterVisibilityChangedListener(const sptr().GetFocusWindowInfo(focusInfo); + SingletonContainer::Get().GetFocusWindowInfo(focusInfo, displayId); } void WindowManagerLite::UpdateFocusChangeInfo(const sptr& focusChangeInfo, bool focused) const diff --git a/wm/test/unittest/window_manager_lite_test.cpp b/wm/test/unittest/window_manager_lite_test.cpp index 23381a7c6a951def094d645fdaac42695932de1d..50481ab5b0980ae5bd91852be03ff06fc607e8cd 100644 --- a/wm/test/unittest/window_manager_lite_test.cpp +++ b/wm/test/unittest/window_manager_lite_test.cpp @@ -115,7 +115,7 @@ HWTEST_F(WindowManagerLiteTest, GetFocusWindowInfo, Function | SmallTest | Level infosResult.uid_ = 11; infosResult.displayId_ = 12; infosResult.windowId_ = 13; - EXPECT_CALL(m->Mock(), GetFocusWindowInfo(_)).Times(1).WillOnce(DoAll(SetArgReferee<0>(infosResult), Return())); + EXPECT_CALL(m->Mock(), GetFocusWindowInfo(_, _)).Times(1).WillOnce(DoAll(SetArgReferee<0>(infosResult), Return())); WindowManagerLite::GetInstance().GetFocusWindowInfo(infosInput); ASSERT_EQ(infosInput.windowId_, infosResult.windowId_); ASSERT_EQ(infosInput.uid_, infosResult.uid_); diff --git a/wmserver/include/window_manager_service.h b/wmserver/include/window_manager_service.h index 1fc770d5a8892a84ef8aea1ada8c8c1d6be40a50..b8037850ed7b67f0c7fa2d511ee895d6bff4c251 100644 --- a/wmserver/include/window_manager_service.h +++ b/wmserver/include/window_manager_service.h @@ -152,7 +152,7 @@ public: void PostAsyncTask(Task task, const std::string& taskName = "WMSTask", uint32_t delay = 0); void SetMaximizeMode(MaximizeMode maximizeMode) override; MaximizeMode GetMaximizeMode() override; - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override; protected: WindowManagerService(); @@ -166,7 +166,7 @@ private: void OnWindowEvent(Event event, const sptr& remoteObject); void NotifyDisplayStateChange(DisplayId defaultDisplayId, sptr displayInfo, const std::map>& displayInfoMap, DisplayStateChangeType type); - WMError GetFocusWindowInfo(sptr& abilityToken); + WMError GetFocusWindowInfo(sptr& abilityToken, DisplayId displayId = DEFAULT_DISPLAY_ID); bool CheckSystemWindowPermission(const sptr& property) const; bool CheckAnimationPermission(const sptr& property) const; void LoadWindowParameter(); diff --git a/wmserver/include/zidl/window_manager_interface.h b/wmserver/include/zidl/window_manager_interface.h index a7e25ad39057813bd41f6e5cab2aff5c5cd3939b..b69344601f45cb7e22292aa69ba1dd26f7ec9042 100644 --- a/wmserver/include/zidl/window_manager_interface.h +++ b/wmserver/include/zidl/window_manager_interface.h @@ -150,7 +150,7 @@ public: std::vector>& targets) = 0; virtual void SetMaximizeMode(MaximizeMode maximizeMode) = 0; virtual MaximizeMode GetMaximizeMode() = 0; - virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo) = 0; + virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) = 0; virtual WMError CheckWindowId(int32_t windowId, int32_t& pid) { return WMError::WM_OK; } virtual WSError UpdateSessionAvoidAreaListener(int32_t persistentId, bool haveListener) { return WSError::WS_OK; } virtual WSError UpdateSessionTouchOutsideListener(int32_t& persistentId, bool haveListener) diff --git a/wmserver/include/zidl/window_manager_lite_interface.h b/wmserver/include/zidl/window_manager_lite_interface.h index fde371a88a320fc8bd47557cad76a4680a43a23e..a88866d40149fa0c78f86aa21c625953de529bf8 100644 --- a/wmserver/include/zidl/window_manager_lite_interface.h +++ b/wmserver/include/zidl/window_manager_lite_interface.h @@ -38,7 +38,7 @@ public: virtual WMError UnregisterWindowManagerAgent(WindowManagerAgentType type, const sptr& windowManagerAgent) = 0; virtual WMError GetVisibilityWindowInfo(std::vector>& infos) { return WMError::WM_OK; }; - virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo) = 0; + virtual void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) = 0; virtual WMError CheckWindowId(int32_t windowId, int32_t& pid) = 0; virtual WMError CheckUIExtensionCreation(int32_t windowId, uint32_t tokenId, const AppExecFwk::ElementName& element, AppExecFwk::ExtensionAbilityType extensionAbilityType, int32_t& pid) = 0; diff --git a/wmserver/include/zidl/window_manager_proxy.h b/wmserver/include/zidl/window_manager_proxy.h index fc82ea4f14862607522f8003fcc5eb7d68417d1c..f21f5877b149e16c45d7293eaf9b3e225d68f5c0 100644 --- a/wmserver/include/zidl/window_manager_proxy.h +++ b/wmserver/include/zidl/window_manager_proxy.h @@ -79,7 +79,7 @@ public: std::vector>& targets) override; void SetMaximizeMode(MaximizeMode maximizeMode) override; MaximizeMode GetMaximizeMode() override; - void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override; + void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override; private: static inline BrokerDelegator delegator_; }; diff --git a/wmserver/src/window_manager_service.cpp b/wmserver/src/window_manager_service.cpp index 96650520e53ebfd42dd67b0c2d7a9bd16952b09b..b532738155528b221f801792d71a822ab1c7d217 100644 --- a/wmserver/src/window_manager_service.cpp +++ b/wmserver/src/window_manager_service.cpp @@ -827,7 +827,7 @@ void WindowManagerService::NotifyAnimationAbilityDied(sptr PostAsyncTask(task, "NotifyAnimationAbilityDied"); } -WMError WindowManagerService::GetFocusWindowInfo(sptr& abilityToken) +WMError WindowManagerService::GetFocusWindowInfo(sptr& abilityToken, DisplayId displayId) { auto task = [this, &abilityToken]() { return windowController_->GetFocusWindowInfo(abilityToken); @@ -1635,7 +1635,7 @@ MaximizeMode WindowManagerService::GetMaximizeMode() return maximizeMode_; } -void WindowManagerService::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void WindowManagerService::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { WLOGFD("Get Focus window info in wms"); windowController_->GetFocusWindowInfo(focusInfo); diff --git a/wmserver/src/zidl/window_manager_proxy.cpp b/wmserver/src/zidl/window_manager_proxy.cpp index 360ebcf9f05691844d27b1ade1fb3fbf334d52c6..812f9f0dbcb8c323736761cfedbe82ad630c86a2 100644 --- a/wmserver/src/zidl/window_manager_proxy.cpp +++ b/wmserver/src/zidl/window_manager_proxy.cpp @@ -370,7 +370,6 @@ void WindowManagerProxy::NotifyServerReadyToMoveOrDrag(uint32_t windowId, sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -399,7 +398,6 @@ void WindowManagerProxy::ProcessPointDown(uint32_t windowId, bool isPointDown) WLOGFE("Write isPointDown failed"); return; } - sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); @@ -1262,7 +1260,7 @@ MaximizeMode WindowManagerProxy::GetMaximizeMode() return static_cast(ret); } -void WindowManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo) +void WindowManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId) { MessageParcel data; MessageParcel reply; @@ -1271,7 +1269,10 @@ void WindowManagerProxy::GetFocusWindowInfo(FocusChangeInfo& focusInfo) WLOGFE("WriteInterfaceToken failed"); return; } - + if (!data.WriteUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "write displayId failed"); + return; + } sptr remote = Remote(); if (remote == nullptr) { WLOGFE("remote is null"); diff --git a/wmserver/src/zidl/window_manager_stub.cpp b/wmserver/src/zidl/window_manager_stub.cpp index 6201306c5dead9f713d1066318331cf0616839dd..bd3ca96b8ddaef7361cd589840ffaa5b23d14f9c 100644 --- a/wmserver/src/zidl/window_manager_stub.cpp +++ b/wmserver/src/zidl/window_manager_stub.cpp @@ -518,7 +518,12 @@ int32_t WindowManagerStub::OnRemoteRequest(uint32_t code, MessageParcel& data, M } case WindowManagerMessage::TRANS_ID_GET_FOCUS_WINDOW_INFO: { FocusChangeInfo focusInfo; - GetFocusWindowInfo(focusInfo); + uint64_t displayId = 0; + if (!data.ReadUint64(displayId)) { + TLOGE(WmsLogTag::WMS_FOCUS, "Failed to read displayId"); + return ERR_INVALID_DATA; + } + GetFocusWindowInfo(focusInfo, displayId); reply.WriteParcelable(&focusInfo); break; } diff --git a/wmserver/test/unittest/window_manager_stub_impl.h b/wmserver/test/unittest/window_manager_stub_impl.h index 3ecba7b84c6030b32de5f3616653dbe40f490b89..1a2632c8f5a6ffcf3f4f40238aa8d6d9567add87 100644 --- a/wmserver/test/unittest/window_manager_stub_impl.h +++ b/wmserver/test/unittest/window_manager_stub_impl.h @@ -157,7 +157,7 @@ MaximizeMode GetMaximizeMode() override { return MaximizeMode::MODE_FULL_FILL; } -void GetFocusWindowInfo(FocusChangeInfo& focusInfo) override {} +void GetFocusWindowInfo(FocusChangeInfo& focusInfo, DisplayId displayId = DEFAULT_DISPLAY_ID) override {} }; } }