Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Individual CPU information not loading on Android #1150

Open
jdvillal opened this issue Nov 18, 2023 · 3 comments
Open

Individual CPU information not loading on Android #1150

jdvillal opened this issue Nov 18, 2023 · 3 comments

Comments

@jdvillal
Copy link

Describe the bug
I'm porting an App to Android. I noticed that sys.cpus() functions is returning always an empty vector on Android platform.
sysinfo = "0.29.10"
The code below returns information in Windows, Linux and MacOS, but it returns an empty vector in Android.

let mut sys = System::new_all();
sys.refresh_cpu();
println!("{:?}",sys.cpus());

Calling sys.physical_core_count() works as expected, returning the actual core count. As Android is Linux, I though sys.cpus() should just work as well, but it doesn't. Is this behavior expected?

@jdvillal jdvillal added the bug label Nov 18, 2023
@jdvillal jdvillal changed the title Individual CPU information not Individual CPU information not loading on Android Nov 18, 2023
@GuillaumeGomez
Copy link
Owner

It's not and I can't test myself on android so I'd be very interested if you could send a fix!

@jdvillal
Copy link
Author

Update.

I found that this is not exactly a problem with sysinfo but rather the way it works. Refreshing CPU data depends on reading proc/stat in Linux.

However, according to https://issuetracker.google.com/issues/37140047, /proc/stat leaks side channel information about applications which could allow one application to infer the state of other applications on the device, so read access to proc/stat was removed from API Levels 26 or higher. Hence, when using a sysinfo feature that requires reading proc/stat we got:
Stderr: failed to retrieve CPU information: Os { code: 13, kind: PermissionDeionDenied, message: "Permission denied" }
Even worst, the permission required to get read access:
https://developer.android.com/reference/android/Manifest.permission#READ_LOGS is reserved for system applications only, so third party software cannot use it.

@GuillaumeGomez
Copy link
Owner

GuillaumeGomez commented Nov 18, 2023

Ah. So I suppose there is nothing that can be done here (except maybe update documentation to mention this).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants