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

can we get cpu usage on high api level device by add native binder service to service manager? #16

Open
jsrdzhk opened this issue Dec 3, 2020 · 2 comments
Labels

Comments

@jsrdzhk
Copy link

jsrdzhk commented Dec 3, 2020

Hello!If we add binder native service to aosp source tree,modify sepolicy and add the service into service manager.Can we get cpu usage info by service's code?For example,use popen to exec "top -m 1 -n 1" to get the cpu usage.

update:
android removed popen on bionic libc🥲

@AntonioRedondo
Copy link
Owner

Hello @jsrdzhk,

I don't think it's possible to access service CPU usage by service from my app. Neither I'm planning to implement this anytime soon.

What you could do is to clone the repo and have a look to the ActivityProcesses.java class. I think there is a chance you could modify logic there to access services and show them on screen. Although I'm not sure if this is possible at all with current Android API restrictions.

@jsrdzhk
Copy link
Author

jsrdzhk commented Dec 30, 2020

😂I copy the popen code into my native service and rename it to popen_s.After that,I can execute shell cmd such as top -m 1 -n 1 or cat /proc/cpuinfo to get cpu usage.Anyway,I will read the code of ActivityProcess.java to see if there's a more elegent way to solve this problem.

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

No branches or pull requests

2 participants