修改截图

Signed-off-by: wwx1285007 <wanglu234@huawei.com>
This commit is contained in:
wwx1285007 2024-06-21 15:13:42 +08:00
parent 1ac41cbe32
commit 56edbb8a9d
10 changed files with 25 additions and 27 deletions

View File

@ -82,6 +82,9 @@ void Capture::ThreadGetCatch(const std::string &curTime) const
void Capture::ThreadGetCatchSocket(const std::string &curTime) const
{
if (curTime.empty()) {
return;
}
auto savePath = "/data/local/tmp/capture/screenCap_" + curTime + ".jpeg";
std::string cmdResult;
if (!SPUtils::FileAccess("/data/local/tmp/capture")) {
@ -89,12 +92,12 @@ void Capture::ThreadGetCatchSocket(const std::string &curTime) const
printf("/data/local/tmp/capture created! \n");
LOGI("/data/local/tmp/capture created!");
};
char resolvedPath[PATH_MAX] = {0x00};
if (realpath(savePath.c_str(), resolvedPath) == nullptr) {
std::cout << "Error: Unable to get resolved path." << std::endl;
if (SPUtils::FileAccess(savePath)) {
std::cout << "" << std::endl;
return;
}
auto fd = open(resolvedPath, O_RDWR | O_CREAT, 0644);
auto fd = open(savePath.c_str(), O_RDWR | O_CREAT, 0644);
SPUtils::LoadCmd("snapshot_display -f " + savePath, cmdResult);
(void)close(fd);
}

View File

@ -13,8 +13,6 @@
* limitations under the License.
*/
#include <iostream>
#include <sstream>
#include <iomanip>
#include "include/sp_utils.h"
#include "include/Power.h"
#include "include/sp_log.h"
@ -24,17 +22,7 @@ std::map<std::string, std::string> Power::ItemData()
{
std::map<std::string, std::string> result;
std::string currentNow;
double avgCurrent = 0.0;
SPUtils::LoadFile(currentNowPath, curAvgCurrent);
const double number = 3.6;
if (lastAvgCurrent != "0") {
int diffAvgCurrent = std::stoi(curAvgCurrent) - std::stoi(lastAvgCurrent);
avgCurrent = diffAvgCurrent * number;
}
std::stringstream ss;
ss << std::fixed << std::setprecision(1) << avgCurrent;
currentNow = ss.str();
lastAvgCurrent = curAvgCurrent;
SPUtils::LoadFile(currentNowPath, currentNow);
std::string voltageNow;
SPUtils::LoadFile(voltageNowPath, voltageNow);
result["currentNow"] = currentNow;

View File

@ -31,10 +31,8 @@ private:
Power() {};
Power(const Power &);
Power &operator = (const Power &);
const std::string currentNowPath = "/sys/class/power_supply/Battery/charge_counter";
const std::string currentNowPath = "/sys/class/power_supply/Battery/current_now";
const std::string voltageNowPath = "/sys/class/power_supply/Battery/voltage_now";
std::string curAvgCurrent;
std::string lastAvgCurrent = "0";
};
}
}

View File

@ -67,7 +67,7 @@ public:
void HelpCommand(CommandHelp type) const;
void HandleCommand(std::string argStr, const std::string &argStr1);
int GetItemInfo(std::multimap<std::string, std::string, decltype(SPUtils::Cmp) *> &spMap);
void printfExecCommand(const std::map<std::string, std::string> data);
void PrintfExecCommand(const std::map<std::string, std::string> data) const;
// 采集次数
int num = 0;
// 包名

View File

