1 /* 2 * Copyright (c) 2022 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 16 #ifndef UPDATE_SYSTEM_EVENT_H 17 #define UPDATE_SYSTEM_EVENT_H 18 19 #include <string> 20 21 #include "hisysevent.h" 22 23 namespace OHOS { 24 namespace UpdateEngine { 25 #define EVENT_WRITE(eventName, type, ...) \ 26 HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::UPDATE, eventName, type, ##__VA_ARGS__) 27 28 #define SYS_EVENT_UPGRADE_INTERVAL(validCheck, versionInfo, type, interval) \ 29 if (!(validCheck)) { \ 30 EVENT_WRITE("UPGRADE_INTERVAL", OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC, \ 31 "VERSION_INFO", versionInfo, "TYPE", type, "INTERVAL", interval); \ 32 } 33 34 #define SYS_EVENT_SYSTEM_UPGRADE_FAULT(validCheck, deviceId, versionInfo, reason, location) \ 35 if (!(validCheck)) { \ 36 EVENT_WRITE("SYSTEM_UPGRADE_FAULT", OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, \ 37 "DEVICE_ID", deviceId, "VERSION_INFO", versionInfo, "FAILED_REASON", reason, \ 38 "LOCATION", location); \ 39 } 40 41 #define SYS_EVENT_SYSTEM_UPGRADE(validCheck, result) \ 42 if (!(validCheck)) { \ 43 EVENT_WRITE("SYSTEM_UPGRADE", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, \ 44 "UPDATE_RESULT", result); \ 45 } 46 47 #define SYS_EVENT_SYSTEM_RESET(validCheck, result) \ 48 if (!(validCheck)) { \ 49 EVENT_WRITE("SYSTEM_RESET", OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, \ 50 "RESET_RESULT", result); \ 51 } 52 53 #define SYS_EVENT_VERIFY_FAILED(validCheck, deviceId, description) \ 54 if (!(validCheck)) { \ 55 EVENT_WRITE("VERIFY_FAILED", OHOS::HiviewDFX::HiSysEvent::EventType::SECURITY, \ 56 "DEVICE_ID", deviceId, "DESCRIPTION", description); \ 57 } 58 59 class UpdateSystemEvent { 60 public: 61 static constexpr const char *EMPTY = ""; 62 static constexpr const char *UPGRADE_START = "upgrade start"; 63 static constexpr const char *RESET_START = "reset start"; 64 static constexpr const char *EVENT_FAILED_RESULT = "failed"; 65 static constexpr const char *EVENT_SUCCESS_RESULT = "success"; 66 67 static constexpr const char *EVENT_UPGRADE_INTERVAL = "upgrade"; 68 static constexpr const char *EVENT_CHECK_INTERVAL = "check"; 69 static constexpr const char *EVENT_DOWNLOAD_INTERVAL = "download"; 70 71 static constexpr const char *EVENT_PERMISSION_VERIFY_FAILED = "permission verify failed"; 72 static constexpr const char *EVENT_PKG_VERIFY_FAILED = "upgrade package verify failed"; 73 }; 74 } // namespace UpdateEngine 75 } // namespace OHOS 76 #endif // UPDATE_SYSTEM_EVENT_H