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 TURN_ON_NFC = 40103, 50 TURN_OFF_NFC = 40104, 51 }; 52 53 const int DEFAULT_COUNT = 1; 54 const int NOT_COUNT = 0; 55 56 typedef struct { 57 MainErrorCode mainErrorCode; 58 SubErrorCode subErrorCode; 59 int defaultRoute; 60 int screenState; 61 int nfcState; 62 int passiveListenState; 63 std::string version; 64 std::string appPackageName; 65 } NfcFailedParams; 66 67 class NfcHisysEvent { 68 public: 69 static void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams); 70 static void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt, 71 int closeRequestCnt, int closeFailCnt); 72 static void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt); 73 static void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName, 74 const std::string &newAppPackageName); 75 static void WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName); 76 static void WriteTagFoundHiSysEvent(const std::vector<int> &techList); 77 static void WritePassiveListenHiSysEvent(int requestCnt, int failCnt); 78 static void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt); 79 static void BuildFailedParams(NfcFailedParams &nfcFailedParams, 80 MainErrorCode mainErrorCode, 81 SubErrorCode subErrorCode); 82 static void WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute); 83 static void WriteAppBehaviorHiSysEvent(SubErrorCode behaviorCode, const std::string &appName); 84 }; 85 } // namespace NFC 86 } // namespace OHOS 87 #endif