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 CDMA_SMS_MESSAGE_H 17 #define CDMA_SMS_MESSAGE_H 18 19 #include "sms_base_message.h" 20 21 namespace OHOS { 22 namespace Telephony { 23 class CdmaSmsMessage : public SmsBaseMessage { 24 public: 25 CdmaSmsMessage() = default; 26 virtual ~CdmaSmsMessage() = default; 27 virtual int GetProtocolId() const; 28 virtual bool IsReplaceMessage(); 29 virtual bool IsCphsMwi() const; 30 virtual bool IsWapPushMsg(); 31 virtual CdmaTransportMsgType GetTransMsgType() const; 32 virtual int GetTransTeleService() const; 33 virtual bool IsStatusReport() const; 34 virtual int16_t GetDestPort() const; 35 virtual bool IsBroadcastMsg() const; 36 virtual bool AddUserDataHeader(const struct SmsUDH &header); 37 virtual int8_t GetCMASCategory() const; 38 virtual int8_t GetCMASResponseType() const; 39 virtual int8_t GetCMASSeverity() const; 40 virtual int8_t GetCMASUrgency() const; 41 virtual int8_t GetCMASCertainty() const; 42 virtual int8_t GetCMASMessageClass() const; 43 virtual bool IsCMAS() const; 44 virtual uint16_t GetMessageId() const; 45 virtual int8_t GetFormat() const; 46 virtual int8_t GetLanguage() const; 47 virtual std::string GetCbInfo() const; 48 virtual int8_t GetPriority() const; 49 virtual bool IsEmergencyMsg() const; 50 virtual uint16_t GetServiceCategoty() const; 51 virtual uint8_t GetGeoScope() const; 52 int64_t GetReceTime() const; 53 54 virtual std::shared_ptr<SpecialSmsIndication> GetSpecialSmsInd(); 55 static std::shared_ptr<CdmaSmsMessage> CreateMessage(const std::string &pdu); 56 57 std::unique_ptr<CdmaTransportMsg> CreateSubmitTransMsg(const std::string &dest, const std::string &sc, 58 const std::string &text, bool bStatusReport, const DataCodingScheme codingScheme); 59 std::unique_ptr<CdmaTransportMsg> CreateSubmitTransMsg(const std::string &dest, const std::string &sc, int32_t port, 60 const uint8_t *data, uint32_t dataLen, bool bStatusReport); 61 62 private: 63 SmsEncodingType CovertEncodingType(const DataCodingScheme &codingScheme); 64 bool PduAnalysis(const std::string &pduHex); 65 void AnalysisP2pMsg(const CdmaP2PMsg &p2pMsg); 66 void AnalysisCbMsg(const CdmaBroadCastMsg &cbMsg); 67 void AnalsisAckMsg(const CdmaAckMsg &ackMsg); 68 void AnalsisDeliverMwi(const CdmaP2PMsg &p2pMsg); 69 void AnalsisDeliverMsg(const TeleserviceDeliver &deliver); 70 void AnalsisDeliverAck(const TeleserviceDeliverAck &deliverAck); 71 void AnalsisSubmitReport(const TeleserviceDeliverReport &report); 72 void AnalsisSubmitMsg(const TeleserviceSubmit &submit); 73 void AnalsisUserData(const SmsTeleSvcUserData &userData); 74 void AnalsisCMASMsg(const TeleserviceDeliver &deliver); 75 void AnalsisHeader(const SmsTeleSvcUserData &userData); 76 virtual int DecodeMessage(uint8_t *decodeData, unsigned int length, DataCodingScheme &codingType, 77 const std::string &msgText, bool &bAbnormal, MSG_LANGUAGE_ID_T &langId); 78 79 private: 80 uint16_t destPort_ = -1; 81 std::unique_ptr<TransportAddr> address_; 82 std::unique_ptr<SmsTeleSvcAddr> callbackNumber_; 83 std::vector<struct SmsUDH> userHeaders_; 84 int8_t category_ = static_cast<int8_t>(SmsCmaeCategory::RESERVED); 85 int8_t responseType_ = static_cast<int8_t>(SmsCmaeResponseType::RESERVED); 86 int8_t severity_ = static_cast<int8_t>(SmsCmaeSeverity::RESERVED); 87 int8_t urgency_ = static_cast<int8_t>(SmsCmaeUrgency::IMMEDIATE); 88 int8_t certainty_ = static_cast<int8_t>(SmsCmaeCertainty::RESERVED); 89 int8_t messageClass_ = static_cast<int8_t>(SmsCmaeAlertHandle::RESERVED); 90 int8_t priority_ = static_cast<int8_t>(SmsPriorityIndicator::NORMAL); 91 bool isCmas_ = false; 92 uint16_t messageId_; 93 int8_t language_; 94 uint16_t serviceCategory_; 95 96 std::unique_ptr<struct CdmaTransportMsg> transMsg_; 97 std::unique_ptr<struct CdmaTransportMsg> GreateTransMsg(); 98 }; 99 } // namespace Telephony 100 } // namespace OHOS 101 #endif 102