mirror of
https://gitee.com/openharmony/window_window_manager
synced 2024-11-23 15:00:12 +00:00
!10605 fix sensor bug and enable sensor
Merge pull request !10605 from HUMBLE./master
This commit is contained in:
commit
934382fd0c
@ -52,15 +52,11 @@ public:
|
||||
|
||||
void HandleHallData(const SensorEvent * const event);
|
||||
|
||||
void HandleSuperSensorChange();
|
||||
|
||||
void SetHasKeyboard(bool flag);
|
||||
void HandleSuperSensorChange(SuperFoldStatusChangeEvents events);
|
||||
|
||||
private:
|
||||
|
||||
std::recursive_mutex mutex_;
|
||||
|
||||
SuperFoldStatusChangeEvents events_ = SuperFoldStatusChangeEvents::UNDEFINED;
|
||||
|
||||
SensorUser postureUser {};
|
||||
|
||||
|
@ -32,6 +32,7 @@ namespace {
|
||||
constexpr float ANGLE_MIN_VAL = 30.0F;
|
||||
constexpr float ANGLE_MAX_VAL = 180.0F;
|
||||
constexpr float ANGLE_FLAT_THRESHOLD = 150.0F;
|
||||
constexpr float ANGLE_SENSOR_THRESHOLD = 177.0F;
|
||||
constexpr float ANGLE_HALF_FOLD_THRESHOLD = 135.0F;
|
||||
constexpr uint16_t HALL_HAVE_KEYBOARD_THRESHOLD = 0B0100;
|
||||
constexpr uint16_t HALL_REMOVE_KEYBOARD_THRESHOLD = 0B0000;
|
||||
@ -128,22 +129,23 @@ void SuperFoldSensorManager::HandlePostureData(const SensorEvent * const event)
|
||||
TLOGI(WmsLogTag::DMS, "Invalid value, angle value is: %{public}f.", curAngle_);
|
||||
return;
|
||||
}
|
||||
TLOGI(WmsLogTag::DMS, "angle value is: %{public}f.", curAngle_);
|
||||
TLOGD(WmsLogTag::DMS, "angle value is: %{public}f.", curAngle_);
|
||||
NotifyFoldAngleChanged(curAngle_);
|
||||
}
|
||||
|
||||
void SuperFoldSensorManager::NotifyFoldAngleChanged(float foldAngle)
|
||||
{
|
||||
SuperFoldStatusChangeEvents events;
|
||||
if (std::isgreaterequal(foldAngle, ANGLE_FLAT_THRESHOLD)) {
|
||||
TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is Expanded");
|
||||
events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED;
|
||||
events = SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED;
|
||||
} else if (std::isless(foldAngle, ANGLE_HALF_FOLD_THRESHOLD) &&
|
||||
std::isgreater(foldAngle, ANGLE_MIN_VAL)) {
|
||||
TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is Half Folded");
|
||||
events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED;
|
||||
events = SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED;
|
||||
} else if (std::islessequal(foldAngle, ANGLE_MIN_VAL)) {
|
||||
TLOGI(WmsLogTag::DMS, "NotifyFoldAngleChanged is Folded");
|
||||
events_ = SuperFoldStatusChangeEvents::ANGLE_CHANGE_FOLDED;
|
||||
events = SuperFoldStatusChangeEvents::ANGLE_CHANGE_FOLDED;
|
||||
} else {
|
||||
TLOGI(WmsLogTag::DMS, "Angle Don't Change!");
|
||||
return;
|
||||
@ -152,7 +154,7 @@ void SuperFoldSensorManager::NotifyFoldAngleChanged(float foldAngle)
|
||||
std::vector<float> foldAngles;
|
||||
foldAngles.push_back(foldAngle);
|
||||
ScreenSessionManager::GetInstance().NotifyFoldAngleChanged(foldAngles);
|
||||
HandleSuperSensorChange();
|
||||
HandleSuperSensorChange(events);
|
||||
}
|
||||
|
||||
void SuperFoldSensorManager::HandleHallData(const SensorEvent * const event)
|
||||
@ -184,24 +186,29 @@ void SuperFoldSensorManager::HandleHallData(const SensorEvent * const event)
|
||||
|
||||
void SuperFoldSensorManager::NotifyHallChanged(uint16_t Hall)
|
||||
{
|
||||
SuperFoldStatusChangeEvents events;
|
||||
if (Hall == HALL_REMOVE_KEYBOARD_THRESHOLD) {
|
||||
TLOGI(WmsLogTag::DMS, "NotifyHallChanged: Keyboard off!");
|
||||
events_ = SuperFoldStatusChangeEvents::KEYBOARD_OFF;
|
||||
events = SuperFoldStatusChangeEvents::KEYBOARD_OFF;
|
||||
} else if (Hall == HALL_HAVE_KEYBOARD_THRESHOLD) {
|
||||
TLOGI(WmsLogTag::DMS, "NotifyHallChanged: Keyboard on!");
|
||||
events_ = SuperFoldStatusChangeEvents::KEYBOARD_ON;
|
||||
events = SuperFoldStatusChangeEvents::KEYBOARD_ON;
|
||||
HandleSuperSensorChange(SuperFoldStatusChangeEvents::ANGLE_CHANGE_HALF_FOLDED);
|
||||
} else {
|
||||
TLOGI(WmsLogTag::DMS, "NotifyHallChanged: Invalid Hall Value!");
|
||||
return;
|
||||
}
|
||||
// notify
|
||||
HandleSuperSensorChange();
|
||||
HandleSuperSensorChange(events);
|
||||
if (std::isgreater(curAngle_, ANGLE_SENSOR_THRESHOLD)) {
|
||||
HandleSuperSensorChange(SuperFoldStatusChangeEvents::ANGLE_CHANGE_EXPANDED);
|
||||
}
|
||||
}
|
||||
|
||||
void SuperFoldSensorManager::HandleSuperSensorChange()
|
||||
void SuperFoldSensorManager::HandleSuperSensorChange(SuperFoldStatusChangeEvents events)
|
||||
{
|
||||
// trigger events
|
||||
SuperFoldStateManager::GetInstance().HandleSuperFoldStatusChange(events_);
|
||||
SuperFoldStateManager::GetInstance().HandleSuperFoldStatusChange(events);
|
||||
}
|
||||
|
||||
SuperFoldSensorManager::SuperFoldSensorManager() {}
|
||||
|
@ -41,11 +41,13 @@ void SuperFoldStateManager::DoAngleChangeExpanded(SuperFoldStatusChangeEvents ev
|
||||
|
||||
void SuperFoldStateManager::DoKeyboardOn(SuperFoldStatusChangeEvents event)
|
||||
{
|
||||
ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(true);
|
||||
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOn()");
|
||||
}
|
||||
|
||||
void SuperFoldStateManager::DoKeyboardOff(SuperFoldStatusChangeEvents event)
|
||||
{
|
||||
ScreenSessionManager::GetInstance().NotifyScreenMagneticStateChanged(false);
|
||||
TLOGI(WmsLogTag::DMS, "SuperFoldStateManager::DoKeyboardOff()");
|
||||
}
|
||||
|
||||
@ -153,7 +155,7 @@ void SuperFoldStateManager::HandleSuperFoldStatusChange(SuperFoldStatusChangeEve
|
||||
return;
|
||||
}
|
||||
ScreenId screenId = screenSession->GetScreenId();
|
||||
ScreenSessionManager::GetInstance().OnSuperFoldStatusChange(screenId, curState_);
|
||||
ScreenSessionManager::GetInstance().OnSuperFoldStatusChange(screenId, curState_.load());
|
||||
ScreenSessionManager::GetInstance().NotifyFoldStatusChanged(
|
||||
MatchSuperFoldStatusToFoldStatus(curState_.load()));
|
||||
}
|
||||
|
@ -56,6 +56,8 @@
|
||||
#include "publish/screen_session_publish.h"
|
||||
#include "dms_xcollie.h"
|
||||
#include "screen_sensor_plugin.h"
|
||||
#include "fold_screen_controller/super_fold_sensor_manager.h"
|
||||
#include "fold_screen_controller/super_fold_state_manager.h"
|
||||
|
||||
namespace OHOS::Rosen {
|
||||
namespace {
|
||||
@ -325,6 +327,11 @@ void ScreenSessionManager::Init()
|
||||
SetSensorSubscriptionEnabled();
|
||||
screenEventTracker_.RecordEvent("Dms subscribed to sensor successfully.");
|
||||
}
|
||||
|
||||
if (FoldScreenStateInternel::IsSuperFoldDisplayDevice()) {
|
||||
SuperFoldSensorManager::GetInstance().RegisterPostureCallback();
|
||||
SuperFoldSensorManager::GetInstance().RegisterHallCallback();
|
||||
}
|
||||
// publish init
|
||||
ScreenSessionPublish::GetInstance().InitPublishEvents();
|
||||
screenEventTracker_.RecordEvent("Dms init end.");
|
||||
|
Loading…
Reference in New Issue
Block a user