diff --git a/common/BUILD.gn b/common/BUILD.gn index 9843f64e4ba029fb33e9edc08e213a75faf20a3c..c5be259d6cb040b33af86501fa7d96d9e35efe2f 100644 --- a/common/BUILD.gn +++ b/common/BUILD.gn @@ -24,6 +24,7 @@ ohos_shared_library("distributed_screen_utils") { ] sources = [ + "src/dscreen_hisysevent.cpp", "src/dscreen_log.cpp", "src/dscreen_util.cpp", ] @@ -32,6 +33,7 @@ ohos_shared_library("distributed_screen_utils") { external_deps = [ "dsoftbus_standard:softbus_client", + "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", ] diff --git a/common/include/dscreen_hisysevent.h b/common/include/dscreen_hisysevent.h new file mode 100644 index 0000000000000000000000000000000000000000..7fe740fc666e11481a47e293e685f96e74024b58 --- /dev/null +++ b/common/include/dscreen_hisysevent.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef OHOS_DSCREEN_HISYSEVENT_H +#define OHOS_DSCREEN_HISYSEVENT_H + +#include + +#include "hisysevent.h" + +namespace OHOS { +namespace DistributedHardware { +const std::string SA_ERROR = "DSCREEN_SA_START_ERROR"; +const std::string WINDOW_ERROR = "DSCREEN_WINDOW_ERROR"; +const std::string VIRTUALSCREEN_ERROR = "DSCREEN_VIRTUALSCREEN_ERROR"; +const std::string VIDEO_DECODER_ERROR = "DSCREEN_VIDEO_DECODER_ERROR"; +const std::string VIDEO_ENCODER_ERROR = "DSCREEN_VIDEO_ENCODER_ERROR"; +const std::string SOFTBUS_SESSIONSERVER_ERROR = "DSCREEN_SOFTBUS_SESSIONSERVER_ERROR"; +const std::string SOFTBUS_SESSION_ERROR = "DSCREEN_SOFTBUS_SESSION_ERROR"; + +void ReportScreenEvent(const std::string &eventName, const std::string &errMsg); +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/common/src/dscreen_hisysevent.cpp b/common/src/dscreen_hisysevent.cpp new file mode 100644 index 0000000000000000000000000000000000000000..245f7fc80be9dfd806bd4a8e32d0d5560625c28d --- /dev/null +++ b/common/src/dscreen_hisysevent.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "dscreen_errcode.h" +#include "dscreen_log.h" +#include "dscreen_hisysevent.h" + +namespace OHOS { +namespace DistributedHardware { +void ReportScreenEvent(const std::string &eventName, const std::string &errMsg) +{ + int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( + OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, + eventName, + OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, + "PID", getpid(), + "UID", getuid(), + "MSG", errMsg); + if (res != DH_SUCCESS) { + DHLOGE("Write HiSysEvent error, res:%d", res); + } +} +} // namespace DistributedHardware +} // namespace OHOS diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp index ef6d9455ef89fdec2ed133009830689e816771d4..dec2afe0cfa1f5e447a5ad5b3140ae654d57a26c 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/callback/dscreen_sink_load_callback.cpp @@ -16,9 +16,8 @@ #include -#include "hisysevent.h" - #include "dscreen_errcode.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" #include "dscreen_sink_handler.h" @@ -43,16 +42,7 @@ void DScreenSinkLoadCallback::OnLoadSystemAbilitySuccess( void DScreenSinkLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DHLOGE("load screen SA failed, systemAbilityId:%d", systemAbilityId); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SA_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dscreen sink OnLoadSystemAbilityFail."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SA_ERROR, "dscreen sink OnLoadSystemAbilityFail."); } } } \ No newline at end of file diff --git a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp index 66472e7b9f5ca7cd64ae41765da5220aa4651756..6938403e7995255956e9d71085949b027a8cc60e 100644 --- a/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_sink/src/dscreen_sink_handler.cpp @@ -15,13 +15,13 @@ #include "dscreen_sink_handler.h" -#include "hisysevent.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_hitrace.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" #include "dscreen_sink_load_callback.h" @@ -59,16 +59,7 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) if (ret != ERR_OK) { DHLOGE("Failed to Load systemAbility, systemAbilityId:%d, ret code:%d", DISTRIBUTED_HARDWARE_SCREEN_SINK_SA_ID, ret); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SA_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dscreen sink LoadSystemAbility call failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SA_ERROR, "dscreen sink LoadSystemAbility call failed."); return ERR_DH_SCREEN_SA_GET_SINKPROXY_FAIL; } } @@ -77,16 +68,7 @@ int32_t DScreenSinkHandler::InitSink(const std::string ¶ms) [this]() { return dScreenSinkProxy_ != nullptr; }); if (!waitStatus) { DHLOGE("screen load sa timeout"); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SA_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dscreen sink sa load timeout."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SA_ERROR, "dscreen sink sa load timeout."); return ERR_DH_SCREEN_SA_LOAD_TIMEOUT; } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp index ce4c32b87f00c56cc0c6c3c77a5f091907446f6a..49ec00c6882b8fc3a4bbea2d4d3381e738258699 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/callback/dscreen_source_load_callback.cpp @@ -16,9 +16,8 @@ #include -#include "hisysevent.h" - #include "dscreen_errcode.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" #include "dscreen_source_handler.h" @@ -42,16 +41,7 @@ void DScreenSourceLoadCallback::OnLoadSystemAbilitySuccess( void DScreenSourceLoadCallback::OnLoadSystemAbilityFail(int32_t systemAbilityId) { DHLOGE("load screen SA failed, systemAbilityId:%d", systemAbilityId); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SA_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dscreen source OnLoadSystemAbilityFail."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SA_ERROR, "dscreen source OnLoadSystemAbilityFail."); } } } diff --git a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp index a4c528d9eb43c2566c63435e1cce22a13668a268..fec82f9f1dab039f5772e47354ea331545ee9ca3 100644 --- a/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp +++ b/interfaces/innerkits/native_cpp/screen_source/src/dscreen_source_handler.cpp @@ -15,13 +15,13 @@ #include "dscreen_source_handler.h" -#include "hisysevent.h" #include "if_system_ability_manager.h" #include "iservice_registry.h" #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_hitrace.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" #include "dscreen_source_load_callback.h" #include "dscreen_util.h" @@ -64,16 +64,7 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) if (ret != ERR_OK) { DHLOGE("Failed to Load systemAbility, systemAbilityId:%d, ret code:%d", DISTRIBUTED_HARDWARE_SCREEN_SOURCE_SA_ID, ret); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SA_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dscreen source LoadSystemAbility call failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SA_ERROR, "dscreen source LoadSystemAbility call failed."); return ERR_DH_SCREEN_SA_GET_SOURCEPROXY_FAIL; } } @@ -82,16 +73,7 @@ int32_t DScreenSourceHandler::InitSource(const std::string ¶ms) [this]() { return (dScreenSourceProxy_ != nullptr); }); if (!waitStatus) { DHLOGE("screen load sa timeout."); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SA_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "dscreen source sa load timeout."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SA_ERROR, "dscreen source sa load timeout."); return ERR_DH_SCREEN_SA_LOAD_TIMEOUT; } diff --git a/services/screenclient/src/screen_client_window_adapter.cpp b/services/screenclient/src/screen_client_window_adapter.cpp index d7c0098be81f9f5453235ed739ee16331298f2e8..30c09c5052921bbb3cd87f11178f2e27f6859fe9 100644 --- a/services/screenclient/src/screen_client_window_adapter.cpp +++ b/services/screenclient/src/screen_client_window_adapter.cpp @@ -15,13 +15,13 @@ #include "screen_client_window_adapter.h" -#include "hisysevent.h" #include "rs_surface_node.h" #include "window_option.h" #include "wm_common.h" #include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" namespace OHOS { @@ -64,16 +64,7 @@ sptr ScreenClientWindowAdapter::CreateWindow(std::shared_ptr window = Rosen::Window::Create(windowName, option); if (window == nullptr || window->GetSurfaceNode() == nullptr) { DHLOGE("Create screen client window failed."); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "WINDOW_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "create window failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(WINDOW_ERROR, "create window failed."); return nullptr; } auto surface = window->GetSurfaceNode()->GetSurface(); @@ -122,16 +113,7 @@ int32_t ScreenClientWindowAdapter::ShowWindow(int32_t windowId) } if (OHOS::Rosen::WMError::WM_OK != window->Show()) { DHLOGE("Show window failed."); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "WINDOW_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "show window failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(WINDOW_ERROR, "show window failed."); return ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR; } DHLOGD("Show window (windowId = %d) success.", windowId); diff --git a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp index b3f4c0a33b1f0c8d7abe25d0d2e032e9ee11b2a9..edbe1baf8f270be46336df44cf4e19ed18c50c4c 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/screen_manager_adapter.cpp @@ -19,11 +19,11 @@ #include "display_manager.h" #include "dm_common.h" -#include "hisysevent.h" #include "screen.h" #include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" namespace OHOS { @@ -47,16 +47,7 @@ uint64_t ScreenMgrAdapter::CreateVirtualScreen(const std::string &devId, const s Rosen::DMError err = Rosen::ScreenManager::GetInstance().DestroyVirtualScreen(iter->second); if (err != Rosen::DMError::DM_OK) { DHLOGE("remove virtual screen failed, screenId:%ulld", iter->second); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "VIRTUALSCREEN_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "destroy virtual screen failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(VIRTUALSCREEN_ERROR, "destroy virtual screen failed."); return SCREEN_ID_INVALID; } screenIdMap_.erase(screenName); @@ -74,16 +65,7 @@ uint64_t ScreenMgrAdapter::CreateVirtualScreen(const std::string &devId, const s uint64_t screenId = Rosen::ScreenManager::GetInstance().CreateVirtualScreen(option); if (screenId == SCREEN_ID_INVALID) { - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "VIRTUALSCREEN_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "create virtual screen failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(VIRTUALSCREEN_ERROR, "create virtual screen failed."); } screenIdMap_.emplace(screenName, screenId); return screenId; @@ -135,16 +117,7 @@ int32_t ScreenMgrAdapter::RemoveVirtualScreen(uint64_t screenId) Rosen::DMError err = Rosen::ScreenManager::GetInstance().DestroyVirtualScreen(screenId); if (err != Rosen::DMError::DM_OK) { DHLOGE("remove virtual screen failed, screenId:%ulld", screenId); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "VIRTUALSCREEN_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "destroy virtual screen failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(VIRTUALSCREEN_ERROR, "destroy virtual screen failed."); return ERR_DH_SCREEN_SA_REMOVE_VIRTUALSCREEN_FAIL; } return DH_SUCCESS; diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index ebd31d7a87319613ee86c4d84b9b0fc9af8b88c9..05e0502442c45de27f3c6318def1ca879293b12b 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -18,10 +18,9 @@ #include #include -#include "hisysevent.h" - #include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" namespace OHOS { @@ -80,16 +79,7 @@ int32_t ImageSinkDecoder::StartDecoder() ret = videoDecoder_->Start(); if (ret != Media::MSERR_OK) { DHLOGE("%s: Start decoder failed.", LOG_TAG); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "VIDEO_DECODER_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "video decoder start failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(VIDEO_DECODER_ERROR, "video decoder start failed."); return ERR_DH_SCREEN_CODEC_START_FAILED; } StartInputThread(); @@ -114,16 +104,7 @@ int32_t ImageSinkDecoder::StopDecoder() ret = videoDecoder_->Stop(); if (ret != Media::MSERR_OK) { DHLOGE("%s: Stop decoder failed.", LOG_TAG); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "VIDEO_DECODER_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "video decoder stop failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(VIDEO_DECODER_ERROR, "video decoder stop failed."); return ERR_DH_SCREEN_CODEC_STOP_FAILED; } StopInputThread(); diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index ca2621b4da8ed2b1d0b0ff17455f7690b3440fc0..5c1f83896d4ea3dc10056769eefa775a9a7f33e8 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -18,10 +18,9 @@ #include #include -#include "hisysevent.h" - #include "dscreen_constants.h" #include "dscreen_errcode.h" +#include "dscreen_hisysevent.h" #include "dscreen_log.h" namespace OHOS { @@ -86,16 +85,7 @@ int32_t ImageSourceEncoder::StartEncoder() ret = videoEncoder_->Start(); if (ret != Media::MSERR_OK) { DHLOGE("%s: Start encoder failed.", LOG_TAG); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "VIDEO_ENCODER_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "video encoder start failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(VIDEO_ENCODER_ERROR, "video encoder start failed."); return ERR_DH_SCREEN_CODEC_START_FAILED; } @@ -118,16 +108,7 @@ int32_t ImageSourceEncoder::StopEncoder() ret = videoEncoder_->Stop(); if (ret != Media::MSERR_OK) { DHLOGE("%s: Stop encoder failed.", LOG_TAG); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "VIDEO_ENCODER_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MSG", "video encoder stop failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(VIDEO_ENCODER_ERROR, "video encoder stop failed."); return ERR_DH_SCREEN_CODEC_STOP_FAILED; } diff --git a/services/softbusadapter/src/softbus_adapter.cpp b/services/softbusadapter/src/softbus_adapter.cpp index 2d7e1f634cd7b963749f8b9919bc342e318c930a..885f7b9feb215d74f955070893bc7d2849cec0a4 100644 --- a/services/softbusadapter/src/softbus_adapter.cpp +++ b/services/softbusadapter/src/softbus_adapter.cpp @@ -18,11 +18,11 @@ #include #include -#include "hisysevent.h" #include "softbus_bus_center.h" #include "softbus_common.h" #include "dscreen_errcode.h" +#include "dscreen_hisysevent.h" #include "dscreen_util.h" namespace OHOS { @@ -111,18 +111,7 @@ int32_t SoftbusAdapter::CreateSoftbusSessionServer(const std::string &pkgname, c int32_t ret = CreateSessionServer(pkgname.c_str(), sessionName.c_str(), &sessListener_); if (ret != DH_SUCCESS) { DHLOGE("%s: CreateSessionServer failed.", LOG_TAG); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SOFTBUS_SESSIONSERVER_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "PKGNAME", pkgname.c_str(), - "SESSIONNAME", sessionName.c_str(), - "MSG", "create session server failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SOFTBUS_SESSIONSERVER_ERROR, "create session server failed."); return ret; } } else { @@ -150,18 +139,7 @@ int32_t SoftbusAdapter::RemoveSoftbusSessionServer(const std::string &pkgname, c int32_t ret = RemoveSessionServer(pkgname.c_str(), sessionName.c_str()); if (ret != DH_SUCCESS) { DHLOGE("%s: RemoveSessionServer failed.", LOG_TAG); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SOFTBUS_SESSIONSERVER_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "PKGNAME", pkgname.c_str(), - "SESSIONNAME", sessionName.c_str(), - "MSG", "remove session server failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SOFTBUS_SESSIONSERVER_ERROR, "remove session server failed."); return ret; } @@ -203,19 +181,7 @@ int32_t SoftbusAdapter::OpenSoftbusSession(const std::string &mySessionName, con int32_t sessionId = OpenSession(mySessionName.c_str(), peerSessionName.c_str(), peerDevId.c_str(), "0", &attr); if (sessionId < 0) { DHLOGE("%s: OpenSession failed sessionId:%d.", LOG_TAG, sessionId); - int32_t res = OHOS::HiviewDFX::HiSysEvent::Write( - OHOS::HiviewDFX::HiSysEvent::Domain::DISTRIBUTED_SCREEN, - "SOFTBUS_SESSION_ERROR", - OHOS::HiviewDFX::HiSysEvent::EventType::FAULT, - "PID", getpid(), - "UID", getuid(), - "MYSESSIONNAME", mySessionName.c_str(), - "PEERSESSIONNAME", peerSessionName.c_str(), - "PEERDEVID", peerDevId.c_str(), - "MSG", "open session failed."); - if (res != DH_SUCCESS) { - DHLOGE("Write HiSysEvent error, res:%d", res); - } + ReportScreenEvent(SOFTBUS_SESSION_ERROR, "open session failed."); return ERR_DH_SCREEN_ADAPTER_OPEN_SESSION_FAIL; }