!2215 【Bugfix】修复sensor场景下Orientation切换现场还原问题

Merge pull request !2215 from X PN/bugfix-orientation
This commit is contained in:
openharmony_ci 2023-02-02 12:51:12 +00:00 committed by Gitee
commit e2c847682f
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -55,10 +55,18 @@ bool ScreenRotationController::IsScreenRotationLocked()
void ScreenRotationController::SetScreenRotationLocked(bool isLocked)
{
isScreenRotationLocked_ = isLocked;
if (isLocked) {
rotationLockedRotation_ = GetCurrentDisplayRotation();
return;
}
if (GetCurrentDisplayRotation() == ConvertDeviceToDisplayRotation(lastSensorRotationConverted_)) {
return;
}
Orientation currentOrientation = GetPreferredOrientation();
if (IsSensorRelatedOrientation(currentOrientation)) {
ProcessSwitchToSensorRelatedOrientation(currentOrientation, lastSensorRotationConverted_);
}
isScreenRotationLocked_ = isLocked;
}
void ScreenRotationController::SetDefaultDeviceRotationOffset(uint32_t defaultDeviceRotationOffset)
@ -257,16 +265,14 @@ void ScreenRotationController::ProcessSwitchToSensorRelatedOrientation(
void ScreenRotationController::ProcessSwitchToAutoRotation(DeviceRotation rotation)
{
if (rotation != DeviceRotation::INVALID) {
return;
SetScreenRotation(ConvertDeviceToDisplayRotation(rotation));
}
}
void ScreenRotationController::ProcessSwitchToAutoRotationPortrait(DeviceRotation rotation)
{
if (IsCurrentDisplayVertical()) {
return;
}
if (IsDeviceRotationVertical(rotation)) {
SetScreenRotation(ConvertDeviceToDisplayRotation(rotation));
return;
}
SetScreenRotation(ConvertDeviceToDisplayRotation(DeviceRotation::ROTATION_PORTRAIT));
@ -274,10 +280,8 @@ void ScreenRotationController::ProcessSwitchToAutoRotationPortrait(DeviceRotatio
void ScreenRotationController::ProcessSwitchToAutoRotationLandscape(DeviceRotation rotation)
{
if (IsCurrentDisplayHorizontal()) {
return;
}
if (IsDeviceRotationHorizontal(rotation)) {
SetScreenRotation(ConvertDeviceToDisplayRotation(rotation));
return;
}
SetScreenRotation(ConvertDeviceToDisplayRotation(DeviceRotation::ROTATION_LANDSCAPE));