You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.9 KiB

/*
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2022-2022. All rights reserved.
* Description: Support private hwgraphics hidl interface
* Author: Hisilicon
* Created: 2022.11.10
*/
#include "HwgraphicsDft.h"
#include <utils/Log.h>
#include "dft_event.h"
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
using namespace dft;
volatile int g_screencapInject = 0;
__attribute__((optnone)) void ScreencapInjectFault()
{
g_screencapInject = 1;
}
__attribute__((optnone)) void ScreencapUnInjectFault()
{
g_screencapInject = 0;
}
volatile int g_screenRecordInject = 0;
__attribute__((optnone)) void ScreenRecordInjectFault()
{
g_screenRecordInject = 1;
}
__attribute__((optnone)) void ScreenRecordUnInjectFault()
{
g_screenRecordInject = 0;
}
volatile int g_overlayInject = 0;
__attribute__((optnone)) void OverlayInjectFault()
{
g_overlayInject = 1;
}
__attribute__((optnone)) void OverlayUnInjectFault()
{
g_overlayInject = 0;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
HwgraphicsDft* HwgraphicsDft::instance;
HwgraphicsDft::~HwgraphicsDft()
{
if (instance != nullptr) {
delete instance;
instance = nullptr;
}
}
HwgraphicsDft* HwgraphicsDft::GetInstance()
{
if (instance == nullptr) {
instance = new HwgraphicsDft();
}
return instance;
}
void HwgraphicsDft::ReportFaultIfNecessary(bool execReport, int eventId, FaultInfo& info)
{
bool ignoreReport = !execReport && (GetInjectValue(eventId) != 1);
if (ignoreReport) {
return;
}
unsigned int handle;
ALOGI("reportFault partion: hwgraphic, function: %s", info.funName.c_str());
int retValue = dft_event_create(eventId, &handle);
if (retValue == SUCCESS) {
dft_event_put_string(handle, "PNAME", "hwgraphic");
dft_event_put_string(handle, "F1NAME", info.funName.c_str());
dft_event_put_string(handle, "P1NAME", info.fParamName.c_str());
dft_event_put_integral(handle, "P1VALUE", info.fParamValue);
dft_event_put_string(handle, "P2NAME", info.sParamName.c_str());
dft_event_put_integral(handle, "P2VALUE", info.sParamValue);
dft_event_report(handle);
dft_event_destroy(handle);
ALOGI("reportFault success, partion: hwgraphic, function: %s", info.funName.c_str());
} else {
ALOGE("reportFault create fail, function:%s retValue:%d", info.funName.c_str(), retValue);
}
return;
}
int HwgraphicsDft::GetInjectValue(int eventId)
{
switch (eventId) {
case SCREENCAP_FAIL:
return g_screencapInject;
case SCREENRECORD_FAIL:
return g_screenRecordInject;
case OVERLAYPLAY_FAIL:
return g_overlayInject;
default:
ALOGW("event id is invalidated eventId:%d", eventId);
return 0;
}
}