diff --git a/dmserver/src/screen_rotation_controller.cpp b/dmserver/src/screen_rotation_controller.cpp index 129bf75fed57d36c31927bcb1d751e405b173d49..2f4474b0e4c229964fb1ff3059be7612a093f911 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,