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