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 CALL_MANAGER_PROXY_H 17 #define CALL_MANAGER_PROXY_H 18 19 #include <string_ex.h> 20 #include <mutex> 21 22 #include "if_system_ability_manager.h" 23 #include "refbase.h" 24 #include "singleton.h" 25 #include "rwlock.h" 26 #include "pac_map.h" 27 28 #include "i_call_manager_service.h" 29 #include "i_call_ability_callback.h" 30 #include "timer.h" 31 32 #include "call_manager_callback.h" 33 #include "call_ability_callback.h" 34 35 namespace OHOS { 36 namespace Telephony { 37 class CallManagerProxy : public Telephony::Timer, public std::enable_shared_from_this<CallManagerProxy> { 38 DECLARE_DELAYED_SINGLETON(CallManagerProxy) 39 public: 40 void Init(int32_t systemAbilityId); 41 void UnInit(); 42 int32_t RegisterCallBack(std::unique_ptr<CallManagerCallback> callback); 43 int32_t UnRegisterCallBack(); 44 int32_t DialCall(std::u16string number, AppExecFwk::PacMap &extras); 45 int32_t AnswerCall(int32_t callId, int32_t videoState); 46 int32_t RejectCall(int32_t callId, bool isSendSms, std::u16string content); 47 int32_t HangUpCall(int32_t callId); 48 int32_t GetCallState(); 49 int32_t HoldCall(int32_t callId); 50 int32_t UnHoldCall(int32_t callId); 51 int32_t SwitchCall(int32_t callId); 52 int32_t CombineConference(int32_t callId); 53 int32_t SeparateConference(int32_t callId); 54 int32_t GetMainCallId(int32_t &callId); 55 std::vector<std::u16string> GetSubCallIdList(int32_t callId); 56 std::vector<std::u16string> GetCallIdListForConference(int32_t callId); 57 int32_t GetCallWaiting(int32_t slotId); 58 int32_t SetCallWaiting(int32_t slotId, bool activate); 59 int32_t GetCallRestriction(int32_t slotId, CallRestrictionType type); 60 int32_t SetCallRestriction(int32_t slotId, CallRestrictionInfo &info); 61 int32_t GetCallTransferInfo(int32_t slotId, CallTransferType type); 62 int32_t SetCallTransferInfo(int32_t slotId, CallTransferInfo &info); 63 int32_t SetCallPreferenceMode(int32_t slotId, int32_t mode); 64 int32_t StartDtmf(int32_t callId, char str); 65 int32_t StopDtmf(int32_t callId); 66 bool IsRinging(); 67 bool HasCall(); 68 bool IsNewCallAllowed(); 69 bool IsInEmergencyCall(); 70 bool IsEmergencyPhoneNumber(std::u16string &number, int32_t slotId, int32_t &errorCode); 71 int32_t FormatPhoneNumber(std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber); 72 int32_t FormatPhoneNumberToE164( 73 std::u16string &number, std::u16string &countryCode, std::u16string &formatNumber); 74 int32_t SetMuted(bool isMute); 75 int32_t MuteRinger(); 76 int32_t SetAudioDevice(AudioDevice deviceType); 77 int32_t ControlCamera(std::u16string cameraId); 78 int32_t SetPreviewWindow(VideoWindow &window); 79 int32_t SetDisplayWindow(VideoWindow &window); 80 int32_t SetCameraZoom(float zoomRatio); 81 int32_t SetPausePicture(std::u16string path); 82 int32_t SetDeviceDirection(int32_t rotation); 83 int32_t GetImsConfig(int32_t slotId, ImsConfigItem item); 84 int32_t SetImsConfig(int32_t slotId, ImsConfigItem item, std::u16string &value); 85 int32_t GetImsFeatureValue(int32_t slotId, FeatureType type); 86 int32_t SetImsFeatureValue(int32_t slotId, FeatureType type, int32_t value); 87 int32_t UpdateImsCallMode(int32_t callId, ImsCallMode mode); 88 int32_t EnableImsSwitch(int32_t slotId); 89 int32_t DisableImsSwitch(int32_t slotId); 90 int32_t IsImsSwitchEnabled(int32_t slotId); 91 int32_t EnableLteEnhanceMode(int32_t slotId); 92 int32_t DisableLteEnhanceMode(int32_t slotId); 93 int32_t IsLteEnhanceModeEnabled(int32_t slotId); 94 int32_t StartRtt(int32_t callId, std::u16string &msg); 95 int32_t StopRtt(int32_t callId); 96 int32_t JoinConference(int32_t callId, std::vector<std::u16string> &numberList); 97 int32_t ReportOttCallDetailsInfo(std::vector<OttCallDetailsInfo> &ottVec); 98 int32_t ReportOttCallEventInfo(OttCallEventInfo &eventInfo); 99 sptr<IRemoteObject> GetProxyObjectPtr(CallManagerProxyType proxyType); 100 101 private: 102 static void task(); 103 int32_t ConnectService(); 104 void DisconnectService(); 105 int32_t ReConnectService(); 106 int32_t ReRegisterCallBack(); 107 void OnDeath(); 108 void NotifyDeath(); 109 110 private: 111 int32_t systemAbilityId_; 112 Utils::RWLock rwClientLock_; 113 bool registerStatus_; 114 bool initStatus_; 115 sptr<ICallManagerService> callManagerServicePtr_ = nullptr; 116 sptr<CallAbilityCallback> callAbilityCallbackPtr_ = nullptr; 117 std::mutex mutex_; 118 }; 119 } // namespace Telephony 120 } // namespace OHOS 121 122 #endif 123