1/* 2 * Copyright (C) 2021-2023 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 SMS_INTERFACE_STUB_H 17#define SMS_INTERFACE_STUB_H 18 19#include <list> 20#include <memory> 21#include <mutex> 22#include <string> 23 24#include "iremote_stub.h" 25 26#include "i_sms_service_interface.h" 27#include "sms_interface_manager.h" 28#include "sms_receive_manager.h" 29#include "sms_send_manager.h" 30#include "sms_service_ipc_interface_code.h" 31 32namespace OHOS { 33namespace Telephony { 34class SmsInterfaceStub : public IRemoteStub<ISmsServiceInterface> { 35public: 36 SmsInterfaceStub(); 37 ~SmsInterfaceStub(); 38 virtual int OnRemoteRequest( 39 uint32_t code, MessageParcel &data, MessageParcel &reply, MessageOption &option) override; 40 std::shared_ptr<SmsInterfaceManager> GetSmsInterfaceManager(int32_t slotId); 41 std::shared_ptr<SmsInterfaceManager> GetSmsInterfaceManager(); 42 43protected: 44 void InitModule(); 45 46private: 47 void OnSendSmsTextRequest(MessageParcel &data, MessageParcel &reply, MessageOption &option); 48 void OnSendSmsTextWithoutSaveRequest(MessageParcel &data, MessageParcel &reply, MessageOption &option); 49 void OnSendSmsDataRequest(MessageParcel &data, MessageParcel &reply, MessageOption &option); 50 void OnSetSmscAddr(MessageParcel &data, MessageParcel &reply, MessageOption &option); 51 void OnGetSmscAddr(MessageParcel &data, MessageParcel &reply, MessageOption &option); 52 void OnAddSimMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option); 53 void OnDelSimMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option); 54 void OnUpdateSimMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option); 55 void OnGetAllSimMessages(MessageParcel &data, MessageParcel &reply, MessageOption &option); 56 void OnSetCBRangeConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option); 57 void OnSetCBConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option); 58 void OnSetImsSmsConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option); 59 void OnSetDefaultSmsSlotId(MessageParcel &data, MessageParcel &reply, MessageOption &option); 60 void OnGetDefaultSmsSlotId(MessageParcel &data, MessageParcel &reply, MessageOption &option); 61 void OnGetDefaultSmsSimId(MessageParcel &data, MessageParcel &reply, MessageOption &option); 62 void OnSplitMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option); 63 void OnGetSmsSegmentsInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option); 64 void OnIsImsSmsSupported(MessageParcel &data, MessageParcel &reply, MessageOption &option); 65 void OnGetImsShortMessageFormat(MessageParcel &data, MessageParcel &reply, MessageOption &option); 66 void OnHasSmsCapability(MessageParcel &data, MessageParcel &reply, MessageOption &option); 67 void OnCreateMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option); 68 void OnGetBase64Encode(MessageParcel &data, MessageParcel &reply, MessageOption &option); 69 void OnGetBase64Decode(MessageParcel &data, MessageParcel &reply, MessageOption &option); 70 void OnGetEncodeStringFunc(MessageParcel &data, MessageParcel &reply, MessageOption &option); 71 void RemoveSpacesInDesAddr(std::u16string &desAddr); 72 73 void OnSendMms(MessageParcel &data, MessageParcel &reply, MessageOption &option); 74 void OnDownloadMms(MessageParcel &data, MessageParcel &reply, MessageOption &option); 75 76 void RegisterServiceCode(); 77 std::map<uint32_t, std::shared_ptr<SmsInterfaceManager>> slotSmsInterfaceManagerMap_; 78 using SmsServiceFunc = std::function<void(MessageParcel &data, MessageParcel &reply, MessageOption &option)>; 79 std::map<SmsServiceInterfaceCode, SmsServiceFunc> memberFuncMap_; 80 std::mutex mutex_; 81 const std::string MMS_APP = "com.ohos.mms"; 82}; 83} // namespace Telephony 84} // namespace OHOS 85#endif