mirror of
https://github.com/openharmony/windowmanager.git
synced 2026-07-19 17:08:11 -04:00
add rotation value init
Signed-off-by: xpeng <pengxin33@huawei.com> Change-Id: I9a6582ad9ac2c3310d02d41f7cb4b21d44f13201
This commit is contained in:
@@ -48,6 +48,7 @@ public:
|
||||
~ScreenRotationController() = default;
|
||||
static void SubscribeGravitySensor();
|
||||
static void UnsubscribeGravitySensor();
|
||||
static void Init();
|
||||
static bool IsScreenRotationLocked();
|
||||
static void SetScreenRotationLocked(bool isLocked);
|
||||
static void SetDefaultDeviceRotationOffset(uint32_t defaultDeviceRotationOffset);
|
||||
|
||||
@@ -585,6 +585,7 @@ void DisplayManagerService::SetGravitySensorSubscriptionEnabled()
|
||||
{
|
||||
if (!isAutoRotationOpen_) {
|
||||
WLOGFE("autoRotation is not open");
|
||||
ScreenRotationController::Init();
|
||||
return;
|
||||
}
|
||||
ScreenRotationController::SubscribeGravitySensor();
|
||||
|
||||
@@ -52,11 +52,11 @@ void ScreenRotationController::SubscribeGravitySensor()
|
||||
WLOGFE("dms: gravity sensor's already subscribed");
|
||||
return;
|
||||
}
|
||||
Init();
|
||||
if (strcpy_s(user_.name, sizeof(user_.name), "ScreenRotationController") != EOK) {
|
||||
WLOGFE("dms strcpy_s error");
|
||||
return;
|
||||
}
|
||||
ProcessRotationMapping();
|
||||
user_.userData = nullptr;
|
||||
user_.callback = &HandleGravitySensorEventCallback;
|
||||
if (SubscribeSensor(SENSOR_TYPE_ID_GRAVITY, &user_) != 0) {
|
||||
@@ -69,9 +69,6 @@ void ScreenRotationController::SubscribeGravitySensor()
|
||||
WLOGFE("dms: Activate gravity sensor failed");
|
||||
return;
|
||||
}
|
||||
currentDisplayRotation_ = GetCurrentDisplayRotation();
|
||||
lastSensorDecidedRotation_ = currentDisplayRotation_;
|
||||
rotationLockedRotation_ = currentDisplayRotation_;
|
||||
isGravitySensorSubscribed_ = true;
|
||||
}
|
||||
|
||||
@@ -93,6 +90,14 @@ void ScreenRotationController::UnsubscribeGravitySensor()
|
||||
isGravitySensorSubscribed_ = false;
|
||||
}
|
||||
|
||||
void ScreenRotationController::Init()
|
||||
{
|
||||
ProcessRotationMapping();
|
||||
currentDisplayRotation_ = GetCurrentDisplayRotation();
|
||||
lastSensorDecidedRotation_ = currentDisplayRotation_;
|
||||
rotationLockedRotation_ = currentDisplayRotation_;
|
||||
}
|
||||
|
||||
bool ScreenRotationController::IsScreenRotationLocked()
|
||||
{
|
||||
return isScreenRotationLocked_;
|
||||
|
||||
Reference in New Issue
Block a user