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 TELEPHONY_TELEPHONY_TYPES_H
17 #define TELEPHONY_TELEPHONY_TYPES_H
18
19 #include <string>
20 #include <vector>
21
22 #include "network_search_types.h"
23 #include "operator_config_types.h"
24 #include "parameter.h"
25
26 namespace OHOS {
27 namespace Telephony {
28 #define SIM_SLOT_COUNT GetMaxSlotCount<int32_t>()
29 #define PREFERRED_NETWORK_TYPE GetPreferredNetworkType<int32_t>()
30 inline const int32_t SYSPARA_SIZE = 128;
31 inline const int32_t DEFAULT_SIM_SLOT_ID = 0;
32 inline const int32_t DEFAULT_SIM_SLOT_ID_REMOVE = -1;
33 inline const int32_t INVALID_MAIN_CARD_SLOTID = -2;
34 inline const int32_t ERROR_SLOT_OPKEY = -2;
35 inline constexpr const char *DEFAULT_SLOT_COUNT = "1";
36 inline constexpr const char *TEL_SIM_SLOT_COUNT = "const.telephony.slotCount";
37 inline constexpr const char *DEFAULT_PREFERRED_NETWORK_TYPE = "5"; // CORE_NETWORK_MODE_LTE_WCDMA_GSM
38 inline constexpr const char *TEL_PREFERRED_NETWORK_TYPE = "const.telephony.preferredNetworkType";
39 inline constexpr const char *DEFAULT_OPERATOR_KEY = "";
40 inline constexpr const char *INITIAL_OPKEY = "-1";
41 inline constexpr const char *DEFAULT_OPERATOR_CONFIG = "default_operator_config.json";
42 inline constexpr const char *OPKEY_PROP_PREFIX = "telephony.sim.opkey";
43 inline constexpr const char *COUNTRY_CODE_KEY = "telephony.sim.countryCode";
44
45 template<typename T>
GetMaxSlotCount()46 inline T GetMaxSlotCount()
47 {
48 char simSlotCount[SYSPARA_SIZE] = { 0 };
49 GetParameter(TEL_SIM_SLOT_COUNT, DEFAULT_SLOT_COUNT, simSlotCount, SYSPARA_SIZE);
50 T slotCount = std::atoi(simSlotCount);
51 return slotCount;
52 }
53
54 template<typename T>
GetPreferredNetworkType()55 inline T GetPreferredNetworkType()
56 {
57 char preferredNetworkType[SYSPARA_SIZE] = { 0 };
58 GetParameter(TEL_PREFERRED_NETWORK_TYPE, DEFAULT_PREFERRED_NETWORK_TYPE, preferredNetworkType, SYSPARA_SIZE);
59 T networkType = std::atoi(preferredNetworkType);
60 return networkType;
61 }
62
63 enum SimSlotId {
64 SIM_SLOT_0 = 0,
65 SIM_SLOT_1,
66 SIM_SLOT_2,
67 SIM_SLOT_3,
68 };
69
70 enum ModemPowerState { CORE_SERVICE_POWER_NOT_AVAILABLE = -1, CORE_SERVICE_POWER_OFF = 0, CORE_SERVICE_POWER_ON = 1 };
71
72 template<typename T>
73 struct TelRilResponseInfo {
74 int32_t slotId;
75 int32_t flag;
76 int32_t errorNo;
77 T object;
78 };
79
80 struct LinkBandwidthRule {
81 int32_t rat;
82 int32_t delayMs;
83 int32_t delayUplinkKbps;
84 int32_t delayDownlinkKbps;
85 std::vector<int32_t> maximumUplinkKbps;
86 std::vector<int32_t> maximumDownlinkKbps;
87 };
88
89 struct DataProfile {
90 int profileId;
91 /** (Access Point Name) a string parameter which is a logical name that is used to select the
92 * GGSN or the external packet data network. from 3GPP TS 27.007 10.1 V4.3.0 (2001-12)
93 */
94 std::string apn;
95 /** (Packet Data Protocol type) a string parameter which specifies the type of packet
96 * data protocol from 3GPP TS 27.007 10.1 V4.3.0 (2001-12)
97 */
98 std::string protocol;
99 int32_t verType;
100 std::string userName;
101 std::string password;
102 std::string roamingProtocol;
103 };
104
105 struct ActivateDataParam {
106 int32_t param; // eg:AppExecFwk::InnerEvent::Get(eventId, activateData.param);
107 int32_t radioTechnology;
108 struct DataProfile dataProfile;
109 bool isRoaming;
110 bool allowRoaming;
111 };
112
113 struct DeactivateDataParam {
114 int32_t param; // eg:AppExecFwk::InnerEvent::Get(eventId, deactivateData.param);
115 int32_t cid;
116 int32_t reason;
117 };
118
119 struct CallTransferParam {
120 int32_t mode;
121 int32_t reason;
122 int32_t classx;
123 std::string number;
124 };
125
126 struct CallRestrictionParam {
127 int32_t mode;
128 std::string password;
129 std::string fac;
130 };
131
132 struct DtmfParam {
133 int32_t index;
134 int32_t switchOn;
135 int32_t switchOff;
136 std::string sDTMFCode;
137 };
138
139 struct CBConfigParam {
140 int32_t mode;
141 std::string idList;
142 std::string dcsList;
143 };
144
145 struct CdmaSimMessageParam {
146 int32_t cdmaIndex;
147 int32_t status;
148 std::string pdu;
149 };
150
151 struct GsmSimMessageParam {
152 int64_t refId;
153 std::string smscPdu;
154 std::string pdu;
155 };
156
157 struct SimMessageParam {
158 int32_t gsmIndex;
159 int32_t status;
160 std::string smscPdu;
161 std::string pdu;
162 };
163
164 struct SimLockParam {
165 std::string fac;
166 int32_t mode;
167 std::string passwd;
168 };
169
170 struct SimPasswordParam {
171 int32_t passwordLength;
172 std::string fac;
173 std::string oldPassword;
174 std::string newPassword;
175 };
176
177 enum class EccType : int32_t {
178 TYPE_CATEGORY = 0,
179 TYPE_POLICE = 1,
180 TYPE_AMBULANCE = 2,
181 TYPE_FIRE = 4,
182 TYPE_SEA = 8,
183 TYPE_MOUNTAIN = 16,
184 };
185
186 enum class SimpresentType : int32_t {
187 TYPE_NO_CARD = 0,
188 TYPE_HAS_CARD = 1,
189 };
190
191 enum class AbnormalServiceType : int32_t {
192 TYPE_ALL = 0,
193 TYPE_ONLY_CS = 1,
194 };
195
196 struct EmergencyCall {
197 std::string eccNum;
198 std::string mcc;
199 EccType eccType;
200 SimpresentType simpresent;
201 AbnormalServiceType abnormalService;
202 bool operator==(const EmergencyCall &call)
203 {
204 return (eccNum == call.eccNum && mcc == call.mcc);
205 }
206 };
207
208 struct SetEccListResponse {
209 int32_t result;
210 int32_t value;
211 };
212
213 struct PlmnNetworkName {
214 std::string longName = "";
215 std::string shortName = "";
216 };
217
218 struct OperatorPlmnInfo {
219 std::string plmnNumeric = "";
220 int32_t lacStart = 0;
221 int32_t lacEnd = 0;
222 int32_t pnnRecordId = 0;
223 };
224
225 enum class RadioProtocolPhase {
226 RADIO_PROTOCOL_PHASE_INITIAL,
227 RADIO_PROTOCOL_PHASE_CHECK,
228 RADIO_PROTOCOL_PHASE_UPDATE,
229 RADIO_PROTOCOL_PHASE_NOTIFY,
230 RADIO_PROTOCOL_PHASE_COMPLETE,
231 };
232
233 enum class RadioProtocolStatus {
234 RADIO_PROTOCOL_STATUS_NONE,
235 RADIO_PROTOCOL_STATUS_SUCCESS,
236 RADIO_PROTOCOL_STATUS_FAIL,
237 };
238
239 struct RadioProtocol {
240 int32_t slotId;
241 int32_t sessionId;
242 RadioProtocolPhase phase;
243 int32_t technology;
244 int32_t modemId;
245 RadioProtocolStatus status;
246 };
247 } // namespace Telephony
248 } // namespace OHOS
249 #endif // TELEPHONY_TELEPHONY_TYPES_H
250