• 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 #include "enum_convert.h"
17 
18 #include "string"
19 
20 namespace OHOS {
21 namespace Telephony {
GetBoolValue(int32_t value)22 std::string GetBoolValue(int32_t value)
23 {
24     std::string result = "";
25     if (value == 0) {
26         result = "FALSE";
27     } else {
28         result = "TRUE";
29     }
30     return result;
31 }
32 
GetSimState(int32_t state)33 std::string GetSimState(int32_t state)
34 {
35     std::string result = "";
36     switch (static_cast<TelephonySimState>(state)) {
37         case TelephonySimState::SIM_STATE_UNKNOWN:
38             result = "SIM_STATE_UNKNOWN";
39             break;
40         case TelephonySimState::SIM_STATE_NOT_PRESENT:
41             result = "SIM_STATE_NOT_PRESENT";
42             break;
43         case TelephonySimState::SIM_STATE_LOCKED:
44             result = "SIM_STATE_LOCKED";
45             break;
46         case TelephonySimState::SIM_STATE_NOT_READY:
47             result = "SIM_STATE_NOT_READY";
48             break;
49         case TelephonySimState::SIM_STATE_READY:
50             result = "SIM_STATE_READY";
51             break;
52         case TelephonySimState::SIM_STATE_LOADED:
53             result = "SIM_STATE_LOADED";
54             break;
55         default:
56             break;
57     }
58     return result;
59 }
60 
GetCallState(int32_t state)61 std::string GetCallState(int32_t state)
62 {
63     std::string result = "CALL_STATUS_IDLE";
64     switch (static_cast<TelephonyCallState>(state)) {
65         case TelephonyCallState::CALL_STATUS_ACTIVE:
66             result = "CALL_STATUS_ACTIVE";
67             break;
68         case TelephonyCallState::CALL_STATUS_HOLDING:
69             result = "CALL_STATUS_HOLDING";
70             break;
71         case TelephonyCallState::CALL_STATUS_DIALING:
72             result = "CALL_STATUS_DIALING";
73             break;
74         case TelephonyCallState::CALL_STATUS_ALERTING:
75             result = "CALL_STATUS_ALERTING";
76             break;
77         case TelephonyCallState::CALL_STATUS_INCOMING:
78             result = "CALL_STATUS_INCOMING";
79             break;
80         case TelephonyCallState::CALL_STATUS_WAITING:
81             result = "CALL_STATUS_WAITING";
82             break;
83         case TelephonyCallState::CALL_STATUS_DISCONNECTED:
84             result = "CALL_STATUS_DISCONNECTED";
85             break;
86         case TelephonyCallState::CALL_STATUS_DISCONNECTING:
87             result = "CALL_STATUS_DISCONNECTING";
88             break;
89         case TelephonyCallState::CALL_STATUS_IDLE:
90             result = "CALL_STATUS_IDLE";
91             break;
92         default:
93             break;
94     }
95     return result;
96 }
97 
GetCardType(int32_t type)98 std::string GetCardType(int32_t type)
99 {
100     std::string result = "";
101     switch (static_cast<TelephonyCardType>(type)) {
102         case TelephonyCardType::UNKNOWN_CARD:
103             result = "UNKNOWN_CARD";
104             break;
105         case TelephonyCardType::SINGLE_MODE_SIM_CARD:
106             result = "SINGLE_MODE_SIM_CARD";
107             break;
108         case TelephonyCardType::SINGLE_MODE_USIM_CARD:
109             result = "SINGLE_MODE_USIM_CARD";
110             break;
111         case TelephonyCardType::SINGLE_MODE_RUIM_CARD:
112             result = "SINGLE_MODE_RUIM_CARD";
113             break;
114         case TelephonyCardType::DUAL_MODE_CG_CARD:
115             result = "DUAL_MODE_CG_CARD";
116             break;
117         case TelephonyCardType::CT_NATIONAL_ROAMING_CARD:
118             result = "CT_NATIONAL_ROAMING_CARD";
119             break;
120         case TelephonyCardType::CU_DUAL_MODE_CARD:
121             result = "CU_DUAL_MODE_CARD";
122             break;
123         case TelephonyCardType::DUAL_MODE_TELECOM_LTE_CARD:
124             result = "DUAL_MODE_TELECOM_LTE_CARD";
125             break;
126         case TelephonyCardType::DUAL_MODE_UG_CARD:
127             result = "DUAL_MODE_UG_CARD";
128             break;
129         case TelephonyCardType::SINGLE_MODE_ISIM_CARD:
130             result = "SINGLE_MODE_ISIM_CARD";
131             break;
132         default:
133             break;
134     }
135     return result;
136 }
137 
GetCellularDataConnectionState(int32_t state)138 std::string GetCellularDataConnectionState(int32_t state)
139 {
140     std::string result = "";
141     switch (static_cast<TelephonyDataConnectionStatus>(state)) {
142         case TelephonyDataConnectionStatus::DATA_STATE_DISCONNECTED:
143             result = "DATA_STATE_DISCONNECTED";
144             break;
145         case TelephonyDataConnectionStatus::DATA_STATE_CONNECTING:
146             result = "DATA_STATE_CONNECTING";
147             break;
148         case TelephonyDataConnectionStatus::DATA_STATE_CONNECTED:
149             result = "DATA_STATE_CONNECTED";
150             break;
151         case TelephonyDataConnectionStatus::DATA_STATE_SUSPENDED:
152             result = "DATA_STATE_SUSPENDED";
153             break;
154         default:
155             break;
156     }
157     return result;
158 }
159 
GetCellularDataFlow(int32_t flowData)160 std::string GetCellularDataFlow(int32_t flowData)
161 {
162     std::string result = "";
163     switch (static_cast<TelephonyCellDataFlowType>(flowData)) {
164         case TelephonyCellDataFlowType::DATA_FLOW_TYPE_NONE:
165             result = "DATA_FLOW_TYPE_NONE";
166             break;
167         case TelephonyCellDataFlowType::DATA_FLOW_TYPE_DOWN:
168             result = "DATA_FLOW_TYPE_DOWN";
169             break;
170         case TelephonyCellDataFlowType::DATA_FLOW_TYPE_UP:
171             result = "DATA_FLOW_TYPE_UP";
172             break;
173         case TelephonyCellDataFlowType::DATA_FLOW_TYPE_UP_DOWN:
174             result = "DATA_FLOW_TYPE_UP_DOWN";
175             break;
176         case TelephonyCellDataFlowType::DATA_FLOW_TYPE_DORMANT:
177             result = "DATA_FLOW_TYPE_DORMANT";
178             break;
179         default:
180             break;
181     }
182     return result;
183 }
184 
GetCellularDataConnectionNetworkType(int32_t type)185 std::string GetCellularDataConnectionNetworkType(int32_t type)
186 {
187     std::string result = "";
188     switch (static_cast<TelephonyRadioTech>(type)) {
189         case TelephonyRadioTech::RADIO_TECHNOLOGY_UNKNOWN:
190             result = "RADIO_TECHNOLOGY_UNKNOWN";
191             break;
192         case TelephonyRadioTech::RADIO_TECHNOLOGY_GSM:
193             result = "RADIO_TECHNOLOGY_GSM";
194             break;
195         case TelephonyRadioTech::RADIO_TECHNOLOGY_1XRTT:
196             result = "RADIO_TECHNOLOGY_1XRTT";
197             break;
198         case TelephonyRadioTech::RADIO_TECHNOLOGY_WCDMA:
199             result = "RADIO_TECHNOLOGY_WCDMA";
200             break;
201         case TelephonyRadioTech::RADIO_TECHNOLOGY_HSPA:
202             result = "RADIO_TECHNOLOGY_HSPA";
203             break;
204         case TelephonyRadioTech::RADIO_TECHNOLOGY_HSPAP:
205             result = "RADIO_TECHNOLOGY_HSPAP";
206             break;
207         case TelephonyRadioTech::RADIO_TECHNOLOGY_TD_SCDMA:
208             result = "RADIO_TECHNOLOGY_TD_SCDMA";
209             break;
210         case TelephonyRadioTech::RADIO_TECHNOLOGY_EVDO:
211             result = "RADIO_TECHNOLOGY_EVDO";
212             break;
213         case TelephonyRadioTech::RADIO_TECHNOLOGY_EHRPD:
214             result = "RADIO_TECHNOLOGY_EHRPD";
215             break;
216         case TelephonyRadioTech::RADIO_TECHNOLOGY_LTE:
217             result = "RADIO_TECHNOLOGY_LTE";
218             break;
219         case TelephonyRadioTech::RADIO_TECHNOLOGY_LTE_CA:
220             result = "RADIO_TECHNOLOGY_LTE_CA";
221             break;
222         case TelephonyRadioTech::RADIO_TECHNOLOGY_IWLAN:
223             result = "RADIO_TECHNOLOGY_IWLAN";
224             break;
225         case TelephonyRadioTech::RADIO_TECHNOLOGY_NR:
226             result = "RADIO_TECHNOLOGY_NR";
227             break;
228         default:
229             break;
230     }
231     return result;
232 }
233 
GetLockReason(int32_t reason)234 std::string GetLockReason(int32_t reason)
235 {
236     std::string result = "";
237     switch (static_cast<TelephonyLockReason>(reason)) {
238         case TelephonyLockReason::SIM_NONE:
239             result = "SIM_NONE";
240             break;
241         case TelephonyLockReason::SIM_PIN:
242             result = "SIM_PIN";
243             break;
244         case TelephonyLockReason::SIM_PUK:
245             result = "SIM_PUK";
246             break;
247         case TelephonyLockReason::SIM_PN_PIN:
248             result = "SIM_PN_PIN";
249             break;
250         case TelephonyLockReason::SIM_PN_PUK:
251             result = "SIM_PN_PUK";
252             break;
253         case TelephonyLockReason::SIM_PU_PIN:
254             result = "SIM_PU_PIN";
255             break;
256         case TelephonyLockReason::SIM_PU_PUK:
257             result = "SIM_PU_PUK";
258             break;
259         case TelephonyLockReason::SIM_PP_PIN:
260             result = "SIM_PP_PIN";
261             break;
262         case TelephonyLockReason::SIM_PP_PUK:
263             result = "SIM_PP_PUK";
264             break;
265         case TelephonyLockReason::SIM_PC_PIN:
266             result = "SIM_PC_PIN";
267             break;
268         case TelephonyLockReason::SIM_PC_PUK:
269             result = "SIM_PC_PUK";
270             break;
271         case TelephonyLockReason::SIM_SIM_PIN:
272             result = "SIM_SIM_PIN";
273             break;
274         case TelephonyLockReason::SIM_SIM_PUK:
275             result = "SIM_SIM_PUK";
276             break;
277         default:
278             break;
279     }
280     return result;
281 }
282 } // namespace Telephony
283 } // namespace OHOS
284