reading application usage information
As you probably know, when dialing * # * # 4 6 3 6 # * # *
a testing menu ap开发者_JAVA百科pears.
On this menu you select > application statistics in order to read application usage time and lunch count.
I want to build a smart launcher that use this information.
Can anyone point me to a source code that implement reading this information?
The source for this menu can be found within the Settings application at https://android.googlesource.com/platform/packages/apps/Settings
If you look in logcat, you will see tht entering that USSD code results in the firing of an intent:
Starting activity: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.android.settings/.TestingSettings }
Which is basically just a normal Activity launch, only for a non-launcher activity. You can probably fire that intent from a program, or by having your program dial the ussd code.
Trying to grab the data to use in a program however will be difficult. The settings application runs under the "system" uid, and is able to claim a lot of permissions not available to 3rd party apps. Those involved in changing settings are almost entirely restricted, and even a fair amount of the read permissions probably are as well.
Looking through the source of the Settings app you will be able to see how it is doing things; looking at the AndroidManifest.xml will show you what permissions it is using - unfortunately, most of what you probably want to do likely requires ones from that list which you cannot obtain for your application.
精彩评论