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 NFC_SWITCH_RETRY_MAX_TIME = 110, 32 INIT_SA_FAILED = 201, // error code for init sa failed 33 NDEF_TEL_EVENT = 301, 34 NDEF_SMS_EVENT = 302, 35 NDEF_MAIL_EVENT = 303, 36 NDEF_TEXT_EVENT = 304, 37 NDEF_VCARD_EVENT = 305, 38 NDEF_APP_NOT_INSTALL = 306, 39 HCE_SWIPE_CARD = 307, 40 NDEF_DISPATCH_TO_APP = 308, 41 APP_BEHAVIOR = 401, 42 HCE_CMD_CB = 402, 43 }; 44 45 enum SubErrorCode { 46 DEFAULT_ERR_DEF = 10000, 47 NCI_RESP_TIMEOUT = 10001, 48 NCI_RESP_ERROR = 10002, 49 PROCESS_ABORT = 10003, 50 NDEF_HAR_DISPATCH = 30800, 51 NDEF_URI_BROWSER_DISPATCH = 30801, 52 UNKNOWN_TAG_DISPATCH = 30802, 53 REG_FOREGROUND_DISPATCH = 40101, 54 REG_FOREGROUND_DISPATCH_ABILITY_INVALID = 40105, // abilityName wrong or background 55 REG_READERMODE = 40102, 56 REG_READERMODE_ABILITY_INVALID = 40106, // abilityName wrong or background 57 TURN_ON_NFC = 40103, 58 TURN_OFF_NFC = 40104, 59 HCE_CMD_CB_EXIST = 40200, 60 HCE_CMD_CB_NOT_EXIST = 40201, 61 HCE_CMD_CB_NULL = 40202, 62 }; 63 64 const int DEFAULT_COUNT = 1; 65 const int NOT_COUNT = 0; 66 67 typedef struct { 68 MainErrorCode mainErrorCode; 69 SubErrorCode subErrorCode; 70 int defaultRoute; 71 int screenState; 72 int nfcState; 73 int passiveListenState; 74 std::string version; 75 std::string appPackageName; 76 } NfcFailedParams; 77 78 class NfcHisysEvent { 79 public: 80 static void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams); 81 static void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt, 82 int closeRequestCnt, int closeFailCnt); 83 static void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt); 84 static void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName, 85 const std::string &newAppPackageName); 86 static void WriteForegroundAppChangeHiSysEvent(const std::string &appPackageName); 87 static void WriteDispatchToAppHiSysEvent(const std::string &appPackageName, SubErrorCode subErrorCode); 88 static void WriteTagFoundHiSysEvent(const std::vector<int> &techList); 89 static void WritePassiveListenHiSysEvent(int requestCnt, int failCnt); 90 static void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt); 91 static void BuildFailedParams(NfcFailedParams &nfcFailedParams, 92 MainErrorCode mainErrorCode, 93 SubErrorCode subErrorCode); 94 static void WriteDefaultRouteChangeHiSysEvent(int oldRoute, int newRoute); 95 static void WriteAppBehaviorHiSysEvent(SubErrorCode behaviorCode, const std::string &appName); 96 static void WriteNfcHceCmdCbHiSysEvent(const std::string &appName, SubErrorCode subErrorCode); 97 }; 98 } // namespace NFC 99 } // namespace OHOS 100 #endif