1 /* 2 * Copyright (C) 2022 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 TELEPHONY_IMS_CALL_CLIENT_H 17 #define TELEPHONY_IMS_CALL_CLIENT_H 18 19 #include "event_runner.h" 20 #include "ims_call_interface.h" 21 #include "ims_core_service_interface.h" 22 #include "iremote_stub.h" 23 #include "rwlock.h" 24 #include "singleton.h" 25 #include "system_ability_status_change_stub.h" 26 27 namespace OHOS { 28 namespace Telephony { 29 class ImsCallClient { 30 DECLARE_DELAYED_SINGLETON(ImsCallClient); 31 32 public: 33 /** 34 * Get ImsCall Remote Object 35 * 36 * @return sptr<ImsCallInterface> 37 */ 38 sptr<ImsCallInterface> GetImsCallProxy(); 39 40 void Init(); 41 void UnInit(); 42 int32_t RegisterImsCallCallbackHandler(int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 43 44 /** 45 * Get Handler 46 * 47 * @param slotId 48 * @return AppExecFwk::EventHandler 49 */ 50 std::shared_ptr<AppExecFwk::EventHandler> GetHandler(int32_t slotId); 51 52 /****************** call basic ******************/ 53 int32_t Dial(const ImsCallInfo &callInfo, CLIRMode mode); 54 int32_t HangUp(const ImsCallInfo &callInfo); 55 int32_t Reject(const ImsCallInfo &callInfo); 56 int32_t RejectWithReason(const ImsCallInfo &callInfo, const ImsRejectReason &reason); 57 int32_t Answer(const ImsCallInfo &callInfo); 58 int32_t HoldCall(int32_t slotId, int32_t callType); 59 int32_t UnHoldCall(int32_t slotId, int32_t callType); 60 int32_t SwitchCall(int32_t slotId, int32_t callType); 61 int32_t CombineConference(int32_t slotId); 62 int32_t InviteToConference(int32_t slotId, const std::vector<std::string> &numberList); 63 int32_t KickOutFromConference(int32_t slotId, const std::vector<std::string> &numberList); 64 int32_t UpdateImsCallMode(const ImsCallInfo &callInfo, ImsCallMode mode); 65 int32_t GetImsCallsDataRequest(int32_t slotId, int64_t lastCallsDataFlag); 66 int32_t GetLastCallFailReason(int32_t slotId); 67 68 /****************** dtmf rtt ******************/ 69 int32_t StartDtmf(int32_t slotId, char cDtmfCode, int32_t index); 70 int32_t SendDtmf(int32_t slotId, char cDtmfCode, int32_t index); 71 int32_t StopDtmf(int32_t slotId, int32_t index); 72 int32_t StartRtt(int32_t slotId, const std::string &msg); 73 int32_t StopRtt(int32_t slotId); 74 75 /****************** ims config ******************/ 76 int32_t SetDomainPreferenceMode(int32_t slotId, int32_t mode); 77 int32_t GetDomainPreferenceMode(int32_t slotId); 78 int32_t SetImsSwitchStatus(int32_t slotId, int32_t active); 79 int32_t GetImsSwitchStatus(int32_t slotId); 80 int32_t SetImsConfig(ImsConfigItem item, const std::string &value); 81 int32_t SetImsConfig(ImsConfigItem item, int32_t value); 82 int32_t GetImsConfig(ImsConfigItem item); 83 int32_t SetImsFeatureValue(FeatureType type, int32_t value); 84 int32_t GetImsFeatureValue(FeatureType type, int32_t &value); 85 int32_t SetMute(int32_t slotId, int32_t mute); 86 int32_t GetMute(int32_t slotId); 87 88 /****************** video settings ******************/ 89 int32_t CtrlCamera(const std::u16string &cameraId, int32_t callingUid, int32_t callingPid); 90 int32_t SetPreviewWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height); 91 int32_t SetDisplayWindow(int32_t x, int32_t y, int32_t z, int32_t width, int32_t height); 92 int32_t SetCameraZoom(float zoomRatio); 93 int32_t SetPauseImage(const std::u16string &path); 94 int32_t SetDeviceDirection(int32_t rotation); 95 96 /****************** supplement ******************/ 97 int32_t SetClip(int32_t slotId, int32_t action); 98 int32_t GetClip(int32_t slotId); 99 int32_t SetClir(int32_t slotId, int32_t action); 100 int32_t GetClir(int32_t slotId); 101 int32_t SetCallTransfer( 102 int32_t slotId, int32_t reason, int32_t mode, const std::string &transferNum, int32_t classType); 103 int32_t GetCallTransfer(int32_t slotId, int32_t reason); 104 int32_t SetCallRestriction(int32_t slotId, const std::string &fac, int32_t mode, const std::string &pw); 105 int32_t GetCallRestriction(int32_t slotId, const std::string &fac); 106 int32_t SetCallWaiting(int32_t slotId, bool activate, int32_t classType); 107 int32_t GetCallWaiting(int32_t slotId); 108 int32_t SetColr(int32_t slotId, int32_t presentation); 109 int32_t GetColr(int32_t slotId); 110 int32_t SetColp(int32_t slotId, int32_t action); 111 int32_t GetColp(int32_t slotId); 112 int32_t UpdateImsCapabilities(int32_t slotId, const ImsCapabilityList &imsCapabilityList); 113 114 private: 115 class SystemAbilityListener : public SystemAbilityStatusChangeStub { 116 public: SystemAbilityListener()117 SystemAbilityListener() {} ~SystemAbilityListener()118 ~SystemAbilityListener() {} 119 public: 120 void OnAddSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 121 void OnRemoveSystemAbility(int32_t systemAbilityId, const std::string& deviceId) override; 122 }; 123 124 /** 125 * Is Connect ImsCall Remote Object 126 * 127 * @return bool 128 */ 129 bool IsConnect() const; 130 int32_t RegisterImsCallCallback(); 131 int32_t ReConnectService(); 132 void Clean(); 133 134 private: 135 sptr<ImsCoreServiceInterface> imsCoreServiceProxy_ = nullptr; 136 sptr<ImsCallInterface> imsCallProxy_ = nullptr; 137 sptr<ImsCallCallbackInterface> imsCallCallback_ = nullptr; 138 std::map<int32_t, std::shared_ptr<AppExecFwk::EventHandler>> handlerMap_; 139 Utils::RWLock rwClientLock_; 140 sptr<ISystemAbilityStatusChange> statusChangeListener_ = nullptr; 141 }; 142 } // namespace Telephony 143 } // namespace OHOS 144 145 #endif // TELEPHONY_IMS_CORE_SERVICE_CLIENT_H 146