judge developer mode

Change-Id: Iaa718d298322053c47a2311b0506b7a296dc4b78
Signed-off-by: leiguangyu <leiguangyu@huawei.com>
This commit is contained in:
leiguangyu 2024-08-27 16:08:03 +08:00
parent 3784c605bf
commit fb2085d678
3 changed files with 17 additions and 0 deletions

View File

@ -336,6 +336,7 @@ void CollectPidsByAppname(std::set<pid_t> &pids, const std::string &appPackage);
bool CheckAppIsRunning (std::vector<pid_t> &selectPids, const std::string &appPackage, int checkAppMs);
bool IsSupportNonDebuggableApp();
const std::string GetUserType();
bool GetDeveloperMode();
bool IsArkJsFile(const std::string& filepath);
std::string GetProcessName(int pid);
bool NeedAdaptSandboxPath(char *filename, int pid, u16 &headerSize);

View File

@ -42,6 +42,11 @@ using namespace OHOS::Developtools::HiPerf;
int main(const int argc, const char *argv[])
{
if (!GetDeveloperMode()) {
printf("error: not in developermode, exit");
return -1;
}
if (argc < 0 || argc > 128) { // 128 : max input argument counts
printf("The number of input arguments exceeds the upper limit.\n");
return -1;

View File

@ -674,6 +674,17 @@ const std::string GetUserType()
#endif
}
bool GetDeveloperMode()
{
#if defined(is_ohos) && is_ohos
bool developerMode = OHOS::system::GetBoolParameter("const.security.developermode.state", true);
HLOGD("GetDeveloperMode: developerMode is %d", developerMode);
return developerMode;
#else
return true;
#endif
}
bool LittleMemory()
{
std::ifstream file("/proc/meminfo");