1cf69771bSopenharmony_ci/*
2cf69771bSopenharmony_ci * Copyright (c) 2022-2022 Huawei Device Co., Ltd.
3cf69771bSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4cf69771bSopenharmony_ci * you may not use this file except in compliance with the License.
5cf69771bSopenharmony_ci * You may obtain a copy of the License at
6cf69771bSopenharmony_ci *
7cf69771bSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8cf69771bSopenharmony_ci *
9cf69771bSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10cf69771bSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11cf69771bSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12cf69771bSopenharmony_ci * See the License for the specific language governing permissions and
13cf69771bSopenharmony_ci * limitations under the License.
14cf69771bSopenharmony_ci */
15cf69771bSopenharmony_ci
16cf69771bSopenharmony_ci#include "time_sysevent.h"
17cf69771bSopenharmony_ci
18cf69771bSopenharmony_ci#include "hisysevent.h"
19cf69771bSopenharmony_ci#include "time_hilog.h"
20cf69771bSopenharmony_ci
21cf69771bSopenharmony_cinamespace OHOS {
22cf69771bSopenharmony_cinamespace MiscServices {
23cf69771bSopenharmony_cinamespace {
24cf69771bSopenharmony_ciusing HiSysEventNameSpace = OHOS::HiviewDFX::HiSysEvent;
25cf69771bSopenharmony_ci} // namespace
26cf69771bSopenharmony_ci
27cf69771bSopenharmony_civoid StatisticReporter(int32_t callerPid, int32_t size, std::shared_ptr<TimerInfo> timer)
28cf69771bSopenharmony_ci{
29cf69771bSopenharmony_ci    int32_t callerUid = timer->uid;
30cf69771bSopenharmony_ci    std::string bundleOrProcessName = timer->bundleName;
31cf69771bSopenharmony_ci    int32_t type = timer->type;
32cf69771bSopenharmony_ci    int64_t triggerTime = timer->whenElapsed.time_since_epoch().count();
33cf69771bSopenharmony_ci    auto interval = static_cast<uint64_t>(timer->repeatInterval.count());
34cf69771bSopenharmony_ci    int ret = HiSysEventWrite(HiSysEventNameSpace::Domain::TIME, "MISC_TIME_STATISTIC_REPORT",
35cf69771bSopenharmony_ci        HiSysEventNameSpace::EventType::STATISTIC, "CALLER_PID", callerPid, "CALLER_UID", callerUid,
36cf69771bSopenharmony_ci        "BUNDLE_OR_PROCESS_NAME", bundleOrProcessName, "TIMER_SIZE", size, "TIMER_TYPE", type,
37cf69771bSopenharmony_ci        "TRIGGER_TIME", triggerTime, "INTERVAL", interval);
38cf69771bSopenharmony_ci    if (ret != 0) {
39cf69771bSopenharmony_ci        TIME_HILOGE(TIME_MODULE_SERVICE,
40cf69771bSopenharmony_ci            "hisysevent Statistic failed! pid %{public}d,uid %{public}d,timer type %{public}d", callerPid, callerUid,
41cf69771bSopenharmony_ci            type);
42cf69771bSopenharmony_ci    }
43cf69771bSopenharmony_ci}
44cf69771bSopenharmony_ci} // namespace MiscServices
45cf69771bSopenharmony_ci} // namespace OHOS