114cf0368Sopenharmony_ci/*
214cf0368Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
314cf0368Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
414cf0368Sopenharmony_ci * you may not use this file except in compliance with the License.
514cf0368Sopenharmony_ci * You may obtain a copy of the License at
614cf0368Sopenharmony_ci *
714cf0368Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
814cf0368Sopenharmony_ci *
914cf0368Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1014cf0368Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1114cf0368Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1214cf0368Sopenharmony_ci * See the License for the specific language governing permissions and
1314cf0368Sopenharmony_ci * limitations under the License.
1414cf0368Sopenharmony_ci */
1514cf0368Sopenharmony_ci#define LOG_TAG "UdmfRadarReporter"
1614cf0368Sopenharmony_ci
1714cf0368Sopenharmony_ci#include "udmf_radar_reporter.h"
1814cf0368Sopenharmony_ci
1914cf0368Sopenharmony_cinamespace OHOS {
2014cf0368Sopenharmony_cinamespace UDMF {
2114cf0368Sopenharmony_ciusing namespace RadarReporter;
2214cf0368Sopenharmony_civoid RadarReporterAdapter::ReportNormal(const std::string &func, int32_t scene,
2314cf0368Sopenharmony_ci                                        int32_t stage, int32_t stageRes, int32_t state)
2414cf0368Sopenharmony_ci{
2514cf0368Sopenharmony_ci    struct HiSysEventParam params[] = {
2614cf0368Sopenharmony_ci        { .name = { "ORG_PKG" },
2714cf0368Sopenharmony_ci            .t = HISYSEVENT_STRING,
2814cf0368Sopenharmony_ci            .v = { .s = const_cast<char *>(ORG_PKG) },
2914cf0368Sopenharmony_ci            .arraySize = 0 },
3014cf0368Sopenharmony_ci        { .name = { "FUNC" },
3114cf0368Sopenharmony_ci            .t = HISYSEVENT_STRING,
3214cf0368Sopenharmony_ci            .v = { .s = const_cast<char *>(func.c_str()) },
3314cf0368Sopenharmony_ci            .arraySize = 0 },
3414cf0368Sopenharmony_ci        { .name = { "BIZ_SCENE" },
3514cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
3614cf0368Sopenharmony_ci            .v = { .i32 = scene },
3714cf0368Sopenharmony_ci            .arraySize = 0 },
3814cf0368Sopenharmony_ci        { .name = { "BIZ_STAGE" },
3914cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
4014cf0368Sopenharmony_ci            .v = { .i32 = stage },
4114cf0368Sopenharmony_ci            .arraySize = 0 },
4214cf0368Sopenharmony_ci        { .name = { "STAGE_RES" },
4314cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
4414cf0368Sopenharmony_ci            .v = { .i32 = stageRes },
4514cf0368Sopenharmony_ci            .arraySize = 0 },
4614cf0368Sopenharmony_ci        { .name = { "BIZ_STATE" },
4714cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
4814cf0368Sopenharmony_ci            .v = { .i32 = state },
4914cf0368Sopenharmony_ci            .arraySize = 0 }
5014cf0368Sopenharmony_ci    };
5114cf0368Sopenharmony_ci    OH_HiSysEvent_Write(
5214cf0368Sopenharmony_ci        DOMAIN,
5314cf0368Sopenharmony_ci        EVENT_NAME,
5414cf0368Sopenharmony_ci        HISYSEVENT_BEHAVIOR,
5514cf0368Sopenharmony_ci        params,
5614cf0368Sopenharmony_ci        sizeof(params) / sizeof(params[0])
5714cf0368Sopenharmony_ci    );
5814cf0368Sopenharmony_ci}
5914cf0368Sopenharmony_ci
6014cf0368Sopenharmony_civoid RadarReporterAdapter::ReportFail(
6114cf0368Sopenharmony_ci    const std::string &func, int32_t scene, int32_t stage, int32_t stageRes, int32_t errorCode, int32_t state)
6214cf0368Sopenharmony_ci{
6314cf0368Sopenharmony_ci    struct HiSysEventParam params[] = {
6414cf0368Sopenharmony_ci        { .name = { "ORG_PKG" },
6514cf0368Sopenharmony_ci            .t = HISYSEVENT_STRING,
6614cf0368Sopenharmony_ci            .v = { .s = const_cast<char *>(ORG_PKG) },
6714cf0368Sopenharmony_ci            .arraySize = 0 },
6814cf0368Sopenharmony_ci        { .name = { "FUNC" },
6914cf0368Sopenharmony_ci            .t = HISYSEVENT_STRING,
7014cf0368Sopenharmony_ci            .v = { .s = const_cast<char *>(func.c_str()) },
7114cf0368Sopenharmony_ci            .arraySize = 0 },
7214cf0368Sopenharmony_ci        { .name = { "BIZ_SCENE" },
7314cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
7414cf0368Sopenharmony_ci            .v = { .i32 = scene },
7514cf0368Sopenharmony_ci            .arraySize = 0 },
7614cf0368Sopenharmony_ci        { .name = { "BIZ_STAGE" },
7714cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
7814cf0368Sopenharmony_ci            .v = { .i32 = stage },
7914cf0368Sopenharmony_ci            .arraySize = 0 },
8014cf0368Sopenharmony_ci        { .name = { "STAGE_RES" },
8114cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
8214cf0368Sopenharmony_ci            .v = { .i32 = stageRes },
8314cf0368Sopenharmony_ci            .arraySize = 0 },
8414cf0368Sopenharmony_ci        { .name = { "ERROR_CODE" },
8514cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
8614cf0368Sopenharmony_ci            .v = { .i32 = stageRes },
8714cf0368Sopenharmony_ci            .arraySize = 0 },
8814cf0368Sopenharmony_ci        { .name = { "BIZ_STATE" },
8914cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
9014cf0368Sopenharmony_ci            .v = { .i32 = state },
9114cf0368Sopenharmony_ci            .arraySize = 0 }
9214cf0368Sopenharmony_ci    };
9314cf0368Sopenharmony_ci    OH_HiSysEvent_Write(
9414cf0368Sopenharmony_ci        DOMAIN,
9514cf0368Sopenharmony_ci        EVENT_NAME,
9614cf0368Sopenharmony_ci        HISYSEVENT_BEHAVIOR,
9714cf0368Sopenharmony_ci        params,
9814cf0368Sopenharmony_ci        sizeof(params) / sizeof(params[0])
9914cf0368Sopenharmony_ci    );
10014cf0368Sopenharmony_ci}
10114cf0368Sopenharmony_ci
10214cf0368Sopenharmony_civoid RadarReporterAdapter::ReportFail(
10314cf0368Sopenharmony_ci    const std::string &func, int32_t scene, int32_t stage, int32_t stageRes, int32_t errorCode)
10414cf0368Sopenharmony_ci{
10514cf0368Sopenharmony_ci    struct HiSysEventParam params[] = {
10614cf0368Sopenharmony_ci        { .name = { "ORG_PKG" },
10714cf0368Sopenharmony_ci            .t = HISYSEVENT_STRING,
10814cf0368Sopenharmony_ci            .v = { .s = const_cast<char *>(ORG_PKG) },
10914cf0368Sopenharmony_ci            .arraySize = 0 },
11014cf0368Sopenharmony_ci        { .name = { "FUNC" },
11114cf0368Sopenharmony_ci            .t = HISYSEVENT_STRING,
11214cf0368Sopenharmony_ci            .v = { .s = const_cast<char *>(func.c_str()) },
11314cf0368Sopenharmony_ci            .arraySize = 0 },
11414cf0368Sopenharmony_ci        { .name = { "BIZ_SCENE" },
11514cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
11614cf0368Sopenharmony_ci            .v = { .i32 = scene },
11714cf0368Sopenharmony_ci            .arraySize = 0 },
11814cf0368Sopenharmony_ci        { .name = { "BIZ_STAGE" },
11914cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
12014cf0368Sopenharmony_ci            .v = { .i32 = stage },
12114cf0368Sopenharmony_ci            .arraySize = 0 },
12214cf0368Sopenharmony_ci        { .name = { "STAGE_RES" },
12314cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
12414cf0368Sopenharmony_ci            .v = { .i32 = stageRes },
12514cf0368Sopenharmony_ci            .arraySize = 0 },
12614cf0368Sopenharmony_ci        { .name = { "ERROR_CODE" },
12714cf0368Sopenharmony_ci            .t = HISYSEVENT_INT32,
12814cf0368Sopenharmony_ci            .v = { .i32 = errorCode },
12914cf0368Sopenharmony_ci            .arraySize = 0 }
13014cf0368Sopenharmony_ci    };
13114cf0368Sopenharmony_ci    OH_HiSysEvent_Write(
13214cf0368Sopenharmony_ci        DOMAIN,
13314cf0368Sopenharmony_ci        EVENT_NAME,
13414cf0368Sopenharmony_ci        HISYSEVENT_BEHAVIOR,
13514cf0368Sopenharmony_ci        params,
13614cf0368Sopenharmony_ci        sizeof(params) / sizeof(params[0])
13714cf0368Sopenharmony_ci    );
13814cf0368Sopenharmony_ci}
13914cf0368Sopenharmony_ci}
14014cf0368Sopenharmony_ci}
141