Read application usage information

As you probably know, when typing * # * # 4 6 3 6 # * # * a test menu appears.

In this menu, you select> application statistics to read the usage time of the application and the number of lunches.

I want to create an intelligent launcher that uses this information.

Can someone point me to the source code that implements reading this information?

+6
source share
1 answer

The source of this menu can be found in the Settings app at https://android.googlesource.com/platform/packages/apps/Settings

If you look in logcat, you will see that in that the USSD code triggers the intent:

Initial activity: Intent {act = android.intent.action.MAIN flg = 0x10000000 cmp = com.android.settings / .TestingSettings}

As a rule, this is a normal activity start, only for activity without a start. You can probably run this intent from a program, or if your program is typing ussd code.

Trying to capture data for use in the program will be difficult. The settings application runs under the "system" uid and may require many permissions that are not available to third-party applications. Those involved in changing the settings are almost completely limited, and even a sufficient number of read permissions are probably also there.

By looking at the source of the Settings application, you can see how it does it; looking at AndroidManifest.xml, you will show you what permissions it uses - unfortunately, most of what you probably want to do will most likely require this list, which you cannot get for your application.

0
source

Source: https://habr.com/ru/post/895421/


All Articles