Commit Graph

487 Commits

Author SHA1 Message Date
Kweku Adams
9d999938df Let settings query an app's minimum bucket.
Bug: 156509848
Test: manual
Change-Id: Ife3869524f93b3341fa6eb1379619142ede5ca73
2022-02-28 20:47:47 +00:00
Sudheer Shanka
d807ffe41f Add an API to bulk query broadcast response stats for all pkgs.
Bug: 217567456
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I12853fdfb8a7b70eac935cf6aab23a388d2b7005
2022-02-15 15:45:17 -08:00
Sudheer Shanka
768522945d Add a missing return statement.
Bug: 206518114
Test: manual
Change-Id: Iadb13f6b64e19fef84310aeefd39c5e4d71d1882
2022-02-02 14:03:47 -08:00
Sudheer Shanka
918d724386 Make broadcast response fg threshold state configurable.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ic28b25393b8ff7d50164535722567d1a4e34f102
2022-01-31 10:40:16 -08:00
Sudheer Shanka
d1e5fabaa9 Track broadcast dispatched event only when the app is in the bg.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ic017fff35d800a1ea9b4288421e021859f443b30
2022-01-28 16:27:57 -08:00
Sudheer Shanka
cc59c25bd1 Make broadcast response window duration configurable.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ifc6792e969304967af7019483fdd1ec242bd2a83
2022-01-28 07:22:30 +00:00
Sudheer Shanka
ea2378808e Add some debug logging to UsageStatsService.
Bug: 197654954
Test: manual
Change-Id: If693714280998c7d057b1649f6d99c57c664b1ce
2022-01-27 19:24:21 +00:00
Sudheer Shanka
7ce974c2b2 Add APIs for querying broadcast response stats.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
CTS-Coverage-Bug: 206518114
Change-Id: Idcefc143215a372a7bd786fcb2208a7c26f2f7e2
2022-01-26 08:10:56 +00:00
Sudheer Shanka
5373a2e698 Merge changes Idde09e4c,I0337b400
* changes:
  Inform UsageStatsManager about notification related events.
  Allow reporting certain events to UsageStatsManager.
2022-01-24 22:13:30 +00:00
Sudheer Shanka
4e50889197 Allow reporting certain events to UsageStatsManager.
Add methods to allow reporting broadcast-dispatched,
notification-posted, notification-updated,
notification-removed events to UsageStatsManager.

Bug: 206518114
Test: atest --test-mapping apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING
Change-Id: I0337b4004505930d21f4ef669e79ba4512b9792b
2022-01-24 09:22:43 -08:00
Neharika Jali
f29cf7bbb5 Makes constants related to cache configurable via DeviceConfig API
Bug: 214343564
Test: atest installd_cache_test, atest StorageManagerBaseTest, atest
StorageManagerTest#testComputeStorageCacheBytes

Change-Id: Ie977b8798e7169471c407621535ca1ca8feb6fec
2022-01-20 10:42:36 +00:00
Neharika Jali
967094148d Merge "In low storage, recalculate cache quotas if 2% change in total space" 2021-12-16 08:14:52 +00:00
Neharika Jali
d5af2ead56 In low storage, recalculate cache quotas if 2% change in total space
Bug: 203651230
Test: manual
Change-Id: Ie5df873f41e0bd0beca430b8e8ec51d5305bb844
2021-12-08 05:33:39 +00:00
Kweku Adams
e566f33a82 Add SystemApi to change app launch time estimates.
An SystemApis that allow a prediction app to update app launch time
estimates.

Bug: 194532703
Test: atest CtsPermissionTestCases:AppIdleStatePermissionTest
Test: atest CtsPermission2TestCases
Change-Id: I0fde220fa038f7f1f4d543a8906e92ca625bf097
2021-12-01 12:40:40 -08:00
Varun Shah
c755331c56 Merge "Update deletion conditions for a package's UsageStats." 2021-11-10 16:51:41 +00:00
Neharika Jali
044731c451 recalculate cache quotas when an app is uninstalled
Bug: 203651114
Test: manual
Change-Id: I81081a1efc6272b41babc64288592765c55ff9ac
2021-11-10 12:32:44 +00:00
Varun Shah
9af940970d Update deletion conditions for a package's UsageStats.
If a profile owner is defined for a specific user, do not delete usage
stats for a package on package deletion.

Bug: 197399948
Test: atest UserUsageStatsServiceTest
Test: atest UsageStatsTest [all]
Change-Id: I94a8e3dfca8ef4c7616f77944d61726e06043b85
2021-11-08 17:55:31 -08:00
Neharika Jali
eb406946e4 Merge "Recalculating cache quotas every 10 hours" 2021-11-08 12:10:28 +00:00
Neharika Jali
945ec1e647 Recalculating cache quotas every 10 hours
Bug: 203651640
Test: manual
Change-Id: I7d8065fcfa619b66d89e70f71f3ea726032f1995
2021-11-07 12:55:36 +00:00
Kweku Adams
4d0d1dd6e8 Revert "Revert "Add basic launch time prediction.""
This reverts commit 3785977ca6.

Reason for revert: Fixing

Change-Id: I31425d8086e3f1d1d806b84e9339d0acd3f420d4
2021-11-04 21:07:05 +00:00
Jakub Pawlowski
3785977ca6 Revert "Add basic launch time prediction."
This reverts commit cc590ac913.

Reason for revert: breakage of errorprone build

Change-Id: I0a896a2637521b36df2a132b8209f4fab23946ad
2021-11-04 16:02:21 +00:00
Kweku Adams
cc590ac913 Add basic launch time prediction.
We estimate the next app launch time by looking at the past 7 days of
usage history and assuming that the user opens the app like clockwork.
If there is at least 24 hours of usage events, then we take the earliest
ACTIVITY_RESUMED event and estimate that the app will be launched
exactly 7 days after that event. If there is less than 24 hours of
history (which would be the case for a new app), then we take the
earliest ACTIVITY_RESUMED and add 24 hours. If we don't see any launch
event in the past 7 days, then we just say the app should be launched
within a year. If we have a long estimate for an app and it is launched,
then we re-evaluate our estimate because we can now estimate a launch
within the next 7 days.

Bug: 194532703
Test: atest FrameworksMockingServicesTests:PrefetchControllerTest
Test: manually launch apps and check dumpsys for expected launch time changes
Change-Id: I9ef5fc3e3df3c2d029243b1fb8949a4bf21900db
2021-11-02 16:18:14 -07:00
Kweku Adams
72754e5847 Address small inefficiencies.
1. Don't hold the lock for validation checks that don't need it.
2. Put early returns ahead of other work when possible.

Bug: 203811598
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/usage
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/usage
Change-Id: Ic923db1534e27e0932e594b8259fe482772b8a6a
2021-10-21 14:09:07 -07:00
Varun Shah
53ba8ca01c Update mUserUnlockedStates locking and docs.
Bug: n/a
Change-Id: If210e0012ebc838183c3ca6b82ded9aae21f62b2
Test: atest UsageStatsTest
2021-10-07 22:29:24 +00:00
TreeHugger Robot
118ebd79ac Merge "Fix to obtain current updated value of available bytes" 2021-09-27 11:01:18 +00:00
Kweku Adams
4d16dcbca5 Remove redundant method.
UsageEvents.getAppStandbyBucket() and .getStandbyBucket() are the exact
same (except for the name). Remove the hidden one.

Bug: 135214188
Test: Android builds
Change-Id: I1c42228fe31e9d978df1cb5feda04a2c0a542904
2021-09-24 10:10:13 -07:00
Neharika Jali
2f882be37c Fix to obtain current updated value of available bytes
Bug: 199378831
Test: manual
Change-Id: Ibe9dc762dd1740e4fa1a34b5a7d5b23d73b25282
2021-09-10 12:31:42 +00:00
Jonathan Nguyen
85a22d00e9 Replace class with empty string for AppUsageEventOccurred Atom
Bug: 196052707
Test: atest CtsStatsdAtomHostTestCases:UidAtomTests#testAppForegroundBackground
Change-Id: Ib916c6698024070000975031c0ba401f7b41ad4c
2021-08-19 15:00:11 -07:00
TreeHugger Robot
3624ed78fd Merge "Enforce permissions check in getLastTimeAnyComponentUsed" into sc-dev am: dbdd7012bc am: 29f69e43bb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15084728

