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_LOCATION_H 17 #define OHOS_CELL_LOCATION_H 18 19 #include "parcel.h" 20 #include "cell_information.h" 21 22 namespace OHOS { 23 namespace Telephony { 24 class CellLocation : public Parcelable { 25 public: 26 enum class CellType { 27 CELL_TYPE_NONE = 0, 28 CELL_TYPE_GSM, 29 CELL_TYPE_CDMA, 30 }; 31 CellLocation() = default; 32 virtual ~CellLocation() = default; 33 virtual CellLocation::CellType GetCellLocationType() const = 0; 34 virtual bool Marshalling(Parcel &parcel) const = 0; 35 static CellLocation *Unmarshalling(Parcel &parcel); 36 virtual bool ReadFromParcel(Parcel &parcel) = 0; 37 38 virtual uint64_t GetTimeStamp() const; 39 protected: 40 uint64_t timeStamp_ = 0; 41 }; 42 43 class GsmCellLocation : public CellLocation { 44 public: 45 GsmCellLocation() = default; 46 virtual ~GsmCellLocation() = default; 47 bool Marshalling(Parcel &parcel) const override; 48 static GsmCellLocation *Unmarshalling(Parcel &parcel); 49 bool ReadFromParcel(Parcel &parcel) override; 50 CellLocation::CellType GetCellLocationType() const override; 51 void SetGsmParam(int32_t cellId, int32_t lac, int32_t psc = 0); 52 /** 53 * @return gsm cell id, 0 if unknown, 0xffff max legal value 54 */ 55 int32_t GetCellId() const; 56 /** 57 * @return gsm location area code, 0 if unknown, 0xffff max legal value 58 */ 59 int32_t GetLac() const; 60 /** 61 * On a UMTS network, return the primary scrambling code 62 * cell. 63 * @return primary scrambling code for WCDMA, 0 if unknown or GSM 64 */ 65 int32_t GetPsc() const; 66 67 private: 68 int32_t cellId_ = 0; 69 int32_t lac_ = 0; 70 int32_t psc_ = 0; 71 }; 72 73 class CdmaCellLocation : public CellLocation { 74 public: 75 CdmaCellLocation() = default; 76 virtual ~CdmaCellLocation() = default; 77 bool Marshalling(Parcel &parcel) const override; 78 static CdmaCellLocation *Unmarshalling(Parcel &parcel); 79 bool ReadFromParcel(Parcel &parcel) override; 80 CellLocation::CellType GetCellLocationType() const override; 81 void SetCdmaParam(int32_t baseId, int32_t latitude, int32_t longitude, int32_t nid, int32_t sid); 82 83 int32_t GetBaseId() const; 84 int32_t GetLatitude() const; 85 int32_t GetLongitude() const; 86 int32_t GetNid() const; 87 int32_t GetSid() const; 88 private: 89 int32_t baseId_ = 0; 90 int32_t latitude_ = 0; 91 int32_t longitude_ = 0; 92 int32_t nid_ = 0; 93 int32_t sid_ = 0; 94 }; 95 } // namespace Telephony 96 } // namespace OHOS 97 #endif // OHOS_CELL_LOCATION_H