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