Change-Id: Ib176042519dd83be639f7fb5ee87c83297123c0f
2021-06-24 06:51:19 +00:00
Zhen Zhang
bdac90593f Enforce permissions check in getLastTimeAnyComponentUsed
Enforce the permission check for both INTERACT_ACROSS_USERS and
PACKAGE_USAGE_STATS permissions.

Bug: 191382775
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Change-Id: I1371070478306005b2b4a59a1bc794bc368ae0c4
2021-06-23 16:34:50 -07:00
Alexander Dorokhine
91ff2270dc Merge "Unhide the storage attribution API with system visibility." into sc-dev am: 48df6c6055
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14414648

Change-Id: I996a30abfa6a51d5e732e1a8849af3fae532578a
2021-05-11 18:11:01 +00:00
Alexander Dorokhine
610afe52c4 Unhide the storage attribution API with system visibility.
Bug: 179160886
Test: StorageStatsManagerLocalTest
Change-Id: I3a8994e215baff123df65d89d2d71b9e12de2af5
2021-05-10 15:59:31 -07:00
TreeHugger Robot
970d36e647 Merge "Handle STOPPED to PAUSED Usage events" into sc-dev am: 80bd76c77a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14256468

Change-Id: I67a56cded5421384f5abb83f9f50825a7c58ff32
2021-04-29 23:02:47 +00:00
TreeHugger Robot
80bd76c77a Merge "Handle STOPPED to PAUSED Usage events" into sc-dev 2021-04-29 23:02:08 +00:00
Varun Shah
e106890957 Merge "Use direct-callback alarms in AppTimeLimitController." into sc-dev am: 3cb4aa35a9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14140806

Change-Id: I0e59aff3ced22cc4367ac9709cc32a8da911ec95
2021-04-22 19:37:55 +00:00
Varun Shah
3288a170f7 Use direct-callback alarms in AppTimeLimitController.
Update SessionUsageGroups to use direct-callback alarms.

Bug: 181983817
Test: atest AppTimeLimitControllerTests
Change-Id: I73a755cb9a893952cef33c0d7cc1b2c0bf2a1318
2021-04-21 16:36:04 -07:00
Michael Wachenschwanz
289f167929 Handle STOPPED to PAUSED Usage events
UsageStatsService wrongly assumed a ACTIVITY_PAUSED event must be
preceded by a ACTIVITY_RESUMED event, but there are some scenarios where
it is possibly to go directly from STOPPED to PAUSED.

Fixes: 182007710
Test: manual (start a pip activity, turn off the screen, and turn it
back on. UsageStats logs should not report unexpected events.)
Test: atest android.app.usage.cts.UsageStatsTest

Change-Id: I609ecb574d8401ab597aa61ba7c3b9d1f4e66827
2021-04-20 16:31:15 -07:00
Suprabh Shukla
1698c0705e Merge "Suspend dialog improvememts" into sc-dev am: 9da117df72
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14150368

Change-Id: Icda2d764a05d9ec22cf7622a731cd94040e559c0
2021-04-14 00:08:56 +00:00
Suprabh Shukla
9da117df72 Merge "Suspend dialog improvememts" into sc-dev 2021-04-13 23:57:38 +00:00
TreeHugger Robot
4eab6ca7cf Merge "Use elapsed-time in AppTimeLimitController." into sc-dev am: 1ddf97e511
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14144546

Change-Id: I6c789b38875363e7accbefe013e0ff850036e816
2021-04-13 19:27:45 +00:00
Suprabh Shukla
346118543b Suspend dialog improvememts
Finishing the suspend dialog when the package for which it was shown
gets unsuspended for any reason.

