From 4634606a36771afc1e4cfcb0604f99f8b37ee9b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Thu, 27 Oct 2022 22:31:57 +0800 Subject: [PATCH] CpuUsage: clearify the restriction on Android --- src/detection/cpuUsage/cpuUsage_linux.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/detection/cpuUsage/cpuUsage_linux.c b/src/detection/cpuUsage/cpuUsage_linux.c index 8667fd526..1888b2b13 100644 --- a/src/detection/cpuUsage/cpuUsage_linux.c +++ b/src/detection/cpuUsage/cpuUsage_linux.c @@ -10,7 +10,13 @@ const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll) FILE* procStat = fopen("/proc/stat", "r"); if(procStat == NULL) + { + #ifdef __ANDROID__ + return "Accessing \"/proc/stat\" is restricted on Android O+"; + #else return "fopen(\"""/proc/stat\", \"r\") == NULL"; + #endif + } if (fscanf(procStat, "cpu%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64 "%" PRIu64, &user, &nice, &system, &idle, &iowait, &irq, &softirq) < 0) {