@ -183,6 +183,7 @@ void ProfilerFPS::PrintSections(int msCount, long long currTimeLast,
}
long long timeN = (currTimeLast - currTimeStart) / conversionTime;
if (timeN == 0) {
printf("sectionsFps:%d|%lld\n", 0, currLastTime);
return;
}
long long fpsSections = (fpsNums * conversionFps) / timeN;
@ -237,7 +238,7 @@ void ProfilerFPS::GetSectionsFps(FpsInfoProfiler &fpsInfoResult, int nums) const
PrintSections(msCount, currTimeLast, currTimeStart, currLastTime);
currTimeLast = currTime;
printCount++;
GetSectionsPrint(printCount, currLastTime, nums, msJiange);
GetSectionsPrint(printCount, currLastTime, nums, harTime);
}
count++;
}

View File

@ -211,16 +211,18 @@ std::string SmartPerfCommand::ExecCommand()
}
if (callGpuCounterResult) {
const std::map<std::string, std::string> data = GpuCounter::GetInstance().ItemData();
printfExecCommand(data);
PrintfExecCommand(data);
SPData spdata;
spdata.values.insert(data.begin(), data.end());
vmap.push_back(spdata);
}
std::this_thread::sleep_for(std::chrono::milliseconds(freq));
LOGI("SmartPerfCommand::WriteCsv start");
SpCsvUtil::WriteCsv(std::string(outPath.c_str()), vmap);
LOGI("SmartPerfCommand::WriteCsv finish");
return std::string("command exec finished!");
}
void SmartPerfCommand::printfExecCommand(const std::map<std::string, std::string> data)
void SmartPerfCommand::PrintfExecCommand(const std::map<std::string, std::string> data) const;
{
int i = 0;
for (auto a = data.cbegin(); a != data.cend(); ++a) {

View File

@ -228,6 +228,9 @@ ErrCode SPTask::StartTask(std::function<void(std::string data)> msgTask)
std::this_thread::sleep_for(std::chrono::milliseconds(curTaskInfo.freq - costTime));
}
}
if (!isRunning) {
vmap.clear();
}
});
LOGI("SPTask::StartTask complete");
return ErrCode::OK;

View File

@ -587,7 +587,7 @@ bool SPUtils::IsHmKernel()
utsname unameBuf;
if ((uname(&unameBuf)) == 0) {
std::string osRelease = unameBuf.release;
isHM = osRelease.find("hmkernel") != std::string::npos;
isHM = osRelease.find("HongMeng") != std::string::npos;
}
return isHM;
}

View File

@ -91,7 +91,10 @@ void StallingRateTrace::AppList(std::string line, const std::string &signS, cons
if (line.find("H:LAUNCHER_APP_LAUNCH_FROM_ICON,") != std::string::npos ||
line.find("H:APP_LIST_FLING,") != std::string::npos ||
line.find("H:WEB_LIST_FLING") != std::string::npos ||
line.find("H:ABILITY_OR_PAGE_SWITCH,") != std::string::npos) {
line.find("H:ABILITY_OR_PAGE_SWITCH,") != std::string::npos ||
line.find("H:APP_TRANSITION_TO_OTHER_APP,") != std::string::npos ||
line.find("H:LUNCHER_APP_LUNCH_FORH_DOCK,") != std::string::npos ||
line.find("H:LUNCHER_APP_LUNCH_FORM_APPCENTER,") != std::string::npos) {
if (animalFlag) {
dynamicFinishTime = GetTimes(line, signF);
LOGI("dynamicFinishTime=====: %s", std::to_string(dynamicFinishTime).c_str());

View File

@ -34,7 +34,7 @@ void StartUpDelay::GetTrace(const std::string &sessionID, const std::string &tra
if (SPUtils::IsHmKernel()) {
cmdString = "hitrace --trace_clock mono -t 5 -b 102400 --overwrite idle ace app ohos ability graphic nweb ";
} else {
cmdString = "hitrace --trace_clock mono -t 5 -b 20480 --overwrite idle ace app ohos ability graphic nweb ";
cmdString = "hitrace --trace_clock mono -t 5 -b 204800 --overwrite idle ace app ohos ability graphic nweb ";
}
std::string cmdStringEnd { "sched freq sync workq multimodalinput > " };
SPUtils::LoadCmd(cmdString + cmdStringEnd + traceName, result);