1 /*
2 * Copyright (C) 2022 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 #include "nfc_service.h"
16 #include <unistd.h>
17 #include "app_data_parser.h"
18 #include "infc_controller_callback.h"
19 #include "iservice_registry.h"
20 #include "loghelper.h"
21 #include "nfc_preferences.h"
22 #include "nfc_event_handler.h"
23 #include "nfc_event_publisher.h"
24 #include "nfc_hisysevent.h"
25 #include "nfc_polling_params.h"
26 #include "nfc_sdk_common.h"
27 #include "nfc_timer.h"
28 #include "nfc_watch_dog.h"
29 #include "tag_session.h"
30 #include "external_deps_proxy.h"
31 #include "want.h"
32 #include "nci_nfcc_proxy.h"
33 #include "nci_tag_proxy.h"
34 #include "nci_ce_proxy.h"
35 #include "hce_session.h"
36
37 namespace OHOS {
38 namespace NFC {
39 const std::u16string NFC_SERVICE_NAME = OHOS::to_utf16("ohos.nfc.service");
40 uint32_t NfcService::unloadStaSaTimerId{0};
41
NfcService()42 NfcService::NfcService()
43 : eventHandler_(nullptr),
44 tagDispatcher_(nullptr),
45 nfcControllerImpl_(nullptr),
46 nfcState_(KITS::STATE_OFF)
47 {
48 }
49
~NfcService()50 NfcService::~NfcService()
51 {
52 nfcControllerImpl_ = nullptr;
53 nfcPollingManager_ = nullptr;
54 nfcRoutingManager_ = nullptr;
55 if (task_ && task_->joinable()) {
56 task_->join();
57 }
58 if (rootTask_ && rootTask_->joinable()) {
59 rootTask_->join();
60 }
61 }
62
GetInstance() const63 std::weak_ptr<NfcService> NfcService::GetInstance() const
64 {
65 return nfcService_;
66 }
67
GetNciTagProxy(void)68 std::weak_ptr<NCI::INciTagInterface> NfcService::GetNciTagProxy(void)
69 {
70 return nciTagProxy_;
71 }
72
GetNfcPollingManager()73 std::weak_ptr<NfcPollingManager> NfcService::GetNfcPollingManager()
74 {
75 return nfcPollingManager_;
76 }
77
GetNfcRoutingManager()78 std::weak_ptr<NfcRoutingManager> NfcService::GetNfcRoutingManager()
79 {
80 return nfcRoutingManager_;
81 }
82
GetCeService()83 std::weak_ptr<CeService> NfcService::GetCeService()
84 {
85 return ceService_;
86 }
87
GetSimVendorBundleName()88 std::string NfcService::GetSimVendorBundleName()
89 {
90 return nciCeProxy_->GetSimVendorBundleName();
91 }
92
Initialize()93 bool NfcService::Initialize()
94 {
95 nfcService_ = shared_from_this();
96 InfoLog("Nfc service initialize.");
97 nciNfccProxy_ = std::make_shared<NFC::NCI::NciNfccProxy>();
98 nciTagProxy_ = std::make_shared<NFC::NCI::NciTagProxy>();
99 nciCeProxy_ = std::make_shared<NFC::NCI::NciCeProxy>();
100 nciTagProxy_->SetTagListener(nfcService_);
101 nciCeProxy_->SetCeHostListener(nfcService_);
102
103 // inner message handler, used by other modules as initialization parameters
104 std::shared_ptr<AppExecFwk::EventRunner> runner = AppExecFwk::EventRunner::Create("nfcservice::EventRunner");
105 eventHandler_ = std::make_shared<NfcEventHandler>(runner, shared_from_this());
106 tagDispatcher_ = std::make_shared<TAG::TagDispatcher>(shared_from_this());
107 ceService_ = std::make_shared<CeService>(shared_from_this(), nciCeProxy_);
108
109 nfcPollingManager_ = std::make_shared<NfcPollingManager>(shared_from_this(), nciNfccProxy_, nciTagProxy_);
110 nfcRoutingManager_ = std::make_shared<NfcRoutingManager>(eventHandler_, nciNfccProxy_,
111 nciCeProxy_, shared_from_this());
112 tagSessionIface_ = new TAG::TagSession(shared_from_this());
113 hceSessionIface_ = new HCE::HceSession(shared_from_this());
114
115 // used by NfcSaManager::Init(), to public for the proxy.
116 nfcControllerImpl_ = new NfcControllerImpl(shared_from_this());
117 nfcPollingManager_->ResetCurrPollingParams();
118
119 runner->Run();
120 // NFC ROOT
121 ExecuteTask(KITS::TASK_INITIALIZE);
122 return true;
123 }
124
UnloadNfcSa()125 void NfcService::UnloadNfcSa()
126 {
127 InfoLog("%{public}s enter, systemAbilityId = [%{public}d] unloading", __func__, KITS::NFC_MANAGER_SYS_ABILITY_ID);
128 if (nfcState_ != KITS::STATE_OFF) {
129 InfoLog("%{public}s nfc state = [%{public}d] skip unload", __func__, nfcState_);
130 return;
131 }
132 sptr<ISystemAbilityManager> samgr =
133 SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
134 if (samgr == nullptr) {
135 ErrorLog("%{public}s: get system ability manager failed!", __func__);
136 return;
137 }
138 int32_t ret = samgr->UnloadSystemAbility(KITS::NFC_MANAGER_SYS_ABILITY_ID);
139 if (ret != ERR_NONE) {
140 ErrorLog("%{public}s: Failed to unload system ability, SA Id = [%{public}d], ret = [%{public}d].",
141 __func__, KITS::NFC_MANAGER_SYS_ABILITY_ID, ret);
142 }
143 }
144
GetTagDispatcher()145 std::weak_ptr<TAG::TagDispatcher> NfcService::GetTagDispatcher()
146 {
147 return tagDispatcher_;
148 }
149
GetTagServiceIface()150 OHOS::sptr<IRemoteObject> NfcService::GetTagServiceIface()
151 {
152 return tagSessionIface_;
153 }
154
OnTagDiscovered(uint32_t tagDiscId)155 void NfcService::OnTagDiscovered(uint32_t tagDiscId)
156 {
157 InfoLog("NfcService::OnTagDiscovered tagDiscId %{public}d", tagDiscId);
158 eventHandler_->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_TAG_FOUND), tagDiscId, 0);
159 InfoLog("NfcService::OnTagDiscovered end");
160 }
161
OnTagLost(uint32_t tagDiscId)162 void NfcService::OnTagLost(uint32_t tagDiscId)
163 {
164 InfoLog("NfcService::OnTagLost tagDiscId %{public}d", tagDiscId);
165 eventHandler_->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_TAG_LOST), tagDiscId, 0);
166 }
167
FieldActivated()168 void NfcService::FieldActivated()
169 {
170 InfoLog("NfcService::FieldActivated");
171 eventHandler_->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_FIELD_ACTIVATED));
172 }
173
FieldDeactivated()174 void NfcService::FieldDeactivated()
175 {
176 InfoLog("NfcService::FieldDeactivated");
177 eventHandler_->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_FIELD_DEACTIVATED));
178 }
179
180 #ifdef VENDOR_APPLICATIONS_ENABLED
OnVendorEvent(int eventType,int arg1,std::string arg2)181 void NfcService::OnVendorEvent(int eventType, int arg1, std::string arg2)
182 {
183 InfoLog("NfcService::OnVendorEvent");
184 eventHandler_->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_VENDOR_EVENT), eventType, 0);
185 }
186 #endif
187
OnCardEmulationData(const std::vector<uint8_t> & data)188 void NfcService::OnCardEmulationData(const std::vector<uint8_t> &data)
189 {
190 InfoLog("NfcService::OnCardEmulationData");
191 ceService_->OnCardEmulationData(data);
192 }
193
OnCardEmulationActivated()194 void NfcService::OnCardEmulationActivated()
195 {
196 InfoLog("NfcService::OnCardEmulationActivated");
197 ceService_->OnCardEmulationActivated();
198 }
199
GetHceServiceIface()200 OHOS::sptr<IRemoteObject> NfcService::GetHceServiceIface()
201 {
202 return hceSessionIface_;
203 }
204
OnCardEmulationDeactivated()205 void NfcService::OnCardEmulationDeactivated()
206 {
207 InfoLog("NfcService::OnCardEmulationDeactivated");
208 ceService_->OnCardEmulationDeactivated();
209 }
210
IsNfcTaskReady(std::future<int> & future) const211 bool NfcService::IsNfcTaskReady(std::future<int>& future) const
212 {
213 for (uint8_t count = 0; count < MAX_RETRY_TIME; count++) {
214 if (future.valid()) {
215 std::future_status result = future.wait_for(std::chrono::milliseconds(TASK_THREAD_WAIT_MS));
216 if (result != std::future_status::ready) {
217 InfoLog("result = %{public}d, not ready", result);
218 usleep(TASK_THREAD_WAIT_US);
219 continue;
220 } else {
221 InfoLog("result = %{public}d, ready", result);
222 return true;
223 }
224 } else {
225 return true;
226 }
227 }
228 return false;
229 }
230
ExecuteTask(KITS::NfcTask param)231 int NfcService::ExecuteTask(KITS::NfcTask param)
232 {
233 std::lock_guard<std::mutex> lock(mutex_);
234 if (nfcState_ == KITS::STATE_TURNING_OFF || nfcState_ == KITS::STATE_TURNING_ON) {
235 WarnLog("Execute task %{public}d from bad state %{public}d", param, nfcState_);
236 return ERR_NONE;
237 }
238
239 // Check the current state
240 if (param == KITS::TASK_TURN_ON && nfcState_ == KITS::STATE_ON) {
241 WarnLog("NFC Turn On, already On");
242 ExternalDepsProxy::GetInstance().UpdateNfcState(KITS::STATE_ON);
243 return ERR_NONE;
244 }
245 if (param == KITS::TASK_TURN_OFF && nfcState_ == KITS::STATE_OFF) {
246 WarnLog("NFC Turn Off, already Off");
247 ExternalDepsProxy::GetInstance().UpdateNfcState(KITS::STATE_OFF);
248 UnloadNfcSa();
249 return ERR_NONE;
250 }
251
252 std::promise<int> promise;
253 if (rootTask_) {
254 if (!IsNfcTaskReady(future_)) {
255 WarnLog("ExecuteTask, IsNfcTaskReady is false.");
256 return KITS::ERR_NFC_STATE_INVALID;
257 }
258 if (task_ && task_->joinable()) {
259 task_->join();
260 }
261 future_ = promise.get_future();
262 task_ = std::make_unique<std::thread>([this, param, promise = std::move(promise)]() mutable {
263 this->NfcTaskThread(param, std::move(promise));
264 });
265 } else {
266 rootTask_ = std::make_unique<std::thread>([this, param, promise = std::move(promise)]() mutable {
267 this->NfcTaskThread(param, std::move(promise));
268 });
269 }
270 return ERR_NONE;
271 }
272
NfcTaskThread(KITS::NfcTask params,std::promise<int> promise)273 void NfcService::NfcTaskThread(KITS::NfcTask params, std::promise<int> promise)
274 {
275 InfoLog("Nfc task thread params %{public}d", params);
276 switch (params) {
277 case KITS::TASK_TURN_ON:
278 DoTurnOn();
279 break;
280 case KITS::TASK_TURN_OFF:
281 DoTurnOff();
282 break;
283 case KITS::TASK_INITIALIZE:
284 DoInitialize();
285 break;
286 default:
287 break;
288 }
289 promise.set_value_at_thread_exit(0);
290 return;
291 }
292
DoTurnOn()293 bool NfcService::DoTurnOn()
294 {
295 InfoLog("Nfc do turn on: current state %{public}d", nfcState_);
296
297 CancelUnloadNfcSaTimer();
298 UpdateNfcState(KITS::STATE_TURNING_ON);
299 NotifyMessageToVendor(KITS::NFC_SWITCH_KEY, std::to_string(KITS::STATE_TURNING_ON));
300 NfcWatchDog nfcWatchDog("DoTurnOn", WAIT_MS_INIT, nciNfccProxy_);
301 nfcWatchDog.Run();
302 // Routing WakeLock acquire
303 if (!nciNfccProxy_->Initialize()) {
304 ErrorLog("Nfc do turn on err");
305 UpdateNfcState(KITS::STATE_OFF);
306 // Routing Wake Lock release
307 nfcWatchDog.Cancel();
308 // Do turn on failed, openRequestCnt and openFailedCnt = 1, others = 0
309 ExternalDepsProxy::GetInstance().WriteOpenAndCloseHiSysEvent(DEFAULT_COUNT, DEFAULT_COUNT,
310 NOT_COUNT, NOT_COUNT);
311 // Record failed event
312 ExternalDepsProxy::GetInstance().WriteNfcFailedHiSysEvent(MainErrorCode::NFC_OPEN_FAILED,
313 SubErrorCode::NCI_RESP_ERROR);
314 NotifyMessageToVendor(KITS::NFC_SWITCH_KEY, std::to_string(KITS::STATE_OFF));
315 return false;
316 }
317 // Routing Wake Lock release
318 nfcWatchDog.Cancel();
319
320 nciVersion_ = nciNfccProxy_->GetNciVersion();
321 InfoLog("Get nci version: ver %{public}d", nciVersion_);
322
323 UpdateNfcState(KITS::STATE_ON);
324
325 NfcWatchDog nfcRoutingManagerDog("RoutingManager", WAIT_ROUTING_INIT, nciNfccProxy_);
326 nfcRoutingManagerDog.Run();
327 screenState_ = (int)eventHandler_->CheckScreenState();
328 nciNfccProxy_->SetScreenStatus(screenState_);
329
330 /* Start polling loop */
331 nfcPollingManager_->StartPollingLoop(true);
332 ceService_->Initialize();
333 ceService_->InitConfigAidRouting(true);
334
335 nfcRoutingManager_->ComputeRoutingParams(ceService_->GetDefaultPaymentType());
336 nfcRoutingManager_->CommitRouting();
337 nfcRoutingManagerDog.Cancel();
338 // Do turn on success, openRequestCnt = 1, others = 0
339 ExternalDepsProxy::GetInstance().WriteOpenAndCloseHiSysEvent(DEFAULT_COUNT, NOT_COUNT, NOT_COUNT, NOT_COUNT);
340 // Record success event
341 ExternalDepsProxy::GetInstance().WriteNfcFailedHiSysEvent(
342 MainErrorCode::NFC_OPEN_SUCCEED, SubErrorCode::DEFAULT_ERR_DEF);
343 NotifyMessageToVendor(KITS::NFC_SWITCH_KEY, std::to_string(KITS::STATE_ON));
344 return true;
345 }
346
DoTurnOff()347 bool NfcService::DoTurnOff()
348 {
349 InfoLog("Nfc do turn off: current state %{public}d", nfcState_);
350 UpdateNfcState(KITS::STATE_TURNING_OFF);
351 NotifyMessageToVendor(KITS::NFC_SWITCH_KEY, std::to_string(KITS::STATE_TURNING_OFF));
352
353 /* WatchDog to monitor for Deinitialize failed */
354 NfcWatchDog nfcWatchDog("DoTurnOff", WAIT_MS_SET_ROUTE, nciNfccProxy_);
355 nfcWatchDog.Run();
356
357 bool result = nciNfccProxy_->Deinitialize();
358 InfoLog("Nfcc deinitialize result %{public}d", result);
359
360 nfcWatchDog.Cancel();
361
362 nfcPollingManager_->ResetCurrPollingParams();
363 ceService_->Deinitialize();
364 UpdateNfcState(KITS::STATE_OFF);
365
366 // Do turn off success, closeRequestCnt = 1, others = 0
367 ExternalDepsProxy::GetInstance().WriteOpenAndCloseHiSysEvent(NOT_COUNT, NOT_COUNT, DEFAULT_COUNT, NOT_COUNT);
368 // Record success event
369 ExternalDepsProxy::GetInstance().WriteNfcFailedHiSysEvent(
370 MainErrorCode::NFC_CLOSE_SUCCEED, SubErrorCode::DEFAULT_ERR_DEF);
371 NotifyMessageToVendor(KITS::NFC_SWITCH_KEY, std::to_string(KITS::STATE_OFF));
372 return result;
373 }
374
DoInitialize()375 void NfcService::DoInitialize()
376 {
377 eventHandler_->Intialize(tagDispatcher_, ceService_, nfcPollingManager_, nfcRoutingManager_, nciNfccProxy_);
378 ExternalDepsProxy::GetInstance().InitAppList();
379
380 int nfcStateFromPref = ExternalDepsProxy::GetInstance().NfcDataGetInt(PREF_KEY_STATE);
381 int nfcStateFromParam = ExternalDepsProxy::GetInstance().GetNfcStateFromParam();
382 if (nfcStateFromPref == KITS::STATE_ON || nfcStateFromParam == KITS::STATE_ON) {
383 InfoLog("should turn nfc on.");
384 ExecuteTask(KITS::TASK_TURN_ON);
385 } else {
386 // 5min later unload nfc_service, if nfc state is off
387 SetupUnloadNfcSaTimer(true);
388 }
389 ExternalDepsProxy::GetInstance().NfcDataClear(); // delete nfc state xml
390 }
391
SetRegisterCallBack(const sptr<INfcControllerCallback> & callback,const std::string & type,Security::AccessToken::AccessTokenID callerToken)392 int NfcService::SetRegisterCallBack(const sptr<INfcControllerCallback> &callback,
393 const std::string& type, Security::AccessToken::AccessTokenID callerToken)
394 {
395 InfoLog("NfcService SetRegisterCallBack");
396 if (callback == nullptr) {
397 ErrorLog("register callback is nullptr");
398 return KITS::ERR_NFC_PARAMETERS;
399 }
400 std::lock_guard<std::mutex> lock(mutex_);
401 bool isExist = false;
402 NfcStateRegistryRecord record;
403 InfoLog("RecordsSize=%{public}zu,isExist=%{public}d,type=%{public}s",
404 stateRecords_.size(), isExist, type.c_str());
405 for (size_t i = 0; i < stateRecords_.size(); i++) {
406 record = stateRecords_[i];
407 InfoLog("record.type_=%{public}s", record.type_.c_str());
408 if (record.type_.compare(type) == 0 && record.callerToken_ == callerToken) {
409 isExist = true;
410 break;
411 }
412 }
413 InfoLog("isExist=%{public}d", isExist);
414 if (!isExist) {
415 record.type_ = type;
416 record.callerToken_ = callerToken;
417 record.nfcStateChangeCallback_ = callback;
418 stateRecords_.push_back(record);
419 callback->OnNfcStateChanged(nfcState_);
420 }
421 return KITS::ERR_NONE;
422 }
423
RemoveRegisterCallBack(const std::string & type,Security::AccessToken::AccessTokenID callerToken)424 int NfcService::RemoveRegisterCallBack(const std::string& type,
425 Security::AccessToken::AccessTokenID callerToken)
426 {
427 InfoLog("NfcService RemoveRegisterCallBack");
428 std::lock_guard<std::mutex> lock(mutex_);
429 int32_t result = KITS::ERR_NFC_PARAMETERS;
430 std::vector<NfcStateRegistryRecord>::iterator it;
431 for (it = stateRecords_.begin(); it != stateRecords_.end(); ++it) {
432 if (it->type_.compare(type) == 0 && it->callerToken_ == callerToken) {
433 InfoLog("NfcService RemoveRegisterCallBack success.");
434 stateRecords_.erase(it);
435 result = KITS::ERR_NONE;
436 break;
437 }
438 }
439 return result;
440 }
441
RemoveAllRegisterCallBack(Security::AccessToken::AccessTokenID callerToken)442 int NfcService::RemoveAllRegisterCallBack(Security::AccessToken::AccessTokenID callerToken)
443 {
444 InfoLog("NfcService RemoveAllRegisterCallBack");
445 std::lock_guard<std::mutex> lock(mutex_);
446 int32_t result = KITS::ERR_NFC_PARAMETERS;
447 std::vector<NfcStateRegistryRecord>::iterator it;
448 for (it = stateRecords_.begin(); it != stateRecords_.end(); ++it) {
449 if (it->callerToken_ == callerToken) {
450 InfoLog("NfcService RemoveAllRegisterCallBack success.");
451 stateRecords_.erase(it);
452 result = KITS::ERR_NONE;
453 break;
454 }
455 }
456 return result;
457 }
458
UpdateNfcState(int newState)459 void NfcService::UpdateNfcState(int newState)
460 {
461 InfoLog("Update nfc state: oldState %{public}d, newState %{public}d", nfcState_, newState);
462 std::lock_guard<std::mutex> lock(mutex_);
463 if (newState == nfcState_) {
464 return;
465 }
466 nfcState_ = newState;
467
468 ExternalDepsProxy::GetInstance().UpdateNfcState(newState);
469 ExternalDepsProxy::GetInstance().PublishNfcStateChanged(newState);
470 InfoLog("Update nfc state: nfcState_ %{public}d, newState %{public}d succ", nfcState_, newState);
471
472 // notify the nfc state changed by callback to JS APP
473 InfoLog("stateRecords_.size[%{public}zu]", stateRecords_.size());
474 for (size_t i = 0; i < stateRecords_.size(); i++) {
475 NfcStateRegistryRecord record = stateRecords_[i];
476 DebugLog("stateRecords_[%{public}d]:type_=%{public}s ",
477 (int)i, record.type_.c_str());
478 if (record.nfcStateChangeCallback_ != nullptr) {
479 record.nfcStateChangeCallback_->OnNfcStateChanged(newState);
480 }
481 }
482 if (nfcState_ == KITS::STATE_OFF) {
483 // 5min later unload nfc_service, if nfc state is off
484 SetupUnloadNfcSaTimer(true);
485 } else {
486 CancelUnloadNfcSaTimer();
487 }
488 }
489
GetNfcState()490 int NfcService::GetNfcState()
491 {
492 InfoLog("start to get nfc state.");
493 std::lock_guard<std::mutex> lock(mutex_);
494 // 5min later unload nfc_service, if nfc state is off
495 if (nfcState_ == KITS::STATE_OFF) {
496 SetupUnloadNfcSaTimer(false);
497 }
498 InfoLog("get nfc state[%{public}d]", nfcState_);
499 return nfcState_;
500 }
501
GetScreenState()502 int NfcService::GetScreenState()
503 {
504 std::lock_guard<std::mutex> lock(mutex_);
505 return screenState_;
506 }
507
GetNciVersion()508 int NfcService::GetNciVersion()
509 {
510 return nciVersion_;
511 }
512
IsNfcEnabled()513 bool NfcService::IsNfcEnabled()
514 {
515 InfoLog("IsNfcEnabled, nfcState_=%{public}d", nfcState_);
516 return (nfcState_ == KITS::STATE_ON);
517 }
518
HandleShutdown()519 void NfcService::HandleShutdown()
520 {
521 std::lock_guard<std::mutex> lock(mutex_);
522 ExternalDepsProxy::GetInstance().UpdateNfcState(nfcState_);
523 InfoLog("device is shutting down, nfcState_ = %{public}d", nfcState_);
524 nciNfccProxy_->Shutdown();
525 }
526
RegNdefMsgCb(const sptr<INdefMsgCallback> & callback)527 bool NfcService::RegNdefMsgCb(const sptr<INdefMsgCallback> &callback)
528 {
529 DebugLog("NfcService::RegNdefMsgCb");
530 tagDispatcher_->RegNdefMsgCb(callback);
531 return true;
532 }
533
SetupUnloadNfcSaTimer(bool shouldRestartTimer)534 void NfcService::SetupUnloadNfcSaTimer(bool shouldRestartTimer)
535 {
536 TimeOutCallback timeoutCallback = [this]() { UnloadNfcSa(); };
537 if (unloadStaSaTimerId != 0) {
538 if (!shouldRestartTimer) {
539 InfoLog("timer already started.");
540 return;
541 }
542 NfcTimer::GetInstance()->UnRegister(unloadStaSaTimerId);
543 unloadStaSaTimerId = 0;
544 }
545 NfcTimer::GetInstance()->Register(timeoutCallback, unloadStaSaTimerId, TIMEOUT_UNLOAD_NFC_SA);
546 }
547
CancelUnloadNfcSaTimer()548 void NfcService::CancelUnloadNfcSaTimer()
549 {
550 if (unloadStaSaTimerId != 0) {
551 NfcTimer::GetInstance()->UnRegister(unloadStaSaTimerId);
552 unloadStaSaTimerId = 0;
553 }
554 }
555
NotifyMessageToVendor(int key,const std::string & value)556 void NfcService::NotifyMessageToVendor(int key, const std::string &value)
557 {
558 if (nciNfccProxy_ == nullptr) {
559 ErrorLog("nciNfccProxy_ nullptr.");
560 return;
561 }
562 nciNfccProxy_->NotifyMessageToVendor(key, value);
563 }
564 } // namespace NFC
565 } // namespace OHOS
566