166f3657fSopenharmony_ci/*
266f3657fSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
366f3657fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
466f3657fSopenharmony_ci * you may not use this file except in compliance with the License.
566f3657fSopenharmony_ci * You may obtain a copy of the License at
666f3657fSopenharmony_ci *
766f3657fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
866f3657fSopenharmony_ci *
966f3657fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1066f3657fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1166f3657fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1266f3657fSopenharmony_ci * See the License for the specific language governing permissions and
1366f3657fSopenharmony_ci * limitations under the License.
1466f3657fSopenharmony_ci */
1566f3657fSopenharmony_ci
1666f3657fSopenharmony_ci#include "dscreen_hisysevent.h"
1766f3657fSopenharmony_ci
1866f3657fSopenharmony_ci#include "hisysevent.h"
1966f3657fSopenharmony_ci
2066f3657fSopenharmony_ci#include "dscreen_errcode.h"
2166f3657fSopenharmony_ci#include "dscreen_log.h"
2266f3657fSopenharmony_ci
2366f3657fSopenharmony_cinamespace OHOS {
2466f3657fSopenharmony_cinamespace DistributedHardware {
2566f3657fSopenharmony_civoid ReportSaFail(const std::string &eventName, int32_t errCode, int32_t saId, const std::string &errMsg)
2666f3657fSopenharmony_ci{
2766f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(
2866f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
2966f3657fSopenharmony_ci        eventName,
3066f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
3166f3657fSopenharmony_ci        "ERRCODE", errCode,
3266f3657fSopenharmony_ci        "SAID", saId,
3366f3657fSopenharmony_ci        "MSG", errMsg);
3466f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
3566f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
3666f3657fSopenharmony_ci    }
3766f3657fSopenharmony_ci}
3866f3657fSopenharmony_ci
3966f3657fSopenharmony_civoid ReportRegisterFail(const std::string &eventName, int32_t errCode, const std::string &devId,
4066f3657fSopenharmony_ci    const std::string &dhId, const std::string &errMsg)
4166f3657fSopenharmony_ci{
4266f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, eventName,
4366f3657fSopenharmony_ci                                  OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, "ERRCODE", errCode,
4466f3657fSopenharmony_ci                                  "DEVID", devId, "DHID", dhId, "MSG", errMsg);
4566f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
4666f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
4766f3657fSopenharmony_ci    }
4866f3657fSopenharmony_ci}
4966f3657fSopenharmony_ci
5066f3657fSopenharmony_civoid ReportUnRegisterFail(const std::string &eventName, int32_t errCode, const std::string &devId,
5166f3657fSopenharmony_ci    const std::string &dhId, const std::string &errMsg)
5266f3657fSopenharmony_ci{
5366f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(
5466f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
5566f3657fSopenharmony_ci        eventName,
5666f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
5766f3657fSopenharmony_ci        "ERRCODE", errCode,
5866f3657fSopenharmony_ci        "DEVID", devId,
5966f3657fSopenharmony_ci        "DHID", dhId,
6066f3657fSopenharmony_ci        "MSG", errMsg);
6166f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
6266f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
6366f3657fSopenharmony_ci    }
6466f3657fSopenharmony_ci}
6566f3657fSopenharmony_ci
6666f3657fSopenharmony_civoid ReportOptFail(const std::string &eventName, int32_t errCode, const std::string &errMsg)
6766f3657fSopenharmony_ci{
6866f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(
6966f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
7066f3657fSopenharmony_ci        eventName,
7166f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::EventType::FAULT,
7266f3657fSopenharmony_ci        "ERRCODE", errCode,
7366f3657fSopenharmony_ci        "MSG", errMsg);
7466f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
7566f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
7666f3657fSopenharmony_ci    }
7766f3657fSopenharmony_ci}
7866f3657fSopenharmony_ci
7966f3657fSopenharmony_civoid ReportSaEvent(const std::string &eventName, int32_t saId, const std::string &errMsg)
8066f3657fSopenharmony_ci{
8166f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(
8266f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
8366f3657fSopenharmony_ci        eventName,
8466f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
8566f3657fSopenharmony_ci        "SAID", saId,
8666f3657fSopenharmony_ci        "MSG", errMsg);
8766f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
8866f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
8966f3657fSopenharmony_ci    }
9066f3657fSopenharmony_ci}
9166f3657fSopenharmony_ci
9266f3657fSopenharmony_civoid ReportRegisterScreenEvent(const std::string &eventName, const std::string &devId, const std::string &dhId,
9366f3657fSopenharmony_ci    const std::string &errMsg)
9466f3657fSopenharmony_ci{
9566f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, eventName,
9666f3657fSopenharmony_ci                                  OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "DEVID", devId,
9766f3657fSopenharmony_ci                                  "DHID", dhId, "MSG", errMsg);
9866f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
9966f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
10066f3657fSopenharmony_ci    }
10166f3657fSopenharmony_ci}
10266f3657fSopenharmony_ci
10366f3657fSopenharmony_civoid ReportUnRegisterScreenEvent(const std::string &eventName, const std::string &devId, const std::string &dhId,
10466f3657fSopenharmony_ci    const std::string &errMsg)
10566f3657fSopenharmony_ci{
10666f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, eventName,
10766f3657fSopenharmony_ci                                  OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR, "DEVID", devId, "DHID", dhId,
10866f3657fSopenharmony_ci                                  "MSG", errMsg);
10966f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
11066f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
11166f3657fSopenharmony_ci    }
11266f3657fSopenharmony_ci}
11366f3657fSopenharmony_ci
11466f3657fSopenharmony_civoid ReportScreenMirrorEvent(const std::string &eventName, const std::string &devId, const std::string &dhId,
11566f3657fSopenharmony_ci    const std::string &errMsg)
11666f3657fSopenharmony_ci{
11766f3657fSopenharmony_ci    int32_t res = HiSysEventWrite(
11866f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN,
11966f3657fSopenharmony_ci        eventName,
12066f3657fSopenharmony_ci        OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR,
12166f3657fSopenharmony_ci        "DEVID", devId,
12266f3657fSopenharmony_ci        "DHID", dhId,
12366f3657fSopenharmony_ci        "MSG", errMsg);
12466f3657fSopenharmony_ci    if (res != DH_SUCCESS) {
12566f3657fSopenharmony_ci        DHLOGE("Write HiSysEvent error, res:%{public}" PRId32, res);
12666f3657fSopenharmony_ci    }
12766f3657fSopenharmony_ci}
12866f3657fSopenharmony_ci} // namespace DistributedHardware
12966f3657fSopenharmony_ci} // namespace OHOS
130