Android System CPU Resource related queries

Source: Internet
Author: User

Android System CPU Resource related queries


We all know that Android is based on the Linux system kernel, in the Linux system we look at the system resource consumption, a direct command line from the top command to see that there is CPU specific usage, of course, on the Android system is still retained. Top is still useful, so how do you show it in Android apps?

In the "Settings" app, there is an out-of-the-box view of CPU usage in the developer options, and the display is displayed in the UI's system layer, not activities, which is always higher than activities, and can be displayed normally in any application interface. This system layer design of the UI is pretty good. Let's look at this setting first! Such as:

/*****************************************************************************************************/
Disclaimer: The content of this blog is by http://blog.csdn.net/edsam49 original, reproduced please indicate the source, thank you!
/*****************************************************************************************************/


We can see the display of this special layer in the upper right corner of the system, the LOADAVG is the average load, and the following is a few active tasks. How does this come true?

In the android4.4 system, there is a Developmentsettings.java in the code that sets up the application, there is a show_cpu_usage_key, and tracking it can find some key code:

    private void Updatecpuusageoptions () {        updatecheckbox (mshowcpuusage, Settings.Global.getInt (Getactivity (). Getcontentresolver (),                Settings.Global.SHOW_PROCESSES, 0)! = 0);    }    private void Writecpuusageoptions () {        Boolean value = mshowcpuusage.ischecked ();        Settings.Global.putInt (Getactivity (). Getcontentresolver (),                Settings.Global.SHOW_PROCESSES, value? 1:0);        Intent service = (new Intent ())                . Setclassname ("Com.android.systemui", "Com.android.systemui.LoadAverageService ");        if (value) {            getactivity (). StartService (service);        } else {            getactivity (). StopService (service);        }    }

It is clear that the checkbox of the option is related to the setting value of the Settings.Global.SHOW_PROCESSES database, specifically, if it is hooked up, it triggers a service loadaverageservice on the boot systemui. This service is to get some CPU data, first analysis here, the next article to study some of the loadaverageservice, can not be analyzed proc below the system state file.


Android System CPU Resource related queries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.