!10451 修复竖屏展开误旋转到横屏

Merge pull request !10451 from wyk99/master
This commit is contained in:
openharmony_ci 2024-11-05 01:28:35 +00:00 committed by Gitee
commit 2ee13cd5f0
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 30 additions and 2 deletions

View File

@ -5379,7 +5379,7 @@ void ScreenSessionManager::ScbStatusRecoveryWhenSwitchUser(std::vector<int32_t>
TLOGE(WmsLogTag::DMS, "unsupport foldStatus: %{public}u", foldStatus);
}
} else {
screenSession->UpdateRotationAfterBoot(true);
screenSession->UpdateValidRotationToScb();
}
auto task = [=] {
clientProxy_->SwitchUserCallback(oldScbPids, newScbPid);

View File

@ -233,6 +233,7 @@ public:
bool UpdateAvailableArea(DMRect area);
void SetFoldScreen(bool isFold);
void UpdateRotationAfterBoot(bool foldToExpand);
void UpdateValidRotationToScb();
std::shared_ptr<Media::PixelMap> GetScreenSnapshot(float scaleX, float scaleY);
void SetDefaultDeviceRotationOffset(uint32_t defaultRotationOffset);
@ -258,6 +259,7 @@ private:
std::function<void(float, float)> updateScreenPivotCallback_ = nullptr;
bool isFold_ = false;
float currentSensorRotation_ { -1.0f };
float currentValidSensorRotation_ { -1.0f };
std::vector<uint32_t> hdrFormats_;
std::vector<uint32_t> colorSpaces_;
MirrorScreenType mirrorScreenType_ { MirrorScreenType::VIRTUAL_MIRROR };

View File

@ -480,8 +480,9 @@ void ScreenSession::SensorRotationChange(Rotation sensorRotation)
void ScreenSession::SensorRotationChange(float sensorRotation)
{
if (sensorRotation >= 0.0f) {
currentSensorRotation_ = sensorRotation;
currentValidSensorRotation_ = sensorRotation;
}
currentSensorRotation_ = sensorRotation;
for (auto& listener : screenChangeListenerList_) {
listener->OnSensorRotationChange(sensorRotation, screenId_);
}
@ -677,6 +678,12 @@ void ScreenSession::UpdateRotationAfterBoot(bool foldToExpand)
}
}
void ScreenSession::UpdateValidRotationToScb()
{
TLOGI(WmsLogTag::DMS, "Rotation: %{public}f", currentValidSensorRotation_);
SensorRotationChange(currentValidSensorRotation_);
}
sptr<SupportedScreenModes> ScreenSession::GetActiveScreenMode() const
{
if (activeIdx_ < 0 || activeIdx_ >= static_cast<int32_t>(modes_.size())) {

View File

@ -497,6 +497,25 @@ HWTEST_F(ScreenSessionTest, UpdateRotationAfterBoot02, Function | SmallTest | Le
GTEST_LOG_(INFO) << "UpdateRotationAfterBoot end";
}
/**
* @tc.name: UpdateValidRotationToScb
* @tc.desc: normal function
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionTest, UpdateValidRotationToScb, Function | SmallTest | Level2)
{
GTEST_LOG_(INFO) << "UpdateValidRotationToScb start";
ScreenSessionConfig config = {
.screenId = 100,
.rsId = 101,
.name = "OpenHarmony",
};
sptr<ScreenSession> screenSession = new ScreenSession(config, ScreenSessionReason::CREATE_SESSION_FOR_VIRTUAL);
EXPECT_NE(nullptr, screenSession);
screenSession->UpdateValidRotationToScb();
GTEST_LOG_(INFO) << "UpdateValidRotationToScb end";
}
/**
* @tc.name: SetScreenSceneDpiChangeListener
* @tc.desc: normal function