1/* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15#include <iostream> 16#include <fstream> 17#include <sstream> 18#include <algorithm> 19#include <unistd.h> 20#include <dirent.h> 21#include <cstdio> 22#include <cstdlib> 23#include <climits> 24#include <cctype> 25#include <climits> 26#include <sys/utsname.h> 27#include "sys/time.h" 28#include "securec.h" 29#include "include/sp_utils.h" 30#include "include/sp_log.h" 31#include "include/common.h" 32#include "cpu_collector.h" 33#include "collect_result.h" 34#include "include/FPS.h" 35#include "include/GPU.h" 36#include "include/Power.h" 37#include "include/DDR.h" 38#include "include/profiler_fps.h" 39 40using namespace OHOS::HiviewDFX; 41using namespace OHOS::HiviewDFX::UCollectUtil; 42using namespace OHOS::HiviewDFX::UCollect; 43 44namespace OHOS { 45namespace SmartPerf { 46const unsigned int INT_MAX_LEN = 10; 47const unsigned int CHAR_NUM_DIFF = 48; 48const unsigned int UI_DECIMALISM = 10; 49const unsigned int UI_INDEX_2 = 2; 50bool SPUtils::FileAccess(const std::string &fileName) 51{ 52 return (access(fileName.c_str(), F_OK) == 0); 53} 54bool SPUtils::HasNumber(const std::string &str) 55{ 56 return std::any_of(str.begin(), str.end(), [](char c) { return std::isdigit(c); }); 57} 58bool SPUtils::Cmp(const std::string &a, const std::string &b) 59{ 60 if (HasNumber(a) && HasNumber(b)) { 61 std::string str1 = a.substr(0, a.find_first_of("0123456789")); 62 std::string str2 = b.substr(0, b.find_first_of("0123456789")); 63 if (str1 != str2) { 64 return str1 < str2; 65 } 66 int num1 = std::stoi(a.substr(str1.length())); 67 int num2 = std::stoi(b.substr(str2.length())); 68 return num1 < num2; 69 } 70 return false; 71} 72 73bool SPUtils::LoadFile(const std::string &filePath, std::string &content) 74{ 75 char realPath[PATH_MAX] = {0x00}; 76 if ((realpath(filePath.c_str(), realPath) == nullptr)) { 77 std::cout << "" << std::endl; 78 } 79 std::ifstream file(realPath); 80 if (!file.is_open()) { 81 return false; 82 } 83 84 file.seekg(0, std::ios::end); 85 file.tellg(); 86 87 content.clear(); 88 file.seekg(0, std::ios::beg); 89 copy(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>(), std::back_inserter(content)); 90 // remove '' \n\r 91 ReplaceString(content); 92 return true; 93} 94 95bool SPUtils::LoadCmdWithLinkBreak(const std::string &cmd, bool isClearLinkBreak, std::string &result) 96{ 97 const std::string cmdExc = cmd; 98 FILE *fd = popen(cmdExc.c_str(), "r"); 99 if (fd == nullptr) { 100 return false; 101 } 102 char buf[4096] = {'\0'}; 103 size_t ret = fread(buf, sizeof(buf), 1, fd); 104 if (ret >= 0) { 105 result = buf; 106 } 107 if (pclose(fd) == -1) { 108 std::cout << "" << std::endl; 109 } 110 111 if (isClearLinkBreak) { 112 // remove '' \n\r 113 ReplaceString(result); 114 } 115 116 return ret >= 0 ? true : false; 117} 118 119bool SPUtils::LoadCmd(const std::string &cmd, std::string &result) 120{ 121 return LoadCmdWithLinkBreak(cmd, true, result); 122} 123 124std::string SPUtils::IncludePathDelimiter(const std::string &path) 125{ 126 if (!path.empty() && path.back() != '/') { 127 return path + "/"; 128 } else { 129 return path; 130 } 131} 132 133void SPUtils::ForDirFiles(const std::string &path, std::vector<std::string> &files) 134{ 135 std::string pathStringWithDelimiter; 136 DIR *dir = opendir(path.c_str()); 137 if (dir == nullptr) { 138 return; 139 } 140 141 while (true) { 142 struct dirent *ptr = readdir(dir); 143 if (ptr == nullptr) { 144 break; 145 } 146 147 // current dir OR parent dir 148 if ((strcmp(ptr->d_name, ".") == 0) || (strcmp(ptr->d_name, "..") == 0)) { 149 continue; 150 } else if (ptr->d_type == DT_DIR) { 151 pathStringWithDelimiter = IncludePathDelimiter(path) + std::string(ptr->d_name); 152 ForDirFiles(pathStringWithDelimiter, files); 153 } else { 154 files.push_back(IncludePathDelimiter(path) + std::string(ptr->d_name)); 155 } 156 } 157 closedir(dir); 158} 159 160bool SPUtils::IsSubString(const std::string &str, const std::string &sub) 161{ 162 if (sub.empty() || str.empty()) { 163 return false; 164 } 165 166 return str.find(sub) != std::string::npos; 167} 168 169void SPUtils::StrSplit(const std::string &content, const std::string &sp, std::vector<std::string> &out) 170{ 171 size_t index = 0; 172 while (index != std::string::npos) { 173 size_t tEnd = content.find_first_of(sp, index); 174 std::string tmp = content.substr(index, tEnd - index); 175 if (tmp != "" && tmp != " ") { 176 out.push_back(tmp); 177 } 178 if (tEnd == std::string::npos) { 179 break; 180 } 181 index = tEnd + 1; 182 } 183} 184 185std::string SPUtils::ExtractNumber(const std::string &str) 186{ 187 int cntInt = 0; 188 const int shift = 10; 189 for (int i = 0; str[i] != '\0'; ++i) { 190 if (str[i] >= '0' && str[i] <= '9') { 191 cntInt *= shift; 192 cntInt += str[i] - '0'; 193 } 194 } 195 return std::to_string(cntInt); 196} 197 198void SPUtils::ReplaceString(std::string &res) 199{ 200 std::string flagOne = "\r"; 201 std::string flagTwo = "\n"; 202 std::string::size_type ret = res.find(flagOne); 203 while (ret != res.npos) { 204 res.replace(ret, 1, ""); 205 ret = res.find(flagOne); 206 } 207 ret = res.find(flagTwo); 208 while (ret != res.npos) { 209 res.replace(ret, 1, ""); 210 ret = res.find(flagTwo); 211 } 212} 213 214long long SPUtils::GetCurTime() 215{ 216 struct timeval tv; 217 gettimeofday(&tv, nullptr); 218 long long timestamp = tv.tv_sec * 1000 + tv.tv_usec / 1000; 219 return timestamp; 220} 221 222std::string SPUtils::GetTopPkgName() 223{ 224 std::string cmd = HIDUMPER_CMD_MAP.at(HidumperCmd::DUMPER_HEAD); 225 std::string curTopPkgStr = ""; 226 LoadCmd(cmd, curTopPkgStr); 227 uint64_t left = curTopPkgStr.find_first_of("["); 228 uint64_t right = curTopPkgStr.find_first_of("]"); 229 std::string topPkg = curTopPkgStr.substr(left + 1, static_cast<int64_t>(right) - static_cast<int64_t>(left) - 1); 230 return topPkg; 231} 232 233std::string SPUtils::GetRadar() 234{ 235 std::string cmd = HISYSEVENT_CMD_MAP.at(HisyseventCmd::HISYS_APP_START); 236 std::string curRadar = ""; 237 LoadCmd(cmd, curRadar); 238 return curRadar; 239} 240std::string SPUtils::GetScreen() 241{ 242 std::string cmd = HIDUMPER_CMD_MAP.at(HidumperCmd::DUMPER_SCREEN); 243 std::string screenStr = ""; 244 LoadCmd(cmd, screenStr); 245 uint64_t left = screenStr.find("activeMode"); 246 uint64_t right = screenStr.find("capability"); 247 std::string screen = screenStr.substr(left, right - left); 248 return screen; 249} 250std::string SPUtils::GetRadarFrame() 251{ 252 std::string cmd = HISYSEVENT_CMD_MAP.at(HisyseventCmd::HISYS_JANK); 253 std::string curRadar = ""; 254 LoadCmd(cmd, curRadar); 255 return curRadar; 256} 257std::string SPUtils::GetRadarResponse() 258{ 259 std::string cmd = HISYSEVENT_CMD_MAP.at(HisyseventCmd::HISYS_RESPONSE); 260 std::string curRadar = ""; 261 LoadCmd(cmd, curRadar); 262 return curRadar; 263} 264std::string SPUtils::GetRadarComplete() 265{ 266 std::string cmd = HISYSEVENT_CMD_MAP.at(HisyseventCmd::HISYS_COMPLETED); 267 std::string curRadar = ""; 268 LoadCmd(cmd, curRadar); 269 return curRadar; 270} 271static std::string GetSplitOne(std::string cmd) 272{ 273 std::string result; 274 SPUtils::LoadCmd(cmd, result); 275 return result; 276} 277 278std::string SPUtils::GetDeviceInfoMap() 279{ 280 size_t len = 2; 281 bool isTcpMessage = false; 282 std::map<std::string, std::string> deviceInfoMap; 283 std::map<std::string, std::string> cpuInfo = GetCpuInfo(isTcpMessage); 284 std::map<std::string, std::string> gpuInfo = GetGpuInfo(isTcpMessage); 285 std::map<std::string, std::string> deviceInfo = GetDeviceInfo(); 286 std::string screenInfos = GetScreen(); 287 size_t pos = screenInfos.find(": "); 288 size_t pos1 = screenInfos.find(","); 289 std::string screenSize = screenInfos.substr(pos + len, pos1 - pos - len); 290 deviceInfoMap.insert(cpuInfo.begin(), cpuInfo.end()); 291 deviceInfoMap.insert(gpuInfo.begin(), gpuInfo.end()); 292 deviceInfoMap.insert(deviceInfo.begin(), deviceInfo.end()); 293 deviceInfoMap["activeMode"] = screenSize; 294 if (deviceInfoMap.empty()) { 295 LOGI("Failed to obtain device information"); 296 } 297 for (auto iter = deviceInfoMap.cbegin(); iter != deviceInfoMap.cend(); ++iter) { 298 printf("%s: %s\n", iter->first.c_str(), iter->second.c_str()); 299 } 300 std::cout << "" << std::endl; 301 return std::string("command exec finished!"); 302} 303 304std::map<std::string, std::string> SPUtils::GetDeviceInfo() 305{ 306 std::map<std::string, std::string> resultMap; 307 std::string sn = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::SN)); 308 std::string deviceTypeName = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::DEVICET_NAME)); 309 std::string brand = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::BRAND)); 310 std::string version = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::VERSION)); 311 std::string abilist = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::ABILIST)); 312 std::string name = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::NAME)); 313 std::string model = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::MODEL)); 314 std::string fullname = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::FULL_NAME)); 315 resultMap["sn"] = sn; 316 resultMap["deviceTypeName"] = deviceTypeName; 317 resultMap["brand"] = brand; 318 resultMap["board"] = "hw"; 319 resultMap["version"] = version; 320 resultMap["abilist"] = abilist; 321 resultMap["name"] = name; 322 resultMap["model"] = model; 323 resultMap["fullname"] = fullname; 324 return resultMap; 325} 326std::map<std::string, std::string> SPUtils::GetCpuInfo(bool isTcpMessage) 327{ 328 std::string clusterNames; 329 std::vector<std::string> policyFiles; 330 std::map<std::string, std::string> resultMap; 331 std::string basePath = "/sys/devices/system/cpu/cpufreq/"; 332 DIR *dir = opendir(basePath.c_str()); 333 if (dir == nullptr) { 334 return resultMap; 335 } 336 while (true) { 337 struct dirent *ptr = readdir(dir); 338 if (ptr == nullptr) { 339 break; 340 } 341 if ((strcmp(ptr->d_name, ".") == 0) || (strcmp(ptr->d_name, "..") == 0)) { 342 continue; 343 } 344 std::string clusterName = std::string(ptr->d_name); 345 if (!isTcpMessage) { 346 clusterNames += clusterName + " "; 347 resultMap["cpu_cluster_name"] = clusterNames; 348 } 349 policyFiles.push_back(IncludePathDelimiter(basePath) + clusterName); 350 } 351 closedir(dir); 352 for (size_t i = 0; i < policyFiles.size(); i++) { 353 std::string cpus; 354 LoadFile(policyFiles[i] + "/affected_cpus", cpus); 355 std::string max; 356 LoadFile(policyFiles[i] + "/cpuinfo_max_freq", max); 357 std::string min; 358 LoadFile(policyFiles[i] + "/cpuinfo_min_freq", min); 359 std::string nameBase; 360 if (!isTcpMessage) { 361 nameBase = "cpu_c" + std::to_string(i + 1) + "_"; 362 } else { 363 nameBase = "cpu-c" + std::to_string(i + 1) + "-"; 364 } 365 resultMap[nameBase + "cluster"] = cpus; 366 resultMap[nameBase + "max"] = max; 367 resultMap[nameBase + "min"] = min; 368 } 369 return resultMap; 370} 371std::map<std::string, std::string> SPUtils::GetGpuInfo(bool isTcpMessage) 372{ 373 const std::vector<std::string> gpuCurFreqPaths = { 374 "/sys/class/devfreq/fde60000.gpu/", 375 "/sys/class/devfreq/gpufreq/", 376 }; 377 std::map<std::string, std::string> resultMap; 378 for (auto path : gpuCurFreqPaths) { 379 if (FileAccess(path)) { 380 std::string max; 381 SPUtils::LoadFile(path + "/max_freq", max); 382 std::string min; 383 SPUtils::LoadFile(path + "/min_freq", min); 384 resultMap["gpu_max_freq"] = max; 385 resultMap["gpu_min_freq"] = min; 386 } 387 } 388 return resultMap; 389} 390 391void SPUtils::RemoveSpace(std::string &str) 392{ 393 int len = 0; 394 395 for (size_t i = 0; i < str.length(); i++) { 396 if (str[i] != ' ') { 397 break; 398 } 399 400 ++len; 401 } 402 403 if (len > 0) { 404 str = str.substr(len); 405 } 406 407 len = 0; 408 for (size_t i = str.length(); i > 0; --i) { 409 if (str[i - 1] != ' ') { 410 break; 411 } 412 413 ++len; 414 } 415 416 if (len > 0) { 417 for (int i = 0; i < len; i++) { 418 str.pop_back(); 419 } 420 } 421} 422 423 424bool SPUtils::IntegerVerification(std::string str, std::string errorInfo) 425{ 426 uint64_t dest = 0; 427 bool isValid = false; 428 429 if (str.empty()) { 430 errorInfo = "option requires an argument"; 431 LOGE("sour(%s) error(%s)", str.c_str(), errorInfo.c_str()); 432 return false; 433 } 434 if (str.length() > INT_MAX_LEN) { 435 errorInfo = "invalid option parameters"; 436 LOGE("sour(%s) error(%s)", str.c_str(), errorInfo.c_str()); 437 return false; 438 } 439 440 for (size_t i = 0; i < str.length(); i++) { 441 if (str[i] < '0' || str[i] > '9') { 442 errorInfo = "invalid option parameters"; 443 LOGE("sour(%s) error(%s)", str.c_str(), errorInfo.c_str()); 444 return false; 445 } 446 447 if (!isValid && (str[i] == '0')) { 448 continue; 449 } 450 451 isValid = true; 452 dest *= UI_DECIMALISM; 453 dest += (str[i] - CHAR_NUM_DIFF); 454 } 455 456 if (dest == 0 || dest > INT_MAX) { 457 errorInfo = "option parameter out of range"; 458 LOGE("sour(%s) dest(%u) error(%s)", str.c_str(), dest, errorInfo.c_str()); 459 return false; 460 } 461 462 return true; 463} 464 465bool SPUtils::VeriyParameter(std::set<std::string> &keys, std::string param, std::string &errorInfo) 466{ 467 std::string keyParam; 468 std::string valueParm; 469 std::vector<std::string> out; 470 std::vector<std::string> subOut; 471 std::map<std::string, std::string> mapInfo; 472 473 if (param.empty()) { 474 errorInfo = "The parameter cannot be empty"; 475 return false; 476 } 477 478 SPUtils::StrSplit(param, "-", out); 479 480 for (auto it = out.begin(); it != out.end(); ++it) { // Parsing keys and values 481 subOut.clear(); 482 SPUtils::StrSplit(*it, " ", subOut); 483 if (mapInfo.end() != mapInfo.find(subOut[0])) { 484 errorInfo = "duplicate parameters -- '" + subOut[0] + "'"; 485 return false; 486 } 487 488 if (subOut.size() >= UI_INDEX_2) { 489 keyParam = subOut[0]; 490 valueParm = subOut[1]; 491 SPUtils::RemoveSpace(keyParam); 492 SPUtils::RemoveSpace(valueParm); 493 mapInfo[keyParam] = valueParm; 494 } else if (subOut.size() >= 1) { 495 keyParam = subOut[0]; 496 SPUtils::RemoveSpace(keyParam); 497 mapInfo[keyParam] = ""; 498 } 499 } 500 501 if (!VeriyKey(keys, mapInfo, errorInfo)) { 502 LOGE("%s", errorInfo.c_str()); 503 return false; 504 } 505 506 if (!VerifyValueStr(mapInfo, errorInfo)) { 507 LOGE("%s", errorInfo.c_str()); 508 return false; 509 } 510 511 if (!IntegerValueVerification(keys, mapInfo, errorInfo)) { 512 LOGE("%s", errorInfo.c_str()); 513 return false; 514 } 515 return true; 516} 517 518bool SPUtils::VeriyKey(std::set<std::string> &keys, std::map<std::string, std::string> &mapInfo, 519 std::string &errorInfo) 520{ 521 for (auto it = mapInfo.begin(); it != mapInfo.end(); ++it) { 522 if (keys.end() == keys.find(it->first)) { 523 errorInfo = "invalid parameter -- '" + it->first + "'"; 524 return false; 525 } 526 } 527 528 return true; 529} 530 531bool SPUtils::VerifyValueStr(std::map<std::string, std::string> &mapInfo, std::string &errorInfo) 532{ 533 auto a = mapInfo.find("VIEW"); 534 if (mapInfo.end() != a && a->second.empty()) { // Cannot be null 535 errorInfo += "option requires an argument -- '" + a->first + "'"; 536 return false; 537 } 538 a = mapInfo.find("PKG"); 539 if (mapInfo.end() != a && a->second.empty()) { // Cannot be null 540 errorInfo += "option requires an argument -- '" + a->first + "'"; 541 return false; 542 } 543 a = mapInfo.find("OUT"); 544 if (mapInfo.end() != a) { 545 if (a->second.empty()) { 546 errorInfo += "option requires an argument -- '" + a->first + "'"; 547 return false; 548 } 549 // The total length of file path and name cannot exceed PATH_MAX 550 if (a->second.length() >= PATH_MAX) { 551 errorInfo += 552 "invalid parameter, file path cannot exceed " + std::to_string(PATH_MAX) + " -- '" + a->first + "'"; 553 return false; 554 } 555 size_t pos = a->second.rfind('/'); 556 if (pos == a->second.length()) { // not file name 557 errorInfo += "invalid parameter,not file name -- '" + a->first + "'"; 558 return false; 559 } 560 if (std::string::npos != pos && 561 (!SPUtils::FileAccess(a->second.substr(0, pos)))) { // determine if the directory exists 562 errorInfo += "invalid parameter,file path not found -- '" + a->first + "'"; 563 return false; 564 } 565 std::string outStr = a->second; 566 std::vector<std::string> outList; 567 SPUtils::StrSplit(outStr, "/", outList); 568 for (auto it = outList.begin(); outList.end() != it; ++it) { 569 if ((*it).length() >= NAME_MAX) { 570 errorInfo += "invalid parameter, file directory or name cannot exceed 255 -- '" + a->first + "'"; 571 return false; 572 } 573 } 574 } 575 return true; 576} 577 578bool SPUtils::IntegerValueVerification(std::set<std::string> &keys, std::map<std::string, std::string> &mapInfo, 579 std::string &errorInfo) 580{ 581 std::vector<std::string> integerCheck; // Number of integers to be detected 582 583 if (keys.end() != keys.find("N")) { 584 integerCheck.push_back("N"); 585 } 586 if (keys.end() != keys.find("fl")) { 587 integerCheck.push_back("fl"); 588 } 589 if (keys.end() != keys.find("ftl")) { 590 integerCheck.push_back("ftl"); 591 } 592 593 for (auto it = integerCheck.begin(); it != integerCheck.end(); ++it) { 594 auto a = mapInfo.find(*it); 595 if (mapInfo.end() != a) { 596 if (a->second.empty()) { 597 errorInfo += "option requires an argument -- '" + a->first + "'"; 598 return false; 599 } 600 if (!SPUtils::IntegerVerification(a->second, errorInfo)) { 601 errorInfo += "option parameter out of range -- '" + a->first + "'"; 602 return false; 603 } 604 } 605 } 606 607 return true; 608} 609 610bool SPUtils::IsHmKernel() 611{ 612 bool isHM = false; 613 utsname unameBuf; 614 if ((uname(&unameBuf)) == 0) { 615 std::string osRelease = unameBuf.release; 616 isHM = osRelease.find("HongMeng") != std::string::npos; 617 } 618 return isHM; 619} 620 621std::string SPUtils::GetCpuNum() 622{ 623 std::string cpuCores = "cpuCores||"; 624 std::shared_ptr<CpuCollector> collector = CpuCollector::Create(); 625 CollectResult<std::vector<CpuFreq>> result = collector->CollectCpuFrequency(); 626 std::vector<CpuFreq> &cpufreq = result.data; 627 size_t cpuNum = cpufreq.size(); 628 cpuCores += std::to_string(cpuNum); 629 if (cpuNum == 0) { 630 std::cout << "CPU frequency collection failed." << std::endl; 631 LOGI("CPU frequency collection failed."); 632 } 633 return cpuCores; 634} 635void SPUtils::GetCurrentTime(int num, int prevTime) 636{ 637 unsigned long sleepNowTime = 10000; 638 for (int i = 0; i < num; i++) { 639 struct timespec time1 = { 0 }; 640 clock_gettime(CLOCK_MONOTONIC, &time1); 641 int curTimeNow = static_cast<int>(time1.tv_sec - 1); 642 if (curTimeNow == prevTime) { 643 usleep(sleepNowTime); 644 } else { 645 break; 646 } 647 } 648} 649bool SPUtils::IsForeGround(std::string &pkg) 650{ 651 bool isFoundAppName = false; 652 bool isFoundBundleName = false; 653 const std::string cmd = "aa dump -l"; 654 char buf[1024] = {'\0'}; 655 std::string appLine = "app name [" + pkg; 656 std::string bundleLine = "bundle name [" + pkg; 657 FILE *fd = popen(cmd.c_str(), "r"); 658 if (fd == nullptr) { 659 return false; 660 } 661 bool tag = false; 662 while (fgets(buf, sizeof(buf), fd) != nullptr) { 663 std::string line = buf; 664 if (line.find(appLine) != std::string::npos) { 665 isFoundAppName = true; 666 } 667 if (line.find(bundleLine) != std::string::npos) { 668 isFoundBundleName = true; 669 } 670 if (isFoundAppName || isFoundBundleName) { 671 if (line.find("app state") != std::string::npos) { 672 tag = IsFindForeGround(line); 673 isFoundAppName = false; 674 isFoundBundleName = false; 675 } 676 } 677 } 678 pclose(fd); 679 return tag; 680} 681bool SPUtils::IsFindForeGround(std::string line) 682{ 683 std::string foreGroundTag = line.substr(line.find("#") + 1); 684 if (foreGroundTag.find("FOREGROUND") != std::string::npos) { 685 return true; 686 } else { 687 return false; 688 } 689} 690bool SPUtils::IsFindAbilist() 691{ 692 std::string abilist = GetSplitOne(DEVICE_CMD_MAP.at(DeviceCmd::ABILIST)); 693 if (abilist.find("arm") != std::string::npos) { 694 return true; 695 } else { 696 return false; 697 } 698} 699void SPUtils::SetRkFlag() 700{ 701 bool FindAbilistResult = IsFindAbilist(); 702 if (!FindAbilistResult) { 703 OHOS::SmartPerf::FPS::GetInstance().SetRkFlag(); 704 OHOS::SmartPerf::Power::GetInstance().SetRkFlag(); 705 OHOS::SmartPerf::GPU::GetInstance().SetRkFlag(); 706 OHOS::SmartPerf::ProfilerFPS::GetInstance().SetRkFlag(); 707 OHOS::SmartPerf::DDR::GetInstance().SetRkFlag(); 708 } 709} 710} 711} 712