1/* 2 * Copyright (c) 2023-2024 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#include "test_processor.h" 16 17#include <cinttypes> 18 19#include "app_event_processor_mgr.h" 20#include "hilog/log.h" 21 22#undef LOG_DOMAIN 23#define LOG_DOMAIN 0xD002D07 24 25#undef LOG_TAG 26#define LOG_TAG "TestProcessor" 27 28namespace OHOS { 29namespace HiviewDFX { 30namespace HiAppEvent { 31namespace { 32void PrintReportConfig(int64_t processorSeq) 33{ 34 ReportConfig config; 35 AppEventProcessorMgr::GetProcessorConfig(processorSeq, config); 36 HILOG_INFO(LOG_CORE, ".name=%{public}s", config.name.c_str()); 37 HILOG_INFO(LOG_CORE, ".debugMode=%{public}d", config.debugMode); 38 HILOG_INFO(LOG_CORE, ".routeInfo=%{public}s", config.routeInfo.c_str()); 39 HILOG_INFO(LOG_CORE, ".appId=%{public}s", config.appId.c_str()); 40 HILOG_INFO(LOG_CORE, ".triggerCond.row=%{public}d", config.triggerCond.row); 41 HILOG_INFO(LOG_CORE, ".triggerCond.size=%{public}d", config.triggerCond.size); 42 HILOG_INFO(LOG_CORE, ".triggerCond.timeout=%{public}d", config.triggerCond.timeout); 43 HILOG_INFO(LOG_CORE, ".triggerCond.onStartup=%{public}d", config.triggerCond.onStartup); 44 HILOG_INFO(LOG_CORE, ".triggerCond.onBackground=%{public}d", config.triggerCond.onBackground); 45 HILOG_INFO(LOG_CORE, ".userIdNames.size=%{public}zu", config.userIdNames.size()); 46 HILOG_INFO(LOG_CORE, ".userPropertyNames.size=%{public}zu", config.userPropertyNames.size()); 47 HILOG_INFO(LOG_CORE, ".eventConfigs.size=%{public}zu", config.eventConfigs.size()); 48 HILOG_INFO(LOG_CORE, ".configId=%{public}d", config.configId); 49 HILOG_INFO(LOG_CORE, ".customConfigs.size=%{public}zu", config.customConfigs.size()); 50} 51 52void PrintEvent(const AppEventInfo& event) 53{ 54 HILOG_INFO(LOG_CORE, "AppEventInfo.domain=%{public}s", event.domain.c_str()); 55 HILOG_INFO(LOG_CORE, "AppEventInfo.name=%{public}s", event.name.c_str()); 56 HILOG_INFO(LOG_CORE, "AppEventInfo.eventType=%{public}d", event.eventType); 57 HILOG_INFO(LOG_CORE, "AppEventInfo.timestamp=%{public}" PRId64, event.timestamp); 58 HILOG_INFO(LOG_CORE, "AppEventInfo.params=%{public}s", event.params.c_str()); 59} 60} 61 62int TestProcessor::OnReport( 63 int64_t processorSeq, 64 const std::vector<UserId>& userIds, 65 const std::vector<UserProperty>& userProperties, 66 const std::vector<AppEventInfo>& events) 67{ 68 HILOG_INFO(LOG_CORE, "OnReport start"); 69 PrintReportConfig(processorSeq); 70 for (const auto& event : events) { 71 PrintEvent(event); 72 } 73 HILOG_INFO(LOG_CORE, "OnReport end"); 74 return 0; 75} 76 77int TestProcessor::ValidateUserId(const UserId& userId) 78{ 79 return 0; 80} 81 82int TestProcessor::ValidateUserProperty(const UserProperty& userProperty) 83{ 84 return 0; 85} 86 87int TestProcessor::ValidateEvent(const AppEventInfo& event) 88{ 89 return 0; 90} 91} // namespace HiAppEvent 92} // namespace HiviewDFX 93} // namespace OHOS 94