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  #ifndef I_NFC_SERVICE_H
16  #define I_NFC_SERVICE_H
17  #include "element_name.h"
18  #include "iforeground_callback.h"
19  
20  namespace OHOS {
21  namespace NFC {
22  namespace TAG {
23      class TagDispatcher;
24  #ifdef NDEF_WIFI_ENABLED
25      class WifiConnectionManager;
26  #endif
27  #ifdef NDEF_BT_ENABLED
28      class BtConnectionManager;
29  #endif
30  }
31  class NfcEventHandler;
32  class NfcPollingManager;
33  class NfcRoutingManager;
34  class CeService;
35  enum class NfcCommonEvent {
36      // tags found
37      MSG_TAG_FOUND = 0,
38      MSG_TAG_DEBOUNCE,
39      MSG_TAG_LOST,
40  
41      // screen changed
42      MSG_SCREEN_CHANGED,
43  
44      // package updated
45      MSG_PACKAGE_UPDATED,
46  
47      // card emulation
48      MSG_ROUTE_AID,
49      MSG_COMMIT_ROUTING,
50      MSG_COMPUTE_ROUTING_PARAMS,
51  
52      // field activated
53      MSG_FIELD_ACTIVATED,
54  
55      // field deactivated
56      MSG_FIELD_DEACTIVATED,
57  
58      // notify field on
59      MSG_NOTIFY_FIELD_ON,
60  
61      // notify field off
62      MSG_NOTIFY_FIELD_OFF,
63      MSG_NOTIFY_FIELD_OFF_TIMEOUT,
64  
65      // device shutdown
66      MSG_SHUTDOWN,
67  
68      // datashare ready
69      MSG_DATA_SHARE_READY,
70  
71  #ifdef VENDOR_APPLICATIONS_ENABLED
72      // vendor event
73      MSG_VENDOR_EVENT,
74  #endif
75  #ifdef NDEF_WIFI_ENABLED
76      // for connect wifi by ndef wifi tag
77      MSG_WIFI_ENABLE_TIMEOUT,
78      MSG_WIFI_CONNECT_TIMEOUT,
79      MSG_WIFI_ENABLED,
80      MSG_WIFI_CONNECTED,
81      MSG_WIFI_NTF_CLICKED,
82  #endif
83  #ifdef NDEF_BT_ENABLED
84      // for connect BT by ndef bt tag
85      MSG_BT_ENABLE_TIMEOUT,
86      MSG_BT_PAIR_TIMEOUT,
87      MSG_BT_CONNECT_TIMEOUT,
88      MSG_BT_ENABLED,
89      MSG_BT_PAIR_STATUS_CHANGED,
90      MSG_BT_CONNECT_STATUS_CHANGED,
91      MSG_BT_NTF_CLICKED,
92  #endif
93  };
94  
95  enum class ScreenState {
96      SCREEN_STATE_UNKNOWN = 0x00,
97      SCREEN_STATE_OFF_UNLOCKED = 0x01,
98      SCREEN_STATE_OFF_LOCKED = 0x02,
99      SCREEN_STATE_ON_LOCKED = 0x04,
100      SCREEN_STATE_ON_UNLOCKED = 0x08,
101      // Polling mask
102      SCREEN_POLLING_TAG_MASK = 0x10,
103      SCREEN_POLLING_READER_MASK = 0x40
104  };
105  
106  class INfcService {
107  public:
~INfcService()108      virtual ~INfcService() {}
109  
110      virtual bool IsNfcEnabled() = 0;
111      virtual int GetNfcState() = 0;
112      virtual int GetScreenState() = 0;
113      virtual int GetNciVersion() = 0;
114      virtual std::weak_ptr<TAG::TagDispatcher> GetTagDispatcher() = 0;
115      virtual std::weak_ptr<NfcPollingManager> GetNfcPollingManager() = 0;
116      virtual std::weak_ptr<NfcRoutingManager> GetNfcRoutingManager() = 0;
117      virtual OHOS::sptr<IRemoteObject> GetTagServiceIface() = 0;
118      virtual OHOS::sptr<IRemoteObject> GetHceServiceIface() = 0;
119      virtual std::weak_ptr<CeService> GetCeService() = 0 ;
120      virtual std::string GetSimVendorBundleName() = 0;
121  };
122  }  // namespace NFC
123  }  // namespace OHOS
124  #endif  // I_NFC_SERVICE_H
125