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