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