From 86ea84ad2674a1b902b4190934b78123da395e6a Mon Sep 17 00:00:00 2001 From: cloud_nine Date: Wed, 21 Feb 2024 14:42:09 +0800 Subject: [PATCH] =?UTF-8?q?Description:=E4=BF=AE=E5=A4=8D=E5=81=B6?= =?UTF-8?q?=E7=8E=B0=E6=97=8B=E8=BD=AC=E6=96=B9=E5=90=91=E5=81=8F=E5=B7=AE?= =?UTF-8?q?90=C2=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: chenyunjiu --- dmserver/src/screen_rotation_controller.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dmserver/src/screen_rotation_controller.cpp b/dmserver/src/screen_rotation_controller.cpp index 09db23add7..f2c8918a0d 100644 --- a/dmserver/src/screen_rotation_controller.cpp +++ b/dmserver/src/screen_rotation_controller.cpp @@ -19,6 +19,7 @@ #include #include "display_manager_service_inner.h" +#include "parameters.h" namespace OHOS { namespace Rosen { @@ -347,7 +348,20 @@ void ScreenRotationController::ProcessRotationMapping() DisplayManagerServiceInner::GetInstance().GetScreenModesByDisplayId(defaultDisplayId_); // 0 means PORTRAIT, 1 means LANDSCAPE. - defaultDeviceRotation_ = (modes == nullptr || modes->width_ < modes->height_) ? 0 : 1; + if (modes == nullptr) { + defaultDeviceRotation_ = 1; + WLOGFE("Get screen modes is nullptr."); + } else { + defaultDeviceRotation_ = (modes->width_ < modes->height_) ? 0 : 1; + WLOGFI("Get screen modes width: %{public}d, height: %{public}d", modes->width_, modes->height_); + } + if (OHOS::system::GetParameter("const.product.devicetype", "unknown") == "phone") { + WLOGFI("Current device type is phone, set defaultDeviceRotation is portrait"); + defaultDeviceRotation_ = 0; + } + WLOGFI("defaultDeviceRotation: %{public}u, defaultDisplayId: %{public}u", + defaultDeviceRotation_, static_cast(defaultDisplayId_)); + if (deviceToDisplayRotationMap_.empty()) { deviceToDisplayRotationMap_ = { {DeviceRotation::ROTATION_PORTRAIT, -- Gitee