已关闭
four step power on/off for concurrentuser #20075
wsen创建于 8月22日关闭于 25 天前
four step power on/off for concurrentuser #20075
已关闭
共 23 个文件变更+857-16
| @@ -53,6 +53,7 @@ public: | |||
| 53 | void NotifyBrightnessInfoChanged(ScreenId screenId, const ScreenBrightnessInfo& info) override {}; | 53 | void NotifyBrightnessInfoChanged(ScreenId screenId, const ScreenBrightnessInfo& info) override {}; |
| 54 | void OnDisplayAttributeChange(sptr<DisplayInfo> displayInfo, const std::vector<std::string>& attributes) | 54 | void OnDisplayAttributeChange(sptr<DisplayInfo> displayInfo, const std::vector<std::string>& attributes) |
| 55 | override {}; | 55 | override {}; |
| 56 | + void NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state) override {}; | ||
| 56 | }; | 57 | }; |
| 57 | } | 58 | } |
| 58 | } | 59 | } |
| @@ -53,6 +53,7 @@ public: | |||
| 53 | virtual void OnDisplayAttributeChange(sptr<DisplayInfo> displayInfo, const std::vector<std::string>& attributes) | 53 | virtual void OnDisplayAttributeChange(sptr<DisplayInfo> displayInfo, const std::vector<std::string>& attributes) |
| 54 | override; | 54 | override; |
| 55 | virtual void NotifyRecordingDisplayChanged(const std::vector<DisplayId>& displayIds) override; | 55 | virtual void NotifyRecordingDisplayChanged(const std::vector<DisplayId>& displayIds) override; |
| 56 | + virtual void NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state) override; | ||
| 56 | private: | 57 | private: |
| 57 | static inline BrokerDelegator<DisplayManagerAgentProxy> delegator_; | 58 | static inline BrokerDelegator<DisplayManagerAgentProxy> delegator_; |
| 58 | }; | 59 | }; |
| @@ -78,6 +78,7 @@ public: | |||
| 78 | TRANS_ID_ON_BRIGHTNESS_INFO_CHANGED, | 78 | TRANS_ID_ON_BRIGHTNESS_INFO_CHANGED, |
| 79 | TRANS_ID_ON_DISPLAY_ATTRIBUTE_CHANGED, | 79 | TRANS_ID_ON_DISPLAY_ATTRIBUTE_CHANGED, |
| 80 | TRANS_ID_ON_RECORDING_DISPLAY_CHANGED, | 80 | TRANS_ID_ON_RECORDING_DISPLAY_CHANGED, |
| 81 | + TRANS_ID_NOTIFY_DISPLAY_STATE_CHANGED_BY_ID, | ||
| 81 | }; | 82 | }; |
| 82 | virtual void NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) = 0; | 83 | virtual void NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status) = 0; |
| 83 | virtual void NotifyDisplayStateChanged(DisplayId id, DisplayState state) = 0; | 84 | virtual void NotifyDisplayStateChanged(DisplayId id, DisplayState state) = 0; |
| @@ -105,6 +106,7 @@ public: | |||
| 105 | virtual void OnDisplayAttributeChange(sptr<DisplayInfo> displayInfo, | 106 | virtual void OnDisplayAttributeChange(sptr<DisplayInfo> displayInfo, |
| 106 | const std::vector<std::string>& attributes) = 0; | 107 | const std::vector<std::string>& attributes) = 0; |
| 107 | virtual void NotifyRecordingDisplayChanged(const std::vector<DisplayId>& displayIds) = 0; | 108 | virtual void NotifyRecordingDisplayChanged(const std::vector<DisplayId>& displayIds) = 0; |
| 109 | + virtual void NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state) = 0; | ||
| 108 | }; | 110 | }; |
| 109 | } // namespace Rosen | 111 | } // namespace Rosen |
| 110 | } // namespace OHOS | 112 | } // namespace OHOS |
| @@ -86,6 +86,37 @@ void DisplayManagerAgentProxy::NotifyDisplayStateChanged(DisplayId id, DisplaySt | |||
| 86 | } | 86 | } |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | +void DisplayManagerAgentProxy::NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state) | ||
| 90 | +{ | ||
| 91 | + sptr<IRemoteObject> remote = Remote(); | ||
| 92 | + if (remote == nullptr) { | ||
| 93 | + TLOGW(WmsLogTag::DMS, "remote is nullptr"); | ||
| 94 | + return; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + MessageParcel data; | ||
| 98 | + MessageParcel reply; | ||
| 99 | + MessageOption option; | ||
| 100 | + if (!data.WriteInterfaceToken(GetDescriptor())) { | ||
| 101 | + TLOGE(WmsLogTag::DMS, "WriteInterfaceToken failed"); | ||
| 102 | + return; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + if (!data.WriteUint64(static_cast<uint64_t>(displayId))) { | ||
| 106 | + TLOGE(WmsLogTag::DMS, "Write screenId failed"); | ||
| 107 | + return; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + if (!data.WriteUint32(static_cast<uint32_t>(state))) { | ||
| 111 | + TLOGE(WmsLogTag::DMS, "Write DisplayState failed"); | ||
| 112 | + return; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + if (remote->SendRequest(TRANS_ID_NOTIFY_DISPLAY_STATE_CHANGED_BY_ID, data, reply, option) != ERR_NONE) { | ||
| 116 | + TLOGE(WmsLogTag::DMS, "SendRequest failed"); | ||
| 117 | + } | ||
| 118 | +} | ||
| 119 | + | ||
| 89 | void DisplayManagerAgentProxy::OnScreenConnect(sptr<ScreenInfo> screenInfo) | 120 | void DisplayManagerAgentProxy::OnScreenConnect(sptr<ScreenInfo> screenInfo) |
| 90 | { | 121 | { |
| 91 | sptr<IRemoteObject> remote = Remote(); | 122 | sptr<IRemoteObject> remote = Remote(); |
| @@ -47,6 +47,12 @@ int32_t DisplayManagerAgentStub::OnRemoteRequest(uint32_t code, MessageParcel& d | |||
| 47 | NotifyDisplayStateChanged(id, state); | 47 | NotifyDisplayStateChanged(id, state); |
| 48 | break; | 48 | break; |
| 49 | } | 49 | } |
| 50 | + case TRANS_ID_NOTIFY_DISPLAY_STATE_CHANGED_BY_ID: { | ||
| 51 | + DisplayId displayId = static_cast<DisplayId>(data.ReadUint64()); | ||
| 52 | + DisplayState state = static_cast<DisplayState>(data.ReadUint32()); | ||
| 53 | + NotifyDisplayStateChangedById(displayId, state); | ||
| 54 | + break; | ||
| 55 | + } | ||
| 50 | case TRANS_ID_ON_SCREEN_CONNECT: { | 56 | case TRANS_ID_ON_SCREEN_CONNECT: { |
| 51 | sptr<ScreenInfo> screenInfo = data.ReadParcelable<ScreenInfo>(); | 57 | sptr<ScreenInfo> screenInfo = data.ReadParcelable<ScreenInfo>(); |
| 52 | OnScreenConnect(screenInfo); | 58 | OnScreenConnect(screenInfo); |
| @@ -106,6 +106,11 @@ public: | |||
| 106 | virtual DMError UnregisterDisplayAttribute(const std::vector<std::string>& attributes, | 106 | virtual DMError UnregisterDisplayAttribute(const std::vector<std::string>& attributes, |
| 107 | const sptr<IDisplayManagerAgent>& displayManagerAgent); | 107 | const sptr<IDisplayManagerAgent>& displayManagerAgent); |
| 108 | virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion(); | 108 | virtual sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion(); |
| 109 | + virtual bool WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 110 | + virtual bool WakeUpEnd(DisplayId displayId); | ||
| 111 | + virtual bool SuspendBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 112 | + virtual bool SuspendEnd(DisplayId displayId); | ||
| 113 | + virtual bool SetDisplayState(DisplayId displayId, DisplayState state); | ||
| 109 | private: | 114 | private: |
| 110 | static inline SingletonDelegator<DisplayManagerAdapterLite> delegator; | 115 | static inline SingletonDelegator<DisplayManagerAdapterLite> delegator; |
| 111 | protected: | 116 | protected: |
| @@ -128,6 +133,8 @@ public: | |||
| 128 | virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos, bool isNeedUnused = false); | 133 | virtual DMError GetAllScreenInfos(std::vector<sptr<ScreenInfo>>& screenInfos, bool isNeedUnused = false); |
| 129 | virtual bool SynchronizePowerStatus(ScreenPowerState state); | 134 | virtual bool SynchronizePowerStatus(ScreenPowerState state); |
| 130 | virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio); | 135 | virtual DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio); |
| 136 | + virtual bool SetScreenPowerForSpecifiedId(DisplayId displayId, | ||
| 137 | + ScreenPowerState state, PowerStateChangeReason reason); | ||
| 131 | private: | 138 | private: |
| 132 | static inline SingletonDelegator<ScreenManagerAdapterLite> delegator; | 139 | static inline SingletonDelegator<ScreenManagerAdapterLite> delegator; |
| 133 | }; | 140 | }; |
| @@ -90,6 +90,12 @@ public: | |||
| 90 | DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio); | 90 | DMError SetResolution(ScreenId screenId, uint32_t width, uint32_t height, float virtualPixelRatio); |
| 91 | sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion(); | 91 | sptr<FoldCreaseRegion> GetCurrentFoldCreaseRegion(); |
| 92 | void NotifyBootAnimationFinished(); | 92 | void NotifyBootAnimationFinished(); |
| 93 | + bool WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 94 | + bool WakeUpEnd(DisplayId displayId); | ||
| 95 | + bool SuspendBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 96 | + bool SuspendEnd(DisplayId displayId); | ||
| 97 | + bool SetScreenPowerForSpecifiedId(DisplayId displayId, ScreenPowerState state, PowerStateChangeReason reason); | ||
| 98 | + bool SetDisplayState(DisplayId displayId, DisplayState state); | ||
| 93 | private: | 99 | private: |
| 94 | static inline DMError ConvertToDMError(ErrCode errCode, int32_t dmError); | 100 | static inline DMError ConvertToDMError(ErrCode errCode, int32_t dmError); |
| 95 | sptr<IRemoteObject> Remote() | 101 | sptr<IRemoteObject> Remote() |
| @@ -155,6 +161,12 @@ private: | |||
| 155 | COMMAND_GET_ALL_DISPLAY_PHYSICAL_RESOLUTION, | 161 | COMMAND_GET_ALL_DISPLAY_PHYSICAL_RESOLUTION, |
| 156 | COMMAND_SET_SCREEN_BRIGHTNESS, | 162 | COMMAND_SET_SCREEN_BRIGHTNESS, |
| 157 | COMMAND_GET_SCREEN_BRIGHTNESS, | 163 | COMMAND_GET_SCREEN_BRIGHTNESS, |
| 164 | + COMMAND_WAKE_UP_BEGIN_WITH_DISPLAY_ID, | ||
| 165 | + COMMAND_WAKE_UP_END_WITH_DISPLAY_ID, | ||
| 166 | + COMMAND_SUSPEND_BEGIN_WITH_DISPLAY_ID, | ||
| 167 | + COMMAND_SUSPEND_END_WITH_DISPLAY_ID, | ||
| 168 | + COMMAND_SET_DISPLAY_STATE_WITH_DISPLAY_ID, | ||
| 169 | + COMMAND_SET_SCREEN_POWER_FOR_SPECIFIED_ID, | ||
| 158 | }; | 170 | }; |
| 159 | 171 | ||
| 160 | // generated by IDisplayManagerLite.idl | 172 | // generated by IDisplayManagerLite.idl |
| @@ -1,17 +1,17 @@ | |||
| 1 | -// /* | 1 | +/* |
| 2 | -// * Copyright (c) 2023 Huawei Device Co., Ltd. | 2 | + * Copyright (c) 2023 Huawei Device Co., Ltd. |
| 3 | -// * Licensed under the Apache License, Version 2.0 (the "License"); | 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | -// * you may not use this file except in compliance with the License. | 4 | + * you may not use this file except in compliance with the License. |
| 5 | -// * You may obtain a copy of the License at, | 5 | + * You may obtain a copy of the License at, |
| 6 | -// * | 6 | + * |
| 7 | -// * http://www.apache.org/licenses/LICENSE-2.0 | 7 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | -// * | 8 | + * |
| 9 | -// * Unless required by applicable law or agreed to in writing, software, | 9 | + * Unless required by applicable law or agreed to in writing, software, |
| 10 | -// * distributed under the License is distributed on an "AS IS" BASIS, | 10 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | -// * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | -// * See the License for the specific language governing permissions and | 12 | + * See the License for the specific language governing permissions and |
| 13 | -// * limitations under the License. | 13 | + * limitations under the License. |
| 14 | -// */ | 14 | + */ |
| 15 | 15 | ||
| 16 | 16 | ||
| 17 | 17 | ||
| @@ -213,6 +213,46 @@ bool DisplayManagerAdapterLite::SuspendEnd() | |||
| 213 | return displayManagerServiceProxy_->SuspendEnd(); | 213 | return displayManagerServiceProxy_->SuspendEnd(); |
| 214 | } | 214 | } |
| 215 | 215 | ||
| 216 | +bool DisplayManagerAdapterLite::WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 217 | +{ | ||
| 218 | + if (IsScreenLessDevice()) { | ||
| 219 | + return true; | ||
| 220 | + } | ||
| 221 | + INIT_PROXY_CHECK_RETURN(false); | ||
| 222 | + | ||
| 223 | + return displayManagerServiceProxy_->WakeUpBegin(displayId, reason); | ||
| 224 | +} | ||
| 225 | + | ||
| 226 | +bool DisplayManagerAdapterLite::WakeUpEnd(DisplayId displayId) | ||
| 227 | +{ | ||
| 228 | + if (IsScreenLessDevice()) { | ||
| 229 | + return true; | ||
| 230 | + } | ||
| 231 | + INIT_PROXY_CHECK_RETURN(false); | ||
| 232 | + | ||
| 233 | + return displayManagerServiceProxy_->WakeUpEnd(displayId); | ||
| 234 | +} | ||
| 235 | + | ||
| 236 | +bool DisplayManagerAdapterLite::SuspendBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 237 | +{ | ||
| 238 | + if (IsScreenLessDevice()) { | ||
| 239 | + return true; | ||
| 240 | + } | ||
| 241 | + INIT_PROXY_CHECK_RETURN(false); | ||
| 242 | + | ||
| 243 | + return displayManagerServiceProxy_->SuspendBegin(displayId, reason); | ||
| 244 | +} | ||
| 245 | + | ||
| 246 | +bool DisplayManagerAdapterLite::SuspendEnd(DisplayId displayId) | ||
| 247 | +{ | ||
| 248 | + if (IsScreenLessDevice()) { | ||
| 249 | + return true; | ||
| 250 | + } | ||
| 251 | + INIT_PROXY_CHECK_RETURN(false); | ||
| 252 | + | ||
| 253 | + return displayManagerServiceProxy_->SuspendEnd(displayId); | ||
| 254 | +} | ||
| 255 | + | ||
| 216 | DMError DisplayManagerAdapterLite::SetScreenSwitchState(ScreenClosedState screenClosedState, bool isScreenOn) | 256 | DMError DisplayManagerAdapterLite::SetScreenSwitchState(ScreenClosedState screenClosedState, bool isScreenOn) |
| 217 | { | 257 | { |
| 218 | if (IsScreenLessDevice()) { | 258 | if (IsScreenLessDevice()) { |
| @@ -254,6 +294,16 @@ bool DisplayManagerAdapterLite::SetDisplayState(DisplayState state) | |||
| 254 | return displayManagerServiceProxy_->SetDisplayState(state); | 294 | return displayManagerServiceProxy_->SetDisplayState(state); |
| 255 | } | 295 | } |
| 256 | 296 | ||
| 297 | +bool DisplayManagerAdapterLite::SetDisplayState(DisplayId displayId, DisplayState state) | ||
| 298 | +{ | ||
| 299 | + if (IsScreenLessDevice()) { | ||
| 300 | + return true; | ||
| 301 | + } | ||
| 302 | + INIT_PROXY_CHECK_RETURN(false); | ||
| 303 | + | ||
| 304 | + return displayManagerServiceProxy_->SetDisplayState(displayId, state); | ||
| 305 | +} | ||
| 306 | + | ||
| 257 | DisplayState DisplayManagerAdapterLite::GetDisplayState(DisplayId displayId) | 307 | DisplayState DisplayManagerAdapterLite::GetDisplayState(DisplayId displayId) |
| 258 | { | 308 | { |
| 259 | INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN); | 309 | INIT_PROXY_CHECK_RETURN(DisplayState::UNKNOWN); |
| @@ -400,6 +450,17 @@ bool ScreenManagerAdapterLite::SetScreenPowerForAll(ScreenPowerState state, Powe | |||
| 400 | return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason); | 450 | return displayManagerServiceProxy_->SetScreenPowerForAll(state, reason); |
| 401 | } | 451 | } |
| 402 | 452 | ||
| 453 | +bool ScreenManagerAdapterLite::SetScreenPowerForSpecifiedId(DisplayId displayId, ScreenPowerState state, | ||
| 454 | + PowerStateChangeReason reason) | ||
| 455 | +{ | ||
| 456 | + if (IsScreenLessDevice()) { | ||
| 457 | + return true; | ||
| 458 | + } | ||
| 459 | + INIT_PROXY_CHECK_RETURN(false); | ||
| 460 | + | ||
| 461 | + return displayManagerServiceProxy_->SetScreenPowerForSpecifiedId(displayId, state, reason); | ||
| 462 | +} | ||
| 463 | + | ||
| 403 | ScreenPowerState ScreenManagerAdapterLite::GetScreenPower(ScreenId dmsScreenId) | 464 | ScreenPowerState ScreenManagerAdapterLite::GetScreenPower(ScreenId dmsScreenId) |
| 404 | { | 465 | { |
| 405 | if (IsScreenLessDevice()) { | 466 | if (IsScreenLessDevice()) { |
| @@ -59,6 +59,7 @@ public: | |||
| 59 | * used by powermgr | 59 | * used by powermgr |
| 60 | */ | 60 | */ |
| 61 | bool SetDisplayState(DisplayState state, DisplayStateCallback callback); | 61 | bool SetDisplayState(DisplayState state, DisplayStateCallback callback); |
| 62 | + bool SetDisplayState(DisplayId displayId, DisplayState state, DisplayStateCallback callback); | ||
| 62 | private: | 63 | private: |
| 63 | void NotifyDisplayCreate(sptr<DisplayInfo> info); | 64 | void NotifyDisplayCreate(sptr<DisplayInfo> info); |
| 64 | void NotifyDisplayDestroy(DisplayId); | 65 | void NotifyDisplayDestroy(DisplayId); |
| @@ -70,7 +71,9 @@ private: | |||
| 70 | * used by powermgr | 71 | * used by powermgr |
| 71 | */ | 72 | */ |
| 72 | void NotifyDisplayStateChanged(DisplayId id, DisplayState state); | 73 | void NotifyDisplayStateChanged(DisplayId id, DisplayState state); |
| 74 | + void NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state); | ||
| 73 | void ClearDisplayStateCallback(); | 75 | void ClearDisplayStateCallback(); |
| 76 | + void ClearDisplayStateCallback(DisplayId id); | ||
| 74 | void ClearFoldStatusCallback(); | 77 | void ClearFoldStatusCallback(); |
| 75 | void ClearDisplayModeCallback(); | 78 | void ClearDisplayModeCallback(); |
| 76 | void Clear(); | 79 | void Clear(); |
| @@ -93,6 +96,7 @@ private: | |||
| 93 | */ | 96 | */ |
| 94 | class DisplayManagerAgent; | 97 | class DisplayManagerAgent; |
| 95 | sptr<DisplayManagerAgent> displayStateAgent_; | 98 | sptr<DisplayManagerAgent> displayStateAgent_; |
| 99 | + std::map<DisplayId, std::pair<DisplayStateCallback, sptr<DisplayManagerAgent>>> displayStateMap_; | ||
| 96 | void NotifyScreenMagneticStateChanged(bool isMagneticState); | 100 | void NotifyScreenMagneticStateChanged(bool isMagneticState); |
| 97 | std::set<sptr<IScreenMagneticStateListener>> screenMagneticStateListeners_; | 101 | std::set<sptr<IScreenMagneticStateListener>> screenMagneticStateListeners_; |
| 98 | class DisplayManagerScreenMagneticStateAgent; | 102 | class DisplayManagerScreenMagneticStateAgent; |
| @@ -267,6 +271,11 @@ public: | |||
| 267 | { | 271 | { |
| 268 | pImpl_->NotifyDisplayStateChanged(id, state); | 272 | pImpl_->NotifyDisplayStateChanged(id, state); |
| 269 | } | 273 | } |
| 274 | + | ||
| 275 | + virtual void NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state) override | ||
| 276 | + { | ||
| 277 | + pImpl_->NotifyDisplayStateChangedById(screenId, state); | ||
| 278 | + } | ||
| 270 | private: | 279 | private: |
| 271 | sptr<Impl> pImpl_; | 280 | sptr<Impl> pImpl_; |
| 272 | }; | 281 | }; |
| @@ -754,6 +763,31 @@ bool DisplayManagerLite::SuspendEnd() | |||
| 754 | return SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendEnd(); | 763 | return SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendEnd(); |
| 755 | } | 764 | } |
| 756 | 765 | ||
| 766 | +bool DisplayManagerLite::WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 767 | +{ | ||
| 768 | + TLOGD(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpBegin start, reason:%{public}u", reason); | ||
| 769 | + return SingletonContainer::Get<DisplayManagerAdapterLite>().WakeUpBegin(displayId, reason); | ||
| 770 | +} | ||
| 771 | + | ||
| 772 | +bool DisplayManagerLite::WakeUpEnd(DisplayId displayId) | ||
| 773 | +{ | ||
| 774 | + TLOGD(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpEnd start"); | ||
| 775 | + return SingletonContainer::Get<DisplayManagerAdapterLite>().WakeUpEnd(displayId); | ||
| 776 | +} | ||
| 777 | + | ||
| 778 | +bool DisplayManagerLite::SuspendBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 779 | +{ | ||
| 780 | + // dms->wms notify other windows to hide | ||
| 781 | + TLOGD(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendBegin start, reason:%{public}u", reason); | ||
| 782 | + return SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendBegin(displayId, reason); | ||
| 783 | +} | ||
| 784 | + | ||
| 785 | +bool DisplayManagerLite::SuspendEnd(DisplayId displayId) | ||
| 786 | +{ | ||
| 787 | + TLOGD(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendEnd start"); | ||
| 788 | + return SingletonContainer::Get<DisplayManagerAdapterLite>().SuspendEnd(displayId); | ||
| 789 | +} | ||
| 790 | + | ||
| 757 | DMError DisplayManagerLite::SetScreenSwitchState(ScreenClosedState screenClosedState, bool isScreenOn) | 791 | DMError DisplayManagerLite::SetScreenSwitchState(ScreenClosedState screenClosedState, bool isScreenOn) |
| 758 | { | 792 | { |
| 759 | TLOGI(WmsLogTag::DMS, "[UL_POWER] start"); | 793 | TLOGI(WmsLogTag::DMS, "[UL_POWER] start"); |
| @@ -777,6 +811,13 @@ bool DisplayManagerLite::SetDisplayState(DisplayState state, DisplayStateCallbac | |||
| 777 | return pImpl_->SetDisplayState(state, callback); | 811 | return pImpl_->SetDisplayState(state, callback); |
| 778 | } | 812 | } |
| 779 | 813 | ||
| 814 | +bool DisplayManagerLite::SetDisplayState(DisplayId displayId, DisplayState state, DisplayStateCallback callback) | ||
| 815 | +{ | ||
| 816 | + TLOGD(WmsLogTag::DMS, "[UL_POWER_IVI]SetDisplayState start with screenId:%{public}" PRIu64 ",state:%{public}u", | ||
| 817 | + displayId, static_cast<uint32_t>(state)); | ||
| 818 | + return pImpl_->SetDisplayState(displayId, state, callback); | ||
| 819 | +} | ||
| 820 | + | ||
| 780 | DisplayState DisplayManagerLite::GetDisplayState(DisplayId displayId) | 821 | DisplayState DisplayManagerLite::GetDisplayState(DisplayId displayId) |
| 781 | { | 822 | { |
| 782 | return SingletonContainer::Get<DisplayManagerAdapterLite>().GetDisplayState(displayId); | 823 | return SingletonContainer::Get<DisplayManagerAdapterLite>().GetDisplayState(displayId); |
| @@ -842,6 +883,79 @@ void DisplayManagerLite::Impl::ClearDisplayStateCallback() | |||
| 842 | } | 883 | } |
| 843 | } | 884 | } |
| 844 | 885 | ||
| 886 | +bool DisplayManagerLite::Impl::SetDisplayState(DisplayId displayId, DisplayState state, DisplayStateCallback callback) | ||
| 887 | +{ | ||
| 888 | + TLOGD(WmsLogTag::DMS, "[UL_POWER_IVI]screenId:%{public}" PRIu64",state:%{public}u", displayId, state); | ||
| 889 | + if (callback == nullptr) { | ||
| 890 | + TLOGI(WmsLogTag::DMS, "[UL_POWER_IVI]Invalid callback received"); | ||
| 891 | + return false; | ||
| 892 | + } | ||
| 893 | + | ||
| 894 | + bool ret = true; | ||
| 895 | + { | ||
| 896 | + std::lock_guard<std::recursive_mutex> lock(mutex_); | ||
| 897 | + auto it = displayStateMap_.find(displayId); | ||
| 898 | + if (it != displayStateMap_.end()) { | ||
| 899 | + TLOGI(WmsLogTag::DMS, "[UL_POWER_IVI]Clear previous agent for displayId:%{public}" PRIu64, displayId); | ||
| 900 | + SingletonContainer::Get<DisplayManagerAdapterLite>().UnregisterDisplayManagerAgent( | ||
| 901 | + it->second.second, DisplayManagerAgentType::DISPLAY_STATE_LISTENER); | ||
| 902 | + displayStateMap_.erase(it); | ||
| 903 | + } | ||
| 904 | + auto agent = new DisplayManagerAgent(this); | ||
| 905 | + displayStateMap_[displayId] = { callback, agent }; | ||
| 906 | + ret = SingletonContainer::Get<DisplayManagerAdapterLite>().RegisterDisplayManagerAgent( | ||
| 907 | + agent, DisplayManagerAgentType::DISPLAY_STATE_LISTENER) == DMError::DM_OK; | ||
| 908 | + } | ||
| 909 | + | ||
| 910 | + if (!ret) { | ||
| 911 | + std::lock_guard<std::recursive_mutex> lock(mutex_); | ||
| 912 | + displayStateMap_.erase(displayId); | ||
| 913 | + return false; | ||
| 914 | + } | ||
| 915 | + ret = ret && SingletonContainer::Get<DisplayManagerAdapterLite>().SetDisplayState(displayId, state); | ||
| 916 | + if (!ret) { | ||
| 917 | + ClearDisplayStateCallback(displayId); | ||
| 918 | + } | ||
| 919 | + return ret; | ||
| 920 | +} | ||
| 921 | + | ||
| 922 | +void DisplayManagerLite::Impl::NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state) | ||
| 923 | +{ | ||
| 924 | + TLOGD(WmsLogTag::DMS, "state:%{public}u", state); | ||
| 925 | + DisplayStateCallback callback = nullptr; | ||
| 926 | + { | ||
| 927 | + std::lock_guard<std::recursive_mutex> lock(mutex_); | ||
| 928 | + auto it = displayStateMap_.find(displayId); | ||
| 929 | + if (it == displayStateMap_.end()) { | ||
| 930 | + TLOGW(WmsLogTag::DMS, "screenId:%{public}" PRIu64" not exist!", displayId); | ||
| 931 | + return; | ||
| 932 | + } | ||
| 933 | + callback = it->second.first; | ||
| 934 | + } | ||
| 935 | + | ||
| 936 | + if (callback) { | ||
| 937 | + callback(state); | ||
| 938 | + ClearDisplayStateCallback(displayId); | ||
| 939 | + return; | ||
| 940 | + } | ||
| 941 | + TLOGW(WmsLogTag::DMS, "callback_ target is not set!"); | ||
| 942 | +} | ||
| 943 | + | ||
| 944 | +void DisplayManagerLite::Impl::ClearDisplayStateCallback(DisplayId id) | ||
| 945 | +{ | ||
| 946 | + std::lock_guard<std::recursive_mutex> lock(mutex_); | ||
| 947 | + TLOGD(WmsLogTag::DMS, "[UL_POWER_IVI] Clear display state agent enter, displayId:%{public}" PRIu64, id); | ||
| 948 | + | ||
| 949 | + auto it = displayStateMap_.find(id); | ||
| 950 | + if (it == displayStateMap_.end()) { | ||
| 951 | + TLOGW(WmsLogTag::DMS, "[UL_POWER_IVI] No display state agent for displayId:%{public}" PRIu64, id); | ||
| 952 | + return; | ||
| 953 | + } | ||
| 954 | + SingletonContainer::Get<DisplayManagerAdapterLite>().UnregisterDisplayManagerAgent( | ||
| 955 | + it->second.second, DisplayManagerAgentType::DISPLAY_STATE_LISTENER); | ||
| 956 | + displayStateMap_.erase(it); | ||
| 957 | +} | ||
| 958 | + | ||
| 845 | extern "C" __attribute__((destructor)) void DisplayManagerLite::Impl::DlcloseClearResource() | 959 | extern "C" __attribute__((destructor)) void DisplayManagerLite::Impl::DlcloseClearResource() |
| 846 | { | 960 | { |
| 847 | // clear stub callback when dlclose | 961 | // clear stub callback when dlclose |
| @@ -658,6 +658,142 @@ bool DisplayManagerLiteProxy::SuspendEnd() | |||
| 658 | 658 | ||
| 659 | } | 659 | } |
| 660 | 660 | ||
| 661 | +bool DisplayManagerLiteProxy::WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 662 | +{ | ||
| 663 | + | ||
| 664 | + sptr<IRemoteObject> remote = Remote(); | ||
| 665 | + if (remote == nullptr) { | ||
| 666 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpBegin with screenId remote is nullptr"); | ||
| 667 | + return false; | ||
| 668 | + } | ||
| 669 | + | ||
| 670 | + MessageParcel data; | ||
| 671 | + MessageParcel reply; | ||
| 672 | + MessageOption option; | ||
| 673 | + | ||
| 674 | + if (!data.WriteInterfaceToken(GetDescriptor())) { | ||
| 675 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpBegin with screenId: WriteInterfaceToken failed"); | ||
| 676 | + return false; | ||
| 677 | + } | ||
| 678 | + if (!data.WriteUint64(static_cast<uint64_t>(displayId))) { | ||
| 679 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpBegin with screenId: Write screenId failed"); | ||
| 680 | + return false; | ||
| 681 | + } | ||
| 682 | + if (!data.WriteUint32(static_cast<uint32_t>(reason))) { | ||
| 683 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpBegin with screenId: Write PowerStateChangeReason failed"); | ||
| 684 | + return false; | ||
| 685 | + } | ||
| 686 | + if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN_WITH_DISPLAY_ID), | ||
| 687 | + data, reply, option) != ERR_NONE) { | ||
| 688 | + TLOGW(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpBegin with screenId: SendRequest failed"); | ||
| 689 | + return false; | ||
| 690 | + } | ||
| 691 | + return reply.ReadBool(); | ||
| 692 | + | ||
| 693 | + return false; | ||
| 694 | + | ||
| 695 | +} | ||
| 696 | + | ||
| 697 | +bool DisplayManagerLiteProxy::WakeUpEnd(DisplayId displayId) | ||
| 698 | +{ | ||
| 699 | + | ||
| 700 | + sptr<IRemoteObject> remote = Remote(); | ||
| 701 | + if (remote == nullptr) { | ||
| 702 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpEnd with screenId remote is nullptr"); | ||
| 703 | + return false; | ||
| 704 | + } | ||
| 705 | + | ||
| 706 | + MessageParcel data; | ||
| 707 | + MessageParcel reply; | ||
| 708 | + MessageOption option; | ||
| 709 | + | ||
| 710 | + if (!data.WriteInterfaceToken(GetDescriptor())) { | ||
| 711 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpEnd with screenId: WriteInterfaceToken failed"); | ||
| 712 | + return false; | ||
| 713 | + } | ||
| 714 | + if (!data.WriteUint64(static_cast<uint64_t>(displayId))) { | ||
| 715 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpEnd with screenId: Write screenId failed"); | ||
| 716 | + return false; | ||
| 717 | + } | ||
| 718 | + if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_WAKE_UP_END_WITH_DISPLAY_ID), | ||
| 719 | + data, reply, option) != ERR_NONE) { | ||
| 720 | + TLOGW(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpEnd with screenId: SendRequest failed"); | ||
| 721 | + return false; | ||
| 722 | + } | ||
| 723 | + return reply.ReadBool(); | ||
| 724 | + | ||
| 725 | + return false; | ||
| 726 | + | ||
| 727 | +} | ||
| 728 | + | ||
| 729 | +bool DisplayManagerLiteProxy::SuspendBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 730 | +{ | ||
| 731 | + | ||
| 732 | + sptr<IRemoteObject> remote = Remote(); | ||
| 733 | + if (remote == nullptr) { | ||
| 734 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendBegin with screenId remote is nullptr"); | ||
| 735 | + return false; | ||
| 736 | + } | ||
| 737 | + | ||
| 738 | + MessageParcel data; | ||
| 739 | + MessageParcel reply; | ||
| 740 | + MessageOption option; | ||
| 741 | + | ||
| 742 | + if (!data.WriteInterfaceToken(GetDescriptor())) { | ||
| 743 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendBegin with screenId : WriteInterfaceToken failed"); | ||
| 744 | + return false; | ||
| 745 | + } | ||
| 746 | + if (!data.WriteUint64(static_cast<uint64_t>(displayId))) { | ||
| 747 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendBegin with screenId: Write screenId failed"); | ||
| 748 | + return false; | ||
| 749 | + } | ||
| 750 | + if (!data.WriteUint32(static_cast<uint32_t>(reason))) { | ||
| 751 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendBegin with screenId: Write PowerStateChangeReason failed"); | ||
| 752 | + return false; | ||
| 753 | + } | ||
| 754 | + if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN_WITH_DISPLAY_ID), | ||
| 755 | + data, reply, option) != ERR_NONE) { | ||
| 756 | + TLOGW(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendBegin with screenId: SendRequest failed"); | ||
| 757 | + return false; | ||
| 758 | + } | ||
| 759 | + return reply.ReadBool(); | ||
| 760 | + | ||
| 761 | + return false; | ||
| 762 | + | ||
| 763 | +} | ||
| 764 | + | ||
| 765 | +bool DisplayManagerLiteProxy::SuspendEnd(DisplayId displayId) | ||
| 766 | +{ | ||
| 767 | + | ||
| 768 | + sptr<IRemoteObject> remote = Remote(); | ||
| 769 | + if (remote == nullptr) { | ||
| 770 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendEnd with screenId remote is nullptr"); | ||
| 771 | + return false; | ||
| 772 | + } | ||
| 773 | + | ||
| 774 | + MessageParcel data; | ||
| 775 | + MessageParcel reply; | ||
| 776 | + MessageOption option; | ||
| 777 | + | ||
| 778 | + if (!data.WriteInterfaceToken(GetDescriptor())) { | ||
| 779 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendEnd with screenId: WriteInterfaceToken failed"); | ||
| 780 | + return false; | ||
| 781 | + } | ||
| 782 | + if (!data.WriteUint64(static_cast<uint64_t>(displayId))) { | ||
| 783 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendEnd with screenId: Write screenId failed"); | ||
| 784 | + return false; | ||
| 785 | + } | ||
| 786 | + if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SUSPEND_END_WITH_DISPLAY_ID), | ||
| 787 | + data, reply, option) != ERR_NONE) { | ||
| 788 | + TLOGW(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendEnd with screenId: SendRequest failed"); | ||
| 789 | + return false; | ||
| 790 | + } | ||
| 791 | + return reply.ReadBool(); | ||
| 792 | + | ||
| 793 | + return false; | ||
| 794 | + | ||
| 795 | +} | ||
| 796 | + | ||
| 661 | DMError DisplayManagerLiteProxy::SetScreenSwitchState(ScreenClosedState screenClosedState, bool isScreenOn) | 797 | DMError DisplayManagerLiteProxy::SetScreenSwitchState(ScreenClosedState screenClosedState, bool isScreenOn) |
| 662 | { | 798 | { |
| 663 | 799 | ||
| @@ -839,6 +975,46 @@ bool DisplayManagerLiteProxy::SetScreenPowerForAll(ScreenPowerState state, Power | |||
| 839 | 975 | ||
| 840 | } | 976 | } |
| 841 | 977 | ||
| 978 | +bool DisplayManagerLiteProxy::SetScreenPowerForSpecifiedId(DisplayId displayId, ScreenPowerState state, | ||
| 979 | + PowerStateChangeReason reason) | ||
| 980 | +{ | ||
| 981 | + | ||
| 982 | + sptr<IRemoteObject> remote = Remote(); | ||
| 983 | + if (remote == nullptr) { | ||
| 984 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI] SetScreenPowerForSpecifiedId remote is nullptr"); | ||
| 985 | + return false; | ||
| 986 | + } | ||
| 987 | + | ||
| 988 | + MessageParcel data; | ||
| 989 | + MessageParcel reply; | ||
| 990 | + MessageOption option; | ||
| 991 | + if (!data.WriteInterfaceToken(GetDescriptor())) { | ||
| 992 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI] WriteInterfaceToken failed"); | ||
| 993 | + return false; | ||
| 994 | + } | ||
| 995 | + if (!data.WriteUint64(static_cast<uint64_t>(displayId))) { | ||
| 996 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI] Write ScreenId failed"); | ||
| 997 | + return false; | ||
| 998 | + } | ||
| 999 | + if (!data.WriteUint32(static_cast<uint32_t>(state))) { | ||
| 1000 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI] Write ScreenPowerState failed"); | ||
| 1001 | + return false; | ||
| 1002 | + } | ||
| 1003 | + if (!data.WriteUint32(static_cast<uint32_t>(reason))) { | ||
| 1004 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI] Write PowerStateChangeReason failed"); | ||
| 1005 | + return false; | ||
| 1006 | + } | ||
| 1007 | + if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_SPECIFIED_ID), | ||
| 1008 | + data, reply, option) != ERR_NONE) { | ||
| 1009 | + TLOGW(WmsLogTag::DMS, "[UL_POWER_IVI] SendRequest failed"); | ||
| 1010 | + return false; | ||
| 1011 | + } | ||
| 1012 | + return reply.ReadBool(); | ||
| 1013 | + | ||
| 1014 | + return false; | ||
| 1015 | + | ||
| 1016 | +} | ||
| 1017 | + | ||
| 842 | ScreenPowerState DisplayManagerLiteProxy::GetScreenPower(ScreenId dmsScreenId) | 1018 | ScreenPowerState DisplayManagerLiteProxy::GetScreenPower(ScreenId dmsScreenId) |
| 843 | { | 1019 | { |
| 844 | 1020 | ||
| @@ -964,6 +1140,42 @@ bool DisplayManagerLiteProxy::SetDisplayState(DisplayState state) | |||
| 964 | 1140 | ||
| 965 | } | 1141 | } |
| 966 | 1142 | ||
| 1143 | +bool DisplayManagerLiteProxy::SetDisplayState(ScreenId screenId, DisplayState state) | ||
| 1144 | +{ | ||
| 1145 | + | ||
| 1146 | + sptr<IRemoteObject> remote = Remote(); | ||
| 1147 | + if (remote == nullptr) { | ||
| 1148 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SetDisplayState remote is nullptr"); | ||
| 1149 | + return false; | ||
| 1150 | + } | ||
| 1151 | + | ||
| 1152 | + MessageParcel data; | ||
| 1153 | + MessageParcel reply; | ||
| 1154 | + MessageOption option; | ||
| 1155 | + if (!data.WriteInterfaceToken(GetDescriptor())) { | ||
| 1156 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]WriteInterfaceToken failed"); | ||
| 1157 | + return false; | ||
| 1158 | + } | ||
| 1159 | + if (!data.WriteUint64(static_cast<uint64_t>(screenId))) { | ||
| 1160 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]SuspendBegin with screenId: Write screenId failed"); | ||
| 1161 | + return false; | ||
| 1162 | + } | ||
| 1163 | + if (!data.WriteUint32(static_cast<uint32_t>(state))) { | ||
| 1164 | + TLOGE(WmsLogTag::DMS, "[UL_POWER_IVI]Write DisplayState failed"); | ||
| 1165 | + return false; | ||
| 1166 | + } | ||
| 1167 | + if (remote->SendRequest( | ||
| 1168 | + static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE_WITH_SCREEN_ID), | ||
| 1169 | + data, reply, option) != ERR_NONE) { | ||
| 1170 | + TLOGW(WmsLogTag::DMS, "[UL_POWER_IVI]SendRequest failed"); | ||
| 1171 | + return false; | ||
| 1172 | + } | ||
| 1173 | + return reply.ReadBool(); | ||
| 1174 | + | ||
| 1175 | + return false; | ||
| 1176 | + | ||
| 1177 | +} | ||
| 1178 | + | ||
| 967 | DisplayState DisplayManagerLiteProxy::GetDisplayState(DisplayId displayId) | 1179 | DisplayState DisplayManagerLiteProxy::GetDisplayState(DisplayId displayId) |
| 968 | { | 1180 | { |
| 969 | 1181 | ||
| @@ -399,6 +399,15 @@ bool ScreenManagerLite::SetScreenPowerForAll(ScreenPowerState state, PowerStateC | |||
| 399 | return SingletonContainer::Get<ScreenManagerAdapterLite>().SetScreenPowerForAll(state, reason); | 399 | return SingletonContainer::Get<ScreenManagerAdapterLite>().SetScreenPowerForAll(state, reason); |
| 400 | } | 400 | } |
| 401 | 401 | ||
| 402 | +bool ScreenManagerLite::SetScreenPowerForSpecifiedId(DisplayId displayId, | ||
| 403 | + ScreenPowerState state, PowerStateChangeReason reason) | ||
| 404 | +{ | ||
| 405 | + TLOGI(WmsLogTag::DMS, | ||
| 406 | + "screenId:%{public}" PRIu64 ", state:%{public}u, reason:%{public}u", displayId, state, reason); | ||
| 407 | + return SingletonContainer::Get<ScreenManagerAdapterLite>().SetScreenPowerForSpecifiedId(displayId, state, reason); | ||
| 408 | +} | ||
| 409 | + | ||
| 410 | + | ||
| 402 | ScreenPowerState ScreenManagerLite::GetScreenPower(ScreenId dmsScreenId) | 411 | ScreenPowerState ScreenManagerLite::GetScreenPower(ScreenId dmsScreenId) |
| 403 | { | 412 | { |
| 404 | return SingletonContainer::Get<ScreenManagerAdapterLite>().GetScreenPower(dmsScreenId); | 413 | return SingletonContainer::Get<ScreenManagerAdapterLite>().GetScreenPower(dmsScreenId); |
| @@ -141,7 +141,10 @@ ohos_unittest("dm_screen_manager_lite_test") { | |||
| 141 | 141 | ||
| 142 | deps = [ ":dm_unittest_common_lite" ] | 142 | deps = [ ":dm_unittest_common_lite" ] |
| 143 | deps += dm_unittest_common_lite_deps | 143 | deps += dm_unittest_common_lite_deps |
| 144 | - external_deps = [ "hilog:libhilog" ] | 144 | + external_deps = [ |
| 145 | + "hilog:libhilog", | ||
| 146 | + "googletest:gmock", | ||
| 147 | + ] | ||
| 145 | } | 148 | } |
| 146 | 149 | ||
| 147 | ## Build dm_unittest_common_lite.a {{{ | 150 | ## Build dm_unittest_common_lite.a {{{ |
| @@ -211,6 +211,12 @@ enum class DisplayManagerMessage : unsigned int { | |||
| 211 | TRANS_ID_GET_RENDER_SESSION, | 211 | TRANS_ID_GET_RENDER_SESSION, |
| 212 | TRANS_ID_NOTIFY_BOOT_ANIMATION_FINISHED, | 212 | TRANS_ID_NOTIFY_BOOT_ANIMATION_FINISHED, |
| 213 | TRANS_ID_SET_HOVER_BLOCK_LIST, | 213 | TRANS_ID_SET_HOVER_BLOCK_LIST, |
| 214 | + TRANS_ID_WAKE_UP_BEGIN_WITH_DISPLAY_ID, | ||
| 215 | + TRANS_ID_WAKE_UP_END_WITH_DISPLAY_ID, | ||
| 216 | + TRANS_ID_SUSPEND_BEGIN_WITH_DISPLAY_ID, | ||
| 217 | + TRANS_ID_SUSPEND_END_WITH_DISPLAY_ID, | ||
| 218 | + TRANS_ID_SET_DISPLAY_STATE_WITH_DISPLAY_ID, | ||
| 219 | + TRANS_ID_SET_SCREEN_POWER_FOR_SPECIFIED_ID, | ||
| 214 | }; | 220 | }; |
| 215 | } | 221 | } |
| 216 | 222 | ||
| @@ -260,6 +260,41 @@ public: | |||
| 260 | */ | 260 | */ |
| 261 | bool SuspendEnd(); | 261 | bool SuspendEnd(); |
| 262 | 262 | ||
| 263 | + /** | ||
| 264 | + * @brief Begin to wake up screen. | ||
| 265 | + * | ||
| 266 | + * @param displayId display Id | ||
| 267 | + * @param reason Reason for power state change. | ||
| 268 | + * @return True means begin success, false means begin failed. | ||
| 269 | + */ | ||
| 270 | + bool WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 271 | + | ||
| 272 | + /** | ||
| 273 | + * @brief Wake up screen end. | ||
| 274 | + * | ||
| 275 | + * @param displayId display Id | ||
| 276 | + * @return True means end success, false means end failed. | ||
| 277 | + */ | ||
| 278 | + bool WakeUpEnd(DisplayId displayId); | ||
| 279 | + | ||
| 280 | + /** | ||
| 281 | + * @brief Begin to suspend the screen. | ||
| 282 | + * | ||
| 283 | + * @param displayId display Id | ||
| 284 | + * @param reason Reason for power state change. | ||
| 285 | + * @return True means begin success, false means begin failed. | ||
| 286 | + */ | ||
| 287 | + bool SuspendBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 288 | + | ||
| 289 | + /** | ||
| 290 | + * @brief Suspend screen end. | ||
| 291 | + * | ||
| 292 | + * @param displayId display Id | ||
| 293 | + * @return True means suspend screen end success. | ||
| 294 | + * @return False means suspend screen end failed. | ||
| 295 | + */ | ||
| 296 | + bool SuspendEnd(DisplayId displayId); | ||
| 297 | + | ||
| 263 | /** | 298 | /** |
| 264 | * @brief Set the open/close lid status. | 299 | * @brief Set the open/close lid status. |
| 265 | * | 300 | * |
| @@ -294,6 +329,16 @@ public: | |||
| 294 | */ | 329 | */ |
| 295 | bool SetDisplayState(DisplayState state, DisplayStateCallback callback); | 330 | bool SetDisplayState(DisplayState state, DisplayStateCallback callback); |
| 296 | 331 | ||
| 332 | + /** | ||
| 333 | + * @brief Set the Display State object | ||
| 334 | + * | ||
| 335 | + * @param displayId display Id | ||
| 336 | + * @param state State of display. | ||
| 337 | + * @param callback Callback for display state. | ||
| 338 | + * @return True means set success, false means set failed. | ||
| 339 | + */ | ||
| 340 | + bool SetDisplayState(DisplayId displayId, DisplayState state, DisplayStateCallback callback); | ||
| 341 | + | ||
| 297 | /** | 342 | /** |
| 298 | * @brief Get the state of the target display. | 343 | * @brief Get the state of the target display. |
| 299 | * | 344 | * |
| @@ -131,6 +131,16 @@ public: | |||
| 131 | */ | 131 | */ |
| 132 | bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); | 132 | bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason); |
| 133 | 133 | ||
| 134 | + /** | ||
| 135 | + * @brief Set the screen power state on the specified screen. only concurrent user | ||
| 136 | + * | ||
| 137 | + * @param displayId display Id | ||
| 138 | + * @param state Screen power state. | ||
| 139 | + * @param reason Reason for power state change. | ||
| 140 | + * @return True means set success, false means set failed. | ||
| 141 | + */ | ||
| 142 | + bool SetScreenPowerForSpecifiedId(DisplayId displayId, ScreenPowerState state, PowerStateChangeReason reason); | ||
| 143 | + | ||
| 134 | /** | 144 | /** |
| 135 | * @brief Synchronize the screen state in power mansger. | 145 | * @brief Synchronize the screen state in power mansger. |
| 136 | * | 146 | * |
| @@ -83,6 +83,7 @@ ohos_shared_library("screen_session_manager") { | |||
| 83 | "src/screen_sensor_connector.cpp", | 83 | "src/screen_sensor_connector.cpp", |
| 84 | "src/screen_sensor_plugin.cpp", | 84 | "src/screen_sensor_plugin.cpp", |
| 85 | "src/screen_session_dumper.cpp", | 85 | "src/screen_session_dumper.cpp", |
| 86 | + "src/screen_session_manager_display_power.cpp", | ||
| 86 | "src/screen_session_manager.cpp", | 87 | "src/screen_session_manager.cpp", |
| 87 | "src/screen_setting_helper.cpp", | 88 | "src/screen_setting_helper.cpp", |
| 88 | "src/screen_tent_property.cpp", | 89 | "src/screen_tent_property.cpp", |
| @@ -301,6 +301,9 @@ public: | |||
| 301 | /** | 301 | /** |
| 302 | * On/Off screen | 302 | * On/Off screen |
| 303 | */ | 303 | */ |
| 304 | + bool WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason) override; | ||
| 305 | + bool DoWakeUpBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 306 | + bool WakeUpEnd(DisplayId displayId) override; | ||
| 304 | bool WakeUpBegin(PowerStateChangeReason reason) override; | 307 | bool WakeUpBegin(PowerStateChangeReason reason) override; |
| 305 | bool DoWakeUpBegin(PowerStateChangeReason reason); | 308 | bool DoWakeUpBegin(PowerStateChangeReason reason); |
| 306 | bool WakeUpEnd() override; | 309 | bool WakeUpEnd() override; |
| @@ -308,6 +311,9 @@ public: | |||
| 308 | bool SuspendBegin(PowerStateChangeReason reason) override; | 311 | bool SuspendBegin(PowerStateChangeReason reason) override; |
| 309 | bool DoSuspendBegin(PowerStateChangeReason reason); | 312 | bool DoSuspendBegin(PowerStateChangeReason reason); |
| 310 | bool SuspendEnd() override; | 313 | bool SuspendEnd() override; |
| 314 | + bool SuspendBegin(DisplayId displayId, PowerStateChangeReason reason) override; | ||
| 315 | + bool DoSuspendBegin(DisplayId displayId, PowerStateChangeReason reason); | ||
| 316 | + bool SuspendEnd(DisplayId displayId) override; | ||
| 311 | bool IsPreBright(PowerStateChangeReason reason); | 317 | bool IsPreBright(PowerStateChangeReason reason); |
| 312 | void BlockScreenOnByCV(void); | 318 | void BlockScreenOnByCV(void); |
| 313 | void BlockScreenOffByCV(void); | 319 | void BlockScreenOffByCV(void); |
| @@ -320,9 +326,15 @@ public: | |||
| 320 | bool DoSetDisplayState(DisplayState state); | 326 | bool DoSetDisplayState(DisplayState state); |
| 321 | bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override; | 327 | bool SetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason) override; |
| 322 | bool DoSetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason, bool isApAod = false); | 328 | bool DoSetScreenPowerForAll(ScreenPowerState state, PowerStateChangeReason reason, bool isApAod = false); |
| 329 | + bool SetScreenPowerForSpecifiedId(DisplayId displayId, ScreenPowerState state, | ||
| 330 | + PowerStateChangeReason reason) override; | ||
| 331 | + bool SetDisplayState(DisplayId displayId, DisplayState state) override; | ||
| 332 | + bool DoSetDisplayState(DisplayId displayId, DisplayState state); | ||
| 323 | ScreenPowerState GetScreenPower(ScreenId screenId) override; | 333 | ScreenPowerState GetScreenPower(ScreenId screenId) override; |
| 324 | void NotifyDisplayEvent(DisplayEvent event) override; | 334 | void NotifyDisplayEvent(DisplayEvent event) override; |
| 325 | bool NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status, PowerStateChangeReason reason); | 335 | bool NotifyDisplayPowerEvent(DisplayPowerEvent event, EventStatus status, PowerStateChangeReason reason); |
| 336 | + bool NotifySpecifiedDisplayPowerEvent(DisplayId displayId, DisplayPowerEvent event, EventStatus status, | ||
| 337 | + PowerStateChangeReason reason); | ||
| 326 | bool TryToCancelScreenOff() override; | 338 | bool TryToCancelScreenOff() override; |
| 327 | 339 | ||
| 328 | void DisablePowerOffRenderControl(ScreenId screenId) override; | 340 | void DisablePowerOffRenderControl(ScreenId screenId) override; |
| @@ -383,6 +395,7 @@ public: | |||
| 383 | void TriggerDisplayModeUpdate(FoldDisplayMode targetDisplayMode); | 395 | void TriggerDisplayModeUpdate(FoldDisplayMode targetDisplayMode); |
| 384 | void CallRsSetScreenPowerStatusSync(ScreenId screenId, ScreenPowerStatus status, | 396 | void CallRsSetScreenPowerStatusSync(ScreenId screenId, ScreenPowerStatus status, |
| 385 | PowerStateChangeReason reason = PowerStateChangeReason::STATE_CHANGE_REASON_UNKNOWN, bool isApAod = false); | 397 | PowerStateChangeReason reason = PowerStateChangeReason::STATE_CHANGE_REASON_UNKNOWN, bool isApAod = false); |
| 398 | + void CallRsSetScreenPowerStatusForConcurrent(DisplayId displayId, ScreenPowerStatus status); | ||
| 386 | void CallRsSetScreenPowerStatusSyncForFold(ScreenPowerStatus status, bool isApAod = false); | 399 | void CallRsSetScreenPowerStatusSyncForFold(ScreenPowerStatus status, bool isApAod = false); |
| 387 | void TryToRecoverFoldDisplayMode(ScreenPowerStatus status); | 400 | void TryToRecoverFoldDisplayMode(ScreenPowerStatus status); |
| 388 | bool GetScreenLcdStatus(ScreenId screenId, PanelPowerStatus& status); | 401 | bool GetScreenLcdStatus(ScreenId screenId, PanelPowerStatus& status); |
| @@ -41,6 +41,7 @@ public: | |||
| 41 | void OnDisplayDestroy(DisplayId); | 41 | void OnDisplayDestroy(DisplayId); |
| 42 | void OnDisplayCreate(sptr<DisplayInfo>); | 42 | void OnDisplayCreate(sptr<DisplayInfo>); |
| 43 | bool NotifyDisplayStateChanged(DisplayId id, DisplayState state); | 43 | bool NotifyDisplayStateChanged(DisplayId id, DisplayState state); |
| 44 | + bool NotifyDisplayStateChangedById(ScreenId screenId, DisplayState state); | ||
| 44 | void OnScreenChange(sptr<ScreenInfo>, ScreenChangeEvent); | 45 | void OnScreenChange(sptr<ScreenInfo>, ScreenChangeEvent); |
| 45 | void OnDisplayChange(sptr<DisplayInfo>, DisplayChangeEvent event, int32_t uid); | 46 | void OnDisplayChange(sptr<DisplayInfo>, DisplayChangeEvent event, int32_t uid); |
| 46 | void OnDisplayChange(sptr<DisplayInfo>, DisplayChangeEvent event); | 47 | void OnDisplayChange(sptr<DisplayInfo>, DisplayChangeEvent event); |
| @@ -467,6 +467,15 @@ public: | |||
| 467 | virtual DMError GetBundleName(DisplayId displayId, std::string& bundleName) { return DMError::DM_OK; } | 467 | virtual DMError GetBundleName(DisplayId displayId, std::string& bundleName) { return DMError::DM_OK; } |
| 468 | virtual sptr<IRemoteObject> GetRenderSession(ScreenId screenId) { return nullptr; } | 468 | virtual sptr<IRemoteObject> GetRenderSession(ScreenId screenId) { return nullptr; } |
| 469 | virtual void SetHoverBlockList(const std::vector<std::string>& hoverBlockList) {} | 469 | virtual void SetHoverBlockList(const std::vector<std::string>& hoverBlockList) {} |
| 470 | + virtual bool WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason) { return false; } | ||
| 471 | + virtual bool WakeUpEnd(DisplayId displayId) { return false; } | ||
| 472 | + virtual bool SuspendBegin(DisplayId displayId, PowerStateChangeReason reason) { return false; } | ||
| 473 | + virtual bool SuspendEnd(DisplayId displayId) { return false; } | ||
| 474 | + virtual bool SetScreenPowerForSpecifiedId(DisplayId displayId, ScreenPowerState, PowerStateChangeReason) | ||
| 475 | + { | ||
| 476 | + return false; | ||
| 477 | + } | ||
| 478 | + virtual bool SetDisplayState(DisplayId displayId, DisplayState state) { return false; } | ||
| 470 | }; | 479 | }; |
| 471 | } // namespace Rosen | 480 | } // namespace Rosen |
| 472 | } // namespace OHOS | 481 | } // namespace OHOS |
| @@ -222,6 +222,23 @@ bool ScreenSessionManagerAdapter::NotifyDisplayStateChanged(DisplayId id, Displa | |||
| 222 | return true; | 222 | return true; |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | +bool ScreenSessionManagerAdapter::NotifyDisplayStateChangedById(DisplayId displayId, DisplayState state) | ||
| 226 | +{ | ||
| 227 | + INIT_PROXY_CHECK_RETURN(); | ||
| 228 | + auto agents = dmAgentContainer_.GetAgentsByType(DisplayManagerAgentType::DISPLAY_STATE_LISTENER); | ||
| 229 | + if (agents.empty()) { | ||
| 230 | + TLOGE(WmsLogTag::DMS, "agent is null"); | ||
| 231 | + return false; | ||
| 232 | + } | ||
| 233 | + TLOGNFI(WmsLogTag::DMS, | ||
| 234 | + "Display State Changed: ID=%{public}d State=%{public}d", | ||
| 235 | + static_cast<uint32_t>(displayId), static_cast<uint32_t>(state)); | ||
| 236 | + for (auto& agent : agents) { | ||
| 237 | + agent->NotifyDisplayStateChangedById(displayId, state); | ||
| 238 | + } | ||
| 239 | + return true; | ||
| 240 | +} | ||
| 241 | + | ||
| 225 | void ScreenSessionManagerAdapter::OnDisplayCreate(sptr<DisplayInfo> displayInfo) | 242 | void ScreenSessionManagerAdapter::OnDisplayCreate(sptr<DisplayInfo> displayInfo) |
| 226 | { | 243 | { |
| 227 | INIT_PROXY_CHECK_RETURN(); | 244 | INIT_PROXY_CHECK_RETURN(); |
| @@ -0,0 +1,244 @@ | |||
| 1 | +/* | ||
| 2 | + * Copyright (c) 2026 Huawei Device Co., Ltd. | ||
| 3 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 4 | + * you may not use this file except in compliance with the License. | ||
| 5 | + * You may obtain a copy of the License at | ||
| 6 | + * | ||
| 7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 8 | + * | ||
| 9 | + * Unless required by applicable law or agreed to in writing, software | ||
| 10 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 11 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 12 | + * See the License for the specific language governing permissions and | ||
| 13 | + * limitations under the License. | ||
| 14 | + */ | ||
| 15 | + | ||
| 16 | + | ||
| 17 | + | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + | ||
| 23 | + | ||
| 24 | +namespace OHOS::Rosen { | ||
| 25 | +bool ScreenSessionManager::WakeUpBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 26 | +{ | ||
| 27 | + // only power use for concurrent user | ||
| 28 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI]ScreenId: %{public}" PRIu64 ", Reason: %{public}u", | ||
| 29 | + displayId, static_cast<uint32_t>(reason)); | ||
| 30 | + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { | ||
| 31 | + TLOGNFE(WmsLogTag::DMS, "Permission denied! calling: %{public}s, pid: %{public}d", | ||
| 32 | + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); | ||
| 33 | + return false; | ||
| 34 | + } | ||
| 35 | + std::vector<ScreenId> screenIds = GetAllScreenIds(); | ||
| 36 | + auto iter = std::find(screenIds.begin(), screenIds.end(), displayId); | ||
| 37 | + if (iter == screenIds.end()) { | ||
| 38 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI] Invalid displayId"); | ||
| 39 | + return false; | ||
| 40 | + } | ||
| 41 | + return DoWakeUpBegin(displayId, reason); | ||
| 42 | +} | ||
| 43 | + | ||
| 44 | +bool ScreenSessionManager::DoWakeUpBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 45 | +{ | ||
| 46 | + TLOGNFI(WmsLogTag::DMS, "Start"); | ||
| 47 | + bool notifyResult = ScreenSessionManagerAdapter::GetInstance(). | ||
| 48 | + NotifyDisplayPowerEvent(DisplayPowerEvent::WAKE_UP, EventStatus::BEGIN); | ||
| 49 | + if (!notifyResult) { | ||
| 50 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI] Agents failed to notify"); | ||
| 51 | + return false; | ||
| 52 | + } | ||
| 53 | + sptr<ScreenSession> screenSession = GetScreenSession(displayId); | ||
| 54 | + if (screenSession == nullptr) { | ||
| 55 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI] Cannot get ScreenSession, screenId: %{public}" PRIu64"", displayId); | ||
| 56 | + return false; | ||
| 57 | + } | ||
| 58 | + screenSession->PowerStatusChange(DisplayPowerEvent::WAKE_UP, EventStatus::BEGIN, reason); | ||
| 59 | + TLOGNFI(WmsLogTag::DMS, "End"); | ||
| 60 | + return true; | ||
| 61 | +} | ||
| 62 | + | ||
| 63 | +bool ScreenSessionManager::WakeUpEnd(DisplayId displayId) | ||
| 64 | +{ | ||
| 65 | + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER_IVI]ssm:WakeUpEndWithScreenId"); | ||
| 66 | + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { | ||
| 67 | + TLOGNFE(WmsLogTag::DMS, "Permission denied! calling: %{public}s, pid: %{public}d", | ||
| 68 | + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); | ||
| 69 | + return false; | ||
| 70 | + } | ||
| 71 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI] WakeUpEnd enter"); | ||
| 72 | + std::vector<ScreenId> screenIds = GetAllScreenIds(); | ||
| 73 | + auto iter = std::find(screenIds.begin(), screenIds.end(), displayId); | ||
| 74 | + if (iter == screenIds.end()) { | ||
| 75 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI] Invalid displayId"); | ||
| 76 | + return false; | ||
| 77 | + } | ||
| 78 | + return NotifySpecifiedDisplayPowerEvent(displayId, DisplayPowerEvent::WAKE_UP, EventStatus::END, | ||
| 79 | + PowerStateChangeReason::STATE_CHANGE_REASON_INIT); | ||
| 80 | +} | ||
| 81 | + | ||
| 82 | +bool ScreenSessionManager::SuspendBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 83 | +{ | ||
| 84 | + // only power use for concurrent user | ||
| 85 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI]ScreenId: %{public}" PRIu64 ", Reason: %{public}u", | ||
| 86 | + displayId, static_cast<uint32_t>(reason)); | ||
| 87 | + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { | ||
| 88 | + TLOGNFE(WmsLogTag::DMS, "permission denied! calling: %{public}s, pid: %{public}d", | ||
| 89 | + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); | ||
| 90 | + return false; | ||
| 91 | + } | ||
| 92 | + std::vector<ScreenId> screenIds = GetAllScreenIds(); | ||
| 93 | + auto iter = std::find(screenIds.begin(), screenIds.end(), displayId); | ||
| 94 | + if (iter == screenIds.end()) { | ||
| 95 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI]invalid displayId"); | ||
| 96 | + return false; | ||
| 97 | + } | ||
| 98 | + return DoSuspendBegin(displayId, reason); | ||
| 99 | +} | ||
| 100 | + | ||
| 101 | +bool ScreenSessionManager::DoSuspendBegin(DisplayId displayId, PowerStateChangeReason reason) | ||
| 102 | +{ | ||
| 103 | + TLOGNFI(WmsLogTag::DMS, "Start"); | ||
| 104 | + bool notifyResult = ScreenSessionManagerAdapter::GetInstance(). | ||
| 105 | + NotifyDisplayPowerEvent(DisplayPowerEvent::SLEEP, EventStatus::BEGIN); | ||
| 106 | + if (!notifyResult) { | ||
| 107 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI] Agents failed to notify"); | ||
| 108 | + return false; | ||
| 109 | + } | ||
| 110 | + sptr<ScreenSession> screenSession = GetScreenSession(displayId); | ||
| 111 | + if (screenSession == nullptr) { | ||
| 112 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI]Cannot get ScreenSession, screenId: %{public}" PRIu64"", displayId); | ||
| 113 | + return false; | ||
| 114 | + } | ||
| 115 | + screenSession->PowerStatusChange(DisplayPowerEvent::SLEEP, EventStatus::BEGIN, reason); | ||
| 116 | + TLOGNFI(WmsLogTag::DMS, "End"); | ||
| 117 | + return true; | ||
| 118 | +} | ||
| 119 | + | ||
| 120 | +bool ScreenSessionManager::SuspendEnd(DisplayId displayId) | ||
| 121 | +{ | ||
| 122 | + HITRACE_METER_FMT(HITRACE_TAG_WINDOW_MANAGER, "[UL_POWER_IVI]ssm:WakeUpEndWithScreenId"); | ||
| 123 | + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { | ||
| 124 | + TLOGNFE(WmsLogTag::DMS, "Permission denied! calling: %{public}s, pid: %{public}d", | ||
| 125 | + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); | ||
| 126 | + return false; | ||
| 127 | + } | ||
| 128 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI]WakeUpEnd enter"); | ||
| 129 | + std::vector<ScreenId> screenIds = GetAllScreenIds(); | ||
| 130 | + auto iter = std::find(screenIds.begin(), screenIds.end(), displayId); | ||
| 131 | + if (iter == screenIds.end()) { | ||
| 132 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI]invalid displayId"); | ||
| 133 | + return false; | ||
| 134 | + } | ||
| 135 | + return NotifySpecifiedDisplayPowerEvent(displayId, DisplayPowerEvent::SLEEP, EventStatus::END, | ||
| 136 | + PowerStateChangeReason::STATE_CHANGE_REASON_INIT); | ||
| 137 | +} | ||
| 138 | + | ||
| 139 | +bool ScreenSessionManager::NotifySpecifiedDisplayPowerEvent(DisplayId displayId, DisplayPowerEvent event, | ||
| 140 | + EventStatus status, PowerStateChangeReason reason) | ||
| 141 | +{ | ||
| 142 | + bool notifyResult = ScreenSessionManagerAdapter::GetInstance().NotifyDisplayPowerEvent( | ||
| 143 | + event, status); | ||
| 144 | + if (!notifyResult) { | ||
| 145 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI] Agents failed to notify"); | ||
| 146 | + return false; | ||
| 147 | + } | ||
| 148 | + sptr<ScreenSession> screenSession = GetScreenSession(displayId); | ||
| 149 | + if (screenSession == nullptr) { | ||
| 150 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI]Cannot get ScreenSession, screenId: %{public}" PRIu64"", displayId); | ||
| 151 | + return false; | ||
| 152 | + } | ||
| 153 | + screenSession->PowerStatusChange(event, status, reason); | ||
| 154 | + return true; | ||
| 155 | +} | ||
| 156 | + | ||
| 157 | +bool ScreenSessionManager::SetDisplayState(DisplayId displayId, DisplayState state) | ||
| 158 | +{ | ||
| 159 | + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { | ||
| 160 | + TLOGNFE(WmsLogTag::DMS, "permission denied! calling: %{public}s, pid: %{public}d", | ||
| 161 | + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); | ||
| 162 | + return false; | ||
| 163 | + } | ||
| 164 | + std::vector<ScreenId> screenIds = GetAllScreenIds(); | ||
| 165 | + auto iter = std::find(screenIds.begin(), screenIds.end(), displayId); | ||
| 166 | + if (iter == screenIds.end()) { | ||
| 167 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI]invalid displayId"); | ||
| 168 | + return false; | ||
| 169 | + } | ||
| 170 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI] state: %{public}d", state); | ||
| 171 | + return DoSetDisplayState(displayId, state); | ||
| 172 | +} | ||
| 173 | + | ||
| 174 | +bool ScreenSessionManager::DoSetDisplayState(DisplayId displayId, DisplayState state) | ||
| 175 | +{ | ||
| 176 | + sptr<ScreenSession> screenSession = GetScreenSession(displayId); | ||
| 177 | + if (screenSession == nullptr) { | ||
| 178 | + TLOGNFW(WmsLogTag::DMS, "[UL_POWER_IVI] screenId: %{public}" PRIu64, displayId); | ||
| 179 | + return false; | ||
| 180 | + } | ||
| 181 | + screenSession->UpdateDisplayState(state); | ||
| 182 | + return ScreenSessionManagerAdapter::GetInstance().NotifyDisplayStateChangedById(displayId, state); | ||
| 183 | +} | ||
| 184 | + | ||
| 185 | +bool ScreenSessionManager::SetScreenPowerForSpecifiedId(DisplayId displayId, ScreenPowerState state, | ||
| 186 | + PowerStateChangeReason reason) | ||
| 187 | +{ | ||
| 188 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI] Set screen power: %{public}d", state); | ||
| 189 | + if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) { | ||
| 190 | + TLOGNFE(WmsLogTag::DMS, "Permission Denied! calling: %{public}s, pid: %{public}d", | ||
| 191 | + SysCapUtil::GetClientName().c_str(), IPCSkeleton::GetCallingPid()); | ||
| 192 | + return false; | ||
| 193 | + } | ||
| 194 | + TLOGNFI(WmsLogTag::DMS, "screen id:%{public}" PRIu64 ", state:%{public}u", | ||
| 195 | + displayId, state); | ||
| 196 | + ScreenPowerStatus status; | ||
| 197 | + switch (state) { | ||
| 198 | + case ScreenPowerState::POWER_ON: { | ||
| 199 | + status = ScreenPowerStatus::POWER_STATUS_ON; | ||
| 200 | + break; | ||
| 201 | + } | ||
| 202 | + case ScreenPowerState::POWER_OFF: { | ||
| 203 | + status = ScreenPowerStatus::POWER_STATUS_OFF; | ||
| 204 | + break; | ||
| 205 | + } | ||
| 206 | + default: { | ||
| 207 | + TLOGNFW(WmsLogTag::DMS, "[UL_POWER]SetScreenPowerStatus state not support"); | ||
| 208 | + return false; | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + CallRsSetScreenPowerStatusForConcurrent(displayId, status); | ||
| 212 | + return NotifySpecifiedDisplayPowerEvent(displayId, | ||
| 213 | + state == ScreenPowerState::POWER_ON ? DisplayPowerEvent::DISPLAY_ON :DisplayPowerEvent::DISPLAY_OFF, | ||
| 214 | + EventStatus::END, reason); | ||
| 215 | +} | ||
| 216 | + | ||
| 217 | +void ScreenSessionManager::CallRsSetScreenPowerStatusForConcurrent(DisplayId displayId, ScreenPowerStatus status) | ||
| 218 | +{ | ||
| 219 | + auto rsSetScreenPowerStatusTask = [=] { | ||
| 220 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI ] rsSet Screen Power Status Task start"); | ||
| 221 | + auto screenSession = GetScreenSession(displayId); | ||
| 222 | + if (screenSession == nullptr) { | ||
| 223 | + return; | ||
| 224 | + } | ||
| 225 | + SetRSScreenPowerStatusExt(displayId, status); | ||
| 226 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI ] rsSet Screen Power Status Task end"); | ||
| 227 | + }; | ||
| 228 | + if (ffrtQueueHelper_ == nullptr) { | ||
| 229 | + screenPowerTaskScheduler_->PostVoidSyncTask(rsSetScreenPowerStatusTask, | ||
| 230 | + "rsInterface_.SetScreenPowerStatus task"); | ||
| 231 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI ]PostVoidSyncTask end"); | ||
| 232 | + return; | ||
| 233 | + } | ||
| 234 | + constexpr uint64_t SET_SCREEN_POWER_TIMEOUT_MS = 10000; | ||
| 235 | + bool isTimeOut = ffrtQueueHelper_->SubmitTaskAndWait(std::move(rsSetScreenPowerStatusTask), | ||
| 236 | + SET_SCREEN_POWER_TIMEOUT_MS); | ||
| 237 | + if (isTimeOut) { | ||
| 238 | + TLOGNFE(WmsLogTag::DMS, "[UL_POWER_IVI ]CallRsSetScreenPowerStatus timeout, ScreenId: %{public}" PRIu64"", | ||
| 239 | + displayId); | ||
| 240 | + return; | ||
| 241 | + } | ||
| 242 | + TLOGNFI(WmsLogTag::DMS, "[UL_POWER_IVI ]Call Rs Set Screen Power StatusSync end"); | ||
| 243 | +} | ||
| 244 | +} | ||
| @@ -107,6 +107,28 @@ int32_t ScreenSessionManagerStub::OnRemoteRequestInner(uint32_t code, MessagePar | |||
| 107 | reply.WriteUint32(static_cast<uint32_t>(ret)); | 107 | reply.WriteUint32(static_cast<uint32_t>(ret)); |
| 108 | break; | 108 | break; |
| 109 | } | 109 | } |
| 110 | + case DisplayManagerMessage::TRANS_ID_WAKE_UP_BEGIN_WITH_DISPALY_ID: { | ||
| 111 | + DisplayId displayId = data.ReadUint64(); | ||
| 112 | + PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32()); | ||
| 113 | + reply.WriteBool(WakeUpBegin(displayId, reason)); | ||
| 114 | + break; | ||
| 115 | + } | ||
| 116 | + case DisplayManagerMessage::TRANS_ID_WAKE_UP_END_WITH_SCREEN_ID: { | ||
| 117 | + DisplayId displayId = data.ReadUint64(); | ||
| 118 | + reply.WriteBool(WakeUpEnd(displayId)); | ||
| 119 | + break; | ||
| 120 | + } | ||
| 121 | + case DisplayManagerMessage::TRANS_ID_SUSPEND_BEGIN_WITH_SCREEN_ID: { | ||
| 122 | + DisplayId displayId = data.ReadUint64(); | ||
| 123 | + PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32()); | ||
| 124 | + reply.WriteBool(SuspendBegin(displayId, reason)); | ||
| 125 | + break; | ||
| 126 | + } | ||
| 127 | + case DisplayManagerMessage::TRANS_ID_SUSPEND_END_WITH_SCREEN_ID: { | ||
| 128 | + DisplayId displayId = data.ReadUint64(); | ||
| 129 | + reply.WriteBool(SuspendEnd(displayId)); | ||
| 130 | + break; | ||
| 131 | + } | ||
| 110 | case DisplayManagerMessage::TRANS_ID_GET_INTERNAL_SCREEN_ID: { | 132 | case DisplayManagerMessage::TRANS_ID_GET_INTERNAL_SCREEN_ID: { |
| 111 | reply.WriteUint64(GetInternalScreenId()); | 133 | reply.WriteUint64(GetInternalScreenId()); |
| 112 | break; | 134 | break; |
| @@ -115,7 +137,7 @@ int32_t ScreenSessionManagerStub::OnRemoteRequestInner(uint32_t code, MessagePar | |||
| 115 | ScreenId screenId = data.ReadUint64(); | 137 | ScreenId screenId = data.ReadUint64(); |
| 116 | ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32()); | 138 | ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32()); |
| 117 | PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32()); | 139 | PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32()); |
| 118 | - reply.WriteBool(SetScreenPowerById(screenId, state, reason)); | 140 | + reply.WriteBool(SetScreenPowerById(displayId, state, reason)); |
| 119 | break; | 141 | break; |
| 120 | } | 142 | } |
| 121 | case DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE: { | 143 | case DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE: { |
| @@ -123,6 +145,12 @@ int32_t ScreenSessionManagerStub::OnRemoteRequestInner(uint32_t code, MessagePar | |||
| 123 | reply.WriteBool(SetDisplayState(state)); | 145 | reply.WriteBool(SetDisplayState(state)); |
| 124 | break; | 146 | break; |
| 125 | } | 147 | } |
| 148 | + case DisplayManagerMessage::TRANS_ID_SET_DISPLAY_STATE_WITH_SCREEN_ID: { | ||
| 149 | + DisplayId displayId = data.ReadUint64(); | ||
| 150 | + DisplayState state = static_cast<DisplayState>(data.ReadUint32()); | ||
| 151 | + reply.WriteBool(SetDisplayState(displayId, state)); | ||
| 152 | + break; | ||
| 153 | + } | ||
| 126 | case DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER: { | 154 | case DisplayManagerMessage::TRANS_ID_SET_SPECIFIED_SCREEN_POWER: { |
| 127 | ScreenId screenId = static_cast<ScreenId>(data.ReadUint32()); | 155 | ScreenId screenId = static_cast<ScreenId>(data.ReadUint32()); |
| 128 | ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32()); | 156 | ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32()); |
| @@ -136,6 +164,13 @@ int32_t ScreenSessionManagerStub::OnRemoteRequestInner(uint32_t code, MessagePar | |||
| 136 | reply.WriteBool(SetScreenPowerForAll(state, reason)); | 164 | reply.WriteBool(SetScreenPowerForAll(state, reason)); |
| 137 | break; | 165 | break; |
| 138 | } | 166 | } |
| 167 | + case DisplayManagerMessage::TRANS_ID_SET_SCREEN_POWER_FOR_SPECIFIED_ID: { | ||
| 168 | + DisplayId displayId = static_cast<DisplayId>(data.ReadUint64()); | ||
| 169 | + ScreenPowerState state = static_cast<ScreenPowerState>(data.ReadUint32()); | ||
| 170 | + PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32()); | ||
| 171 | + reply.WriteBool(SetScreenPowerForSpecifiedId(displayId, state, reason)); | ||
| 172 | + break; | ||
| 173 | + } | ||
| 139 | case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE: { | 174 | case DisplayManagerMessage::TRANS_ID_GET_DISPLAY_STATE: { |
| 140 | DisplayState state = GetDisplayState(data.ReadUint64()); | 175 | DisplayState state = GetDisplayState(data.ReadUint64()); |
| 141 | reply.WriteUint32(static_cast<uint32_t>(state)); | 176 | reply.WriteUint32(static_cast<uint32_t>(state)); |
| @@ -87,6 +87,7 @@ test_source_common = [ | |||
| 87 | "${window_base_path}/window_scene/screen_session_manager/src/screen_sensor_connector.cpp", | 87 | "${window_base_path}/window_scene/screen_session_manager/src/screen_sensor_connector.cpp", |
| 88 | "${window_base_path}/window_scene/screen_session_manager/src/screen_session_dumper.cpp", | 88 | "${window_base_path}/window_scene/screen_session_manager/src/screen_session_dumper.cpp", |
| 89 | "${window_base_path}/window_scene/screen_session_manager/src/screen_session_manager.cpp", | 89 | "${window_base_path}/window_scene/screen_session_manager/src/screen_session_manager.cpp", |
| 90 | + "${window_base_path}/window_scene/screen_session_manager/src/screen_session_manager_display_power.cpp", | ||
| 90 | "${window_base_path}/window_scene/screen_session_manager/src/screen_setting_helper.cpp", | 91 | "${window_base_path}/window_scene/screen_session_manager/src/screen_setting_helper.cpp", |
| 91 | "${window_base_path}/window_scene/screen_session_manager/src/screen_tent_property.cpp", | 92 | "${window_base_path}/window_scene/screen_session_manager/src/screen_tent_property.cpp", |
| 92 | "${window_base_path}/window_scene/screen_session_manager/src/screen_power_fsm/session_display_power_controller.cpp", | 93 | "${window_base_path}/window_scene/screen_session_manager/src/screen_power_fsm/session_display_power_controller.cpp", |