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