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