• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 CDMA_SMS_SENDER_H
17 #define CDMA_SMS_SENDER_H
18 
19 #include <memory>
20 
21 #include "gsm_sms_message.h"
22 #include "ims_sms_client.h"
23 #include "sms_receive_indexer.h"
24 #include "sms_sender.h"
25 
26 namespace OHOS {
27 namespace Telephony {
28 class CdmaSmsSender : public SmsSender {
29 public:
30     CdmaSmsSender(const std::shared_ptr<AppExecFwk::EventRunner> &runner, int32_t slotId,
31         std::function<void(std::shared_ptr<SmsSendIndexer>)> sendRetryFun);
32     ~CdmaSmsSender() override;
33     void TextBasedSmsDelivery(const std::string &desAddr, const std::string &scAddr, const std::string &text,
34         const sptr<ISendShortMessageCallback> &sendCallback,
35         const sptr<IDeliveryShortMessageCallback> &deliveryCallback) override;
36     void TextBasedSmsDeliveryViaIms(const std::string &desAddr, const std::string &scAddr, const std::string &text,
37         const sptr<ISendShortMessageCallback> &sendCallback,
38         const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
39     bool TpduNullOrSmsPageOverNormalOrSmsEncodeFail(std::vector<struct SplitInfo> cellsInfos,
40         std::shared_ptr<struct SmsTpdu> tpdu, std::shared_ptr<uint8_t> unSentCellCount,
41         std::shared_ptr<bool> hasCellFailed, const sptr<ISendShortMessageCallback> &sendCallback);
42     void SendSmsForEveryIndexer(int &i, std::vector<struct SplitInfo> cellsInfos, const std::string &desAddr,
43         const std::string &scAddr, std::shared_ptr<struct SmsTpdu> tpdu, GsmSmsMessage gsmSmsMessage,
44         std::shared_ptr<uint8_t> unSentCellCount, std::shared_ptr<bool> hasCellFailed, SmsCodingScheme codingType,
45         uint8_t msgRef8bit, const sptr<ISendShortMessageCallback> &sendCallback,
46         const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
47     void ReadySendSms(GsmSmsMessage gsmSmsMessage, const std::string &scAddr, bool isMore,
48         std::shared_ptr<SmsSendIndexer> indexer, uint8_t msgRef8bit, std::shared_ptr<uint8_t> unSentCellCount,
49         std::shared_ptr<bool> hasCellFailed);
50     void DataBasedSmsDelivery(const std::string &desAddr, const std::string &scAddr, int32_t port, const uint8_t *data,
51         uint32_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
52         const sptr<IDeliveryShortMessageCallback> &deliveryCallback) override;
53     void DataBasedSmsDeliveryViaIms(const std::string &desAddr, const std::string &scAddr, int32_t port,
54         const uint8_t *data, uint32_t dataLen, const sptr<ISendShortMessageCallback> &sendCallback,
55         const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
56     void SendSmsToRil(const std::shared_ptr<SmsSendIndexer> &smsIndexer) override;
57     void Init() override;
58     void ReceiveStatusReport(const std::shared_ptr<SmsReceiveIndexer> &smsIndexer);
59     void ResendTextDelivery(const std::shared_ptr<SmsSendIndexer> &smsIndexer) override;
60     void ResendDataDelivery(const std::shared_ptr<SmsSendIndexer> &smsIndexer) override;
61     int32_t IsImsSmsSupported(int32_t slotId, bool &isSupported) override;
62     void StatusReportSetImsSms(const AppExecFwk::InnerEvent::Pointer &event) override;
63     void StatusReportGetImsSms(const AppExecFwk::InnerEvent::Pointer &event) override;
64     void RegisterImsHandler() override;
65     void SetSendIndexerInfo(const std::shared_ptr<SmsSendIndexer> &indexer,
66         const std::shared_ptr<struct EncodeInfo> &encodeInfo, unsigned char msgRef8bit);
67 
68 protected:
69     void StatusReportAnalysis(const AppExecFwk::InnerEvent::Pointer &event) override;
70 
71 private:
72     static constexpr uint16_t TAPI_NETTEXT_SMDATA_SIZE_MAX = 255;
73 
74     void SetConcact(const std::shared_ptr<SmsSendIndexer> &smsIndexer,
75         const std::unique_ptr<SmsTransMsg> &transMsg);
76     uint8_t GetSeqNum();
77     uint8_t GetSubmitMsgId();
78     void SetPduSeqInfo(const std::shared_ptr<SmsSendIndexer> &smsIndexer, const std::size_t size,
79         const std::unique_ptr<SmsTransMsg> &transMsg, const std::size_t index, const uint8_t msgRef8bit);
80 
81     void SendCsSms(const std::shared_ptr<SmsSendIndexer> &smsIndexer, int64_t &refId, std::string &pdu);
82     void SendImsSms(const std::shared_ptr<SmsSendIndexer> &smsIndexer, int64_t &refId, std::string &pdu);
83 
84 private:
85     uint8_t msgSeqNum_ = 0;
86     uint8_t msgSubmitId_ = 0;
87 
88     std::mutex mutex_;
89     bool isImsCdmaHandlerRegistered = false;
90 };
91 } // namespace Telephony
92 } // namespace OHOS
93 #endif