1e5d0e473Sopenharmony_ci/*
2e5d0e473Sopenharmony_ci * Copyright (C) 2021 Huawei Device Co., Ltd.
3e5d0e473Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e5d0e473Sopenharmony_ci * you may not use this file except in compliance with the License.
5e5d0e473Sopenharmony_ci * You may obtain a copy of the License at
6e5d0e473Sopenharmony_ci *
7e5d0e473Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e5d0e473Sopenharmony_ci *
9e5d0e473Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e5d0e473Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e5d0e473Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e5d0e473Sopenharmony_ci * See the License for the specific language governing permissions and
13e5d0e473Sopenharmony_ci * limitations under the License.
14e5d0e473Sopenharmony_ci */
15e5d0e473Sopenharmony_ci
16e5d0e473Sopenharmony_ci#include "gsm_sms_sender_test.h"
17e5d0e473Sopenharmony_ci
18e5d0e473Sopenharmony_ci#include <iostream>
19e5d0e473Sopenharmony_ci
20e5d0e473Sopenharmony_ci#include "ability_context.h"
21e5d0e473Sopenharmony_ci#include "ability_info.h"
22e5d0e473Sopenharmony_ci#include "access_mms_token.h"
23e5d0e473Sopenharmony_ci#include "context_deal.h"
24e5d0e473Sopenharmony_ci#include "iservice_registry.h"
25e5d0e473Sopenharmony_ci#include "sms_delivery_callback_test.h"
26e5d0e473Sopenharmony_ci#include "sms_send_callback_test.h"
27e5d0e473Sopenharmony_ci#include "string_utils.h"
28e5d0e473Sopenharmony_ci#include "telephony_errors.h"
29e5d0e473Sopenharmony_ci
30e5d0e473Sopenharmony_cinamespace OHOS {
31e5d0e473Sopenharmony_cinamespace Telephony {
32e5d0e473Sopenharmony_cinamespace {
33e5d0e473Sopenharmony_ciconst std::string CU_MMSC = "http://mmsc.myuni.com.cn";
34e5d0e473Sopenharmony_ciconst std::string SEND_MMS_FILE_URL = "/data/app/deSrc/SendReq.mms";
35e5d0e473Sopenharmony_ci} // namespace
36e5d0e473Sopenharmony_ci
37e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestGsmSendShortData(const sptr<ISmsServiceInterface> &smsService) const
38e5d0e473Sopenharmony_ci{
39e5d0e473Sopenharmony_ci    AccessMmsToken token;
40e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
41e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
42e5d0e473Sopenharmony_ci        return;
43e5d0e473Sopenharmony_ci    }
44e5d0e473Sopenharmony_ci    std::string dest;
45e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
46e5d0e473Sopenharmony_ci    int32_t slotIdTesta;
47e5d0e473Sopenharmony_ci    std::cin >> dest;
48e5d0e473Sopenharmony_ci    slotIdTesta = atoi(dest.c_str());
49e5d0e473Sopenharmony_ci    std::cout << "Please enter the receiver's telephone number" << std::endl;
50e5d0e473Sopenharmony_ci    dest.clear();
51e5d0e473Sopenharmony_ci    std::cin >> dest;
52e5d0e473Sopenharmony_ci    std::string sca("");
53e5d0e473Sopenharmony_ci    OHOS::sptr<SmsSendCallbackTest> sendCallBackPtr(new SmsSendCallbackTest());
54e5d0e473Sopenharmony_ci    OHOS::sptr<SmsDeliveryCallbackTest> deliveryCallBackPtr(new SmsDeliveryCallbackTest());
55e5d0e473Sopenharmony_ci    uint16_t port = 100;
56e5d0e473Sopenharmony_ci    uint8_t data[] = "hello world";
57e5d0e473Sopenharmony_ci    bool isMmsApp = false;
58e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTesta, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca), port, data,
59e5d0e473Sopenharmony_ci        (sizeof(data) / sizeof(data[0]) - 1), sendCallBackPtr, deliveryCallBackPtr, false);
60e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTesta, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca), port, data,
61e5d0e473Sopenharmony_ci        (sizeof(data) / sizeof(data[0]) - 1), sendCallBackPtr, deliveryCallBackPtr, true);
62e5d0e473Sopenharmony_ci    std::cout << "TestGsmSendShortData" << std::endl;
63e5d0e473Sopenharmony_ci}
64e5d0e473Sopenharmony_ci
65e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestGsmSendLongData(const sptr<ISmsServiceInterface> &smsService) const
66e5d0e473Sopenharmony_ci{
67e5d0e473Sopenharmony_ci    AccessMmsToken token;
68e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
69e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
70e5d0e473Sopenharmony_ci        return;
71e5d0e473Sopenharmony_ci    }
72e5d0e473Sopenharmony_ci    int32_t slotIdTestb;
73e5d0e473Sopenharmony_ci    std::string dest;
74e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
75e5d0e473Sopenharmony_ci    std::cin >> dest;
76e5d0e473Sopenharmony_ci    slotIdTestb = atoi(dest.c_str());
77e5d0e473Sopenharmony_ci    dest.clear();
78e5d0e473Sopenharmony_ci    std::cout << "Please enter the receiver's telephone number" << std::endl;
79e5d0e473Sopenharmony_ci    std::cin >> dest;
80e5d0e473Sopenharmony_ci    std::string sca("");
81e5d0e473Sopenharmony_ci    OHOS::sptr<SmsSendCallbackTest> sendCallBackPtr(new SmsSendCallbackTest());
82e5d0e473Sopenharmony_ci    OHOS::sptr<SmsDeliveryCallbackTest> deliveryCallBackPtr(new SmsDeliveryCallbackTest());
83e5d0e473Sopenharmony_ci    uint8_t data[] =
84e5d0e473Sopenharmony_ci        R"(This is the test data!This is the test data!This is the test data!
85e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
86e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
87e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
88e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
89e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!)";
90e5d0e473Sopenharmony_ci    uint16_t port = 100;
91e5d0e473Sopenharmony_ci
92e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTestb, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca), port, data,
93e5d0e473Sopenharmony_ci        sizeof(data) / sizeof(data[0]), sendCallBackPtr, deliveryCallBackPtr, true);
94e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTestb, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca), port, data,
95e5d0e473Sopenharmony_ci        sizeof(data) / sizeof(data[0]), sendCallBackPtr, deliveryCallBackPtr, false);
96e5d0e473Sopenharmony_ci    std::cout << "TestGsmSendLongData" << std::endl;
97e5d0e473Sopenharmony_ci}
98e5d0e473Sopenharmony_ci
99e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestSendShortText(const sptr<ISmsServiceInterface> &smsService) const
100e5d0e473Sopenharmony_ci{
101e5d0e473Sopenharmony_ci    AccessMmsToken token;
102e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
103e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
104e5d0e473Sopenharmony_ci        return;
105e5d0e473Sopenharmony_ci    }
106e5d0e473Sopenharmony_ci    std::string dest;
107e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
108e5d0e473Sopenharmony_ci    int32_t slotIdTestc;
109e5d0e473Sopenharmony_ci    std::cin >> dest;
110e5d0e473Sopenharmony_ci    slotIdTestc = atoi(dest.c_str());
111e5d0e473Sopenharmony_ci    dest.clear();
112e5d0e473Sopenharmony_ci    std::string text;
113e5d0e473Sopenharmony_ci    std::cin.ignore();
114e5d0e473Sopenharmony_ci    std::cout << "Please enter the receiver's telephone number" << std::endl;
115e5d0e473Sopenharmony_ci    getline(std::cin, dest);
116e5d0e473Sopenharmony_ci    std::cout << "Please enter text" << std::endl;
117e5d0e473Sopenharmony_ci    getline(std::cin, text);
118e5d0e473Sopenharmony_ci    std::string sca("");
119e5d0e473Sopenharmony_ci    OHOS::sptr<SmsSendCallbackTest> sendCallBackPtr(new SmsSendCallbackTest());
120e5d0e473Sopenharmony_ci    OHOS::sptr<SmsDeliveryCallbackTest> deliveryCallBackPtr(new SmsDeliveryCallbackTest());
121e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTestc, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca),
122e5d0e473Sopenharmony_ci        StringUtils::ToUtf16(text), sendCallBackPtr, deliveryCallBackPtr, true);
123e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTestc, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca),
124e5d0e473Sopenharmony_ci        StringUtils::ToUtf16(text), sendCallBackPtr, deliveryCallBackPtr, false);
125e5d0e473Sopenharmony_ci    std::cout << "TestGsmSendShortText" << std::endl;
126e5d0e473Sopenharmony_ci}
127e5d0e473Sopenharmony_ci
128e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestSendMms(const sptr<ISmsServiceInterface> &smsService) const
129e5d0e473Sopenharmony_ci{
130e5d0e473Sopenharmony_ci    AccessMmsToken token;
131e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
132e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
133e5d0e473Sopenharmony_ci        return;
134e5d0e473Sopenharmony_ci    }
135e5d0e473Sopenharmony_ci    std::string dest;
136e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
137e5d0e473Sopenharmony_ci    int32_t slotId;
138e5d0e473Sopenharmony_ci    std::cin >> dest;
139e5d0e473Sopenharmony_ci    slotId = atoi(dest.c_str());
140e5d0e473Sopenharmony_ci    dest.clear();
141e5d0e473Sopenharmony_ci    std::u16string mmsc(StringUtils::ToUtf16(CU_MMSC));
142e5d0e473Sopenharmony_ci    std::u16string data(StringUtils::ToUtf16(SEND_MMS_FILE_URL));
143e5d0e473Sopenharmony_ci    std::u16string ua(u"");
144e5d0e473Sopenharmony_ci    std::u16string uaprof(u"");
145e5d0e473Sopenharmony_ci    int64_t time = 0;
146e5d0e473Sopenharmony_ci    int32_t result = smsService->SendMms(slotId, mmsc, data, ua, uaprof, time);
147e5d0e473Sopenharmony_ci    if (result == 0) {
148e5d0e473Sopenharmony_ci        std::cout << "send mms success" << std::endl;
149e5d0e473Sopenharmony_ci    } else {
150e5d0e473Sopenharmony_ci        std::cout << "send mms fail" << std::endl;
151e5d0e473Sopenharmony_ci    }
152e5d0e473Sopenharmony_ci    result = smsService->SendMms(slotId, mmsc, data, ua, uaprof, time, true);
153e5d0e473Sopenharmony_ci    if (result == 0) {
154e5d0e473Sopenharmony_ci        std::cout << "send mms success" << std::endl;
155e5d0e473Sopenharmony_ci    } else {
156e5d0e473Sopenharmony_ci        std::cout << "send mms fail" << std::endl;
157e5d0e473Sopenharmony_ci    }
158e5d0e473Sopenharmony_ci}
159e5d0e473Sopenharmony_ci
160e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestSendLongText(const sptr<ISmsServiceInterface> &smsService) const
161e5d0e473Sopenharmony_ci{
162e5d0e473Sopenharmony_ci    AccessMmsToken token;
163e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
164e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
165e5d0e473Sopenharmony_ci        return;
166e5d0e473Sopenharmony_ci    }
167e5d0e473Sopenharmony_ci    int32_t slotIdTestd;
168e5d0e473Sopenharmony_ci    std::string dest;
169e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
170e5d0e473Sopenharmony_ci    std::cin >> dest;
171e5d0e473Sopenharmony_ci    slotIdTestd = atoi(dest.c_str());
172e5d0e473Sopenharmony_ci    dest.clear();
173e5d0e473Sopenharmony_ci    std::cout << "Please enter the receiver's telephone number" << std::endl;
174e5d0e473Sopenharmony_ci    std::cin >> dest;
175e5d0e473Sopenharmony_ci    std::string sca("");
176e5d0e473Sopenharmony_ci    std::string text(
177e5d0e473Sopenharmony_ci        R"(This is the test data!This is the test data!This is the test data!
178e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
179e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
180e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
181e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!
182e5d0e473Sopenharmony_ci        This is the test data!This is the test data!This is the test data!)");
183e5d0e473Sopenharmony_ci    OHOS::sptr<SmsSendCallbackTest> sendCallBackPtr(new SmsSendCallbackTest());
184e5d0e473Sopenharmony_ci    OHOS::sptr<SmsDeliveryCallbackTest> deliveryCallBackPtr(new SmsDeliveryCallbackTest());
185e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTestd, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca),
186e5d0e473Sopenharmony_ci        StringUtils::ToUtf16(text), sendCallBackPtr, deliveryCallBackPtr, true);
187e5d0e473Sopenharmony_ci    smsService->SendMessage(slotIdTestd, StringUtils::ToUtf16(dest), StringUtils::ToUtf16(sca),
188e5d0e473Sopenharmony_ci        StringUtils::ToUtf16(text), sendCallBackPtr, deliveryCallBackPtr, false);
189e5d0e473Sopenharmony_ci    std::cout << "TestGsmSendLongText" << std::endl;
190e5d0e473Sopenharmony_ci}
191e5d0e473Sopenharmony_ci
192e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestSetSmscAddr(const sptr<ISmsServiceInterface> &smsService) const
193e5d0e473Sopenharmony_ci{
194e5d0e473Sopenharmony_ci    AccessMmsToken token;
195e5d0e473Sopenharmony_ci    bool result = false;
196e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
197e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
198e5d0e473Sopenharmony_ci        return;
199e5d0e473Sopenharmony_ci    }
200e5d0e473Sopenharmony_ci    std::string dest;
201e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
202e5d0e473Sopenharmony_ci    int32_t slotIdTeste;
203e5d0e473Sopenharmony_ci    std::cin >> dest;
204e5d0e473Sopenharmony_ci    slotIdTeste = atoi(dest.c_str());
205e5d0e473Sopenharmony_ci    dest.clear();
206e5d0e473Sopenharmony_ci    std::string sca;
207e5d0e473Sopenharmony_ci    std::cout << "Please enter smsc" << std::endl;
208e5d0e473Sopenharmony_ci    std::cin >> sca;
209e5d0e473Sopenharmony_ci    result = smsService->SetSmscAddr(slotIdTeste, StringUtils::ToUtf16(sca));
210e5d0e473Sopenharmony_ci    if (result) {
211e5d0e473Sopenharmony_ci        std::cout << "TestSetSmscAddr OK!" << std::endl;
212e5d0e473Sopenharmony_ci    } else {
213e5d0e473Sopenharmony_ci        std::cout << "TestSetSmscAddr failed!" << std::endl;
214e5d0e473Sopenharmony_ci    }
215e5d0e473Sopenharmony_ci}
216e5d0e473Sopenharmony_ci
217e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestGetSmscAddr(const sptr<ISmsServiceInterface> &smsService) const
218e5d0e473Sopenharmony_ci{
219e5d0e473Sopenharmony_ci    AccessMmsToken token;
220e5d0e473Sopenharmony_ci    std::u16string result;
221e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
222e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
223e5d0e473Sopenharmony_ci        return;
224e5d0e473Sopenharmony_ci    }
225e5d0e473Sopenharmony_ci    std::string dest;
226e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
227e5d0e473Sopenharmony_ci    int32_t slotIdTestf;
228e5d0e473Sopenharmony_ci    std::cin >> dest;
229e5d0e473Sopenharmony_ci    slotIdTestf = atoi(dest.c_str());
230e5d0e473Sopenharmony_ci    dest.clear();
231e5d0e473Sopenharmony_ci    smsService->GetSmscAddr(slotIdTestf, result);
232e5d0e473Sopenharmony_ci    std::cout << "TestGetSmscAddr:" << StringUtils::ToUtf8(result) << std::endl;
233e5d0e473Sopenharmony_ci}
234e5d0e473Sopenharmony_ci
235e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestAddSimMessage(const sptr<ISmsServiceInterface> &smsService) const
236e5d0e473Sopenharmony_ci{
237e5d0e473Sopenharmony_ci    AccessMmsToken token;
238e5d0e473Sopenharmony_ci    bool result = false;
239e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
240e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
241e5d0e473Sopenharmony_ci        return;
242e5d0e473Sopenharmony_ci    }
243e5d0e473Sopenharmony_ci    std::string dest;
244e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
245e5d0e473Sopenharmony_ci    int32_t slotIdTestg;
246e5d0e473Sopenharmony_ci    std::cin >> dest;
247e5d0e473Sopenharmony_ci    slotIdTestg = atoi(dest.c_str());
248e5d0e473Sopenharmony_ci    std::string smsc;
249e5d0e473Sopenharmony_ci    std::cout << "Please enter smsc" << std::endl;
250e5d0e473Sopenharmony_ci    std::cin >> smsc;
251e5d0e473Sopenharmony_ci    std::string pdu;
252e5d0e473Sopenharmony_ci    std::cout << "Please enter pdu" << std::endl;
253e5d0e473Sopenharmony_ci    std::cin >> pdu;
254e5d0e473Sopenharmony_ci    std::string input;
255e5d0e473Sopenharmony_ci    std::cout << "Please enter status" << std::endl;
256e5d0e473Sopenharmony_ci    std::cin >> input;
257e5d0e473Sopenharmony_ci    uint32_t status = std::atoi(input.c_str());
258e5d0e473Sopenharmony_ci    result = smsService->AddSimMessage(slotIdTestg, StringUtils::ToUtf16(smsc), StringUtils::ToUtf16(pdu),
259e5d0e473Sopenharmony_ci        static_cast<ISmsServiceInterface::SimMessageStatus>(status));
260e5d0e473Sopenharmony_ci    if (result == 0) {
261e5d0e473Sopenharmony_ci        std::cout << "TestAddSimMessage OK!" << std::endl;
262e5d0e473Sopenharmony_ci    } else {
263e5d0e473Sopenharmony_ci        std::cout << "TestAddSimMessage failed!" << std::endl;
264e5d0e473Sopenharmony_ci    }
265e5d0e473Sopenharmony_ci}
266e5d0e473Sopenharmony_ci
267e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestDelSimMessage(const sptr<ISmsServiceInterface> &smsService) const
268e5d0e473Sopenharmony_ci{
269e5d0e473Sopenharmony_ci    AccessMmsToken token;
270e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
271e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
272e5d0e473Sopenharmony_ci        return;
273e5d0e473Sopenharmony_ci    }
274e5d0e473Sopenharmony_ci    bool result = false;
275e5d0e473Sopenharmony_ci    int32_t slotIdTesth;
276e5d0e473Sopenharmony_ci    std::string dest;
277e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
278e5d0e473Sopenharmony_ci    std::cin >> dest;
279e5d0e473Sopenharmony_ci    slotIdTesth = atoi(dest.c_str());
280e5d0e473Sopenharmony_ci    dest.clear();
281e5d0e473Sopenharmony_ci    std::string input;
282e5d0e473Sopenharmony_ci    std::cout << "Please enter msgIndex" << std::endl;
283e5d0e473Sopenharmony_ci    std::cin >> input;
284e5d0e473Sopenharmony_ci    uint32_t msgIndex = std::atoi(input.c_str());
285e5d0e473Sopenharmony_ci    result = smsService->DelSimMessage(slotIdTesth, msgIndex);
286e5d0e473Sopenharmony_ci    if (result == 0) {
287e5d0e473Sopenharmony_ci        std::cout << "TestDelSimMessage OK!" << std::endl;
288e5d0e473Sopenharmony_ci    } else {
289e5d0e473Sopenharmony_ci        std::cout << "TestDelSimMessage failed!" << std::endl;
290e5d0e473Sopenharmony_ci    }
291e5d0e473Sopenharmony_ci}
292e5d0e473Sopenharmony_ci
293e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestUpdateSimMessage(const sptr<ISmsServiceInterface> &smsService) const
294e5d0e473Sopenharmony_ci{
295e5d0e473Sopenharmony_ci    AccessMmsToken token;
296e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
297e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
298e5d0e473Sopenharmony_ci        return;
299e5d0e473Sopenharmony_ci    }
300e5d0e473Sopenharmony_ci    bool result = false;
301e5d0e473Sopenharmony_ci    std::string dest;
302e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
303e5d0e473Sopenharmony_ci    int32_t slotIdTesti;
304e5d0e473Sopenharmony_ci    std::cin >> dest;
305e5d0e473Sopenharmony_ci    slotIdTesti = atoi(dest.c_str());
306e5d0e473Sopenharmony_ci    dest.clear();
307e5d0e473Sopenharmony_ci    std::string input;
308e5d0e473Sopenharmony_ci    std::cout << "Please enter msgIndex" << std::endl;
309e5d0e473Sopenharmony_ci    std::cin >> input;
310e5d0e473Sopenharmony_ci    uint32_t msgIndex = std::atoi(input.c_str());
311e5d0e473Sopenharmony_ci    std::string pdu;
312e5d0e473Sopenharmony_ci    std::cout << "Please enter pdu" << std::endl;
313e5d0e473Sopenharmony_ci    std::cin >> pdu;
314e5d0e473Sopenharmony_ci    std::string smsc;
315e5d0e473Sopenharmony_ci    std::cout << "Please enter smsc" << std::endl;
316e5d0e473Sopenharmony_ci    std::cin >> smsc;
317e5d0e473Sopenharmony_ci    int32_t status;
318e5d0e473Sopenharmony_ci    std::cout << "Please enter status" << std::endl;
319e5d0e473Sopenharmony_ci    std::cin >> status;
320e5d0e473Sopenharmony_ci    std::u16string pduData = StringUtils::ToUtf16(pdu);
321e5d0e473Sopenharmony_ci    std::u16string smscData = StringUtils::ToUtf16(smsc);
322e5d0e473Sopenharmony_ci    result = smsService->UpdateSimMessage(
323e5d0e473Sopenharmony_ci        slotIdTesti, msgIndex, static_cast<ISmsServiceInterface::SimMessageStatus>(status), pduData, smscData);
324e5d0e473Sopenharmony_ci    if (result) {
325e5d0e473Sopenharmony_ci        std::cout << "TestUpdateSimMessage OK!" << std::endl;
326e5d0e473Sopenharmony_ci    } else {
327e5d0e473Sopenharmony_ci        std::cout << "TestUpdateSimMessage failed!" << std::endl;
328e5d0e473Sopenharmony_ci    }
329e5d0e473Sopenharmony_ci}
330e5d0e473Sopenharmony_ci
331e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestGetAllSimMessages(const sptr<ISmsServiceInterface> &smsService) const
332e5d0e473Sopenharmony_ci{
333e5d0e473Sopenharmony_ci    AccessMmsToken token;
334e5d0e473Sopenharmony_ci    std::vector<ShortMessage> result;
335e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
336e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
337e5d0e473Sopenharmony_ci        return;
338e5d0e473Sopenharmony_ci    }
339e5d0e473Sopenharmony_ci    std::string dest;
340e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
341e5d0e473Sopenharmony_ci    int32_t slotIdTestj;
342e5d0e473Sopenharmony_ci    std::cin >> dest;
343e5d0e473Sopenharmony_ci    slotIdTestj = atoi(dest.c_str());
344e5d0e473Sopenharmony_ci    dest.clear();
345e5d0e473Sopenharmony_ci    smsService->GetAllSimMessages(slotIdTestj, result);
346e5d0e473Sopenharmony_ci    std::cout << "TestGetAllSimMessages Begin:" << std::endl;
347e5d0e473Sopenharmony_ci    for (auto &item : result) {
348e5d0e473Sopenharmony_ci        std::cout << "[" << item.GetIndexOnSim() << "] " << StringUtils::StringToHex(item.GetPdu()) << std::endl;
349e5d0e473Sopenharmony_ci        std::cout << "status:" << item.GetIccMessageStatus()
350e5d0e473Sopenharmony_ci                  << " message:" << StringUtils::ToUtf8(item.GetVisibleMessageBody()) << std::endl;
351e5d0e473Sopenharmony_ci    }
352e5d0e473Sopenharmony_ci    std::cout << "TestGetAllSimMessages End!" << std::endl;
353e5d0e473Sopenharmony_ci}
354e5d0e473Sopenharmony_ci
355e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestEnableCBRangeConfig(const sptr<ISmsServiceInterface> &smsService) const
356e5d0e473Sopenharmony_ci{
357e5d0e473Sopenharmony_ci    AccessMmsToken token;
358e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
359e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
360e5d0e473Sopenharmony_ci        return;
361e5d0e473Sopenharmony_ci    }
362e5d0e473Sopenharmony_ci    std::string dest;
363e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
364e5d0e473Sopenharmony_ci    int32_t slotIdTestk;
365e5d0e473Sopenharmony_ci    std::cin >> dest;
366e5d0e473Sopenharmony_ci    bool enable = true;
367e5d0e473Sopenharmony_ci    slotIdTestk = atoi(dest.c_str());
368e5d0e473Sopenharmony_ci    dest.clear();
369e5d0e473Sopenharmony_ci    uint8_t ranType = 1;
370e5d0e473Sopenharmony_ci    uint32_t startMessageId = 0;
371e5d0e473Sopenharmony_ci    uint32_t endMessageId = 0;
372e5d0e473Sopenharmony_ci    std::cout << "Please enter startMessageId" << std::endl;
373e5d0e473Sopenharmony_ci    std::string input;
374e5d0e473Sopenharmony_ci    std::cin >> input;
375e5d0e473Sopenharmony_ci    startMessageId = std::atoi(input.c_str());
376e5d0e473Sopenharmony_ci    std::cout << "Please enter endMessageId" << std::endl;
377e5d0e473Sopenharmony_ci    std::cin >> input;
378e5d0e473Sopenharmony_ci    endMessageId = std::atoi(input.c_str());
379e5d0e473Sopenharmony_ci    int32_t result = smsService->SetCBConfig(slotIdTestk, enable, startMessageId, endMessageId, ranType);
380e5d0e473Sopenharmony_ci    std::cout << "TestEnableCBRangeConfig:" << result << std::endl;
381e5d0e473Sopenharmony_ci}
382e5d0e473Sopenharmony_ci
383e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestDisableCBRangeConfig(const sptr<ISmsServiceInterface> &smsService) const
384e5d0e473Sopenharmony_ci{
385e5d0e473Sopenharmony_ci    AccessMmsToken token;
386e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
387e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
388e5d0e473Sopenharmony_ci        return;
389e5d0e473Sopenharmony_ci    }
390e5d0e473Sopenharmony_ci    std::string dest;
391e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
392e5d0e473Sopenharmony_ci    std::cin >> dest;
393e5d0e473Sopenharmony_ci    int32_t slotIdTestl = atoi(dest.c_str());
394e5d0e473Sopenharmony_ci    bool enable = false;
395e5d0e473Sopenharmony_ci    uint32_t startMessageId = 0;
396e5d0e473Sopenharmony_ci    uint32_t endMessageId = 0;
397e5d0e473Sopenharmony_ci    uint8_t ranType = 1;
398e5d0e473Sopenharmony_ci    std::string input;
399e5d0e473Sopenharmony_ci    std::cout << "Please enter startMessageId" << std::endl;
400e5d0e473Sopenharmony_ci    std::cin >> input;
401e5d0e473Sopenharmony_ci    startMessageId = std::atoi(input.c_str());
402e5d0e473Sopenharmony_ci    std::cout << "Please enter endMessageId" << std::endl;
403e5d0e473Sopenharmony_ci    std::cin >> input;
404e5d0e473Sopenharmony_ci    endMessageId = std::atoi(input.c_str());
405e5d0e473Sopenharmony_ci    int32_t result = smsService->SetCBConfig(slotIdTestl, enable, startMessageId, endMessageId, ranType);
406e5d0e473Sopenharmony_ci    std::cout << "TestDisableCBRangeConfig:" << result << std::endl;
407e5d0e473Sopenharmony_ci}
408e5d0e473Sopenharmony_ci
409e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestEnableCBConfig(const sptr<ISmsServiceInterface> &smsService) const
410e5d0e473Sopenharmony_ci{
411e5d0e473Sopenharmony_ci    AccessMmsToken token;
412e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
413e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
414e5d0e473Sopenharmony_ci        return;
415e5d0e473Sopenharmony_ci    }
416e5d0e473Sopenharmony_ci    std::string dest;
417e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
418e5d0e473Sopenharmony_ci    int32_t slotIdTestm;
419e5d0e473Sopenharmony_ci    std::cin >> dest;
420e5d0e473Sopenharmony_ci    slotIdTestm = atoi(dest.c_str());
421e5d0e473Sopenharmony_ci    dest.clear();
422e5d0e473Sopenharmony_ci    bool enable = true;
423e5d0e473Sopenharmony_ci    uint32_t identifier = 0;
424e5d0e473Sopenharmony_ci    uint8_t ranType = 1;
425e5d0e473Sopenharmony_ci    std::string input;
426e5d0e473Sopenharmony_ci    std::cout << "Please enter identifier" << std::endl;
427e5d0e473Sopenharmony_ci    std::cin >> input;
428e5d0e473Sopenharmony_ci    identifier = std::atoi(input.c_str());
429e5d0e473Sopenharmony_ci    int32_t result = smsService->SetCBConfig(slotIdTestm, enable, identifier, identifier, ranType);
430e5d0e473Sopenharmony_ci    std::cout << "TestEnableCBConfig:" << result << std::endl;
431e5d0e473Sopenharmony_ci}
432e5d0e473Sopenharmony_ci
433e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestDisableCBConfig(const sptr<ISmsServiceInterface> &smsService) const
434e5d0e473Sopenharmony_ci{
435e5d0e473Sopenharmony_ci    AccessMmsToken token;
436e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
437e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
438e5d0e473Sopenharmony_ci        return;
439e5d0e473Sopenharmony_ci    }
440e5d0e473Sopenharmony_ci    std::string dest;
441e5d0e473Sopenharmony_ci    std::cout << "Please enter the card id" << std::endl;
442e5d0e473Sopenharmony_ci    int32_t slotIdTestn;
443e5d0e473Sopenharmony_ci    std::cin >> dest;
444e5d0e473Sopenharmony_ci    slotIdTestn = atoi(dest.c_str());
445e5d0e473Sopenharmony_ci    dest.clear();
446e5d0e473Sopenharmony_ci    bool enable = false;
447e5d0e473Sopenharmony_ci    uint32_t identifier = 0;
448e5d0e473Sopenharmony_ci    uint8_t ranType = 1;
449e5d0e473Sopenharmony_ci    std::string input;
450e5d0e473Sopenharmony_ci    std::cout << "Please enter identifier" << std::endl;
451e5d0e473Sopenharmony_ci    std::cin >> input;
452e5d0e473Sopenharmony_ci    identifier = std::atoi(input.c_str());
453e5d0e473Sopenharmony_ci    int32_t result = smsService->SetCBConfig(slotIdTestn, enable, identifier, identifier, ranType);
454e5d0e473Sopenharmony_ci    std::cout << "TestDisableCBConfig:" << result << std::endl;
455e5d0e473Sopenharmony_ci}
456e5d0e473Sopenharmony_ci
457e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestSetDefaultSmsSlotId(const sptr<ISmsServiceInterface> &smsService) const
458e5d0e473Sopenharmony_ci{
459e5d0e473Sopenharmony_ci    AccessMmsToken token;
460e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
461e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
462e5d0e473Sopenharmony_ci        return;
463e5d0e473Sopenharmony_ci    }
464e5d0e473Sopenharmony_ci    int32_t slotId;
465e5d0e473Sopenharmony_ci    std::string input;
466e5d0e473Sopenharmony_ci    std::cout << "Please enter Slot Id" << std::endl;
467e5d0e473Sopenharmony_ci    std::cin >> input;
468e5d0e473Sopenharmony_ci    slotId = std::atoi(input.c_str());
469e5d0e473Sopenharmony_ci    int32_t result = smsService->SetDefaultSmsSlotId(slotId);
470e5d0e473Sopenharmony_ci    std::cout << "TestSetDefaultSmsSlotId:" << result << std::endl;
471e5d0e473Sopenharmony_ci}
472e5d0e473Sopenharmony_ci
473e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestGetDefaultSmsSlotId(const sptr<ISmsServiceInterface> &smsService) const
474e5d0e473Sopenharmony_ci{
475e5d0e473Sopenharmony_ci    int32_t result;
476e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
477e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
478e5d0e473Sopenharmony_ci        return;
479e5d0e473Sopenharmony_ci    }
480e5d0e473Sopenharmony_ci    result = smsService->GetDefaultSmsSlotId();
481e5d0e473Sopenharmony_ci    std::cout << "TestGetDefaultSmsSlotId:" << result << std::endl;
482e5d0e473Sopenharmony_ci}
483e5d0e473Sopenharmony_ci
484e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestSplitMessage(const sptr<ISmsServiceInterface> &smsService) const
485e5d0e473Sopenharmony_ci{
486e5d0e473Sopenharmony_ci    AccessMmsToken token;
487e5d0e473Sopenharmony_ci    std::vector<std::u16string> result;
488e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
489e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
490e5d0e473Sopenharmony_ci        return;
491e5d0e473Sopenharmony_ci    }
492e5d0e473Sopenharmony_ci    std::string input;
493e5d0e473Sopenharmony_ci    std::cout << "Please enter message" << std::endl;
494e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
495e5d0e473Sopenharmony_ci    smsService->SplitMessage(StringUtils::ToUtf16(input), result);
496e5d0e473Sopenharmony_ci    std::cout << "TestSplitMessage size:" << result.size() << std::endl;
497e5d0e473Sopenharmony_ci    for (auto &item : result) {
498e5d0e473Sopenharmony_ci        std::cout << StringUtils::ToUtf8(item) << std::endl;
499e5d0e473Sopenharmony_ci    }
500e5d0e473Sopenharmony_ci}
501e5d0e473Sopenharmony_ci
502e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestGetSmsSegmentsInfo(const sptr<ISmsServiceInterface> &smsService) const
503e5d0e473Sopenharmony_ci{
504e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
505e5d0e473Sopenharmony_ci        std::cout << "TestGetSmsSegmentsInfo smsService is nullptr." << std::endl;
506e5d0e473Sopenharmony_ci        return;
507e5d0e473Sopenharmony_ci    }
508e5d0e473Sopenharmony_ci    int32_t slotId;
509e5d0e473Sopenharmony_ci    std::string input;
510e5d0e473Sopenharmony_ci    std::cout << "TestGetSmsSegmentsInfo Please enter Slot Id" << std::endl;
511e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
512e5d0e473Sopenharmony_ci    slotId = std::atoi(input.c_str());
513e5d0e473Sopenharmony_ci    input.clear();
514e5d0e473Sopenharmony_ci    std::cout << "Please enter message" << std::endl;
515e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
516e5d0e473Sopenharmony_ci    ISmsServiceInterface::SmsSegmentsInfo result;
517e5d0e473Sopenharmony_ci    if (smsService->GetSmsSegmentsInfo(slotId, StringUtils::ToUtf16(input), false, result) != TELEPHONY_ERR_SUCCESS) {
518e5d0e473Sopenharmony_ci        std::cout << "Get Sms SegmentsInfo Fail." << std::endl;
519e5d0e473Sopenharmony_ci        return;
520e5d0e473Sopenharmony_ci    }
521e5d0e473Sopenharmony_ci
522e5d0e473Sopenharmony_ci    int32_t codeScheme = static_cast<int32_t>(result.msgCodeScheme);
523e5d0e473Sopenharmony_ci    std::cout << "msgSegCount:" << result.msgSegCount << " msgEncodingCount:" << result.msgEncodingCount << std::endl;
524e5d0e473Sopenharmony_ci    std::cout << "msgRemainCount:" << result.msgRemainCount << " msgCodeScheme:" << codeScheme << std::endl;
525e5d0e473Sopenharmony_ci}
526e5d0e473Sopenharmony_ci
527e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestIsImsSmsSupported(const sptr<ISmsServiceInterface> &smsService) const
528e5d0e473Sopenharmony_ci{
529e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
530e5d0e473Sopenharmony_ci        std::cout << "TestIsImsSmsSupported smsService is nullptr." << std::endl;
531e5d0e473Sopenharmony_ci        return;
532e5d0e473Sopenharmony_ci    }
533e5d0e473Sopenharmony_ci    int32_t slotId;
534e5d0e473Sopenharmony_ci    std::string input;
535e5d0e473Sopenharmony_ci    std::cout << "TestIsImsSmsSupported Please enter Slot Id" << std::endl;
536e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
537e5d0e473Sopenharmony_ci    slotId = std::atoi(input.c_str());
538e5d0e473Sopenharmony_ci    bool result = false;
539e5d0e473Sopenharmony_ci    smsService->IsImsSmsSupported(slotId, result);
540e5d0e473Sopenharmony_ci    std::string res = result ? "true" : "false";
541e5d0e473Sopenharmony_ci    std::cout << "IsImsSmsSupported:" << res << std::endl;
542e5d0e473Sopenharmony_ci}
543e5d0e473Sopenharmony_ci
544e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestSetImsSmsConfig(const sptr<ISmsServiceInterface> &smsService) const
545e5d0e473Sopenharmony_ci{
546e5d0e473Sopenharmony_ci    AccessMmsToken token;
547e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
548e5d0e473Sopenharmony_ci        std::cout << "TestSetImsSmsConfig smsService is nullptr." << std::endl;
549e5d0e473Sopenharmony_ci        return;
550e5d0e473Sopenharmony_ci    }
551e5d0e473Sopenharmony_ci    int32_t slotId;
552e5d0e473Sopenharmony_ci    std::string input;
553e5d0e473Sopenharmony_ci    std::cout << "TestSetImsSmsConfig Please enter Slot Id" << std::endl;
554e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
555e5d0e473Sopenharmony_ci    slotId = std::atoi(input.c_str());
556e5d0e473Sopenharmony_ci    int32_t enable;
557e5d0e473Sopenharmony_ci    std::cout << "Please enter enable" << std::endl;
558e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
559e5d0e473Sopenharmony_ci    enable = std::atoi(input.c_str());
560e5d0e473Sopenharmony_ci    std::string res = smsService->SetImsSmsConfig(slotId, enable) ? "true" : "false";
561e5d0e473Sopenharmony_ci    std::cout << "SetImsSmsConfig:" << res << std::endl;
562e5d0e473Sopenharmony_ci}
563e5d0e473Sopenharmony_ci
564e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestGetImsShortMessageFormat(const sptr<ISmsServiceInterface> &smsService) const
565e5d0e473Sopenharmony_ci{
566e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
567e5d0e473Sopenharmony_ci        std::cout << "smsService is nullptr." << std::endl;
568e5d0e473Sopenharmony_ci        return;
569e5d0e473Sopenharmony_ci    }
570e5d0e473Sopenharmony_ci    std::u16string format;
571e5d0e473Sopenharmony_ci    smsService->GetImsShortMessageFormat(format);
572e5d0e473Sopenharmony_ci    std::cout << "GetImsShortMessageFormat:" << StringUtils::ToUtf8(format) << std::endl;
573e5d0e473Sopenharmony_ci}
574e5d0e473Sopenharmony_ci
575e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestAddBlockPhone() const
576e5d0e473Sopenharmony_ci{
577e5d0e473Sopenharmony_ci    std::shared_ptr<DataShare::DataShareHelper> helper = CreateDataAHelper();
578e5d0e473Sopenharmony_ci    if (helper == nullptr) {
579e5d0e473Sopenharmony_ci        std::cout << "Creator helper nullptr error." << std::endl;
580e5d0e473Sopenharmony_ci        return;
581e5d0e473Sopenharmony_ci    }
582e5d0e473Sopenharmony_ci    std::string input;
583e5d0e473Sopenharmony_ci    std::cout << "Please enter block phone number" << std::endl;
584e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
585e5d0e473Sopenharmony_ci
586e5d0e473Sopenharmony_ci    Uri uri("datashare:///com.ohos.contactsdataability/contacts/contact_blocklist");
587e5d0e473Sopenharmony_ci    DataShare::DataShareValuesBucket value;
588e5d0e473Sopenharmony_ci    value.Put("phone_number", input);
589e5d0e473Sopenharmony_ci    int ret = helper->Insert(uri, value);
590e5d0e473Sopenharmony_ci    helper->Release();
591e5d0e473Sopenharmony_ci    std::cout << "add block:" << input << ((ret >= 0) ? " success" : " error") << std::endl;
592e5d0e473Sopenharmony_ci}
593e5d0e473Sopenharmony_ci
594e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestRemoveBlockPhone() const
595e5d0e473Sopenharmony_ci{
596e5d0e473Sopenharmony_ci    std::shared_ptr<DataShare::DataShareHelper> helper = CreateDataAHelper();
597e5d0e473Sopenharmony_ci    if (helper == nullptr) {
598e5d0e473Sopenharmony_ci        std::cout << "Creator helper nullptr error." << std::endl;
599e5d0e473Sopenharmony_ci        return;
600e5d0e473Sopenharmony_ci    }
601e5d0e473Sopenharmony_ci    std::string input;
602e5d0e473Sopenharmony_ci    std::cout << "Please enter Remove phone number" << std::endl;
603e5d0e473Sopenharmony_ci    std::getline(std::cin, input);
604e5d0e473Sopenharmony_ci    Uri uri("datashare:///com.ohos.contactsdataability/contacts/contact_blocklist");
605e5d0e473Sopenharmony_ci    DataShare::DataSharePredicates predicates;
606e5d0e473Sopenharmony_ci    predicates.EqualTo("phone_number", input);
607e5d0e473Sopenharmony_ci    int ret = helper->Delete(uri, predicates);
608e5d0e473Sopenharmony_ci    helper->Release();
609e5d0e473Sopenharmony_ci    std::cout << "remove block:" << input << ((ret >= 0) ? " success" : " error") << std::endl;
610e5d0e473Sopenharmony_ci}
611e5d0e473Sopenharmony_ci
612e5d0e473Sopenharmony_civoid GsmSmsSenderTest::TestHasSmsCapability(const sptr<ISmsServiceInterface> &smsService) const
613e5d0e473Sopenharmony_ci{
614e5d0e473Sopenharmony_ci    if (smsService == nullptr) {
615e5d0e473Sopenharmony_ci        std::cout << "GsmSmsSenderTest smsService is nullptr error." << std::endl;
616e5d0e473Sopenharmony_ci        return;
617e5d0e473Sopenharmony_ci    }
618e5d0e473Sopenharmony_ci    std::string res = smsService->HasSmsCapability() ? "true" : "false";
619e5d0e473Sopenharmony_ci    std::cout << "HasSmsCapability:" << res << std::endl;
620e5d0e473Sopenharmony_ci}
621e5d0e473Sopenharmony_ci
622e5d0e473Sopenharmony_cistd::shared_ptr<DataShare::DataShareHelper> GsmSmsSenderTest::CreateDataAHelper() const
623e5d0e473Sopenharmony_ci{
624e5d0e473Sopenharmony_ci    auto saManager = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
625e5d0e473Sopenharmony_ci    if (saManager == nullptr) {
626e5d0e473Sopenharmony_ci        std::cout << "Get system ability mgr failed." << std::endl;
627e5d0e473Sopenharmony_ci        return nullptr;
628e5d0e473Sopenharmony_ci    }
629e5d0e473Sopenharmony_ci    auto remoteObj = saManager->GetSystemAbility(TELEPHONY_SMS_MMS_SYS_ABILITY_ID);
630e5d0e473Sopenharmony_ci    if (remoteObj == nullptr) {
631e5d0e473Sopenharmony_ci        std::cout << "GetSystemAbility Service Failed." << std::endl;
632e5d0e473Sopenharmony_ci        return nullptr;
633e5d0e473Sopenharmony_ci    }
634e5d0e473Sopenharmony_ci    const std::string uriContact("datashare:///com.ohos.contactsdataability");
635e5d0e473Sopenharmony_ci    return DataShare::DataShareHelper::Creator(remoteObj, uriContact);
636e5d0e473Sopenharmony_ci}
637e5d0e473Sopenharmony_ci} // namespace Telephony
638e5d0e473Sopenharmony_ci} // namespace OHOS
639