|
|
|
@@ -34,9 +34,6 @@
|
|
|
|
|
#include "parameters.h"
|
|
|
|
|
#include "singleton.h"
|
|
|
|
|
|
|
|
|
|
#ifdef SOC_PERF_ENABLE
|
|
|
|
|
#include "socperf_client.h"
|
|
|
|
|
#endif
|
|
|
|
|
#include "app_mgr_client.h"
|
|
|
|
|
#include "hilog_tag_wrapper.h"
|
|
|
|
|
#include "time_util.h"
|
|
|
|
@@ -73,16 +70,6 @@ static bool g_betaVersion = OHOS::system::GetParameter("const.logsystem.versiont
|
|
|
|
|
static bool g_developMode = (OHOS::system::GetParameter("persist.hiview.leak_detector", "unknown") == "enable") ||
|
|
|
|
|
(OHOS::system::GetParameter("persist.hiview.leak_detector", "unknown") == "true");
|
|
|
|
|
}
|
|
|
|
|
static constexpr const char *const TWELVE_BIG_CPU_CUR_FREQ = "/sys/devices/system/cpu/cpufreq/policy2/scaling_cur_freq";
|
|
|
|
|
static constexpr const char *const TWELVE_BIG_CPU_MAX_FREQ = "/sys/devices/system/cpu/cpufreq/policy2/scaling_max_freq";
|
|
|
|
|
static constexpr const char *const TWELVE_MID_CPU_CUR_FREQ = "/sys/devices/system/cpu/cpufreq/policy1/scaling_cur_freq";
|
|
|
|
|
static constexpr const char *const TWELVE_MID_CPU_MAX_FREQ = "/sys/devices/system/cpu/cpufreq/policy1/scaling_max_freq";
|
|
|
|
|
static constexpr const char *const TWELVE_LIT_CPU_CUR_FREQ = "/sys/devices/system/cpu/cpufreq/policy0/scaling_cur_freq";
|
|
|
|
|
static constexpr const char *const TWELVE_LIT_CPU_MAX_FREQ = "/sys/devices/system/cpu/cpufreq/policy0/scaling_max_freq";
|
|
|
|
|
const static std::set<std::string> HALF_EVENT_CONFIGS = {"UI_BLOCK_3S", "THREAD_BLOCK_3S", "BUSSNESS_THREAD_BLOCK_3S",
|
|
|
|
|
"LIFECYCLE_HALF_TIMEOUT"};
|
|
|
|
|
static constexpr int PERF_TIME = 60000;
|
|
|
|
|
static constexpr int PERF_NUM = 10202;
|
|
|
|
|
std::shared_ptr<AppfreezeManager> AppfreezeManager::instance_ = nullptr;
|
|
|
|
|
ffrt::mutex AppfreezeManager::singletonMutex_;
|
|
|
|
|
ffrt::mutex AppfreezeManager::freezeMutex_;
|
|
|
|
@@ -346,7 +333,6 @@ int AppfreezeManager::NotifyANR(const FaultData& faultData, const AppfreezeManag
|
|
|
|
|
DelayedSingleton<AppExecFwk::AppMgrClient>::GetInstance()->GetAppRunningUniqueIdByPid(appInfo.pid,
|
|
|
|
|
appRunningUniqueId);
|
|
|
|
|
int ret = 0;
|
|
|
|
|
this->PerfStart(faultData.errorObject.name);
|
|
|
|
|
int64_t startTime = AbilityRuntime::TimeUtil::CurrentTimeMillis();
|
|
|
|
|
if (faultData.errorObject.name == AppFreezeType::APP_INPUT_BLOCK) {
|
|
|
|
|
ret = HiSysEventWrite(OHOS::HiviewDFX::HiSysEvent::Domain::AAFWK, faultData.errorObject.name,
|
|
|
|
@@ -758,47 +744,5 @@ bool AppfreezeManager::IsValidFreezeFilter(int32_t pid, const std::string& bundl
|
|
|
|
|
"pid:%{public}d", ret, bundleName.c_str(), pid);
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
void AppfreezeManager::PerfStart(std::string eventName)
|
|
|
|
|
{
|
|
|
|
|
const int buffSize = 128;
|
|
|
|
|
char paramOutBuff[buffSize] = {0};
|
|
|
|
|
GetParameter("const.dfx.sub_health_recovery.enable", "", paramOutBuff, buffSize - 1);
|
|
|
|
|
std::string str(paramOutBuff);
|
|
|
|
|
if (str != "true") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
auto it = HALF_EVENT_CONFIGS.find(eventName);
|
|
|
|
|
if (it == HALF_EVENT_CONFIGS.end()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
auto curTime = AbilityRuntime::TimeUtil::SystemTimeMillisecond();
|
|
|
|
|
if (curTime - perfTime < PERF_TIME) {
|
|
|
|
|
TAG_LOGI(AAFwkTag::APPDFR, "perf time is less than 60s");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
std::string bigCpuCurFreq = this->GetFirstLine(TWELVE_BIG_CPU_CUR_FREQ);
|
|
|
|
|
std::string bigCpuMaxFreq = this->GetFirstLine(TWELVE_BIG_CPU_MAX_FREQ);
|
|
|
|
|
std::string midCpuCurFreq = this->GetFirstLine(TWELVE_MID_CPU_CUR_FREQ);
|
|
|
|
|
std::string midCpuMaxFreq = this->GetFirstLine(TWELVE_MID_CPU_MAX_FREQ);
|
|
|
|
|
if (bigCpuCurFreq == bigCpuMaxFreq || midCpuCurFreq == midCpuMaxFreq) {
|
|
|
|
|
perfTime = curTime;
|
|
|
|
|
TAG_LOGI(AAFwkTag::APPDFR, "perf start");
|
|
|
|
|
#ifdef SOC_PERF_ENABLE
|
|
|
|
|
OHOS::SOCPERF::SocPerfClient::GetInstance().PerfRequest(PERF_NUM, "");
|
|
|
|
|
#endif
|
|
|
|
|
TAG_LOGI(AAFwkTag::APPDFR, "perf end");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
std::string AppfreezeManager::GetFirstLine(const std::string &path)
|
|
|
|
|
{
|
|
|
|
|
std::ifstream inFile(path.c_str());
|
|
|
|
|
if (!inFile) {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
std::string firstLine;
|
|
|
|
|
getline(inFile, firstLine);
|
|
|
|
|
inFile.close();
|
|
|
|
|
return firstLine;
|
|
|
|
|
}
|
|
|
|
|
} // namespace AAFwk
|
|
|
|
|
} // namespace OHOS
|