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 IMPL_CORE_MANAGER_INNER_H 17 #define IMPL_CORE_MANAGER_INNER_H 18 19 #include <unistd.h> 20 #include <thread> 21 22 #include "i_network_search.h" 23 #include "i_sim_manager.h" 24 #include "i_tel_ril_manager.h" 25 #include "telephony_errors.h" 26 #include "telephony_types.h" 27 28 namespace OHOS { 29 namespace Telephony { 30 class CoreManagerInner final { 31 public: 32 ~CoreManagerInner() = default; 33 DISALLOW_COPY_AND_MOVE(CoreManagerInner); 34 static CoreManagerInner &GetInstance(); 35 void OnInit(std::shared_ptr<INetworkSearch> networkSearchManager, 36 std::shared_ptr<Telephony::ISimManager> simManager, std::shared_ptr<ITelRilManager> telRilManager); 37 void SetTelRilMangerObj(std::shared_ptr<ITelRilManager> telRilManager); 38 int32_t RegisterCoreNotify( 39 int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler, int what, int32_t *obj); 40 int32_t UnRegisterCoreNotify( 41 int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &observerCallBack, int what); 42 void RegisterCellularDataObject(const sptr<NetworkSearchCallBackBase> &callback); 43 void UnRegisterCellularDataObject(const sptr<NetworkSearchCallBackBase> &callback); 44 void RegisterCellularCallObject(const sptr<NetworkSearchCallBackBase> &callback); 45 void UnRegisterCellularCallObject(const sptr<NetworkSearchCallBackBase> &callback); 46 bool IsInitFinished(void); 47 bool IsInitFinishedForTelRil(void); 48 int32_t GetDefaultSlotId(void); 49 int32_t GetMaxSimCount(void); 50 51 /******************** telRilManager start *******************/ 52 int32_t SetRadioState( 53 int32_t slotId, int32_t eventId, int fun, int rst, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 54 int32_t GetRadioState( 55 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 56 int32_t ShutDown(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 57 int32_t GetRadioCapability( 58 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 59 int32_t Dial(int32_t slotId, int32_t eventId, std::string address, int clirMode, 60 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 61 int32_t Reject(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 62 int32_t Hangup( 63 int32_t slotId, int32_t eventId, int32_t gsmIndex, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 64 int32_t Answer(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 65 int32_t GetCallList( 66 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 67 int32_t HoldCall(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 68 int32_t UnHoldCall(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 69 int32_t SwitchCall(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 70 int32_t CombineConference( 71 int32_t slotId, int32_t eventId, int32_t callType, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 72 int32_t SeparateConference(int32_t slotId, int32_t eventId, int32_t callIndex, int32_t callType, 73 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 74 int32_t CallSupplement( 75 int32_t slotId, int32_t eventId, int32_t type, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 76 int32_t GetClip(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 77 int32_t SetClip( 78 int32_t slotId, int32_t eventId, int32_t action, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 79 int32_t GetClir(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 80 int32_t SetClir( 81 int32_t slotId, int32_t eventId, int32_t action, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 82 int32_t SetCallWaiting( 83 int32_t slotId, int32_t eventId, int32_t activate, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 84 int32_t SetCallTransferInfo(int32_t slotId, int32_t eventId, const CallTransferParam &callTransfer, 85 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 86 int32_t GetCallTransferInfo(int32_t slotId, int32_t eventId, const int32_t reason, 87 const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 88 int32_t GetCallWaiting( 89 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 90 int32_t GetCallRestriction(int32_t slotId, int32_t eventId, std::string fac, 91 const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 92 int32_t SetCallRestriction(int32_t slotId, int32_t eventId, const CallRestrictionParam &callRestriction, 93 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 94 /* PDP start */ 95 int32_t SetInitApnInfo(int32_t slotId, int32_t eventId, const DataProfile &dataProfile, 96 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 97 int32_t ActivatePdpContext(int32_t slotId, int32_t eventId, const ActivateDataParam &activateData, 98 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 99 int32_t DeactivatePdpContext(int32_t slotId, int32_t eventId, const DeactivateDataParam &deactivateData, 100 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 101 int32_t GetPdpContextList( 102 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 103 int32_t GetLinkBandwidthInfo( 104 int32_t slotId, int32_t eventId, const int32_t cid, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 105 int32_t SetLinkBandwidthReportingRule(int32_t slotId, int32_t eventId, LinkBandwidthRule linkBandwidth, 106 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 107 /* PDP end */ 108 int32_t StopDTMF( 109 int32_t slotId, int32_t eventId, int32_t index, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 110 int32_t StartDTMF(int32_t slotId, int32_t eventId, char cDTMFCode, int32_t index, 111 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 112 int32_t SendDTMF(int32_t slotId, int32_t eventId, char cDTMFCode, int32_t index, 113 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 114 int32_t SendDTMF(int32_t slotId, int32_t eventId, const DtmfParam &dtmfParam, 115 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 116 117 int32_t GetImsRegStatus( 118 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 119 int32_t GetSignalStrength( 120 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 121 int32_t GetCsRegStatus( 122 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 123 int32_t GetPsRegStatus( 124 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 125 int32_t GetImsCallList( 126 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 127 int32_t SetCallPreferenceMode(int32_t slotId, int32_t eventId, int32_t mode, 128 const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 129 int32_t GetCallPreferenceMode( 130 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 131 int32_t SetLteImsSwitchStatus(int32_t slotId, int32_t eventId, int32_t active, 132 const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 133 int32_t GetLteImsSwitchStatus( 134 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 135 int32_t SetUssd(int32_t slotId, int32_t eventId, const std::string str, 136 const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 137 int32_t GetUssd( 138 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 139 int32_t GetMute(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 140 int32_t SetMute(int32_t slotId, int32_t eventId, int32_t mute, 141 const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 142 int32_t GetEmergencyCallList( 143 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 144 int32_t GetCallFailReason( 145 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 146 int32_t GetOperatorInfo( 147 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 148 int32_t GetCellInfoList(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 149 int32_t GetCurrentCellInfo( 150 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 151 152 int32_t SendGsmSms(int32_t slotId, int32_t eventId, GsmSimMessageParam &gsmMessage, 153 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 154 int32_t SendCdmaSms(int32_t slotId, int32_t eventId, std::string pdu, int64_t refId, 155 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 156 int32_t AddSimMessage(int32_t slotId, int32_t eventId, const SimMessageParam &simMessage, 157 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 158 int32_t GetSmscAddr( 159 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 160 int32_t GetCdmaCBConfig(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 161 int32_t SetSmscAddr(int32_t slotId, int32_t eventId, int32_t tosca, std::string address, 162 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 163 int32_t DelSimMessage( 164 int32_t slotId, int32_t eventId, int32_t gsmIndex, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 165 int32_t SendSmsMoreMode(int32_t slotId, int32_t eventId, GsmSimMessageParam &gsmMessage, 166 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 167 int32_t SendSmsAck(int32_t slotId, int32_t eventId, bool success, int32_t cause, 168 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 169 int32_t GetCBConfig(int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 170 int32_t SetCBConfig(int32_t slotId, int32_t eventId, const CBConfigParam &cbConfig, 171 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 172 int32_t SetCdmaCBConfig(int32_t slotId, int32_t eventId, CdmaCBConfigInfoList &cdmaCBConfigInfoList, 173 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 174 int32_t GetNetworkSearchInformation( 175 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 176 int32_t GetNetworkSelectionMode( 177 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler) const; 178 int32_t SetNetworkSelectionMode(int32_t slotId, int32_t eventId, int32_t automaticFlag, std::string oper, 179 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 180 int32_t AddCdmaSimMessage(int32_t slotId, int32_t eventId, int32_t status, std::string pdu, 181 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 182 int32_t DelCdmaSimMessage( 183 int32_t slotId, int32_t eventId, int32_t cdmaIndex, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 184 int32_t UpdateCdmaSimMessage(int32_t slotId, int32_t eventId, const CdmaSimMessageParam &cdmaSimMsg, 185 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 186 int32_t SetPreferredNetworkPara(int32_t slotId, int32_t eventId, int32_t preferredNetworkType, 187 const std::shared_ptr<AppExecFwk::EventHandler> &handler); 188 int32_t GetPreferredNetworkPara( 189 int32_t slotId, int32_t eventId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 190 std::vector<std::shared_ptr<DiallingNumbersInfo>> QueryIccDiallingNumbers(int slotId, int type); 191 192 /******************** telRilManager end *******************/ 193 /******************** networkSearchManager start *******************/ 194 int32_t GetPsRadioTech(int32_t slotId); 195 int32_t GetCsRadioTech(int32_t slotId); 196 int32_t GetPsRegState(int32_t slotId); 197 int32_t GetCsRegState(int32_t slotId); 198 int32_t GetPsRoamingState(int32_t slotId); 199 bool SetNetworkSelectionMode(int32_t slotId, int32_t selectMode, 200 const sptr<NetworkInformation> &networkInformation, bool resumeSelection, 201 const sptr<INetworkSearchCallback> &callback); 202 std::vector<sptr<SignalInformation>> GetSignalInfoList(int32_t slotId); 203 std::u16string GetOperatorNumeric(int32_t slotId); 204 std::u16string GetOperatorName(int32_t slotId); 205 sptr<NetworkState> GetNetworkStatus(int32_t slotId); 206 bool SetRadioState(int32_t slotId, bool isOn, int32_t rst, const sptr<INetworkSearchCallback> &callback); 207 int32_t GetRadioState(int32_t slotId); 208 bool GetRadioState(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 209 std::u16string GetIsoCountryCodeForNetwork(int32_t slotId); 210 std::u16string GetImei(int32_t slotId); 211 std::u16string GetMeid(int32_t slotId); 212 std::u16string GetUniqueDeviceId(int32_t slotId); 213 PhoneType GetPhoneType(int32_t slotId); 214 sptr<CellLocation> GetCellLocation(int32_t slotId); 215 bool GetNetworkSearchInformation(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 216 bool GetNetworkSelectionMode(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 217 bool GetImsRegStatus(int32_t slotId) const; 218 std::vector<sptr<CellInformation>> GetCellInfoList(int32_t slotId); 219 bool SendUpdateCellLocationRequest(int32_t slotId); 220 221 bool GetPreferredNetwork(int32_t slotId, const sptr<INetworkSearchCallback> &callback); 222 bool SetPreferredNetwork(int32_t slotId, int32_t networkMode, const sptr<INetworkSearchCallback> &callback); 223 224 bool IsNrSupported(int32_t slotId); 225 NrMode GetNrOptionMode(int32_t slotId); 226 FrequencyType GetFrequencyType(int32_t slotId) const; 227 NrState GetNrState(int32_t slotId) const; 228 void DcPhysicalLinkActiveUpdate(int32_t slotId, bool isActive); 229 /******************** networkSearchManager end *******************/ 230 /******************** simManager start ***************************/ 231 int32_t ObtainSpnCondition(int32_t slotId, bool roaming, std::string operatorNum); 232 std::u16string GetSpn(int32_t slotId); 233 bool SetVoiceMailInfo(int32_t slotId, const std::u16string &mailName, const std::u16string &mailNumber); 234 bool HasOperatorPrivileges(const int32_t slotId); 235 bool SendEnvelopeCmd(int32_t slotId, const std::string &cmd); 236 bool SendTerminalResponseCmd(int32_t slotId, const std::string &cmd); 237 bool UnlockSimLock(int32_t slotId, const PersoLockInfo &lockInfo, LockStatusResponse &response); 238 bool HasSimCard(int32_t slotId); 239 int32_t GetSimState(int32_t slotId); 240 int32_t GetCardType(int32_t slotId); 241 bool UnlockPin(int32_t slotId, std::string pin, LockStatusResponse &response); 242 bool UnlockPuk(int32_t slotId, std::string newPin, std::string puk, LockStatusResponse &response); 243 bool AlterPin(int32_t slotId, std::string newPin, std::string oldPin, LockStatusResponse &response); 244 bool SetLockState(int32_t slotId, const LockInfo &options, LockStatusResponse &response); 245 int32_t GetLockState(int32_t slotId, LockType lockType); 246 int32_t RefreshSimState(int32_t slotId); 247 bool UnlockPin2(int32_t slotId, std::string pin2, LockStatusResponse &response); 248 bool UnlockPuk2(int32_t slotId, std::string newPin2, std::string puk2, LockStatusResponse &response); 249 bool AlterPin2(int32_t slotId, std::string newPin2, std::string oldPin2, LockStatusResponse &response); 250 std::u16string GetShowNumber(int32_t slotId); 251 std::u16string GetShowName(int32_t slotId); 252 bool GetActiveSimAccountInfoList(std::vector<IccAccountInfo> &iccAccountInfoList); 253 bool GetOperatorConfigs(int slotId, OperatorConfig &poc); 254 std::u16string GetSimOperatorNumeric(int32_t slotId); 255 std::u16string GetISOCountryCodeForSim(int32_t slotId); 256 std::u16string GetSimIccId(int32_t slotId); 257 std::u16string GetIMSI(int32_t slotId); 258 std::u16string GetLocaleFromDefaultSim(int32_t slotId); 259 std::u16string GetSimGid1(int32_t slotId); 260 std::u16string GetSimTelephoneNumber(int32_t slotId); 261 std::u16string GetSimTeleNumberIdentifier(const int32_t slotId); 262 std::u16string GetVoiceMailIdentifier(int32_t slotId); 263 std::u16string GetVoiceMailNumber(int32_t slotId); 264 bool AddIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber); 265 bool DelIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber); 266 bool UpdateIccDiallingNumbers(int slotId, int type, const std::shared_ptr<DiallingNumbersInfo> &diallingNumber); 267 bool AddSmsToIcc(int slotId, int status, std::string &pdu, std::string &smsc); 268 bool UpdateSmsIcc(int slotId, int index, int status, std::string &pduData, std::string &smsc); 269 bool DelSmsIcc(int slotId, int index); 270 std::vector<std::string> ObtainAllSmsOfIcc(int slotId); 271 bool IsSimActive(int32_t slotId); 272 bool SetActiveSim(int32_t slotId, int32_t enable); 273 bool GetSimAccountInfo(int32_t slotId, IccAccountInfo &info); 274 bool SetDefaultVoiceSlotId(int32_t slotId); 275 bool SetDefaultSmsSlotId(int32_t slotId); 276 bool SetDefaultCellularDataSlotId(int32_t slotId); 277 bool SetPrimarySlotId(int32_t slotId); 278 bool SetShowNumber(int32_t slotId, const std::u16string number); 279 bool SetShowName(int32_t slotId, const std::u16string name); 280 int32_t GetDefaultVoiceSlotId(); 281 int32_t GetDefaultSmsSlotId(); 282 int32_t GetDefaultCellularDataSlotId(); 283 int32_t GetPrimarySlotId(); 284 /******************** simManager end *****************************/ 285 private: 286 CoreManagerInner(); 287 288 private: 289 bool isInitAllObj_ = false; 290 std::shared_ptr<INetworkSearch> networkSearchManager_ = nullptr; 291 std::shared_ptr<ISimManager> simManager_ = nullptr; 292 std::shared_ptr<ITelRilManager> telRilManager_ = nullptr; 293 }; 294 } // namespace Telephony 295 } // namespace OHOS 296 #endif 297