• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 NAPI_STATE_REGISTRY_H
17 #define NAPI_STATE_REGISTRY_H
18 
19 #include <initializer_list>
20 #include <string>
21 #include <list>
22 
23 #include "base_context.h"
24 #include "event_listener.h"
25 #include "napi/native_api.h"
26 #include "napi/native_node_api.h"
27 #include "telephony_observer_broker.h"
28 #include "telephony_update_event_type.h"
29 #include "telephony_types.h"
30 
31 namespace OHOS {
32 namespace Telephony {
33 constexpr int32_t NONE_EVENT_TYPE = 0;
34 constexpr int32_t LISTEN_NET_WORK_STATE = TelephonyObserverBroker::OBSERVER_MASK_NETWORK_STATE;
35 constexpr int32_t LISTEN_CALL_STATE = TelephonyObserverBroker::OBSERVER_MASK_CALL_STATE;
36 constexpr int32_t LISTEN_CELL_INFO = TelephonyObserverBroker::OBSERVER_MASK_CELL_INFO;
37 constexpr int32_t LISTEN_SIGNAL_STRENGTHS = TelephonyObserverBroker::OBSERVER_MASK_SIGNAL_STRENGTHS;
38 constexpr int32_t LISTEN_SIM_STATE = TelephonyObserverBroker::OBSERVER_MASK_SIM_STATE;
39 constexpr int32_t LISTEN_DATA_CONNECTION_STATE = TelephonyObserverBroker::OBSERVER_MASK_DATA_CONNECTION_STATE;
40 constexpr int32_t LISTEN_CELLULAR_DATA_FLOW = TelephonyObserverBroker::OBSERVER_MASK_DATA_FLOW;
41 
42 enum class CallState : int32_t {
43     /**
44      * Indicates an invalid state, which is used when the call state fails to be
45      * obtained.
46      */
47     CALL_STATE_UNKNOWN = -1,
48 
49     /**
50      * Indicates that there is no ongoing call.
51      */
52     CALL_STATE_IDLE = 0,
53 
54     /**
55      * Indicates that an incoming call is ringing or waiting.
56      */
57     CALL_STATE_RINGING = 1,
58 
59     /**
60      * Indicates that a least one call is in the dialing, active, or hold state,
61      * and there is no new incoming call ringing or waiting.
62      */
63     CALL_STATE_OFFHOOK = 2
64 };
65 
66 struct ObserverContext : BaseContext {
67     int32_t slotId = DEFAULT_SIM_SLOT_ID;
68     TelephonyUpdateEventType eventType = TelephonyUpdateEventType::NONE_EVENT_TYPE;
69     int32_t errorCode = 0;
70     std::list<EventListener> removeListenerList;
71 };
72 } // namespace Telephony
73 } // namespace OHOS
74 #endif // NAPI_STATE_REGISTRY_H