• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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 NFC_HISYSEVENT_H
16 #define NFC_HISYSEVENT_H
17 #include <string>
18 
19 namespace OHOS {
20 namespace NFC {
21 enum MainErrorCode {
22     NFC_OPEN_FAILED = 101,
23     NFC_CLOSE_FAILED = 102,
24     FIRMWARE_UPDATE_FAILED = 103,
25     PASSIVE_LISTEN_FAILED = 104,
26     SET_READER_MODE_EVENT = 105,
27     NFC_OPEN_SUCCEED = 106,
28     NFC_CLOSE_SUCCEED = 107,
29     NFC_GENERAL_ERR = 108,
30     NFC_EVENTHANDLER_TIMEOUT = 109,
31     INIT_SA_FAILED = 201, // error code for init sa failed
32     NDEF_TEL_EVENT = 301,
33     NDEF_SMS_EVENT = 302,
34     NDEF_MAIL_EVENT = 303,
35     NDEF_TEXT_EVENT = 304,
36     NDEF_VCARD_EVENT = 305,
37     NDEF_APP_NOT_INSTALL = 306,
38     HCE_SWIPE_CARD = 307,
39     NDEF_DISPATCH_TO_APP = 308,
40     APP_BEHAVIOR = 401,
41     HCE_CMD_CB = 402,
42 };
43 
44 enum SubErrorCode {
45     DEFAULT_ERR_DEF = 10000,
46     NCI_RESP_TIMEOUT = 10001,
47     NCI_RESP_ERROR = 10002,
48     PROCESS_ABORT = 10003,
49     NDEF_HAR_DISPATCH = 30800,
50     NDEF_URI_BROWSER_DISPATCH = 30801,
51     UNKNOWN_TAG_DISPATCH = 30802,
52     REG_FOREGROUND_DISPATCH = 40101,
53     REG_READERMODE = 40102,
54     TURN_ON_NFC = 40103,
55     TURN_OFF_NFC = 40104,
56     HCE_CMD_CB_EXIST = 40200,
57     HCE_CMD_CB_NOT_EXIST = 40201,
58     HCE_CMD_CB_NULL = 40202,
59 };
60 
61 const int DEFAULT_COUNT = 1;
62 const int NOT_COUNT = 0;
63 
64 typedef struct {
65     MainErrorCode mainErrorCode;
66     SubErrorCode subErrorCode;
67     int defaultRoute;
68     int screenState;
69     int nfcState;
70     int passiveListenState;
71     std::string version;
72     std::string appPackageName;
73 } NfcFailedParams;
74 
75 class NfcHisysEvent {
76 public:
77     static void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams);
78     static void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt,
79                                             int closeRequestCnt, int closeFailCnt);
80     static void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt);
81     static void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName,
82                                                        const std::string &newAppPackageName);
83     static void WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName);
84     static void WriteDispatchToAppHiSysEvent(const std::string &appPackageName, SubErrorCode subErrorCode);
85     static void WriteTagFoundHiSysEvent(const std::vector<int> &techList);
86     static void WritePassiveListenHiSysEvent(int requestCnt, int failCnt);
87     static void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt);
88     static void BuildFailedParams(NfcFailedParams &nfcFailedParams,
89                                   MainErrorCode mainErrorCode,
90                                   SubErrorCode subErrorCode);
91     static void WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute);
92     static void WriteAppBehaviorHiSysEvent(SubErrorCode behaviorCode, const std::string &appName);
93     static void WriteNfcHceCmdCbHiSysEvent(const std::string &appName, SubErrorCode subErrorCode);
94 };
95 }  // namespace NFC
96 }  // namespace OHOS
97 #endif