• 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 NETWORK_STATE_H
17 #define NETWORK_STATE_H
18 
19 #include "parcel.h"
20 #include "network_search_types.h"
21 
22 namespace OHOS {
23 namespace Telephony {
24 class NetworkState : public Parcelable {
25 public:
26     NetworkState();
27     virtual ~NetworkState() = default;
28     void Init();
29     bool operator==(const NetworkState &other) const;
30     bool ReadFromParcel(Parcel &parcel);
31     bool Marshalling(Parcel &parcel) const override;
32     static NetworkState *Unmarshalling(Parcel &parcel);
33     void SetOperatorInfo(const std::string &longName, const std::string &shortName, const std::string &numeric,
34         DomainType domainType);
35     void SetEmergency(bool isEmergency);
36     void SetNetworkType(RadioTech tech, DomainType domainType);
37     void SetRoaming(RoamingType roamingType, DomainType domainType);
38     void SetNetworkState(RegServiceState state, DomainType domainType);
39     void SetNrState(NrState state);
40     void SetCfgTech(RadioTech tech);
41     void SetLongOperatorName(const std::string &longName, DomainType domainType);
42     RegServiceState GetPsRegStatus() const;
43     RegServiceState GetCsRegStatus() const;
44     RoamingType GetPsRoamingStatus() const;
45     RoamingType GetCsRoamingStatus() const;
46     bool IsCdma() const;
47     bool IsGsm() const;
48     /*
49      * Obtains RAT of the PS domain on the registered network.
50      * @return Returns RAT of the PS domain on the registered network
51      */
52     RadioTech GetPsRadioTech() const;
53     /*
54      * Obtains RAT of the PS domain on the registered network.
55      * @return Returns last RAT of the PS domain on the registered network
56      */
57     RadioTech GetLastPsRadioTech() const;
58     /*
59      * Obtains RAT of the CS domain on the registered network.
60      * @return Returns RAT of the CS domain on the registered network
61      */
62     RadioTech GetCsRadioTech() const;
63     /*
64      * Obtains the operator name in the long alphanumeric format of the registered network.
65      * @return Returns operator name in the long alphanumeric format
66      */
67     std::string GetLongOperatorName() const;
68     /*
69      * Obtains the operator name in the short alphanumeric format of the registered network.
70      * @return Returns operator name in the short alphanumeric format
71      */
72     std::string GetShortOperatorName() const;
73     /*
74      * Obtains the PLMN code of the registered network.
75      * @return Returns the PLMN code
76      */
77     std::string GetPlmnNumeric() const;
78     /*
79      * Obtains the network registration status of the device.
80      * @return Returns the network registration status
81      */
82     RegServiceState GetRegStatus() const;
83     /*
84      * Checks whether this device is allowed to make emergency calls only.
85      * @return Returns the device emergency calls state.
86      */
87     bool IsEmergency() const;
88     /*
89      * Checks whether the device is roaming.
90      * @return Returns roaming state.
91      */
92     bool IsRoaming() const;
93     std::string ToString() const;
94     /*
95      * Obtains the NSA network registration status of the device.
96      * @return Returns nsa state.
97      */
98     NrState GetNrState() const;
99     /*
100      * Obtains the radio access technology after config conversion.
101      * @return Returns access technology.
102      */
103     RadioTech GetCfgTech() const;
104     /*
105      * Obtains the radio Access technology after config conversion.
106      * @return Returns last access technology.
107      */
108     RadioTech GetLastCfgTech() const;
109 
110 private:
111     bool isEmergency_;
112     OperatorInformation psOperatorInfo_;
113     OperatorInformation csOperatorInfo_;
114     RoamingType csRoaming_;
115     RoamingType psRoaming_;
116     RegServiceState psRegStatus_;
117     RegServiceState csRegStatus_;
118     RadioTech psRadioTech_;
119     RadioTech lastPsRadioTech_;
120     RadioTech lastCfgTech_;
121     RadioTech csRadioTech_;
122     RadioTech cfgTech_;
123     NrState nrState_;
124     bool ReadParcelString(Parcel &parcel);
125     bool ReadParcelInt(Parcel &parcel);
126 };
127 } // namespace Telephony
128 } // namespace OHOS
129 #endif // NETWORK_STATE_H
130