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