I want to get cpu usage of the phone and then draw on PC.
I want to do like this:
First, run a background process in the phone which caculate the CPU usage and show in terminal.
Second, use adb commnad to get the terminal output.
Finally, draw curve with data.
I'm confused wheather it will work normally without big latency. At first, I want to put the cpu usage into a file, and use command of 'adb pull' to pull the file, then read the file and draw. I thought this may cause big latency.
Does anyone could help me?
Thanks. James.
To run the command just type adb reboot-bootloader in the command line and to boot the device in recovery just type adb reboot recovery.
I'm not entirely sure if that is what you are trying to achieve but you can use:
adb shell
to access the shell prompt of the device and run commands from there.
See: http://developer.android.com/tools/help/adb.html#shellcommands
adb logcat
to get the live log stream from the device. You can use filters etc to adjust the output to what you need.
See: http://developer.android.com/tools/help/adb.html#logcat
Write an Android application write to a file, for sample: cpu_usage.txt
Use LogCat to get output: adb shell cat /path_to_your_file/cpu_usage.txt
Parse the output from command line, then draw it on the graph. High latency? Nope.
Edit:
Ok, if you get root
permission, just execute the command as you wish, for example,
C:\>adb shell top -m -d 1 -n 1 > C:\top_result.txt
Check out the result at: C:\top_result.txt
.
Also, as I read your message, you say something like socket
, if I were you, I would never use it, because it always causes high latency.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With