• 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 SMS_SERVICE_MANAGER_CLIENT_H
17 #define SMS_SERVICE_MANAGER_CLIENT_H
18 
19 #include <string>
20 #include <vector>
21 #include <mutex>
22 
23 #include "singleton.h"
24 
25 #include "i_sms_service_interface.h"
26 #include "refbase.h"
27 
28 namespace OHOS {
29 namespace Telephony {
30 class SmsServiceManagerClient : public std::enable_shared_from_this<SmsServiceManagerClient>  {
31     DECLARE_DELAYED_SINGLETON(SmsServiceManagerClient)
32 public:
33     bool InitSmsServiceProxy();
34     void ResetSmsServiceProxy();
35 
36     bool SetDefaultSmsSlotId(int32_t slotId);
37     int32_t GetDefaultSmsSlotId();
38     int32_t SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr,
39         const std::u16string text, const sptr<ISendShortMessageCallback> &callback,
40         const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
41     int32_t SendMessage(int32_t slotId, const std::u16string desAddr, const std::u16string scAddr,
42         uint16_t port, const uint8_t *data, uint16_t dataLen, const sptr<ISendShortMessageCallback> &callback,
43         const sptr<IDeliveryShortMessageCallback> &deliveryCallback);
44     bool SetScAddress(int32_t slotId, const std::u16string &scAddr);
45     std::u16string GetScAddress(int32_t slotId);
46     bool AddSimMessage(int32_t slotId, const std::u16string &smsc, const std::u16string &pdu,
47         ISmsServiceInterface::SimMessageStatus status);
48     bool DelSimMessage(int32_t slotId, uint32_t msgIndex);
49     bool UpdateSimMessage(int32_t slotId, uint32_t msgIndex,
50         ISmsServiceInterface::SimMessageStatus newStatus, const std::u16string &pdu, const std::u16string &smsc);
51     std::vector<ShortMessage> GetAllSimMessages(int32_t slotId);
52     bool SetCBConfig(
53         int32_t slotId, bool enable, uint32_t startMessageId, uint32_t endMessageId, uint8_t ranType);
54     std::vector<std::u16string> SplitMessage(const std::u16string &message);
55     bool GetSmsSegmentsInfo(int32_t slotId, const std::u16string &message, bool force7BitCode,
56         ISmsServiceInterface::SmsSegmentsInfo &segInfo);
57     bool IsImsSmsSupported();
58     std::u16string GetImsShortMessageFormat();
59     bool HasSmsCapability();
60 private:
61     std::mutex mutex_;
62     sptr<ISmsServiceInterface> smsServiceInterface_;
63     sptr<IRemoteObject::DeathRecipient> recipient_;
64 };
65 
66 enum class SmsSendResult {
67     /**
68      *  Indicates that the SMS message is successfully sent.
69      */
70     SEND_SMS_SUCCESS = 0,
71     /**
72      * Indicates that sending the SMS message fails due to an unknown reason.
73      */
74     SEND_SMS_FAILURE_UNKNOWN = 1,
75     /**
76      * Indicates that sending the SMS fails because the modem is powered off.
77      */
78     SEND_SMS_FAILURE_RADIO_OFF = 2,
79     /**
80      * Indicates that sending the SMS message fails because the network is unavailable
81      * or does not support sending or reception of SMS messages.
82      */
83     SEND_SMS_FAILURE_SERVICE_UNAVAILABLE = 3
84 };
85 } // namespace Telephony
86 } // namespace OHOS
87 #endif // SMS_SERVICE_MANAGER_CLIENT_H