android统计App应用信息相关
统计App应用信息时候用到 UsageStatsManager
, 其中的相关的数据位于/data/system/usagestats/0/下, 其下的xml文件内容如下:
<?xml version='1.0' encoding='utf-8' standalone='yes' ?>
<usagestats version="1" endTime="4682677">
<packages>
<package lastTimeActive="2430028" package="com.google.android.youtube" timeActive="2885" lastEvent="2" />
<package lastTimeActive="-1668562823445" package="com.google.android.ext.services" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.providers.telephony" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.google.android.googlequicksearchbox" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.providers.calendar" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.providers.media" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.providers.downloads" timeActive="0" lastEvent="0" />
<package lastTimeActive="2416380" package="com.google.android.apps.messaging" timeActive="3193" lastEvent="2" />
<package lastTimeActive="-1668562823445" package="com.android.defcontainer" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.carrierconfig" timeActive="0" lastEvent="0" />
<package lastTimeActive="2758914" package="com.android.launcher3" timeActive="1185171" lastEvent="2" />
<package lastTimeActive="-1668562823445" package="com.google.android.gm" timeActive="0" lastEvent="0" />
<package lastTimeActive="9672" package="com.google.android.setupwizard" timeActive="1382" lastEvent="2" />
<package lastTimeActive="-1668562823445" package="com.google.android.music" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.printspooler" timeActive="0" lastEvent="0" />
<package lastTimeActive="9981" package="com.android.sdksetup" timeActive="240" lastEvent="2" />
<package lastTimeActive="-1668562823445" package="com.android.cellbroadcastreceiver" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.keychain" timeActive="0" lastEvent="0" />
<package lastTimeActive="2411617" package="com.android.chrome" timeActive="16136" lastEvent="2" />
<package lastTimeActive="2419185" package="com.android.dialer" timeActive="1639" lastEvent="2" />
<package lastTimeActive="-1668562823445" package="com.google.android.gms" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.google.android.gsf" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.google.android.partnersetup" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.inputmethod.latin" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.google.android.calendar" timeActive="0" lastEvent="0" />
<package lastTimeActive="2759000" package="com.example.appusetime" timeActive="292064" lastEvent="1" />
<package lastTimeActive="2392748" package="com.android.settings" timeActive="58878" lastEvent="2" />
<package lastTimeActive="-1668562823445" package="com.android.phone" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.providers.blockednumber" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.providers.userdictionary" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.systemui" timeActive="0" lastEvent="0" />
<package lastTimeActive="-1668562823445" package="com.android.providers.contacts" timeActive="0" lastEvent="0" />
</packages>
<configurations>
<config lastTimeActive="139084" timeActive="2454" count="1" fs="1065353216" mcc="310" mnc="260" locales="en-US,zh-Hans-CN" touch="3" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435794" ui="17" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="136630" timeActive="130560" count="1" fs="1065353216" mcc="310" mnc="260" locales="en-US" touch="3" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435794" ui="17" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="2392031" timeActive="2248706" count="2" active="true" fs="1065353216" mcc="310" mnc="260" locales="zh-Hans-CN,en-US" touch="3" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435794" ui="17" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="2387811" timeActive="16" count="1" fs="1065353216" locales="zh-Hans-CN" touch="1" key="1" keyHid="1" hardKeyHid="2" nav="1" navHid="2" ori="1" scrLay="268435794" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="2387833" timeActive="22" count="1" fs="1065353216" locales="zh-Hans-CN" touch="1" key="1" keyHid="1" hardKeyHid="2" nav="1" navHid="2" ori="1" scrLay="268435794" ui="17" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="2387795" timeActive="6" count="1" fs="1065353216" locales="zh-Hans-CN" touch="1" key="1" keyHid="1" hardKeyHid="2" nav="1" navHid="2" ori="1" scrLay="268435810" width="411" height="731" sw="411" density="420" />
<config lastTimeActive="2390871" timeActive="3038" count="1" fs="1065353216" locales="zh-Hans-CN" touch="3" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435794" ui="17" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="36" timeActive="30" count="1" fs="1065353216" locales="en-US" touch="3" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435794" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="6070" timeActive="6034" count="1" fs="1065353216" locales="en-US" touch="3" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435794" ui="17" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="2392030" timeActive="1159" count="1" fs="1065353216" locales="zh-Hans-CN,en-US" touch="3" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435794" ui="17" width="411" height="659" sw="411" density="420" />
<config lastTimeActive="6" timeActive="8" count="1" fs="1065353216" locales="en-US" touch="1" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435810" width="411" height="731" sw="411" density="420" />
</configurations>
<event-log>
<event time="-1" package="android" type="5" fs="1065353216" locales="en-US" touch="1" key="2" keyHid="1" hardKeyHid="1" nav="2" navHid="1" ori="1" scrLay="268435810" width="411" height="731" sw="411" density="420" />
<event time="7" package="android" type="5" fs="1065353216" touch="3" scrLay="16" height="659" />
<event time="37" package="android" type="5" fs="1065353216" ui="17" />
<event time="3914" package="com.android.settings" class="com.android.settings.CryptKeeper" type="1" />
<event time="4746" package="com.android.settings" class="com.android.settings.CryptKeeper" type="2" />
<event time="4991" package="com.android.settings" class="com.android.settings.FallbackHome" type="1" />
<event time="6071" package="android" type="5" fs="1065353216" mcc="310" mnc="260" />
<event time="8157" package="com.android.settings" class="com.android.settings.FallbackHome" type="2" />
<event time="8290" package="com.google.android.setupwizard" class="com.google.android.setupwizard.SetupWizardActivity" type="1" />
<event time="9672" package="com.google.android.setupwizard" class="com.google.android.setupwizard.SetupWizardActivity" type="2" />
<event time="9741" package="com.android.sdksetup" class="com.android.sdksetup.DefaultActivity" type="1" />
<event time="9981" package="com.android.sdksetup" class="com.android.sdksetup.DefaultActivity" type="2" />
<event time="10052" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="47900" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="48078" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
<event time="51108" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="2" />
<event time="51146" package="com.android.settings" class="com.android.settings.Settings$UsageAccessSettingsActivity" type="1" />
<event time="53200" package="com.android.settings" class="com.android.settings.Settings$UsageAccessSettingsActivity" type="2" />
<event time="53210" package="com.android.settings" class="com.android.settings.SubSettings" type="1" />
<event time="56331" package="com.android.settings" class="com.android.settings.SubSettings" type="2" />
<event time="56333" package="com.android.settings" class="com.android.settings.Settings$UsageAccessSettingsActivity" type="1" />
<event time="57163" package="com.android.settings" class="com.android.settings.Settings$UsageAccessSettingsActivity" type="2" />
<event time="57165" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
<event time="58515" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="2" />
<event time="58551" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="95964" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="95971" package="com.android.settings" class="com.android.settings.Settings" type="1" />
<event time="127847" package="com.android.settings" class="com.android.settings.Settings" type="2" />
<event time="127850" package="com.android.settings" class="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" type="1" />
<event time="130444" package="com.android.settings" class="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" type="2" />
<event time="130449" package="com.android.settings" class="com.android.settings.SubSettings" type="1" />
<event time="136631" package="android" type="5" fs="1065353216" locales="en-US,zh-Hans-CN" />
<event time="139085" package="android" type="5" fs="1065353216" locales="zh-Hans-CN,en-US" />
<event time="140927" package="com.android.settings" class="com.android.settings.SubSettings" type="2" />
<event time="140940" package="com.android.settings" class="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" type="1" />
<event time="140941" package="com.android.settings" class="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" type="1" />
<event time="142541" package="com.android.settings" class="com.android.settings.Settings$InputMethodAndLanguageSettingsActivity" type="2" />
<event time="142545" package="com.android.settings" class="com.android.settings.Settings" type="1" />
<event time="142546" package="com.android.settings" class="com.android.settings.Settings" type="1" />
<event time="143464" package="com.android.settings" class="com.android.settings.Settings" type="2" />
<event time="143472" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="143524" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="162193" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="162199" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
<event time="164419" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="2" />
<event time="164484" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2387790" package="android" type="5" fs="1065353216" locales="zh-Hans-CN" touch="1" key="1" nav="1" navHid="2" scrLay="32" height="731" />
<event time="2387796" package="android" type="5" fs="1065353216" scrLay="16" height="659" />
<event time="2387812" package="android" type="5" fs="1065353216" ui="17" />
<event time="2387834" package="android" type="5" fs="1065353216" touch="3" key="2" nav="2" navHid="1" />
<event time="2390872" package="android" type="5" fs="1065353216" locales="zh-Hans-CN,en-US" />
<event time="2391339" package="com.android.settings" class="com.android.settings.FallbackHome" type="1" />
<event time="2392031" package="android" type="5" fs="1065353216" mcc="310" mnc="260" />
<event time="2392748" package="com.android.settings" class="com.android.settings.FallbackHome" type="2" />
<event time="2392800" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2395269" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="2395314" package="com.android.chrome" class="org.chromium.chrome.browser.ChromeTabbedActivity" type="1" />
<event time="2395793" package="com.android.chrome" class="org.chromium.chrome.browser.ChromeTabbedActivity" type="2" />
<event time="2395875" package="com.android.chrome" class="org.chromium.chrome.browser.firstrun.FirstRunActivity" type="1" />
<event time="2400199" package="com.android.chrome" class="org.chromium.chrome.browser.firstrun.FirstRunActivity" type="2" />
<event time="2400284" package="com.android.chrome" class="org.chromium.chrome.browser.ChromeTabbedActivity" type="1" />
<event time="2411617" package="com.android.chrome" class="org.chromium.chrome.browser.ChromeTabbedActivity" type="2" />
<event time="2411665" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2413170" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="2413178" package="com.google.android.apps.messaging" class="com.google.android.apps.messaging.ui.conversationlist.ConversationListActivity" type="1" />
<event time="2415313" package="com.google.android.apps.messaging" class="com.google.android.apps.messaging.ui.conversationlist.ConversationListActivity" type="2" />
<event time="2415322" package="com.google.android.apps.messaging" class="com.google.android.apps.messaging.ui.conversation.ConversationActivity" type="1" />
<event time="2416380" package="com.google.android.apps.messaging" class="com.google.android.apps.messaging.ui.conversation.ConversationActivity" type="2" />
<event time="2416418" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2417515" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="2417546" package="com.android.dialer" class="com.android.dialer.DialtactsActivity" type="1" />
<event time="2419185" package="com.android.dialer" class="com.android.dialer.DialtactsActivity" type="2" />
<event time="2419209" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2427116" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="2427122" package="com.google.android.youtube" class="com.google.android.apps.youtube.app.application.Shell$HomeActivity" type="1" />
<event time="2427157" package="com.google.android.youtube" class="com.google.android.apps.youtube.app.application.Shell$HomeActivity" type="2" />
<event time="2427178" package="com.google.android.youtube" class="com.google.android.apps.youtube.app.WatchWhileActivity" type="1" />
<event time="2430028" package="com.google.android.youtube" class="com.google.android.apps.youtube.app.WatchWhileActivity" type="2" />
<event time="2430064" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2437809" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="2437848" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
<event time="2636778" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="2" />
<event time="2636783" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2637910" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2637916" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2646375" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2646381" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2648397" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2648400" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
<event time="2650720" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="2" />
<event time="2650724" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2653518" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2653523" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2655005" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2655013" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2656294" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2656298" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2657398" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2657402" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2658447" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2658451" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2660254" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2660261" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="1" />
<event time="2663232" package="com.example.appusetime" class="com.example.appusetime.ui.UseTimeDetailActivity" type="2" />
<event time="2663236" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
<event time="2665190" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="2" />
<event time="2665241" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2697192" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="2697230" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
<event time="2755412" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="2" />
<event time="2755418" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="1" />
<event time="2758914" package="com.android.launcher3" class="com.android.launcher3.Launcher" type="2" />
<event time="2759000" package="com.example.appusetime" class="com.example.appusetime.ui.MainActivity" type="1" />
</event-log>
</usagestats>