1 /* 2 * Copyright (c) 2025 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 #ifndef OHOS_ABILITY_RUNTIME_APPFREEZE_UTIL_H 16 #define OHOS_ABILITY_RUNTIME_APPFREEZE_UTIL_H 17 18 #include <sys/types.h> 19 #include <string> 20 21 namespace OHOS { 22 namespace AppExecFwk { 23 class AppfreezeUtil { 24 public: 25 static constexpr const char* const PROC_STAT_PATH = "/proc/stat"; 26 static constexpr const char* const LOG_FILE_PATH = "/data/log/eventlog/freeze"; 27 static constexpr const char* const EVENTLOG_PATH = "/data/log/eventlog"; 28 static constexpr int64_t SEC_TO_MILLISEC = 1000; 29 static constexpr int32_t CPU_COUNT_SUBTRACT = 1; 30 AppfreezeUtil(); 31 ~AppfreezeUtil(); 32 33 static std::string CreateFile(const std::string& dirPath, const std::string& fileName); 34 static std::string TimestampFormatToDate(time_t timeStamp, const std::string& format); 35 static uint64_t GetMilliseconds(); 36 static std::string RoundToTwoDecimals(float value); 37 static int GetCpuCount(); 38 }; 39 } // namespace AppExecFwk 40 } // namespace OHOS 41 #endif // OHOS_ABILITY_RUNTIME_APPFREEZE_UTIL_H 42