diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp index ae3e5efff2..ff0ee41f30 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_root_scene_session.cpp @@ -255,6 +255,17 @@ void JsRootSceneSession::PendingSessionActivationInner(std::shared_ptrPostMainThreadTask(task, "PendingSessionActivationInner"); } +static int32_t GetRealCallerSessionId(const sptr& sceneSession) +{ + int32_t realCallerSessionId = SceneSessionManager::GetInstance().GetFocusedSessionId(); + if (realCallerSessionId == sceneSession->GetPersistentId()) { + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller is self, switch to self caller."); + realCallerSessionId = sceneSession->GetSessionInfo().callerPersistentId_; + } + TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller session: %{public}d.", realCallerSessionId); + return realCallerSessionId; +} + void JsRootSceneSession::PendingSessionActivation(SessionInfo& info) { TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]bundleName %{public}s, moduleName %{public}s, abilityName %{public}s, " @@ -271,16 +282,7 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info) TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]session: %{public}d isNeedBackToOther: %{public}d", sceneSession->GetPersistentId(), isNeedBackToOther); if (isNeedBackToOther) { - int32_t realCallerSessionId = SceneSessionManager::GetInstance().GetFocusedSessionId(); - if (realCallerSessionId == sceneSession->GetPersistentId()) { - TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller is self, switch to self caller."); - auto scnSession = SceneSessionManager::GetInstance().GetSceneSession(realCallerSessionId); - if (scnSession != nullptr) { - realCallerSessionId = scnSession->GetSessionInfo().callerPersistentId_; - } - } - TLOGI(WmsLogTag::WMS_LIFE, "[NAPI]caller session: %{public}d.", realCallerSessionId); - info.callerPersistentId_ = realCallerSessionId; + info.callerPersistentId_ = GetRealCallerSessionId(sceneSession); VerifyCallerToken(info); } else { info.callerPersistentId_ = 0; @@ -311,6 +313,9 @@ void JsRootSceneSession::PendingSessionActivation(SessionInfo& info) PendingSessionActivationInner(sessionInfo); }; sceneSession->PostLifeCycleTask(task, "PendingSessionActivation", LifeCycleTaskType::START); + if (info.fullScreenStart_) { + sceneSession->NotifySessionFullScreen(true); + } } void JsRootSceneSession::VerifyCallerToken(SessionInfo& info) diff --git a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp index a4889d1c39..62ad21d52b 100644 --- a/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp +++ b/window_scene/interfaces/kits/napi/scene_session_manager/js_scene_session.cpp @@ -2100,6 +2100,9 @@ void JsSceneSession::PendingSessionActivation(SessionInfo& info) PendingSessionActivationInner(sessionInfo); }; sceneSession->PostLifeCycleTask(task, "PendingSessionActivation", LifeCycleTaskType::START); + if (info.fullScreenStart_) { + sceneSession->NotifySessionFullScreen(true); + } } void JsSceneSession::PendingSessionActivationInner(std::shared_ptr sessionInfo) diff --git a/window_scene/session/container/include/zidl/session_stage_interface.h b/window_scene/session/container/include/zidl/session_stage_interface.h index 3ad7fc2c37..9f1954174e 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -73,6 +73,7 @@ public: virtual void NotifyDisplayMove(DisplayId from, DisplayId to) = 0; virtual WSError SwitchFreeMultiWindow(bool enable) = 0; virtual WSError GetUIContentRemoteObj(sptr& uiContentRemoteObj) = 0; + virtual void NotifySessionFullScreen(bool fullScreen) {} // **Non** IPC interface virtual void NotifyBackpressedEvent(bool& isConsumed) {} diff --git a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h index 563451844d..a6ee8e6b87 100644 --- a/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h +++ b/window_scene/session/container/include/zidl/session_stage_ipc_interface_code.h @@ -53,6 +53,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_GET_UI_CONTENT_REMOTE_OBJ, TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE, TRANS_ID_NOTIFY_DENSITY_FOLLOW_HOST, + TRANS_ID_NOTIFY_SESSION_FULLSCREEN, }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/session/container/include/zidl/session_stage_proxy.h b/window_scene/session/container/include/zidl/session_stage_proxy.h index ea73a410de..fdd6a27b7d 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -66,6 +66,7 @@ public: WSError SwitchFreeMultiWindow(bool enable) override; WSError GetUIContentRemoteObj(sptr& uiContentRemoteObj) override; void NotifyKeyboardPanelInfoChange(const KeyboardPanelInfo& keyboardPanelInfo) override; + void NotifySessionFullScreen(bool fullScreen) override; private: static inline BrokerDelegator delegator_; diff --git a/window_scene/session/container/include/zidl/session_stage_stub.h b/window_scene/session/container/include/zidl/session_stage_stub.h index c8ae4612ba..d930a5aa98 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -66,6 +66,7 @@ private: int HandleSwitchFreeMultiWindow(MessageParcel& data, MessageParcel& reply); int HandleGetUIContentRemoteObj(MessageParcel& data, MessageParcel& reply); int HandleNotifyKeyboardPanelInfoChange(MessageParcel& data, MessageParcel& reply); + int HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply); }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_STUB_H diff --git a/window_scene/session/container/src/zidl/session_stage_proxy.cpp b/window_scene/session/container/src/zidl/session_stage_proxy.cpp index 352c8f1303..9198626f2d 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -585,6 +585,31 @@ void SessionStageProxy::NotifySessionForeground(uint32_t reason, bool withAnima } } +void SessionStageProxy::NotifySessionFullScreen(bool fullScreen) +{ + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_LAYOUT, "remote is null"); + return; + } + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_LAYOUT, "WriteInterfaceToken failed"); + return; + } + if (!data.WriteBool(fullScreen)) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Write fullScreen failed"); + return; + } + if (remote->SendRequest( + static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_LAYOUT, "Send Request failed"); + } +} + void SessionStageProxy::NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) { MessageParcel data; diff --git a/window_scene/session/container/src/zidl/session_stage_stub.cpp b/window_scene/session/container/src/zidl/session_stage_stub.cpp index e04a72ff7b..8ef9624143 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -100,6 +100,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel &data, Messag return HandleGetUIContentRemoteObj(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_KEYBOARD_INFO_CHANGE): return HandleNotifyKeyboardPanelInfoChange(data, reply); + case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_SESSION_FULLSCREEN): + return HandleNotifySessionFullScreen(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -325,6 +327,14 @@ int SessionStageStub::HandleNotifySessionForeground(MessageParcel& data, Message return ERR_NONE; } +int SessionStageStub::HandleNotifySessionFullScreen(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_LAYOUT, "called"); + bool fullScreen = data.ReadBool(); + NotifySessionFullScreen(fullScreen); + return ERR_NONE; +} + int SessionStageStub::HandleNotifySessionBackground(MessageParcel& data, MessageParcel& reply) { WLOGFD("HandleNotifySessionBackground"); diff --git a/window_scene/session/host/include/scene_session.h b/window_scene/session/host/include/scene_session.h index c7c14c0e05..c68aae6872 100644 --- a/window_scene/session/host/include/scene_session.h +++ b/window_scene/session/host/include/scene_session.h @@ -308,6 +308,7 @@ public: void RemoveExtWindowFlags(int32_t extPersistentId); void ClearExtWindowFlags(); void NotifyDisplayMove(DisplayId from, DisplayId to); + void NotifySessionFullScreen(bool fullScreen); void SetSessionState(SessionState state) override; void UpdateSessionState(SessionState state) override; diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 05265acc3f..bcef574ad2 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -2696,6 +2696,9 @@ static SessionInfo MakeSessionInfoDuringPendingActivation(const sptr(info.want->GetIntParam(AAFwk::Want::PARAM_RESV_DISPLAY_ID, -1)); TLOGI(WmsLogTag::WMS_LIFE, "want: screenId %{public}" PRIu64, info.screenId_); } + if (info.windowMode == static_cast(WindowMode::WINDOW_MODE_FULLSCREEN)) { + info.fullScreenStart_ = true; + } TLOGI(WmsLogTag::WMS_LIFE, "bundleName:%{public}s, moduleName:%{public}s, " "abilityName:%{public}s, appIndex:%{public}d, affinity:%{public}s. " "callState:%{public}d, want persistentId:%{public}d, " @@ -3558,6 +3561,15 @@ void SceneSession::NotifySessionBackground(uint32_t reason, bool withAnimation, return sessionStage_->NotifySessionBackground(reason, withAnimation, isFromInnerkits); } +void SceneSession::NotifySessionFullScreen(bool fullScreen) +{ + if (!sessionStage_) { + TLOGE(WmsLogTag::WMS_LAYOUT, "sessionStage is null"); + return; + } + sessionStage_->NotifySessionFullScreen(fullScreen); +} + WSError SceneSession::UpdatePiPRect(const Rect& rect, SizeChangeReason reason) { if (!WindowHelper::IsPipWindow(GetWindowType())) { diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index 2e8bc9de56..184bc0fc3e 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -61,6 +61,7 @@ public: MOCK_METHOD2(NotifyDisplayMove, void(DisplayId from, DisplayId to)); MOCK_METHOD1(SwitchFreeMultiWindow, WSError(bool enable)); MOCK_METHOD1(GetUIContentRemoteObj, WSError(sptr& uiContentRemoteObj)); + MOCK_METHOD1(NotifySessionFullScreen, void(bool fullScreen)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index c0ed1c25e8..aac7c003bb 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -714,6 +714,31 @@ HWTEST_F(SceneSessionTest2, NotifySessionForeground, Function | SmallTest | Leve ASSERT_EQ(ret, 1); } +/** + * @tc.name: NotifySessionFullScreen01 + * @tc.desc: NotifySessionFullScreen + * @tc.type: FUNC + */ +HWTEST_F(SceneSessionTest2, NotifySessionFullScreen, Function | SmallTest | Level2) +{ + SessionInfo info; + info.abilityName_ = "FullScreen01"; + info.bundleName_ = "IsFloatingWindowAppType"; + info.windowType_ = 1; + sptr specificCallback = + new (std::nothrow) SceneSession::SpecificSessionCallback(); + EXPECT_NE(specificCallback, nullptr); + sptr sceneSession = new (std::nothrow) SceneSession(info, nullptr); + EXPECT_NE(sceneSession, nullptr); + sptr mockSessionStage = new (std::nothrow) SessionStageMocker(); + ASSERT_NE(mockSessionStage, nullptr); + bool fullScreen = true; + int ret = 1; + sceneSession->sessionStage_ = mockSessionStage; + sceneSession->NotifySessionFullScreen(fullScreen); + ASSERT_EQ(ret, 1); +} + /** * @tc.name: NotifySessionBackground01 * @tc.desc: NotifySessionBackground diff --git a/window_scene/test/unittest/session_stage_proxy_test.cpp b/window_scene/test/unittest/session_stage_proxy_test.cpp index 846452d90e..d1b4b2244d 100644 --- a/window_scene/test/unittest/session_stage_proxy_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_test.cpp @@ -281,6 +281,18 @@ HWTEST_F(SessionStageProxyTest, NotifySessionBackground, Function | SmallTest | sessionStage_->NotifySessionBackground(reason, withAnimation, isFromInnerkits); } +/** + * @tc.name: NotifySessionFullScreen + * @tc.desc: test function : NotifySessionFullScreen + * @tc.type: FUNC + */ +HWTEST_F(SessionStageProxyTest, NotifySessionFullScreen, Function | SmallTest | Level1) +{ + bool fullScreen = true; + ASSERT_TRUE(sessionStage_ != nullptr); + sessionStage_->NotifySessionFullScreen(fullScreen); +} + /** * @tc.name: NotifyWindowVisibility * @tc.desc: test function : NotifyWindowVisibility diff --git a/window_scene/test/unittest/session_stage_stub_test.cpp b/window_scene/test/unittest/session_stage_stub_test.cpp index 438c575177..cf85bc68d7 100644 --- a/window_scene/test/unittest/session_stage_stub_test.cpp +++ b/window_scene/test/unittest/session_stage_stub_test.cpp @@ -298,6 +298,21 @@ HWTEST_F(SessionStageStubTest, HandleNotifySessionForeground, Function | SmallTe ASSERT_EQ(0, sessionStageStub_->HandleNotifySessionForeground(data, reply)); } +/** + * @tc.name: NotifySessionFullScreen + * @tc.desc: test function : NotifySessionFullScreen + * @tc.type: FUNC + */ +HWTEST_F(SessionStageStubTest, HandleNotifySessionFullScreen, Function | SmallTest | Level1) +{ + MessageParcel data; + MessageParcel reply; + + data.WriteBool(true); + ASSERT_TRUE(sessionStageStub_ != nullptr); + ASSERT_EQ(0, sessionStageStub_->HandleNotifySessionFullScreen(data, reply)); +} + /** * @tc.name: NotifySessionBackground * @tc.desc: test function : NotifySessionBackground diff --git a/wm/include/window_scene_session_impl.h b/wm/include/window_scene_session_impl.h index 12d0f2f0b5..d4d0da1e31 100644 --- a/wm/include/window_scene_session_impl.h +++ b/wm/include/window_scene_session_impl.h @@ -160,6 +160,7 @@ public: virtual WMError SetImmersiveModeEnabledState(bool enable) override; virtual bool GetImmersiveModeEnabledState() const override; uint32_t GetStatusBarHeight() override; + void NotifySessionFullScreen(bool fullScreen) override; protected: void DestroySubWindow(); diff --git a/wm/src/window_scene_session_impl.cpp b/wm/src/window_scene_session_impl.cpp index b64dc3830e..966f16907a 100644 --- a/wm/src/window_scene_session_impl.cpp +++ b/wm/src/window_scene_session_impl.cpp @@ -1678,8 +1678,8 @@ WMError WindowSceneSessionImpl::SetLayoutFullScreen(bool status) } if (WindowHelper::IsMainWindow(GetType()) && - windowSystemConfig_.uiType_ != "phone" && - windowSystemConfig_.uiType_ != "pad") { + ((windowSystemConfig_.uiType_ != "phone" && windowSystemConfig_.uiType_ != "pad") || + IsFreeMultiWindowMode())) { if (!WindowHelper::IsWindowModeSupported(property_->GetModeSupportInfo(), WindowMode::WINDOW_MODE_FULLSCREEN)) { TLOGE(WmsLogTag::WMS_IMMS, "fullscreen window mode is not supported"); return WMError::WM_ERROR_INVALID_WINDOW; @@ -3068,6 +3068,12 @@ void WindowSceneSessionImpl::NotifySessionForeground(uint32_t reason, bool withA Show(reason, withAnimation); } +void WindowSceneSessionImpl::NotifySessionFullScreen(bool fullScreen) +{ + TLOGI(WmsLogTag::WMS_LAYOUT, "winId: %{public}u", GetWindowId()); + SetLayoutFullScreen(fullScreen); +} + void WindowSceneSessionImpl::NotifySessionBackground(uint32_t reason, bool withAnimation, bool isFromInnerkits) { WLOGFI("NotifySessionBackground"); diff --git a/wm/test/unittest/window_scene_session_impl_test2.cpp b/wm/test/unittest/window_scene_session_impl_test2.cpp index 467e5ef9ec..4e2aad1c54 100644 --- a/wm/test/unittest/window_scene_session_impl_test2.cpp +++ b/wm/test/unittest/window_scene_session_impl_test2.cpp @@ -875,6 +875,24 @@ HWTEST_F(WindowSceneSessionImplTest2, NotifySessionBackground, Function | SmallT windowSceneSession->NotifySessionBackground(reason, withAnimation, isFromInnerkits); } +/** + * @tc.name: NotifySessionFullScreen + * @tc.desc: NotifySessionFullScreen + * @tc.type: FUNC + */ +HWTEST_F(WindowSceneSessionImplTest2, NotifySessionFullScreen, Function | SmallTest | Level2) +{ + sptr option = new (std::nothrow) WindowOption(); + ASSERT_NE(nullptr, option); + option->SetWindowName("NotifySessionFullScreen"); + option->SetWindowType(WindowType::SYSTEM_WINDOW_BASE); + sptr windowSceneSession = new (std::nothrow) WindowSceneSessionImpl(option); + ASSERT_NE(nullptr, windowSceneSession); + + bool fullScreen = true; + windowSceneSession->NotifySessionFullScreen(fullScreen); +} + /** * @tc.name: NotifyPrepareClosePiPWindow01 * @tc.desc: NotifyPrepareClosePiPWindow