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 OHOS_HRIL_NETWORK_H 17 #define OHOS_HRIL_NETWORK_H 18 19 #include "hril_base.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 class HRilNetwork : public HRilBase { 24 public: 25 HRilNetwork(int32_t slotId); 26 virtual ~HRilNetwork() = default; 27 28 int32_t GetSignalStrength(int32_t serialId); 29 int32_t GetCsRegStatus(int32_t serialId); 30 int32_t GetPsRegStatus(int32_t serialId); 31 int32_t GetOperatorInfo(int32_t serialId); 32 int32_t GetNeighboringCellInfoList(int32_t serialId); 33 int32_t GetCurrentCellInfo(int32_t serialId); 34 int32_t GetNetworkSearchInformation(int32_t serialId); 35 int32_t GetNetworkSelectionMode(int32_t serialId); 36 int32_t SetNetworkSelectionMode(int32_t serialId, const HDI::Ril::V1_1::SetNetworkModeInfo &networkModeInfo); 37 int32_t SetPreferredNetwork(int32_t serialId, int32_t preferredNetworkType); 38 int32_t GetPreferredNetwork(int32_t serialId); 39 int32_t GetPhysicalChannelConfig(int32_t serialId); 40 int32_t SetLocateUpdates(int32_t serialId, const HDI::Ril::V1_1::RilRegNotifyMode mode); 41 int32_t SetNotificationFilter(int32_t serialId, int32_t newFilter); 42 int32_t SetDeviceState(int32_t serialId, int32_t deviceStateType, int32_t deviceStateOn); 43 int32_t SetNrOptionMode(int32_t serialId, int32_t mode); 44 int32_t GetNrOptionMode(int32_t serialId); 45 int32_t GetRrcConnectionState(int32_t serialId); 46 int32_t GetNrSsbId(int32_t serialId); 47 48 int32_t GetSignalStrengthResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 49 const void *response, size_t responseLen); 50 int32_t GetCsRegStatusResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 51 const void *response, size_t responseLen); 52 int32_t GetPsRegStatusResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 53 const void *response, size_t responseLen); 54 int32_t GetOperatorInfoResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 55 const void *response, size_t responseLen); 56 int32_t GetNetworkSearchInformationResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 57 const void *response, size_t responseLen); 58 int32_t GetNetworkSelectionModeResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 59 const void *response, size_t responseLen); 60 int32_t SetNetworkSelectionModeResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 61 const void *response, size_t responseLen); 62 int32_t SetPreferredNetworkResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 63 const void *response, size_t responseLen); 64 int32_t GetPreferredNetworkResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 65 const void *response, size_t responseLen); 66 int32_t GetNeighboringCellInfoListResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 67 const void *response, size_t responseLen); 68 int32_t GetNeighboringCellInfoListResponse_1_2(int32_t requestNum, 69 HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, const void *response, size_t responseLen); 70 int32_t GetCurrentCellInfoResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 71 const void *response, size_t responseLen); 72 int32_t GetCurrentCellInfoResponse_1_1(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 73 const void *response, size_t responseLen); 74 int32_t GetCurrentCellInfoResponse_1_2(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 75 const void *response, size_t responseLen); 76 int32_t GetPhysicalChannelConfigResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 77 const void *response, size_t responseLen); 78 int32_t SetLocateUpdatesResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 79 const void *response, size_t responseLen); 80 int32_t SetNotificationFilterResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 81 const void *response, size_t responseLen); 82 int32_t SetDeviceStateResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 83 const void *response, size_t responseLen); 84 int32_t SetNrOptionModeResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 85 const void *response, size_t responseLen); 86 int32_t GetNrOptionModeResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 87 const void *response, size_t responseLen); 88 int32_t GetRrcConnectionStateResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 89 const void *response, size_t responseLen); 90 int32_t GetNrSsbIdResponse(int32_t requestNum, HDI::Ril::V1_1::RilRadioResponseInfo &responseInfo, 91 const void *response, size_t responseLen); 92 93 int32_t NetworkCsRegStatusUpdated(int32_t indType, HRilErrNumber error, const void *response, size_t responseLen); 94 int32_t NetworkPsRegStatusUpdated(int32_t indType, HRilErrNumber error, const void *response, size_t responseLen); 95 int32_t SignalStrengthUpdated(int32_t indType, HRilErrNumber error, const void *response, size_t responseLen); 96 int32_t NetworkTimeUpdated(int32_t indType, HRilErrNumber error, const void *response, size_t responseLen); 97 int32_t NetworkTimeZoneUpdated(int32_t indType, HRilErrNumber error, const void *response, size_t responseLen); 98 int32_t NetworkPhyChnlCfgUpdated( 99 int32_t indType, const HRilErrNumber error, const void *response, size_t responseLen); 100 int32_t NetworkCurrentCellUpdated( 101 int32_t indType, const HRilErrNumber error, const void *response, size_t responseLen); 102 int32_t GetRrcConnectionStateUpdated( 103 int32_t indType, const HRilErrNumber error, const void *response, size_t responseLen); 104 int32_t NetworkCurrentCellUpdated_1_1( 105 int32_t indType, const HRilErrNumber error, const void *response, size_t responseLen); 106 int32_t NetworkCurrentCellUpdated_1_2( 107 int32_t indType, const HRilErrNumber error, const void *response, size_t responseLen); 108 void RegisterNetworkFuncs(const HRilNetworkReq *networkFuncs); 109 bool IsNetworkRespOrNotify(uint32_t code); 110 int32_t ResidentNetworkUpdated(int32_t indType, HRilErrNumber error, const void *response, size_t responseLen); 111 112 private: 113 void AddNotificationToMap(); 114 void AddBasicHandlerToMap(); 115 void AddNetworkSearchHandlerToMap(); 116 void ExchangeRilRssiToHdf(const void *response, HDI::Ril::V1_1::Rssi &rssi); 117 void BuildOperatorList( 118 HDI::Ril::V1_1::AvailableNetworkList &availableNetworkList, const void *response, size_t responseLen); 119 // V1_0 120 void FillCellNearbyInfo(HDI::Ril::V1_1::CellNearbyInfo &cellInfo, const CellInfo *cellPtr); 121 void FillCellNearbyInfoTdscdma(HDI::Ril::V1_1::CellNearbyInfo &cellInfo, const CellInfo *hrilCellPtr); 122 void FillCellNearbyInfoCdma(HDI::Ril::V1_1::CellNearbyInfo &cellInfo, const CellInfo *hrilCellPtr); 123 int32_t BuildNeighboringCellList(HDI::Ril::V1_1::CellListNearbyInfo &cellInfoList, 124 const void *response, size_t responseLen); 125 // V1_2 126 void FillCellNearbyInfo(HDI::Ril::V1_2::CellNearbyInfo_1_2 &cellInfo, const CellInfo *cellPtr); 127 void FillCellNearbyInfoTdscdma(HDI::Ril::V1_2::CellNearbyInfo_1_2 &cellInfo, const CellInfo *hrilCellPtr); 128 void FillCellNearbyInfoCdma(HDI::Ril::V1_2::CellNearbyInfo_1_2 &cellInfo, const CellInfo *hrilCellPtr); 129 int32_t BuildNeighboringCellList( 130 HDI::Ril::V1_2::CellListNearbyInfo_1_2 &cellInfoList, const void *response, size_t responseLen); 131 // V1_0 132 void FillCellInfoType(HDI::Ril::V1_1::CurrentCellInfo &cellInfo, const CurrentCellInfoVendor *hrilCellInfoVendor); 133 void FillCurrentCellInfo(HDI::Ril::V1_1::CurrentCellInfo &cellInfo, const CurrentCellInfoVendor *cellInfoVendor); 134 int32_t BuildCurrentCellList( 135 HDI::Ril::V1_1::CellListCurrentInfo &cellInfoList, const void *response, size_t responseLen); 136 // V1_1 137 void FillCellInfoType( 138 HDI::Ril::V1_1::CurrentCellInfo_1_1 &cellInfo, const CurrentCellInfoVendor *hrilCellInfoVendor); 139 void FillCurrentCellInfo( 140 HDI::Ril::V1_1::CurrentCellInfo_1_1 &cellInfo, const CurrentCellInfoVendor *cellInfoVendor); 141 int32_t BuildCurrentCellList( 142 HDI::Ril::V1_1::CellListCurrentInfo_1_1 &cellInfoList, const void *response, size_t responseLen); 143 // V1_2 144 void FillCellInfoType( 145 HDI::Ril::V1_2::CurrentCellInfo_1_2 &cellInfo, const CurrentCellInfoVendor *hrilCellInfoVendor); 146 void FillCurrentCellInfo( 147 HDI::Ril::V1_2::CurrentCellInfo_1_2 &cellInfo, const CurrentCellInfoVendor *cellInfoVendor); 148 int32_t BuildCurrentCellList( 149 HDI::Ril::V1_2::CellListCurrentInfo_1_2 &cellInfoList, const void *response, size_t responseLen); 150 int32_t BuildNrCellSsbIdsInfo(HDI::Ril::V1_2::NrCellSsbIds &nrCellSsbIds, const void *response, size_t responseLen); 151 bool IsNetworkResponse(uint32_t code); 152 bool IsNetworkNotification(uint32_t code); 153 154 private: 155 const HRilNetworkReq *networkFuncs_ = nullptr; 156 const int32_t SCELL_SSB_LIST = 8; 157 const int32_t NBCELL_SSB_LIST = 4; 158 const int32_t MAX_NBCELL_COUNT = 4; 159 }; 160 } // namespace Telephony 161 } // namespace OHOS 162 #endif // OHOS_HRIL_NETWORK_H 163