• 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 #ifndef TAG_INFO_H
16 #define TAG_INFO_H
17 
18 #include "itag_session.h"
19 #include "nfc_basic_proxy.h"
20 #include "nfc_sdk_common.h"
21 #include "pac_map.h"
22 #include "parcel.h"
23 
24 namespace OHOS {
25 namespace NFC {
26 namespace KITS {
27 class TagInfo {
28 public:
29     static const int MAX_TAG_TECH_NUM = 10;
30     static const int SEND_COMMAND_HEAD_LEN_2 = 2;
31     static const int SEND_COMMAND_MAX_LEN = 256;
32 
33     // ISODEP
34     static constexpr const auto HISTORICAL_BYTES = "HistoricalBytes";
35     static constexpr const auto HILAYER_RESPONSE = "HiLayerResponse";
36     // iso 14443-3a
37     static constexpr const auto SAK = "Sak";
38     static constexpr const auto ATQA = "Atqa";
39     // iso 14443-3b
40     static constexpr const auto APP_DATA = "AppData";
41     static constexpr const auto PROTOCOL_INFO = "ProtocolInfo";
42     // NDEF
43     static constexpr const auto NDEF_MSG = "NdefMsg";
44     static constexpr const auto NDEF_FORUM_TYPE = "NdefForumType";
45     static constexpr const auto NDEF_TAG_LENGTH = "NdefTagLength";
46     static constexpr const auto NDEF_TAG_MODE = "NdefTagMode";
47     // MifareUltralight
48     static constexpr const auto MIFARE_ULTRALIGHT_C_TYPE = "MifareUltralightC";
49     // Iso15693
50     static constexpr const auto RESPONSE_FLAGS = "ResponseFlags";
51     static constexpr const auto DSF_ID = "DsfId";
52     // NfcF, Feilica
53     static constexpr const auto NFCF_SC = "SystemCode";
54     static constexpr const auto NFCF_PMM = "Pmm";
55 
56 public:
57     TagInfo(std::vector<int> tagTechList,
58         std::vector<AppExecFwk::PacMap> tagTechExtrasData,
59         std::string& tagUid,
60         int tagRfDiscId,
61         OHOS::sptr<IRemoteObject> tagServiceIface);
62     ~TagInfo();
63 
64     std::string GetTagUid() const;
65     std::vector<int> GetTagTechList() const;
66 
67     AppExecFwk::PacMap GetTechExtrasByIndex(size_t techIndex);
68     AppExecFwk::PacMap GetTechExtrasByTech(KITS::TagTechnology tech);
69     std::string GetStringExtrasData(AppExecFwk::PacMap& extrasData, const std::string& extrasName);
70     int GetIntExtrasData(AppExecFwk::PacMap& extrasData, const std::string& extrasName);
71     bool GetBoolExtrasData(AppExecFwk::PacMap& extrasData, const std::string& extrasName);
72 
73     bool IsTechSupported(KITS::TagTechnology tech);
74     int GetTagRfDiscId() const;
75     KITS::TagTechnology GetConnectedTagTech() const;
76     void SetConnectedTagTech(KITS::TagTechnology connectedTagTech);
77     OHOS::sptr<TAG::ITagSession> GetTagSessionProxy();
78     static std::string GetStringTach(int tech);
79 private:
80     int tagRfDiscId_;
81     KITS::TagTechnology connectedTagTech_;
82     std::string tagUid_;
83     std::vector<int> tagTechList_;
84     std::vector<AppExecFwk::PacMap> tagTechExtrasData_;
85 
86     OHOS::sptr<IRemoteObject> tagServiceIface_;
87     OHOS::sptr<TAG::ITagSession> tagSessionProxy_;
88     friend class BasicTagSession;
89     friend class NdefTag;
90     friend class NdefFormatableTag;
91 };
92 }  // namespace KITS
93 }  // namespace NFC
94 }  // namespace OHOS
95 #endif  // TAG_INFO_H
96