1 /*
2  * Copyright (C) 2021-2024 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 TEL_RIL_NETWORK_H
17 #define TEL_RIL_NETWORK_H
18 
19 #include "tel_ril_network_parcel.h"
20 #include "tel_ril_base.h"
21 
22 namespace OHOS {
23 namespace Telephony {
24 class TelRilNetwork : public TelRilBase {
25 public:
26     TelRilNetwork(int32_t slotId, sptr<HDI::Ril::V1_3::IRil> rilInterface,
27         std::shared_ptr<ObserverHandler> observerHandler, std::shared_ptr<TelRilHandler> handler);
28     ~TelRilNetwork() = default;
29 
30     // send  command
31     int32_t GetSignalStrength(const AppExecFwk::InnerEvent::Pointer &response);
32     int32_t GetCsRegStatus(const AppExecFwk::InnerEvent::Pointer &response);
33     int32_t GetPsRegStatus(const AppExecFwk::InnerEvent::Pointer &response);
34     int32_t GetOperatorInfo(const AppExecFwk::InnerEvent::Pointer &response);
35     int32_t GetNetworkSearchInformation(const AppExecFwk::InnerEvent::Pointer &response);
36     int32_t GetNetworkSelectionMode(const AppExecFwk::InnerEvent::Pointer &response);
37     int32_t SetNetworkSelectionMode(
38         int32_t automaticFlag, std::string oper, const AppExecFwk::InnerEvent::Pointer &response);
39     int32_t SetPreferredNetwork(int32_t preferredNetworkType, const AppExecFwk::InnerEvent::Pointer &response);
40     int32_t GetPreferredNetwork(const AppExecFwk::InnerEvent::Pointer &response);
41     int32_t GetCellInfoList(const AppExecFwk::InnerEvent::Pointer &response);
42     int32_t GetCurrentCellInfo(const AppExecFwk::InnerEvent::Pointer &response);
43     int32_t GetPhysicalChannelConfig(const AppExecFwk::InnerEvent::Pointer &response);
44     int32_t SetLocateUpdates(RegNotifyMode mode, const AppExecFwk::InnerEvent::Pointer &response);
45     int32_t SetNotificationFilter(int32_t newFilter, const AppExecFwk::InnerEvent::Pointer &response);
46     int32_t SetDeviceState(
47         int32_t deviceStateType, bool deviceStateOn, const AppExecFwk::InnerEvent::Pointer &response);
48     int32_t SetNrOptionMode(int32_t mode, const AppExecFwk::InnerEvent::Pointer &response);
49     int32_t GetNrOptionMode(const AppExecFwk::InnerEvent::Pointer &response);
50     int32_t GetRrcConnectionState(const AppExecFwk::InnerEvent::Pointer &response);
51     int32_t GetNrSsbId(const AppExecFwk::InnerEvent::Pointer &response);
52 
53     // ril unsol
54     int32_t SignalStrengthUpdated(const HDI::Ril::V1_1::Rssi &rssi);
55     int32_t NetworkCsRegStatusUpdated(const HDI::Ril::V1_1::CsRegStatusInfo &csRegStatusInfo);
56     int32_t NetworkPsRegStatusUpdated(const HDI::Ril::V1_1::PsRegStatusInfo &psRegStatusInfo);
57     int32_t NetworkTimeZoneUpdated(const std::string &timeZoneStr);
58     int32_t NetworkTimeUpdated(const std::string &timeStr);
59     int32_t NetworkPhyChnlCfgUpdated(const HDI::Ril::V1_1::ChannelConfigInfoList &channelConfigInfoList);
60     int32_t NetworkCurrentCellUpdated(const HDI::Ril::V1_1::CellListCurrentInfo &cellListCurrentInfo);
61     int32_t NetworkCurrentCellUpdated_1_1(const HDI::Ril::V1_1::CellListCurrentInfo_1_1 &cellListCurrentInformation);
62     int32_t NetworkCurrentCellUpdated_1_2(const HDI::Ril::V1_2::CellListCurrentInfo_1_2 &cellListCurrentInformation);
63     int32_t ResidentNetworkUpdated(const std::string &plmn);
64 
65     int32_t GetSignalStrengthResponse(
66         const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::Rssi &rssi);
67     int32_t GetCsRegStatusResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
68         const HDI::Ril::V1_1::CsRegStatusInfo &csRegStatusInfo);
69     int32_t GetPsRegStatusResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
70         const HDI::Ril::V1_1::PsRegStatusInfo &psRegStatusInfo);
71     int32_t GetOperatorInfoResponse(
72         const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const HDI::Ril::V1_1::OperatorInfo &operatorInfo);
73     int32_t GetNetworkSearchInformationResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
74         const HDI::Ril::V1_1::AvailableNetworkList &availableNetworkList);
75     int32_t GetNetworkSelectionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
76         const HDI::Ril::V1_1::SetNetworkModeInfo &setNetworkModeInfo);
77     int32_t SetNetworkSelectionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo);
78     int32_t GetNeighboringCellInfoListResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
79         const HDI::Ril::V1_1::CellListNearbyInfo &cellInfoList);
80     int32_t GetNeighboringCellInfoListResponse_1_2(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
81         const HDI::Ril::V1_2::CellListNearbyInfo_1_2 &cellInfoList);
82     int32_t GetCurrentCellInfoResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
83         const HDI::Ril::V1_1::CellListCurrentInfo &cellInfoList);
84     int32_t GetCurrentCellInfoResponse_1_1(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
85         const HDI::Ril::V1_1::CellListCurrentInfo_1_1 &cellListCurrentInformation);
86     int32_t GetCurrentCellInfoResponse_1_2(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
87         const HDI::Ril::V1_2::CellListCurrentInfo_1_2 &cellListCurrentInformation);
88     int32_t SetPreferredNetworkResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo);
89     int32_t GetPreferredNetworkResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
90         const HDI::Ril::V1_1::PreferredNetworkTypeInfo &preferredNetworkTypeInfo);
91     int32_t GetPhysicalChannelConfigResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
92         const HDI::Ril::V1_1::ChannelConfigInfoList &channelConfigInfoList);
93     int32_t SetLocateUpdatesResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo);
94     int32_t SetNotificationFilterResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo);
95     int32_t SetDeviceStateResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo);
96     int32_t SetNrOptionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo);
97     int32_t GetNrOptionModeResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, int32_t mode);
98     int32_t GetRrcConnectionStateResponse(
99         const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, int32_t rrcConnectionState);
100     int32_t GetRrcConnectionStateUpdated(int32_t state);
101     int32_t GetNrSsbIdResponse(const HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo,
102         const HDI::Ril::V1_2::NrCellSsbIds &nrCellSsbIds);
103 
104 private:
105     void BuildSignalStrength(std::shared_ptr<Rssi> signalStrength, const HDI::Ril::V1_1::Rssi &rssi);
106     void BuildCsRegStatusInfo(
107         std::shared_ptr<CsRegStatusInfo> regStatusInfo, const HDI::Ril::V1_1::CsRegStatusInfo &csRegStatusInfo);
108     void BuildPsRegStatusInfo(
109         std::shared_ptr<PsRegStatusResultInfo> regStatusInfo, const HDI::Ril::V1_1::PsRegStatusInfo &psRegStatusInfo);
110     void BuildOperatorInfo(
111         std::shared_ptr<OperatorInfoResult> operatorInfoResult, const HDI::Ril::V1_1::OperatorInfo &operatorInfo);
112     void BuildAvailableNetworkList(std::shared_ptr<AvailableNetworkList> availableNetworkInfos,
113         const HDI::Ril::V1_1::AvailableNetworkList &availableNetworkList);
114     void BuildNetworkModeInfo(std::shared_ptr<SetNetworkModeInfo> networkModeInfo,
115         const HDI::Ril::V1_1::SetNetworkModeInfo &setNetworkModeInfo);
116     void BuildNeighboringCellInfoList(std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo,
117         const HDI::Ril::V1_1::CellListNearbyInfo &cellInfoList);
118     void FillGsmCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info);
119     void FillLteCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info);
120     void FillWcdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info);
121     void FillCdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info);
122     void FillTdscdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info);
123     void FillNrCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info);
124     void FillCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_1::CellNearbyInfo &info);
125     void BuildNeighboringCellInfoList(std::shared_ptr<CellListNearbyInfo> cellListNearbyInfo,
126         const HDI::Ril::V1_2::CellListNearbyInfo_1_2 &cellInfoList);
127     void FillCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info);
128     void FillGsmCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info);
129     void FillLteCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info);
130     void FillWcdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info);
131     void FillCdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info);
132     void FillTdscdmaCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info);
133     void FillNrCellNearbyInfo(CellNearbyInfo &cellInfo, const HDI::Ril::V1_2::CellNearbyInfo_1_2 &info);
134     void BuildCurrentCellInfoList(std::shared_ptr<CellListCurrentInfo> currentCellList,
135         const HDI::Ril::V1_1::CellListCurrentInfo &cellInfoList);
136     void FillCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info);
137     void FillGsmCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info);
138     void FillLteCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info);
139     void FillWcdmaCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info);
140     void FillCdmaCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info);
141     void FillTdscdmaCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info);
142     void FillNrCurrentCellInfo(CurrentCellInfo &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo &info);
143     void BuildCurrentCellInformationList(std::shared_ptr<CellListCurrentInformation> currentCellList,
144         const HDI::Ril::V1_1::CellListCurrentInfo_1_1 &cellInfoList);
145     void FillCurrentCellInformation(CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info);
146     void FillGsmCurrentCellInformation(
147         CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info);
148     void FillLteCurrentCellInformation(
149         CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info);
150     void FillWcdmaCurrentCellInformation(
151         CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info);
152     void FillCdmaCurrentCellInformation(
153         CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info);
154     void FillTdscdmaCurrentCellInformation(
155         CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info);
156     void FillNrCurrentCellInformation(
157         CurrentCellInformation &cellInfo, const HDI::Ril::V1_1::CurrentCellInfo_1_1 &info);
158     void BuildCurrentCellInformationList(std::shared_ptr<CellListCurrentInformation> currentCellList,
159         const HDI::Ril::V1_2::CellListCurrentInfo_1_2 &cellInfoList);
160     void FillCurrentCellInformation(CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info);
161     void FillGsmCurrentCellInformation(
162         CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info);
163     void FillLteCurrentCellInformation(
164         CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info);
165     void FillWcdmaCurrentCellInformation(
166         CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info);
167     void FillCdmaCurrentCellInformation(
168         CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info);
169     void FillTdscdmaCurrentCellInformation(
170         CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info);
171     void FillNrCurrentCellInformation(
172         CurrentCellInformation &cellInfo, const HDI::Ril::V1_2::CurrentCellInfo_1_2 &info);
173     void BuildChannelConfigInfoList(std::shared_ptr<ChannelConfigInfoList> channelConfigList,
174         const HDI::Ril::V1_1::ChannelConfigInfoList &channelConfigInfoList);
175 
176 private:
177     const int32_t MAX_NBCELL_COUNT = 4;
178 };
179 } // namespace Telephony
180 } // namespace OHOS
181 #endif // TEL_RIL_NETWORK_H
182