Also, attributing any interaction with this dialog to the suspending
package, as the system is showing the dialog on its behalf.

Test: Manual, from an unrooted shell:
adb shell pm suspend com.android.chrome
Tap to start chrome and wait for the dialog to appear. Then:
adb shell pm unsuspend com.android.chrome
The dialog should disappear. Further,
adb shell dumpsys usagestats
should show USER_INTERACTION for com.android.shell.

Bug: 169137795
Fixes: 180336589
Change-Id: I70b6f23e2994d8802335e35932ed09209754697c
2021-04-12 19:10:31 -07:00
Varun Shah
911ef52179 Use elapsed-time in AppTimeLimitController.
Bug: 181983817
Test: atest AppTimeLimitControllerTests
Change-Id: Ia0f20475ebd54039a1a4fd3206d730a8d5649765
2021-04-09 14:46:43 -07:00
Zhen Zhang
03c15bed9d Merge "Persist user-agnostic lastTimeAnyComponentUsed in disk" into sc-dev am: bf5667bec6
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13980062

Change-Id: If340d748111b71b4c45e4e401d6c18e1fd1af2f7
2021-03-31 23:01:22 +00:00
Zhen Zhang
131f53fdf4 Persist user-agnostic lastTimeAnyComponentUsed in disk
Persist the user-agnostic lastTimeAnyComponentUsed usage stats in disk.

Bug: 183462940
Test: atest UsageStatsServiceTest
Test: atest UserStatsPersistenceTest
Test: atest CtsUsageStatsTestCases:UsageStatsTest

Change-Id: Ibe946f8e9fd9fa7d9ba546da67a6040c00e0f9ea
2021-03-31 11:27:26 -07:00
Zhen Zhang
e6fe3ee1d5 Merge "Create package-level last time usage stats for app hibernation" into sc-dev am: eed249828f
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13933089

Change-Id: I0ba03547e92c28ee32d7938beca4f30b287f807c
2021-03-31 09:20:05 +00:00
Zhen Zhang
b8b107372a Create package-level last time usage stats for app hibernation
Create a user-agnostic package-level last time used usage stats for app
hibernation. Usage is updated when USER_INTERACTION or
APP_COMPONENT_USED event reported. Also moved checkAndGetTimeLocked and
convertToSystemTimeLocked methods up to UsageStatsService class and
refactored usages.

Bug: 183142974
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Test: atest UsageStatsServiceTest
Test: atest UserUsageStatsServiceTest

Change-Id: I93d8653bb92b98af8f6b57156eb1139fbd7e562a
2021-03-30 16:16:08 -07:00
Zhen Zhang
bb4922a46d Merge "Create component used metrics in UsageStats" into sc-dev am: abb8a88e85
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13819021

Change-Id: I7534778ed762b81e80b7fd90dd50bf2c225258c9
2021-03-16 06:08:17 +00:00
Zhen Zhang
23f7206dbc Create component used metrics in UsageStats
Created a new metrics called mLastTimeComponentUsed in UsageStats.
It is persisted and loaded as other metrics.

Bug: 175829712
Test: core/tests/coretests/src/android/app/usage/UsageStatsTest
Test: cts/UsageStatsTest
Test: UsageStatsDatabaseTest
Test: UsageStatsServiceTest
Test: UsageStatsPersistenceTest
Change-Id: I10cf5c40cf5955246a6a04e96ac0352b4ed29acd
2021-03-15 14:24:08 -07:00
Mady Mellor
61edf3a56b Merge changes from topic "mm_setSuppress" into sc-dev am: e15c6dd81a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13609283

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: I52864a9ceecad3703c221d78bb24bdf6ed6fc517
2021-03-08 21:56:46 +00:00
Mady Mellor
e15c6dd81a Merge changes from topic "mm_setSuppress" into sc-dev
* changes:
  SysUI changes for setSuppressBubble
  Track locusId visibility in ShellTaskOrganizer
  Add locus id to ActivityRecord / TaskInfo
  Bubble API: suppress bubble
2021-03-08 21:27:36 +00:00