• 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 OHOS_CELL_INFORMATION_H
17 #define OHOS_CELL_INFORMATION_H
18 
19 #include "parcel.h"
20 
21 namespace OHOS {
22 namespace Telephony {
23 class CellInformation : public Parcelable {
24 public:
25     static const int32_t MAX_CELL_NUM = 10;
26     enum class CellType {
27         CELL_TYPE_NONE = 0,
28         CELL_TYPE_GSM,
29         CELL_TYPE_CDMA,
30         CELL_TYPE_WCDMA,
31         CELL_TYPE_TDSCDMA,
32         CELL_TYPE_LTE,
33         CELL_TYPE_NR
34     };
35     CellInformation() = default;
36     virtual ~CellInformation() = default;
37     virtual bool Marshalling(Parcel &parcel) const = 0;
38     static CellInformation *Unmarshalling(Parcel &parcel);
39     virtual bool ReadFromParcel(Parcel &parcel) = 0;
40     virtual CellInformation::CellType GetNetworkType() const = 0;
41     virtual std::string ToString() const = 0;
42     void Init(int32_t mcc, int32_t mnc, int32_t cellId);
43 
44     virtual int32_t GetCellId() const;
45     virtual std::string GetMcc() const;
46     virtual std::string GetMnc() const;
47     virtual uint64_t GetTimeStamp() const;
48     virtual int32_t GetSignalLevel() const;
49     virtual int32_t GetSignalIntensity() const;
50     virtual bool GetIsCamped() const;
51     virtual void SetIsCamped(bool isCamped);
52     virtual void SetSignalIntensity(int32_t signalIntensity);
53     virtual void SetSignalLevel(int32_t signalLevel);
54 
55 protected:
56     std::string mcc_ = "";
57     std::string mnc_ = "";
58     int32_t cellId_ = 0;
59     uint64_t timeStamp_ = 0;
60     int32_t signalIntensity_ = 0;
61     int32_t signalLevel_ = 0;
62     bool isCamped_ = false;
63 };
64 
65 class GsmCellInformation : public CellInformation {
66 public:
67     GsmCellInformation() = default;
68     virtual ~GsmCellInformation() = default;
69     bool Marshalling(Parcel &parcel) const override;
70     static GsmCellInformation *Unmarshalling(Parcel &parcel);
71     bool ReadFromParcel(Parcel &parcel) override;
72     CellInformation::CellType GetNetworkType() const override;
73     std::string ToString() const override;
74     void SetGsmParam(int32_t bsic, int32_t lac, int32_t arfcn);
75     void UpdateLocation(int32_t cellId, int32_t lac);
76     GsmCellInformation(const GsmCellInformation &gsmCell);
77     GsmCellInformation &operator=(const GsmCellInformation &gsmCell);
78     bool operator==(const GsmCellInformation &other) const;
79     int32_t GetLac() const;
80     int32_t GetBsic() const;
81     int32_t GetArfcn() const;
82 private:
83     int32_t lac_ = 0;
84     int32_t bsic_ = 0;
85     int32_t arfcn_ = 0;
86 };
87 
88 class LteCellInformation : public CellInformation {
89 public:
90     LteCellInformation() = default;
91     virtual ~LteCellInformation() = default;
92     bool Marshalling(Parcel &parcel) const override;
93     static LteCellInformation *Unmarshalling(Parcel &parcel);
94     bool ReadFromParcel(Parcel &parcel) override;
95     CellInformation::CellType GetNetworkType() const override;
96     std::string ToString() const override;
97     void SetLteParam(int32_t pci, int32_t tac, int32_t arfcn);
98     LteCellInformation(const LteCellInformation &lteCell);
99     LteCellInformation &operator=(const LteCellInformation &lteCell);
100     bool operator==(const LteCellInformation &other) const;
101     void UpdateLocation(int32_t cellId, int32_t tac);
102     int32_t GetPci() const;
103     int32_t GetTac() const;
104     int32_t GetArfcn() const;
105 private:
106     int32_t pci_ = 0;
107     int32_t tac_ = 0;
108     int32_t earfcn_ = 0;
109 };
110 
111 class WcdmaCellInformation : public CellInformation {
112 public:
113     WcdmaCellInformation() = default;
114     virtual ~WcdmaCellInformation() = default;
115     bool Marshalling(Parcel &parcel) const override;
116     static WcdmaCellInformation *Unmarshalling(Parcel &parcel);
117     bool ReadFromParcel(Parcel &parcel) override;
118     CellInformation::CellType GetNetworkType() const override;
119     std::string ToString() const override;
120     void SetWcdmaParam(int32_t psc, int32_t lac, int32_t arfcn);
121     WcdmaCellInformation(const WcdmaCellInformation &wcdmaCell);
122     WcdmaCellInformation &operator=(const WcdmaCellInformation &wcdmaCell);
123     bool operator==(const WcdmaCellInformation &other) const;
124     void UpdateLocation(int32_t cellId, int32_t lac);
125     int32_t GetPsc() const;
126     int32_t GetLac() const;
127     int32_t GetArfcn() const;
128 private:
129     int32_t lac_ = 0;
130     int32_t psc_ = 0;
131     int32_t uarfcn_ = 0;
132 };
133 
134 class TdscdmaCellInformation : public CellInformation {
135 public:
136     TdscdmaCellInformation() = default;
137     virtual ~TdscdmaCellInformation() = default;
138     bool Marshalling(Parcel &parcel) const override;
139     static TdscdmaCellInformation *Unmarshalling(Parcel &parcel);
140     bool ReadFromParcel(Parcel &parcel) override;
141     CellInformation::CellType GetNetworkType() const override;
142     std::string ToString() const override;
143     void SetTdscdmaParam(int32_t psc, int32_t lac, int32_t arfcn);
144     TdscdmaCellInformation(const TdscdmaCellInformation &wcdmaCell);
145     TdscdmaCellInformation &operator=(const TdscdmaCellInformation &wcdmaCell);
146     bool operator==(const TdscdmaCellInformation &other) const;
147     void UpdateLocation(int32_t cellId, int32_t lac);
148     int32_t GetCpid() const;
149     int32_t GetLac() const;
150     int32_t GetArfcn() const;
151 private:
152     int32_t lac_ = 0;
153     int32_t cpid_ = 0;
154     int32_t uarfcn_ = 0;
155 };
156 
157 class CdmaCellInformation : public CellInformation {
158 public:
159     CdmaCellInformation() = default;
160     virtual ~CdmaCellInformation() = default;
161     bool Marshalling(Parcel &parcel) const override;
162     static CdmaCellInformation *Unmarshalling(Parcel &parcel);
163     bool ReadFromParcel(Parcel &parcel) override;
164     CellInformation::CellType GetNetworkType() const override;
165     std::string ToString() const override;
166     void SetCdmaParam(int32_t baseId, int32_t latitude, int32_t longitude, int32_t nid, int32_t sid);
167     CdmaCellInformation(const CdmaCellInformation &cdmaCell);
168     CdmaCellInformation &operator=(const CdmaCellInformation &cdmaCell);
169     bool operator==(const CdmaCellInformation &other) const;
170     void UpdateLocation(int32_t baseId, int32_t latitude, int32_t longitude);
171     int32_t GetBaseId() const;
172     int32_t GetLatitude() const;
173     int32_t GetLongitude() const;
174     int32_t GetNid() const;
175     int32_t GetSid() const;
176 
177 private:
178     int32_t baseId_ = 0;
179     int32_t latitude_ = 0;
180     int32_t longitude_ = 0;
181     int32_t nid_ = 0;
182     int32_t sid_ = 0;
183 };
184 
185 class NrCellInformation : public CellInformation {
186 public:
187     NrCellInformation() = default;
188     virtual ~NrCellInformation() = default;
189     bool Marshalling(Parcel &parcel) const override;
190     static NrCellInformation *Unmarshalling(Parcel &parcel);
191     bool ReadFromParcel(Parcel &parcel) override;
192     CellInformation::CellType GetNetworkType() const override;
193     std::string ToString() const override;
194     void SetNrParam(int32_t nrArfcn, int32_t pci, int32_t tac, int64_t nci);
195     NrCellInformation(const NrCellInformation &nrCell);
196     NrCellInformation &operator=(const NrCellInformation &nrCell);
197     bool operator==(const NrCellInformation &other) const;
198     void UpdateLocation(int32_t pci, int32_t tac);
199     int32_t GetArfcn() const;
200     int32_t GetPci() const;
201     int32_t GetTac() const;
202     int64_t GetNci() const;
203 private:
204     int32_t nrArfcn_ = 0;
205     int32_t pci_ = 0;
206     int32_t tac_ = 0;
207     int64_t nci_ = 0;
208 };
209 } // namespace Telephony
210 } // namespace OHOS
211 #endif // OHOS_CELL_INFORMATION_H