1d95e75fdSopenharmony_ci 2d95e75fdSopenharmony_ci/* 3d95e75fdSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 4d95e75fdSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 5d95e75fdSopenharmony_ci * you may not use this file except in compliance with the License. 6d95e75fdSopenharmony_ci * You may obtain a copy of the License at 7d95e75fdSopenharmony_ci * 8d95e75fdSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 9d95e75fdSopenharmony_ci * 10d95e75fdSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 11d95e75fdSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 12d95e75fdSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d95e75fdSopenharmony_ci * See the License for the specific language governing permissions and 14d95e75fdSopenharmony_ci * limitations under the License. 15d95e75fdSopenharmony_ci */ 16d95e75fdSopenharmony_ci 17d95e75fdSopenharmony_ci#ifndef TELEPHONY_SATELLITE_CALL_CLIENT_H 18d95e75fdSopenharmony_ci#define TELEPHONY_SATELLITE_CALL_CLIENT_H 19d95e75fdSopenharmony_ci 20d95e75fdSopenharmony_ci#include "event_runner.h" 21d95e75fdSopenharmony_ci#include "i_satellite_service.h" 22d95e75fdSopenharmony_ci#include "iremote_stub.h" 23d95e75fdSopenharmony_ci#include "rwlock.h" 24d95e75fdSopenharmony_ci#include "satellite_call_interface.h" 25d95e75fdSopenharmony_ci#include "singleton.h" 26d95e75fdSopenharmony_ci#include "system_ability_status_change_stub.h" 27d95e75fdSopenharmony_ci 28d95e75fdSopenharmony_cinamespace OHOS { 29d95e75fdSopenharmony_cinamespace Telephony { 30d95e75fdSopenharmony_ciclass SatelliteCallClient { 31d95e75fdSopenharmony_ci DECLARE_DELAYED_SINGLETON(SatelliteCallClient); 32d95e75fdSopenharmony_ci 33d95e75fdSopenharmony_cipublic: 34d95e75fdSopenharmony_ci /** 35d95e75fdSopenharmony_ci * @brief Get SatelliteCall Remote Object ptr 36d95e75fdSopenharmony_ci * 37d95e75fdSopenharmony_ci * @return sptr<SatelliteCallInterface> 38d95e75fdSopenharmony_ci */ 39d95e75fdSopenharmony_ci sptr<SatelliteCallInterface> GetSatelliteCallProxy(); 40d95e75fdSopenharmony_ci 41d95e75fdSopenharmony_ci /** 42d95e75fdSopenharmony_ci * @brief Get the remote object ptr, initiate a listener and subscribe the system ability 43d95e75fdSopenharmony_ci */ 44d95e75fdSopenharmony_ci void Init(); 45d95e75fdSopenharmony_ci 46d95e75fdSopenharmony_ci /** 47d95e75fdSopenharmony_ci * @brief Clear the listener and the remote ptr when destroy the SatelliteCallClient Object 48d95e75fdSopenharmony_ci */ 49d95e75fdSopenharmony_ci void UnInit(); 50d95e75fdSopenharmony_ci 51d95e75fdSopenharmony_ci /** 52d95e75fdSopenharmony_ci * @brief Register SatelliteCallCallback Handler, put the handler and slot id into {handlerMap_} 53d95e75fdSopenharmony_ci * 54d95e75fdSopenharmony_ci * @param slotId Indicates the card slot index number, 55d95e75fdSopenharmony_ci * @param handler Indicates the event handler ptr 56d95e75fdSopenharmony_ci * @return Returns TELEPHONY_SUCCESS on success, others on failure. 57d95e75fdSopenharmony_ci */ 58d95e75fdSopenharmony_ci int32_t RegisterSatelliteCallCallbackHandler( 59d95e75fdSopenharmony_ci int32_t slotId, const std::shared_ptr<AppExecFwk::EventHandler> &handler); 60d95e75fdSopenharmony_ci 61d95e75fdSopenharmony_ci /** 62d95e75fdSopenharmony_ci * @brief Get the event handler ptr from {handlerMap_} 63d95e75fdSopenharmony_ci * 64d95e75fdSopenharmony_ci * @param slotId Indicates the card slot index number, 65d95e75fdSopenharmony_ci * @return AppExecFwk::EventHandler 66d95e75fdSopenharmony_ci */ 67d95e75fdSopenharmony_ci std::shared_ptr<AppExecFwk::EventHandler> GetHandler(int32_t slotId); 68d95e75fdSopenharmony_ci 69d95e75fdSopenharmony_ci /****************** call basic ******************/ 70d95e75fdSopenharmony_ci /** 71d95e75fdSopenharmony_ci * @brief Satellite dial the call interface 72d95e75fdSopenharmony_ci * 73d95e75fdSopenharmony_ci * @param SatelliteCallInfo Indicates the call detail information, contains phone number, slot id, 74d95e75fdSopenharmony_ci * video state, call index 75d95e75fdSopenharmony_ci * @param CLIRMode Indicates the CLIR mode, like default, transfer, inhibition 76d95e75fdSopenharmony_ci * @return Returns TELEPHONY_SUCCESS on success, others on failure. 77d95e75fdSopenharmony_ci */ 78d95e75fdSopenharmony_ci int32_t Dial(const SatelliteCallInfo &callInfo, CLIRMode mode); 79d95e75fdSopenharmony_ci 80d95e75fdSopenharmony_ci /** 81d95e75fdSopenharmony_ci * @brief Satellite HangUp the call interface 82d95e75fdSopenharmony_ci * 83d95e75fdSopenharmony_ci * @param slotId Indicates the call slot id, 84d95e75fdSopenharmony_ci * @param index Indicates the call id, 85d95e75fdSopenharmony_ci * @return Returns TELEPHONY_SUCCESS on success, others on failure. 86d95e75fdSopenharmony_ci */ 87d95e75fdSopenharmony_ci int32_t HangUp(int32_t slotId, int32_t index); 88d95e75fdSopenharmony_ci 89d95e75fdSopenharmony_ci /** 90d95e75fdSopenharmony_ci * @brief Satellite Reject the call interface 91d95e75fdSopenharmony_ci * 92d95e75fdSopenharmony_ci * @param slotId Indicates the call slot id, 93d95e75fdSopenharmony_ci * @return Returns TELEPHONY_SUCCESS on success, others on failure. 94d95e75fdSopenharmony_ci */ 95d95e75fdSopenharmony_ci int32_t Reject(int32_t slotId); 96d95e75fdSopenharmony_ci 97d95e75fdSopenharmony_ci /** 98d95e75fdSopenharmony_ci * @brief Satellite Answer the call interface 99d95e75fdSopenharmony_ci * 100d95e75fdSopenharmony_ci * @param slotId Indicates the call slot id, 101d95e75fdSopenharmony_ci * @return Returns TELEPHONY_SUCCESS on success, others on failure. 102d95e75fdSopenharmony_ci */ 103d95e75fdSopenharmony_ci int32_t Answer(int32_t slotId); 104d95e75fdSopenharmony_ci 105d95e75fdSopenharmony_ci /** 106d95e75fdSopenharmony_ci * @brief Get Satellite Calls Data Request 107d95e75fdSopenharmony_ci * 108d95e75fdSopenharmony_ci * @param slotId Indicates the card slot index number, 109d95e75fdSopenharmony_ci * @param lastCallsDataFlag The Satellite call data id, is a number in milliseconds 110d95e75fdSopenharmony_ci * @return Returns TELEPHONY_SUCCESS on success, others on failure. 111d95e75fdSopenharmony_ci */ 112d95e75fdSopenharmony_ci int32_t GetSatelliteCallsDataRequest(int32_t slotId, int64_t lastCallsDataFlag); 113d95e75fdSopenharmony_ci 114d95e75fdSopenharmony_ci /** 115d95e75fdSopenharmony_ci * @brief Get Satellite status 116d95e75fdSopenharmony_ci * 117d95e75fdSopenharmony_ci * @param slotId Indicates the card slot index number, 118d95e75fdSopenharmony_ci * @return Returns true on satellite enable, others on false. 119d95e75fdSopenharmony_ci */ 120d95e75fdSopenharmony_ci bool IsSatelliteEnabled(int32_t slotId); 121d95e75fdSopenharmony_ci 122d95e75fdSopenharmony_ciprivate: 123d95e75fdSopenharmony_ci /** 124d95e75fdSopenharmony_ci * Is Connect ImsCall Remote Object 125d95e75fdSopenharmony_ci * 126d95e75fdSopenharmony_ci * @return bool 127d95e75fdSopenharmony_ci */ 128d95e75fdSopenharmony_ci bool IsConnect(); 129d95e75fdSopenharmony_ci int32_t RegisterSatelliteCallCallback(); 130d95e75fdSopenharmony_ci int32_t ReConnectService(); 131d95e75fdSopenharmony_ci void Clean(); 132d95e75fdSopenharmony_ci 133d95e75fdSopenharmony_ci class SatelliteServiceDeathRecipient : public IRemoteObject::DeathRecipient { 134d95e75fdSopenharmony_ci public: 135d95e75fdSopenharmony_ci explicit SatelliteServiceDeathRecipient(SatelliteCallClient &client) : client_(client) {} 136d95e75fdSopenharmony_ci ~SatelliteServiceDeathRecipient() override = default; 137d95e75fdSopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &remote) override 138d95e75fdSopenharmony_ci { 139d95e75fdSopenharmony_ci client_.OnRemoteDied(remote); 140d95e75fdSopenharmony_ci } 141d95e75fdSopenharmony_ci 142d95e75fdSopenharmony_ci private: 143d95e75fdSopenharmony_ci SatelliteCallClient &client_; 144d95e75fdSopenharmony_ci }; 145d95e75fdSopenharmony_ci 146d95e75fdSopenharmony_ci void RemoveDeathRecipient(const wptr<IRemoteObject> &remote); 147d95e75fdSopenharmony_ci 148d95e75fdSopenharmony_ci void OnRemoteDied(const wptr<IRemoteObject> &remote); 149d95e75fdSopenharmony_ci 150d95e75fdSopenharmony_ciprivate: 151d95e75fdSopenharmony_ci sptr<ISatelliteService> satelliteServiceProxy_ = nullptr; 152d95e75fdSopenharmony_ci sptr<SatelliteCallInterface> satelliteCallProxy_ = nullptr; 153d95e75fdSopenharmony_ci sptr<SatelliteCallCallbackInterface> satelliteCallCallback_ = nullptr; 154d95e75fdSopenharmony_ci sptr<IRemoteObject::DeathRecipient> deathRecipient_ { nullptr }; 155d95e75fdSopenharmony_ci std::map<int32_t, std::shared_ptr<AppExecFwk::EventHandler>> handlerMap_; 156d95e75fdSopenharmony_ci Utils::RWLock rwClientLock_; 157d95e75fdSopenharmony_ci std::mutex mutexProxy_; 158d95e75fdSopenharmony_ci std::mutex mutexMap_; 159d95e75fdSopenharmony_ci}; 160d95e75fdSopenharmony_ci} // namespace Telephony 161d95e75fdSopenharmony_ci} // namespace OHOS 162d95e75fdSopenharmony_ci 163d95e75fdSopenharmony_ci#endif // TELEPHONY_SATELLITE_CALL_CLIENT_H