1 /*
2 * Copyright (C) 2021-2022 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 const int32_t DSDS_MODE_V2 = 0;
36 inline const int32_t DSDS_MODE_V3 = 1;
37 inline const size_t MAX_PARAMETER_LENGTH = 100;
38 inline int32_t maxSlotCount_ = 0;
39 inline constexpr const char *SATELLITE_DEFAULT_VALUE = "0";
40 inline constexpr const char *DEFAULT_SLOT_COUNT = "1";
41 inline constexpr const char *TEL_SIM_SLOT_COUNT = "const.telephony.slotCount";
42 inline constexpr const char *DEFAULT_PREFERRED_NETWORK_TYPE = "5"; // CORE_NETWORK_MODE_LTE_WCDMA_GSM
43 inline constexpr const char *TEL_PREFERRED_NETWORK_TYPE = "const.telephony.preferredNetworkType";
44 inline constexpr const char *DEFAULT_OPERATOR_KEY = "";
45 inline constexpr const char *INITIAL_OPKEY = "-1";
46 inline constexpr const char *DEFAULT_OPERATOR_CONFIG = "default_operator_config.json";
47 inline constexpr const char *OPKEY_PROP_PREFIX = "telephony.sim.opkey";
48 inline constexpr const char *COUNTRY_CODE_KEY = "telephony.sim.countryCode";
49 inline constexpr const char *TEL_SATELLITE_SUPPORTED = "const.telephony.satellite.supported";
50
51 template<typename T>
GetMaxSlotCount()52 inline T GetMaxSlotCount()
53 {
54 if (maxSlotCount_ == 0) {
55 char simSlotCount[SYSPARA_SIZE] = { 0 };
56 GetParameter(TEL_SIM_SLOT_COUNT, DEFAULT_SLOT_COUNT, simSlotCount, SYSPARA_SIZE);
57 maxSlotCount_ = std::atoi(simSlotCount);
58 }
59 return maxSlotCount_;
60 }
61
62 template<typename T>
GetPreferredNetworkType()63 inline T GetPreferredNetworkType()
64 {
65 char preferredNetworkType[SYSPARA_SIZE] = { 0 };
66 GetParameter(TEL_PREFERRED_NETWORK_TYPE, DEFAULT_PREFERRED_NETWORK_TYPE, preferredNetworkType, SYSPARA_SIZE);
67 T networkType = std::atoi(preferredNetworkType);
68 return networkType;
69 }
70
71 enum SatelliteValue {
72 SATELLITE_NOT_SUPPORTED = 0,
73 SATELLITE_SUPPORTED = 1,
74 };
75
76 enum SimSlotId {
77 SIM_SLOT_0 = 0,
78 SIM_SLOT_1,
79 SIM_SLOT_2,
80 SIM_SLOT_3,
81 };
82
83 /**
84 * @brief The modem power status.
85 */
86 enum ModemPowerState {
87 /**
88 * Power Not Available
89 */
90 CORE_SERVICE_POWER_NOT_AVAILABLE = -1,
91 /**
92 * Power OFF
93 */
94 CORE_SERVICE_POWER_OFF = 0,
95 /**
96 * Power ON
97 */
98 CORE_SERVICE_POWER_ON = 1
99 };
100
101 template<typename T>
102 struct TelRilResponseInfo {
103 int32_t slotId = DEFAULT_SIM_SLOT_ID;
104 int32_t flag = 0;
105 int32_t errorNo = 0;
106 T object;
107 };
108
109 /**
110 * @brief Defines the network bandwidth reporting rule.
111 */
112 struct LinkBandwidthRule {
113 /**
114 * Radio access technology
115 */
116 int32_t rat = 0;
117 /**
118 * Delay time
119 */
120 int32_t delayMs = 0;
121 /**
122 * Uplink delay
123 */
124 int32_t delayUplinkKbps = 0;
125 /**
126 * Downlink delay
127 */
128 int32_t delayDownlinkKbps = 0;
129 /**
130 * Maximum uplink parameter list
131 */
132 std::vector<int32_t> maximumUplinkKbps {};
133 /**
134 * Maximum downlink parameter list
135 */
136 std::vector<int32_t> maximumDownlinkKbps {};
137 };
138
139 /**
140 * @brief Defines PDP context information.
141 */
142 struct DataProfile {
143 /**
144 * Profile Id
145 */
146 int profileId = 0;
147 /**
148 * (Access Point Name) a string parameter which is a logical name that is used to select the
149 * GGSN or the external packet data network. from 3GPP TS 27.007 10.1 V4.3.0 (2001-12)
150 */
151 std::string apn = "";
152 /**
153 * (Packet Data Protocol type) a string parameter which specifies the type of packet
154 * data protocol from 3GPP TS 27.007 10.1 V4.3.0 (2001-12)
155 */
156 std::string protocol = "";
157 /**
158 * Authentication Type
159 */
160 int32_t verType = 0;
161 /**
162 * Username
163 */
164 std::string userName = "";
165 /**
166 * Password
167 */
168 std::string password = "";
169 /**
170 * Roaming protocol version
171 */
172 std::string roamingProtocol = "";
173 };
174
175 /**
176 * @brief Defines activate data information.
177 */
178 struct ActivateDataParam {
179 /**
180 * eg:AppExecFwk::InnerEvent::Get(eventId, activateData.param);
181 */
182 int32_t param = 0;
183 /**
184 * Radio access technology
185 */
186 int32_t radioTechnology = 0;
187 /**
188 * DataProfile
189 */
190 struct DataProfile dataProfile;
191 /**
192 * Whether the user is roaming. The value true indicates that the user is roaming,
193 * and the value false indicates the opposite.
194 */
195 bool isRoaming = false;
196 /**
197 * Whether allow roaming
198 */
199 bool allowRoaming = false;
200 };
201
202 /**
203 * @brief Defines deactivate data information.
204 */
205 struct DeactivateDataParam {
206 /**
207 * eg:AppExecFwk::InnerEvent::Get(eventId, deactivateData.param);
208 */
209 int32_t param = 0;
210 /**
211 * Packet Data Protocol (PDP) context ID
212 */
213 int32_t cid = 0;
214 /**
215 * Reason code of the data service activation failure. For details, see 3GPP TS 24.008.
216 */
217 int32_t reason = 0;
218 };
219
220 /**
221 * @brief Defines the call forwarding information.
222 */
223 struct CallTransferParam {
224 /**
225 * Call forwarding operation mode:
226 *- 0: deactivation
227 *- 1: activation
228 *- 2: status query
229 *- 3: registration
230 *- 4: deletion
231 */
232 int32_t mode = 0;
233 /**
234 * Call forwarding type:
235 *- 0: call forwarding unconditional
236 *- 1: call forwarding on busy
237 *- 2: call forwarding on no reply
238 *- 3: call forwarding not reachable (no network service, or power-off)
239 *- 4: any call forwarding
240 *- 5: any call forwarding conditional
241 */
242 int32_t reason = 0;
243 /**
244 * Service class. For details, see 3GPP TS 27.007.
245 */
246 int32_t classx = 0;
247 /**
248 * Phone number
249 */
250 std::string number = "";
251 };
252
253 /**
254 * @brief Defines the call restriction information.
255 */
256 struct CallRestrictionParam {
257 /**
258 * Operation mode:
259 *- 0: deactivation
260 *- 1: activation
261 */
262 int32_t mode = 0;
263 /**
264 * Password
265 */
266 char password[MAX_PARAMETER_LENGTH + 1] = { 0 };
267 /**
268 * Operation object
269 */
270 std::string fac = "";
271 };
272
273 /**
274 * @brief Defines the dual tone multi-frequency (DTMF) information.
275 */
276 struct DtmfParam {
277 /**
278 * Call ID
279 */
280 int32_t index = 0;
281 /**
282 * Duration for playing the DTMF tone
283 */
284 int32_t switchOn = 0;
285 /**
286 * Interval for sending DTMF signals
287 */
288 int32_t switchOff = 0;
289 /**
290 * DTMF keyword
291 */
292 std::string sDTMFCode = "";
293 };
294
295 /**
296 * @brief Defines the GSM cell broadcast configuration information.
297 */
298 struct CBConfigParam {
299 /**
300 * Mode (activated or not)
301 */
302 int32_t mode = 0;
303 /**
304 * Message IDs
305 */
306 std::string idList = "";
307 /**
308 * Data coding schemes
309 */
310 std::string dcsList = "";
311 };
312
313 /**
314 * @brief Defines the SMS message information in a SIM card.
315 */
316 struct CdmaSimMessageParam {
317 /**
318 * Message index.
319 */
320 int32_t cdmaIndex = 0;
321 /**
322 * Status
323 */
324 int32_t status = 0;
325 /**
326 * Protocol data unit
327 */
328 std::string pdu = "";
329 };
330
331 /**
332 * @brief GSM SMS message parameter.
333 */
334 struct GsmSimMessageParam {
335 /**
336 * Reference Id
337 */
338 int64_t refId = 0;
339 /**
340 * Short message service center
341 */
342 std::string smscPdu = "";
343 /**
344 * Protocol data unit
345 */
346 std::string pdu = "";
347 };
348
349 /**
350 * @brief Defines the SMS message information in a SIM card.
351 */
352 struct SimMessageParam {
353 /**
354 * Message index.
355 */
356 int32_t gsmIndex = 0;
357 /**
358 * Status
359 */
360 int32_t status = 0;
361 /**
362 * Short message service center
363 */
364 std::string smscPdu = "";
365 /**
366 * Protocol data unit
367 */
368 std::string pdu = "";
369 };
370
371 /**
372 * @brief Defines the SIM card lock information.
373 */
374 struct SimLockParam {
375 /**
376 * SIM lock type:
377 *- AO: barring of all outgoing calls
378 *- OI: barring of all outgoing international calls
379 *- OX: barring of all outgoing international calls except those directed to the home country
380 *- AI: barring of all incoming calls
381 *- IR: barring of all incoming calls when roaming outside the home location
382 *- AB: barring of all services (applicable only when the mode is greater than or equal to 0)
383 *- AG: barring of the outgoing call service (applicable only when the mode is greater than or equal to 0)
384 *- AC: barring of the incoming call service (applicable only when the mode is greater than or equal to 0)
385 *- FD: fixed dialing number (FDN)
386 *- PN: network locking
387 *- PU: subnet locking
388 *- PP: SP locking
389 */
390 std::string fac = "";
391 /**
392 * Mode:
393 *- 0: deactivation (When fac is set to PN, PU, or PP, the operation is equivalent to unlocking.)
394 *- 1: activation (When fac is set to PN, PU, or PP, activation is not supported.)
395 *- 2: query
396 */
397 int32_t mode = 0;
398 /**
399 * Password text
400 */
401 std::string passwd = "";
402 };
403
404 /**
405 * @brief Defines the SIM card password information.
406 */
407 struct SimPasswordParam {
408 /**
409 * Maximum password length
410 */
411 int32_t passwordLength = 0;
412 /**
413 * SIM lock type:
414 *- AO: barring of all outgoing calls
415 *- OI: barring of all outgoing international calls
416 *- OX: barring of all outgoing international calls except those directed to the home country
417 *- AI: barring of all incoming calls
418 *- IR: barring of all incoming calls when roaming outside the home location
419 *- AB: barring of all services (applicable only when the mode is greater than or equal to 0)
420 *- AG: barring of the outgoing call service (applicable only when the mode is greater than or equal to 0)
421 *- AC: barring of the incoming call service (applicable only when the mode is greater than or equal to 0)
422 *- FD: fixed dialing number (FDN)
423 *- PN: network locking
424 *- PU: subnet locking
425 *- PP: SP locking
426 */
427 std::string fac = "";
428 /**
429 * Old password text
430 */
431 std::string oldPassword = "";
432 /**
433 * New password text
434 */
435 std::string newPassword = "";
436 };
437
438 /**
439 * @brief Enumerates emergency call types.
440 */
441 enum class EccType : int32_t {
442 /**
443 * Default
444 */
445 TYPE_CATEGORY = 0,
446 /**
447 * Police
448 */
449 TYPE_POLICE = 1,
450 /**
451 * Ambulance
452 */
453 TYPE_AMBULANCE = 2,
454 /**
455 * Fire alarm
456 */
457 TYPE_FIRE = 4,
458 /**
459 * Marine police
460 */
461 TYPE_SEA = 8,
462 /**
463 * Mountain rescue
464 */
465 TYPE_MOUNTAIN = 16,
466 };
467
468 /**
469 * @brief Specifies whether a number is valid when there is a card or no card.
470 */
471 enum class SimpresentType : int32_t {
472 /**
473 * Valid when there is no card
474 */
475 TYPE_NO_CARD = 0,
476 /**
477 * Valid when there is a card
478 */
479 TYPE_HAS_CARD = 1,
480 };
481
482 /**
483 * @brief Specifies whether a number is valid for all states or only for the abnormal service state of
484 * the circuit switched (CS) domain.
485 */
486 enum class AbnormalServiceType : int32_t {
487 /**
488 * Vaild for all states
489 */
490 TYPE_ALL = 0,
491 /**
492 * Valid only for the abnormal service state of the CS domain
493 */
494 TYPE_ONLY_CS = 1,
495 };
496
497 /**
498 * @brief Defines the emergency call number.
499 */
500 struct EmergencyCall {
501 /**
502 * Emergency number
503 */
504 std::string eccNum = "";
505 /**
506 * Mobile country code
507 */
508 std::string mcc = "";
509 /**
510 * Enumerates emergency call types. For details, see EccType.
511 */
512 EccType eccType = EccType::TYPE_CATEGORY;
513 /**
514 * Whether a number is valid when there is a card or no card. For details, see SimpresentType.
515 */
516 SimpresentType simpresent = SimpresentType::TYPE_NO_CARD;
517 /**
518 * Whether a number is valid for all states or only for the abnormal service state of the CS domain.
519 * For details, see AbnormalService.
520 */
521 AbnormalServiceType abnormalService = AbnormalServiceType::TYPE_ALL;
522 bool operator==(const EmergencyCall &call)
523 {
524 return (eccNum == call.eccNum && mcc == call.mcc);
525 }
526 };
527
528 /**
529 * @brief Defines the response info of SetEmergencyCallList.
530 */
531 struct SetEccListResponse {
532 /**
533 * Response result
534 */
535 int32_t result = 0;
536 /**
537 * Response value
538 */
539 int32_t value = 0;
540 };
541
542 /**
543 * @brief Defines the Public Land Mobile Network name.
544 */
545 struct PlmnNetworkName {
546 /**
547 * Long name of the registered network
548 */
549 std::string longName = "";
550 /**
551 * Short name of the registered network
552 */
553 std::string shortName = "";
554 };
555
556 /**
557 * @brief Defines the Operator PLMN information see 3GPP TS 31.102 Section 4.2.59.
558 */
559 struct OperatorPlmnInfo {
560 /**
561 * PLMN numeric
562 */
563 std::string plmnNumeric = "";
564 /**
565 * Start of the LAC range
566 */
567 int32_t lacStart = 0;
568 /**
569 * End of the LAC range
570 */
571 int32_t lacEnd = 0;
572 /**
573 * Identifier of operator name in PNN to be displayed
574 */
575 int32_t pnnRecordId = 0;
576 };
577
578 /**
579 * @brief Enumerates radio protocol phases.
580 *
581 * @enum RadioProtocolPhase
582 */
583 enum class RadioProtocolPhase {
584 /**
585 * The value of Initial radio protocol phase
586 */
587 RADIO_PROTOCOL_PHASE_INITIAL,
588 /**
589 * The value of execute check communication phase
590 */
591 RADIO_PROTOCOL_PHASE_CHECK,
592 /**
593 * The value of execute update communication phase
594 */
595 RADIO_PROTOCOL_PHASE_UPDATE,
596 /**
597 * The value of unsol radio phase
598 */
599 RADIO_PROTOCOL_PHASE_NOTIFY,
600 /**
601 * The value of execute complete communication phase
602 */
603 RADIO_PROTOCOL_PHASE_COMPLETE,
604 };
605
606 /**
607 * @brief Enumerates radio protocol states.
608 */
609 enum class RadioProtocolStatus {
610 /**
611 * Unknow radio protocol state
612 */
613 RADIO_PROTOCOL_STATUS_NONE,
614 /**
615 * Set radio protocol successed
616 */
617 RADIO_PROTOCOL_STATUS_SUCCESS,
618 /**
619 * Set radio protocol failed
620 */
621 RADIO_PROTOCOL_STATUS_FAIL,
622 };
623
624 /**
625 * @brief Defines the protocol stack information of the primary and secondary SIM cards.
626 */
627 struct RadioProtocol {
628 /**
629 * Card slot ID
630 */
631 int32_t slotId = DEFAULT_SIM_SLOT_ID;
632 /**
633 * Session ID
634 */
635 int32_t sessionId = 0;
636 /**
637 * Radio protocol parameters. For details, see RadioProtocolPhase.
638 */
639 RadioProtocolPhase phase = RadioProtocolPhase::RADIO_PROTOCOL_PHASE_INITIAL;
640 /**
641 * Radio protocol technology:
642 *- 1: GSM
643 *- 2: 1XRTT
644 *- 4: WCDMA
645 *- 8: HSPA
646 *- 16: HSPAP
647 *- 32: TDSCDMA
648 *- 64: EV-DO
649 *- 128: EHRPD
650 *- 256: LTE
651 *- 512: LTE_CA
652 *- 1024: IWLAN
653 *- 2048: NR
654 */
655 int32_t technology = 0;
656 /**
657 * Modem ID, corresponding to slotId at the bottom layer
658 */
659 int32_t modemId = 0;
660 /**
661 * Radio protocol status. For details, see RadioProtocolStatus.
662 */
663 RadioProtocolStatus status = RadioProtocolStatus::RADIO_PROTOCOL_STATUS_NONE;
664 };
665
666 /**
667 * @brief Defines the result info of ss command.
668 */
669 struct SsBaseResult {
670 /**
671 * Command index, use for find the ss command to retry
672 */
673 int32_t index = 0;
674 /**
675 * The result of execute command
676 */
677 int32_t result = 0;
678 /**
679 * This use for remaind message code
680 */
681 int32_t reason = 0;
682 /**
683 * This use for remaind message
684 */
685 std::string message = "";
686 };
687
688 /**
689 * @brief Defines the result info of GetClip.
690 */
691 struct GetClipResult {
692 /**
693 * Query results
694 */
695 SsBaseResult result;
696 /**
697 * Parameter sets/shows the result code presentation status in the TA
698 */
699 int32_t action = 0;
700 /**
701 * Parameter shows the subscriber CLIP service status in the network, <0-4>
702 */
703 int32_t clipStat = 0;
704 };
705
706 /**
707 * @brief Defines the result info of GetClir.
708 */
709 struct GetClirResult {
710 /**
711 * Query results
712 */
713 SsBaseResult result;
714 /**
715 * Parameter sets/shows the result code presentation status in the TA
716 */
717 int32_t action = 0;
718 /**
719 * Parameter shows the subscriber CLIP service status in the network, <0-4>
720 */
721 int32_t clirStat = 0;
722 };
723
724 /**
725 * @brief Defines the result info of GetColr.
726 */
727 struct GetColrResult {
728 /**
729 * Query results
730 */
731 SsBaseResult result;
732 /**
733 * Parameter sets/shows the result code presentation status in the TA
734 */
735 int32_t action = 0;
736 /**
737 * Parameter shows the subscriber COLR service status in the network, <0-4>
738 */
739 int32_t colrStat = 0;
740 };
741
742 /**
743 * @brief Defines the result info of GetColp.
744 */
745 struct GetColpResult {
746 /**
747 * Query results
748 */
749 SsBaseResult result;
750 /**
751 * Parameter sets/shows the result code presentation status in the TA
752 */
753 int32_t action = 0;
754 /**
755 * Parameter shows the subscriber COLP service status in the network, <0-4>
756 */
757 int32_t colpStat = 0;
758 };
759
760 /**
761 * @brief Defines the result info of CallWait.
762 */
763 struct CallWaitResult {
764 /**
765 * Query results
766 */
767 SsBaseResult result;
768 /**
769 * Parameter sets/shows the result code presentation status in the TA
770 */
771 int32_t status = 0;
772 /**
773 * Parameter shows the subscriber CLIP service status in the network, <0-4>
774 */
775 int32_t classCw = 0;
776 };
777
778 /**
779 * @brief Defines the result info of CallRestriction.
780 */
781 struct CallRestrictionResult {
782 /**
783 * Query results
784 */
785 SsBaseResult result;
786 /**
787 * Parameter sets/shows the result code presentation status in the TA
788 */
789 int32_t status = 0;
790 /**
791 * Parameter shows the subscriber CLIP service status in the network, <0-4>
792 */
793 int32_t classCw = 0;
794 };
795
796 /**
797 * @brief Defines the call forwarding query result.
798 */
799 struct CallForwardQueryResult {
800 /**
801 * Request SN
802 */
803 int32_t serial = 0;
804 /**
805 * Query result
806 */
807 int32_t result = 0;
808 /**
809 * Status:
810 *- 0: not activated
811 *- 1: activated
812 */
813 int32_t status = 0;
814 /**
815 * Service class. For details, see 3GPP TS 27.007.
816 */
817 int32_t classx = 0;
818 /**
819 * Phone number
820 */
821 std::string number = "";
822 /**
823 * Number type:
824 *-129: common number
825 *- 145: international number
826 */
827 int32_t type = 0;
828 /**
829 * Call forwarding type:
830 *- 0: call forwarding unconditional
831 *- 1: call forwarding on busy
832 *- 2: call forwarding on no reply
833 *- 3: call forwarding not reachable (no network service or power-off)
834 *- 4: any call forwarding
835 *- 5: any call forwarding conditional
836 */
837 int32_t reason = 0;
838 /**
839 * Waiting time
840 */
841 int32_t time = 0;
842 /**
843 * Start hour
844 */
845 int32_t startHour = 0;
846 /**
847 * Start minute
848 */
849 int32_t startMinute = 0;
850 /**
851 * End hour
852 */
853 int32_t endHour = 0;
854 /**
855 * End minute
856 */
857 int32_t endMinute = 0;
858 };
859
860 /**
861 * @brief Defines the list of call forwarding information.
862 */
863 struct CallForwardQueryInfoList {
864 /**
865 * Query results
866 */
867 SsBaseResult result;
868 /**
869 * Total number
870 */
871 int32_t callSize = 0;
872 /**
873 * ID of the call forwarding query result
874 */
875 int32_t flag = 0;
876 /**
877 * Call forwarding query result
878 */
879 std::vector<CallForwardQueryResult> calls {};
880 };
881 } // namespace Telephony
882 } // namespace OHOS
883 #endif // TELEPHONY_TELEPHONY_TYPES_H
884