• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_event_handler.h"
16 
17 #include "ce_service.h"
18 #include "common_event_support.h"
19 #include "loghelper.h"
20 #include "nfc_service.h"
21 #include "nfc_polling_manager.h"
22 #include "nfc_routing_manager.h"
23 #include "want.h"
24 #include "screenlock_manager.h"
25 #include "power_mgr_client.h"
26 #include "nfc_watch_dog.h"
27 
28 #ifdef NDEF_WIFI_ENABLED
29 #include "wifi_connection_manager.h"
30 #endif
31 #ifdef NDEF_BT_ENABLED
32 #include "bt_connection_manager.h"
33 #endif
34 #ifdef NFC_HANDLE_SCREEN_LOCK
35 #include "ndef_har_dispatch.h"
36 #endif
37 
38 namespace OHOS {
39 namespace NFC {
40 const std::string EVENT_DATA_SHARE_READY = "usual.event.DATA_SHARE_READY";
41 
42 class NfcEventHandler::ScreenChangedReceiver : public EventFwk::CommonEventSubscriber {
43 public:
44     explicit ScreenChangedReceiver(std::weak_ptr<NfcService> nfcService,
45         const EventFwk::CommonEventSubscribeInfo& subscribeInfo);
~ScreenChangedReceiver()46     ~ScreenChangedReceiver()
47     {
48     }
49     void OnReceiveEvent(const EventFwk::CommonEventData& data) override;
50 
51 private:
52     std::weak_ptr<NfcService> nfcService_ {};
53     std::weak_ptr<NfcEventHandler> eventHandler_ {};
54 };
55 
ScreenChangedReceiver(std::weak_ptr<NfcService> nfcService,const EventFwk::CommonEventSubscribeInfo & subscribeInfo)56 NfcEventHandler::ScreenChangedReceiver::ScreenChangedReceiver(std::weak_ptr<NfcService> nfcService,
57     const EventFwk::CommonEventSubscribeInfo& subscribeInfo)
58     : EventFwk::CommonEventSubscriber(subscribeInfo),
59     nfcService_(nfcService),
60     eventHandler_(nfcService.lock()->eventHandler_)
61 {
62 }
63 
IsScreenOn()64 bool NfcEventHandler::IsScreenOn()
65 {
66     return PowerMgr::PowerMgrClient::GetInstance().IsScreenOn();
67 }
68 
IsScreenLocked()69 bool NfcEventHandler::IsScreenLocked()
70 {
71     return OHOS::ScreenLock::ScreenLockManager::GetInstance()->IsScreenLocked();
72 }
73 
CheckScreenState()74 ScreenState NfcEventHandler::CheckScreenState()
75 {
76     bool isScreenOn = IsScreenOn();
77     bool isScreenLocked = IsScreenLocked();
78     if (isScreenOn && isScreenLocked) {
79         return ScreenState::SCREEN_STATE_ON_LOCKED;
80     } else if (!isScreenOn && !isScreenLocked) {
81         return ScreenState::SCREEN_STATE_OFF_UNLOCKED;
82     } else if (!isScreenOn && isScreenLocked) {
83         return ScreenState::SCREEN_STATE_OFF_LOCKED;
84     } else if (isScreenOn && !isScreenLocked) {
85         return ScreenState::SCREEN_STATE_ON_UNLOCKED;
86     }
87     return ScreenState::SCREEN_STATE_UNKNOWN;
88 }
89 
OnReceiveEvent(const EventFwk::CommonEventData & data)90 void NfcEventHandler::ScreenChangedReceiver::OnReceiveEvent(const EventFwk::CommonEventData& data)
91 {
92     std::string action = data.GetWant().GetAction();
93     if (action.empty()) {
94         ErrorLog("action is empty");
95         return;
96     }
97     InfoLog("OnScreenChanged: action: %{public}s", action.c_str());
98     if (eventHandler_.expired() || nfcService_.expired()) {
99         ErrorLog("eventHandler_ is null.");
100         return;
101     }
102     ScreenState screenState = ScreenState::SCREEN_STATE_UNKNOWN;
103     if (action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON) == 0) {
104         screenState = eventHandler_.lock()->IsScreenLocked() ?
105             ScreenState::SCREEN_STATE_ON_LOCKED : ScreenState::SCREEN_STATE_ON_UNLOCKED;
106     } else if (action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF) == 0) {
107         screenState = eventHandler_.lock()->IsScreenLocked() ?
108             ScreenState::SCREEN_STATE_OFF_LOCKED : ScreenState::SCREEN_STATE_OFF_UNLOCKED;
109     } else if (action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED) == 0) {
110         nfcService_.lock()->ExecuteTask(KITS::TASK_INITIALIZE);
111         screenState = eventHandler_.lock()->IsScreenOn() ?
112             ScreenState::SCREEN_STATE_ON_UNLOCKED : ScreenState::SCREEN_STATE_OFF_UNLOCKED;
113 #ifdef NFC_HANDLE_SCREEN_LOCK
114         TAG::NdefHarDispatch::HandleCarrierReport();
115 #endif
116     } else {
117         ErrorLog("Screen changed receiver event:unknown");
118         return;
119     }
120     if (eventHandler_.expired()) {
121         ErrorLog("eventHandler_ is null.");
122         return;
123     }
124     eventHandler_.lock()->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_SCREEN_CHANGED),
125         static_cast<int64_t>(screenState), static_cast<int64_t>(0));
126 }
127 
128 class NfcEventHandler::PackageChangedReceiver : public EventFwk::CommonEventSubscriber {
129 public:
130     explicit PackageChangedReceiver(std::weak_ptr<NfcService> nfcService,
131         const EventFwk::CommonEventSubscribeInfo& subscribeInfo);
~PackageChangedReceiver()132     ~PackageChangedReceiver()
133     {
134     }
135     void OnReceiveEvent(const EventFwk::CommonEventData& data) override;
136 
137 private:
138     std::weak_ptr<NfcService> nfcService_ {};
139     std::weak_ptr<AppExecFwk::EventHandler> eventHandler_ {};
140 };
141 
PackageChangedReceiver(std::weak_ptr<NfcService> nfcService,const EventFwk::CommonEventSubscribeInfo & subscribeInfo)142 NfcEventHandler::PackageChangedReceiver::PackageChangedReceiver(std::weak_ptr<NfcService> nfcService,
143     const EventFwk::CommonEventSubscribeInfo& subscribeInfo)
144     : EventFwk::CommonEventSubscriber(subscribeInfo),
145     nfcService_(nfcService),
146     eventHandler_(nfcService.lock()->eventHandler_)
147 {
148 }
149 
OnReceiveEvent(const EventFwk::CommonEventData & data)150 void NfcEventHandler::PackageChangedReceiver::OnReceiveEvent(const EventFwk::CommonEventData& data)
151 {
152     DebugLog("NfcEventHandler::PackageChangedReceiver");
153     std::string action = data.GetWant().GetAction();
154     if (action.empty()) {
155         ErrorLog("action is empty");
156         return;
157     }
158     if (eventHandler_.expired()) {
159         ErrorLog("eventHandler_ is null.");
160         return;
161     }
162     const std::shared_ptr<EventFwk::CommonEventData> mdata =
163         std::make_shared<EventFwk::CommonEventData> (data);
164     if (action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED) == 0 ||
165         action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED) == 0 ||
166         action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED) == 0) {
167         eventHandler_.lock()->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_PACKAGE_UPDATED),
168             mdata, static_cast<int64_t>(0));
169     }
170 }
171 
172 class NfcEventHandler::ShutdownEventReceiver : public EventFwk::CommonEventSubscriber {
173 public:
174     explicit ShutdownEventReceiver(std::weak_ptr<NfcService> nfcService,
175         const EventFwk::CommonEventSubscribeInfo& subscribeInfo);
~ShutdownEventReceiver()176     ~ShutdownEventReceiver()
177     {
178     }
179     void OnReceiveEvent(const EventFwk::CommonEventData& data) override;
180 
181 private:
182     std::weak_ptr<NfcService> nfcService_ {};
183     std::weak_ptr<AppExecFwk::EventHandler> eventHandler_ {};
184 };
185 
ShutdownEventReceiver(std::weak_ptr<NfcService> nfcService,const EventFwk::CommonEventSubscribeInfo & subscribeInfo)186 NfcEventHandler::ShutdownEventReceiver::ShutdownEventReceiver(std::weak_ptr<NfcService> nfcService,
187     const EventFwk::CommonEventSubscribeInfo& subscribeInfo)
188     : EventFwk::CommonEventSubscriber(subscribeInfo),
189     nfcService_(nfcService),
190     eventHandler_(nfcService.lock()->eventHandler_)
191 {
192 }
193 
OnReceiveEvent(const EventFwk::CommonEventData & data)194 void NfcEventHandler::ShutdownEventReceiver::OnReceiveEvent(const EventFwk::CommonEventData& data)
195 {
196     DebugLog("NfcEventHandler::ShutdownEventReceiver");
197     std::string action = data.GetWant().GetAction();
198     if (action.empty()) {
199         ErrorLog("action is empty");
200         return;
201     }
202     if (eventHandler_.expired()) {
203         ErrorLog("eventHandler_ is null.");
204         return;
205     }
206     if (action.compare(EventFwk::CommonEventSupport::COMMON_EVENT_SHUTDOWN) == 0) {
207         eventHandler_.lock()->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_SHUTDOWN),
208                                         static_cast<int64_t>(0));
209     }
210 }
211 
212 class NfcEventHandler::DataShareChangedReceiver : public EventFwk::CommonEventSubscriber {
213 public:
214     explicit DataShareChangedReceiver(std::weak_ptr<NfcService> nfcService,
215         const EventFwk::CommonEventSubscribeInfo& subscribeInfo);
~DataShareChangedReceiver()216     ~DataShareChangedReceiver()
217     {
218     }
219     void OnReceiveEvent(const EventFwk::CommonEventData& data) override;
220 
221 private:
222     std::weak_ptr<NfcService> nfcService_ {};
223     std::weak_ptr<AppExecFwk::EventHandler> eventHandler_ {};
224 };
225 
DataShareChangedReceiver(std::weak_ptr<NfcService> nfcService,const EventFwk::CommonEventSubscribeInfo & subscribeInfo)226 NfcEventHandler::DataShareChangedReceiver::DataShareChangedReceiver(std::weak_ptr<NfcService> nfcService,
227     const EventFwk::CommonEventSubscribeInfo& subscribeInfo)
228     : EventFwk::CommonEventSubscriber(subscribeInfo),
229     nfcService_(nfcService),
230     eventHandler_(nfcService.lock()->eventHandler_)
231 {
232 }
233 
OnReceiveEvent(const EventFwk::CommonEventData & data)234 void NfcEventHandler::DataShareChangedReceiver::OnReceiveEvent(const EventFwk::CommonEventData& data)
235 {
236     DebugLog("NfcEventHandler::DataShareChangedReceiver");
237     std::string action = data.GetWant().GetAction();
238     if (action.empty()) {
239         ErrorLog("action is empty");
240         return;
241     }
242     InfoLog("DataShareChangedReceiver: action = %{public}s", action.c_str());
243     if (action.compare(EVENT_DATA_SHARE_READY) == 0 && !eventHandler_.expired()) {
244         eventHandler_.lock()->SendEvent(static_cast<uint32_t>(NfcCommonEvent::MSG_DATA_SHARE_READY),
245                                         static_cast<int64_t>(0));
246     }
247 }
248 
NfcEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> & runner,std::weak_ptr<NfcService> service)249 NfcEventHandler::NfcEventHandler(const std::shared_ptr<AppExecFwk::EventRunner> &runner,
250                                  std::weak_ptr<NfcService> service)
251     : EventHandler(runner), nfcService_(service)
252 {
253 }
254 
~NfcEventHandler()255 NfcEventHandler::~NfcEventHandler()
256 {
257     EventFwk::CommonEventManager::UnSubscribeCommonEvent(screenSubscriber_);
258     EventFwk::CommonEventManager::UnSubscribeCommonEvent(pkgSubscriber_);
259     EventFwk::CommonEventManager::UnSubscribeCommonEvent(shutdownSubscriber_);
260     EventFwk::CommonEventManager::UnSubscribeCommonEvent(dataShareSubscriber_);
261 }
262 
Intialize(std::weak_ptr<TAG::TagDispatcher> tagDispatcher,std::weak_ptr<CeService> ceService,std::weak_ptr<NfcPollingManager> nfcPollingManager,std::weak_ptr<NfcRoutingManager> nfcRoutingManager,std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy)263 void NfcEventHandler::Intialize(std::weak_ptr<TAG::TagDispatcher> tagDispatcher,
264                                 std::weak_ptr<CeService> ceService,
265                                 std::weak_ptr<NfcPollingManager> nfcPollingManager,
266                                 std::weak_ptr<NfcRoutingManager> nfcRoutingManager,
267                                 std::weak_ptr<NCI::INciNfccInterface> nciNfccProxy)
268 {
269     DebugLog("NfcEventHandler::Intialize");
270     tagDispatcher_ = tagDispatcher;
271     ceService_ = ceService;
272     nfcPollingManager_ = nfcPollingManager;
273     nfcRoutingManager_ = nfcRoutingManager;
274     nciNfccProxy_ = nciNfccProxy;
275 
276     SubscribeScreenChangedEvent();
277     SubscribePackageChangedEvent();
278     SubscribeShutdownEvent();
279     SubscribeDataShareChangedEvent();
280 }
281 
SubscribeScreenChangedEvent()282 void NfcEventHandler::SubscribeScreenChangedEvent()
283 {
284     std::lock_guard<std::mutex> guard(commonEventMutex_);
285     if (screenSubscriber_ != nullptr) {
286         InfoLog("Screen changed event is subscribed, skip");
287         return;
288     }
289     EventFwk::MatchingSkills matchingSkills;
290     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_ON);
291     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_OFF);
292     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SCREEN_UNLOCKED);
293     EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
294     screenSubscriber_ = std::make_shared<ScreenChangedReceiver>(nfcService_, subscribeInfo);
295     if (screenSubscriber_ == nullptr) {
296         ErrorLog("Create screen changed subscriber failed");
297         return;
298     }
299 
300     if (!EventFwk::CommonEventManager::SubscribeCommonEvent(screenSubscriber_)) {
301         ErrorLog("Subscribe screen changed event fail");
302     }
303 }
304 
SubscribePackageChangedEvent()305 void NfcEventHandler::SubscribePackageChangedEvent()
306 {
307     std::lock_guard<std::mutex> guard(commonEventMutex_);
308     if (pkgSubscriber_ != nullptr) {
309         InfoLog("Package changed subscriber is subscribed, skip");
310         return;
311     }
312     EventFwk::MatchingSkills matchingSkills;
313     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_ADDED);
314     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_REMOVED);
315     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_PACKAGE_CHANGED);
316     EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
317     pkgSubscriber_ = std::make_shared<PackageChangedReceiver>(nfcService_, subscribeInfo);
318     if (pkgSubscriber_ == nullptr) {
319         ErrorLog("Create package changed subscriber failed");
320         return;
321     }
322 
323     if (!EventFwk::CommonEventManager::SubscribeCommonEvent(pkgSubscriber_)) {
324         ErrorLog("Subscribe package changed event fail");
325     }
326 }
327 
SubscribeShutdownEvent()328 void NfcEventHandler::SubscribeShutdownEvent()
329 {
330     std::lock_guard<std::mutex> guard(commonEventMutex_);
331     if (shutdownSubscriber_ != nullptr) {
332         InfoLog("Shutdown event is subscribed, skip");
333         return;
334     }
335     EventFwk::MatchingSkills matchingSkills;
336     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SHUTDOWN);
337     EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
338     shutdownSubscriber_ = std::make_shared<ShutdownEventReceiver>(nfcService_, subscribeInfo);
339     if (shutdownSubscriber_ == nullptr) {
340         ErrorLog("Create shutdown subscriber failed");
341         return;
342     }
343 
344     if (!EventFwk::CommonEventManager::SubscribeCommonEvent(shutdownSubscriber_)) {
345         ErrorLog("Subscribe shutdown event fail");
346     }
347 }
348 
SubscribeDataShareChangedEvent()349 void NfcEventHandler::SubscribeDataShareChangedEvent()
350 {
351     std::lock_guard<std::mutex> guard(commonEventMutex_);
352     if (dataShareSubscriber_ != nullptr) {
353         InfoLog("DataShare changed event is subscribed, skip");
354         return;
355     }
356     EventFwk::MatchingSkills matchingSkills;
357     matchingSkills.AddEvent(EVENT_DATA_SHARE_READY);
358     EventFwk::CommonEventSubscribeInfo subscribeInfo(matchingSkills);
359     dataShareSubscriber_ = std::make_shared<DataShareChangedReceiver>(nfcService_, subscribeInfo);
360     if (dataShareSubscriber_ == nullptr) {
361         ErrorLog("dataShareSubscriber_ failed");
362         return;
363     }
364 
365     if (!EventFwk::CommonEventManager::SubscribeCommonEvent(dataShareSubscriber_)) {
366         ErrorLog("Subscribe dataShareSubscriber_ fail");
367     }
368 }
369 
ProcessEvent(const AppExecFwk::InnerEvent::Pointer & event)370 void NfcEventHandler::ProcessEvent(const AppExecFwk::InnerEvent::Pointer& event)
371 {
372     if (event == nullptr) {
373         ErrorLog("event is nullptr");
374         return;
375     }
376     NfcCommonEvent eventId = static_cast<NfcCommonEvent>(event->GetInnerEventId());
377     if (eventId != NfcCommonEvent::MSG_NOTIFY_FIELD_OFF &&
378         eventId != NfcCommonEvent::MSG_NOTIFY_FIELD_ON) {
379         InfoLog("NFC common event handler receive a message of %{public}d", eventId);
380     }
381     NfcWatchDog nfcProcessEventDog(
382         "ProcessEvent_" + std::to_string(static_cast<int>(eventId)), WAIT_PROCESS_EVENT_TIMES, nciNfccProxy_);
383     nfcProcessEventDog.Run();
384     switch (eventId) {
385         case NfcCommonEvent::MSG_TAG_FOUND:
386             if (!tagDispatcher_.expired()) {
387                 tagDispatcher_.lock()->HandleTagFound(event->GetParam());
388             }
389             break;
390         case NfcCommonEvent::MSG_TAG_DEBOUNCE:
391             if (!tagDispatcher_.expired()) {
392                 tagDispatcher_.lock()->HandleTagDebounce();
393             }
394             break;
395         case NfcCommonEvent::MSG_TAG_LOST:
396             if (!tagDispatcher_.expired()) {
397                 tagDispatcher_.lock()->HandleTagLost(event->GetParam());
398             }
399             break;
400         case NfcCommonEvent::MSG_SCREEN_CHANGED: {
401             if (!nfcPollingManager_.expired()) {
402                 nfcPollingManager_.lock()->HandleScreenChanged(event->GetParam());
403             }
404             break;
405         }
406         case NfcCommonEvent::MSG_PACKAGE_UPDATED: {
407             if (nfcPollingManager_.expired()) {
408                 break;
409             }
410             bool updated = nfcPollingManager_.lock()->HandlePackageUpdated(
411                 event->GetSharedObject<EventFwk::CommonEventData>());
412             if (updated) {
413                 ceService_.lock()->OnAppAddOrChangeOrRemove(event->GetSharedObject<EventFwk::CommonEventData>());
414             }
415             break;
416         }
417         case NfcCommonEvent::MSG_COMMIT_ROUTING: {
418             if (!nfcRoutingManager_.expired()) {
419                 nfcRoutingManager_.lock()->HandleCommitRouting();
420             }
421             break;
422         }
423         case NfcCommonEvent::MSG_COMPUTE_ROUTING_PARAMS: {
424             int defaultPaymentType = event->GetParam();
425             if (!nfcRoutingManager_.expired()) {
426                 nfcRoutingManager_.lock()->HandleComputeRoutingParams(defaultPaymentType);
427             }
428             break;
429         }
430         case NfcCommonEvent::MSG_FIELD_ACTIVATED: {
431             if (!ceService_.expired()) {
432                 ceService_.lock()->HandleFieldActivated();
433             }
434             break;
435         }
436         case NfcCommonEvent::MSG_FIELD_DEACTIVATED: {
437             if (!ceService_.expired()) {
438                 ceService_.lock()->HandleFieldDeactivated();
439             }
440             break;
441         }
442         case NfcCommonEvent::MSG_NOTIFY_FIELD_ON: {
443             if (!ceService_.expired()) {
444                 ceService_.lock()->PublishFieldOnOrOffCommonEvent(true);
445             }
446             break;
447         }
448         case NfcCommonEvent::MSG_NOTIFY_FIELD_OFF: {
449             if (!ceService_.expired()) {
450                 ceService_.lock()->PublishFieldOnOrOffCommonEvent(false);
451             }
452             break;
453         }
454         case NfcCommonEvent::MSG_NOTIFY_FIELD_OFF_TIMEOUT: {
455             if (!ceService_.expired()) {
456                 ceService_.lock()->PublishFieldOnOrOffCommonEvent(false);
457             }
458             break;
459         }
460         case NfcCommonEvent::MSG_SHUTDOWN: {
461             if (!nfcService_.expired()) {
462                 nfcService_.lock()->HandleShutdown();
463             }
464             break;
465         }
466         case NfcCommonEvent::MSG_DATA_SHARE_READY: {
467             if (!ceService_.expired()) {
468                 ceService_.lock()->HandleDataShareReady();
469             }
470             break;
471         }
472 #ifdef VENDOR_APPLICATIONS_ENABLED
473         case NfcCommonEvent::MSG_VENDOR_EVENT: {
474             int eventType = event->GetParam();
475             if ((eventType == KITS::VENDOR_APP_INIT_DONE || eventType == KITS::VENDOR_APP_CHANGE)
476                 && !ceService_.expired()) {
477                 ceService_.lock()->ConfigRoutingAndCommit();
478             }
479             break;
480         }
481 #endif
482 #ifdef NDEF_WIFI_ENABLED
483         case NfcCommonEvent::MSG_WIFI_ENABLE_TIMEOUT: {
484             TAG::WifiConnectionManager::GetInstance().HandleWifiEnableFailed();
485             break;
486         }
487         case NfcCommonEvent::MSG_WIFI_CONNECT_TIMEOUT: {
488             TAG::WifiConnectionManager::GetInstance().HandleWifiConnectFailed();
489             break;
490         }
491         case NfcCommonEvent::MSG_WIFI_ENABLED: {
492             TAG::WifiConnectionManager::GetInstance().OnWifiEnabled();
493             break;
494         }
495         case NfcCommonEvent::MSG_WIFI_CONNECTED: {
496             TAG::WifiConnectionManager::GetInstance().OnWifiConnected();
497             break;
498         }
499         case NfcCommonEvent::MSG_WIFI_NTF_CLICKED: {
500             TAG::WifiConnectionManager::GetInstance().OnWifiNtfClicked();
501             break;
502         }
503 #endif
504 #ifdef NDEF_BT_ENABLED
505         case NfcCommonEvent::MSG_BT_ENABLE_TIMEOUT: {
506             TAG::BtConnectionManager::GetInstance().HandleBtEnableFailed();
507             break;
508         }
509         case NfcCommonEvent::MSG_BT_PAIR_TIMEOUT: {
510             TAG::BtConnectionManager::GetInstance().HandleBtPairFailed();
511             break;
512         }
513         case NfcCommonEvent::MSG_BT_CONNECT_TIMEOUT: {
514             TAG::BtConnectionManager::GetInstance().HandleBtConnectFailed();
515             break;
516         }
517         case NfcCommonEvent::MSG_BT_ENABLED: {
518             TAG::BtConnectionManager::GetInstance().OnBtEnabled();
519             break;
520         }
521         case NfcCommonEvent::MSG_BT_PAIR_STATUS_CHANGED: {
522             TAG::BtConnectionManager::GetInstance().OnPairStatusChanged(
523                 event->GetSharedObject<TAG::BtConnectionInfo>());
524             break;
525         }
526         case NfcCommonEvent::MSG_BT_CONNECT_STATUS_CHANGED: {
527             TAG::BtConnectionManager::GetInstance().OnConnectionStateChanged(
528                 event->GetSharedObject<TAG::BtConnectionInfo>());
529             break;
530         }
531         case NfcCommonEvent::MSG_BT_NTF_CLICKED: {
532             TAG::BtConnectionManager::GetInstance().OnBtNtfClicked();
533             break;
534         }
535 #endif
536         default:
537             ErrorLog("Unknown message received: id %{public}d", eventId);
538             break;
539     }
540     nfcProcessEventDog.Cancel();
541 }
542 }  // namespace NFC
543 }  // namespace OHOS
544