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 APP_DOMAIN_VERIFY_HISYSTEM_EVENT_H 16 #define APP_DOMAIN_VERIFY_HISYSTEM_EVENT_H 17 #include <string> 18 #include "hisysevent.h" 19 20 namespace OHOS { 21 namespace AppDomainVerify { 22 static constexpr char APP_DOMAIN_VERIFY[] = "APPDOMAINVERIFY"; 23 namespace EventType { 24 const std::string APP_INSTALL_EVENT = "PKG_INSTALL"; 25 const std::string APP_DELETE_EVENT = "PKG_UNINSTALL"; 26 const std::string APP_VERIFY_EVENT = "PKG_VERIFY_RESULT"; 27 const std::string APP_UNIVERSAL_ERROR_EVENT = "UNIVERSAL_ERROR"; 28 } 29 namespace EventParamKey { 30 const std::string APP_ID = "APP_ID"; 31 const std::string BUNDLE_NAME = "BUNDLE_NAME"; 32 const std::string VERIFY_STATUS = "VERIFY_STATUS"; 33 const std::string VERIFY_WAY = "VERIFY_WAY"; 34 const std::string ERROR_CODE = "ERROR_CODE"; 35 } 36 typedef enum EnumTaskType { 37 IMMEDIATE_TASK, 38 BOOT_REFRESH_TASK, 39 SCHEDULE_REFRESH_TASK, 40 UNKNOWN_TASK 41 } TaskType; 42 enum EventCode : uint32_t { 43 COMMON_FAULT_START = 0x00000, 44 SIGN_FAULT = 0x00001, 45 GET_GATEWAY_FAULT = 0x00002, 46 CONNECT_MGR_FAULT = 0x00003, 47 CONNECT_AGENT_FAULT = 0x00004, 48 CONNECT_OTHER_FAULT = 0x00005, 49 GET_EXT_FAULT = 0x00006, 50 UPDATE_DB_FAULT = 0x00007, 51 COMMON_FAULT_END, 52 53 BASE_LINK_FAULT_START = 0x10000, 54 LOAD_DB_FAULT = 0x10001, 55 GET_DATE_IN_BOOT_FAULT = 0x12001, 56 GET_DATE_IN_LOOP_FAULT = 0x12101, 57 DEL_DB_IN_WRITE_BACK_FAULT = 0x13001, 58 WRITE_DB_IN_WRITE_BACK_FAULT = 0x13002, 59 BASE_LINK_FAULT_END, 60 61 SHORT_LINK_FAULT_START = 0x20000, 62 SYNC_WHITE_LIST_FAULT = 0x20001, 63 WRITE_DYNAMIC_WHITE_LIST_FAULT = 0x20002, 64 READ_DEFAULT_WHITE_LIST_FAULT = 0x20101, 65 READ_DYNAMIC_WHITE_LIST_FAULT = 0x20102, 66 READ_CACHE_FAULT = 0x21001, 67 NET_UNREACHED_FAULT = 0x21101, 68 CONVERT_TO_WANT_FAULT = 0x21102, 69 CALL_BACK_FAULT = 0x21201, 70 UPDATE_CACHE_FAULT = 0x21301, 71 SHORT_LINK_FAULT_END 72 }; 73 74 #define INSTALL_EVENT(appIdentifier, bundleName) \ 75 do { \ 76 HiSysEventWrite(APP_DOMAIN_VERIFY, EventType::APP_INSTALL_EVENT, \ 77 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, EventParamKey::APP_ID, (appIdentifier), \ 78 EventParamKey::BUNDLE_NAME, (bundleName)); \ 79 } while (0) 80 81 #define UNINSTALL_EVENT(appIdentifier, bundleName) \ 82 do { \ 83 HiSysEventWrite(APP_DOMAIN_VERIFY, EventType::APP_DELETE_EVENT, \ 84 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, EventParamKey::APP_ID, (appIdentifier), \ 85 EventParamKey::BUNDLE_NAME, (bundleName)); \ 86 } while (0) 87 88 #define VERIFY_RESULT_EVENT(appIdentifier, bundleName, type, status) \ 89 do { \ 90 HiSysEventWrite(APP_DOMAIN_VERIFY, EventType::APP_VERIFY_EVENT, \ 91 OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, EventParamKey::APP_ID, (appIdentifier), \ 92 EventParamKey::BUNDLE_NAME, (bundleName), EventParamKey::VERIFY_WAY, (type), EventParamKey::VERIFY_STATUS, \ 93 (status)); \ 94 } while (0) 95 96 #define UNIVERSAL_ERROR_EVENT(errorCode) \ 97 do { \ 98 HiSysEventWrite(APP_DOMAIN_VERIFY, EventType::APP_UNIVERSAL_ERROR_EVENT, \ 99 OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, EventParamKey::ERROR_CODE, (errorCode)); \ 100 } while (0) 101 102 } 103 } 104 #endif