!1287 添加beta版本校验

Merge pull request !1287 from 卢韬/master
This commit is contained in:
openharmony_ci 2024-01-02 08:46:37 +00:00 committed by Gitee
commit 23b1f9b4be
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 21 additions and 0 deletions

View File

@ -80,6 +80,7 @@ ohos_source_set("hiprofiler_base") {
"bundle_framework:appexecfwk_base",
"bundle_framework:appexecfwk_core",
"c_utils:utils",
"init:libbegetutil",
"ipc:ipc_core",
"os_account:os_account_innerkits",
"samgr:samgr_proxy",

View File

@ -46,5 +46,6 @@ std::string GetClockStr(const int32_t clockId);
void AdaptSandboxPath(std::string& filePath, int pid);
int32_t GetPackageUid(const std::string &name);
bool GetCurrentUserId(int32_t &userId);
bool IsBetaVersion();
} // COMMON
#endif // COMMON_H

View File

@ -21,6 +21,8 @@
#include <dirent.h>
#include <fstream>
#include <iostream>
#include <parameter.h>
#include <parameters.h>
#include <sstream>
#include <sys/file.h>
#include <sys/types.h>
@ -64,6 +66,7 @@ const int FILE_PATH_SIZE = 512;
const int BUFFER_SIZE = 1024;
const int INVALID_PID = -1;
constexpr int32_t EC_INVALID_VALUE = -2;
const std::string KEY_HIVIEW_USER_TYPE = "const.logsystem.versiontype";
}
bool IsProcessRunning(int& lockFileFd)
@ -564,4 +567,16 @@ int32_t GetPackageUid(const std::string& name)
HILOG_INFO(LOG_CORE, "pkgname is: %s, uid is : %d", name.c_str(), uid);
return uid;
}
bool IsBetaVersion()
{
int ret = static_cast<int>(FindParameter(KEY_HIVIEW_USER_TYPE.c_str()));
if (ret == -1) {
HILOG_INFO(LOG_CORE, "user type is not exist");
return true;
}
std::string userType = OHOS::system::GetParameter(KEY_HIVIEW_USER_TYPE, "");
HILOG_INFO(LOG_CORE, "user type is:%s", userType.c_str());
return userType == "beta";
}
} // namespace COMMON

View File

@ -235,6 +235,10 @@ int main(int argc, char* argv[])
}
if (argc > 1) {
if (!COMMON::IsBetaVersion()) {
printf("memory profiler only support in beta version\n");
return 0;
}
if (argc == 2 && strcmp(argv[1], "sa") == 0) {
if (!OHOS::Developtools::NativeDaemon::NativeMemoryProfilerSaService::StartServiceAbility()) {
return 0;