!1 整改hisysevent故障打点

Merge pull request !1 from gaoqiang/master
This commit is contained in:
william
2022-06-08 02:58:07 +00:00
committed by Gitee
12 changed files with 103 additions and 200 deletions
+2
View File
@@ -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",
]
+36
View File
@@ -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 <string>
#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
+38
View File
@@ -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 <unistd.h>
#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
@@ -16,9 +16,8 @@
#include <unistd.h>
#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.");
}
}
}
@@ -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 &params)
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 &params)
[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;
}
@@ -16,9 +16,8 @@
#include <unistd.h>
#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.");
}
}
}
@@ -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 &params)
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 &params)
[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;
}
@@ -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<Surface> ScreenClientWindowAdapter::CreateWindow(std::shared_ptr<WindowProp
sptr<Rosen::Window> 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);
@@ -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;
@@ -18,10 +18,9 @@
#include <chrono>
#include <securec.h>
#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();
@@ -18,10 +18,9 @@
#include <securec.h>
#include <stddef.h>
#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;
}
@@ -18,11 +18,11 @@
#include <securec.h>
#include <unistd.h>
#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;
}