diff --git a/window_scene/common/include/window_session_property.h b/window_scene/common/include/window_session_property.h index 14ecb65fc9c250013e2e32be055010d7eeb7d172..581aed90f549a0fba2402c8c597ae923d4cc7e3c 100755 --- a/window_scene/common/include/window_session_property.h +++ b/window_scene/common/include/window_session_property.h @@ -350,6 +350,9 @@ public: void SetExclusivelyHighlighted(bool isExclusivelyHighlighted); mutable std::mutex windowMaskMutex_; + void SetIsShowDecorWhenLocked(bool isShow); + bool GetIsShowDecorWhenLocked() const; + private: void setTouchHotAreasInner(const std::vector& rects, std::vector& touchHotAreas); bool MarshallingTouchHotAreasInner(const std::vector& touchHotAreas, Parcel& parcel) const; @@ -595,6 +598,8 @@ private: * Window Transition Animation For PC */ std::unordered_map> transitionAnimationConfig_; + + bool isShowDecorWhenLocked_ { false }; }; class CompatibleModeProperty : public Parcelable { diff --git a/window_scene/common/src/window_session_property.cpp b/window_scene/common/src/window_session_property.cpp index 011f485f87e46cc65435536b1a68ea135f05859a..e69b84f4566e304f095c8965898ce653603370ad 100755 --- a/window_scene/common/src/window_session_property.cpp +++ b/window_scene/common/src/window_session_property.cpp @@ -1367,7 +1367,8 @@ bool WindowSessionProperty::Marshalling(Parcel& parcel) const parcel.WriteBool(isPcAppInpadSpecificSystemBarInvisible_) && parcel.WriteBool(isPcAppInpadOrientationLandscape_) && parcel.WriteBool(isPcAppInpadCompatibleMode_) && - parcel.WriteString(ancoRealBundleName_); + parcel.WriteString(ancoRealBundleName_) && + parcel.WriteBool(isShowDecorWhenLocked_); } WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) @@ -1483,6 +1484,7 @@ WindowSessionProperty* WindowSessionProperty::Unmarshalling(Parcel& parcel) property->SetPcAppInpadOrientationLandscape(parcel.ReadBool()); property->SetPcAppInpadCompatibleMode(parcel.ReadBool()); property->SetAncoRealBundleName(parcel.ReadString()); + property->SetIsShowDecorWhenLocked(parcel.ReadBool()); return property; } @@ -1594,6 +1596,7 @@ void WindowSessionProperty::CopyFrom(const sptr& property std::lock_guard lock(missionInfoMutex_); missionInfo_ = property->missionInfo_; } + isShowDecorWhenLocked_ = property->isShowDecorWhenLocked_; } bool WindowSessionProperty::Write(Parcel& parcel, WSPropertyChangeAction action) @@ -2590,5 +2593,15 @@ void SystemSessionConfig::ConvertSupportUIExtensionSubWindow(const std::string& { supportUIExtensionSubWindow_ = StringUtil::ConvertStringToBool(itemValue); } + +void WindowSessionProperty::SetIsShowDecorWhenLocked(bool isShow) +{ + isShowDecorWhenLocked_ = isShow; +} + +bool WindowSessionProperty::GetIsShowDecorWhenLocked() const +{ + return isShowDecorWhenLocked_; +} } // namespace Rosen } // namespace OHOS \ No newline at end of file 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 47eb7df6173b7bdcc4f57c62dda1e02c0714759a..39aef1d1eba830e58aa7d84ce62242e84ce1c00f 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 @@ -324,8 +324,6 @@ napi_value JsSceneSessionManager::Init(napi_env env, napi_value exportObj) JsSceneSessionManager::SetUIEffectControllerAliveInUI); BindNativeFunction(env, exportObj, "setPiPSettingSwitchStatus", moduleName, JsSceneSessionManager::SetPiPSettingSwitchStatus); - BindNativeFunction(env, exportObj, "UpdateSystemDecorEnable", moduleName, - JsSceneSessionManager::UpdateSystemDecorEnable); BindNativeFunction(env, exportObj, "applyFeatureConfig", moduleName, JsSceneSessionManager::ApplyFeatureConfig); return NapiGetUndefined(env); @@ -5320,33 +5318,4 @@ napi_value JsSceneSessionManager::OnSetPiPSettingSwitchStatus(napi_env env, napi SceneSessionManager::GetInstance().SetPiPSettingSwitchStatus(switchStatus); return NapiGetUndefined(env); } - -napi_value JsSceneSessionManager::UpdateSystemDecorEnable(napi_env env, napi_callback_info info) -{ - TLOGI(WmsLogTag::WMS_DECOR, "in"); - JsSceneSessionManager* me = CheckParamsAndGetThis(env, info); - return (me != nullptr) ? me->OnUpdateSystemDecorEnable(env, info) : nullptr; -} - -napi_value JsSceneSessionManager::OnUpdateSystemDecorEnable(napi_env env, napi_callback_info info) -{ - size_t argc = ARGC_ONE; - napi_value argv[ARGC_ONE] = { nullptr }; - napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr); - if (argc != ARGC_ONE) { - TLOGE(WmsLogTag::WMS_DECOR, "Argc is invalid: %{public}zu", argc); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); - return NapiGetUndefined(env); - } - bool enable = true; - if (!ConvertFromJsValue(env, argv[0], enable)) { - TLOGE(WmsLogTag::WMS_DECOR, "Failed to convert parameter to enable"); - napi_throw(env, CreateJsError(env, static_cast(WSErrorCode::WS_ERROR_INVALID_PARAM), - "Input parameter is missing or invalid")); - return NapiGetUndefined(env); - } - SceneSessionManager::GetInstance().UpdateSystemDecorEnable(enable); - return NapiGetUndefined(env); -} } // namespace OHOS::Rosen \ No newline at end of file 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 8e0172a96c6f91a22b94f62db6e3239cb8146190..d06130ea2df6c23920723d25541bd729133b16e0 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 @@ -178,8 +178,6 @@ public: */ static napi_value SetPiPSettingSwitchStatus(napi_env env, napi_callback_info info); - static napi_value UpdateSystemDecorEnable(napi_env env, napi_callback_info info); - private: napi_value OnSetBehindWindowFilterEnabled(napi_env env, napi_callback_info info); napi_value OnRegisterCallback(napi_env env, napi_callback_info info); @@ -404,8 +402,6 @@ private: */ napi_value OnSupportSnapshotAllSessionStatus(napi_env env, napi_callback_info info); napi_value OnSupportPreloadStartingWindow(napi_env env, napi_callback_info info); - - napi_value OnUpdateSystemDecorEnable(napi_env env, napi_callback_info info); }; } // namespace OHOS::Rosen 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 c08cbf3016335d083ac1d8a4f50e11a7991269c6..4b2e85c81dc3e298bf9f764998ff11b8a206b357 100644 --- a/window_scene/session/container/include/zidl/session_stage_interface.h +++ b/window_scene/session/container/include/zidl/session_stage_interface.h @@ -287,6 +287,16 @@ public: * @return Returns WSError::WS_OK if called success, otherwise failed. */ virtual WSError SendFbActionEvent(const std::string& action) = 0; + + /** + * @brief update if show decor when screen locked. + * + * update decor show status. Such as true or false. + * + * @param isShow Indicates if the decor show. + * @return Returns WSError::WS_OK if called success, otherwise failed. + */ + virtual WSError UpdateIsShowDecorWhenLocked(bool isShow) = 0; }; } // namespace OHOS::Rosen #endif // OHOS_WINDOW_SCENE_SESSION_STAGE_INTERFACE_H 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 99cacaf6c490f3bb030bd27935740f7ab74ecac0..9c9ebdd0998b3a6dfb7c378393ecabf5c79c9bf0 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 @@ -97,6 +97,7 @@ enum class SessionStageInterfaceCode { TRANS_ID_UPDATE_GLOBAL_DISPLAY_RECT, // Floating ball TRANS_ID_SEND_FB_ACTION_EVENT, + TRANS_ID_NOTIFY_UPDATE_ISSHOWDECORWHENLOCKED, }; } // 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 700cc196d965c970f8d0e2e742a4af4e7a6874a0..4983a12f96b72dfddc5afc1d3f56852fa7da29af 100644 --- a/window_scene/session/container/include/zidl/session_stage_proxy.h +++ b/window_scene/session/container/include/zidl/session_stage_proxy.h @@ -114,6 +114,7 @@ public: void NotifyAppUseControlStatus(bool isUseControl) override; WMError GetRouterStackInfo(std::string& routerStackInfo) override; WSError SendFbActionEvent(const std::string& action) override; + WSError UpdateIsShowDecorWhenLocked(bool isShow) 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 79e0024968fbfcdf562f74a446c8781adc971718..03ee9d0a5d8d6673db960b5865d8fa1cbcb70860 100644 --- a/window_scene/session/container/include/zidl/session_stage_stub.h +++ b/window_scene/session/container/include/zidl/session_stage_stub.h @@ -105,6 +105,7 @@ private: int HandleGetRouterStackInfo(MessageParcel& data, MessageParcel& reply); int HandleCloseSpecificScene(MessageParcel& data, MessageParcel& reply); int HandleSendFbActionEvent(MessageParcel& data, MessageParcel& reply); + int HandleUpdateIsShowDecorWhenLocked(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 05c8b318be2b10b958b37cc411ed1ee5c0919f41..9b0f1f1d78e7f323772e9948cffeb023452ca3b3 100644 --- a/window_scene/session/container/src/zidl/session_stage_proxy.cpp +++ b/window_scene/session/container/src/zidl/session_stage_proxy.cpp @@ -2248,4 +2248,36 @@ WSError SessionStageProxy::CloseSpecificScene() } return WSError::WS_OK; } + +WSError SessionStageProxy::UpdateIsShowDecorWhenLocked(bool isShow) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option(MessageOption::TF_ASYNC); + if (!data.WriteInterfaceToken(GetDescriptor())) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "WriteInterfaceToken failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + if (!data.WriteBool(isShow)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Write isShow failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + + sptr remote = Remote(); + if (remote == nullptr) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "remote is null"); + return WSError::WS_ERROR_IPC_FAILED; + } + + if (remote->SendRequest( + static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_UPDATE_ISSHOWDECORWHENLOCKED), + data, reply, option) != ERR_NONE) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "SendRequest failed"); + return WSError::WS_ERROR_IPC_FAILED; + } + int32_t ret = reply.ReadInt32(); + return static_cast(ret); +} + + } // namespace OHOS::Rosen 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 c52c1d096969366b77b1ef28dec01ff4212bce64..eb10a83f65eac21203d4a03fac2e661ae0ba0cd2 100644 --- a/window_scene/session/container/src/zidl/session_stage_stub.cpp +++ b/window_scene/session/container/src/zidl/session_stage_stub.cpp @@ -236,6 +236,8 @@ int SessionStageStub::OnRemoteRequest(uint32_t code, MessageParcel& data, Messag return HandleUpdateGlobalDisplayRectFromServer(data, reply); case static_cast(SessionStageInterfaceCode::TRANS_ID_SEND_FB_ACTION_EVENT): return HandleSendFbActionEvent(data, reply); + case static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_UPDATE_ISSHOWDECORWHENLOCKED): + return HandleUpdateIsShowDecorWhenLocked(data, reply); default: WLOGFE("Failed to find function handler!"); return IPCObjectStub::OnRemoteRequest(code, data, reply, option); @@ -1224,4 +1226,19 @@ int SessionStageStub::HandleCloseSpecificScene(MessageParcel& data, MessageParce CloseSpecificScene(); return ERR_NONE; } + +int SessionStageStub::HandleUpdateIsShowDecorWhenLocked(MessageParcel& data, MessageParcel& reply) +{ + TLOGD(WmsLogTag::WMS_ATTRIBUTE, "called!"); + bool isShow = true; + if (!data.ReadBool(isShow)) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "read isShow failed"); + return ERR_INVALID_DATA; + } + WSError errCode = UpdateIsShowDecorWhenLocked(isShow); + if (!reply.WriteInt32(static_cast(errCode))) { + return ERR_INVALID_DATA; + } + return ERR_NONE; +} } // namespace OHOS::Rosen diff --git a/window_scene/session/host/include/session.h b/window_scene/session/host/include/session.h index 306a829fd535eeeca8260809ed64e10d11449443..ff942454ef931ff1c655cbfe95ed239242105a85 100644 --- a/window_scene/session/host/include/session.h +++ b/window_scene/session/host/include/session.h @@ -760,6 +760,8 @@ public: */ std::shared_ptr GetRSUIContext(const char* caller = ""); + WSError SetIsShowDecorWhenLocked(bool isShow); + protected: class SessionLifeCycleTask : public virtual RefBase { public: diff --git a/window_scene/session/host/src/scene_session.cpp b/window_scene/session/host/src/scene_session.cpp index 2a037c2232d96a454c0e6843cbfa83878a80fac4..82c578cbb159644083f619094ec1e0d47587265e 100644 --- a/window_scene/session/host/src/scene_session.cpp +++ b/window_scene/session/host/src/scene_session.cpp @@ -7369,6 +7369,8 @@ void SceneSession::SetTemporarilyShowWhenLocked(bool isTemporarilyShowWhenLocked isTemporarilyShowWhenLocked_.store(isTemporarilyShowWhenLocked); TLOGI(WmsLogTag::WMS_SCB, "SetTemporarilyShowWhenLocked successfully, target:%{public}u", isTemporarilyShowWhenLocked); + GetSessionProperty()->SetScreenLocked(!isTemporarilyShowWhenLocked); + SetScreenLocked(!isTemporarilyShowWhenLocked); } bool SceneSession::IsTemporarilyShowWhenLocked() const diff --git a/window_scene/session/host/src/session.cpp b/window_scene/session/host/src/session.cpp index fabf801d9a5d3ab357cd45d0088b245957a32ac2..1d0243cff14bf3019119b6aab0649f50c734b48d 100644 --- a/window_scene/session/host/src/session.cpp +++ b/window_scene/session/host/src/session.cpp @@ -1357,6 +1357,7 @@ void Session::InitSessionPropertyWhenConnect(const sptr& property->SetPcAppInpadCompatibleMode(GetSessionProperty()->GetPcAppInpadCompatibleMode()); property->SetPcAppInpadSpecificSystemBarInvisible(GetSessionProperty()->GetPcAppInpadSpecificSystemBarInvisible()); property->SetPcAppInpadOrientationLandscape(GetSessionProperty()->GetPcAppInpadOrientationLandscape()); + property->SetScreenLocked(isScreenLockedCallback_ && isScreenLockedCallback_()); SetSessionProperty(property); GetSessionProperty()->SetIsNeedUpdateWindowMode(false); } @@ -3328,12 +3329,12 @@ WSError Session::SetAppSupportPhoneInPc(bool isSupportPhone) WSError Session::SetCompatibleModeProperty(const sptr compatibleModeProperty) { auto property = GetSessionProperty(); - if (property == nullptr || compatibleModeProperty == nullptr) { + if (property == nullptr) { TLOGE(WmsLogTag::WMS_COMPAT, "id: %{public}d property is nullptr", persistentId_); return WSError::WS_ERROR_NULLPTR; } property->SetCompatibleModeProperty(compatibleModeProperty); - if (compatibleModeProperty->IsDragResizeDisabled()) { + if (compatibleModeProperty && compatibleModeProperty->IsDragResizeDisabled()) { property->SetDragEnabled(false); } if (!sessionStage_) { @@ -4868,4 +4869,23 @@ std::shared_ptr Session::GetRSUIContext(const char* caller) caller, RSAdapterUtil::RSUIContextToStr(rsUIContext_).c_str(), GetPersistentId(), screenId); return rsUIContext_; } + +WSError Session::SetIsShowDecorWhenLocked(bool isShow) +{ + if (!IsSessionValid()) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "Session is invalid, id: %{public}d state: %{public}u", + GetPersistentId(), GetSessionState()); + return WSError::WS_ERROR_INVALID_SESSION; + } + if (!sessionStage_) { + TLOGE(WmsLogTag::WMS_ATTRIBUTE, "sessionStage_ is null"); + return WSError::WS_ERROR_NULLPTR; + } + if (WindowHelper::IsMainWindow(GetWindowType())) { + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "id: %{public}d isShow: %{public}d", + GetPersistentId(), isShow); + return sessionStage_->updateIsShowDecorWhenLocked(isShow); + } + return WSError::WS_OK; +} } // namespace OHOS::Rosen \ No newline at end of file diff --git a/window_scene/session/host/src/zidl/session_proxy.cpp b/window_scene/session/host/src/zidl/session_proxy.cpp index 00d3dd6a181e89b2c68e2b09d954405d09350b0e..1691d407e0920b90b964cfd8886a026c07deef29 100644 --- a/window_scene/session/host/src/zidl/session_proxy.cpp +++ b/window_scene/session/host/src/zidl/session_proxy.cpp @@ -343,6 +343,7 @@ WSError SessionProxy::Connect(const sptr& sessionStage, const spt return WSError::WS_ERROR_IPC_FAILED; } property->SetMissionInfo(*missionInfo); + property->SetIsShowDecorWhenLocked(reply.ReadBool()); } int32_t ret = reply.ReadInt32(); return static_cast(ret); diff --git a/window_scene/session/host/src/zidl/session_stub.cpp b/window_scene/session/host/src/zidl/session_stub.cpp index 455a2f243f86c998923a5978c858d7da4d92ba6c..d56b2f87d2d594ba775c7e04adf777ff9de3225e 100644 --- a/window_scene/session/host/src/zidl/session_stub.cpp +++ b/window_scene/session/host/src/zidl/session_stub.cpp @@ -507,6 +507,7 @@ int SessionStub::HandleConnect(MessageParcel& data, MessageParcel& reply) reply.WriteString(property->GetAncoRealBundleName()); MissionInfo missionInfo = property->GetMissionInfo(); reply.WriteParcelable(&missionInfo); + reply.WriteBool(property->GetIsShowDecorWhenLocked()); } reply.WriteUint32(static_cast(errCode)); return ERR_NONE; diff --git a/window_scene/session_manager/include/scene_session_manager.h b/window_scene/session_manager/include/scene_session_manager.h index c9499419c762acc301747e0facb7abbe612ef7ab..cfa898b900ad74e2cafb7f7b7c6d65f3e423d94b 100644 --- a/window_scene/session_manager/include/scene_session_manager.h +++ b/window_scene/session_manager/include/scene_session_manager.h @@ -808,7 +808,6 @@ public: std::vector> GetSceneSessions(ScreenId screenId); WMError UpdateScreenLockState(int32_t persistentId); - WMError UpdateSystemDecorEnable(bool enable); protected: SceneSessionManager(); @@ -1719,6 +1718,7 @@ private: void UpdateAllStartingWindowRdb(); bool needUpdateRdb_ = true; std::string GetCallerSessionColorMode(const SessionInfo& sessionInfo); + void NotifySessionScreenLockedChange(bool isScreenLocked); }; } // namespace OHOS::Rosen diff --git a/window_scene/session_manager/src/scene_session_manager.cpp b/window_scene/session_manager/src/scene_session_manager.cpp index 5a2f962d7427a8c8bf66e4674620e14892607b45..6efde6fada06bfb98b8c6a7b61230c7cef96fd11 100644 --- a/window_scene/session_manager/src/scene_session_manager.cpp +++ b/window_scene/session_manager/src/scene_session_manager.cpp @@ -8482,6 +8482,7 @@ void SceneSessionManager::SetScreenLocked(const bool isScreenLocked) isScreenLocked_ = isScreenLocked; DeleteStateDetectTask(); NotifyPiPWindowVisibleChange(isScreenLocked); + NotifySessionScreenLockedChange(isScreenLocked); }, __func__); } @@ -17574,10 +17575,15 @@ WMError SceneSessionManager::UpdateScreenLockState(int32_t persistentId) return WMError::WM_OK; } -WMError SceneSessionManager::UpdateSystemDecorEnable(bool enable) -{ - TLOGI(WmsLogTag::WMS_DECOR, "set system decor enable: %{public}d", enable); - systemConfig_.isSystemDecorEnable_ = enable; - return WMError::WM_OK; +void SceneSessionManager::NotifySessionScreenLockedChange(bool isScreenLocked) { + std::shared_lock lock(sceneSessionMapMutex_); + for (const auto& [_, sceneSession] : sceneSessionMap_) { + if (sceneSession == nullptr && !(GetSessionProperty()->GetWindowFlags() & + static_cast(WindowFlag::WINDOW_FLAG_SHOW_WHEN_LOCKED))) { + continue; + } + sceneSession->GetSessionProperty()->SetIsShowDecorWhenLocked(!isScreenLocked); + sceneSession->SetIsShowDecorWhenLocked(!isScreenLocked); + } } } // namespace OHOS::Rosen diff --git a/window_scene/test/mock/mock_session.h b/window_scene/test/mock/mock_session.h index b22c90c2a2fce120cdc489277e1db3ec20b991a0..57bd1138f4a5ad935da6563318e2f3593cd6c058 100644 --- a/window_scene/test/mock/mock_session.h +++ b/window_scene/test/mock/mock_session.h @@ -70,6 +70,7 @@ public: MOCK_METHOD1(RaiseMainWindowAboveTarget, WSError(int32_t targetId)); MOCK_METHOD(WSError, ProcessPointDownSession, (int32_t x, int32_t y), (override)); MOCK_CONST_METHOD2(ConvertGlobalRectToRelative, WSRect(const WSRect& globalRect, DisplayId targetDisplayId)); + MOCK_METHOD1(SetIsShowDecorWhenLocked, WSError(bool isShow)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/mock/mock_session_stage.h b/window_scene/test/mock/mock_session_stage.h index dfa0390941e085cfe1e9e0410f2dd40e9562e315..a5101aae4144c9017268a341e2ab2548f6dd7cdd 100644 --- a/window_scene/test/mock/mock_session_stage.h +++ b/window_scene/test/mock/mock_session_stage.h @@ -92,6 +92,7 @@ public: MOCK_METHOD0(NotifyAppHookWindowInfoUpdated, WSError(void)); MOCK_METHOD1(GetRouterStackInfo, WMError(std::string& routerStackInfo)); MOCK_METHOD1(SendFbActionEvent, WSError(const std::string& action)); + MOCK_METHOD1(UpdateIsShowDecorWhenLocked, WSError(bool isShow)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/mock/mock_session_stub.h b/window_scene/test/mock/mock_session_stub.h index ec39d858b20cfdd5ca3aa5518c7db16b92cc85a9..b08a511bd307bf168958dd9522337bb9461f0a4d 100644 --- a/window_scene/test/mock/mock_session_stub.h +++ b/window_scene/test/mock/mock_session_stub.h @@ -87,6 +87,7 @@ public: MOCK_METHOD1(GetFloatingBallWindowId, WMError(uint32_t& windowId)); MOCK_METHOD1(SendFbActionEvent, WSError(const std::string& action)); MOCK_METHOD1(RestoreFbMainWindow, WMError(const std::shared_ptr& want)); + MOCK_METHOD1(UpdateIsShowDecorWhenLocked, WSError(bool& isShow)); }; } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index a6e87b2ebf17779b3c79db3b2309faba420c8287..3b50f371fae0c5306005f3ca3a85d4a6e361dc8c 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -3031,19 +3031,6 @@ HWTEST_F(SceneSessionManagerTest12, UpdateScreenLockState, Function | SmallTest EXPECT_EQ(result, WMError::WM_OK); } -/** - * @tc.name: UpdateScreenLockState - * @tc.desc: test function : UpdateScreenLockState - * @tc.type: FUNC - */ -HWTEST_F(SceneSessionManagerTest12, UpdateSystemDecorEnable, Function | SmallTest | Level2) -{ - bool enable = false; - auto result = ssm_->UpdateSystemDecorEnable(enable); - EXPECT_EQ(result, WMError::WM_OK); - EXPECT_EQ(ssm_->systemConfig_.isSystemDecorEnable_, enable); -} - /** * @tc.name: IsFocusWindowParent * @tc.desc: test function : IsFocusWindowParent diff --git a/window_scene/test/unittest/session_stage_proxy_test.cpp b/window_scene/test/unittest/session_stage_proxy_test.cpp index 270ff05d8c3122501894b5be915e9272d247b5b1..826e0315f9bbdf471511b3449ce4d8ad3f96c466 100755 --- a/window_scene/test/unittest/session_stage_proxy_test.cpp +++ b/window_scene/test/unittest/session_stage_proxy_test.cpp @@ -1011,6 +1011,35 @@ HWTEST_F(SessionStageProxyTest, TestUpdateGlobalDisplayRectFromServer, TestSize. sptr successProxy = sptr::MakeSptr(remoteMock); EXPECT_EQ(WSError::WS_OK, successProxy->UpdateGlobalDisplayRectFromServer(rect, reason)); } + +/** + * @tc.name: SetScreenLocked + * @tc.desc: Test SetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(SessionStageProxyTest, UpdateIsShowDecorWhenLocked, TestSize.Level1) +{ + ASSERT_TRUE(sessionStage_ != nullptr); + bool isShow = true; + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(true); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionStage_->UpdateIsShowDecorWhenLocked(isShow)); + + MockMessageParcel::SetWriteInterfaceTokenErrorFlag(false); + + ASSERT_EQ(WSError::WS_OK, sessionStage_->UpdateIsShowDecorWhenLocked(isShow)); + sptr sProxy = sptr::MakeSptr(nullptr); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sProxy->UpdateIsShowDecorWhenLocked(isShow)); + + auto remoteMocker = sptr::MakeSptr(); + remoteMocker->sendRequestResult_ = 1; + sptr sessionStage = sptr::MakeSptr(remoteMocker); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionStage->UpdateIsShowDecorWhenLocked(isShow)); + + MockMessageParcel::SetWriteBoolErrorFlag(true); + ASSERT_EQ(WSError::WS_ERROR_IPC_FAILED, sessionStage_->UpdateIsShowDecorWhenLocked(isShow)); + MockMessageParcel::SetWriteStringErrorFlag(false); + MockMessageParcel::ClearAllErrorFlag(); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_stage_stub_test.cpp b/window_scene/test/unittest/session_stage_stub_test.cpp index dd2777cac68842596d8a817320b3cea2a53132ce..2eb74a499d61b61a339f65ecc4d8cbb1bc43d3e5 100644 --- a/window_scene/test/unittest/session_stage_stub_test.cpp +++ b/window_scene/test/unittest/session_stage_stub_test.cpp @@ -1286,6 +1286,39 @@ HWTEST_F(SessionStageStubTest, HandleNotifyAppHookWindowInfoUpdated, TestSize.Le ASSERT_TRUE(sessionStageStub_ != nullptr); EXPECT_EQ(ERR_NONE, sessionStageStub_->OnRemoteRequest(code, data, reply, option)); } + +/** + * @tc.name: HandleUpdateIsShowDecorWhenLocked + * @tc.desc: test function : HandleUpdateIsShowDecorWhenLocked + * @tc.type: FUNC + */ +HWTEST_F(SessionStageStubTest, HandleUpdateIsShowDecorWhenLocked, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + MessageOption option; + data.WriteInterfaceToken(SessionStageStub::GetDescriptor()); + sptr windowManagerAgent = sptr::MakeSptr(); + data.WriteRemoteObject(windowManagerAgent->AsObject()); + ASSERT_TRUE(sessionStageStub_ != nullptr); + uint32_t code = static_cast(SessionStageInterfaceCode::TRANS_ID_NOTIFY_UPDATA_ISSHOWDECORWHENLOCKED); + EXPECT_EQ(ERR_INVALID_DATA, sessionStageStub_->OnRemoteRequest(code, data, reply, option)); +} + +/** + * @tc.name: HandleUpdateIsShowDecorWhenLocked 02 + * @tc.desc: test function : HandleUpdateIsShowDecorWhenLocked 02 + * @tc.type: FUNC + */ +HWTEST_F(SessionStageStubTest, HandleUpdateIsShowDecorWhenLocked02, TestSize.Level1) +{ + MessageParcel data; + MessageParcel reply; + bool isShow = true; + data.WriteBool(static_cast(isShow)); + ASSERT_TRUE(sessionStageStub_ != nullptr); + EXPECT_EQ(ERR_NONE, sessionStageStub_->HandleUpdateIsShowDecorWhenLocked(data, reply)); +} } // namespace } // namespace Rosen } // namespace OHOS \ No newline at end of file diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index 9ed999db81e4e534be411de8f833ca37b90e22c1..83cfd1c300c06f5dea17816994754b2e461616db 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -1521,6 +1521,55 @@ HWTEST_F(WindowSessionTest4, HasParentSessionWithToken, TestSize.Level1) ret = session->HasParentSessionWithToken(token); EXPECT_EQ(ret, true); } + +/** + * @tc.name: SetIsShowDecorWhenLocked 01 + * @tc.desc: Test Case SetIsShowDecorWhenLocked 01 + * @tc.name: SetIsShowDecorWhenLocked 01 + * @tc.desc: Test Case SetIsShowDecorWhenLocked 01 + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, SetIsShowDecorWhenLocked01, TestSize.Level1) +HWTEST_F(WindowSessionTest4, SetIsShowDecorWhenLocked01, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + bool isShow = true; + bool isShow = true; + session_->state_ = SessionState::STATE_DISCONNECT; + WSError result = session_->SetIsShowDecorWhenLocked(isShow); + WSError result = session_->SetIsShowDecorWhenLocked(isShow); + EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION); + + session_->state_ = SessionState::STATE_CONNECT; + session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + WSError result02 = session_->SetIsShowDecorWhenLocked(isShow); + WSError result02 = session_->SetIsShowDecorWhenLocked(isShow); + EXPECT_EQ(result02, WSError::WS_ERROR_NULLPTR); +} + +/** + * @tc.name: SetIsShowDecorWhenLocked 02 + * @tc.desc: Test Case SetIsShowDecorWhenLocked 02 + * @tc.name: SetIsShowDecorWhenLocked 02 + * @tc.desc: Test Case SetIsShowDecorWhenLocked 02 + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionTest4, SetIsShowDecorWhenLocked02, TestSize.Level1) +HWTEST_F(WindowSessionTest4, SetIsShowDecorWhenLocked02, TestSize.Level1) +{ + ASSERT_NE(session_, nullptr); + bool isShow = true; + bool isShow = true; + session_->state_ = SessionState::STATE_CONNECT; + session_->sessionStage_ = sptr::MakeSptr(); + session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE); + WSError result = session_->SetIsShowDecorWhenLocked(isShow); + EXPECT_EQ(result, WSError::WS_OK); + + session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END); + WSError result02 = session_->SetIsShowDecorWhenLocked(isShow); + EXPECT_EQ(result02, WSError::WS_OK); +} } // namespace } // namespace Rosen } // namespace OHOS diff --git a/window_scene/test/unittest/window_session_property_test.cpp b/window_scene/test/unittest/window_session_property_test.cpp index 0200eb1545c9fab9839c3463602dd60558690584..4284a1da9c2bba6e0d9cbe26e0c00d348da4f3e3 100755 --- a/window_scene/test/unittest/window_session_property_test.cpp +++ b/window_scene/test/unittest/window_session_property_test.cpp @@ -1654,6 +1654,36 @@ HWTEST_F(WindowSessionPropertyTest, UnmarshallingFbTemplateInfoTest, TestSize.Le ASSERT_EQ(property->GetFbTemplateInfo().backgroundColor_, fbTemplateInfo.backgroundColor_); ASSERT_EQ(property->GetFbTemplateInfo().icon_, fbTemplateInfo.icon_); } + +/** + * @tc.name: SetScreenLocked + * @tc.desc: Test SetScreenLocked + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, SetIsShowDecorWhenLocked, TestSize.Level1) +{ + sptr property = sptr::MakeSptr(); + bool isShow = true; + property->SetIsShowDecorWhenLocked(isShow); + ASSERT_EQ(isShow, property->GetIsShowDecorWhenLocked()); + isShow = false; + property->SetIsShowDecorWhenLocked(isShow); + ASSERT_EQ(isShow, property->GetIsShowDecorWhenLocked()); +} + +/** + * @tc.name: GetIsShowDecorWhenLocked + * @tc.desc: Test GetIsShowDecorWhenLocked + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionPropertyTest, GetIsShowDecorWhenLocked, TestSize.Level1) +{ + sptr property = sptr::MakeSptr(); + bool isShow = true; + property->SetIsShowDecorWhenLocked(isShow); + ASSERT_EQ(true, property->getIsShowDecorWhenLocked()); +} + } // namespace } // namespace Rosen } // namespace OHOS diff --git a/wm/include/window_session_impl.h b/wm/include/window_session_impl.h index ec8fad751cf7a653940edbe66329312276ca4925..77afabbb0e0cf53efc73c8a5c928850e1adbd67a 100644 --- a/wm/include/window_session_impl.h +++ b/wm/include/window_session_impl.h @@ -584,6 +584,8 @@ public: WMError GetRouterStackInfo(std::string& routerStackInfo) override; void SetNavDestinationInfo(const std::string& navDestinationInfo) override; + WSError UpdateIsShowDecorWhenLocked(bool isShow) override; + protected: WMError Connect(); bool IsWindowSessionInvalid() const; diff --git a/wm/src/window_session_impl.cpp b/wm/src/window_session_impl.cpp index 10068cf229e23c8f34fe789a4329c539dd098b2b..a675d5ff4ff038f2ae5a95245f2baec2af8b3a8f 100644 --- a/wm/src/window_session_impl.cpp +++ b/wm/src/window_session_impl.cpp @@ -2337,7 +2337,8 @@ void WindowSessionImpl::UpdateDecorEnableToAce(bool isDecorEnable) auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || (property_->GetIsPcAppInPad() && isSubWindow)) && - !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()) && + property_->GetIsShowDecorWhenLocked(); } if (mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { decorVisible = false; @@ -2369,7 +2370,8 @@ void WindowSessionImpl::UpdateDecorEnable(bool needNotify, WindowMode mode) auto isSubWindow = WindowHelper::IsSubWindow(GetType()); decorVisible = decorVisible && (windowSystemConfig_.freeMultiWindowEnable_ || (property_->GetIsPcAppInPad() && isSubWindow)) && - !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()); + !(mode == WindowMode::WINDOW_MODE_FULLSCREEN && property_->GetCompatibleModeProperty()) && + property_->GetIsShowDecorWhenLocked(); } if (GetWindowMode() == WindowMode::WINDOW_MODE_FULLSCREEN && property_->IsDecorFullscreenDisabled()) { decorVisible = false; @@ -8114,5 +8116,12 @@ void WindowSessionImpl::SetNotifySizeChangeFlag(bool flag) notifySizeChangeFlag_ = false; } +WSError WindowSessionImpl::UpdateIsShowDecorWhenLocked(bool isShow) +{ + TLOGI(WmsLogTag::WMS_ATTRIBUTE, "isShow: %{public}d", isShow); + property_->SetIsShowDecorWhenLocked(isShow); + return WSError::WS_OK; +} + } // namespace Rosen } // namespace OHOS diff --git a/wm/test/unittest/window_session_impl_test5.cpp b/wm/test/unittest/window_session_impl_test5.cpp index b19ea601b10e32096de0fa6eb621ae3f11a4cb1c..5ffaabfd314bf706f80ae3321ef5e9c4922b8f92 100644 --- a/wm/test/unittest/window_session_impl_test5.cpp +++ b/wm/test/unittest/window_session_impl_test5.cpp @@ -1969,6 +1969,20 @@ HWTEST_F(WindowSessionImplTest5, NotifySizeChangeFlag, Function | SmallTest | Le window->SetNotifySizeChangeFlag(true); ASSERT_EQ(window->notifySizeChangeFlag_, false); } + +/** + * @tc.name: UpdateIsShowDecorWhenLocked + * @tc.desc: UpdateIsShowDecorWhenLocked + * @tc.type: FUNC + */ +HWTEST_F(WindowSessionImplTest5, UpdateIsShowDecorWhenLocked, Function | SmallTest | Level1) +{ + sptr option = sptr::MakeSptr(); + option->SetWindowName("UpdateIsShowDecorWhenLocked"); + sptr window = sptr::MakeSptr(option); + bool isShow = true; + ASSERT_EQ(WSError::WS_OK, window->UpdateIsShowDecorWhenLocked(isShow)); +} } // namespace } // namespace Rosen } // namespace OHOS