add rotation value init

Signed-off-by: xpeng <pengxin33@huawei.com>
Change-Id: I9a6582ad9ac2c3310d02d41f7cb4b21d44f13201
This commit is contained in:
xpeng
2022-07-11 19:21:14 +08:00
parent 8ed7aabca2
commit d65b50232f
3 changed files with 11 additions and 4 deletions
@@ -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);
+1
View File
@@ -585,6 +585,7 @@ void DisplayManagerService::SetGravitySensorSubscriptionEnabled()
{
if (!isAutoRotationOpen_) {
WLOGFE("autoRotation is not open");
ScreenRotationController::Init();
return;
}
ScreenRotationController::SubscribeGravitySensor();
+9 -4
View File
@@ -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_;