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 18 #include "element_name.h" 19 #include "infcc_host.h" 20 #include "tag_dispatcher.h" 21 22 namespace OHOS { 23 namespace NFC { 24 enum class NfcCommonEvent { 25 // tags found 26 MSG_TAG_FOUND = 0, 27 MSG_TAG_DEBOUNCE, 28 29 // screen changed 30 MSG_SCREEN_CHANGED, 31 32 // package updated 33 MSG_PACKAGE_UPDATED, 34 35 // card emulation 36 MSG_ROUTE_AID, 37 MSG_COMMIT_ROUTING, 38 MSG_COMPUTE_ROUTING_PARAMS, 39 40 // field activated 41 MSG_FIELD_ACTIVATED, 42 43 // field deactivated 44 MSG_FIELD_DEACTIVATED, 45 46 // notify field on 47 MSG_NOTIFY_FIELD_ON, 48 49 // notify field off 50 MSG_NOTIFY_FIELD_OFF, 51 MSG_NOTIFY_FIELD_OFF_TIMEOUT, 52 }; 53 54 enum class ScreenState { 55 SCREEN_STATE_UNKNOWN = 0x00, 56 SCREEN_STATE_OFF_UNLOCKED = 0x01, 57 SCREEN_STATE_OFF_LOCKED = 0x02, 58 SCREEN_STATE_ON_LOCKED = 0x04, 59 SCREEN_STATE_ON_UNLOCKED = 0x08, 60 // Polling mask 61 SCREEN_POLLING_TAG_MASK = 0x10, 62 SCREEN_POLLING_READER_MASK = 0x40 63 }; 64 65 class INfcService { 66 public: ~INfcService()67 virtual ~INfcService() {} 68 69 virtual bool IsNfcEnabled() = 0; 70 virtual int GetNfcState() = 0; 71 virtual int GetScreenState() = 0; 72 virtual int GetNciVersion() = 0; 73 virtual std::weak_ptr<NFC::NCI::INfccHost> GetNfccHost() = 0; 74 virtual std::weak_ptr<TAG::TagDispatcher> GetTagDispatcher() = 0; 75 virtual OHOS::sptr<IRemoteObject> GetTagServiceIface() = 0; 76 virtual bool EnableForegroundDispatch(AppExecFwk::ElementName element, std::vector<uint32_t> &discTech, 77 const sptr<KITS::IForegroundCallback> &callback) = 0; 78 virtual bool DisableForegroundDispatch(AppExecFwk::ElementName element) = 0; 79 virtual bool DisableForegroundByDeathRcpt() = 0; 80 virtual bool IsForegroundEnabled() = 0; 81 virtual void SendTagToForeground(KITS::TagInfoParcelable tagInfo) = 0; 82 }; 83 } // namespace NFC 84 } // namespace OHOS 85 #endif // I_NFC_SERVICE_H 86