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 DEVICE_EVENT_MONITOR_H 17 #define DEVICE_EVENT_MONITOR_H 18 19 #include "singleton.h" 20 21 #include "common_event_manager.h" 22 #include "common_event_support.h" 23 24 namespace OHOS { 25 namespace MMI { 26 enum StateType { 27 CALL_STATUS_ACTIVE = 0, 28 CALL_STATUS_HOLDING = 1, 29 CALL_STATUS_DIALING = 2, 30 CALL_STATUS_ALERTING = 3, 31 CALL_STATUS_INCOMING = 4, 32 CALL_STATUS_WAITING = 5, 33 CALL_STATUS_DISCONNECTED = 6, 34 CALL_STATUS_DISCONNECTING = 7, 35 CALL_STATUS_IDLE = 8, 36 CALL_STATUS_ANSWERED = 9 37 }; 38 39 class DeviceEventMonitor final { 40 DECLARE_DELAYED_SINGLETON(DeviceEventMonitor); 41 public: 42 DISALLOW_COPY_AND_MOVE(DeviceEventMonitor); 43 44 void InitCommonEventSubscriber(); 45 void SetCallState(const EventFwk::CommonEventData &eventData, int32_t callState); 46 int32_t GetCallState(); 47 void SetHasHandleRingMute(bool hasHandleRingMute); 48 bool GetHasHandleRingMute(); 49 private: 50 bool hasInit_ { false }; 51 int32_t callState_ { -1 }; 52 bool hasHandleRingMute_ { false }; 53 std::mutex stateMutex_; 54 std::mutex commonEventMutex_; 55 }; 56 #define DEVICE_MONITOR ::OHOS::DelayedSingleton<DeviceEventMonitor>::GetInstance() 57 } // namespace MMI 58 } // namespace OHOS 59 #endif // DEVICE_EVENT_MONITOR_H 60