1 /*
2  * Copyright (c) 2023 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_SCREEN_SENSOR_CONNECTOR_H
17 #define OHOS_ROSEN_SCREEN_SENSOR_CONNECTOR_H
18 
19 #include <map>
20 #include <refbase.h>
21 #include "dm_common.h"
22 #ifdef WM_SUBSCRIBE_MOTION_ENABLE
23 #include "motion_agent.h"
24 #include "motion_callback_stub.h"
25 #endif
26 #include "screen_rotation_property.h"
27 #include "screen_tent_property.h"
28 #ifdef SENSOR_ENABLE
29 #include "sensor_agent.h"
30 #endif
31 #include "window_manager_hilog.h"
32 
33 namespace OHOS {
34 namespace Rosen {
35 class ScreenSensorConnector : public RefBase {
36 public:
37     ScreenSensorConnector() = delete;
38     ~ScreenSensorConnector() = default;
39 
40     static void SubscribeRotationSensor();
41     static void UnsubscribeRotationSensor();
42     static void SubscribeTentSensor();
43     static void UnsubscribeTentSensor();
44 };
45 
46 #ifdef WM_SUBSCRIBE_MOTION_ENABLE
47 using OHOS::Msdp::MotionCallbackStub;
48 using OHOS::Msdp::MotionEvent;
49 
50 class RotationMotionEventCallback : public MotionCallbackStub {
51 public:
52     void OnMotionChanged(const MotionEvent& motionData) override;
53 };
54 
55 class TentMotionEventCallback : public MotionCallbackStub {
56 public:
57     void OnMotionChanged(const MotionEvent& motionData) override;
58 };
59 
60 class MotionSubscriber {
61 friend ScreenSensorConnector;
62 public:
63     MotionSubscriber() = delete;
64     ~MotionSubscriber() = default;
65 private:
66     static void SubscribeMotionSensor();
67     static void UnsubscribeMotionSensor();
68 
69     static sptr<RotationMotionEventCallback> motionEventCallback_;
70     static bool isMotionSensorSubscribed_;
71 };
72 
73 class MotionTentSubscriber {
74 friend ScreenSensorConnector;
75 public:
76     MotionTentSubscriber() = delete;
77     ~MotionTentSubscriber() = default;
78 private:
79     static void SubscribeMotionSensor();
80     static void UnsubscribeMotionSensor();
81 
82     static sptr<TentMotionEventCallback> motionEventCallback_;
83     static bool isMotionSensorSubscribed_;
84 };
85 #endif
86 } // Rosen
87 } // OHOS
88 #endif // OHOS_ROSEN_SCREEN_CONNECTOR_H
89