• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H
17 #define OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H
18 
19 #include <deque>
20 #include <memory>
21 #include <mutex>
22 #include <sstream>
23 #include <functional>
24 #include <climits>
25 
26 #include "refbase.h"
27 #include "wm_single_instance.h"
28 #include "ws_common.h"
29 #include "sensor_agent.h"
30 #include "sensor_agent_type.h"
31 #include "session/screen/include/screen_property.h"
32 #include "dm_common.h"
33 
34 namespace OHOS {
35 
36 namespace Rosen {
37 
38 class SuperFoldSensorManager : public RefBase {
39 WM_DECLARE_SINGLE_INSTANCE_BASE(SuperFoldSensorManager);
40 
41 public:
42 
43     void RegisterPostureCallback(); //折叠角度注册回调
44 
45     void RegisterHallCallback(); // 磁吸键盘
46 
47     void UnregisterPostureCallback();
48 
49     void UnregisterHallCallback();
50 
51     void HandlePostureData(const SensorEvent * const event);
52 
53     void HandleHallData(const SensorEvent * const event);
54 
55     void HandleSuperSensorChange(SuperFoldStatusChangeEvents events);
56 
57     float GetCurAngle();
58 
59     void HandleScreenConnectChange();
60     void HandleScreenDisconnectChange();
61 
62 private:
63 
64     std::recursive_mutex mutex_;
65 
66     SensorUser postureUser {};
67 
68     SensorUser hallUser {};
69 
70     float curAngle_ = 170.0F;
71 
72     uint16_t curHall_ = USHRT_MAX;
73 
74     void NotifyFoldAngleChanged(float foldAngle);
75 
76     void NotifyHallChanged(uint16_t hall);
77 
78     void NotifySoftKeyboardChanged();
79 
80     SuperFoldSensorManager();
81 
82     ~SuperFoldSensorManager();
83 };
84 }
85 }
86 
87 #endif // OHOS_ROSEN_SUPER_FOLD_SENSOR_MANAGER_H