• 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     APP_BEHAVIOR = 401,
40 };
41 
42 enum SubErrorCode {
43     DEFAULT_ERR_DEF = 10000,
44     NCI_RESP_TIMEOUT = 10001,
45     NCI_RESP_ERROR = 10002,
46     PROCESS_ABORT = 10003,
47     REG_FOREGROUND_DISPATCH = 40101,
48     REG_READERMODE = 40102,
49 };
50 
51 const int DEFAULT_COUNT = 1;
52 const int NOT_COUNT = 0;
53 
54 typedef struct {
55     MainErrorCode mainErrorCode;
56     SubErrorCode subErrorCode;
57     int defaultRoute;
58     int screenState;
59     int nfcState;
60     int passiveListenState;
61     std::string version;
62     std::string appPackageName;
63 } NfcFailedParams;
64 
65 class NfcHisysEvent {
66 public:
67     static void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams);
68     static void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt,
69                                             int closeRequestCnt, int closeFailCnt);
70     static void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt);
71     static void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName,
72                                                        const std::string &newAppPackageName);
73     static void WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName);
74     static void WriteTagFoundHiSysEvent(const std::vector<int> &techList);
75     static void WritePassiveListenHiSysEvent(int requestCnt, int failCnt);
76     static void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt);
77     static void BuildFailedParams(NfcFailedParams &nfcFailedParams,
78                                   MainErrorCode mainErrorCode,
79                                   SubErrorCode subErrorCode);
80     static void WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute);
81 };
82 }  // namespace NFC
83 }  // namespace OHOS
84 #endif