Signed-off-by: weishaoxiong <weishaoxiong1@huawei.com>

feat:dfx
This commit is contained in:
weishaoxiong 2022-07-01 10:33:24 +08:00
parent 5d31b03f06
commit f289dbab81
4 changed files with 23 additions and 9 deletions

View File

@ -43,14 +43,11 @@ SERVICE_FAULT:
__BASE: {type: FAULT, level: CRITICAL, desc: The event is service fault }
FAULT_TYPE: {type: STRING, desc: fault id }
MODULE_NAME: {type: STRING, desc: module name }
USER_ID: {type: STRING, desc: store id }
ERROR_TYPE: {type: INT32, desc: error type }
RUNTIME_FAULT:
__BASE: {type: FAULT, level: CRITICAL, desc: The event is runtime fault }
FAULT_TYPE: {type: STRING, desc: fault id }
MODULE_NAME: {type: STRING, desc: module name }
USER_ID: {type: STRING, desc: store id }
ERROR_TYPE: {type: INT32, desc: error type }
USAGETIME_STATISTIC:

View File

@ -73,6 +73,7 @@ ohos_shared_library("wallpaper_service") {
"${aafwk_services_path}/abilitymgr:abilityms",
"${utils_path}:wallpaper_utils",
"//base/hiviewdfx/hiview/adapter/utility:hiview_adapter_utility",
"//foundation/bundlemanager/bundle_framework/interfaces/inner_api/appexecfwk_core:appexecfwk_core",
"//foundation/graphic/graphic_2d/frameworks/surface:surface",
"//foundation/graphic/graphic_2d/rosen/modules/2d_graphics:2d_graphics",
"//foundation/graphic/graphic_2d/rosen/modules/render_service_client:librender_service_client",

View File

@ -22,12 +22,12 @@ constexpr const char *SERVICE_FAULT = "SERVICE_FAULT";
constexpr const char *RUNTIME_FAULT = "RUNTIME_FAULT";
constexpr const char *FAULT_TYPE = "FAULT_TYPE";
constexpr const char *MODULE_NAME = "MODULE_NAME";
constexpr const char *ERROR_REASON = "ERROR_REASON";
constexpr const char *ERROR_TYPE = "ERROR_TYPE";
ReportStatus FaultReporter::ReportServiceFault(const FaultMsg &msg)
{
int nRet = HiSysEvent::Write(HiSysEvent::Domain::MISC_WALLPAPER, SERVICE_FAULT, HiSysEvent::EventType::FAULT,
FAULT_TYPE, static_cast<int>(msg.faultType), MODULE_NAME, msg.moduleName, ERROR_REASON,
FAULT_TYPE, static_cast<int>(msg.faultType), MODULE_NAME, msg.moduleName, ERROR_TYPE,
static_cast<int>(msg.errorCode));
return nRet == 0 ? ReportStatus::SUCCESS : ReportStatus::ERROR;
}
@ -35,7 +35,7 @@ ReportStatus FaultReporter::ReportServiceFault(const FaultMsg &msg)
ReportStatus FaultReporter::ReportRuntimeFault(const FaultMsg &msg)
{
int nRet = HiSysEvent::Write(HiSysEvent::Domain::MISC_WALLPAPER, RUNTIME_FAULT, HiSysEvent::EventType::FAULT,
FAULT_TYPE, static_cast<int>(msg.faultType), ERROR_REASON, static_cast<int>(msg.errorCode));
FAULT_TYPE, static_cast<int>(msg.faultType), ERROR_TYPE, static_cast<int>(msg.errorCode));
return nRet == 0 ? ReportStatus::SUCCESS : ReportStatus::ERROR;
}
} // namespace MiscServices

View File

@ -52,6 +52,7 @@
#include "reporter.h"
#include "dfx_types.h"
#include "dump_helper.h"
#include "bundle_mgr_proxy.h"
#include "wallpaper_service.h"
namespace OHOS {
@ -616,8 +617,13 @@ bool WallpaperService::SetWallpaperBackupData(std::string uriOrPixelMap, int wal
void WallpaperService::ReporterUsageTimeStatisic()
{
int userId = static_cast<int>(IPCSkeleton::GetCallingUid());
std::string bundleName;
bool bRet = WPGetBundleNameByUid(userId, bundleName);
if (!bRet){
bundleName = WALLPAPER_BUNDLE_NAME;
}
UsageTimeStat timeStat;
timeStat.packagesName = WALLPAPER_BUNDLE_NAME;
timeStat.packagesName = bundleName;
timeStat.startTime = time(nullptr);
Reporter::GetInstance().UsageTimeStatistic().ReportUsageTimeStatistic(userId, timeStat);
}
@ -1001,7 +1007,13 @@ void WallpaperService::WallpaperDump(int fd)
dprintf(fd, " * heigh = %d\n", height);
int32_t width = GetWallpaperMinWidth();
dprintf(fd, " * heigh = %d\n", width);
dprintf(fd, " * WallpaperExtension = ExtensionInfo{%s}\n", WALLPAPER_BUNDLE_NAME.c_str());
int uid = static_cast<int>(IPCSkeleton::GetCallingUid());
std::string bundleName;
bool bRet = WPGetBundleNameByUid(uid, bundleName);
if (!bRet){
bundleName = WALLPAPER_BUNDLE_NAME;
}
dprintf(fd, " * WallpaperExtension = ExtensionInfo{%s}\n", bundleName.c_str());
}
void WallpaperService::ReporterFault(FaultType faultType, FaultCode faultCode)
@ -1029,7 +1041,11 @@ int WallpaperService::Dump(int fd, const std::vector<std::u16string> &args)
int uid = static_cast<int>(IPCSkeleton::GetCallingUid());
const int maxUid = 10000;
if (uid > maxUid) {
return 0;
Security::AccessToken::AccessTokenID callerToken = IPCSkeleton::GetCallingTokenID();
if (Security::AccessToken::AccessTokenKit::GetTokenTypeFlag(callerToken)
!= Security::AccessToken::TOKEN_NATIVE) {
return 1;
}
}
std::vector<std::string> argsStr;