• 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     /*
47      * Obtains RAT of the PS domain on the registered network.
48      * @return Returns RAT of the PS domain on the registered network
49      */
50     RadioTech GetPsRadioTech() const;
51     /*
52      * Obtains RAT of the PS domain on the registered network.
53      * @return Returns last RAT of the PS domain on the registered network
54      */
55     RadioTech GetLastPsRadioTech() const;
56     /*
57      * Obtains RAT of the CS domain on the registered network.
58      * @return Returns RAT of the CS domain on the registered network
59      */
60     RadioTech GetCsRadioTech() const;
61     /*
62      * Obtains the operator name in the long alphanumeric format of the registered network.
63      * @return Returns operator name in the long alphanumeric format
64      */
65     std::string GetLongOperatorName() const;
66     /*
67      * Obtains the operator name in the short alphanumeric format of the registered network.
68      * @return Returns operator name in the short alphanumeric format
69      */
70     std::string GetShortOperatorName() const;
71     /*
72      * Obtains the PLMN code of the registered network.
73      * @return Returns the PLMN code
74      */
75     std::string GetPlmnNumeric() const;
76     /*
77      * Obtains the network registration status of the device.
78      * @return Returns the network registration status
79      */
80     RegServiceState GetRegStatus() const;
81     /*
82      * Checks whether this device is allowed to make emergency calls only.
83      * @return Returns the device emergency calls state.
84      */
85     bool IsEmergency() const;
86     /*
87      * Checks whether the device is roaming.
88      * @return Returns roaming state.
89      */
90     bool IsRoaming() const;
91     std::string ToString() const;
92     /*
93      * Obtains the NSA network registration status of the device.
94      * @return Returns nsa state.
95      */
96     NrState GetNrState() const;
97     /*
98      * Obtains the radio access technology after config conversion.
99      * @return Returns access technology.
100      */
101     RadioTech GetCfgTech() const;
102     /*
103      * Obtains the radio Access technology after config conversion.
104      * @return Returns last access technology.
105      */
106     RadioTech GetLastCfgTech() const;
107 
108 private:
109     bool isEmergency_;
110     OperatorInformation psOperatorInfo_;
111     OperatorInformation csOperatorInfo_;
112     RoamingType csRoaming_;
113     RoamingType psRoaming_;
114     RegServiceState psRegStatus_;
115     RegServiceState csRegStatus_;
116     RadioTech psRadioTech_;
117     RadioTech lastPsRadioTech_;
118     RadioTech lastCfgTech_;
119     RadioTech csRadioTech_;
120     RadioTech cfgTech_;
121     NrState nrState_;
122     bool ReadParcelString(Parcel &parcel);
123     bool ReadParcelInt(Parcel &parcel);
124 };
125 } // namespace Telephony
126 } // namespace OHOS
127 #endif // NETWORK_STATE_H
128