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