mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 23:10:54 +00:00
Description:修改screen.isScreenRotationLocked接口查询锁定开关状态不对
IssueNo:https://gitee.com/openharmony/drivers_hdf_core/issues/IA594T Feature or Bugfix:Bugfix Binary Source:No Signed-off-by: wyk99 <wangyuekai1@huawei.com>
This commit is contained in:
parent
8a1fc4ff46
commit
5790a1574d
@ -120,6 +120,7 @@ public:
|
||||
virtual DMError GetDensityInCurResolution(ScreenId screenId, float& virtualPixelRatio);
|
||||
virtual DMError ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height);
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked);
|
||||
virtual DMError SetScreenRotationLockedFromJs(bool isLocked);
|
||||
virtual DMError IsScreenRotationLocked(bool& isLocked);
|
||||
// colorspace, gamut
|
||||
virtual DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts);
|
||||
|
@ -256,6 +256,13 @@ DMError ScreenManagerAdapter::SetScreenRotationLocked(bool isLocked)
|
||||
return displayManagerServiceProxy_->SetScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
DMError ScreenManagerAdapter::SetScreenRotationLockedFromJs(bool isLocked)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
WLOGFI("DisplayManagerAdapter::SetScreenRotationLockedFromJs");
|
||||
return displayManagerServiceProxy_->SetScreenRotationLockedFromJs(isLocked);
|
||||
}
|
||||
|
||||
DMError ScreenManagerAdapter::IsScreenRotationLocked(bool& isLocked)
|
||||
{
|
||||
INIT_PROXY_CHECK_RETURN(DMError::DM_ERROR_INIT_DMS_PROXY_LOCKED);
|
||||
|
@ -599,6 +599,11 @@ DMError ScreenManager::SetScreenRotationLocked(bool isLocked)
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
DMError ScreenManager::SetScreenRotationLockedFromJs(bool isLocked)
|
||||
{
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().SetScreenRotationLockedFromJs(isLocked);
|
||||
}
|
||||
|
||||
DMError ScreenManager::IsScreenRotationLocked(bool& isLocked)
|
||||
{
|
||||
return SingletonContainer::Get<ScreenManagerAdapter>().IsScreenRotationLocked(isLocked);
|
||||
|
@ -88,6 +88,7 @@ public:
|
||||
TRANS_ID_SCREEN_SET_COLOR_SPACE,
|
||||
TRANS_ID_IS_SCREEN_ROTATION_LOCKED,
|
||||
TRANS_ID_SET_SCREEN_ROTATION_LOCKED,
|
||||
TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS,
|
||||
TRANS_ID_HAS_PRIVATE_WINDOW,
|
||||
TRANS_ID_GET_CUTOUT_INFO,
|
||||
TRANS_ID_HAS_IMMERSIVE_WINDOW,
|
||||
@ -158,6 +159,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked) = 0;
|
||||
virtual DMError SetScreenRotationLockedFromJs(bool isLocked) = 0;
|
||||
virtual DMError IsScreenRotationLocked(bool& isLocked) = 0;
|
||||
|
||||
// colorspace, gamut
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
DmErrorCode* errorCode = nullptr) override;
|
||||
DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
DMError SetScreenRotationLockedFromJs(bool isLocked) override;
|
||||
|
||||
// colorspace, gamut
|
||||
DMError GetScreenSupportedColorGamuts(ScreenId screenId, std::vector<ScreenColorGamut>& colorGamuts) override;
|
||||
|
@ -52,6 +52,7 @@ public:
|
||||
DMError SetVirtualScreenSurface(ScreenId screenId, sptr<IBufferProducer> surface) override;
|
||||
DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
DMError SetScreenRotationLockedFromJs(bool isLocked) override;
|
||||
|
||||
sptr<DisplayInfo> GetDefaultDisplayInfo() override;
|
||||
sptr<DisplayInfo> GetDisplayInfoById(DisplayId displayId) override;
|
||||
|
@ -1567,6 +1567,33 @@ DMError DisplayManagerProxy::SetScreenRotationLocked(bool isLocked)
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
DMError DisplayManagerProxy::SetScreenRotationLockedFromJs(bool isLocked)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("remote is null");
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteBool(isLocked)) {
|
||||
WLOGFE("write isLocked failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
DMError DisplayManagerProxy::ResizeVirtualScreen(ScreenId screenId, uint32_t width, uint32_t height)
|
||||
{
|
||||
WLOGFI("DisplayManagerProxy::ResizeVirtualScreen: ENTER");
|
||||
|
@ -771,6 +771,15 @@ DMError DisplayManagerService::SetScreenRotationLocked(bool isLocked)
|
||||
return ScreenRotationController::SetScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
DMError DisplayManagerService::SetScreenRotationLockedFromJs(bool isLocked)
|
||||
{
|
||||
if (!Permission::IsSystemCalling() && !Permission::IsStartByHdcd()) {
|
||||
WLOGFE("set screen rotation locked from js permission denied!");
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
return ScreenRotationController::SetScreenRotationLocked(isLocked);
|
||||
}
|
||||
|
||||
void DisplayManagerService::SetGravitySensorSubscriptionEnabled()
|
||||
{
|
||||
if (!isAutoRotationOpen_) {
|
||||
|
@ -355,6 +355,12 @@ int32_t DisplayManagerStub::OnRemoteRequest(uint32_t code, MessageParcel &data,
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS: {
|
||||
bool isLocked = static_cast<bool>(data.ReadBool());
|
||||
DMError ret = SetScreenRotationLockedFromJs(isLocked);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_HAS_PRIVATE_WINDOW: {
|
||||
DisplayId id = static_cast<DisplayId>(data.ReadUint64());
|
||||
bool hasPrivateWindow = false;
|
||||
|
@ -240,6 +240,14 @@ public:
|
||||
*/
|
||||
DMError SetScreenRotationLocked(bool isLocked);
|
||||
|
||||
/**
|
||||
* @brief Set screen rotation lock status from js.
|
||||
*
|
||||
* @param isLocked True means forbid to rotate screen, false means the opposite.
|
||||
* @return DM_OK means set success, others means set failed.
|
||||
*/
|
||||
DMError SetScreenRotationLockedFromJs(bool isLocked);
|
||||
|
||||
/**
|
||||
* @brief Get screen rotation lock status.
|
||||
*
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "interfaces/include/ws_common.h"
|
||||
#include "js_screen_utils.h"
|
||||
#include "window_manager_hilog.h"
|
||||
#include "singleton_container.h"
|
||||
#include "screen_manager.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
using namespace AbilityRuntime;
|
||||
@ -194,8 +196,24 @@ napi_value JsScreenSession::OnSetScreenRotationLocked(napi_env env, napi_callbac
|
||||
return NapiGetUndefined(env);
|
||||
}
|
||||
screenSession_->SetScreenRotationLockedFromJs(isLocked);
|
||||
NapiAsyncTask::CompleteCallback complete =
|
||||
[isLocked](napi_env env, NapiAsyncTask& task, int32_t status) {
|
||||
auto res = DM_JS_TO_ERROR_CODE_MAP.at(
|
||||
SingletonContainer::Get<ScreenManager>().SetScreenRotationLockedFromJs(isLocked));
|
||||
if (res == DmErrorCode::DM_OK) {
|
||||
task.Resolve(env, NapiGetUndefined(env));
|
||||
WLOGFI("OnSetScreenRotationLocked success");
|
||||
} else {
|
||||
task.Reject(env, CreateJsError(env, static_cast<int32_t>(res),
|
||||
"JsScreenSession::OnSetScreenRotationLocked failed."));
|
||||
WLOGFE("OnSetScreenRotationLocked failed");
|
||||
}
|
||||
};
|
||||
napi_value result = nullptr;
|
||||
NapiAsyncTask::Schedule("JsScreenSession::OnSetScreenRotationLocked",
|
||||
env, CreateAsyncTaskWithLastParam(env, nullptr, nullptr, std::move(complete), &result));
|
||||
WLOGFI("SetScreenRotationLocked %{public}u success.", static_cast<uint32_t>(isLocked));
|
||||
return NapiGetUndefined(env);
|
||||
return result;
|
||||
}
|
||||
|
||||
napi_value JsScreenSession::SetTouchEnabled(napi_env env, napi_callback_info info)
|
||||
|
@ -123,6 +123,7 @@ public:
|
||||
std::vector<ScreenColorGamut>& colorGamuts) override;
|
||||
DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
DMError SetScreenRotationLockedFromJs(bool isLocked) override;
|
||||
DMError SetOrientation(ScreenId screenId, Orientation orientation) override;
|
||||
bool SetRotation(ScreenId screenId, Rotation rotationAfter, bool isFromWindow);
|
||||
void SetSensorSubscriptionEnabled();
|
||||
|
@ -60,6 +60,7 @@ public:
|
||||
return nullptr;
|
||||
}
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked) override { return DMError::DM_OK; }
|
||||
virtual DMError SetScreenRotationLockedFromJs(bool isLocked) override { return DMError::DM_OK; }
|
||||
virtual DMError IsScreenRotationLocked(bool& isLocked) override { return DMError::DM_OK; }
|
||||
|
||||
// colorspace, gamut
|
||||
|
@ -109,6 +109,7 @@ public:
|
||||
|
||||
virtual DMError SetOrientation(ScreenId screenId, Orientation orientation) override;
|
||||
virtual DMError SetScreenRotationLocked(bool isLocked) override;
|
||||
virtual DMError SetScreenRotationLockedFromJs(bool isLocked) override;
|
||||
virtual DMError IsScreenRotationLocked(bool& isLocked) override;
|
||||
virtual sptr<CutoutInfo> GetCutoutInfo(DisplayId displayId) override;
|
||||
virtual DMError HasImmersiveWindow(bool& immersive) override;
|
||||
|
@ -1611,6 +1611,22 @@ DMError ScreenSessionManager::SetScreenRotationLocked(bool isLocked)
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
DMError ScreenSessionManager::SetScreenRotationLockedFromJs(bool isLocked)
|
||||
{
|
||||
if (!SessionPermission::IsSystemCalling() && !SessionPermission::IsStartByHdcd()) {
|
||||
TLOGE(WmsLogTag::DMS, "set screen rotation locked from js permission denied!");
|
||||
return DMError::DM_ERROR_NOT_SYSTEM_APP;
|
||||
}
|
||||
sptr<ScreenSession> screenSession = GetDefaultScreenSession();
|
||||
if (screenSession == nullptr) {
|
||||
TLOGE(WmsLogTag::DMS, "fail to get default screenSession");
|
||||
return DMError::DM_ERROR_INVALID_PARAM;
|
||||
}
|
||||
screenSession->SetScreenRotationLockedFromJs(isLocked);
|
||||
TLOGI(WmsLogTag::DMS, "isLocked: %{public}u", isLocked);
|
||||
return DMError::DM_OK;
|
||||
}
|
||||
|
||||
void ScreenSessionManager::UpdateScreenRotationProperty(ScreenId screenId, const RRect& bounds, float rotation)
|
||||
{
|
||||
sptr<ScreenSession> screenSession = GetScreenSession(screenId);
|
||||
|
@ -1634,6 +1634,33 @@ DMError OHOS::Rosen::ScreenSessionManagerProxy::SetScreenRotationLocked(bool isL
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
DMError OHOS::Rosen::ScreenSessionManagerProxy::SetScreenRotationLockedFromJs(bool isLocked)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
if (remote == nullptr) {
|
||||
WLOGFW("remote is null");
|
||||
return DMError::DM_ERROR_NULLPTR;
|
||||
}
|
||||
|
||||
MessageParcel data;
|
||||
MessageParcel reply;
|
||||
MessageOption option;
|
||||
if (!data.WriteInterfaceToken(GetDescriptor())) {
|
||||
WLOGFE("WriteInterfaceToken failed");
|
||||
return DMError::DM_ERROR_WRITE_INTERFACE_TOKEN_FAILED;
|
||||
}
|
||||
if (!data.WriteBool(isLocked)) {
|
||||
WLOGFE("write isLocked failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
if (remote->SendRequest(static_cast<uint32_t>(DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS),
|
||||
data, reply, option) != ERR_NONE) {
|
||||
WLOGFE("SendRequest failed");
|
||||
return DMError::DM_ERROR_IPC_FAILED;
|
||||
}
|
||||
return static_cast<DMError>(reply.ReadInt32());
|
||||
}
|
||||
|
||||
DMError OHOS::Rosen::ScreenSessionManagerProxy::IsScreenRotationLocked(bool& isLocked)
|
||||
{
|
||||
sptr<IRemoteObject> remote = Remote();
|
||||
|
@ -489,6 +489,12 @@ int32_t ScreenSessionManagerStub::OnRemoteRequest(uint32_t code, MessageParcel&
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_SET_SCREEN_ROTATION_LOCKED_FROM_JS: {
|
||||
bool isLocked = static_cast<bool>(data.ReadBool());
|
||||
DMError ret = SetScreenRotationLockedFromJs(isLocked);
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
break;
|
||||
}
|
||||
case DisplayManagerMessage::TRANS_ID_IS_SCREEN_ROTATION_LOCKED: {
|
||||
bool isLocked = false;
|
||||
DMError ret = IsScreenRotationLocked(isLocked);
|
||||
|
Loading…
Reference in New Issue
Block a user