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 OPEN_NFC_EVENT = 106, 28 CLOSE_NFC_EVENT = 107, 29 INIT_SA_FAILED = 201 // error code for init sa failed 30 }; 31 32 enum SubErrorCode { 33 DEFAULT_ERR_DEF = 10000, 34 NCI_RESP_TIMEOUT = 10001, 35 NCI_RESP_ERROR = 10002, 36 }; 37 38 const int DEFAULT_COUNT = 1; 39 const int NOT_COUNT = 0; 40 41 typedef struct { 42 MainErrorCode mainErrorCode; 43 SubErrorCode subErrorCode; 44 int defaultRoute; 45 int screenState; 46 int nfcState; 47 int passiveListenState; 48 std::string version; 49 std::string appPackageName; 50 } NfcFailedParams; 51 52 class NfcHisysEvent { 53 public: 54 static void WriteNfcFailedHiSysEvent(const NfcFailedParams* failedParams); 55 static void WriteOpenAndCloseHiSysEvent(int openRequestCnt, int openFailCnt, 56 int closeRequestCnt, int closeFailCnt); 57 static void WriteHceSwipeResultHiSysEvent(const std::string &appPackageName, int hceSwipeCnt); 58 static void WriteDefaultPaymentAppChangeHiSysEvent(const std::string &oldAppPackageName, 59 const std::string &newAppPackageName); 60 static void WriteTagFoundHiSysEvent(const std::vector<int>& techList); 61 static void WritePassiveListenHiSysEvent(int requestCnt, int failCnt); 62 static void WriteFirmwareUpdateHiSysEvent(int requestCnt, int failCnt); 63 static void BuildFailedParams(NfcFailedParams &nfcFailedParams, 64 MainErrorCode mainErrorCode, 65 SubErrorCode subErrorCode); 66 }; 67 } // namespace NFC 68 } // namespace OHOS 69 #endif