17405867cSopenharmony_ci/*
27405867cSopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
37405867cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
47405867cSopenharmony_ci * you may not use this file except in compliance with the License.
57405867cSopenharmony_ci * You may obtain a copy of the License at
67405867cSopenharmony_ci *
77405867cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
87405867cSopenharmony_ci *
97405867cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
107405867cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
117405867cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
127405867cSopenharmony_ci * See the License for the specific language governing permissions and
137405867cSopenharmony_ci * limitations under the License.
147405867cSopenharmony_ci */
157405867cSopenharmony_ci#include "test_processor.h"
167405867cSopenharmony_ci
177405867cSopenharmony_ci#include <cinttypes>
187405867cSopenharmony_ci
197405867cSopenharmony_ci#include "app_event_processor_mgr.h"
207405867cSopenharmony_ci#include "hilog/log.h"
217405867cSopenharmony_ci
227405867cSopenharmony_ci#undef LOG_DOMAIN
237405867cSopenharmony_ci#define LOG_DOMAIN 0xD002D07
247405867cSopenharmony_ci
257405867cSopenharmony_ci#undef LOG_TAG
267405867cSopenharmony_ci#define LOG_TAG "TestProcessor"
277405867cSopenharmony_ci
287405867cSopenharmony_cinamespace OHOS {
297405867cSopenharmony_cinamespace HiviewDFX {
307405867cSopenharmony_cinamespace HiAppEvent {
317405867cSopenharmony_cinamespace {
327405867cSopenharmony_civoid PrintReportConfig(int64_t processorSeq)
337405867cSopenharmony_ci{
347405867cSopenharmony_ci    ReportConfig config;
357405867cSopenharmony_ci    AppEventProcessorMgr::GetProcessorConfig(processorSeq, config);
367405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".name=%{public}s", config.name.c_str());
377405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".debugMode=%{public}d", config.debugMode);
387405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".routeInfo=%{public}s", config.routeInfo.c_str());
397405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".appId=%{public}s", config.appId.c_str());
407405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".triggerCond.row=%{public}d", config.triggerCond.row);
417405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".triggerCond.size=%{public}d", config.triggerCond.size);
427405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".triggerCond.timeout=%{public}d", config.triggerCond.timeout);
437405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".triggerCond.onStartup=%{public}d", config.triggerCond.onStartup);
447405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".triggerCond.onBackground=%{public}d", config.triggerCond.onBackground);
457405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".userIdNames.size=%{public}zu", config.userIdNames.size());
467405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".userPropertyNames.size=%{public}zu", config.userPropertyNames.size());
477405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".eventConfigs.size=%{public}zu", config.eventConfigs.size());
487405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".configId=%{public}d", config.configId);
497405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, ".customConfigs.size=%{public}zu", config.customConfigs.size());
507405867cSopenharmony_ci}
517405867cSopenharmony_ci
527405867cSopenharmony_civoid PrintEvent(const AppEventInfo& event)
537405867cSopenharmony_ci{
547405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, "AppEventInfo.domain=%{public}s", event.domain.c_str());
557405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, "AppEventInfo.name=%{public}s", event.name.c_str());
567405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, "AppEventInfo.eventType=%{public}d", event.eventType);
577405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, "AppEventInfo.timestamp=%{public}" PRId64, event.timestamp);
587405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, "AppEventInfo.params=%{public}s", event.params.c_str());
597405867cSopenharmony_ci}
607405867cSopenharmony_ci}
617405867cSopenharmony_ci
627405867cSopenharmony_ciint TestProcessor::OnReport(
637405867cSopenharmony_ci    int64_t processorSeq,
647405867cSopenharmony_ci    const std::vector<UserId>& userIds,
657405867cSopenharmony_ci    const std::vector<UserProperty>& userProperties,
667405867cSopenharmony_ci    const std::vector<AppEventInfo>& events)
677405867cSopenharmony_ci{
687405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, "OnReport start");
697405867cSopenharmony_ci    PrintReportConfig(processorSeq);
707405867cSopenharmony_ci    for (const auto& event : events) {
717405867cSopenharmony_ci        PrintEvent(event);
727405867cSopenharmony_ci    }
737405867cSopenharmony_ci    HILOG_INFO(LOG_CORE, "OnReport end");
747405867cSopenharmony_ci    return 0;
757405867cSopenharmony_ci}
767405867cSopenharmony_ci
777405867cSopenharmony_ciint TestProcessor::ValidateUserId(const UserId& userId)
787405867cSopenharmony_ci{
797405867cSopenharmony_ci    return 0;
807405867cSopenharmony_ci}
817405867cSopenharmony_ci
827405867cSopenharmony_ciint TestProcessor::ValidateUserProperty(const UserProperty& userProperty)
837405867cSopenharmony_ci{
847405867cSopenharmony_ci    return 0;
857405867cSopenharmony_ci}
867405867cSopenharmony_ci
877405867cSopenharmony_ciint TestProcessor::ValidateEvent(const AppEventInfo& event)
887405867cSopenharmony_ci{
897405867cSopenharmony_ci    return 0;
907405867cSopenharmony_ci}
917405867cSopenharmony_ci} // namespace HiAppEvent
927405867cSopenharmony_ci} // namespace HiviewDFX
937405867cSopenharmony_ci} // namespace OHOS
94