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