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_SEARCH_INCLUDE_CELL_INFO_H 17 #define NETWORK_SEARCH_INCLUDE_CELL_INFO_H 18 19 #include "event_handler.h" 20 #include "hril_network_parcel.h" 21 #include "cell_information.h" 22 #include "signal_information.h" 23 #include "network_state.h" 24 #include "cell_location.h" 25 26 namespace OHOS { 27 namespace Telephony { 28 class NetworkSearchManager; 29 class CellInfo { 30 public: 31 CellInfo(std::weak_ptr<NetworkSearchManager> networkSearchManager, int32_t slotId); 32 virtual ~CellInfo() = default; 33 static void InitCellSignalBar(const int32_t bar = 5); 34 void GetCellInfoList(std::vector<sptr<CellInformation>> &cellInfo); 35 void ProcessNeighboringCellInfo(const AppExecFwk::InnerEvent::Pointer &event); 36 void ProcessCurrentCellInfo(const AppExecFwk::InnerEvent::Pointer &event); 37 void ClearCellInfoList(); 38 void UpdateCellLocation(int32_t techType, int32_t cellId, int32_t lac); 39 sptr<CellLocation> GetCellLocation(); 40 41 private: 42 bool ProcessCellLocation( 43 sptr<CellInformation> &cell, CellInformation::CellType type, int32_t cellId, int32_t lac); 44 bool ProcessNeighboringCellGsm(CellNearbyInfo *cellInfo); 45 bool ProcessNeighboringCellLte(CellNearbyInfo *cellInfo); 46 bool ProcessNeighboringCellWcdma(CellNearbyInfo *cellInfo); 47 bool ProcessNeighboringCellCdma(CellNearbyInfo *cellInfo); 48 bool ProcessNeighboringCellTdscdma(CellNearbyInfo *cellInfo); 49 bool ProcessNeighboringCellNr(CellNearbyInfo *cellInfo); 50 bool ProcessCurrentCell(CurrentCellInfo *cellInfo); 51 bool ProcessCurrentCellWcdma(CurrentCellInfo *cellInfo); 52 bool ProcessCurrentCellLte(CurrentCellInfo *cellInfo); 53 bool ProcessCurrentCellGsm(CurrentCellInfo *cellInfo); 54 bool ProcessCurrentCellCdma(CurrentCellInfo *cellInfo); 55 bool ProcessCurrentCellTdscdma(CurrentCellInfo *cellInfo); 56 bool ProcessCurrentCellNr(CurrentCellInfo *cellInfo); 57 int32_t GetCurrentSignalLevelGsm(int32_t rxlev); 58 int32_t GetCurrentSignalLevelLte(int32_t rsrp); 59 int32_t GetCurrentSignalLevelWcdma(int32_t rscp); 60 int32_t GetCurrentSignalLevelCdma(int32_t pilotStrength); 61 int32_t GetCurrentSignalLevelTdscdma(int32_t rscp); 62 void AddCellInformation(sptr<CellInformation> &cellInfo, std::vector<sptr<CellInformation>> &cellInfos); 63 void NotifyCellInfoUpdated() const; 64 void UpdateSignalLevel(sptr<CellInformation> &cell, CellInformation::CellType cellType); 65 CellInformation::CellType ConvertToCellType(SignalInformation::NetworkType signalType) const; 66 CellInformation::CellType ConvertTechToCellType(RadioTech techType) const; 67 CellInformation::CellType ConvertRatToCellType(int ratType) const; 68 std::mutex mutex_; 69 std::vector<sptr<CellInformation>> cellInfos_; 70 sptr<CellInformation> currentCellInfo_ = nullptr; 71 std::weak_ptr<NetworkSearchManager> networkSearchManager_; 72 73 using CallInfoFunc = bool (CellInfo::*)(CellNearbyInfo *); 74 static const std::map<RatType, CallInfoFunc> memberFuncMap_; 75 int32_t slotId_ = 0; 76 static int32_t signalBar_; 77 }; 78 } // namespace Telephony 79 } // namespace OHOS 80 #endif // NETWORK_SEARCH_INCLUDE_CELL_INFO_H