• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "sensor_agent.h"
28 #include "window_manager_hilog.h"
29 
30 namespace OHOS {
31 namespace Rosen {
32 class ScreenSensorConnector : public RefBase {
33 public:
34     ScreenSensorConnector() = delete;
35     ~ScreenSensorConnector() = default;
36 
37     static void SubscribeRotationSensor();
38     static void UnsubscribeRotationSensor();
39 };
40 
41 #ifdef WM_SUBSCRIBE_MOTION_ENABLE
42 using OHOS::Msdp::MotionCallbackStub;
43 using OHOS::Msdp::MotionEvent;
44 
45 class RotationMotionEventCallback : public MotionCallbackStub {
46 public:
47     void OnMotionChanged(const MotionEvent& motionData) override;
48 };
49 
50 class MotionSubscriber {
51 friend ScreenSensorConnector;
52 public:
53     MotionSubscriber() = delete;
54     ~MotionSubscriber() = default;
55 private:
56     static void SubscribeMotionSensor();
57     static void UnsubscribeMotionSensor();
58 
59     static sptr<RotationMotionEventCallback> motionEventCallback_;
60     static bool isMotionSensorSubscribed_;
61 };
62 #endif
63 } // Rosen
64 } // OHOS
65 #endif // OHOS_ROSEN_SCREEN_CONNECTOR_H
66