12

I'm really confused. I have just noticed that starting from Android 8 all system calls like /proc/stat will be disabled. Ok, but what is work around to get CPU Usage in Android 8? No system calls at all. Is there some API that I'm not familiar with?

I really hope that there is solution which I can't see now.

2 Answers 2

8

No, all of /proc/stat has been disabled for non-System apps, as a side-channel.

More information, with an official response from Google here: https://issuetracker.google.com/issues/37140047

6
  • Thanks for info. It seems that root users will be more and more with each Android version ;) Sep 15, 2017 at 6:52
  • 6
    seriously @Google, you just keep giving me more reasons to not upgrade.
    – Michael
    Sep 26, 2017 at 18:43
  • 1
    Process p = Runtime.getRunime().exec("su"). If user gives you access to SU, then connec to steams (p.getOutputstream(), p.getInputStream()) and start executing commands as you are in shell. You can'n make your main application process to run as root. The target device must have root libraries installed. Oct 12, 2017 at 19:36
  • 1
    @KamenStoykov So basically try reading the same file we were before, but through adb shell commands once su is granted?
    – Flyview
    Oct 14, 2017 at 23:10
  • 1
    @Flyview exactly Oct 15, 2017 at 6:34
0

Precise cpu usage since oreo seems not possible from normal app. But on Android we can guess the cpu usage from cpu frequency.

I did a small lib that permit to do that. Here is the code that hopefully is precise enough: available as a class or as a simple app.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.