mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-21 04:25:28 -04:00
add display power interface
Signed-off-by: chenqinxin <chenqinxin1@huawei.com> Change-Id: I87574556ce30af234ffc70fa7bc1d7fb04f5538a
This commit is contained in:
@@ -39,11 +39,20 @@ public:
|
||||
sptr<Surface> surface);
|
||||
bool DestroyVirtualDisplay(DisplayId displayId);
|
||||
sptr<Media::PixelMap> GetDisplaySnapshot(DisplayId displayId);
|
||||
|
||||
bool SuspendBegin(PowerStateChangeReason reason);
|
||||
bool SetDisplayState(DisplayState state, DisplayStateCallback callback);
|
||||
DisplayState GetDisplayState(uint64_t displayId);
|
||||
void NotifyDisplayEvent(DisplayEvent event);
|
||||
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
DisplayManagerAdapter() = default;
|
||||
~DisplayManagerAdapter() = default;
|
||||
bool InitDMSProxyLocked();
|
||||
void NotifyDisplayChange(DisplayState state);
|
||||
|
||||
static inline SingletonDelegator<DisplayManagerAdapter> delegator;
|
||||
|
||||
std::mutex mutex_;
|
||||
@@ -51,6 +60,7 @@ private:
|
||||
sptr<DMSDeathRecipient> dmsDeath_ = nullptr;
|
||||
std::map<DisplayId, sptr<Display>> displayMap_;
|
||||
DisplayId defaultDisplayId_;
|
||||
DisplayStateCallback callback_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
#endif // FOUNDATION_DM_DISPLAY_MANAGER_ADAPTER_H
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
#include "display_manager.h"
|
||||
|
||||
#include <cinttypes>
|
||||
#include <transaction/rs_interfaces.h>
|
||||
|
||||
#include "display_manager_adapter.h"
|
||||
#include "dm_common.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
@@ -153,4 +155,86 @@ bool DisplayManager::DestroyVirtualDisplay(DisplayId displayId)
|
||||
WLOGFI("DisplayManager::DestroyVirtualDisplay override params");
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().DestroyVirtualDisplay(displayId);
|
||||
}
|
||||
|
||||
bool DisplayManager::WakeUpBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DisplayManager::WakeUpEnd()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DisplayManager::SuspendBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
// dms->wms notify other windows to hide
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SuspendBegin(reason);
|
||||
}
|
||||
|
||||
bool DisplayManager::SuspendEnd()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DisplayManager::SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason)
|
||||
{
|
||||
// TODO: should get all screen ids
|
||||
ScreenId defaultId = GetDefaultDisplayId();
|
||||
if (defaultId == DISPLAY_ID_INVALD) {
|
||||
return false;
|
||||
}
|
||||
WLOGFI("state:%{public}u, reason:%{public}u, defaultId:%{public}" PRIu64".", state, reason, defaultId);
|
||||
ScreenPowerStatus status;
|
||||
switch (state) {
|
||||
case DisplayPowerState::POWER_ON: {
|
||||
status = ScreenPowerStatus::POWER_STATUS_ON;
|
||||
break;
|
||||
}
|
||||
case DisplayPowerState::POWER_OFF: {
|
||||
status = ScreenPowerStatus::POWER_STATUS_OFF;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
WLOGFW("SetScreenPowerStatus state not support");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
RSInterfaces::GetInstance().SetScreenPowerStatus(defaultId, status);
|
||||
return true;
|
||||
}
|
||||
|
||||
DisplayPowerState DisplayManager::GetScreenPower(uint64_t screenId)
|
||||
{
|
||||
DisplayPowerState res = static_cast<DisplayPowerState>(RSInterfaces::GetInstance().GetScreenPowerStatus(screenId));
|
||||
WLOGFI("GetScreenPower:%{public}u, defaultId:%{public}" PRIu64".", res, screenId);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool DisplayManager::SetDisplayState(DisplayState state, DisplayStateCallback callback)
|
||||
{
|
||||
WLOGFI("state:%{public}u", state);
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().SetDisplayState(state, callback);
|
||||
}
|
||||
|
||||
DisplayState DisplayManager::GetDisplayState(uint64_t displayId)
|
||||
{
|
||||
return SingletonContainer::Get<DisplayManagerAdapter>().GetDisplayState(displayId);
|
||||
}
|
||||
|
||||
bool DisplayManager::SetScreenBrightness(uint64_t screenId, uint32_t level)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t DisplayManager::GetScreenBrightness(uint64_t screenId) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DisplayManager::NotifyDisplayEvent(DisplayEvent event)
|
||||
{
|
||||
// Unlock event dms->wms restore other hidden windows
|
||||
SingletonContainer::Get<DisplayManagerAdapter>().NotifyDisplayEvent(event);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -97,6 +97,57 @@ bool DisplayManagerAdapter::DestroyVirtualDisplay(DisplayId displayId)
|
||||
return displayManagerServiceProxy_->DestroyVirtualDisplay(displayId);
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::SuspendBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
return displayManagerServiceProxy_->SuspendBegin(reason);
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::SetDisplayState(DisplayState state, DisplayStateCallback callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return false;
|
||||
}
|
||||
callback_ = callback;
|
||||
bool ret = displayManagerServiceProxy_->SetDisplayState(state);
|
||||
if (state == DisplayState::OFF) {
|
||||
NotifyDisplayChange(state);
|
||||
}
|
||||
// TODO: NotifyDisplayChange ON when keyguard is drawn
|
||||
return ret;
|
||||
}
|
||||
|
||||
DisplayState DisplayManagerAdapter::GetDisplayState(uint64_t displayId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return DisplayState::UNKNOWN;
|
||||
}
|
||||
return displayManagerServiceProxy_->GetDisplayState(displayId);
|
||||
}
|
||||
|
||||
void DisplayManagerAdapter::NotifyDisplayEvent(DisplayEvent event)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (!InitDMSProxyLocked()) {
|
||||
return;
|
||||
}
|
||||
displayManagerServiceProxy_->NotifyDisplayEvent(event);
|
||||
}
|
||||
|
||||
void DisplayManagerAdapter::NotifyDisplayChange(DisplayState state)
|
||||
{
|
||||
if (callback_) {
|
||||
callback_(state);
|
||||
return;
|
||||
}
|
||||
WLOGFW("callback_ target is not set!");
|
||||
}
|
||||
|
||||
bool DisplayManagerAdapter::InitDMSProxyLocked()
|
||||
{
|
||||
WLOGFI("InitDMSProxy");
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <pixel_map.h>
|
||||
#include <surface.h>
|
||||
|
||||
#include "dm_common.h"
|
||||
#include "display_info.h"
|
||||
#include "virtual_display_info.h"
|
||||
|
||||
@@ -34,6 +35,10 @@ public:
|
||||
TRANS_ID_CREATE_VIRTUAL_DISPLAY,
|
||||
TRANS_ID_DESTROY_VIRTUAL_DISPLAY,
|
||||
TRANS_ID_GET_DISPLAY_SNAPSHOT,
|
||||
TRANS_ID_SUSPEND_BEGIN,
|
||||
TRANS_ID_SET_DISPLAY_STATE,
|
||||
TRANS_ID_GET_DISPLAY_STATE,
|
||||
TRANS_ID_NOTIFY_DISPLAY_EVENT,
|
||||
};
|
||||
|
||||
virtual DisplayId GetDefaultDisplayId() = 0;
|
||||
@@ -42,8 +47,12 @@ public:
|
||||
virtual DisplayId CreateVirtualDisplay(const VirtualDisplayInfo &virtualDisplayInfo,
|
||||
sptr<Surface> surface) = 0;
|
||||
virtual bool DestroyVirtualDisplay(DisplayId displayId) = 0;
|
||||
|
||||
virtual sptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) = 0;
|
||||
|
||||
virtual bool SuspendBegin(PowerStateChangeReason reason) = 0;
|
||||
virtual bool SetDisplayState(DisplayState state) = 0;
|
||||
virtual DisplayState GetDisplayState(uint64_t displayId) = 0;
|
||||
virtual void NotifyDisplayEvent(DisplayEvent event) = 0;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
||||
@@ -34,6 +34,12 @@ public:
|
||||
sptr<Surface> surface) override;
|
||||
bool DestroyVirtualDisplay(DisplayId displayId) override;
|
||||
sptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) override;
|
||||
|
||||
bool SuspendBegin(PowerStateChangeReason reason) override;
|
||||
bool SetDisplayState(DisplayState state) override;
|
||||
DisplayState GetDisplayState(uint64_t displayId) override;
|
||||
void NotifyDisplayEvent(DisplayEvent event) override;
|
||||
|
||||
private:
|
||||
static inline BrokerDelegator<DisplayManagerProxy> delegator_;
|
||||
};
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "abstract_display.h"
|
||||
#include "abstract_display_manager.h"
|
||||
#include "display_manager_stub.h"
|
||||
#include "display_power_controller.h"
|
||||
#include "single_instance.h"
|
||||
#include "singleton_delegator.h"
|
||||
|
||||
@@ -44,6 +45,12 @@ public:
|
||||
DisplayId GetDefaultDisplayId() override;
|
||||
DisplayInfo GetDisplayInfoById(DisplayId displayId) override;
|
||||
sptr<Media::PixelMap> GetDispalySnapshot(DisplayId displayId) override;
|
||||
|
||||
bool SuspendBegin(PowerStateChangeReason reason) override;
|
||||
bool SetDisplayState(DisplayState state) override;
|
||||
DisplayState GetDisplayState(uint64_t displayId) override;
|
||||
void NotifyDisplayEvent(DisplayEvent event) override;
|
||||
|
||||
private:
|
||||
DisplayManagerService();
|
||||
~DisplayManagerService() = default;
|
||||
@@ -53,6 +60,7 @@ private:
|
||||
|
||||
static inline SingletonDelegator<DisplayManagerService> delegator_;
|
||||
std::map<int32_t, sptr<AbstractDisplay>> abstractDisplayMap_;
|
||||
DisplayPowerController displayPowerController_;
|
||||
};
|
||||
} // namespace OHOS::Rosen
|
||||
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H
|
||||
#define OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H
|
||||
|
||||
#include <map>
|
||||
#include <mutex>
|
||||
#include "dm_common.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class DisplayPowerController {
|
||||
public:
|
||||
DisplayPowerController() = default;
|
||||
virtual ~DisplayPowerController() = default;
|
||||
|
||||
bool SuspendBegin(PowerStateChangeReason reason);
|
||||
bool SetDisplayState(DisplayState state);
|
||||
DisplayState GetDisplayState(uint64_t displayId);
|
||||
void NotifyDisplayEvent(DisplayEvent event);
|
||||
|
||||
private:
|
||||
std::recursive_mutex mutex_;
|
||||
DisplayState displayState_ { DisplayState::ON };
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // OHOS_ROSEN_DISPLAY_POWER_CONTROLLER_H
|
||||
@@ -168,4 +168,83 @@ sptr<Media::PixelMap> DisplayManagerProxy::GetDispalySnapshot(DisplayId displayI
|
||||
}
|
||||
return pixelMap;
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::SuspendBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(reason))) {
|
||||
WLOGFE("Write PowerStateChangeReason failed");
|
||||
return false;
|
||||
}
|
||||
if (Remote()->SendRequest(TRANS_ID_SUSPEND_BEGIN, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("SendRequest failed");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
bool DisplayManagerProxy::SetDisplayState(DisplayState state)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return false;
|
||||
}
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(state))) {
|
||||
WLOGFE("Write DisplayState failed");
|
||||
return false;
|
||||
}
|
||||
if (Remote()->SendRequest(TRANS_ID_SET_DISPLAY_STATE, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("SendRequest failed");
|
||||
return false;
|
||||
}
|
||||
return reply.ReadBool();
|
||||
}
|
||||
|
||||
DisplayState DisplayManagerProxy::GetDisplayState(uint64_t displayId)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return DisplayState::UNKNOWN;
|
||||
}
|
||||
if (!data.WriteUint64(static_cast<uint32_t>(displayId))) {
|
||||
WLOGFE("Write displayId failed");
|
||||
return DisplayState::UNKNOWN;
|
||||
}
|
||||
if (Remote()->SendRequest(TRANS_ID_GET_DISPLAY_STATE, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("SendRequest failed");
|
||||
return DisplayState::UNKNOWN;
|
||||
}
|
||||
return static_cast<DisplayState>(reply.ReadUint32());
|
||||
}
|
||||
|
||||
void DisplayManagerProxy::NotifyDisplayEvent(DisplayEvent event)
|
||||
{
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return;
|
||||
}
|
||||
if (!data.WriteUint32(static_cast<uint32_t>(event))) {
|
||||
WLOGFE("Write DisplayEvent failed");
|
||||
return;
|
||||
}
|
||||
if (Remote()->SendRequest(TRANS_ID_NOTIFY_DISPLAY_EVENT, data, reply, option) != ERR_NONE) {
|
||||
WLOGFW("SendRequest failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -112,4 +112,24 @@ void DisplayManagerService::OnStop()
|
||||
{
|
||||
WLOGFI("ready to stop display service.");
|
||||
}
|
||||
|
||||
bool DisplayManagerService::SuspendBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
return displayPowerController_.SuspendBegin(reason);
|
||||
}
|
||||
|
||||
bool DisplayManagerService::SetDisplayState(DisplayState state)
|
||||
{
|
||||
return displayPowerController_.SetDisplayState(state);
|
||||
}
|
||||
|
||||
DisplayState DisplayManagerService::GetDisplayState(uint64_t displayId)
|
||||
{
|
||||
return displayPowerController_.GetDisplayState(displayId);
|
||||
}
|
||||
|
||||
void DisplayManagerService::NotifyDisplayEvent(DisplayEvent event)
|
||||
{
|
||||
displayPowerController_.NotifyDisplayEvent(event);
|
||||
}
|
||||
} // namespace OHOS::Rosen
|
||||
@@ -64,13 +64,31 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
}
|
||||
case TRANS_ID_GET_DISPLAY_SNAPSHOT: {
|
||||
DisplayId displayId = data.ReadUint64();
|
||||
|
||||
sptr<Media::PixelMap> dispalySnapshot = GetDispalySnapshot(displayId);
|
||||
if (dispalySnapshot == nullptr) {
|
||||
reply.WriteParcelable(nullptr);
|
||||
break;
|
||||
}
|
||||
reply.WriteParcelable(dispalySnapshot.GetRefPtr());
|
||||
}
|
||||
case TRANS_ID_SUSPEND_BEGIN: {
|
||||
PowerStateChangeReason reason = static_cast<PowerStateChangeReason>(data.ReadUint32());
|
||||
reply.WriteBool(SuspendBegin(reason));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_SET_DISPLAY_STATE: {
|
||||
DisplayState state = static_cast<DisplayState>(data.ReadUint32());
|
||||
reply.WriteBool(SetDisplayState(state));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_GET_DISPLAY_STATE: {
|
||||
DisplayState state = GetDisplayState(data.ReadUint64());
|
||||
reply.WriteUint32(static_cast<uint32_t>(state));
|
||||
break;
|
||||
}
|
||||
case TRANS_ID_NOTIFY_DISPLAY_EVENT: {
|
||||
DisplayEvent event = static_cast<DisplayEvent>(data.ReadUint32());
|
||||
NotifyDisplayEvent(event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "display_power_controller.h"
|
||||
#include "window_manager_service_inner.h"
|
||||
#include "window_manager_hilog.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
namespace {
|
||||
constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "DisplayPowerController"};
|
||||
}
|
||||
|
||||
bool DisplayPowerController::SuspendBegin(PowerStateChangeReason reason)
|
||||
{
|
||||
WLOGFI("reason:%{public}u", reason);
|
||||
return WindowManagerServiceInner::GetInstance().NotifyDisplaySuspend();
|
||||
}
|
||||
|
||||
bool DisplayPowerController::SetDisplayState(DisplayState state)
|
||||
{
|
||||
WLOGFI("state:%{public}u", state);
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
if (displayState_ == state) {
|
||||
WLOGFI("state is already set");
|
||||
return true;
|
||||
}
|
||||
switch (state) {
|
||||
case DisplayState::ON: {
|
||||
// TODO: open vsync and SendSystemEvent to keyguard
|
||||
break;
|
||||
}
|
||||
case DisplayState::OFF: {
|
||||
// TODO: SendSystemEvent to keyguard
|
||||
displayState_ = state;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WLOGFW("unknown DisplayState!");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
DisplayState DisplayPowerController::GetDisplayState(uint64_t displayId)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
return displayState_;
|
||||
}
|
||||
|
||||
void DisplayPowerController::NotifyDisplayEvent(DisplayEvent event)
|
||||
{
|
||||
if (event == DisplayEvent::UNLOCK) {
|
||||
WLOGFI("DisplayEvent UNLOCK");
|
||||
WindowManagerServiceInner::GetInstance().RestoreSuspendedWindows();
|
||||
return;
|
||||
}
|
||||
// TODO: set displayState_ ON when keyguard is drawn
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@
|
||||
#include <surface.h>
|
||||
|
||||
#include "display.h"
|
||||
#include "dm_common.h"
|
||||
#include "single_instance.h"
|
||||
#include "virtual_display_info.h"
|
||||
// #include "wm_common.h"
|
||||
@@ -49,6 +50,18 @@ public:
|
||||
sptr<Media::PixelMap> GetScreenshot(DisplayId displayId, const Media::Rect &rect,
|
||||
const Media::Size &size, int rotation);
|
||||
|
||||
bool WakeUpBegin(PowerStateChangeReason reason);
|
||||
bool WakeUpEnd();
|
||||
bool SuspendBegin(PowerStateChangeReason reason);
|
||||
bool SuspendEnd();
|
||||
bool SetScreenPowerForAll(DisplayPowerState state, PowerStateChangeReason reason);
|
||||
DisplayPowerState GetScreenPower(uint64_t screenId);
|
||||
bool SetDisplayState(DisplayState state, DisplayStateCallback callback);
|
||||
DisplayState GetDisplayState(uint64_t displayId);
|
||||
bool SetScreenBrightness(uint64_t screenId, uint32_t level);
|
||||
uint32_t GetScreenBrightness(uint64_t screenId) const;
|
||||
void NotifyDisplayEvent(DisplayEvent event);
|
||||
|
||||
private:
|
||||
bool CheckRectOffsetValid(int32_t param) const;
|
||||
bool CheckRectSizeValid(int32_t param) const;
|
||||
|
||||
@@ -16,11 +16,32 @@
|
||||
#ifndef OHOS_ROSEN_DM_COMMON_H
|
||||
#define OHOS_ROSEN_DM_COMMON_H
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
constexpr int32_t INVALID_DISPLAY_ID = -1;
|
||||
enum class PowerStateChangeReason : uint32_t {
|
||||
POWER_BUTTON
|
||||
};
|
||||
|
||||
enum class DisplayPowerState : uint32_t {
|
||||
POWER_ON,
|
||||
POWER_STAND_BY,
|
||||
POWER_SUSPEND,
|
||||
POWER_OFF,
|
||||
POWER_BUTT,
|
||||
INVALID_STATE,
|
||||
};
|
||||
|
||||
enum class DisplayState : uint32_t {
|
||||
ON,
|
||||
OFF,
|
||||
UNKNOWN
|
||||
};
|
||||
|
||||
enum class DisplayEvent : uint32_t {
|
||||
UNLOCK
|
||||
};
|
||||
using DisplayStateCallback = std::function<void(DisplayState)>;
|
||||
}
|
||||
}
|
||||
#endif // OHOS_ROSEN_DM_COMMON_H
|
||||
#endif // OHOS_ROSEN_DM_COMMON_H
|
||||
@@ -52,6 +52,7 @@ config("libwm_public_config") {
|
||||
include_dirs = [
|
||||
"//foundation/windowmanager/interfaces/innerkits/wm",
|
||||
"//foundation/windowmanager/wmserver/include",
|
||||
"//foundation/windowmanager/dm/include",
|
||||
"//foundation/windowmanager/dmserver/include",
|
||||
"//foundation/windowmanager/utils/include",
|
||||
"../interfaces/innerkits/dm",
|
||||
|
||||
@@ -554,8 +554,7 @@ void WindowImpl::UpdateConfiguration(const std::shared_ptr<AppExecFwk::Configura
|
||||
{
|
||||
if (uiContent_ != nullptr) {
|
||||
WLOGFD("notify ace winId:%{public}d", GetWindowId());
|
||||
// TODO: fix me
|
||||
// uiContent_->UpdateConfiguration(configuration);
|
||||
uiContent_->UpdateConfiguration(configuration);
|
||||
}
|
||||
if (subWindowMap_.count(GetWindowId()) == 0) {
|
||||
return;
|
||||
|
||||
@@ -37,12 +37,14 @@ ohos_shared_library("libwms") {
|
||||
"../dmserver/src/display_manager_service_inner.cpp",
|
||||
"../dmserver/src/display_manager_stub.cpp",
|
||||
"../dmserver/src/display_node_control.cpp",
|
||||
"../dmserver/src/display_power_controller.cpp",
|
||||
"../dmserver/src/screen.cpp",
|
||||
"../wm/src/zidl/window_manager_agent_proxy.cpp",
|
||||
"src/input_window_monitor.cpp",
|
||||
"src/window_controller.cpp",
|
||||
"src/window_layout_policy.cpp",
|
||||
"src/window_manager_service.cpp",
|
||||
"src/window_manager_service_inner.cpp",
|
||||
"src/window_manager_stub.cpp",
|
||||
"src/window_node.cpp",
|
||||
"src/window_node_container.cpp",
|
||||
|
||||
@@ -56,6 +56,10 @@ public:
|
||||
void RegisterFocusChangedListener(const sptr<IWindowManagerAgent>& windowManagerAgent) override;
|
||||
void UnregisterFocusChangedListener(const sptr<IWindowManagerAgent>& windowManagerAgent) override;
|
||||
|
||||
// Inner interfaces
|
||||
WMError NotifyDisplaySuspend();
|
||||
void RestoreSuspendedWindows();
|
||||
|
||||
protected:
|
||||
WindowManagerService();
|
||||
virtual ~WindowManagerService() = default;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef OHOS_WINDOW_MANAGER_SERVICE_INNER_H
|
||||
#define OHOS_WINDOW_MANAGER_SERVICE_INNER_H
|
||||
|
||||
#include "single_instance.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
class WindowManagerServiceInner {
|
||||
DECLARE_SINGLE_INSTANCE(WindowManagerServiceInner)
|
||||
public:
|
||||
bool NotifyDisplaySuspend();
|
||||
void RestoreSuspendedWindows();
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif // OHOS_WINDOW_MANAGER_SERVICE_INNER_H
|
||||
@@ -55,6 +55,10 @@ void WindowLayoutPolicy::LayoutWindowNode(sptr<WindowNode>& node)
|
||||
return;
|
||||
}
|
||||
if (node->parent_ != nullptr) { // isn't root node
|
||||
if (!node->currentVisibility_) {
|
||||
WLOGFI("window[%{public}d] currently not visible, no need layout", node->GetWindowId());
|
||||
return;
|
||||
}
|
||||
UpdateLayoutRect(node);
|
||||
if (avoidTypes_.find(node->GetWindowType()) != avoidTypes_.end()) {
|
||||
RecordAvoidRect(node);
|
||||
|
||||
@@ -224,5 +224,20 @@ void WindowManagerService::OnWindowEvent(Event event, uint32_t windowId)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
WMError WindowManagerService::NotifyDisplaySuspend()
|
||||
{
|
||||
WLOGFI("NotifyDisplaySuspend");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
// TODO: notify windows covered by keyguard window to hide
|
||||
return WMError::WM_OK;
|
||||
}
|
||||
|
||||
void WindowManagerService::RestoreSuspendedWindows()
|
||||
{
|
||||
WLOGFI("RestoreSuspendedWindows");
|
||||
std::lock_guard<std::recursive_mutex> lock(mutex_);
|
||||
// TODO: restore windows covered by keyguard
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "window_manager_service_inner.h"
|
||||
#include "window_manager_service.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace Rosen {
|
||||
|
||||
bool WindowManagerServiceInner::NotifyDisplaySuspend()
|
||||
{
|
||||
WMError ret = WindowManagerService::GetInstance().NotifyDisplaySuspend();
|
||||
return ret == WMError::WM_OK;
|
||||
}
|
||||
void WindowManagerServiceInner::RestoreSuspendedWindows()
|
||||
{
|
||||
WindowManagerService::GetInstance().RestoreSuspendedWindows();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user