From 2c701472fbe6f146ee2bfd69246df79bd699e2e9 Mon Sep 17 00:00:00 2001 From: xpeng Date: Fri, 5 Aug 2022 11:25:48 +0800 Subject: [PATCH] add constraints for map Signed-off-by: xpeng Change-Id: Ib4cb5015022812e99726b8939b144aeedde8cb9b --- dmserver/src/screen_rotation_controller.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dmserver/src/screen_rotation_controller.cpp b/dmserver/src/screen_rotation_controller.cpp index 03d68c40..c6dc1f4c 100644 --- a/dmserver/src/screen_rotation_controller.cpp +++ b/dmserver/src/screen_rotation_controller.cpp @@ -413,6 +413,9 @@ SensorRotation ScreenRotationController::CalcSensorRotation(int sensorDegree) DeviceRotation ScreenRotationController::ConvertSensorToDeviceRotation(SensorRotation sensorRotation) { + if (sensorToDeviceRotationMap_.empty()) { + ProcessRotationMapping(); + } return sensorToDeviceRotationMap_.at(sensorRotation); } @@ -421,6 +424,9 @@ Rotation ScreenRotationController::ConvertDeviceToDisplayRotation(DeviceRotation if (deviceRotation == DeviceRotation::INVALID) { return GetCurrentDisplayRotation(); } + if (deviceToDisplayRotationMap_.empty()) { + ProcessRotationMapping(); + } return deviceToDisplayRotationMap_.at(deviceRotation); }