• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
32 namespace OHOS {
33 namespace Telephony {
34 class SmsInterfaceStub : public IRemoteStub<ISmsServiceInterface> {
35 public:
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 
43 protected:
44     void InitModule();
45 
46 private:
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 OnSetCBConfigList(MessageParcel &data, MessageParcel &reply, MessageOption &option);
59     void OnSetImsSmsConfig(MessageParcel &data, MessageParcel &reply, MessageOption &option);
60     void OnSetDefaultSmsSlotId(MessageParcel &data, MessageParcel &reply, MessageOption &option);
61     void OnGetDefaultSmsSlotId(MessageParcel &data, MessageParcel &reply, MessageOption &option);
62     void OnGetDefaultSmsSimId(MessageParcel &data, MessageParcel &reply, MessageOption &option);
63     void OnSplitMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option);
64     void OnGetSmsSegmentsInfo(MessageParcel &data, MessageParcel &reply, MessageOption &option);
65     void OnIsImsSmsSupported(MessageParcel &data, MessageParcel &reply, MessageOption &option);
66     void OnGetImsShortMessageFormat(MessageParcel &data, MessageParcel &reply, MessageOption &option);
67     void OnHasSmsCapability(MessageParcel &data, MessageParcel &reply, MessageOption &option);
68     void OnCreateMessage(MessageParcel &data, MessageParcel &reply, MessageOption &option);
69     void OnGetBase64Encode(MessageParcel &data, MessageParcel &reply, MessageOption &option);
70     void OnGetBase64Decode(MessageParcel &data, MessageParcel &reply, MessageOption &option);
71     void OnGetEncodeStringFunc(MessageParcel &data, MessageParcel &reply, MessageOption &option);
72     void RemoveSpacesInDesAddr(std::u16string &desAddr);
73 
74     void OnSendMms(MessageParcel &data, MessageParcel &reply, MessageOption &option);
75     void OnDownloadMms(MessageParcel &data, MessageParcel &reply, MessageOption &option);
76 
77     void RegisterServiceCode();
78     std::map<uint32_t, std::shared_ptr<SmsInterfaceManager>> slotSmsInterfaceManagerMap_;
79     using SmsServiceFunc = std::function<void(MessageParcel &data, MessageParcel &reply, MessageOption &option)>;
80     std::map<SmsServiceInterfaceCode, SmsServiceFunc> memberFuncMap_;
81     std::mutex mutex_;
82     const std::string MMS_APP = "com.ohos.mms";
83 };
84 } // namespace Telephony
85 } // namespace OHOS
86 #endif