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